Package org.geotools.process

Examples of org.geotools.process.ProcessFactory


                "description"));
        descriptionContainer.add(descriptionLabel);
        // if we're editing an existing process show the description
        if (existingProcess) {
            Name name = Ows11Util.name(execute.processName);
            ProcessFactory pf = Processors.createProcessFactory(name);
            description = pf.getDescription(name).toString(Locale.ENGLISH);
        }

        // the process inputs
        final WebMarkupContainer inputContainer = new WebMarkupContainer("inputContainer");
        inputContainer.setVisible(existingProcess);
        add(inputContainer);
        final ListView inputView = new ListView("inputs", new PropertyModel(execute, "inputs")) {

            @Override
            protected void populateItem(ListItem item) {
                InputParameterValues pv = (InputParameterValues) item.getModelObject();
                Parameter p = pv.getParameter();
                item.add(new Label("param", buildParamSpec(p)));
                item.add(new Label("paramDescription", p.description.toString(Locale.ENGLISH)));
                if (!pv.isComplex() && !pv.isCoordinateReferenceSystem() && !pv.isBoundingBox()) {
                    Fragment f = new Fragment("paramValue", "literal", WPSRequestBuilderPanel.this);
                    FormComponent literal = new TextField("literalValue", new PropertyModel(pv,
                            "values[0].value"));
                    literal.setRequired(p.minOccurs > 0);
                    literal.setLabel(new Model(p.key));
                    f.add(literal);
                    item.add(f);
                } else if (pv.isBoundingBox()) {
                    EnvelopePanel envelope = new EnvelopePanel("paramValue", new PropertyModel(pv,
                            "values[0].value"));
                    envelope.setCRSFieldVisible(true);
                    item.add(envelope);
                } else if (pv.isCoordinateReferenceSystem()) {
                    CRSPanel crs = new CRSPanel("paramValue", new PropertyModel(pv,
                            "values[0].value"));
                    item.add(crs);
                } else {
                    ComplexInputPanel input = new ComplexInputPanel("paramValue", pv, 0);
                    item.add(input);
                }
            }
        };
        inputView.setReuseItems(true);
        inputContainer.add(inputView);

        // the process outputs
        final WebMarkupContainer outputContainer = new WebMarkupContainer("outputContainer");
        outputContainer.setVisible(existingProcess);
        add(outputContainer);
        final ListView outputView = new ListView("outputs", new PropertyModel(execute, "outputs")) {

            @Override
            protected void populateItem(ListItem item) {
                OutputParameter pv = (OutputParameter) item.getModelObject();
                Parameter p = pv.getParameter();
                item.add(new CheckBox("include", new PropertyModel(pv, "include")));
                item.add(new Label("param", buildParamSpec(p)));
                item.add(new Label("paramDescription", p.description.toString(Locale.ENGLISH)));
                if (pv.isComplex()) {
                    DropDownChoice mime = new DropDownChoice("mime", new PropertyModel(pv,
                            "mimeType"), pv.getSupportedMime());
                    item.add(mime);
                } else {
                    item.add(new Label("mime", "").setVisible(false)); // placeholder
                }
            }
        };
        outputView.setReuseItems(true);
        outputContainer.add(outputView);

        // the output response window
        responseWindow = new ModalWindow("responseWindow");
        add(responseWindow);
        responseWindow.setPageMapName("demoResponse");
        responseWindow.setCookieName("demoResponse");

        responseWindow.setPageCreator(new ModalWindow.PageCreator() {

            public Page createPage() {
                DemoRequest request = new DemoRequest(null);
                HttpServletRequest http = ((WebRequest) WPSRequestBuilderPanel.this.getRequest())
                        .getHttpServletRequest();
                String url = ResponseUtils.buildURL(ResponseUtils.baseURL(http), "ows", Collections
                        .singletonMap("strict", "true"), URLType.SERVICE);
                request.setRequestUrl(url);
                request.setRequestBody((String) responseWindow.getDefaultModelObject());
                return new DemoRequestResponse(new Model(request));
            }
        });

        // the describe process link
        final GeoServerAjaxFormLink describeLink = new GeoServerAjaxFormLink("describeProcess") {

            @Override
            protected void onClick(AjaxRequestTarget target, Form form) {
                processChoice.processInput();
                if (execute.processName != null) {
                    responseWindow.setDefaultModel(new Model(getDescribeXML(execute.processName)));
                    responseWindow.show(target);
                }
            }
        };
        descriptionContainer.add(describeLink);

        // the feedback panel, for validation errors
        feedback = new FeedbackPanel("feedback");
        feedback.setOutputMarkupId(true);
        add(feedback);

        // the process choice dropdown ajax behavior
        processChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                Name name = Ows11Util.name(execute.processName);
                ProcessFactory pf = Processors.createProcessFactory(name);
                if (pf == null) {
                    error("No such process: " + execute.processName);
                    descriptionContainer.setVisible(false);
                    inputContainer.setVisible(false);
                    outputContainer.setVisible(false);
                } else {
                    description = pf.getDescription(name).toString(Locale.ENGLISH);
                    execute.inputs = buildInputParameters(pf, name);
                    execute.outputs = buildOutputParameters(pf, name);
                    inputView.removeAll();
                    outputView.removeAll();
                    descriptionContainer.setVisible(true);
View Full Code Here


        ExecuteType execute = (ExecuteType) super.read(request, kvp, rawKvp);
        Wps10Factory factory = Wps10Factory.eINSTANCE;
       
        // grab the process, we need it to parse the data inputs
        Name processName = Ows11Util.name(execute.getIdentifier());
        ProcessFactory pf = Processors.createProcessFactory(processName);
        if (pf == null) {
            throw new WPSException("No such process: " + processName);
        }

        // parse inputs
        List<InputType> inputs = parseDataInputs(pf.getParameterInfo(processName), (String) rawKvp.get("DataInputs"));
        DataInputsType1 input1 = factory.createDataInputsType1();
        input1.getInput().addAll(inputs);
        execute.setDataInputs(input1);
       
        if(rawKvp.containsKey("responseDocument")) {
            execute.setResponseForm(parseResponseDocument(pf.getResultInfo(processName, null), (String) rawKvp.get("responseDocument")));
        } else if(rawKvp.containsKey("rawDataOutput")) {
            execute.setResponseForm(parseRawDataOutput(pf.getResultInfo(processName, null), (String) rawKvp.get("rawDataOutput")));
        }
       
        return execute;
    }
