Exemplo n.º 1
0
        public ObjectVersion GetObjectInfo(ObjVer objVer, bool latestVersion, bool updateFromServer = false)
        {
            vault.MetricGatherer.MethodCalled();

            // TODO: use LatestVersion and UpdateFromServer
            List <TestObjectVersionAndProperties> thisObj =
                vault.ovaps.Where(obj => obj.ObjVer.ID == objVer.ID && obj.ObjVer.Type == objVer.Type).ToList();

            if (thisObj.Count == 0)
            {
                return(null);
            }
            int lookupVersion = (objVer.Version == -1) ? thisObj.Max(obj => obj.ObjVer.Version) : objVer.Version;
            TestObjectVersionAndProperties objectVersionAndProperties = thisObj.SingleOrDefault(obj => obj.ObjVer.Version == lookupVersion);

            if (objectVersionAndProperties == null)
            {
                throw new Exception("Parameter is invalid.");
            }

            TestObjectVersion objectVersion = objectVersionAndProperties.versionData;

            //objectVersion.Class = objectVersionAndProperties.Properties.SearchForProperty( 100 ).Value.GetLookupID();
            //objectVersion.Title = objectVersionAndProperties.Properties.SearchForProperty( 0 ).GetValueAsLocalizedText();

            return(objectVersion);
        }
Exemplo n.º 2
0
        private TestObjectVersionAndProperties CreateNewTestObject(int objectType, PropertyValues propertyValues)
        {
            int maxId = 0;
            List <TestObjectVersionAndProperties> objThisType = vault.ovaps.Where(obj => obj.ObjVer.Type == objectType).ToList();

            if (objThisType.Count > 0)
            {
                maxId = objThisType.Max(obj => obj.ObjVer.ID);
            }
            TestObjectVersion objectVersion = new TestObjectVersion(vault)
            {
                ObjVer = new ObjVer {
                    Type = objectType, ID = maxId + 1, Version = 1
                }
            };
            TestObjectVersionAndProperties ovap = new TestObjectVersionAndProperties
            {
                Properties  = propertyValues,
                Vault       = vault,
                VersionData = objectVersion
            };

            vault.ovaps.Add(ovap);
            return(ovap);
        }
Exemplo n.º 3
0
        public ObjectVersion RemoveObject(ObjID objID)
        {
            vault.MetricGatherer.MethodCalled();

            TestObjectVersionAndProperties ovap = GetLatestTestObjectVersionAndProperties(objID, false, true);

            ovap.versionData.deleted = true;
            return(ovap.VersionData);
        }
Exemplo n.º 4
0
        public ObjectVersionAndProperties CreateNewObject(int objectType, PropertyValues propertyValues,
                                                          SourceObjectFiles sourceObjectFiles = null, AccessControlList accessControlList = null)
        {
            vault.MetricGatherer.MethodCalled();

            // TODO: use parameter args
            TestObjectVersionAndProperties ovap = CreateNewTestObject(objectType, propertyValues);

            return(ovap);
        }
Exemplo n.º 5
0
        public ObjectVersion CheckIn(ObjVer objVer)
        {
            vault.MetricGatherer.MethodCalled();

            // TODO: implement
            //throw new NotImplementedException();
            TestObjectVersionAndProperties ovap = GetLatestTestObjectVersionAndProperties(objVer.ObjID, false);

            ovap.versionData.checkedOut = false;
            return(ovap.VersionData);
        }
        public ObjectVersionAndProperties Clone()
        {
            TestObjectVersionAndProperties clone = new TestObjectVersionAndProperties
            {
                Properties  = this.Properties.Clone(),
                Vault       = this.Vault,
                VersionData = this.VersionData.Clone()
            };

            return(clone);
        }
