Example #1
0
        /// <summary>
        /// Serialize the <see cref="StakeholderValue"/>
        /// </summary>
        /// <param name="stakeholderValue">The <see cref="StakeholderValue"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(StakeholderValue stakeholderValue)
        {
            var jsonObject = new JObject();

            jsonObject.Add("alias", this.PropertySerializerMap["alias"](stakeholderValue.Alias.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("category", this.PropertySerializerMap["category"](stakeholderValue.Category.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), stakeholderValue.ClassKind)));
            jsonObject.Add("definition", this.PropertySerializerMap["definition"](stakeholderValue.Definition.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](stakeholderValue.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](stakeholderValue.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("hyperLink", this.PropertySerializerMap["hyperLink"](stakeholderValue.HyperLink.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](stakeholderValue.Iid));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](stakeholderValue.ModifiedOn));
            jsonObject.Add("name", this.PropertySerializerMap["name"](stakeholderValue.Name));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](stakeholderValue.RevisionNumber));
            jsonObject.Add("shortName", this.PropertySerializerMap["shortName"](stakeholderValue.ShortName));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](stakeholderValue.ThingPreference));
            return(jsonObject);
        }
Example #2
0
        /// <summary>
        /// Persist the <see cref="StakeholderValue"/> containment tree to the ORM layer. Update if it already exists.
        /// This is typically used during the import of existing data to the Database.
        /// </summary>
        /// <param name="transaction">
        /// The current <see cref="NpgsqlTransaction"/> to the database.
        /// </param>
        /// <param name="partition">
        /// The database partition (schema) where the requested resource will be stored.
        /// </param>
        /// <param name="stakeholderValue">
        /// The <see cref="StakeholderValue"/> instance to persist.
        /// </param>
        /// <returns>
        /// True if the persistence was successful.
        /// </returns>
        private bool UpsertContainment(NpgsqlTransaction transaction, string partition, StakeholderValue stakeholderValue)
        {
            var results = new List <bool>();

            foreach (var alias in this.ResolveFromRequestCache(stakeholderValue.Alias))
            {
                results.Add(this.AliasService.UpsertConcept(transaction, partition, alias, stakeholderValue));
            }

            foreach (var definition in this.ResolveFromRequestCache(stakeholderValue.Definition))
            {
                results.Add(this.DefinitionService.UpsertConcept(transaction, partition, definition, stakeholderValue));
            }

            foreach (var hyperLink in this.ResolveFromRequestCache(stakeholderValue.HyperLink))
            {
                results.Add(this.HyperLinkService.UpsertConcept(transaction, partition, hyperLink, stakeholderValue));
            }

            return(results.All(x => x));
        }
 /// <summary>
 /// Add an Stakeholder Value row view model to the list of <see cref="StakeholderValue"/>
 /// </summary>
 /// <param name="stakeholderValue">
 /// The <see cref="StakeholderValue"/> that is to be added
 /// </param>
 private StakeholderValueRowViewModel AddStakeholderValueRowViewModel(StakeholderValue stakeholderValue)
 {
     return(new StakeholderValueRowViewModel(stakeholderValue, this.Session, this));
 }