/** * A long-term, persistent, globally unique identifier for this source. * * @param persistentId A long-term, persistent, globally unique identifier for this source. */ @JsonIgnore @org.codehaus.jackson.annotate.JsonIgnore public void setPersistentId(URI persistentId) { if (this.identifiers == null) { this.identifiers = new ArrayList<Identifier>(); } //clear out any other primary ids. Iterator<Identifier> it = this.identifiers.iterator(); while (it.hasNext()) { if (IdentifierType.Persistent.equals(it.next().getKnownType())) { it.remove(); } } Identifier identifier = new Identifier(); identifier.setKnownType(IdentifierType.Persistent); identifier.setValue(persistentId); this.identifiers.add(identifier); }
/** * Build up this identifier with a type. * @param type The type. * @return this. */ public Identifier type(URI type) { setType(type); return this; }
/** * The enum referencing a known identifier type. * * @return The enum referencing a known identifier type, or {@link org.gedcomx.types.IdentifierType#OTHER} if not known. */ @XmlTransient @JsonIgnore @org.codehaus.jackson.annotate.JsonIgnore public IdentifierType getKnownType() { return getType() == null ? null : IdentifierType.fromQNameURI(getType()); }
if (childAndParentsRelationship.getIdentifiers() != null) { for (Identifier identifier : childAndParentsRelationship.getIdentifiers()) { if (identifier.getKnownType() == IdentifierType.Primary) { primaryIdentifier = identifier; break; if (primaryIdentifier != null) { fatherChildRelationship.setIdentifiers(new ArrayList<>(1)); fatherChildRelationship.getIdentifiers().add(new Identifier()); fatherChildRelationship.getIdentifiers().get(0).setType(FamilySearchIdentifierType.ChildAndParentsRelationship.toQNameURI(), true); fatherChildRelationship.getIdentifiers().get(0).setValue(primaryIdentifier.getValue()); if (primaryIdentifier != null) { motherChildRelationship.setIdentifiers(new ArrayList<>(1)); motherChildRelationship.getIdentifiers().add(new Identifier()); motherChildRelationship.getIdentifiers().get(0).setType(FamilySearchIdentifierType.ChildAndParentsRelationship.toQNameURI(), true); motherChildRelationship.getIdentifiers().get(0).setValue(primaryIdentifier.getValue());
/** * Find the long-term, persistent identifier for this subject from the list of identifiers. * * @return The long-term, persistent identifier for this subject. */ @XmlTransient @JsonIgnore @org.codehaus.jackson.annotate.JsonIgnore public URI getPersistentId() { URI identifier = null; if (this.identifiers != null) { for (Identifier id : this.identifiers) { if (IdentifierType.Persistent.equals(id.getKnownType())) { identifier = id.getValue(); break; } } } return identifier; }
/** * Create a map of local id (and "#" + id) and identifier URIs to the PlaceDescription that has that id or URL. * If there are no place descriptions, an empty (but non-null) map is returned. * @param doc - document to find place descriptions for * @return Map of local id (and "#" + id) and URI string to each PlaceDescription in the doc. */ public static Map<String, PlaceDescription> getPlaceMap(Gedcomx doc) { Map<String, PlaceDescription> map = new HashMap<String, PlaceDescription>(); if (doc.getPlaces() != null) { for (PlaceDescription placeDescription : doc.getPlaces()) { map.put(placeDescription.getId(), placeDescription); map.put("#" + placeDescription.getId(), placeDescription); if (placeDescription.getIdentifiers() != null) { for (Identifier identifier : placeDescription.getIdentifiers()) { if (identifier.getValue() != null) { map.put(identifier.getValue().toString(), placeDescription); } } } } } return map; } }
public PersonMatchResultsState updateMatchStatus(Entry entry, MatchStatus status, StateTransitionOption... options) { URI updateStatusUri = UriBuilder.fromUri(getSelfUri()).replaceQueryParam(FamilySearchOptions.STATUS, status.name().toLowerCase()).build(); ClientRequest request = createAuthenticatedRequest() .type(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE) .accept(AtomModel.ATOM_GEDCOMX_JSON_MEDIA_TYPE) .entity(new Gedcomx().person(new Person().identifier(new Identifier(entry.getId(), IdentifierType.Persistent)))) .build(updateStatusUri, HttpMethod.POST); return ((FamilySearchStateFactory)this.stateFactory).newPersonMatchResultsState(request, invoke(request, options), this.accessToken); }
/** * Build up this identifier with a value. * * @param value The value. * @return this. */ public Identifier value(URI value) { setValue(value); return this; }
/** * Build up this identifier with a type. * @param type The type. * @return this. */ public Identifier type(IdentifierType type) { setKnownType(type); return this; }
/** * Find the long-term, persistent identifier for this source from the list of identifiers. * * @return The long-term, persistent identifier for this source. */ @XmlTransient @JsonIgnore @org.codehaus.jackson.annotate.JsonIgnore public URI getPersistentId() { URI identifier = null; if (this.identifiers != null) { for (Identifier id : this.identifiers) { if (IdentifierType.Persistent.equals(id.getKnownType())) { identifier = id.getValue(); break; } } } return identifier; }
/** * Create a map of id (and "#" + id) and all identifier URI strings to SourceDescription with that ID, * to make it easier to look up SourceDescriptions that are referenced elsewhere. * @param doc - GedcomX document to create a map for. * @return map of id (and "#" + id) to SourceDescription. */ public static Map<String, SourceDescription> getSourceDescriptionMap(Gedcomx doc) { Map<String, SourceDescription> map = new HashMap<String, SourceDescription>(); if (doc.getSourceDescriptions() != null) { for (SourceDescription sourceDescription : doc.getSourceDescriptions()) { map.put(sourceDescription.getId(), sourceDescription); map.put("#" + sourceDescription.getId(), sourceDescription); if (sourceDescription.getIdentifiers() != null) { for (Identifier identifier : sourceDescription.getIdentifiers()) { if (identifier.getValue() != null) { map.put(identifier.getValue().toString(), sourceDescription); } } } } } return map; }
public Identifier(URI value, IdentifierType knownType) { this.value = value; setKnownType( knownType ); }
/** * A long-term, persistent, globally unique identifier for this subject. * * @param persistentId A long-term, persistent, globally unique identifier for this subject. */ @JsonIgnore @org.codehaus.jackson.annotate.JsonIgnore public void setPersistentId(URI persistentId) { if (this.identifiers == null) { this.identifiers = new ArrayList<Identifier>(); } //clear out any other primary ids. Iterator<Identifier> it = this.identifiers.iterator(); while (it.hasNext()) { if (IdentifierType.Persistent.equals(it.next().getKnownType())) { it.remove(); } } Identifier identifier = new Identifier(); identifier.setKnownType(IdentifierType.Persistent); identifier.setValue(persistentId); this.identifiers.add(identifier); }
public static <S extends Subject> S findSubject(List<S> items, URI ref) { if (items == null || ref == null) { return null; } String value = ref.toString(); String id = value.startsWith("#") ? value.substring(1) : null; for (S subject : items) { if (id != null && id.equals(subject.getId())) { return subject; } if (subject.getIdentifiers() != null) { for (Identifier identifier : subject.getIdentifiers()) { if (ref.equals(identifier.getValue())) { return subject; } } } } return null; }
/** * Set the value of the id type from a known identifier type. * * @param knownType The known identifier type. */ @JsonIgnore @org.codehaus.jackson.annotate.JsonIgnore public void setKnownType(IdentifierType knownType) { setType(knownType == null ? null : knownType.toQNameURI()); }
/** * Create a map of local id (and "#" + id) as well as all person identifiers to the local Person object * with that id or identifier. * @param doc - GedcomX document to create a map for. * @return map of local id, "#" + id, and all URIs for each Person in the document to that Person. */ public static Map<String, Person> getPersonMap(Gedcomx doc) { Map<String, Person> map = new HashMap<String, Person>(); if (doc.getPersons() != null) { for (Person person : doc.getPersons()) { if (person.getId() != null) { map.put(person.getId(), person); map.put("#" + person.getId(), person); } if (person.getIdentifiers() != null) { for (Identifier identifier : person.getIdentifiers()) { if (identifier.getValue() != null) { map.put(identifier.getValue().toString(), person); } } } } } return map; }
private static String getSourceDescriptionName(SourceDescription sd) { if (sd.getId() != null && sd.getId().length() > 0) { return "SourceDescription with id=" + sd.getId(); } if (sd.getAbout() != null) { return "SourceDescription with about=" + sd.getAbout().toString(); } if (sd.getIdentifiers() != null) { for (Identifier identifier : sd.getIdentifiers()) { if (identifier.getValue() != null) { return "SourceDescription for URI " + identifier.getValue().toString(); } } } if (sd.getTitle() != null) { return "SourceDescription with title " + sd.getTitle().getValue(); } if (sd.getCitation() != null) { return "SourceDescription with citation " + sd.getCitation().getValue(); } return "SourceDescription with no identifiers, title or citation"; }