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);
}
}
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;
}
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);
}
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);
}
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;
}
Aggregations