Search in sources :

Example 1 with ProcessOffering

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);
}
Also used : ProcessOfferings(org.geotoolkit.wps.xml.v200.ProcessOfferings) ProcessOffering(org.geotoolkit.wps.xml.v200.ProcessOffering)

Example 2 with ProcessOffering

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);
}
Also used : ProcessDescription(org.geotoolkit.wps.xml.v200.ProcessDescription) OutputDescription(org.geotoolkit.wps.xml.v200.OutputDescription) InternationalString(org.opengis.util.InternationalString) DefaultInternationalString(org.apache.sis.util.DefaultInternationalString) DefaultInternationalString(org.apache.sis.util.DefaultInternationalString) ParameterDescriptorGroup(org.opengis.parameter.ParameterDescriptorGroup) ArrayList(java.util.ArrayList) GeneralParameterDescriptor(org.opengis.parameter.GeneralParameterDescriptor) InputDescription(org.geotoolkit.wps.xml.v200.InputDescription) InternationalString(org.opengis.util.InternationalString) DefaultInternationalString(org.apache.sis.util.DefaultInternationalString) ParameterBuilder(org.apache.sis.parameter.ParameterBuilder)

Example 3 with ProcessOffering

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())));
    }
}
Also used : ProcessOffering(org.geotoolkit.wps.xml.v200.ProcessOffering)

Example 4 with ProcessOffering

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;
}
Also used : NoSuchIdentifierException(org.opengis.util.NoSuchIdentifierException) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) UncheckedIOException(java.io.UncheckedIOException) ProcessSummary(org.geotoolkit.wps.xml.v200.ProcessSummary) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) ProcessOffering(org.geotoolkit.wps.xml.v200.ProcessOffering) NoSuchIdentifierException(org.opengis.util.NoSuchIdentifierException) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException) UncheckedIOException(java.io.UncheckedIOException) CapabilitiesException(org.geotoolkit.client.CapabilitiesException)

Aggregations

ProcessOffering (org.geotoolkit.wps.xml.v200.ProcessOffering)3 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 ArrayList (java.util.ArrayList)1 JAXBException (javax.xml.bind.JAXBException)1 ParameterBuilder (org.apache.sis.parameter.ParameterBuilder)1 DefaultInternationalString (org.apache.sis.util.DefaultInternationalString)1 CapabilitiesException (org.geotoolkit.client.CapabilitiesException)1 ProcessDescriptor (org.geotoolkit.process.ProcessDescriptor)1 InputDescription (org.geotoolkit.wps.xml.v200.InputDescription)1 OutputDescription (org.geotoolkit.wps.xml.v200.OutputDescription)1 ProcessDescription (org.geotoolkit.wps.xml.v200.ProcessDescription)1 ProcessOfferings (org.geotoolkit.wps.xml.v200.ProcessOfferings)1 ProcessSummary (org.geotoolkit.wps.xml.v200.ProcessSummary)1 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)1 ParameterDescriptorGroup (org.opengis.parameter.ParameterDescriptorGroup)1 InternationalString (org.opengis.util.InternationalString)1 NoSuchIdentifierException (org.opengis.util.NoSuchIdentifierException)1