@Test public void withNullInteractionType() throws StudyImporterException { final List<Map<String, String>> links = new ArrayList<>(); InteractionListener listener = new InteractionListenerWithInteractionTypeMapping(links::add, new InteractTypeMapper() { @Override public boolean shouldIgnoreInteractionType(String nameOrId) { return false; } @Override public InteractType getInteractType(String nameOrId) { return InteractType.ATE; } }, new NullImportLogger()); listener.newLink(new HashMap<String, String>() { { put(INTERACTION_TYPE_NAME, null); put(INTERACTION_TYPE_ID, null); } }); assertThat(links.size(), is(1)); assertThat(links.get(0).get(INTERACTION_TYPE_ID), is(nullValue())); assertThat(links.get(0).get(INTERACTION_TYPE_NAME), is(nullValue())); assertThat(links.get(0).get(INTERACTION_TYPE_ID_VERBATIM), is(nullValue())); assertThat(links.get(0).get(INTERACTION_TYPE_NAME_VERBATIM), is(nullValue())); }
@Override public void newLink(Map<String, String> link) throws StudyImporterException { TaxonUtil.enrichTaxonNames(link); String interactionTypeName = link.get(INTERACTION_TYPE_NAME); String interactionTypeId = link.get(INTERACTION_TYPE_ID); if (mapper.shouldIgnoreInteractionType(interactionTypeName) || mapper.shouldIgnoreInteractionType(interactionTypeId)) { if (logger != null) { logger.info(LogUtil.contextFor(link), "ignoring interaction record with interaction name [" + interactionTypeName + "]"); } } else if (mapper.shouldIgnoreInteractionType(interactionTypeId)) { if (logger != null) { logger.info(LogUtil.contextFor(link), "ignoring interaction record with interaction id [" + interactionTypeName + "]"); } } else { InteractType mappedType = null; if (interactionTypeId != null) { mappedType = mapper.getInteractType(interactionTypeId); } if (mappedType == null && interactionTypeName != null) { mappedType = mapper.getInteractType(interactionTypeName); } HashMap<String, String> properties = new HashMap<>(link); if (mappedType != null) { InteractUtil.putNotNull(properties, INTERACTION_TYPE_ID_VERBATIM, properties.get(INTERACTION_TYPE_ID)); InteractUtil.putNotNull(properties, INTERACTION_TYPE_NAME_VERBATIM, properties.get(INTERACTION_TYPE_NAME)); properties.put(INTERACTION_TYPE_ID, mappedType.getIRI()); properties.put(INTERACTION_TYPE_NAME, mappedType.getLabel()); } listener.newLink(properties); counter.incrementAndGet(); } }
InteractionListenerWithInteractionTypeMapping implements InteractionListener { @Override public void newLink(Map<String, String> link) throws StudyImporterException { TaxonUtil.enrichTaxonNames(link); String interactionTypeName = link.get(INTERACTION_TYPE_NAME); String interactionTypeId = link.get(INTERACTION_TYPE_ID); if (mapper.shouldIgnoreInteractionType(interactionTypeName) || mapper.shouldIgnoreInteractionType(interactionTypeId)) { if (logger != null) { logger.info(LogUtil.contextFor(link), "ignoring interaction record with interaction name [" + interactionTypeName + "]"); } } else if (mapper.shouldIgnoreInteractionType(interactionTypeId)) { if (logger != null) { logger.info(LogUtil.contextFor(link), "ignoring interaction record with interaction id [" + interactionTypeName + "]"); } } else { InteractType mappedType = null; if (interactionTypeId != null) { mappedType = mapper.getInteractType(interactionTypeId); } if (mappedType == null && interactionTypeName != null) { mappedType = mapper.getInteractType(interactionTypeName); } HashMap<String, String> properties = new HashMap<>(link); if (mappedType != null) { InteractUtil.putNotNull(properties, INTERACTION_TYPE_ID_VERBATIM, properties.get(INTERACTION_TYPE_ID)); InteractUtil.putNotNull(properties, INTERACTION_TYPE_NAME_VERBATIM, properties.get(INTERACTION_TYPE_NAME)); properties.put(INTERACTION_TYPE_ID, mappedType.getIRI()); properties.put(INTERACTION_TYPE_NAME, mappedType.getLabel()); } listener.newLink(properties); counter.incrementAndGet(); } } }
InteractionListenerWithInteractionTypeMapping implements InteractionListener { @Override public void newLink(Map<String, String> link) throws StudyImporterException { TaxonUtil.enrichTaxonNames(link); String interactionTypeName = link.get(INTERACTION_TYPE_NAME); String interactionTypeId = link.get(INTERACTION_TYPE_ID); if (mapper.shouldIgnoreInteractionType(interactionTypeName) || mapper.shouldIgnoreInteractionType(interactionTypeId)) { if (logger != null) { logger.info(LogUtil.contextFor(link), "ignoring interaction record with interaction name [" + interactionTypeName + "]"); } } else if (mapper.shouldIgnoreInteractionType(interactionTypeId)) { if (logger != null) { logger.info(LogUtil.contextFor(link), "ignoring interaction record with interaction id [" + interactionTypeName + "]"); } } else { InteractType mappedType = null; if (interactionTypeId != null) { mappedType = mapper.getInteractType(interactionTypeId); } if (mappedType == null && interactionTypeName != null) { mappedType = mapper.getInteractType(interactionTypeName); } HashMap<String, String> properties = new HashMap<>(link); if (mappedType != null) { InteractUtil.putNotNull(properties, INTERACTION_TYPE_ID_VERBATIM, properties.get(INTERACTION_TYPE_ID)); InteractUtil.putNotNull(properties, INTERACTION_TYPE_NAME_VERBATIM, properties.get(INTERACTION_TYPE_NAME)); properties.put(INTERACTION_TYPE_ID, mappedType.getIRI()); properties.put(INTERACTION_TYPE_NAME, mappedType.getLabel()); } listener.newLink(properties); counter.incrementAndGet(); } } InteractionListenerWithInteractionTypeMapping(InteractionListener listener,
                                                  InteractTypeMapper mapper,
                                                  ImportLogger logger); }
