Repository: incubator-unomi Updated Branches: refs/heads/master 4f1ed654b -> b02863425
UNOMI-101 : Fix issue with empty column Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/d37b0be4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/d37b0be4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/d37b0be4 Branch: refs/heads/master Commit: d37b0be4800207d197c63ac507174a930c17314e Parents: 4f1ed65 Author: Abdelkader Midani <amid...@apache.org> Authored: Thu Aug 10 01:19:03 2017 +0200 Committer: Abdelkader Midani <amid...@apache.org> Committed: Thu Aug 10 01:19:03 2017 +0200 ---------------------------------------------------------------------- .../unomi/router/core/processor/LineSplitProcessor.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/d37b0be4/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java ---------------------------------------------------------------------- diff --git a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java index dcd8374..081a9ef 100644 --- a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java +++ b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java @@ -85,7 +85,12 @@ public class LineSplitProcessor implements Processor { .withSeparator(columnSeparator.charAt(0)) .build(); + logger.debug("$$$$ : LineSplitProcessor : BODY : " + (String) exchange.getIn().getBody()); + String[] profileData = rfc4180Parser.parseLine(((String) exchange.getIn().getBody())); + + logger.debug("$$$$ : LineSplitProcessor : LINE : {}, {}, {}.", profileData[0], profileData[1], profileData[2]); + ProfileToImport profileToImport = new ProfileToImport(); profileToImport.setItemId(UUID.randomUUID().toString()); profileToImport.setItemType("profile"); @@ -95,6 +100,7 @@ public class LineSplitProcessor implements Processor { if (hasDeleteColumn && (fieldsMapping.size() > (profileData.length - 1))) { throw new BadProfileDataFormatException("The mapping does not match the number of column : line [" + ((Integer) exchange.getProperty("CamelSplitIndex") + 1) + "]", new Throwable("MAPPING_COLUMN_MATCH")); } + logger.debug("$$$$ : LineSplitProcessor : MAPPING : " + fieldsMapping.keySet()); Map<String, Object> properties = new HashMap<>(); for (String fieldMappingKey : fieldsMapping.keySet()) { PropertyType propertyType = RouterUtils.getPropertyTypeById(profileService.getAllPropertyTypes("profiles"), fieldMappingKey); @@ -104,15 +110,14 @@ public class LineSplitProcessor implements Processor { if (propertyType.getValueTypeId().equals("string") || propertyType.getValueTypeId().equals("email")) { if (BooleanUtils.isTrue(propertyType.isMultivalued())) { String multivalueArray = profileData[fieldsMapping.get(fieldMappingKey)].trim(); - if (StringUtils.isNoneBlank(multiValueDelimiter) && multiValueDelimiter.length() == 2) { + if (StringUtils.isNotBlank(multiValueDelimiter) && multiValueDelimiter.length() == 2) { multivalueArray = multivalueArray.replaceAll("\\" + multiValueDelimiter.charAt(0), "").replaceAll("\\" + multiValueDelimiter.charAt(1), ""); - multivalueArray = RouterUtils.removeQuotes(multivalueArray); } String[] valuesArray = multivalueArray.split("\\" + multiValueSeparator); properties.put(fieldMappingKey, valuesArray); } else { String singleValue = profileData[fieldsMapping.get(fieldMappingKey)].trim(); - properties.put(fieldMappingKey, RouterUtils.removeQuotes(singleValue)); + properties.put(fieldMappingKey, singleValue); } } else if (propertyType.getValueTypeId().equals("boolean")) { properties.put(fieldMappingKey, new Boolean(profileData[fieldsMapping.get(fieldMappingKey)].trim()));