use of org.geotoolkit.wps.xml.v200.ProcessOffering in project geotoolkit by Geomatys.
the class WPS2ProcessDescriptor method create.
public static ProcessDescriptor create(WPSProcessingRegistry registry, final String processIdentifier) throws Exception {
final ProcessOfferings offerings = registry.getClient().getDescribeProcess(Collections.singletonList(processIdentifier));
final List<ProcessOffering> offeringList = offerings.getProcessOffering();
if (offeringList == null || offeringList.isEmpty()) {
throw new RuntimeException("No process description has been found for identifier " + processIdentifier);
} else if (offeringList.size() != 1) {
throw new RuntimeException(String.format("We asked for exactly one process descriptor (%s), but we've got %d results.", processIdentifier, offeringList.size()));
}
final ProcessOffering offering = offeringList.get(0);
return create(registry, offering);
}
use of org.geotoolkit.wps.xml.v200.ProcessOffering in project geotoolkit by Geomatys.
the class WPS2ProcessDescriptor method create.
public static ProcessDescriptor create(WPSProcessingRegistry registry, ProcessOffering offering) throws IOException, JAXBException, UnsupportedParameterException {
final ProcessDescription process = offering.getProcess();
final String processIdentifier = process.getIdentifier().getValue();
final InternationalString abs;
if (process.getFirstAbstract() != null) {
abs = new DefaultInternationalString(process.getFirstAbstract());
} else {
abs = new DefaultInternationalString("");
}
final InternationalString displayName;
if (process.getFirstTitle() != null) {
displayName = new DefaultInternationalString(process.getFirstTitle());
} else {
displayName = new DefaultInternationalString("");
}
final List<GeneralParameterDescriptor> inputLst = new ArrayList<>();
final List<GeneralParameterDescriptor> outputLst = new ArrayList<>();
for (final InputDescription input : process.getInputs()) {
inputLst.add(toDescriptor(processIdentifier, input));
}
for (final OutputDescription outputDesc : process.getOutputs()) {
outputLst.add(toDescriptor(processIdentifier, outputDesc));
}
final ParameterDescriptorGroup inputs = new ParameterBuilder().addName("inputs").createGroup(inputLst.toArray(new GeneralParameterDescriptor[inputLst.size()]));
final ParameterDescriptorGroup outputs = new ParameterBuilder().addName("ouptuts").createGroup(outputLst.toArray(new GeneralParameterDescriptor[outputLst.size()]));
return new WPS2ProcessDescriptor(offering, processIdentifier, registry, abs, displayName, inputs, outputs);
}
use of org.geotoolkit.wps.xml.v200.ProcessOffering in project geotoolkit by Geomatys.
the class WPS2Process method setExecutionMode.
@Override
public void setExecutionMode(final Execute.Mode executionMode) {
final ProcessOffering offering = desc.getOffering();
boolean isCompatible = WPSUtilities.testCompatibility(offering, executionMode);
if (isCompatible) {
this.executionMode = executionMode;
} else {
throw new IllegalArgumentException(String.format("%s mode is not compatible with available job control options: %s", executionMode, Arrays.toString(offering.getJobControlOptions().toArray())));
}
}
use of org.geotoolkit.wps.xml.v200.ProcessOffering in project geotoolkit by Geomatys.
the class WPSProcessingRegistry method getDescriptor.
@Override
public ProcessDescriptor getDescriptor(final String name) throws NoSuchIdentifierException {
checkDescriptors(false);
Object desc = descriptors.get(name);
// if the process has been added after the registry start.
if (desc == null && dynamicLoading) {
try {
desc = checkDescriptor(name);
} catch (Exception ex) {
LOGGER.log(Level.WARNING, ex.getMessage());
throw new NoSuchIdentifierException("No process descriptor for name :" + name, name);
}
}
if (desc instanceof ProcessDescriptor) {
return (ProcessDescriptor) desc;
}
final ProcessDescriptor pd;
if (desc == null) {
throw new NoSuchIdentifierException("No process descriptor for name :" + name, name);
} else if (desc instanceof ProcessOffering) {
try {
pd = WPS2ProcessDescriptor.create(this, (ProcessOffering) desc);
} catch (IOException ex) {
throw new UncheckedIOException(ex);
} catch (JAXBException | UnsupportedParameterException ex) {
throw new RuntimeException(ex);
}
} else if (desc instanceof ProcessSummary) {
try {
pd = toProcessDescriptor(((ProcessSummary) desc).getIdentifier().getValue());
} catch (UnsupportedParameterException ex) {
throw new RuntimeException(ex.getMessage(), ex);
} catch (Throwable ex) {
throw new RuntimeException(ex.getMessage(), ex);
}
} else
throw new UnsupportedOperationException("Cannot work with " + desc.getClass());
descriptors.put(pd.getIdentifier().getCode(), pd);
return pd;
}
Aggregations