InteractionListenerWithInteractionTypeMapping implements InteractionListener { @Override public void newLink(Map<String, String> link) throws StudyImporterException { TaxonUtil.enrichTaxonNames(link); String interactionTypeName = link.get(INTERACTION_TYPE_NAME); String interactionTypeId = link.get(INTERACTION_TYPE_ID); if (mapper.shouldIgnoreInteractionType(interactionTypeName) || mapper.shouldIgnoreInteractionType(interactionTypeId)) { if (logger != null) { logger.info(LogUtil.contextFor(link), "ignoring interaction record with interaction name [" + interactionTypeName + "]"); } } else if (mapper.shouldIgnoreInteractionType(interactionTypeId)) { if (logger != null) { logger.info(LogUtil.contextFor(link), "ignoring interaction record with interaction id [" + interactionTypeName + "]"); } } else { InteractType mappedType = null; if (interactionTypeId != null) { mappedType = mapper.getInteractType(interactionTypeId); } if (mappedType == null && interactionTypeName != null) { mappedType = mapper.getInteractType(interactionTypeName); } HashMap<String, String> properties = new HashMap<>(link); if (mappedType != null) { InteractUtil.putNotNull(properties, INTERACTION_TYPE_ID_VERBATIM, properties.get(INTERACTION_TYPE_ID)); InteractUtil.putNotNull(properties, INTERACTION_TYPE_NAME_VERBATIM, properties.get(INTERACTION_TYPE_NAME)); properties.put(INTERACTION_TYPE_ID, mappedType.getIRI()); properties.put(INTERACTION_TYPE_NAME, mappedType.getLabel()); } listener.newLink(properties); counter.incrementAndGet(); } } InteractionListenerWithInteractionTypeMapping(InteractionListener listener,
                                                  InteractTypeMapper mapper,
                                                  ImportLogger logger); @Override void newLink(Map<String, String> link); int getNumberOfSubmittedLinks(); }
InteractionListenerWithInteractionTypeMapping implements InteractionListener { @Override public void newLink(Map<String, String> link) throws StudyImporterException { TaxonUtil.enrichTaxonNames(link); String interactionTypeName = link.get(INTERACTION_TYPE_NAME); String interactionTypeId = link.get(INTERACTION_TYPE_ID); if (mapper.shouldIgnoreInteractionType(interactionTypeName) || mapper.shouldIgnoreInteractionType(interactionTypeId)) { if (logger != null) { logger.info(LogUtil.contextFor(link), "ignoring interaction record with interaction name [" + interactionTypeName + "]"); } } else if (mapper.shouldIgnoreInteractionType(interactionTypeId)) { if (logger != null) { logger.info(LogUtil.contextFor(link), "ignoring interaction record with interaction id [" + interactionTypeName + "]"); } } else { InteractType mappedType = null; if (interactionTypeId != null) { mappedType = mapper.getInteractType(interactionTypeId); } if (mappedType == null && interactionTypeName != null) { mappedType = mapper.getInteractType(interactionTypeName); } HashMap<String, String> properties = new HashMap<>(link); if (mappedType != null) { InteractUtil.putNotNull(properties, INTERACTION_TYPE_ID_VERBATIM, properties.get(INTERACTION_TYPE_ID)); InteractUtil.putNotNull(properties, INTERACTION_TYPE_NAME_VERBATIM, properties.get(INTERACTION_TYPE_NAME)); properties.put(INTERACTION_TYPE_ID, mappedType.getIRI()); properties.put(INTERACTION_TYPE_NAME, mappedType.getLabel()); } listener.newLink(properties); counter.incrementAndGet(); } } InteractionListenerWithInteractionTypeMapping(InteractionListener listener,
                                                  InteractTypeMapper mapper,
                                                  ImportLogger logger); @Override void newLink(Map<String, String> link); int getNumberOfSubmittedLinks();  }