Exemplo n.º 1
0
        private Item GetTimeItemFromProxy(XsdNs.GetObservationTypeTemporalFilter proxy)
        {
            switch (proxy.TemporalOpsTypeInfo)
            {
            case XsdNs.TemporalObsTypeType.After:
            case XsdNs.TemporalObsTypeType.Before:

                // It is necessary to build a PropertyType object
                var timeInstantObj  = ((XsdNs.BinaryTemporalOpType_TimeInstant)proxy.TemporalOps).TimeInstant;
                var timeInstantProp = new XsdNs.TimeInstantPropertyType
                {
                    TimeInstant = timeInstantObj
                };

                return(new Item_TimeInstant(timeInstantProp));

            case XsdNs.TemporalObsTypeType.During:

                // It is necessary to build a PropertyType object
                var timePeriodObj  = ((XsdNs.BinaryTemporalOpType_TimePeriod)proxy.TemporalOps).TimePeriod;
                var timePeriodProp = new XsdNs.TimePeriodPropertyType
                {
                    TimePeriod = timePeriodObj
                };

                return(new Item_TimeRange(timePeriodProp));

            default:
                throw new XNeut.InvalidMessageException("Unsupported temporal operator in message: " + proxy.TemporalOpsTypeInfo.ToString());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor. Use this to populate the object from an XML proxy.
        /// </summary>
        /// <param name="proxy">Proxy.</param>
        /// <exception cref="XNeut.InvalidMessageException">Thrown if the message is invalid.</exception>
        internal TemporalFilter(XsdNs.GetObservationTypeTemporalFilter proxy)
        {
            try
            {
                // Mapping value reference
                switch (proxy.TemporalOps.ValueReference)
                {
                case ValueRefPhenoTime:
                    ValueReference = ValueReferenceType.PhenomenonTime;
                    break;

                case ValueRefResultTime:
                    ValueReference = ValueReferenceType.ResultTime;
                    break;

                default:
                    throw new XNeut.InvalidMessageException("Unsupported value reference " + proxy.TemporalOps.ValueReference);
                }

                // Mapping the operator
                switch (proxy.TemporalOpsTypeInfo)
                {
                case XsdNs.TemporalObsTypeType.After:
                    Operator = OperatorType.After;
                    break;

                case XsdNs.TemporalObsTypeType.Before:
                    Operator = OperatorType.Before;

                    break;

                case XsdNs.TemporalObsTypeType.During:
                    Operator = OperatorType.During;
                    break;

                default:
                    throw new XNeut.InvalidMessageException("Unsupported temporal operator in message: " + proxy.TemporalOpsTypeInfo.ToString());
                }

                // Getting time item
                Time = GetTimeItemFromProxy(proxy);

                // Checking consistency
                CheckConsistency(Operator, Time);
            }
            catch (ArgumentException e)
            {
                throw new XNeut.InvalidMessageException("Failed to process temporal filter (inconsistent values?)", e);
            }
            catch (NullReferenceException e)
            {
                throw new XNeut.InvalidMessageException("Failed to process temporal filter (something missing?)", e);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Generates an XML proxy from the object.
        /// </summary>
        /// <param name="idPrefix">A prefix to be appended to the IDs of any child XML elements that
        /// require an ID. For certain XML elements, the schema requires an ID that is unique within
        /// the XML document. Instead of generating random IDs, these are systematic and hierarchical
        /// in this software. To ensure uniqueness, each ID prefix can occur only once. The ID is of
        /// type xsd:id. This derives from xsd:NCName, so not all characters are allowed.</param>
        /// <returns>Proxy.</returns>
        internal XsdNs.GetObservationTypeTemporalFilter ToXmlProxy(string idPrefix)
        {
            var proxy       = new XsdNs.GetObservationTypeTemporalFilter();
            var idPrefixAll = idPrefix + "TempF_";

            // Creating condition element
            switch (Operator)
            {
            case OperatorType.After:

                proxy.TemporalOpsTypeInfo = XsdNs.TemporalObsTypeType.After;
                proxy.TemporalOps         = CreateTimeInstantForProxy(idPrefixAll);
                break;

            case OperatorType.Before:

                proxy.TemporalOpsTypeInfo = XsdNs.TemporalObsTypeType.Before;
                proxy.TemporalOps         = CreateTimeInstantForProxy(idPrefixAll);
                break;

            case OperatorType.During:

                proxy.TemporalOpsTypeInfo = XsdNs.TemporalObsTypeType.During;
                proxy.TemporalOps         = CreateTimePeriodForProxy(idPrefixAll);
                break;

            default:
                throw new NotImplementedException("Unsupported operator " + Operator.ToString());
            }

            // Setting value reference
            switch (ValueReference)
            {
            case ValueReferenceType.PhenomenonTime:
                proxy.TemporalOps.ValueReference = ValueRefPhenoTime;
                break;

            case ValueReferenceType.ResultTime:
                proxy.TemporalOps.ValueReference = ValueRefResultTime;
                break;

            default:
                throw new NotImplementedException("Unsupported value reference " + ValueReference.ToString());
            }

            return(proxy);
        }