Search in sources :

Example 16 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class TreeNodeChildrenTest method testShowAll.

/**
 * Tests the children list with the {@link ValueExistencePolicy#ALL}.
 */
@Test
@DependsOnMethod("testReadOnlyWithMultiOccurrences")
public void testShowAll() {
    final DefaultCitation citation = metadataWithMultiOccurrences();
    final TreeNodeChildren children = create(citation, ValueExistencePolicy.ALL);
    final String[] expected = { "Some title", "First alternate title", "Second alternate title", // dates (collection)
    null, "Some edition", // edition date
    null, // identifiers (collection)
    null, // cited responsibly parties (collection)
    null, "PresentationForm[MAP_DIGITAL]", "PresentationForm[MAP_HARDCOPY]", // series
    null, "Some other details", // ISBN
    null, // ISSN
    null, // onlineResources (collection)
    null, // graphics (collection)
    null };
    assertEquals("titleProperty", -1, children.titleProperty);
    assertFalse("isEmpty()", children.isEmpty());
    assertEquals("size()", expected.length, children.size());
    assertAllNextEqual(expected, children.iterator());
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 17 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class TreeNodeTest method metadataWithHierarchy.

/**
 * Creates a metadata hierarchy to be used for the tests.
 * This method creates the following metadata:
 *
 * {@preformat text
 *   Citation
 *     ├─Title…………………………………………………………………………………………… Some title
 *     ├─Alternate title (1 of 2)………………………………………… First alternate title
 *     ├─Alternate title (2 of 2)………………………………………… Second alternate title
 *     ├─Edition……………………………………………………………………………………… Some edition
 *     ├─Cited responsible party (1 of 2)
 *     │   └─Organisation
 *     │      ├─Name…………………………………………………………………………… Some organisation
 *     │      └─Role…………………………………………………………………………… Distributor
 *     ├─Cited responsible party (2 of 2)
 *     │   └─Individual
 *     │      ├─Name…………………………………………………………………………… Some person of contact
 *     │      ├─Contact info
 *     │      │   └─Address
 *     │      │       └─Electronic mail address…… Some email
 *     │      └─Role…………………………………………………………………………… Point of contact
 *     ├─Presentation form (1 of 2)…………………………………… Map digital
 *     ├─Presentation form (2 of 2)…………………………………… map hardcopy
 *     └─Other citation details……………………………………………… Some other details
 * }
 */
static DefaultCitation metadataWithHierarchy() {
    final DefaultCitation citation = TreeNodeChildrenTest.metadataWithMultiOccurrences();
    AbstractParty party = new DefaultOrganisation("Some organisation", null, null, null);
    DefaultResponsibleParty responsibility = new DefaultResponsibleParty(Role.DISTRIBUTOR);
    responsibility.setParties(singleton(party));
    assertTrue(citation.getCitedResponsibleParties().add(responsibility));
    // Add a second responsible party with deeper hierarchy.
    final DefaultContact contact = new DefaultContact();
    final DefaultAddress address = new DefaultAddress();
    address.setElectronicMailAddresses(singleton("Some email"));
    contact.setAddresses(singleton(address));
    party = new DefaultIndividual("Some person of contact", null, contact);
    responsibility = new DefaultResponsibleParty(Role.POINT_OF_CONTACT);
    responsibility.setParties(singleton(party));
    assertTrue(citation.getCitedResponsibleParties().add(responsibility));
    return citation;
}
Also used : AbstractParty(org.apache.sis.metadata.iso.citation.AbstractParty) DefaultAddress(org.apache.sis.metadata.iso.citation.DefaultAddress) DefaultOrganisation(org.apache.sis.metadata.iso.citation.DefaultOrganisation) DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) DefaultContact(org.apache.sis.metadata.iso.citation.DefaultContact) DefaultIndividual(org.apache.sis.metadata.iso.citation.DefaultIndividual)

Example 18 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class TreeNodeTest method testNewChild.

/**
 * Tests {@link TreeNode#newChild()}.
 */
