Search in sources :

Example 1 with MDMetadataType

use of org.isotc211._2005.gmd.MDMetadataType in project ARLAS-server by gisaia.

the class GetRecordsByIdHandler method getMDMetadaTypeResponse.

public GetRecordByIdResponse getMDMetadaTypeResponse(List<CollectionReference> collections, ElementSetName elementSetName) throws OGCException {
    if (collections.size() > 0) {
        GetRecordByIdResponse getRecordByIdResponse = new GetRecordByIdResponse();
        switch(elementSetName) {
            case brief:
                MDMetadataType briefMDMetadata = MDMetadataBuilder.getBriefMDMetadata(collections.get(0));
                getRecordByIdResponse.getMdMetadata().add(briefMDMetadata);
                break;
            case summary:
                MDMetadataType summaryMDMetadata = MDMetadataBuilder.getSummaryMDMetadata(collections.get(0), cswHandler.ogcConfiguration, cswHandler.inspireConfiguration, cswHandler.baseUri);
                getRecordByIdResponse.getMdMetadata().add(summaryMDMetadata);
                break;
            case full:
                MDMetadataType fullMDMetadata = MDMetadataBuilder.getFullMDMetadata(collections.get(0), cswHandler.ogcConfiguration, cswHandler.inspireConfiguration, cswHandler.baseUri);
                getRecordByIdResponse.getMdMetadata().add(fullMDMetadata);
                break;
            default:
                MDMetadataType defaultMDMetadata = MDMetadataBuilder.getSummaryMDMetadata(collections.get(0), cswHandler.ogcConfiguration, cswHandler.inspireConfiguration, cswHandler.baseUri);
                getRecordByIdResponse.getMdMetadata().add(defaultMDMetadata);
                break;
        }
        return getRecordByIdResponse;
    } else {
        throw new OGCException(OGCExceptionCode.NOT_FOUND, "Document not Found", "id", Service.CSW);
    }
}
Also used : MDMetadataType(org.isotc211._2005.gmd.MDMetadataType) OGCException(io.arlas.server.ogc.common.exceptions.OGC.OGCException)

Example 2 with MDMetadataType

use of org.isotc211._2005.gmd.MDMetadataType in project ARLAS-server by gisaia.

the class GetRecordsHandler method getCSWGetRecordsResponse.

public GetRecordsResponseType getCSWGetRecordsResponse(List<CollectionReference> collections, ElementSetName elementSetName, int startPosition, long recordsMatched, String[] elements, String outputSchema) throws DatatypeConfigurationException {
    GetRecordsResponseType getRecordsResponseType = new GetRecordsResponseType();
    SearchResultsType searchResultType = new SearchResultsType();
    RequestStatusType searchStatus = new RequestStatusType();
    GregorianCalendar c = new GregorianCalendar();
    c.setTime(new Date());
    XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
    searchStatus.setTimestamp(date);
    getRecordsResponseType.setSearchStatus(searchStatus);
    switch(elementSetName) {
        case brief:
            collections.forEach(collectionReference -> {
                if (outputSchema != null && outputSchema.equals(CSWConstant.SUPPORTED_CSW_OUTPUT_SCHEMA[2])) {
                    MDMetadataType briefMDMetadata = MDMetadataBuilder.getBriefMDMetadata(collectionReference);
                    searchResultType.getMDMetadata().add(briefMDMetadata);
                } else {
                    BriefRecordType briefRecord = RecordBuilder.getBriefResult(collectionReference, elements, cswHandler.inspireConfiguration.enabled);
                    JAXBElement<BriefRecordType> briefRecordType = cswHandler.cswFactory.createBriefRecord(briefRecord);
                    searchResultType.getAbstractRecord().add(briefRecordType);
                }
            });
            break;
        case summary:
            collections.forEach(collectionReference -> {
                if (outputSchema != null && outputSchema.equals(CSWConstant.SUPPORTED_CSW_OUTPUT_SCHEMA[2])) {
                    try {
                        MDMetadataType summaryMDMetadata = MDMetadataBuilder.getSummaryMDMetadata(collectionReference, cswHandler.ogcConfiguration, cswHandler.inspireConfiguration, cswHandler.baseUri);
                        searchResultType.getMDMetadata().add(summaryMDMetadata);
                    } catch (OGCException e) {
                        throw new RuntimeException(e);
                    }
                } else {
                    SummaryRecordType summaryRecord = RecordBuilder.getSummaryResult(collectionReference, elements, cswHandler.baseUri, cswHandler.inspireConfiguration.enabled);
                    JAXBElement<SummaryRecordType> summaryRecordType = cswHandler.cswFactory.createSummaryRecord(summaryRecord);
                    searchResultType.getAbstractRecord().add(summaryRecordType);
                }
            });
            break;
        case full:
            collections.forEach(collectionReference -> {
                if (outputSchema != null && outputSchema.equals(CSWConstant.SUPPORTED_CSW_OUTPUT_SCHEMA[2])) {
                    try {
                        MDMetadataType summaryMDMetadata = MDMetadataBuilder.getFullMDMetadata(collectionReference, cswHandler.ogcConfiguration, cswHandler.inspireConfiguration, cswHandler.baseUri);
                        searchResultType.getMDMetadata().add(summaryMDMetadata);
                    } catch (OGCException e) {
                        throw new RuntimeException(e);
                    }
                } else {
                    RecordType record = RecordBuilder.getFullResult(collectionReference, elements, cswHandler.baseUri, cswHandler.inspireConfiguration.enabled);
                    JAXBElement<RecordType> recordType = cswHandler.cswFactory.createRecord(record);
                    searchResultType.getAbstractRecord().add(recordType);
                }
            });
            break;
        default:
            collections.forEach(collectionReference -> {
                if (outputSchema != null && outputSchema.equals(CSWConstant.SUPPORTED_CSW_OUTPUT_SCHEMA[2])) {
                    try {
                        MDMetadataType summaryMDMetadata = MDMetadataBuilder.getSummaryMDMetadata(collectionReference, cswHandler.ogcConfiguration, cswHandler.inspireConfiguration, cswHandler.baseUri);
                        searchResultType.getMDMetadata().add(summaryMDMetadata);
                    } catch (OGCException e) {
                        throw new RuntimeException(e);
                    }
                } else {
                    SummaryRecordType summaryRecord = RecordBuilder.getSummaryResult(collectionReference, elements, cswHandler.baseUri, cswHandler.inspireConfiguration.enabled);
                    JAXBElement<SummaryRecordType> summaryRecordType = cswHandler.cswFactory.createSummaryRecord(summaryRecord);
                    searchResultType.getAbstractRecord().add(summaryRecordType);
                }
            });
            break;
    }
    getRecordsResponseType.setSearchResults(searchResultType);
    searchResultType.setNextRecord(BigInteger.valueOf(startPosition + collections.size() + 1));
    searchResultType.setNumberOfRecordsReturned(BigInteger.valueOf(collections.size()));
    searchResultType.setNumberOfRecordsMatched(BigInteger.valueOf(recordsMatched));
    return getRecordsResponseType;
}
Also used : MDMetadataType(org.isotc211._2005.gmd.MDMetadataType) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Date(java.util.Date) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) OGCException(io.arlas.server.ogc.common.exceptions.OGC.OGCException)

