Ejemplo n.º 1
0
    def execute(self, appstruct):
        inputs = appstruct_to_inputs(self.request, appstruct)
        # need to use ComplexDataInput
        complex_inpts = []
        for inpt in self.process.dataInputs:
            if 'ComplexData' in inpt.dataType:
                complex_inpts.append(inpt.identifier)
        new_inputs = []
        for inpt in inputs:
            if inpt[0] in complex_inpts:
                new_inputs.append((inpt[0], ComplexDataInput(inpt[1])))
            else:
                new_inputs.append(inpt)
        inputs = new_inputs
        # prepare outputs
        outputs = []
        for output in self.process.processOutputs:
            outputs.append(
                (output.identifier, output.dataType == 'ComplexData'))

        from phoenix.tasks.execute import execute_process
        result = execute_process.delay(
            userid=self.request.unauthenticated_userid,
            url=self.wps.url,
            service_name=self.service_name,
            identifier=self.process.identifier,
            inputs=inputs,
            outputs=outputs,
            async=appstruct.get('_async_check', True))
        self.session['task_id'] = result.id
        self.request.registry.notify(JobStarted(self.request, result.id))
Ejemplo n.º 2
0
    def success(self, appstruct):
        super(Done, self).success(appstruct)
        self.favorite.set(name='last', state=self.wizard_state.dump())

        result = execute_workflow.delay(userid=authenticated_userid(
            self.request),
                                        url=self.request.wps.url,
                                        service_name=self.service_name,
                                        workflow=self.workflow_description(),
                                        caption=appstruct.get('caption'))
        self.request.registry.notify(JobStarted(self.request, result.id))
Ejemplo n.º 3
0
    def execute(self, appstruct):
        inputs = appstruct_to_inputs(self.request, appstruct)
        # need to use ComplexDataInput
        complex_inpts = {}
        bbox_inpts = []
        for inpt in self.process.dataInputs:
            if 'ComplexData' in inpt.dataType:
                complex_inpts[inpt.identifier] = inpt
            elif 'BoundingBoxData' in inpt.dataType:
                bbox_inpts.append(inpt.identifier)
        new_inputs = []
        for inpt in inputs:
            identifier = inpt[0]
            value = inpt[1]
            if identifier in complex_inpts:
                new_inputs.append((identifier, ComplexDataInput(value)))
                if is_reference(value):
                    if value not in self.request.cart:
                        if complex_inpts[identifier].supportedValues:
                            mime_type = complex_inpts[
                                identifier].supportedValues[0].mimeType
                        else:
                            mime_type = None
                        LOGGER.debug("add input to cart: %s %s", identifier,
                                     mime_type)
                        self.request.cart.add_item(
                            value,
                            abstract=
                            "Automatically added in process execution.",
                            mime_type=mime_type)
            elif identifier in bbox_inpts:
                new_inputs.append((identifier, BoundingBoxDataInput(value)))
            else:
                new_inputs.append(inpt)
        inputs = new_inputs
        # prepare outputs
        outputs = []
        for output in self.process.processOutputs:
            outputs.append(
                (output.identifier, output.dataType == 'ComplexData'))

        from phoenix.tasks.execute import execute_process
        result = execute_process.delay(
            userid=self.request.unauthenticated_userid,
            url=self.wps.url,
            service_name=self.service_name,
            identifier=self.process.identifier,
            inputs=inputs,
            outputs=outputs,
            async=appstruct.get('_async_check', True))
        self.request.registry.notify(JobStarted(self.request, result.id))
        return result.id
Ejemplo n.º 4
0
    def execute(self, appstruct):
        inputs = appstruct_to_inputs(self.request, appstruct)
        # need to use ComplexDataInput
        complex_inpts = {}
        bbox_inpts = []
        for inpt in self.process.dataInputs:
            if 'ComplexData' in inpt.dataType:
                complex_inpts[inpt.identifier] = inpt
            elif 'BoundingBoxData' in inpt.dataType:
                bbox_inpts.append(inpt.identifier)
        new_inputs = []
        for inpt in inputs:
            identifier = inpt[0]
            value = inpt[1]
            if identifier in complex_inpts:
                new_inputs.append((identifier, ComplexDataInput(value)))
            elif identifier in bbox_inpts:
                crs = 'urn:ogc:def:crs:OGC:2:84'
                new_inputs.append((identifier, BoundingBoxDataInput(value, crs=crs)))
            else:
                new_inputs.append(inpt)
        inputs = new_inputs
        # prepare outputs
        outputs = []
        for output in self.process.processOutputs:
            outputs.append(
                (output.identifier, output.dataType == 'ComplexData'))

        from phoenix.tasks.execute import execute_process
        result = execute_process.delay(
            userid=self.request.unauthenticated_userid,
            url=self.wps.url,
            service_name=self.service.title,
            identifier=self.process.identifier,
            inputs=inputs,
            outputs=outputs,
            use_async=appstruct.get('_async_check', True))

        # give the job a chance to start
        sleep(1)
        self.request.registry.notify(JobStarted(self.request, result.id))
        LOGGER.debug('wps url={}'.format(self.wps.url))
        LOGGER.debug('request inputs = {}'.format(str(inputs)))
        return result.id