@Test
@DependsOnMethod("testGetValue")
public void testNewChild() {
    final DefaultCitation citation = metadataWithHierarchy();
    final TreeNode node = create(citation, Citation.class);
    /*
         * Ensure that we can not overwrite existing nodes.
         */
    TreeTable.Node child = node.newChild();
    child.setValue(TableColumn.IDENTIFIER, "title");
    try {
        child.setValue(TableColumn.VALUE, "A new title");
        fail("Attemps to overwrite an existing value shall fail.");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains("title"));
    }
    /*
         * Clear the title and try again. This time, it shall work.
         */
    citation.setTitle(null);
    child = node.newChild();
    child.setValue(TableColumn.IDENTIFIER, "title");
    child.setValue(TableColumn.VALUE, "A new title");
    assertTitleEquals("citation", "A new title", citation);
    assertSame(citation.getTitle(), child.getValue(TableColumn.VALUE));
    /*
         * Try adding a new element in a collection.
         * Note that the code below imply a conversion from String to InternationalString.
         */
    child = node.newChild();
    child.setValue(TableColumn.IDENTIFIER, "alternateTitle");
    child.setValue(TableColumn.VALUE, "Third alternate title");
    assertEquals(3, citation.getAlternateTitles().size());
    assertEquals("Third alternate title", child.getValue(TableColumn.VALUE).toString());
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) TreeTable(org.apache.sis.util.collection.TreeTable) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 19 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class TreeNodeTest method testGetNameForMultiOccurrences.

/**
 * Tests {@link TreeNode#getName()} on a metadata with more than one entry in collections.
 * Those names <em>shall</em> contain numbering like <cite>"(1 of 2)"</cite>.
 */
@Test
@DependsOnMethod("testGetNameForSingleton")
public void testGetNameForMultiOccurrences() {
    final DefaultCitation citation = TreeNodeChildrenTest.metadataWithMultiOccurrences();
    assertColumnContentEquals(create(citation, Citation.class), TableColumn.NAME, "Citation", "Title", "Alternate title (1 of 2)", "Alternate title (2 of 2)", "Edition", "Presentation form (1 of 2)", "Presentation form (2 of 2)", "Other citation details");
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) Citation(org.opengis.metadata.citation.Citation) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 20 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class TreeTableFormatTest method testProcessing.

/**
 * Tests the formatting of a {@link DefaultProcessing} object.
 */
@Test
public void testProcessing() {
    final DefaultCitation titled = new DefaultCitation("Some specification");
    final DefaultCitation coded = new DefaultCitation();
    final DefaultCitation untitled = new DefaultCitation();
    titled.setPresentationForms(singleton(PresentationForm.DOCUMENT_HARDCOPY));
    coded.setPresentationForms(singleton(PresentationForm.IMAGE_HARDCOPY));
    untitled.setCitedResponsibleParties(singleton(new DefaultResponsibleParty(Role.AUTHOR)));
    final DefaultProcessing processing = new DefaultProcessing();
    processing.setDocumentations(asList(titled, coded, untitled));
    final String text = format.format(processing.asTreeTable());
    assertMultilinesEquals("Processing\n" + "  ├─Documentation (1 of 3)…………… Some specification\n" + "  │   └─Presentation form……………… Document hardcopy\n" + "  ├─Documentation (2 of 3)\n" + "  │   └─Presentation form……………… Image hardcopy\n" + "  └─Documentation (3 of 3)\n" + "      └─Cited responsible party\n" + "          └─Role……………………………………… Author\n", text);
}
Also used : DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) DefaultProcessing(org.apache.sis.metadata.iso.lineage.DefaultProcessing) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Test(org.junit.Test) DefaultCitationTest(org.apache.sis.metadata.iso.citation.DefaultCitationTest)

Aggregations

DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)65 Test (org.junit.Test)35 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)32 DependsOnMethod (org.apache.sis.test.DependsOnMethod)21 InternationalString (org.opengis.util.InternationalString)14 Citation (org.opengis.metadata.citation.Citation)10 IdentifiedObject (org.opengis.referencing.IdentifiedObject)9 ImmutableIdentifier (org.apache.sis.metadata.iso.ImmutableIdentifier)5 DefaultResponsibleParty (org.apache.sis.metadata.iso.citation.DefaultResponsibleParty)5 URI (java.net.URI)3 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)3 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)3 DefaultCitationTest (org.apache.sis.metadata.iso.citation.DefaultCitationTest)3 DefaultOnlineResource (org.apache.sis.metadata.iso.citation.DefaultOnlineResource)3 ArrayList (java.util.ArrayList)2 CI_Citation (org.apache.sis.internal.jaxb.metadata.CI_Citation)2 SimpleIdentifiedObject (org.apache.sis.internal.simple.SimpleIdentifiedObject)2 SimpleIdentifier (org.apache.sis.internal.simple.SimpleIdentifier)2 DefaultCitationDate (org.apache.sis.metadata.iso.citation.DefaultCitationDate)2 DefaultIndividual (org.apache.sis.metadata.iso.citation.DefaultIndividual)2