Exemplo n.º 7
0
        public ObjectVersionAndProperties SetProperties(ObjVer objVer, PropertyValues propertyValues)
        {
            vault.MetricGatherer.MethodCalled();

            // TODO: use arguments
            // TODO: error checking
            // TODO: use SetAllProperties?
            foreach (PropertyValue propertyValue in propertyValues)
            {
                if (vault.propertyDefs.SingleOrDefault(prop => prop.PropertyDef.ID == propertyValue.PropertyDef) == null)
                {
                    throw new Exception(string.Format("Property does not exist. ({0})", propertyValue.PropertyDef));
                }
            }

            List <TestObjectVersionAndProperties> thisObj =
                vault.ovaps.Where(obj => obj.ObjVer.ID == objVer.ID && obj.ObjVer.Type == objVer.Type).ToList();

            if (thisObj.Count == 0)
            {
                throw new Exception("Object not found");
            }
            int maxVersion = thisObj.Max(obj => obj.ObjVer.Version);

            if (objVer.Version != -1 && objVer.Version != maxVersion)
            {
                throw new Exception("Invalid version.");
            }

            TestObjectVersionAndProperties current = thisObj.Single(obj => obj.ObjVer.Version == maxVersion);

            if (!current.VersionData.ObjectCheckedOut)
            {
                current = ( TestObjectVersionAndProperties )current.Clone();
                current.ObjVer.Version += 1;
                vault.ovaps.Add(current);
            }

            foreach (PropertyValue propertyValue in propertyValues)
            {
                int index = current.properties.IndexOf(propertyValue.PropertyDef);
                if (index == -1)
                {
                    current.properties.Add(-1, propertyValue);
                }
                else
                {
                    current.properties[index] = propertyValue;
                }
            }

            return(current);
        }
        public TestObjectVersionAndProperties CloneCheckedOut()
        {
            TestObjectVersionAndProperties clone = new TestObjectVersionAndProperties
            {
                Properties  = this.Properties.Clone(),
                Vault       = this.Vault,
                VersionData = this.versionData.Clone()
            };

            clone.versionData.checkedOut = true;

            return(clone);
        }
Exemplo n.º 9
0
        internal TestObjectVersionAndProperties GetTestObjectVersionAndProperties(ObjVer objVer, bool updateFromServer = false)
        {
            List <TestObjectVersionAndProperties> thisObj =
                vault.ovaps.Where(obj => obj.ObjVer.ID == objVer.ID && obj.ObjVer.Type == objVer.Type).ToList();

            if (thisObj.Count == 0)
            {
                throw new Exception(string.Format("Object not found: ({0}-{1}-{2})", objVer.Type, objVer.ID, objVer.Version));
            }
            int lookupVersion = (objVer.Version == -1) ? thisObj.Max(obj => obj.ObjVer.Version) : objVer.Version;
            TestObjectVersionAndProperties objectVersionAndProperties = thisObj.SingleOrDefault(obj => obj.ObjVer.Version == lookupVersion);

            return(objectVersionAndProperties);
        }
Exemplo n.º 10
0
        public TestObjectVersionAndProperties GetLatestTestObjectVersionAndProperties(ObjID objID, bool allowCheckedOut, bool updateFromServer = false)
        {
            vault.MetricGatherer.MethodCalled();

            // TODO: use arguments
            List <TestObjectVersionAndProperties> thisObj = vault.ovaps.Where(obj => obj.ObjVer.ID == objID.ID && obj.ObjVer.Type == objID.Type).ToList();

            if (thisObj.Count == 0)
            {
                return(null);
            }
            int maxObj = thisObj.Max(obj => obj.ObjVer.Version);
            TestObjectVersionAndProperties ovap = thisObj.Single(obj => obj.ObjVer.Version == maxObj);

            return(ovap);
        }
Exemplo n.º 11
0
 internal TestValueListItem(TestObjectVersionAndProperties vli)
 {
     // TODO: commented properties.
     ID          = vli.ObjVer.ID;
     ValueListID = vli.ObjVer.Type;
     Name        = vli.versionData.Title;
     //HasParent = vli.HasParent;
     //ParentID = vli.ParentID;
     //HasOwner = vli.HasOwner;
     //OwnerID = vli.OwnerID;
     //DisplayID = vli.versionData.DisplayID;
     //DisplayIDAvailable = vli.versionData.DisplayIDAvailable;
     //ACLForObjects = vli.ACLForObjects;
     //Icon = vli.Icon;
     //AutomaticPermissionsForObjects = vli.AutomaticPermissionsForObjects;
     //ItemGUID = vli.versionData.ObjectGUID;
     Deleted = vli.versionData.Deleted;
 }
Exemplo n.º 12
0
        public ObjectVersion CheckOut(ObjID objID)
        {
            vault.MetricGatherer.MethodCalled();

            // TODO: finish method
            TestObjectVersionAndProperties ovap = GetLatestTestObjectVersionAndProperties(objID, false);

            if (ovap.versionData.checkedOut)
            {
                throw new Exception(string.Format("Object checked out: ({0}-{1}-{2})", ovap.ObjVer.Type, ovap.ObjVer.ID, ovap.ObjVer.Version));
            }

            TestObjectVersionAndProperties newVersion = ovap.CloneCheckedOut();

            newVersion.VersionData.ObjVer.Version++;
            vault.CheckedOut.Add(newVersion.ObjVer.ObjID);
            vault.ovaps.Add(newVersion);
            return(newVersion.VersionData);
        }