View Full Code Here

        return pds;
    }
   
    void processDescription( CodeType id, ProcessDescriptionsType pds ) {
        Name name = Ows11Util.name(id);
        ProcessFactory pf = Processors.createProcessFactory(name);
        if ( pf == null ) {
            throw new WPSException( "No such process: " + id.getValue() );
        }
       
        ProcessDescriptionType pd = wpsf.createProcessDescriptionType();
        pds.getProcessDescription().add( pd );
       
        pd.setProcessVersion( "1.0.0" );
        pd.setIdentifier( Ows11Util.code( id.getValue() ) );
        pd.setTitle( Ows11Util.languageString(pf.getTitle(name)) );
        pd.setAbstract( Ows11Util.languageString(pf.getDescription(name)) );
       
        //data inputs
        DataInputsType inputs = wpsf.createDataInputsType();
        pd.setDataInputs(inputs);
        dataInputs( inputs, pf, name );
View Full Code Here

                .getBaseUrl(), "ows", null, URLType.SERVICE), ""));
        }

        // process
        Name processName = Ows11Util.name(request.getIdentifier());
        ProcessFactory pf = Processors.createProcessFactory(processName);
        final ProcessBriefType process = f.createProcessBriefType();
        response.setProcess(process);
        process.setIdentifier(request.getIdentifier());
        process.setProcessVersion(pf.getVersion(processName));
        process.setTitle(Ows11Util.languageString(pf.getTitle(processName)));
        process.setAbstract(Ows11Util.languageString(pf.getDescription(processName)));

        // status
        response.setStatus(f.createStatusType());
        response.getStatus().setCreationTime(
                Converters.convert(started, XMLGregorianCalendar.class));
        response.getStatus().setProcessSucceeded("Process succeeded.");

        // inputs
        response.setDataInputs(f.createDataInputsType1());
        for (Iterator i = request.getDataInputs().getInput().iterator(); i.hasNext();) {
            InputType input = (InputType) i.next();
            response.getDataInputs().getInput().add(EMFUtils.clone(input, f, true));
        }

        // output definitions
        OutputDefinitionsType outputs = f.createOutputDefinitionsType();
        response.setOutputDefinitions(outputs);

        Map<String, Parameter<?>> outs = pf.getResultInfo(processName, null);
        Map<String, ProcessParameterIO> ppios = new HashMap();

        for (String key : outputMap.keySet()) {
            Parameter p = pf.getResultInfo(processName, null).get(key);
            if (p == null) {
                throw new WPSException("No such output: " + key);
            }

            // find the ppio
            String mime = outputMap.get(key).definition.getMimeType();
            ProcessParameterIO ppio = ProcessParameterIO.find(p, context, mime);
            if (ppio == null) {
                throw new WPSException("Unable to encode output: " + p.key);
            }
            ppios.put(p.key, ppio);

            DocumentOutputDefinitionType output = f.createDocumentOutputDefinitionType();
            outputs.getOutput().add(output);

            output.setIdentifier(Ows11Util.code(p.key));
            if (ppio instanceof ComplexPPIO) {
                output.setMimeType(((ComplexPPIO) ppio).getMimeType());
                if (ppio instanceof BinaryPPIO) {
                    output.setEncoding("base64");
                } else if (ppio instanceof XMLPPIO) {
                    output.setEncoding("utf-8");
                }
            }

            // TODO: better encoding handling + schema
        }

        // process outputs
        ProcessOutputsType1 processOutputs = f.createProcessOutputsType1();
        response.setProcessOutputs(processOutputs);

        for (String key : outputMap.keySet()) {
            OutputDataType output = f.createOutputDataType();
            output.setIdentifier(Ows11Util.code(key));
            output.setTitle(Ows11Util
                    .languageString(pf.getResultInfo(processName, null).get(key).description));
            processOutputs.getOutput().add(output);

            final Object o = outputMap.get(key).object;
            ProcessParameterIO ppio = ppios.get(key);
View Full Code Here

    }
   
    Map<String, ProcessOutput> executeInternal(ExecuteType request) {
      // load the process factory
        Name processName = Ows11Util.name(request.getIdentifier());
        ProcessFactory pf = Processors.createProcessFactory(processName);
        if (pf == null) {
            throw new WPSException("No such process: " + processName);
        }

        // parse the inputs into in memory representations the process can handle
        Map<String, Object> inputs = parseProcessInputs(request, processName, pf);

        // execute the process
        Map<String, Object> result = null;
        ProcessListener listener = new ProcessListener();
        Throwable exception = null;
        try {
            Process p = pf.create(processName);
            result = p.execute(inputs, listener);
        } catch (Exception e) {
            exception = e;
        }
       
View Full Code Here

    assertEquals(re, computed);
  }

  public void testSPI() throws Exception {
    NameImpl boundsName = new NameImpl("bean", "Bounds");
    ProcessFactory factory = Processors.createProcessFactory(boundsName);
    assertNotNull(factory);
    assertTrue(factory instanceof BeanProcessFactory);

    org.geotools.process.Process buffer = Processors
        .createProcess(boundsName);
View Full Code Here

    assertTrue(buffered.equals(geom.buffer(1d, 12, BufferParameters.CAP_SQUARE)));
  }

  public void testSPI() throws Exception {
    NameImpl bufferName = new NameImpl("JTS", "buffer");
    ProcessFactory factory = Processors.createProcessFactory(bufferName);
    assertNotNull(factory);
    assertTrue(factory instanceof GeometryProcessFactory);
   
    org.geotools.process.Process buffer = Processors.createProcess(bufferName);
    assertNotNull(buffer);
View Full Code Here

                    this.processDescriptionAll();

                    return;
                }

                ProcessFactory pf = Processors.createProcessFactory(identifier);

                if (null == pf) {
                    throw new WPSException("Invalid identifier", "InvalidParameterValue");
                }
