/// <summary>
        /// Apply the value update to the supplied property name of the updatable <see cref="CDP4Common.DTO.Thing"/> instance.
        /// </summary>
        /// <param name="updatableThing">
        /// The <see cref="CDP4Common.DTO.Thing"/> instance to which to apply the property value update.
        /// </param>
        /// <param name="propertyName">
        /// The property name of the <see cref="CDP4Common.DTO.Thing"/> to which to apply the value update.
        /// </param>
        /// <param name="value">
        /// The updated value to apply.
        /// </param>
        /// <returns>
        /// True if the value update was successfully applied.
        /// </returns>
        public bool ApplyPropertyUpdate(CDP4Common.DTO.Thing updatableThing, string propertyName, object value)
        {
            if (updatableThing == null || !this.IsScalar(propertyName))
            {
                return(false);
            }

            this.propertyValueAssignmentMap[propertyName]((CDP4Common.DTO.OrganizationalParticipant)updatableThing, value);

            return(true);
        }
        /// <summary>
        /// Apply the value update to the supplied property name of the updatable <see cref="CDP4Common.DTO.Thing"/> instance.
        /// </summary>
        /// <param name="updatableThing">
        /// The <see cref="CDP4Common.DTO.Thing"/> instance to which to apply the property value update.
        /// </param>
        /// <param name="propertyName">
        /// The property name of the <see cref="CDP4Common.DTO.Thing"/> to which to apply the value update.
        /// </param>
        /// <param name="value">
        /// The updated value to apply.
        /// </param>
        /// <returns>
        /// True if the value update was successfully applied.
        /// </returns>
        public bool ApplyPropertyUpdate(CDP4Common.DTO.Thing updatableThing, string propertyName, object value)
        {
            if (updatableThing == null || !this.IsScalar(propertyName))
            {
                return(false);
            }

            this.propertyValueAssignmentMap[propertyName]((CDP4Common.DTO.BuiltInRuleVerification)updatableThing, value);

            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// Apply the value update to the supplied property name of the updatable <see cref="CDP4Common.DTO.Thing"/> instance.
        /// </summary>
        /// <param name="updatableThing">
        /// The <see cref="CDP4Common.DTO.Thing"/> instance to which to apply the property value update.
        /// </param>
        /// <param name="propertyName">
        /// The property name of the <see cref="CDP4Common.DTO.Thing"/> to which to apply the value update.
        /// </param>
        /// <param name="value">
        /// The updated value to apply.
        /// </param>
        /// <returns>
        /// True if the value update was successfully applied.
        /// </returns>
        public bool ApplyPropertyUpdate(CDP4Common.DTO.Thing updatableThing, string propertyName, object value)
        {
            if (updatableThing == null || !this.IsScalar(propertyName))
            {
                return(false);
            }

            this.propertyValueAssignmentMap[propertyName]((CDP4Common.DTO.PossibleFiniteStateList)updatableThing, value);

            return(true);
        }
        /// <summary>
        /// Apply the value update to the supplied property name of the updatable <see cref="CDP4Common.DTO.Thing"/> instance.
        /// </summary>
        /// <param name="updatableThing">
        /// The <see cref="CDP4Common.DTO.Thing"/> instance to which to apply the property value update.
        /// </param>
        /// <param name="propertyName">
        /// The property name of the <see cref="CDP4Common.DTO.Thing"/> to which to apply the value update.
        /// </param>
        /// <param name="value">
        /// The updated value to apply.
        /// </param>
        /// <returns>
        /// True if the value update was successfully applied.
        /// </returns>
        public bool ApplyPropertyUpdate(CDP4Common.DTO.Thing updatableThing, string propertyName, object value)
        {
            if (updatableThing == null || !this.IsScalar(propertyName))
            {
                return(false);
            }

            this.propertyValueAssignmentMap[propertyName]((CDP4Common.DTO.TimeOfDayParameterType)updatableThing, value);

            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// Apply the value update to the supplied property name of the updatable <see cref="CDP4Common.DTO.Thing"/> instance.
        /// </summary>
        /// <param name="updatableThing">
        /// The <see cref="CDP4Common.DTO.Thing"/> instance to which to apply the property value update.
        /// </param>
        /// <param name="propertyName">
        /// The property name of the <see cref="CDP4Common.DTO.Thing"/> to which to apply the value update.
        /// </param>
        /// <param name="value">
        /// The updated value to apply.
        /// </param>
        /// <returns>
        /// True if the value update was successfully applied.
        /// </returns>
        public bool ApplyPropertyUpdate(CDP4Common.DTO.Thing updatableThing, string propertyName, object value)
        {
            if (updatableThing == null || !this.IsScalar(propertyName))
            {
                return(false);
            }

            this.propertyValueAssignmentMap[propertyName]((CDP4Common.DTO.LogEntryChangelogItem)updatableThing, value);

            return(true);
        }
Beispiel #6
0
        /// <summary>
        /// Apply the value update to the supplied property name of the updatable <see cref="CDP4Common.DTO.Thing"/> instance.
        /// </summary>
        /// <param name="updatableThing">
        /// The <see cref="CDP4Common.DTO.Thing"/> instance to which to apply the property value update.
        /// </param>
        /// <param name="propertyName">
        /// The property name of the <see cref="CDP4Common.DTO.Thing"/> to which to apply the value update.
        /// </param>
        /// <param name="value">
        /// The updated value to apply.
        /// </param>
        /// <returns>
        /// True if the value update was successfully applied.
        /// </returns>
        public bool ApplyPropertyUpdate(CDP4Common.DTO.Thing updatableThing, string propertyName, object value)
        {
            if (updatableThing == null || !this.IsScalar(propertyName))
            {
                return false;
            }

            this.propertyValueAssignmentMap[propertyName]((CDP4Common.DTO.Requirement)updatableThing, value);

            return true;
        }
        /// <summary>
        /// Apply the value update to the supplied property name of the updatable <see cref="CDP4Common.DTO.Thing"/> instance.
        /// </summary>
        /// <param name="updatableThing">
        /// The <see cref="CDP4Common.DTO.Thing"/> instance to which to apply the property value update.
        /// </param>
        /// <param name="propertyName">
        /// The property name of the <see cref="CDP4Common.DTO.Thing"/> to which to apply the value update.
        /// </param>
        /// <param name="value">
        /// The updated value to apply.
        /// </param>
        /// <returns>
        /// True if the value update was successfully applied.
        /// </returns>
        public bool ApplyPropertyUpdate(CDP4Common.DTO.Thing updatableThing, string propertyName, object value)
        {
            if (updatableThing == null || !this.IsScalar(propertyName))
            {
                return(false);
            }

            this.propertyValueAssignmentMap[propertyName]((CDP4Common.DTO.EngineeringModelDataNote)updatableThing, value);

            return(true);
        }
        /// <summary>
        /// Apply the value update to the supplied property name of the updatable <see cref="CDP4Common.DTO.Thing"/> instance.
        /// </summary>
        /// <param name="updatableThing">
        /// The <see cref="CDP4Common.DTO.Thing"/> instance to which to apply the property value update.
        /// </param>
        /// <param name="propertyName">
        /// The property name of the <see cref="CDP4Common.DTO.Thing"/> to which to apply the value update.
        /// </param>
        /// <param name="value">
        /// The updated value to apply.
        /// </param>
        /// <returns>
        /// True if the value update was successfully applied.
        /// </returns>
        public bool ApplyPropertyUpdate(CDP4Common.DTO.Thing updatableThing, string propertyName, object value)
        {
            if (updatableThing == null || !this.IsScalar(propertyName))
            {
                return(false);
            }

            this.propertyValueAssignmentMap[propertyName]((CDP4Common.DTO.SiteDirectoryThingReference)updatableThing, value);

            return(true);
        }
        /// <summary>
        /// Apply the value update to the supplied property name of the updatable <see cref="CDP4Common.DTO.Thing"/> instance.
        /// </summary>
        /// <param name="updatableThing">
        /// The <see cref="CDP4Common.DTO.Thing"/> instance to which to apply the property value update.
        /// </param>
        /// <param name="propertyName">
        /// The property name of the <see cref="CDP4Common.DTO.Thing"/> to which to apply the value update.
        /// </param>
        /// <param name="value">
        /// The updated value to apply.
        /// </param>
        /// <returns>
        /// True if the value update was successfully applied.
        /// </returns>
        public bool ApplyPropertyUpdate(CDP4Common.DTO.Thing updatableThing, string propertyName, object value)
        {
            if (updatableThing == null || !this.IsScalar(propertyName))
            {
                return(false);
            }

            this.propertyValueAssignmentMap[propertyName]((CDP4Common.DTO.DiagramElementContainer)updatableThing, value);

            return(true);
        }
        /// <summary>
        /// Save a <see cref="CDP4Common.DTO.Thing"/> to a cache table
        /// </summary>
        /// <param name="transaction">The current transaction</param>
        /// <param name="partition">The database partition (schema) where the requested resource is stored.</param>
        /// <param name="thing">The revised <see cref="CDP4Common.DTO.Thing"/></param>
        public void Write(NpgsqlTransaction transaction, string partition, Thing thing)
        {
            var table = this.GetThingCacheTableName(thing);

            var columns  = string.Format("(\"{0}\", \"{1}\", \"{2}\")", IidKey, RevisionColumnName, JsonColumnName);
            var values   = "(:iid, :revisionnumber, :jsonb)";
            var sqlQuery = string.Format("INSERT INTO \"{0}\".\"{1}\" {2} VALUES {3} ON CONFLICT (\"{4}\") DO UPDATE SET \"{5}\"=:revisionnumber, \"{6}\"=:jsonb;", partition, table, columns, values, IidKey, RevisionColumnName, JsonColumnName);

            using (var command = new NpgsqlCommand(sqlQuery, transaction.Connection, transaction))
            {
                command.Parameters.Add("iid", NpgsqlDbType.Uuid).Value = thing.Iid;
                command.Parameters.Add("revisionnumber", NpgsqlDbType.Integer).Value = thing.RevisionNumber;
                command.Parameters.Add("jsonb", NpgsqlDbType.Jsonb).Value            = thing.ToJsonObject().ToString(Formatting.None);

                // log the sql command
                command.ExecuteNonQuery();
            }
        }
        /// <summary>
        /// Removes <see cref="Thing"/>s part of a composition with the <see cref="Thing"/> associated to the <see cref="CDP4Common.DTO.Thing"/> if the references are no longer in the updated <see cref="CDP4Common.DTO.Thing"/>
        /// </summary>
        /// <param name="dtoThing">the <see cref="CDP4Common.DTO.Thing"/> to check</param>
        private void ComputeThingsToRemove(Dto dtoThing)
        {
            Lazy <Thing> cachedLazyThing;
            var          cacheKey = new CacheKey(dtoThing.Iid, dtoThing.IterationContainerId);

            if (!this.Cache.TryGetValue(cacheKey, out cachedLazyThing))
            {
                return;
            }

            var dtoContainedGuid   = this.ComputeContainedGuid(dtoThing);
            var pocoContainedThing = this.ComputeContainedThing(cachedLazyThing.Value);

            var thingsToRemove = pocoContainedThing.Where(poco => !dtoContainedGuid.Contains(poco.Iid)).ToList();

            foreach (var thing in thingsToRemove)
            {
                // isPersistent
                this.RecursivelyMarksForRemoval(thing);
            }
        }
        /// <summary>
        /// Compute the contained <see cref="Guid"/> for a <see cref="Dto"/>
        /// </summary>
        /// <param name="dto">The <see cref="Dto"/> to compute</param>
        /// <returns>An <see cref="List{Guid}"/> containing all the contained <see cref="Guid"/></returns>
        private List <Guid> ComputeContainedGuid(Dto dto)
        {
            var containedGuid = new List <Guid>();

            foreach (var container in dto.ContainerLists)
            {
                foreach (var obj in container)
                {
                    var orderedItem = obj as OrderedItem;
                    if (orderedItem != null)
                    {
                        containedGuid.Add(new Guid(orderedItem.V.ToString()));
                    }
                    else
                    {
                        containedGuid.Add((Guid)obj);
                    }
                }
            }

            return(containedGuid);
        }
 /// <summary>
 /// Validates the supplied <see cref="Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="citation">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <returns>
 /// True if all validation rules have passed or if none are defined.
 /// </returns>
 public bool TryValidate(CDP4Common.DTO.Thing citation)
 {
     return(this.TryValidate(citation, x => true));
 }
Beispiel #14
0
 /// <summary>
 /// Validates the supplied <see cref="CDP4Common.DTO.Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="modellingAnnotationItem">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <exception cref="Cdp4ModelValidationException">
 /// If any validation rule failed.
 /// </exception>
 public void Validate(CDP4Common.DTO.Thing modellingAnnotationItem)
 {
     this.Validate(modellingAnnotationItem, x => true);
 }
Beispiel #15
0
 /// <summary>
 /// Validates the supplied <see cref="Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="modellingAnnotationItem">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <returns>
 /// True if all validation rules have passed or if none are defined.
 /// </returns>
 public bool TryValidate(CDP4Common.DTO.Thing modellingAnnotationItem)
 {
     return(this.TryValidate(modellingAnnotationItem, x => true));
 }
Beispiel #16
0
 /// <summary>
 /// Validates the supplied <see cref="CDP4Common.DTO.Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="elementDefinition">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <exception cref="Cdp4ModelValidationException">
 /// If any validation rule failed.
 /// </exception>
 public void Validate(CDP4Common.DTO.Thing elementDefinition)
 {
     this.Validate(elementDefinition, x => true);
 }
Beispiel #17
0
 /// <summary>
 /// Validates the supplied <see cref="Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="elementDefinition">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <returns>
 /// True if all validation rules have passed or if none are defined.
 /// </returns>
 public bool TryValidate(CDP4Common.DTO.Thing elementDefinition)
 {
     return(this.TryValidate(elementDefinition, x => true));
 }
Beispiel #18
0
 /// <summary>
 /// Validates the supplied <see cref="CDP4Common.DTO.Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="thingReference">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <exception cref="Cdp4ModelValidationException">
 /// If any validation rule failed.
 /// </exception>
 public void Validate(CDP4Common.DTO.Thing thingReference)
 {
     this.Validate(thingReference, x => true);
 }
        /// <summary>
        /// Validates the supplied <see cref="Thing"/> by running the business validation rules as per its meta info definition class.
        /// </summary>
        /// <param name="dependentParameterTypeAssignment">
        /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
        /// </param>
        /// <param name="validateProperty">
        /// The validate Property.
        /// </param>
        /// <returns>
        /// True if all validation rules have passed or if none are defined.
        /// </returns>
        public bool TryValidate(CDP4Common.DTO.Thing dependentParameterTypeAssignment, Func <string, bool> validateProperty)
        {
            var applicableValidationRules = this.validationRules.Where(x => validateProperty(x.Key)).Select(x => x.Value);

            return(applicableValidationRules.All(applicableRule => applicableRule.TryValidate((CDP4Common.DTO.DependentParameterTypeAssignment)dependentParameterTypeAssignment)));
        }
 /// <summary>
 /// Validates the supplied <see cref="CDP4Common.DTO.Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="scaleReferenceQuantityValue">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <exception cref="Cdp4ModelValidationException">
 /// If any validation rule failed.
 /// </exception>
 public void Validate(CDP4Common.DTO.Thing scaleReferenceQuantityValue)
 {
     this.Validate(scaleReferenceQuantityValue, x => true);
 }
 /// <summary>
 /// Validates the supplied <see cref="Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="scaleReferenceQuantityValue">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <returns>
 /// True if all validation rules have passed or if none are defined.
 /// </returns>
 public bool TryValidate(CDP4Common.DTO.Thing scaleReferenceQuantityValue)
 {
     return(this.TryValidate(scaleReferenceQuantityValue, x => true));
 }
        /// <summary>
        /// Validates the supplied <see cref="Thing"/> by running the business validation rules as per its meta info definition class.
        /// </summary>
        /// <param name="citation">
        /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
        /// </param>
        /// <param name="validateProperty">
        /// The validate Property.
        /// </param>
        /// <returns>
        /// True if all validation rules have passed or if none are defined.
        /// </returns>
        public bool TryValidate(CDP4Common.DTO.Thing citation, Func <string, bool> validateProperty)
        {
            var applicableValidationRules = this.validationRules.Where(x => validateProperty(x.Key)).Select(x => x.Value);

            return(applicableValidationRules.All(applicableRule => applicableRule.TryValidate((CDP4Common.DTO.Citation)citation)));
        }
 /// <summary>
 /// Validates the supplied <see cref="CDP4Common.DTO.Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="citation">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <exception cref="Cdp4ModelValidationException">
 /// If any validation rule failed.
 /// </exception>
 public void Validate(CDP4Common.DTO.Thing citation)
 {
     this.Validate(citation, x => true);
 }
Beispiel #24
0
 /// <summary>
 /// Validates the supplied <see cref="CDP4Common.DTO.Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="requirementsSpecification">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <exception cref="Cdp4ModelValidationException">
 /// If any validation rule failed.
 /// </exception>
 public void Validate(CDP4Common.DTO.Thing requirementsSpecification)
 {
     this.Validate(requirementsSpecification, x => true);
 }
        /// <summary>
        /// Validates the supplied <see cref="Thing"/> by running the business validation rules as per its meta info definition class.
        /// </summary>
        /// <param name="scaleReferenceQuantityValue">
        /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
        /// </param>
        /// <param name="validateProperty">
        /// The validate Property.
        /// </param>
        /// <returns>
        /// True if all validation rules have passed or if none are defined.
        /// </returns>
        public bool TryValidate(CDP4Common.DTO.Thing scaleReferenceQuantityValue, Func <string, bool> validateProperty)
        {
            var applicableValidationRules = this.validationRules.Where(x => validateProperty(x.Key)).Select(x => x.Value);

            return(applicableValidationRules.All(applicableRule => applicableRule.TryValidate((CDP4Common.DTO.ScaleReferenceQuantityValue)scaleReferenceQuantityValue)));
        }
 /// <summary>
 /// Validates the supplied <see cref="Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="goal">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <returns>
 /// True if all validation rules have passed or if none are defined.
 /// </returns>
 public bool TryValidate(CDP4Common.DTO.Thing goal)
 {
     return(this.TryValidate(goal, x => true));
 }
 /// <summary>
 /// Validates the supplied <see cref="Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="dependentParameterTypeAssignment">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <returns>
 /// True if all validation rules have passed or if none are defined.
 /// </returns>
 public bool TryValidate(CDP4Common.DTO.Thing dependentParameterTypeAssignment)
 {
     return(this.TryValidate(dependentParameterTypeAssignment, x => true));
 }
 /// <summary>
 /// Validates the supplied <see cref="CDP4Common.DTO.Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="goal">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <exception cref="Cdp4ModelValidationException">
 /// If any validation rule failed.
 /// </exception>
 public void Validate(CDP4Common.DTO.Thing goal)
 {
     this.Validate(goal, x => true);
 }
 /// <summary>
 /// Validates the supplied <see cref="CDP4Common.DTO.Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="dependentParameterTypeAssignment">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <exception cref="Cdp4ModelValidationException">
 /// If any validation rule failed.
 /// </exception>
 public void Validate(CDP4Common.DTO.Thing dependentParameterTypeAssignment)
 {
     this.Validate(dependentParameterTypeAssignment, x => true);
 }
Beispiel #30
0
 /// <summary>
 /// Validates the supplied <see cref="Thing"/> by running the business validation rules as per its meta info definition class.
 /// </summary>
 /// <param name="thingReference">
 /// The <see cref="CDP4Common.DTO.Thing"/> for which to run the validation rules.
 /// </param>
 /// <returns>
 /// True if all validation rules have passed or if none are defined.
 /// </returns>
 public bool TryValidate(CDP4Common.DTO.Thing thingReference)
 {
     return(this.TryValidate(thingReference, x => true));
 }