/// <summary>
        /// Process operation request
        /// </summary>
        /// <param name="request"></param>
        /// <returns>Resposne object to be sent back to the client</returns>
        public override OperationResult ProcessRequest(HttpRequest request, OwsRequestBase payload = null)
        {
            var    nvc        = System.Web.HttpUtility.ParseQueryString(request.QueryString.Value);
            string identifier = nvc["Identifier"] ?? nvc["identifier"];

            //  Make sure there is valid request parameter
            if (string.IsNullOrEmpty(identifier))
            {
                throw new NoApplicableCodeException(string.Format(CultureInfo.CurrentCulture, "Process identifier is mandatory for DescribeProcess operation.", identifier));
            }

            OperationResult result = new OperationResult(request);

            var processes = this.GetProcesses();

            if (!processes.ContainsKey(identifier))
            {
                throw new InvalidParameterValueException("Identifier", identifier);
            }

            ProcessDescriptions processDescriptions = new ProcessDescriptions();

            processDescriptions.ProcessDescription = new List <ProcessDescriptionType>();

            foreach (var id in identifier.Split(','))
            {
                processDescriptions.ProcessDescription.Add(processes[id].ProcessDescription);
            }

            result.ResultObject = processDescriptions;

            return(result);
        }
Пример #2
0
 public static bool DescribeProcessHasField(ProcessDescriptions input, string field)
 {
     foreach (var desc in input.ProcessDescription)
     {
         foreach (var data in desc.DataInputs)
         {
             if (data.Identifier != null && data.Identifier.Value == field)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        //---------------------------------------------------------------------------------------------------------------------

        public object DescribeProcess()
        {
            var query = "Service=WPS&Request=DescribeProcess";

            var identifier = (RemoteIdentifier != null ? RemoteIdentifier : Identifier);

            query += "&Identifier=" + identifier;

            if (this.Provider != null)
            {
                query += "&Version=" + this.Provider.WPSVersion;
            }

            var uri = new UriBuilder(Provider.BaseUrl);

            uri.Query = query;

            HttpWebRequest      describeHttpRequest = this.Provider.CreateWebRequest(uri.Uri.AbsoluteUri);
            ProcessDescriptions describeProcess     = null;

            //call describe url
            using (HttpWebResponse describeResponse = (HttpWebResponse)describeHttpRequest.GetResponse()) {
                using (var memStream = new MemoryStream()) {
                    describeResponse.GetResponseStream().CopyTo(memStream);
                    memStream.Seek(0, SeekOrigin.Begin);
                    if (describeResponse.StatusCode != HttpStatusCode.OK)
                    {
                        using (StreamReader reader = new StreamReader(memStream)) {
                            string errormsg = reader.ReadToEnd();
                            log.Error(errormsg);
                            throw new Exception(errormsg); //TEMPORARY - 52 North bug
                        }
                    }
                    describeProcess = (ProcessDescriptions) new System.Xml.Serialization.XmlSerializer(typeof(ProcessDescriptions)).Deserialize(memStream);
                }
            }
            return(describeProcess);
        }
        public void DeserializeDescribeProcess()
        {
            System.IO.FileStream atom       = new System.IO.FileStream("../../Terradue.Portal/Schemas/examples/describeprocess.xml", System.IO.FileMode.Open);
            XmlSerializer        serializer = new XmlSerializer(typeof(ProcessDescriptions));
            ProcessDescriptions  describe   = (ProcessDescriptions)serializer.Deserialize(atom);

            Assert.AreEqual("com.terradue.wps_oozie.process.OozieAbstractAlgorithm", describe.ProcessDescription[0].Identifier.Value);
            Assert.AreEqual("SRTM Digital Elevation Model", describe.ProcessDescription[0].Title.Value);
            Assert.AreEqual(2, describe.ProcessDescription[0].DataInputs.Count);
            Assert.AreEqual("Level0_ref", describe.ProcessDescription[0].DataInputs[0].Identifier.Value);
            Assert.AreEqual("string", describe.ProcessDescription[0].DataInputs[0].LiteralData.DataType.Value);
            Assert.AreEqual("https://data.terradue.com/gs/catalogue/tepqw/gtfeature/search?format=json&uid=ASA_IM__0PNPAM20120407_082248_000001263113_00251_52851_2317.N1", describe.ProcessDescription[0].DataInputs[0].LiteralData.DefaultValue);
            Assert.AreEqual("format", describe.ProcessDescription[0].DataInputs[1].Identifier.Value);
            Assert.AreEqual("string", describe.ProcessDescription[0].DataInputs[1].LiteralData.DataType.Value);
            Assert.AreEqual("gamma", describe.ProcessDescription[0].DataInputs[1].LiteralData.DefaultValue);
            Assert.AreEqual(2, describe.ProcessDescription[0].ProcessOutputs.Count);
            Assert.AreEqual("result_distribution", describe.ProcessDescription[0].ProcessOutputs[0].Identifier.Value);
            Assert.True(describe.ProcessDescription[0].ProcessOutputs[0].Item is SupportedComplexDataType);
            Assert.AreEqual("result_osd", describe.ProcessDescription[0].ProcessOutputs[1].Identifier.Value);

            var stream = new MemoryStream();

            System.Xml.Serialization.XmlSerializerNamespaces ns = new System.Xml.Serialization.XmlSerializerNamespaces();
            ns.Add("wps", "http://www.opengis.net/wps/1.0.0");
            ns.Add("ows", "http://www.opengis.net/ows/1.1");
            ns.Add("xlink", "http://www.w3.org/1999/xlink");
            serializer.Serialize(stream, describe, ns);
            stream.Seek(0, SeekOrigin.Begin);
            string executeText;

            using (StreamReader reader = new StreamReader(stream, System.Text.Encoding.UTF8))
            {
                executeText = reader.ReadToEnd();
            }
            Assert.IsNotNull(executeText);
        }
Пример #5
0
        /// <summary>
        /// Get Describe process from wps3
        /// </summary>
        /// <param name="wps3"></param>
        /// <returns></returns>
        private ProcessDescriptions GetDescribeProcessFromWps3(Process wps3)
        {
            ProcessDescriptions processDescriptions = new ProcessDescriptions();

            var description = new ProcessDescriptionType();

            description.Identifier = new CodeType {
                Value = this.Identifier
            };
            description.Title = new LanguageStringType {
                Value = this.Name
            };
            description.Abstract = new LanguageStringType {
                Value = this.Description
            };
            description.DataInputs     = new List <InputDescriptionType>();
            description.ProcessOutputs = new List <OutputDescriptionType>();

            //inputs
            foreach (var inputWps3 in wps3.Inputs)
            {
                var input = new InputDescriptionType();
                input.Identifier = new CodeType {
                    Value = inputWps3.Id
                };
                input.Title = new LanguageStringType {
                    Value = inputWps3.Title
                };
                input.Abstract = new LanguageStringType {
                    Value = inputWps3.Abstract
                };
                input.minOccurs = inputWps3.MinOccurs.ToString();
                input.maxOccurs = inputWps3.MaxOccurs.ToString();

                if (inputWps3.Input.LiteralDataDomains != null)
                {
                    input.LiteralData = new LiteralInputType();
                    var literaldomain = inputWps3.Input.LiteralDataDomains[0];
                    if (literaldomain.DataType != null)
                    {
                        input.LiteralData.DataType = new DomainMetadataType {
                            Value = literaldomain.DataType.Name, reference = literaldomain.DataType.Reference
                        }
                    }
                    ;
                    if (literaldomain.Uom != null)
                    {
                        input.LiteralData.UOMs = new SupportedUOMsType {
                            Default = new SupportedUOMsTypeDefault {
                                UOM = new DomainMetadataType {
                                    Value = literaldomain.Uom.Name, reference = literaldomain.Uom.Reference
                                }
                            }
                        }
                    }
                    ;
                    if (literaldomain.DefaultValue != null)
                    {
                        input.LiteralData.DefaultValue = literaldomain.DefaultValue;
                    }
                    //if (literaldomain.ValueDefinition != null) input.LiteralData.AnyValue = new ServiceModel.Ogc.Ows11.AnyValue { AnyValue =  }
                }
                description.DataInputs.Add(input);
            }

            //outputs
            var output = new OutputDescriptionType {
                Identifier = new CodeType {
                    Value = "result_osd"
                },
                Title = new LanguageStringType {
                    Value = "OpenSearch Description to the Results"
                },
                Abstract = new LanguageStringType {
                    Value = "OpenSearch Description to the Results"
                },
                Item = new SupportedComplexDataType {
                    Default = new ComplexDataCombinationType {
                        Format = new ComplexDataDescriptionType {
                            MimeType = "application/opensearchdescription+xml"
                        }
                    },
                    Supported = new List <ComplexDataDescriptionType> {
                        new ComplexDataDescriptionType {
                            MimeType = "application/opensearchdescription+xml"
                        }
                    }
                }
            };

            description.ProcessOutputs.Add(output);

            processDescriptions.ProcessDescription = new List <ProcessDescriptionType> {
                description
            };
            return(processDescriptions);
        }
Пример #6
0
        //****************************************************************************************
        // DescribeProcess
        //****************************************************************************************

        public static ProcessDescriptions DescribeProcessCleanup(IfyContext context, ProcessDescriptions input)
        {
            foreach (var desc in input.ProcessDescription)
            {
                var newinputs = new List <InputDescriptionType>();

                //add inputs
                var newinput = new InputDescriptionType();
                newinput.Identifier = new CodeType {
                    Value = "_T2InternalJobTitle"
                };
                newinput.Title = new LanguageStringType {
                    Value = "Job title"
                };
                newinput.Abstract = new LanguageStringType {
                    Value = "Wps job title"
                };
                newinput.minOccurs   = "1";
                newinput.maxOccurs   = "1";
                newinput.LiteralData = new LiteralInputType {
                    DataType = new DomainMetadataType {
                        Value = "string "
                    },
                    DefaultValue = desc.Title != null ? desc.Title.Value : ""
                };
                newinputs.Add(newinput);

                foreach (var data in desc.DataInputs)
                {
                    if (data.LiteralData != null)
                    {
                        if (data.LiteralData.AllowedValues != null && data.LiteralData.AllowedValues.Count == 0)
                        {
                            data.LiteralData.AllowedValues = null;
                        }
                    }
                    //remove inputs
                    if (data.Identifier != null)
                    {
                        switch (data.Identifier.Value)
                        {
                        case "_T2Username":
                        case "_T2UserEmail":
                        case "_T2ApiKey":
                        case "_T2JobInfoFeed":
                        case "_T2ResultsAnalysis":
                        case "_T2InternalJobTitle":
                            break;

                        case "index":
                        case "repoKey":
                            if (data.LiteralData != null && data.LiteralData.DefaultValue != null && context.UserId != 0)
                            {
                                var user = UserTep.FromId(context, context.UserId);
                                data.LiteralData.DefaultValue = data.LiteralData.DefaultValue.Replace("${USERNAME}", user.Username);
                                data.LiteralData.DefaultValue = data.LiteralData.DefaultValue.Replace("${T2USERNAME}", user.TerradueCloudUsername);
                            }
                            newinputs.Add(data);
                            break;

                        default:
                            newinputs.Add(data);
                            break;
                        }
                    }
                }

                desc.DataInputs = newinputs;
            }
            return(input);
        }