@Test public void testCalculateValue() throws CalculationException { String nsr_id = "11E0A704FE3"; String nsr_parent_id = "E0CCED34D8E"; Taxon taxon = new Taxon(); SourceSystem sourceSystem = SourceSystem.NSR; taxon.setSourceSystem(sourceSystem); taxon.setSourceSystemId(nsr_id); taxon.setId(nsr_id + "@" + SourceSystem.NSR.getCode()); taxon.setSourceSystemParentId(nsr_parent_id); taxon.setTaxonRank("species"); List<ScientificName> synonyms = new ArrayList<>(); ScientificName synonym01 = new ScientificName(); synonym01.setFullScientificName("Sagra purpurea (Horn)"); synonym01.setTaxonomicStatus(TaxonomicStatus.SYNONYM); synonyms.add(synonym01); ScientificName synonym02 = new ScientificName(); synonym02.setFullScientificName("Sagra purpurea foo"); synonyms.add(synonym02); taxon.setSynonyms(synonyms); DocumentFlattener df = new DocumentFlattener(new Path("synonyms"), 1); List<EntityObject> entities = df.flatten(taxon); SynonymIdCalculator calculator = new SynonymIdCalculator(); EntityObject entity = entities.get(0); long expected = 0xFFFFFE18DB5D1292L; assertEquals("01", Long.toHexString(expected).toUpperCase(), calculator.calculateValue(entity)); entity = entities.get(1); expected = 0xFFFFFFF0F17D1C0BL; assertEquals("02", Long.toHexString(expected).toUpperCase(), calculator.calculateValue(entity)); }
@Override public Object calculateValue(EntityObject entity) throws CalculationException { Taxon taxon = (Taxon) entity.getDocument(); ScientificName synonym = (ScientificName) entity.getEntity(); long hash = taxon.getSourceSystemId().hashCode(); hash = (hash * 31) + hash(synonym.getFullScientificName()); if (synonym.getTaxonomicStatus() != null) { hash = (hash * 31) + synonym.getTaxonomicStatus().ordinal() + 1; } return Long.toHexString(hash).toUpperCase(); }
SynonymIdCalculator implements ICalculator { @Override public Object calculateValue(EntityObject entity) throws CalculationException { Taxon taxon = (Taxon) entity.getDocument(); ScientificName synonym = (ScientificName) entity.getEntity(); long hash = taxon.getSourceSystemId().hashCode(); hash = (hash * 31) + hash(synonym.getFullScientificName()); if (synonym.getTaxonomicStatus() != null) { hash = (hash * 31) + synonym.getTaxonomicStatus().ordinal() + 1; } return Long.toHexString(hash).toUpperCase(); } }
SynonymIdCalculator implements ICalculator { @Override public Object calculateValue(EntityObject entity) throws CalculationException { Taxon taxon = (Taxon) entity.getDocument(); ScientificName synonym = (ScientificName) entity.getEntity(); long hash = taxon.getSourceSystemId().hashCode(); hash = (hash * 31) + hash(synonym.getFullScientificName()); if (synonym.getTaxonomicStatus() != null) { hash = (hash * 31) + synonym.getTaxonomicStatus().ordinal() + 1; } return Long.toHexString(hash).toUpperCase(); }  }
SynonymIdCalculator implements ICalculator { @Override public Object calculateValue(EntityObject entity) throws CalculationException { Taxon taxon = (Taxon) entity.getDocument(); ScientificName synonym = (ScientificName) entity.getEntity(); long hash = taxon.getSourceSystemId().hashCode(); hash = (hash * 31) + hash(synonym.getFullScientificName()); if (synonym.getTaxonomicStatus() != null) { hash = (hash * 31) + synonym.getTaxonomicStatus().ordinal() + 1; } return Long.toHexString(hash).toUpperCase(); }  @Override void initialize(Class<? extends IDocumentObject> docType, Map<String, String> args); @Override Object calculateValue(EntityObject entity); }
SynonymIdCalculator implements ICalculator { @Override public Object calculateValue(EntityObject entity) throws CalculationException { Taxon taxon = (Taxon) entity.getDocument(); ScientificName synonym = (ScientificName) entity.getEntity(); long hash = taxon.getSourceSystemId().hashCode(); hash = (hash * 31) + hash(synonym.getFullScientificName()); if (synonym.getTaxonomicStatus() != null) { hash = (hash * 31) + synonym.getTaxonomicStatus().ordinal() + 1; } return Long.toHexString(hash).toUpperCase(); }  @Override void initialize(Class<? extends IDocumentObject> docType, Map<String, String> args); @Override Object calculateValue(EntityObject entity);  }