Search in sources :

Example 11 with BriefRecordType

use of net.opengis.cat.csw._3.BriefRecordType in project geotoolkit by Geomatys.

the class CswXMLBindingTest method getRecordByIdResponseUnMarshalingTest.

/**
 * Test getRecordById request Marshalling.
 */
@Test
public void getRecordByIdResponseUnMarshalingTest() throws JAXBException {
    Unmarshaller unmarshaller = pool.acquireUnmarshaller();
    /*
         * Test marshalling csw getRecordByIdResponse v2.0.2
         */
    SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
    SimpleLiteral title = new SimpleLiteral("(JASON-1)");
    SimpleLiteral type = new SimpleLiteral("clearinghouse");
    List<SimpleLiteral> subject = new ArrayList<>();
    subject.add(new SimpleLiteral("oceans elevation NASA/JPL/JASON-1"));
    subject.add(new SimpleLiteral("oceans elevation 2"));
    SimpleLiteral modified = new SimpleLiteral("2007-11-15 21:26:49");
    SimpleLiteral Abstract = new SimpleLiteral("Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.");
    SimpleLiteral references = new SimpleLiteral("http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml");
    SimpleLiteral spatial = new SimpleLiteral("northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;");
    List<BoundingBoxType> bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    RecordType record = new RecordType(id, title, type, subject, null, modified, null, Abstract, bbox, null, null, null, spatial, references);
    BriefRecordType briefRecord = new BriefRecordType(id, title, type, bbox);
    SummaryRecordType sumRecord = new SummaryRecordType(id, title, type, bbox, subject, null, modified, Abstract);
    List<AbstractRecordType> records = new ArrayList<>();
    records.add(record);
    records.add(briefRecord);
    records.add(sumRecord);
    GetRecordByIdResponse expResult = new GetRecordByIdResponseType(records);
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:GetRecordByIdResponse xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dct=\"http://purl.org/dc/terms/\">\n" + "  <csw:Record>\n" + "    <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "    <dc:title>(JASON-1)</dc:title>\n" + "    <dc:type>clearinghouse</dc:type>\n" + "    <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + "    <dc:subject>oceans elevation 2</dc:subject>\n" + "    <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + "    <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + "    <dct:references>http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml</dct:references>\n" + "    <dct:spatial>northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;</dct:spatial>\n" + "    <ows:WGS84BoundingBox dimensions=\"2\">\n" + "      <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "      <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "    </ows:WGS84BoundingBox>\n" + "  </csw:Record>\n" + "  <csw:BriefRecord>\n" + "    <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "    <dc:title>(JASON-1)</dc:title>\n" + "    <dc:type>clearinghouse</dc:type>\n" + "    <ows:WGS84BoundingBox dimensions=\"2\">\n" + "      <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "      <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "    </ows:WGS84BoundingBox>\n" + "  </csw:BriefRecord>\n" + "  <csw:SummaryRecord>\n" + "    <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "    <dc:title>(JASON-1)</dc:title>\n" + "    <dc:type>clearinghouse</dc:type>\n" + "    <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + "    <dc:subject>oceans elevation 2</dc:subject>\n" + "    <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + "    <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + "    <ows:WGS84BoundingBox dimensions=\"2\">\n" + "      <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "      <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "    </ows:WGS84BoundingBox>\n" + "  </csw:SummaryRecord>\n" + "</csw:GetRecordByIdResponse>\n";
    GetRecordByIdResponse result = ((JAXBElement<GetRecordByIdResponse>) unmarshaller.unmarshal(new StringReader(xml))).getValue();
    assertTrue(result.getAny() instanceof List);
    List<Object> resultList = result.getAny();
    List<Object> expResultList = expResult.getAny();
    assertEquals(resultList.get(0), expResultList.get(0));
    assertEquals(resultList.get(1), expResultList.get(1));
    assertEquals(resultList.get(2), expResultList.get(2));
    assertEquals(resultList, expResultList);
    assertEquals(expResult.getAny(), result.getAny());
    assertEquals(expResult, result);
    pool.recycle(unmarshaller);
}
Also used : SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) AbstractRecordType(org.geotoolkit.csw.xml.v202.AbstractRecordType) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) GetRecordByIdResponseType(org.geotoolkit.csw.xml.v202.GetRecordByIdResponseType) AbstractRecordType(org.geotoolkit.csw.xml.v202.AbstractRecordType) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) RecordType(org.geotoolkit.csw.xml.v202.RecordType) StringReader(java.io.StringReader) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) List(java.util.List) ArrayList(java.util.ArrayList) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 12 with BriefRecordType