Example 3 with MDMetadataType

use of org.isotc211._2005.gmd.MDMetadataType in project geo-platform by geosdi.

the class CatalogGetRecordByIdTest method testOutputGmd.

@Ignore(value = "ID REQUEST DOESN'T EXIST")
@Test
public void testOutputGmd() throws Exception {
    CatalogGetRecordByIdRequest<GetRecordByIdResponseType> request = serverConnector.createGetRecordByIdRequest();
    request.setId("7e418dac-3764-4290-b8ac-47c9ac2a12af");
    request.setElementSetType(ElementSetType.FULL.value());
    request.setOutputSchema(OutputSchema.GMD);
    GetRecordByIdResponseType response = request.getResponse();
    assertEquals(false, response.isSetAbstractRecord());
    assertEquals(true, response.isSetAny());
    List<Object> any = response.getAny();
    assertEquals(1, any.size());
    JAXBElement element = ((JAXBElement) any.get(0));
    MDMetadataType metadata = (MDMetadataType) element.getValue();
    Assert.assertNotNull(metadata);
    logger.info("FULL METADATA @@@@@@@@@@@@@@@@@@@@@@@@@@@ {}", metadata);
}
Also used : MDMetadataType(org.geosdi.geoplatform.xml.iso19139.v20070417.gmd.MDMetadataType) JAXBElement(javax.xml.bind.JAXBElement) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with MDMetadataType

use of org.isotc211._2005.gmd.MDMetadataType in project geo-platform by geosdi.

the class CatalogGetRecordByIdTest method testOutputGmdIspra.

@Ignore(value = "Catalog is DOWN")
@Test
public void testOutputGmdIspra() throws Exception {
    URL url = new URL(ISPRA_URL);
    GPCatalogConnectorStore connector = GPCSWConnectorBuilder.newConnector().withServerUrl(url).build();
    CatalogGetRecordByIdRequest<GetRecordByIdResponseType> request = connector.createGetRecordByIdRequest();
    request.setId("{D499D5B8-13A5-43B2-B4FA-9FD2AA519F90}");
    request.setElementSetType(ElementSetType.FULL.value());
    request.setOutputSchema(OutputSchema.GMD);
    GetRecordByIdResponseType response = request.getResponse();
    assertEquals(false, response.isSetAbstractRecord());
    assertEquals(true, response.isSetAny());
    List<Object> any = response.getAny();
    assertEquals(1, any.size());
    JAXBElement element = ((JAXBElement) any.get(0));
    MDMetadataType metadata = (MDMetadataType) element.getValue();
    Assert.assertNotNull(metadata);
    logger.info("FULL METADATA @@@@@@@@@@@@@@@@@@@@@@@@@@@ {}", metadata);
}
Also used : MDMetadataType(org.geosdi.geoplatform.xml.iso19139.v20070417.gmd.MDMetadataType) JAXBElement(javax.xml.bind.JAXBElement) URL(java.net.URL) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with MDMetadataType

