示例#1
0
        private DefaultPropertyValue CreateAndAssignDefaultPropertyValue(ISupportDefaultPropertyValues supportPropertiesObject, PropertyDefinition propertyDef, OperationReport operationReport)
        {
            OperationReport report = GuardAgainstNulls.ArgsContainsNull(new object[] { supportPropertiesObject, propertyDef });

            if (!report.Success)
            {
                operationReport.SetValues(report);
                return(null);
            }

            report = ValidateCanAssociateDefaultPropertyValueToObject(supportPropertiesObject, propertyDef);

            if (!report.Success)
            {
                operationReport.SetValues(report);

                return(null);
            }

            var propDefaultValue = new DefaultPropertyValue(propertyDef);



            supportPropertiesObject.AddDefaultPropertyValue(propDefaultValue);

            lock (typeProperties)
            {
                typeProperties[supportPropertiesObject.UserTypeID].Add(propDefaultValue.Name, propDefaultValue);
            }

            return(propDefaultValue);
        }
示例#2
0
        /// <summary>
        /// Deletes the property definition and removes it from the database.
        /// </summary>
        /// <param name="PropDef">The prop def.</param>
        /// <returns></returns>
        public OperationReport DeletePropertyDefinition(PropertyDefinition PropDef)
        {
            OperationReport validationReport = GuardAgainstNulls.ArgsContainsNull(new object[] { PropDef });

            if (!validationReport.Success)
            {
                throw new OrcaArgumentNullException(validationReport);
            }
            if (PropDef.IsPublished)
            {
                throw new CanNotDeletePublishedDomainObject(PropDef.Name);
            }

            if (newPropertyDefintions.ContainsKey(PropDef.Id))
            {
                newPropertyDefintions.Remove(PropDef.Id);
                persistor.CancelTransaction(PropDef.Id);

                return(new OperationReport("", true));
            }


            var trans = GetPersistTransactionFor(PropDef.Id);

            trans.Delete(PropDef);

            return(persistor.ProcessCommandsTransaction(trans));
        }
示例#3
0
        public PropertyDefinition DefinePropertyDefinition(object DefaultValue, string Name)
        {
            OperationReport validationReport = GuardAgainstNulls.ArgsContainsNull(new object[] { DefaultValue, Name });

            if (!validationReport.Success)
            {
                throw new OrcaArgumentNullException(validationReport);
            }

            OperationReport result = new OperationReport();

            PropertyDefinition def = new PropertyDefinition(Name, DefaultValue);

            persistor.AssignNewID(def);

            //the save only saves to the session, not persisted to the db
            //so the only way to get the object again is by its id
            //to allow for lookup by name we need to keep an assocation of name to id
            //when the object has been persisted out to the db then we remove it from the collection.
            lock (newPropertyDefintions)
            {
                newPropertyDefintions.Add(def.Id, def);
            }

            return(def);
        }
示例#4
0
        public OperationReport RemovePropertyValueFromDomainObject(ISupportDefaultPropertyValues UserTypeObject, PropertyDefinition PropertyDef)
        {
            OperationReport report = GuardAgainstNulls.ArgsContainsNull(new object[] { UserTypeObject, PropertyDef });

            if (!report.Success)
            {
                throw new OrcaArgumentNullException(report);
            }
            return(RemoveDefaultPropertyValue(UserTypeObject, PropertyDef));
        }