View Full Code Here

    private List<FilteredProcess> selectableProcesses;

    public FilteredProcessesProvider(ProcessGroupInfo pfi, Locale locale) {
        this.pfi = pfi;
        this.locale = locale;
        ProcessFactory pf = GeoServerProcessors.getProcessFactory(pfi.getFactoryClass(), false);
        Set<Name> names = pf.getNames();
        selectableProcesses = new ArrayList<FilteredProcess>();
        for (Name name : names) {
            String description = GeoServerProcessors
                    .getProcessFactory(pfi.getFactoryClass(), false).getDescription(name)
                    .toString(locale);
View Full Code Here

    public ProcessSelectionPage(final WPSAdminPage origin, final ProcessGroupInfo pfi) {
        this.pfi = pfi;
       
        // prepare the process factory title
        Class<? extends ProcessFactory> factoryClass = pfi.getFactoryClass();
        ProcessFactory pf = GeoServerProcessors.getProcessFactory(factoryClass, false);
        if(pf == null) {
            throw new IllegalArgumentException("Failed to locate the process factory " + factoryClass);
        }
        this.title = pf.getTitle().toString(getLocale());
       
        Form form = new Form("form");
        add(form);
       
        final FilteredProcessesProvider provider = new FilteredProcessesProvider(pfi, getLocale());
View Full Code Here

TOP

Related Classes of org.geotools.process.ProcessFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.