use of org.geotoolkit.sml.xml.v100.Capabilities in project geotoolkit by Geomatys.
the class CswXMLBindingTest method InspireUnmarshalingTest.
/**
* Test capabilities with INSPIRE extendedCapabilities unmarshalling.
*/
@Test
public void InspireUnmarshalingTest() throws Exception {
Unmarshaller unmarshaller = pool.acquireUnmarshaller();
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:Capabilities version=\"2.0.2\" xmlns:ows=\"http://www.opengis.net/ows\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\">\n" + " <ows:OperationsMetadata>\n" + " <ows:ExtendedCapabilities>\n" + " <ins:MultiLingualCapabilities xmlns:ins=\"http://www.inspire.org\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n" + " <ins:Languages>\n" + " <ins:Language>GER</ins:Language>\n" + " <ins:Language>DUT</ins:Language>\n" + " </ins:Languages>\n" + " <ins:TranslatedCapabilities>\n" + " <ins:Document xlink:href=\"http://www.somehost.com/capabilities_german.xml\" language=\"GER\"/>\n" + " <ins:Document xlink:href=\"http://www.somehost.com/capabilities_dutch.xml\" language=\"DUT\"/>\n" + " </ins:TranslatedCapabilities>\n" + " </ins:MultiLingualCapabilities>\n" + " </ows:ExtendedCapabilities>\n" + " </ows:OperationsMetadata>\n" + "</csw:Capabilities>\n";
Capabilities result = (Capabilities) unmarshaller.unmarshal(new StringReader(xml));
OperationsMetadata om = new OperationsMetadata();
LanguagesType languages = new LanguagesType(Arrays.asList("GER", "DUT"));
List<DocumentType> docs = Arrays.asList(new DocumentType("http://www.somehost.com/capabilities_german.xml", "GER"), new DocumentType("http://www.somehost.com/capabilities_dutch.xml", "DUT"));
TranslatedCapabilitiesType trans = new TranslatedCapabilitiesType(docs);
InspireCapabilitiesType inspireCapa = new InspireCapabilitiesType(languages, trans);
MultiLingualCapabilities m = new MultiLingualCapabilities();
m.setMultiLingualCapabilities(inspireCapa);
om.setExtendedCapabilities(m);
Capabilities expResult = new Capabilities(null, null, om, "2.0.2", null, null);
assertEquals(expResult, result);
pool.recycle(unmarshaller);
}
use of org.geotoolkit.sml.xml.v100.Capabilities in project geotoolkit by Geomatys.
the class WMTSBindingUtilities method unmarshall.
public static Capabilities unmarshall(final Object source, final WMTSVersion version) throws JAXBException {
Unmarshaller unMarshaller = null;
switch(version) {
case v100:
unMarshaller = WMTSMarshallerPool.getInstance().acquireUnmarshaller();
break;
default:
throw new IllegalArgumentException("unknonwed version");
}
Capabilities c = (Capabilities) unmarshall(source, unMarshaller);
WMTSMarshallerPool.getInstance().recycle(unMarshaller);
return c;
}
use of org.geotoolkit.sml.xml.v100.Capabilities in project geotoolkit by Geomatys.
the class SmlXMLFactory method convertTo101.
public static org.geotoolkit.sml.xml.v101.SensorML convertTo101(final org.geotoolkit.sml.xml.v100.SensorML sensor) {
List<org.geotoolkit.sml.xml.v101.SensorML.Member> newMembers = new ArrayList<org.geotoolkit.sml.xml.v101.SensorML.Member>();
for (Member oldMember : sensor.getMember()) {
final org.geotoolkit.sml.xml.v101.AbstractProcessType newProcess;
if (oldMember.getRealProcess() instanceof System) {
newProcess = new org.geotoolkit.sml.xml.v101.SystemType();
} else if (oldMember.getRealProcess() instanceof Component) {
newProcess = new org.geotoolkit.sml.xml.v101.ComponentType();
} else if (oldMember.getRealProcess() instanceof AbstractDataSource) {
newProcess = new org.geotoolkit.sml.xml.v101.DataSourceType();
} else if (oldMember.getRealProcess() instanceof AbstractProcessModel) {
newProcess = new org.geotoolkit.sml.xml.v101.ProcessModelType();
} else if (oldMember.getRealProcess() instanceof ComponentArray) {
newProcess = new org.geotoolkit.sml.xml.v101.ComponentArrayType();
} else {
throw new IllegalArgumentException("Other sensor type than system, component, processModel, processChain, componentArray or datasource are not yet convertible");
}
AbstractProcessType oldProcess = (AbstractProcessType) oldMember.getRealProcess();
// id
newProcess.setId(oldProcess.getId());
// name
newProcess.setName(oldProcess.getName());
// srsName
newProcess.setSrsName(oldProcess.getSrsName());
// description
newProcess.setDescription(oldProcess.getDescription());
// boundedBy
newProcess.setBoundedBy(oldProcess.getBoundedBy());
// capabilities
List<org.geotoolkit.sml.xml.v101.Capabilities> newCapabilities = new ArrayList<org.geotoolkit.sml.xml.v101.Capabilities>();
for (Capabilities oldCapa : oldProcess.getCapabilities()) {
newCapabilities.add(new org.geotoolkit.sml.xml.v101.Capabilities(oldCapa));
}
newProcess.setCapabilities(newCapabilities);
// characteristics
List<org.geotoolkit.sml.xml.v101.Characteristics> newCharacteristics = new ArrayList<org.geotoolkit.sml.xml.v101.Characteristics>();
for (Characteristics oldChar : oldProcess.getCharacteristics()) {
newCharacteristics.add(new org.geotoolkit.sml.xml.v101.Characteristics(oldChar));
}
newProcess.setCharacteristics(newCharacteristics);
// Classification
List<org.geotoolkit.sml.xml.v101.Classification> newClassification = new ArrayList<org.geotoolkit.sml.xml.v101.Classification>();
for (Classification oldClass : oldProcess.getClassification()) {
newClassification.add(new org.geotoolkit.sml.xml.v101.Classification(oldClass));
}
newProcess.setClassification(newClassification);
// Contact
List<org.geotoolkit.sml.xml.v101.Contact> newContact = new ArrayList<org.geotoolkit.sml.xml.v101.Contact>();
for (Contact oldContact : oldProcess.getContact()) {
newContact.add(new org.geotoolkit.sml.xml.v101.Contact(oldContact));
}
newProcess.setContact(newContact);
// Contact
List<org.geotoolkit.sml.xml.v101.Documentation> newDocumentation = new ArrayList<org.geotoolkit.sml.xml.v101.Documentation>();
for (Documentation oldDoc : oldProcess.getDocumentation()) {
newDocumentation.add(new org.geotoolkit.sml.xml.v101.Documentation(oldDoc));
}
newProcess.setDocumentation(newDocumentation);
// History
List<org.geotoolkit.sml.xml.v101.History> newHistory = new ArrayList<org.geotoolkit.sml.xml.v101.History>();
for (History oldhist : oldProcess.getHistory()) {
newHistory.add(new org.geotoolkit.sml.xml.v101.History(oldhist));
}
newProcess.setHistory(newHistory);
// Identification
List<org.geotoolkit.sml.xml.v101.Identification> newIdentification = new ArrayList<org.geotoolkit.sml.xml.v101.Identification>();
for (Identification oldIdent : oldProcess.getIdentification()) {
newIdentification.add(new org.geotoolkit.sml.xml.v101.Identification(oldIdent));
}
newProcess.setIdentification(newIdentification);
// keywords
List<org.geotoolkit.sml.xml.v101.Keywords> newKeywords = new ArrayList<org.geotoolkit.sml.xml.v101.Keywords>();
for (Keywords oldKeyw : oldProcess.getKeywords()) {
newKeywords.add(new org.geotoolkit.sml.xml.v101.Keywords(oldKeyw));
}
newProcess.setKeywords(newKeywords);
// legal constraint
List<org.geotoolkit.sml.xml.v101.LegalConstraint> newLegalConstraints = new ArrayList<org.geotoolkit.sml.xml.v101.LegalConstraint>();
for (LegalConstraint oldcons : oldProcess.getLegalConstraint()) {
newLegalConstraints.add(new org.geotoolkit.sml.xml.v101.LegalConstraint(oldcons));
}
newProcess.setLegalConstraint(newLegalConstraints);
// security constraint
if (oldProcess.getSecurityConstraint() != null) {
newProcess.setSecurityConstraint(new org.geotoolkit.sml.xml.v101.SecurityConstraint(oldProcess.getSecurityConstraint()));
}
// validTime
if (oldProcess.getValidTime() != null) {
newProcess.setValidTime(oldProcess.getValidTime());
}
if (oldProcess instanceof AbstractComponent) {
AbstractComponent newAbsComponent = (AbstractComponent) newProcess;
AbstractComponent oldAbsComponent = (AbstractComponent) oldProcess;
// Inputs
if (oldAbsComponent.getInputs() != null) {
newAbsComponent.setInputs(oldAbsComponent.getInputs());
}
// outputs
if (oldAbsComponent.getOutputs() != null) {
newAbsComponent.setOutputs(oldAbsComponent.getOutputs());
}
// parameters
if (oldAbsComponent.getParameters() != null) {
newAbsComponent.setParameters(oldAbsComponent.getParameters());
}
}
if (oldProcess instanceof AbstractDerivableComponent) {
org.geotoolkit.sml.xml.v101.AbstractDerivableComponentType newDerComponent = (org.geotoolkit.sml.xml.v101.AbstractDerivableComponentType) newProcess;
AbstractDerivableComponent oldDerComponent = (AbstractDerivableComponent) oldProcess;
// Position
if (oldDerComponent.getPosition() != null) {
newDerComponent.setPosition(oldDerComponent.getPosition());
}
if (oldDerComponent.getSMLLocation() != null) {
newDerComponent.setSMLLocation(oldDerComponent.getSMLLocation());
}
if (oldDerComponent.getInterfaces() != null) {
newDerComponent.setInterfaces(new org.geotoolkit.sml.xml.v101.Interfaces(oldDerComponent.getInterfaces()));
}
if (oldDerComponent.getSpatialReferenceFrame() != null) {
newDerComponent.setSpatialReferenceFrame(new org.geotoolkit.sml.xml.v101.SpatialReferenceFrame(oldDerComponent.getSpatialReferenceFrame()));
}
if (oldDerComponent.getTemporalReferenceFrame() != null) {
newDerComponent.setTemporalReferenceFrame(new org.geotoolkit.sml.xml.v101.TemporalReferenceFrame(oldDerComponent.getTemporalReferenceFrame()));
}
if (oldDerComponent.getTimePosition() != null) {
newDerComponent.setTimePosition(new org.geotoolkit.sml.xml.v101.TimePosition(oldDerComponent.getTimePosition()));
}
}
if (oldProcess instanceof AbstractPureProcess) {
org.geotoolkit.sml.xml.v101.AbstractPureProcessType newAbsPuProc = (org.geotoolkit.sml.xml.v101.AbstractPureProcessType) newProcess;
AbstractPureProcess oldAbsPuProc = (AbstractPureProcess) oldProcess;
// Inputs
if (oldAbsPuProc.getInputs() != null) {
newAbsPuProc.setInputs(new org.geotoolkit.sml.xml.v101.Inputs(oldAbsPuProc.getInputs()));
}
// outputs
if (oldAbsPuProc.getOutputs() != null) {
newAbsPuProc.setOutputs(new org.geotoolkit.sml.xml.v101.Outputs(oldAbsPuProc.getOutputs()));
}
// parameters
if (oldAbsPuProc.getParameters() != null) {
newAbsPuProc.setParameters(new org.geotoolkit.sml.xml.v101.Parameters(oldAbsPuProc.getParameters()));
}
}
if (oldMember.getRealProcess() instanceof System) {
SystemType oldSystem = (SystemType) oldMember.getRealProcess();
org.geotoolkit.sml.xml.v101.SystemType newSystem = (org.geotoolkit.sml.xml.v101.SystemType) newProcess;
// components
if (oldSystem.getComponents() != null) {
newSystem.setComponents(new org.geotoolkit.sml.xml.v101.Components(oldSystem.getComponents()));
}
// positions
if (oldSystem.getPositions() != null) {
newSystem.setPositions(new org.geotoolkit.sml.xml.v101.Positions(oldSystem.getPositions()));
}
// connections
if (oldSystem.getConnections() != null) {
newSystem.setConnections(new org.geotoolkit.sml.xml.v101.Connections(oldSystem.getConnections()));
}
} else if (oldMember.getRealProcess() instanceof Component) {
ComponentType oldComponent = (ComponentType) oldMember.getRealProcess();
org.geotoolkit.sml.xml.v101.ComponentType newCompo = (org.geotoolkit.sml.xml.v101.ComponentType) newProcess;
// method
if (oldComponent.getMethod() != null) {
newCompo.setMethod(new org.geotoolkit.sml.xml.v101.MethodPropertyType(oldComponent.getMethod()));
}
} else if (oldMember.getRealProcess() instanceof AbstractDataSource) {
DataSourceType oldDataSource = (DataSourceType) oldMember.getRealProcess();
org.geotoolkit.sml.xml.v101.DataSourceType newDataSource = (org.geotoolkit.sml.xml.v101.DataSourceType) newProcess;
if (oldDataSource.getDataDefinition() != null) {
newDataSource.setDataDefinition(new org.geotoolkit.sml.xml.v101.DataDefinition(oldDataSource.getDataDefinition()));
}
if (oldDataSource.getValues() != null) {
newDataSource.setValues(new org.geotoolkit.sml.xml.v101.Values(oldDataSource.getValues()));
}
if (oldDataSource.getObservationReference() != null) {
newDataSource.setObservationReference(new org.geotoolkit.sml.xml.v101.ObservationReference(oldDataSource.getObservationReference()));
}
} else if (oldMember.getRealProcess() instanceof AbstractProcessModel) {
ProcessModelType oldProcessModel = (ProcessModelType) oldMember.getRealProcess();
org.geotoolkit.sml.xml.v101.ProcessModelType newProcessModel = (org.geotoolkit.sml.xml.v101.ProcessModelType) newProcess;
if (oldProcessModel.getMethod() != null) {
newProcessModel.setMethod(new org.geotoolkit.sml.xml.v101.MethodPropertyType(oldProcessModel.getMethod()));
}
} else if (oldMember.getRealProcess() instanceof AbstractProcessChain) {
ProcessChainType oldProcessChain = (ProcessChainType) oldMember.getRealProcess();
org.geotoolkit.sml.xml.v101.ProcessChainType newProcessChain = (org.geotoolkit.sml.xml.v101.ProcessChainType) newProcess;
// components
if (oldProcessChain.getComponents() != null) {
newProcessChain.setComponents(new org.geotoolkit.sml.xml.v101.Components(oldProcessChain.getComponents()));
}
// connections
if (oldProcessChain.getConnections() != null) {
newProcessChain.setConnections(new org.geotoolkit.sml.xml.v101.Connections(oldProcessChain.getConnections()));
}
} else if (oldMember.getRealProcess() instanceof ComponentArray) {
// nothing to do
} else {
throw new IllegalArgumentException("Other sensor type than system ,component, processModel, processChain, componentArray or datasource are not yet convertible");
}
newMembers.add(new org.geotoolkit.sml.xml.v101.SensorML.Member(newProcess));
}
org.geotoolkit.sml.xml.v101.SensorML result = new org.geotoolkit.sml.xml.v101.SensorML("1.0.1", newMembers);
return result;
}
use of org.geotoolkit.sml.xml.v100.Capabilities in project geotoolkit by Geomatys.
the class CSWClientDemo method main.
public static void main(String[] args) throws MalformedURLException, URISyntaxException, IOException, JAXBException {
Demos.init();
final MarshallerPool pool = CSWMarshallerPool.getInstance();
final Unmarshaller um = pool.acquireUnmarshaller();
final MarshallWarnings warnings = new MarshallWarnings();
um.setProperty(XML.CONVERTER, warnings);
// build a new CSW client
final CatalogServicesClient cswServer = new CatalogServicesClient(new URL("http://catalog.data.gov/csw?"), "2.0.2");
/**
* make a getCapabilities request
*/
final GetCapabilitiesRequest getCapa = cswServer.createGetCapabilities();
InputStream is = getCapa.getResponseStream();
// unmarshall the response
Capabilities capabilities = (Capabilities) um.unmarshal(is);
// print the title of the server
System.out.println(capabilities.getServiceIdentification().getTitle());
/**
* make a getRecords request
*/
final GetRecordsRequest getRecords = cswServer.createGetRecords();
getRecords.setTypeNames("gmd:MD_Metadata");
getRecords.setConstraintLanguage("CQL");
getRecords.setConstraintLanguageVersion("1.1.0");
getRecords.setConstraint("apiso:Title like '%'");
getRecords.setElementSetName(ElementSetType.FULL);
is = getRecords.getResponseStream();
// unmarshall the response
Object obj = um.unmarshal(is);
GetRecordsResponseType response;
if (obj instanceof ExceptionReport) {
System.out.println("Error received:" + obj);
return;
} else {
response = ((JAXBElement<GetRecordsResponseType>) obj).getValue();
}
// print the number of result matching the request
System.out.println(response.getSearchResults().getNumberOfRecordsMatched());
/**
* retrieve results in dublin core
*/
getRecords.setResultType(ResultType.RESULTS);
is = getRecords.getResponseStream();
obj = um.unmarshal(is);
// unmarshall the response
if (obj instanceof ExceptionReport) {
System.out.println("Error received:" + obj);
return;
} else {
response = ((JAXBElement<GetRecordsResponseType>) obj).getValue();
}
// print the first result (Dublin core)
AbstractRecord record = (AbstractRecord) response.getSearchResults().getAny().get(0);
System.out.println(record);
/**
* retrieve results in ISO 19139
*/
getRecords.setOutputSchema("http://www.isotc211.org/2005/gmd");
is = getRecords.getResponseStream();
// unmarshall the response
obj = um.unmarshal(is);
// unmarshall the response
if (obj instanceof ExceptionReport) {
System.out.println("Error received:" + obj);
return;
} else {
response = ((JAXBElement<GetRecordsResponseType>) obj).getValue();
}
// print the first result (ISO 19139)
Metadata meta = (Metadata) response.getSearchResults().getAny().get(0);
System.out.println(meta);
final String identifier = meta.getFileIdentifier();
/**
* make a getRecordById request
*/
final GetRecordByIdRequest getRecordById = cswServer.createGetRecordById();
getRecordById.setOutputSchema("http://www.isotc211.org/2005/gmd");
getRecordById.setIds(identifier);
is = getRecordById.getResponseStream();
// unmarshall the response
obj = um.unmarshal(is);
// unmarshall the response
GetRecordByIdResponse responseBi;
if (obj instanceof ExceptionReport) {
System.out.println("Error received:" + obj);
return;
} else {
responseBi = ((JAXBElement<GetRecordByIdResponse>) obj).getValue();
}
// print the result (same as getRecords first result)
meta = (Metadata) responseBi.getAny().get(0);
System.out.println(meta);
pool.recycle(um);
}
use of org.geotoolkit.sml.xml.v100.Capabilities in project geotoolkit by Geomatys.
the class SOSClientDemo method main.
public static void main(String[] args) throws MalformedURLException, URISyntaxException, IOException, JAXBException {
Demos.init();
final MarshallerPool pool = SOSMarshallerPool.getInstance();
final Unmarshaller um = pool.acquireUnmarshaller();
// build a new SOS client
final SensorObservationServiceClient sosServer = new SensorObservationServiceClient(new URL("http://test.geomatys.com/swe_TS/WS/sos?"), "1.0.0");
/**
* make a getCapabilities request
*/
final GetCapabilitiesRequest getCapa = sosServer.createGetCapabilities();
InputStream is = getCapa.getResponseStream();
// unmarshall the response
Capabilities capabilities = (Capabilities) um.unmarshal(is);
// print the title of the server
System.out.println(capabilities.getServiceIdentification().getTitle());
// extract a sensorML identifier and outputFormat to make a describeSensor request
Operation describeSensorOperation = capabilities.getOperationsMetadata().getOperation("DescribeSensor");
String sensorID = ((ValueType) describeSensorOperation.getParameter("procedure").getAllowedValues().getValueOrRange().get(0)).getValue();
String outputFormat = ((ValueType) describeSensorOperation.getParameter("outputFormat").getAllowedValues().getValueOrRange().get(0)).getValue();
// extract a all the parameters necessary to make a getObservation request
Operation getObservationOperation = capabilities.getOperationsMetadata().getOperation("GetObservation");
String offering = ((ValueType) getObservationOperation.getParameter("offering").getAllowedValues().getValueOrRange().get(0)).getValue();
String responseFormat = ((ValueType) getObservationOperation.getParameter("responseFormat").getAllowedValues().getValueOrRange().get(0)).getValue();
String phenomenon = ((ValueType) getObservationOperation.getParameter("observedProperty").getAllowedValues().getValueOrRange().get(0)).getValue();
String procedure = ((ValueType) getObservationOperation.getParameter("procedure").getAllowedValues().getValueOrRange().get(0)).getValue();
String featureOfInterest = ((ValueType) getObservationOperation.getParameter("featureOfInterest").getAllowedValues().getValueOrRange().get(0)).getValue();
/**
* make a DescribeSensor request
*/
final DescribeSensorRequest descSensor = sosServer.createDescribeSensor();
descSensor.setSensorId(sensorID);
descSensor.setOutputFormat(outputFormat);
is = descSensor.getResponseStream();
// unmarshall the response
AbstractSensorML sensorMLResponse = (AbstractSensorML) um.unmarshal(is);
System.out.println(sensorMLResponse);
/**
* make a GetObservation request
*/
final GetObservationRequest getObs = sosServer.createGetObservation();
getObs.setOffering(offering);
getObs.setObservedProperties(phenomenon);
getObs.setProcedures(procedure);
getObs.setResponseFormat(responseFormat);
getObs.setFeatureOfInterest(new FeatureOfInterest(Arrays.asList(featureOfInterest)));
is = getObs.getResponseStream();
// unmarshall the response
ObservationCollectionType getObsResponse = (ObservationCollectionType) um.unmarshal(is);
System.out.println(getObsResponse);
pool.recycle(um);
}
Aggregations