Package net.opengis.wps10

Examples of net.opengis.wps10.Wps10Factory


            //save the error to report back
            error = t;
        }
       
        //build the response
        Wps10Factory f = Wps10Factory.eINSTANCE;
        ExecuteResponseType response = f.createExecuteResponseType();
        response.setLang("en");
        response.setServiceInstance(ResponseUtils.appendQueryString(ResponseUtils.buildURL(request.getBaseUrl(), "ows", null, URLType.SERVICE), ""));
      
        //process
        final ProcessBriefType process = f.createProcessBriefType();
        response.setProcess( process );
        process.setIdentifier(ct);
        process.setProcessVersion(pf.getVersion(processName));
        process.setTitle( Ows11Util.languageString( pf.getTitle(processName).toString() ) );
        process.setAbstract( Ows11Util.languageString( pf.getDescription(processName).toString() ) );
      
        //status
        response.setStatus( f.createStatusType() );
        response.getStatus().setCreationTime( Converters.convert( started, XMLGregorianCalendar.class ));
       
        if ( error != null ) {
            ProcessFailedType failure = f.createProcessFailedType();
            response.getStatus().setProcessFailed( failure );
           
            failure.setExceptionReport( Ows11Util.exceptionReport( new ServiceException( error ), wps.getGeoServer().getGlobal().isVerboseExceptions()) );
        }
        else {
            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 : result.keySet() ) {
            Parameter p = pf.getResultInfo(processName, null).get( key );
            if ( p == null ) {
                throw new WPSException( "No such output: " + key );
            }
           
            //find the ppio
            ProcessParameterIO ppio = ProcessParameterIO.find( p, context );
            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() );
            }
           
            //TODO: encoding + schema
        }
       
        //process outputs
        ProcessOutputsType1 processOutputs = f.createProcessOutputsType1();
        response.setProcessOutputs( processOutputs );
       
        for ( String key : result.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 = result.get( key );
            ProcessParameterIO ppio = ppios.get( key );
           
            if ( ppio instanceof ReferencePPIO ) {
                //encode as a reference
                OutputReferenceType ref = f.createOutputReferenceType();
                output.setReference( ref );
               
                //TODO: mime type
                ref.setHref( ((ReferencePPIO) ppio).encode(o).toString() );
            }
            else {
                //encode as data
                DataType data = f.createDataType();
                output.setData( data );
          
                if ( ppio instanceof LiteralPPIO ) {
                    LiteralDataType literal = f.createLiteralDataType();
                    data.setLiteralData( literal );
                   
                    literal.setValue( ((LiteralPPIO) ppio).encode( o ) );
                }
                else if ( ppio instanceof ComplexPPIO ) {
                    ComplexDataType complex = f.createComplexDataType();
                    data.setComplexData( complex );
                   
                    ComplexPPIO cppio = (ComplexPPIO) ppio;
                    complex.setMimeType( cppio.getMimeType() );
                   
View Full Code Here


        }

        // TODO: add update sequence negotiation
       
        // encode the response
        Wps10Factory wpsf = Wps10Factory.eINSTANCE;
        Ows11Factory owsf = Ows11Factory.eINSTANCE;
       
        WPSCapabilitiesType caps = wpsf.createWPSCapabilitiesType();
        caps.setVersion("1.0.0");
       
        //TODO: make configurable
        caps.setLang( "en" );
       
        //ServiceIdentification
        ServiceIdentificationType si = owsf.createServiceIdentificationType();
        caps.setServiceIdentification( si );
       
        si.getTitle().add( Ows11Util.languageString( wps.getTitle() ) );
        si.getAbstract().add( Ows11Util.languageString( wps.getAbstract() ) );
       
        KeywordsType kw = Ows11Util.keywords( wps.getKeywords( ) ); ;
        if ( kw != null ) {
            si.getKeywords().add( kw );
        }
       
        si.setServiceType( Ows11Util.code( "WPS" ) );
        si.getServiceTypeVersion().add( "1.0.0" );
        si.setFees( wps.getFees() );
       
        if ( wps.getAccessConstraints() != null ) {
            si.getAccessConstraints().add( wps.getAccessConstraints() );   
        }
       
        //ServiceProvider
        ServiceProviderType sp = owsf.createServiceProviderType();
        caps.setServiceProvider( sp );
       
        //TODO: set provder name from context
        GeoServerInfo geoServer = wps.getGeoServer().getGlobal();
        if ( geoServer.getContact().getContactOrganization() != null ) {
            sp.setProviderNamegeoServer.getContact().getContactOrganization()  );   
        }
        else {
            sp.setProviderName( "GeoServer" );
        }
       
       
        sp.setProviderSite(owsf.createOnlineResourceType());
        sp.getProviderSite().setHref( geoServer.getOnlineResource() );
        sp.setServiceContact( responsibleParty( geoServer, owsf ) );
       
        //OperationsMetadata
        OperationsMetadataType om = owsf.createOperationsMetadataType();
        caps.setOperationsMetadata( om );
       
        OperationType gco = owsf.createOperationType();
        gco.setName("GetCapabilities");
        gco.getDCP().add( Ows11Util.dcp( "wps", gco.getName(), request ) );
        om.getOperation().add( gco );
       
        OperationType dpo = owsf.createOperationType();
        dpo.setName( "DescribeProcess");
        dpo.getDCP().add( Ows11Util.dcp( "wps", dpo.getName(), request ) );
        om.getOperation().add( dpo );
       
        OperationType eo = owsf.createOperationType();
        eo.setName( "Execute" );
        eo.getDCP().add( Ows11Util.dcp( "wps", eo.getName(), request ) );
        om.getOperation().add( eo );
       
        ProcessOfferingsType po = wpsf.createProcessOfferingsType();
        caps.setProcessOfferings( po );
       
        for(ProcessFactory pf : Processors.getProcessFactories()) {
            for (Name name : pf.getNames()) {
                ProcessBriefType p = wpsf.createProcessBriefType();
                p.setProcessVersion(pf.getVersion(name));
                po.getProcess().add( p );
               
                p.setIdentifier(Ows11Util.code(name));
                p.setTitle(Ows11Util.languageString( pf.getTitle(name).toString()));
                p.setAbstract(Ows11Util.languageString( pf.getDescription(name).toString()));
            }
           
        }

        LanguagesType1 languages = wpsf.createLanguagesType1();
        caps.setLanguages( languages );
       
        DefaultType2 defaultLanguage = wpsf.createDefaultType2();
        languages.setDefault(defaultLanguage);
        defaultLanguage.setLanguage("en-US");
       
        LanguagesType supportedLanguages = wpsf.createLanguagesType();
        languages.setSupported( supportedLanguages );
        supportedLanguages.getLanguage().add( "en-US");
       
        return caps;
        // Version detection and alternative invocation if being implemented.
View Full Code Here

* @source $URL$
*/
public class ExecuteTest extends XMLTestSupport {

    public void testExecuteEncode() throws Exception {
        Wps10Factory f = Wps10Factory.eINSTANCE;
        ExecuteType ex = f.createExecuteType();

        CodeType id = Ows11Factory.eINSTANCE.createCodeType();
        ex.setIdentifier(id);
        id.setValue("foo");

        DataInputsType1 inputs = f.createDataInputsType1();
        ex.setDataInputs(inputs);

        InputType in = f.createInputType();
        inputs.getInput().add(in);

        DataType data = f.createDataType();
        in.setData(data);

        ComplexDataType cd = f.createComplexDataType();
        data.setComplexData(cd);

        //cd.getData().add(new GeometryFactory().createPoint(new Coordinate(1, 2)));

        Encoder e = new Encoder(new WPSConfiguration());
View Full Code Here

        e.setIndenting(true);
        e.encode(ex, WPS.Execute, System.out);
    }

    public void testExecuteResponse() throws Exception {
        Wps10Factory f = Wps10Factory.eINSTANCE;
        ExecuteResponseType response = f.createExecuteResponseType();

        ProcessOutputsType1 outputs = f.createProcessOutputsType1();
        response.setProcessOutputs(outputs);

        OutputDataType output = f.createOutputDataType();
        outputs.getOutput().add(output);

        LanguageStringType title = Ows11Factory.eINSTANCE.createLanguageStringType();
        output.setTitle(title);
        title.setValue("foo");

        DataType data = f.createDataType();
        output.setData(data);

        ComplexDataType cdata = f.createComplexDataType();
        data.setComplexData(cdata);
        //cdata.getData().add(new GeometryFactory().createPoint(new Coordinate(1, 1)));

        Encoder e = new Encoder(new WPSConfiguration());
        e.setIndenting(true);
View Full Code Here

        e.setIndenting(true);
        e.encode(response, WPS.ExecuteResponse, System.out);
    }
   
    public void testExecuteResponseProgress() throws Exception {
        Wps10Factory f = Wps10Factory.eINSTANCE;
        ExecuteResponseType response = f.createExecuteResponseType();
        StatusType status = f.createStatusType();
        ProcessStartedType ps = f.createProcessStartedType();
        ps.setPercentCompleted(new BigInteger("20"));
        ps.setValue("Working really hard here");
        status.setProcessStarted(ps);
        response.setStatus(status);
View Full Code Here

* @source $URL$
*/
public class LanguagesBindingTest extends WPSTestSupport {

    public void testEncode() throws Exception {
        Wps10Factory f = Wps10Factory.eINSTANCE;
        LanguagesType1 languages = f.createLanguagesType1();
       
        DefaultType2 defaultLanguage = f.createDefaultType2();
        languages.setDefault(defaultLanguage);
        defaultLanguage.setLanguage("en-US");
       
        LanguagesType supportedLanguages = f.createLanguagesType();
        languages.setSupported( supportedLanguages );
        supportedLanguages.getLanguage().add( "en-US");
       
        Document dom = encode( languages, WPS.Languages );
       
View Full Code Here

    }
   
    @Override
    public Object read(Object request, Map kvp, Map rawKvp) throws Exception {
        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")));
View Full Code Here

        List<IOParam> params = parseIOParameters(inputString);
       
        List<InputType> result = new ArrayList<InputType>();
        for (IOParam ioParam : params) {
            // common
            Wps10Factory factory = Wps10Factory.eINSTANCE;
            InputType it = factory.createInputType();
            it.setIdentifier(Ows11Util.code(ioParam.id));
            it.setData(factory.createDataType());
           
            Parameter<?> gtParam = inputParams.get(ioParam.id);
            if(gtParam == null) {
                throw new WPSException("Unknown data input named '" + ioParam.id + "'");
            }
View Full Code Here

       
        return literal;
    }
   
    ResponseFormType parseResponseDocument(Map<String, Parameter<?>> outputs, String responseDefinition) {
        Wps10Factory factory = Wps10Factory.eINSTANCE;
        List<IOParam> ioParams = parseIOParameters(responseDefinition);
       
        ResponseFormType response = factory.createResponseFormType();
        ResponseDocumentType doc = factory.createResponseDocumentType();
        response.setResponseDocument(doc);
       
        for (IOParam ioParam : ioParams) {
            doc.getOutput().add(parseOutputDefinitionType(outputs, factory, ioParam, true));
        }
View Full Code Here

       
        return odt;
    }
   
    ResponseFormType parseRawDataOutput(Map<String, Parameter<?>> resultInfo, String rawOutputs) {
        Wps10Factory factory = Wps10Factory.eINSTANCE;
        ResponseFormType response = factory.createResponseFormType();
       
        List<IOParam> ioParams = parseIOParameters(rawOutputs);
       
        if(ioParams.size() == 0) {
            return response;
View Full Code Here

TOP

Related Classes of net.opengis.wps10.Wps10Factory

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.