示例#5
0
        /// <summary>
        /// Saves the specified property definition and commits it to the database.
        /// </summary>
        /// <param name="PropertyDef">The PropertyDefinition.</param>
        /// <returns></returns>
        public OperationReport Save(PropertyDefinition PropertyDef)
        {
            OperationReport validationReport = GuardAgainstNulls.ArgsContainsNull(new object[] { PropertyDef });

            if (!validationReport.Success)
            {
                throw new OrcaArgumentNullException(validationReport);
            }

            OperationReport result = new OperationReport();

            try
            {
                IPersistCommandsTransaction trans = GetPersistTransactionFor(PropertyDef.Id);
                if (trans != null)
                {
                    if (newPropertyDefintions.ContainsKey(PropertyDef.Id))
                    {
                        if (PropertyDefinitionNameAvaliable(PropertyDef.Name))
                        {
                            NameToTypeAssociation propertyDefNameRegistration = RegisterPropertyDefintionName(PropertyDef.Name);
                            trans.Save(propertyDefNameRegistration);
                        }
                        else
                        {
                            throw new PropertyNameAlreadyDefinedException(PropertyDef.Name);
                        }
                    }
                    else
                    {
                        trans.SaveOrUpdate(PropertyDef);
                    }
                    result = persistor.ProcessCommandsTransaction(trans);

                    if (result.Success)
                    {
                        lock (newPropertyDefintions)
                        {
                            newPropertyDefintions.Remove(PropertyDef.Id);
                        }
                    }
                    else
                    {
                        //not sure what to do
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.AddNotification(ex.Message, ex);
            }

            return(result);
        }
示例#6
0
        public DefaultPropertyValue AddPropertyDefintionToDomainObject(ISupportDefaultPropertyValues DomainObjectForProperty, PropertyDefinition PropertyDef, OperationReport Report)
        {
            OperationReport validationReport = GuardAgainstNulls.ArgsContainsNull(new object[] { DomainObjectForProperty, PropertyDef });

            if (!validationReport.Success)
            {
                throw new OrcaArgumentNullException(validationReport);
            }

            return(CreateAndAssignDefaultPropertyValue(DomainObjectForProperty, PropertyDef, Report));
        }
示例#7
0
        public OperationReport CanPublish(PropertyDefinition propertyDef)
        {
            OperationReport validationReport = GuardAgainstNulls.ArgsContainsNull(new object[] { propertyDef });

            if (!validationReport.Success)
            {
                throw new OrcaArgumentNullException(validationReport);
            }

            return(publishService.CanPublish(propertyDef));
        }
示例#8
0
        public void BuildPropertyValuesForObject(ISupportPropertyValues domainObject)
        {
            OperationReport report = GuardAgainstNulls.ArgsContainsNull(new object[] { domainObject });

            if (!report.Success)
            {
                throw new OrcaArgumentNullException(report);
            }

            foreach (DefaultPropertyValue propertyDef in GetDefaultPropertyValuesDomainObject(domainObject.Id))
            {
                if (domainObject.HasProperty(propertyDef.StaticInstanceID))
                {
                    continue;
                }

                CreateAndAssignPropertyValue(domainObject, propertyDef);
            }
        }
示例#9
0
        public DefaultPropertyValue GetDefaultPropertyValue(ISupportDefaultPropertyValues dynamicPropertyObject, PropertyDefinition propertyDef)
        {
            OperationReport report = GuardAgainstNulls.ArgsContainsNull(new object[] { dynamicPropertyObject, propertyDef });

            if (!report.Success)
            {
                throw new OrcaArgumentNullException(report);
            }

            if (!typeProperties[dynamicPropertyObject.UserTypeID].ContainsKey(propertyDef.Name))
            {
                var result = _repository.GetFirst <DefaultPropertyValue>(x => x.PropertyDefinitionStaticID == propertyDef.StaticInstanceID && x.PropertyOwnerId == dynamicPropertyObject.Id);
                //                var result = _repository.Query<DefaultPropertyValue>().Where(
                //                x => x.PropertyDefinition.StaticInstanceID == propertyDef.StaticInstanceID && x.UserTypeID == dynamicPropertyObject.UserTypeID).FirstOrDefault();

                return(result);
            }

            return(typeProperties[dynamicPropertyObject.UserTypeID][propertyDef.Name]);
        }
示例#10
0
        public bool HasDefaultPropertyValue(ISupportDefaultPropertyValues dynamicPropertyObject, PropertyDefinition propertyDef)
        {
            OperationReport report = GuardAgainstNulls.ArgsContainsNull(new object[] { dynamicPropertyObject, propertyDef });

            if (!report.Success)
            {
                throw new OrcaArgumentNullException(report);
            }


            if (typeProperties[dynamicPropertyObject.UserTypeID].ContainsKey(propertyDef.Name))
            {
                return(true);
            }

            var count = _repository.GetCount <DefaultPropertyValue>(
                x => x.PropertyDefinitionStaticID == propertyDef.StaticInstanceID && x.PropertyOwnerId == dynamicPropertyObject.Id);


            return(count != 0);
        }