use of org.isotc211._2005.gmd.MDMetadataType in project arctic-sea by 52North.

the class Iso19139GmdEncoder method encodeMDMetadata.

private XmlObject encodeMDMetadata(MDMetadata mdMetadata, EncodingContext context) throws EncodingException {
    MDMetadataType mdmt = MDMetadataType.Factory.newInstance(getXmlOptions());
    encodeAbstractObject(mdmt, mdMetadata);
    // add contacts
    for (Referenceable<CiResponsibleParty> contact : mdMetadata.getContact()) {
        if (contact.isReference()) {
            CIResponsiblePartyPropertyType cirppt = CIResponsiblePartyPropertyType.Factory.newInstance(getXmlOptions());
            cirppt.setHref(contact.getReference().getHref().get().toString());
            if (contact.getReference().getTitle().isPresent()) {
                cirppt.setTitle(contact.getReference().getTitle().get());
            }
            if (contact.getReference().getRole().isPresent()) {
                cirppt.setRole(contact.getReference().getRole().get());
            }
            return cirppt;
        } else if (!contact.isAbsent()) {
            mdmt.addNewContact().set(encodeResponsibleParty(contact.getInstance().get(), EncodingContext.of(XmlBeansEncodingFlags.PROPERTY_TYPE, true)));
        }
    }
    // add dateStamp
    mdmt.addNewDateStamp().setDateTime(mdMetadata.getDateStamp().toCalendar(Locale.ROOT));
    // add identificationInfo
    for (Referenceable<AbstractMDIdentification> identificationInfo : mdMetadata.getIdentificationInfo()) {
        if (identificationInfo.isReference()) {
            MDIdentificationPropertyType mdipt = mdmt.addNewIdentificationInfo();
            mdipt.setHref(identificationInfo.getReference().getHref().get().toString());
            if (identificationInfo.getReference().getTitle().isPresent()) {
                mdipt.setTitle(identificationInfo.getReference().getTitle().get());
            }
            if (identificationInfo.getReference().getRole().isPresent()) {
                mdipt.setRole(identificationInfo.getReference().getRole().get());
            }
        } else if (!identificationInfo.isAbsent()) {
            mdmt.addNewIdentificationInfo().set(encode(identificationInfo.getInstance().get(), EncodingContext.of(XmlBeansEncodingFlags.PROPERTY_TYPE)));
        // TODO substitution???
        }
    }
    // TODO all other optional elements if required
    if (context.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
        MDMetadataPropertyType mdmpt = MDMetadataPropertyType.Factory.newInstance(getXmlOptions());
        mdmpt.setMDMetadata(mdmt);
        return mdmpt;
    } else if (context.has(XmlBeansEncodingFlags.DOCUMENT)) {
        MDMetadataDocument mdmd = MDMetadataDocument.Factory.newInstance(getXmlOptions());
        mdmd.setMDMetadata(mdmt);
        return mdmd;
    }
    return mdmt;
}
Also used : CiResponsibleParty(org.n52.shetland.iso.gmd.CiResponsibleParty) AbstractMDIdentification(org.n52.shetland.iso.gmd.AbstractMDIdentification) MDMetadataType(org.isotc211.x2005.gmd.MDMetadataType) CIResponsiblePartyPropertyType(org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType) MDMetadataPropertyType(org.isotc211.x2005.gmd.MDMetadataPropertyType) MDIdentificationPropertyType(org.isotc211.x2005.gmd.MDIdentificationPropertyType) MDMetadataDocument(org.isotc211.x2005.gmd.MDMetadataDocument)

Aggregations

MDMetadataType (org.geosdi.geoplatform.xml.iso19139.v20070417.gmd.MDMetadataType)3 Ignore (org.junit.Ignore)3 Test (org.junit.Test)3 OGCException (io.arlas.server.ogc.common.exceptions.OGC.OGCException)2 URL (java.net.URL)2 JAXBElement (javax.xml.bind.JAXBElement)2 MDMetadataType (org.isotc211._2005.gmd.MDMetadataType)2 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 CIResponsiblePartyPropertyType (org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType)1 MDIdentificationPropertyType (org.isotc211.x2005.gmd.MDIdentificationPropertyType)1 MDMetadataDocument (org.isotc211.x2005.gmd.MDMetadataDocument)1 MDMetadataPropertyType (org.isotc211.x2005.gmd.MDMetadataPropertyType)1 MDMetadataType (org.isotc211.x2005.gmd.MDMetadataType)1 AbstractMDIdentification (org.n52.shetland.iso.gmd.AbstractMDIdentification)1 CiResponsibleParty (org.n52.shetland.iso.gmd.CiResponsibleParty)1