src/main/java/org/embulk/output/mailchimp/MailChimpAbstractRecordBuffer.java in embulk-output-mailchimp-0.3.2 vs src/main/java/org/embulk/output/mailchimp/MailChimpAbstractRecordBuffer.java in embulk-output-mailchimp-0.3.3

- old
+ new

@@ -29,10 +29,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import static org.embulk.output.mailchimp.helper.MailChimpHelper.containsCaseInsensitive; +import static org.embulk.output.mailchimp.helper.MailChimpHelper.fromCommaSeparatedString; import static org.embulk.output.mailchimp.model.MemberStatus.PENDING; import static org.embulk.output.mailchimp.model.MemberStatus.SUBSCRIBED; /** * Created by thangnc on 4/14/17. @@ -293,20 +294,24 @@ final JsonNode input) { ObjectNode interests = JsonNodeFactory.instance.objectNode(); for (String category : task.getGroupingColumns().get()) { - String value = input.findValue(category).asText(); + String inputValue = input.findValue(category).asText(); + List<String> interestValues = fromCommaSeparatedString(inputValue); Map<String, InterestResponse> availableCategories = categories.get(category); // Only update user-predefined categories if replace interests != true - // Otherwise, force update all categories include user-predefined categories - if (!task.getReplaceInterests() && availableCategories.get(value) != null) { - interests.put(availableCategories.get(value).getId(), true); - } + if (!task.getReplaceInterests()) { + for (String interestValue : interestValues) { + if (availableCategories.get(interestValue) != null) { + interests.put(availableCategories.get(interestValue).getId(), true); + } + } + } // Otherwise, force update all categories include user-predefined categories else if (task.getReplaceInterests()) { for (String availableCategory : availableCategories.keySet()) { - if (availableCategory.equals(value)) { + if (interestValues.contains(availableCategory)) { interests.put(availableCategories.get(availableCategory).getId(), true); } else { interests.put(availableCategories.get(availableCategory).getId(), false); }