Ejemplo n.º 1
0
        /// <summary>
        /// Returns any deleted objects in the database that match the resurrection criteria
        /// </summary>
        /// <param name="csentryChange">The CSEntryChange object representing the object being added to the database</param>
        /// <param name="dc">The DBDataContext in use on this thread</param>
        /// <returns>An MAObject matching the resurrection criteria, or null if no matching object was found</returns>
        private static MAObjectHologram GetResurrectionObject(CSEntryChange csentryChange)
        {
            AcmaSchemaObjectClass objectClass = null;

            if (csentryChange.ObjectType != null)
            {
                objectClass = ActiveConfig.DB.GetObjectClass(csentryChange.ObjectType);
            }

            MAObjectHologram existingObject = ActiveConfig.DB.GetMAObjectOrDefault(csentryChange.DN, objectClass);

            if (existingObject != null)
            {
                return(existingObject);
            }

            if (!ActiveConfig.DB.GetObjectClass(csentryChange.ObjectType).AllowResurrection)
            {
                return(null);
            }

            if (!ActiveConfig.XmlConfig.ClassConstructors.Contains(csentryChange.ObjectType))
            {
                return(null);
            }

            DBQueryGroup parameters = ActiveConfig.XmlConfig.ClassConstructors[csentryChange.ObjectType].ResurrectionParameters;

            if (parameters == null || parameters.DBQueries == null || parameters.DBQueries.Count == 0)
            {
                return(null);
            }

            return(ActiveConfig.DB.GetResurrectionObject(parameters, csentryChange));
        }
Ejemplo n.º 2
0
        private IList <MAObjectHologram> GetEventRecipientsFromQuery(MAObjectHologram hologram)
        {
            List <MAObjectHologram> recipients = new List <MAObjectHologram>();

            foreach (DBQueryObject query in this.RecipientQueries)
            {
                DBQueryGroup group;

                if (query is DBQueryGroup)
                {
                    group = query as DBQueryGroup;
                }
                else if (query is DBQueryByValue)
                {
                    group          = new DBQueryGroup();
                    group.Operator = GroupOperator.Any;
                    group.AddChildQueryObjects(query);
                }
                else
                {
                    throw new NotSupportedException();
                }

                IEnumerable <MAObjectHologram> queryRecipients;

                queryRecipients = ActiveConfig.DB.GetMAObjectsFromDBQuery(group, hologram);

                if (queryRecipients != null)
                {
                    recipients.AddRange(queryRecipients);
                }
            }

            return(recipients);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the DBQueryBuilder class
        /// </summary>
        /// <param name="queryGroup">The query group to build the query from</param>
        /// <param name="maximumResults">The maximum number of results to return</param>
        public DBQueryBuilder(DBQueryGroup queryGroup, int maximumResults)
            : this()
        {
            WhereClause whereClause = queryGroup.CreateWhereClause(this);

            this.QueryString = this.BuildQuery(whereClause, maximumResults);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the DBQueryBuilder class
        /// </summary>
        /// <param name="queryGroup">The query group to build the query from</param>
        /// <param name="maximumResults">The maximum number of results to return</param>
        /// <param name="hologram">The object used as the source of the query values</param>
        public DBQueryBuilder(DBQueryGroup queryGroup, int maximumResults, MAObjectHologram hologram)
            : this()
        {
            this.SourceObjectId = hologram.ObjectID;
            WhereClause whereClause = queryGroup.CreateWhereClause(this, hologram);

            this.QueryString = this.BuildQuery(whereClause, maximumResults);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the DBQueryBuilder class
        /// </summary>
        /// <param name="queryGroup">The query group to build the query from</param>
        /// <param name="maximumResults">The maximum number of results to return</param>
        /// <param name="csentry">The object used as the source of the query values</param>
        public DBQueryBuilder(DBQueryGroup queryGroup, int maximumResults, CSEntryChange csentry)
            : this()
        {
            this.SourceObjectId = new Guid(csentry.DN);
            WhereClause whereClause = queryGroup.CreateWhereClause(this, csentry);

            this.QueryString = this.BuildQuery(whereClause, maximumResults);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the DBQueryBuilder class
        /// </summary>
        /// <param name="queryGroup">The query group to build the query from</param>
        /// <param name="maximumResults">The maximum number of results to return</param>
        public DBQueryBuilder(DBQueryGroup queryGroup, OrderByTermCollection orderByTerms)
            : this()
        {
            WhereClause whereClause = queryGroup.CreateWhereClause(this);

            this.OrderByTerms = orderByTerms;
            this.QueryString  = this.BuildQuery(whereClause, 0);
        }
Ejemplo n.º 7
0
        private static MAObjectHologram GetObjectFromDnOrAnchor(CSEntryChange csentryChange)
        {
            MAObjectHologram maObject = null;

            AcmaSchemaObjectClass objectClass = null;

            if (csentryChange.ObjectType != null)
            {
                objectClass = ActiveConfig.DB.GetObjectClass(csentryChange.ObjectType);
            }

            if (!string.IsNullOrWhiteSpace(csentryChange.DN))
            {
                if (objectClass != null)
                {
                    maObject = ActiveConfig.DB.GetMAObjectOrDefault(new Guid(csentryChange.DN), objectClass);
                }
                else
                {
                    maObject = ActiveConfig.DB.GetMAObjectOrDefault(new Guid(csentryChange.DN));
                }

                if (maObject != null)
                {
                    return(maObject);
                }
            }

            DBQueryGroup anchorGroupSearch = new DBQueryGroup(GroupOperator.Any);

            foreach (AnchorAttribute anchor in csentryChange.AnchorAttributes)
            {
                AcmaSchemaAttribute attribute = ActiveConfig.DB.GetAttribute(anchor.Name);
                DBQueryByValue      query     = new DBQueryByValue(attribute, ValueOperator.Equals, new ValueDeclaration(anchor.Value.ToSmartString()));
                anchorGroupSearch.DBQueries.Add(query);
            }

            if (anchorGroupSearch.DBQueries.Count > 0)
            {
                DBQueryGroup parentGroup;

                if (objectClass != null)
                {
                    parentGroup = new DBQueryGroup(GroupOperator.All);
                    DBQueryByValue query = new DBQueryByValue(ActiveConfig.DB.GetAttribute("objectClass"), ValueOperator.Equals, new ValueDeclaration(objectClass.Name));
                    parentGroup.DBQueries.Add(query);
                    parentGroup.DBQueries.Add(anchorGroupSearch);
                }
                else
                {
                    parentGroup = anchorGroupSearch;
                }

                IList <MAObjectHologram> results = ActiveConfig.DB.GetMAObjectsFromDBQuery(parentGroup).ToList();

                if (results.Count == 1)
                {
                    return(results.First());
                }
                else if (results.Count > 1)
                {
                    throw new MultipleMatchException("Multiple objects were returned in the search for an anchor attribute");
                }
            }

            if (string.IsNullOrWhiteSpace(csentryChange.DN))
            {
                throw new InvalidOperationException("The CSEntryChange did not have a DN");
            }

            throw new NoSuchObjectException("The specified object does not exist in the database: " + csentryChange.DN);
        }