Exemplo n.º 13
0
        public ObjectVersionAndProperties SetAllProperties(ObjVer objVer, bool allowModifyingCheckedInObject, PropertyValues propertyValues)
        {
            vault.MetricGatherer.MethodCalled();

            // TODO: error checking
            foreach (PropertyValue propertyValue in propertyValues)
            {
                if (vault.propertyDefs.SingleOrDefault(prop => prop.PropertyDef.ID == propertyValue.PropertyDef) == null)
                {
                    throw new Exception(string.Format("Property does not exist. ({0})", propertyValue.PropertyDef));
                }
            }

            List <TestObjectVersionAndProperties> thisObj =
                vault.ovaps.Where(obj => obj.ObjVer.ID == objVer.ID && obj.ObjVer.Type == objVer.Type).ToList();

            if (thisObj.Count == 0)
            {
                throw new Exception("Object not found");
            }
            int maxVersion = thisObj.Max(obj => obj.ObjVer.Version);

            if (objVer.Version != -1 && objVer.Version != maxVersion)
            {
                throw new Exception("Invalid version");
            }
            TestObjectVersionAndProperties current = thisObj.Single(obj => obj.ObjVer.Version == maxVersion);

            if (!current.VersionData.ObjectCheckedOut)
            {
                if (!allowModifyingCheckedInObject)
                {
                    throw new Exception("Modifying Checked In Object not allowed.");
                }
                current = ( TestObjectVersionAndProperties )current.Clone();
                current.ObjVer.Version += 1;
                vault.ovaps.Add(current);
            }
            current.Properties = propertyValues.Clone();

            return(current);
        }
Exemplo n.º 14
0
        public ObjectVersion ForceUndoCheckout(ObjVer objVer)
        {
            vault.MetricGatherer.MethodCalled();

            TestObjectVersionAndProperties ovap = GetLatestTestObjectVersionAndProperties(objVer.ObjID, true);

            if (ovap == null)
            {
                throw new Exception(string.Format("Object not found: ({0}-{1}-{2})", objVer.Type, objVer.ID, objVer.Version));
            }
            if (!ovap.versionData.checkedOut)
            {
                throw new Exception(string.Format("Object not checked out: ({0}-{1}-{2})", objVer.Type, objVer.ID, objVer.Version));
            }
            vault.CheckedOut.Remove(objVer.ObjID);
            vault.ovaps.Remove(ovap);

            TestObjectVersionAndProperties prev = GetLatestTestObjectVersionAndProperties(objVer.ObjID, true);

            return(prev.VersionData);
        }
Exemplo n.º 15
0
        public ObjectVersionAndProperties CreateNewObjectEx(int objectType, PropertyValues properties, SourceObjectFiles sourceFiles,
                                                            bool sfd, bool checkIn, AccessControlList accessControlList = null)
        {
            vault.MetricGatherer.MethodCalled();

            // TODO: use parameter args
            TestPropertyValue pv = new TestPropertyValue
            {
                PropertyDef = ( int )MFBuiltInPropertyDef.MFBuiltInPropertyDefSingleFileObject
            };

            pv.TypedValue.SetValue(MFDataType.MFDatatypeBoolean, sfd);
            properties.Add(-1, pv);
            TestObjectVersionAndProperties ovap = CreateNewTestObject(objectType, properties);

            if (!checkIn)
            {
                ovap.versionData.checkedOut = true;
            }
            return(ovap);
        }
        public ValueListItem GetValueListItemByID(int valueList, int valueListItemID)
        {
            vault.MetricGatherer.MethodCalled();

            ObjTypeAdmin ota = vault.objTypes.FirstOrDefault(vl => vl.ObjectType.ID == valueList);

            if (ota == null)
            {
                throw new Exception("Value list not found: " + valueList);
            }

            if (!ota.ObjectType.RealObjectType)
            {
                return(vault.ValueListItems.SingleOrDefault(vli => vli.ValueListID == valueList && vli.ID == valueListItemID));
            }

            TestObjectVersionAndProperties ovap = vault.ovaps.FirstOrDefault(ov => ov.ObjVer.Type == valueList && ov.ObjVer.ID == valueListItemID);

            if (ovap == null)
            {
                throw new Exception("Item not found: " + valueListItemID);
            }
            return(new TestValueListItem(ovap));
        }
 internal void Add(TestObjectVersionAndProperties ovap)
 {
     results.Add(ovap);
 }