Package org.gedcomx.common

Examples of org.gedcomx.common.ResourceReference


    }

    // EMAIL
    assertNotNull(gedxOrganization.getEmails());
    assertEquals(gedxOrganization.getEmails().size(), 1);
    ResourceReference email = gedxOrganization.getEmails().get(0);
    assertNotNull(email.getResource());
    assertEquals(email.getResource().toString(), "mailto:info@mycorporation.com");

    // PHON and FAX
    assertNotNull(gedxOrganization.getPhones());
    assertEquals(gedxOrganization.getPhones().size(), 2);
    for (ResourceReference phone : gedxOrganization.getPhones()) {
View Full Code Here


    }

    // EMAIL
    assertNotNull(gedxOrganization.getEmails());
    assertEquals(gedxOrganization.getEmails().size(), 1);
    ResourceReference email = gedxOrganization.getEmails().get(0);
    assertNotNull(email.getResource());
    assertEquals(email.getResource().toString(), "mailto:henrycountyarchive@gmail.com");

    // PHON and FAX
    assertNotNull(gedxOrganization.getPhones());
    assertEquals(gedxOrganization.getPhones().size(), 1);
    for (ResourceReference phone : gedxOrganization.getPhones()) {
View Full Code Here

    return relationship;
  }

  private void testRelationship(Relationship relationship, RelationshipType relationshipType, String person1Id, String person2Id, int factCount) {
    assertEquals(relationship.getKnownType(), relationshipType);
    ResourceReference person1 = relationship.getPerson1();
    ResourceReference person2 = relationship.getPerson2();
    assertEquals(person1.getResource().toString(), CommonMapper.getPersonReference(person1Id));
    assertEquals(person2.getResource().toString(), CommonMapper.getPersonReference(person2Id));

    if (factCount > 0) {
      assertNotNull(relationship.getFacts());
      assertEquals(relationship.getFacts().size(), factCount);
      Fact fact0 = relationship.getFacts().get(0);
View Full Code Here

      else if (dqSource.getTitle() != null) {
        gedxSourceDescription.setTitles(Arrays.asList(new TextValue(dqSource.getTitle())));
      }

      org.gedcomx.source.SourceCitation citation = new org.gedcomx.source.SourceCitation();
      citation.setCitationTemplate(new ResourceReference(URI.create("gedcom5:citation-template")));
      citation.setFields(new ArrayList<CitationField>());
      citation.setValue("");

      if (dqSource.getAuthor() != null) {
        CitationField field = new CitationField();
        field.setName(URI.create("gedcom5:citation-template/author"));
        field.setValue(dqSource.getAuthor());
        citation.getFields().add(field);
        citation.setValue(citation.getValue() + (citation.getValue().length() > 0 ? ", " + dqSource.getAuthor() : dqSource.getAuthor()));
      }

      if (dqSource.getTitle() != null) {
        CitationField field = new CitationField();
        field.setName(URI.create("gedcom5:citation-template/title"));
        field.setValue(dqSource.getTitle());
        citation.getFields().add(field);
        citation.setValue(citation.getValue() + (citation.getValue().length() > 0 ? ", " + dqSource.getTitle() : dqSource.getTitle()));
      }

      if (dqSource.getPublicationFacts() != null) {
        CitationField field = new CitationField();
        field.setName(URI.create("gedcom5:citation-template/publication-facts"));
        field.setValue(dqSource.getPublicationFacts());
        citation.getFields().add(field);
        citation.setValue(citation.getValue() + (citation.getValue().length() > 0 ? ", " + dqSource.getPublicationFacts() : dqSource.getPublicationFacts()));
      }

      if (dqSource.getText() != null) {
        logger.warn(ConversionContext.getContext(), "GEDCOM X does not currently support text extracted from a source.");
      }

      if (dqSource.getRepositoryRef() != null) {
        Marker repoContext = ConversionContext.getDetachedMarker("REPO");
        ConversionContext.addReference(repoContext);
        try {
          RepositoryRef dqRepositoryRef = dqSource.getRepositoryRef();
          if (dqRepositoryRef.getRef() != null) {
            gedxSourceDescription.setMediator(new ResourceReference(URI.create(CommonMapper.getOrganizationReference(dqRepositoryRef.getRef()))));
            // TODO: map NOTEs as another note associated with this SourceDescription
          }
          else {
            String inlineRepoId = dqSource.getId() + ".REPO";
            Agent gedxOrganization = new Agent();
            gedxOrganization.setId(inlineRepoId);
            for (Note dqNote : dqRepositoryRef.getNotes()) {
              org.gedcomx.common.Note gedxNote = new org.gedcomx.common.Note();
              gedxNote.setText(dqNote.getValue());
              gedxOrganization.addExtensionElement(gedxNote);
            }
            for (NoteRef dqNoteRef : dqRepositoryRef.getNoteRefs()) {
              logger.warn(ConversionContext.getContext(), "Unable to associate a note ({}) with the inline-defined organization ({})", dqNoteRef.getRef(), inlineRepoId);
            }
            result.addOrganization(gedxOrganization);
            gedxSourceDescription.setMediator(new ResourceReference(URI.create(CommonMapper.getOrganizationReference(inlineRepoId))));
          }

          if (dqRepositoryRef.getCallNumber() != null) {
            CitationField field = new CitationField();
            field.setName(URI.create("gedcom5:citation-template/call-number"));
View Full Code Here

        boolean sourceDescriptionHasData = false;
        boolean sourceReferenceHasData = false;
        SourceDescription gedxSourceDescription = new SourceDescription();

        org.gedcomx.source.SourceCitation citation = new org.gedcomx.source.SourceCitation();
        citation.setCitationTemplate(new ResourceReference(URI.create("gedcom5:citation-template")));
        citation.setFields(new ArrayList<CitationField>());
        citation.setValue("");

        if (dqSource.getRef() != null) {
          gedxSourceDescription.setId(dqSource.getRef() + "-" + Long.toHexString(SequentialIdentifierGenerator.getNextId()));
View Full Code Here

   * Returns a GEDCOM X reference for the given person identifier.
   * @param gedxPersonId the identifier of the GEDCOM X person
   * @return a ResourceReference instance for the person entry of the identified person
   */
  public static ResourceReference toReference(String gedxPersonId) {
    ResourceReference reference = new ResourceReference();
    reference.setResource( new URI(getPersonReference(gedxPersonId)));
    return reference;
  }
View Full Code Here

    }

    if (phone != null || fax != null) {
      agent.setPhones(new ArrayList<ResourceReference>());
      if (phone != null) {
        ResourceReference phoneRef = new ResourceReference();
        boolean inGlobalFormat = CommonMapper.inCanonicalGlobalFormat(phone);
        String scheme = inGlobalFormat ? "tel" : "data";
        phoneRef.setResource(URI.create(UriBuilder.fromUri("").scheme(scheme).replacePath((inGlobalFormat ? "{arg1}" : ",Phone%3A%20{arg1}")).build(phone).toString()));
        agent.getPhones().add(phoneRef);
      }
      if (fax != null) {
        ResourceReference faxRef = new ResourceReference();
        boolean inGlobalFormat = CommonMapper.inCanonicalGlobalFormat(fax);
        String scheme = inGlobalFormat ? "fax" : "data";
        faxRef.setResource(URI.create(UriBuilder.fromUri("").scheme(scheme).replacePath((inGlobalFormat ? "{arg1}" : ",Fax%3A%20{arg1}")).build(fax).toString()));
        agent.getPhones().add(faxRef);
      }
    }

    if (email != null) {
      try {
        ResourceReference emailRef = new ResourceReference();
        emailRef.setResource(URI.create(java.net.URI.create("mailto:" + email).toString()));
        agent.setEmails(new ArrayList<ResourceReference>());
        agent.getEmails().add(emailRef);
      }
      catch (RuntimeException ex) {
        Marker emailContext = ConversionContext.getDetachedMarker("EMAIL");
        ConversionContext.addReference(emailContext);
        try {
          logger.warn(ConversionContext.getContext(), "Invalid value for EMAIL ({}) was ignored.", email);
        }
        finally {
          ConversionContext.removeReference(emailContext);
        }
      }
    }

    if (www != null) {
      agent.setHomepage(new ResourceReference(URI.create(www)));
    }
  }
View Full Code Here

TOP

Related Classes of org.gedcomx.common.ResourceReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.