/// <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);
        }
Exemple #2
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);
        }