Esempio n. 1
0
        internal void InsertChildListObjects <T>(IList <T> objectsToInserted, int parentArtifactId)
            where T : BaseDto
        {
            var childObjectsInfo = BaseDto.GetRelativityObjectChildrenListProperties <T>();

            bool isFilePropertyPresent = typeof(T).GetProperties().ToList().Any(c => c.DeclaringType.IsAssignableFrom(typeof(RelativityFile)));

            if (childObjectsInfo.Any() || isFilePropertyPresent)
            {
                foreach (var objectToBeInserted in objectsToInserted)
                {
                    SetParentArtifactID(objectToBeInserted, parentArtifactId);
                    int insertedRdoArtifactID = InsertRdo(objectToBeInserted.ToRdo());
                    InsertUpdateFileFields(objectToBeInserted, insertedRdoArtifactID);

                    foreach (var childPropertyInfo in childObjectsInfo)
                    {
                        InsertChildListObjectsWithDynamicType(objectToBeInserted, insertedRdoArtifactID, childPropertyInfo);
                    }
                }
            }
            else
            {
                foreach (var objectToBeInserted in objectsToInserted)
                {
                    SetParentArtifactID(objectToBeInserted, parentArtifactId);
                }

                var rdosToBeInserted = objectsToInserted.Select(x => x.ToRdo()).ToArray();

                rsapiProvider.Create(rdosToBeInserted);
            }
        }
Esempio n. 2
0
        public void Delete <T>(T theObjectToDelete) where T : BaseDto
        {
            var childObjectsInfo = BaseDto.GetRelativityObjectChildrenListProperties <T>();

            DeleteChildObjectsInner(theObjectToDelete, childObjectsInfo);
            DeleteRDO(theObjectToDelete.ArtifactId);
        }
Esempio n. 3
0
        public void Update <T>(T theObjectToUpdate)
            where T : BaseDto
        {
            var childObjectsInfo = BaseDto.GetRelativityObjectChildrenListProperties <T>();

            UpdateRelativityObject(theObjectToUpdate, childObjectsInfo);
        }
Esempio n. 4
0
        internal void DeleteChildObjects <T>(IList <T> parentObjectList, List <int> artifactIds) where T : BaseDto
        {
            var childObjectsInfo = BaseDto.GetRelativityObjectChildrenListProperties <T>();

            foreach (var parentObject in parentObjectList)
            {
                DeleteChildObjectsInner(parentObject, childObjectsInfo);
            }

            DeleteRDOs(artifactIds);
        }
Esempio n. 5
0
        //inserts *child* lists of a parent artifact ID (not associated artifacts)
        protected void UpdateChildListObjects <T>(IList <T> objectsToUpdate, int parentArtifactId)
            where T : BaseDto
        {
            var objectsToBeInsertedLookup = objectsToUpdate.ToLookup(x => x.ArtifactId == 0);
            var objectsToBeInserted       = objectsToBeInsertedLookup[true];
            var objectsToBeUpdated        = objectsToBeInsertedLookup[false];

            //insert ones that do not exist
            if (objectsToBeInserted.Any())
            {
                this.InvokeGenericMethod(typeof(T), nameof(InsertChildListObjects), objectsToBeInserted, parentArtifactId);
            }

            if (!objectsToBeUpdated.Any())
            {
                return;
            }

            var childObjectsInfo = BaseDto.GetRelativityObjectChildrenListProperties <T>();

            //if do not have child objects in turn, we can take a shortcut
            //and batch update all the items at once
            if (childObjectsInfo.Count == 0)
            {
                //update RDOs in bulk
                UpdateRdos(objectsToBeUpdated.Select(x => x.ToRdo()).ToArray());

                //Cannot update files in bulk; do here
                if (typeof(T).GetProperties().ToList()
                    .Any(c => c.DeclaringType.IsAssignableFrom(typeof(RelativityFile))))
                {
                    foreach (var objectToBeUpdated in objectsToBeUpdated)
                    {
                        InsertUpdateFileFields(objectToBeUpdated, objectToBeUpdated.ArtifactId);
                    }
                }

                return;
            }

            //if have child lists, recurse (UpdateRelativityObject and UpdateChildListObjects form a recursion)
            foreach (var objectToUpdate in objectsToBeUpdated)
            {
                UpdateRelativityObject(objectToUpdate, childObjectsInfo);
            }
        }
Esempio n. 6
0
        public int Insert <T>(T theObjectToInsert) where T : BaseDto
        {
            //TODO: should think about some sort of transaction type around this.  If any parts of this fail, it should all fail
            InsertSingleObjectFields(theObjectToInsert);
            InsertMultipleObjectFields(theObjectToInsert);

            int resultArtifactId = InsertRdo(theObjectToInsert.ToRdo());

            InsertUpdateFileFields(theObjectToInsert, resultArtifactId);



            var childObjectsInfo = BaseDto.GetRelativityObjectChildrenListProperties <T>();

            foreach (var childPropertyInfo in childObjectsInfo)
            {
                InsertChildListObjectsWithDynamicType(theObjectToInsert, resultArtifactId, childPropertyInfo);
            }

            return(resultArtifactId);
        }