@Override public double getScore(FeatureMetadatum match, FeatureMetadatum reference) { if (reference == null || match == null || !StringUtils.equals(reference.getType(), match.getType())) { // Not enough information, or different metadata types return 0; } else if (StringUtils.equals(reference.getId(), match.getId())) { // Same term return 1; } else { // Different terms return -1; } } }
@Override public int compareTo(VocabularyProperty o) { if (o == null) { // Nulls at the end return -1; } if (!(o instanceof FeatureMetadatum)) { return super.compareTo(o); } return getType().compareTo(((FeatureMetadatum) o).getType()); } }
@Override public int compareTo(VocabularyProperty o) { if (o == null) { // Nulls at the end return -1; } if (!(o instanceof FeatureMetadatum)) { return super.compareTo(o); } return getType().compareTo(((FeatureMetadatum) o).getType()); } }
@Override public double getScore() { if (this.match == null || this.reference == null || StringUtils.isEmpty(this.match.getId()) || StringUtils.isEmpty(this.reference.getId())) { return Double.NaN; } ComponentManager cm = ComponentManagerRegistry.getContextComponentManager(); FeatureMetadatumSimilarityScorer scorer = null; try { scorer = cm.getInstance(FeatureMetadatumSimilarityScorer.class, this.match.getType()); } catch (ComponentLookupException ex) { try { scorer = cm.getInstance(FeatureMetadatumSimilarityScorer.class); } catch (ComponentLookupException e) { // This should not happen return Double.NaN; } } return scorer.getScore(this.match, this.reference); }