use of net.opengis.cat.csw._3.BriefRecordType in project ARLAS-server by gisaia.

the class RecordBuilder method getBriefResult.

public static BriefRecordType getBriefResult(CollectionReference collectionReference, String[] elements, boolean inspireIsEnabled) {
    BriefRecordType briefRecord = new BriefRecordType();
    DublinCoreElementName dublinCoreElementName = collectionReference.params.dublinCoreElementName;
    addIdentifier(briefRecord, dublinCoreElementName.identifier);
    if (elements.length == 0 || elements == null) {
        // ADD ALL field
        addTitle(briefRecord, dublinCoreElementName.title);
        if (inspireIsEnabled) {
            addType(briefRecord, RESOURCE_TYPE);
        } else {
            addType(briefRecord, dublinCoreElementName.type);
        }
        addBbox(briefRecord, dublinCoreElementName.bbox);
    } else {
        for (String element : Arrays.asList(elements)) {
            switch(element.toLowerCase()) {
                case CSWConstant.DC_FIELD_TITLE:
                    addTitle(briefRecord, dublinCoreElementName.title);
                    break;
                case CSWConstant.DC_FIELD_TYPE:
                    if (inspireIsEnabled) {
                        addType(briefRecord, RESOURCE_TYPE);
                    } else {
                        addType(briefRecord, dublinCoreElementName.type);
                    }
                    break;
                case CSWConstant.DC_FIELD_BBOX:
                    addBbox(briefRecord, dublinCoreElementName.bbox);
                    break;
            }
        }
    }
    return briefRecord;
}
Also used : DublinCoreElementName(io.arlas.server.core.model.DublinCoreElementName) BriefRecordType(net.opengis.cat.csw._3.BriefRecordType)

Example 13 with BriefRecordType

use of net.opengis.cat.csw._3.BriefRecordType in project ARLAS-server by gisaia.

the class RecordBuilder method addType.

public static void addType(AbstractRecordType abstractRecordType, String type) {
    SimpleLiteral simpleLiteral = new SimpleLiteral();
    simpleLiteral.getContent().add(type);
    switch(abstractRecordType.getClass().getSimpleName()) {
        case "BriefRecordType":
            ((BriefRecordType) abstractRecordType).setType(simpleLiteral);
            break;
        case "SummaryRecordType":
            ((SummaryRecordType) abstractRecordType).setType(simpleLiteral);
            break;
        case "RecordType":
            JAXBElement<SimpleLiteral> JAXBElementType = dcObjectFactory.createType(simpleLiteral);
            ((RecordType) abstractRecordType).getDCElement().add(JAXBElementType);
            break;
    }
}
Also used : SummaryRecordType(net.opengis.cat.csw._3.SummaryRecordType) SimpleLiteral(org.purl.dc.elements._1.SimpleLiteral) BriefRecordType(net.opengis.cat.csw._3.BriefRecordType)

Aggregations

Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 BriefRecordType (org.geotoolkit.csw.xml.v202.BriefRecordType)8 SimpleLiteral (org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral)8 BoundingBoxType (org.geotoolkit.ows.xml.v100.BoundingBoxType)8 WGS84BoundingBoxType (org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType)8 StringReader (java.io.StringReader)4 StringWriter (java.io.StringWriter)4 JAXBElement (javax.xml.bind.JAXBElement)4 Marshaller (javax.xml.bind.Marshaller)4 Unmarshaller (javax.xml.bind.Unmarshaller)4 AbstractRecordType (org.geotoolkit.csw.xml.v202.AbstractRecordType)4 RecordType (org.geotoolkit.csw.xml.v202.RecordType)4 SummaryRecordType (org.geotoolkit.csw.xml.v202.SummaryRecordType)4 Metacard (ddf.catalog.data.Metacard)3 BriefRecordType (net.opengis.cat.csw.v_2_0_2.BriefRecordType)3 SimpleLiteral (net.opengis.cat.csw.v_2_0_2.dc.elements.SimpleLiteral)3 List (java.util.List)2 BriefRecordType (net.opengis.cat.csw._3.BriefRecordType)2 InsertResultType (net.opengis.cat.csw.v_2_0_2.InsertResultType)2