/// <summary>
        /// Converts a CSEntryChange from an 'replace' modification type to 'update', converting the contained AttributeChanges from 'add' to 'replace', and adding in the appropriate 'delete' AttributeChanges
        /// </summary>
        /// <param name="csentry">The CSEntryChange to modify</param>
        /// <returns>A copy of the original CSEntryChange with the modification type set to 'update'</returns>
        public static CSEntryChange ConvertCSEntryChangeReplaceToUpdate(this CSEntryChange csentry, MAObjectHologram maObject)
        {
            CSEntryChange newcsentry = CSEntryChange.Create();

            newcsentry.ObjectModificationType = ObjectModificationType.Update;
            newcsentry.ObjectType             = csentry.ObjectType;
            newcsentry.DN = csentry.DN;
            AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass(csentry.ObjectType);

            foreach (AttributeChange attributeChange in csentry.AttributeChanges)
            {
                AttributeChange newAttributeChange = AttributeChange.CreateAttributeReplace(attributeChange.Name, attributeChange.ValueChanges.Select(t => t.Value).ToList <object>());
                newcsentry.AttributeChanges.Add(newAttributeChange);
            }

            foreach (AcmaSchemaAttribute attribute in objectClass.Attributes.Where(t => !t.IsBuiltIn && !t.IsInheritedInClass(objectClass.Name)))
            {
                if (!csentry.AttributeChanges.Any(t => t.Name == attribute.Name))
                {
                    if (maObject.HasAttribute(attribute))
                    {
                        newcsentry.AttributeChanges.Add(AttributeChange.CreateAttributeDelete(attribute.Name));
                    }
                }
            }

            Logger.WriteLine("Converted CSEntryChangeReplace to CSEntryChangeUpdate", LogLevel.Debug);
            return(newcsentry);
        }
Exemple #2
0
 private bool EvaluateAttributeValue(MAObjectHologram sourceObject)
 {
     if (sourceObject.HasAttribute(this.Attribute, this.View))
     {
         if (this.Operator == PresenceOperator.IsPresent)
         {
             return(true);
         }
         else
         {
             this.RaiseRuleFailure("{{{0}}} was present", this.Attribute.Name);
             return(false);
         }
     }
     else
     {
         if (this.Operator == PresenceOperator.NotPresent)
         {
             return(true);
         }
         else
         {
             this.RaiseRuleFailure("{{{0}}} was not present", this.Attribute.Name);
             return(false);
         }
     }
 }