Inheritance: PropertySet
Example #1
0
        private static void WriteAddOrRemovePropertyTypes(ContentListType origSet, ContentListType newSet, List <PropertySet> modifiedPropertySets, SchemaWriter writer)
        {
            bool origSetChanged = false;

            if (origSet == null)
            {
                // New NodeType: add all property
                foreach (PropertyType propType in newSet.PropertyTypes)
                {
                    writer.AddPropertyTypeToPropertySet(propType, newSet, true);
                }
                return;
            }
            // Delete PropertyType if needed
            foreach (PropertyType propType in GetTypesToDelete <PropertyType>(origSet.PropertyTypes, newSet.PropertyTypes))
            {
                writer.RemovePropertyTypeFromPropertySet(propType, newSet);
                origSetChanged = true;
            }

            // Create or modify PropertyTypes
            foreach (PropertyType propType in newSet.PropertyTypes)
            {
                if (NeedToCreate <PropertyType>(origSet.PropertyTypes, propType))
                {
                    writer.AddPropertyTypeToPropertySet(propType, newSet, true);
                    origSetChanged = true;
                }
            }

            if (origSetChanged && !modifiedPropertySets.Contains(origSet))
            {
                modifiedPropertySets.Add(origSet);
            }
        }
Example #2
0
        private ContentListType CreateContentListType(int id, string name)
        {
            var listType = new ContentListType(id, name, this);

            this.ContentListTypes.Add(listType);
            return(listType);
        }
Example #3
0
 private static void WriteDeleteContentListType(SchemaWriter writer, ContentListType contentListType, SchemaEditor origSchema, List <PropertySet> modifiedPropertySets)
 {
     writer.DeleteContentListType(contentListType);
     if (!modifiedPropertySets.Contains(contentListType))
     {
         modifiedPropertySets.Add(contentListType);
     }
 }
Example #4
0
 public void DeleteContentListType(ContentListType listType)
 {
     if (listType == null)
     {
         throw new ArgumentNullException("listType");
     }
     if (listType.SchemaRoot != this)
     {
         throw new SchemaEditorCommandException(SR.Exceptions.Schema.Msg_InconsistentHierarchy);
     }
     listType.PropertyTypes.Clear();
     this.ContentListTypes.Remove(listType);
 }
Example #5
0
        private static void ContentListTypeToXml(ContentListType lt, StringBuilder sb, string indent)
        {
            // <NodeType itemID="1" name="NodeType1">
            sb.Append(indent).Append("<ContentListType");
            sb.Append(" itemID=\"").Append(lt.Id).Append("\"");
            sb.Append(" name=\"").Append(lt.Name).Append("\"");

            if (lt.PropertyTypes.Count == 0)
            {
                sb.AppendLine(" />");
                return;
            }
            sb.AppendLine(">");

            foreach (PropertyType pt in lt.PropertyTypes)
            {
                PropertyTypeReferenceToXml(pt, sb, indent + "\t");
            }

            sb.Append(indent).AppendLine("</ContentListType>");
        }
Example #6
0
		private FieldSetting CreateNewFieldType(FieldDescriptor fieldInfo, Dictionary<string, List<string>> newBindings, ContentListType listType, SlotTable slotTable, SchemaEditor editor)
		{
			List<string> bindList = new List<string>();
			foreach (RepositoryDataType slotType in FieldManager.GetDataTypes(fieldInfo.FieldTypeShortName))
			{
				if (slotType == RepositoryDataType.NotDefined)
					continue;
				int slotNumber = slotTable.ReserveSlot((DataType)slotType);
				string binding = EncodeBinding(slotType, slotNumber);
				bindList.Add(binding);

				PropertyType pt = editor.PropertyTypes[binding];
				if (pt == null)
					pt = editor.CreateContentListPropertyType((DataType)slotType, slotNumber);
				editor.AddPropertyTypeToPropertySet(pt, listType);
			}
			newBindings.Add(fieldInfo.FieldName, bindList);

			return FieldSetting.Create(fieldInfo, bindList);
		}
Example #7
0
        private void Build(IXPathNavigable definitionXml, Dictionary<string, List<string>> bindings, bool modify)
        {
            XPathNavigator nav = definitionXml.CreateNavigator();
            XmlNamespaceManager nsres = new XmlNamespaceManager(nav.NameTable);
            XPathNavigator root = nav.SelectSingleNode("/*[1]", nsres);
            nsres.AddNamespace("x", root.NamespaceURI);
            List<FieldSetting> fieldSettings;

            Dictionary<string, FieldDescriptor> fieldDescriptorList = ParseContentTypeElement(root, nsres);
            _contentListType = ManageContentListType(fieldDescriptorList, bindings, modify, out fieldSettings);

            _fieldSettings = fieldSettings;
            SetFieldSlots();
        }
Example #8
0
 public abstract void DeleteContentListType(ContentListType contentListType);
Example #9
0
		private ContentListType CreateContentListType(int id, string name)
		{
            var listType = new ContentListType(id, name, this);
            this.ContentListTypes.Add(listType);
            return listType;
		}
Example #10
0
 public abstract void DeleteContentListType(ContentListType contentListType);
Example #11
0
        //---- when create new
        internal static NodeData CreateNewNodeData(Node parent, NodeType nodeType, ContentListType listType, int listId)
        {
            var listTypeId = listType == null ? 0 : listType.Id;
            var parentId = parent == null ? 0 : parent.Id;
            var userId = AccessProvider.Current.GetOriginalUser().Id;
            var name = String.Concat(nodeType.Name, "-", DateTime.Now.ToString("yyyyMMddHHmmss")); //Guid.NewGuid().ToString();
            var path = (parent == null) ? "/" + name : RepositoryPath.Combine(parent.Path, name);
            var now = DateTime.Now;
            var versionNumber = new VersionNumber(1, 0, VersionStatus.Approved);
            //---- when create new
            var privateData = new NodeData(nodeType, listType)
            {
                IsShared = false,
                SharedData = null,

                Id = 0,
                NodeTypeId = nodeType.Id,
                ContentListTypeId = listTypeId,
                ContentListId = listId,

                ParentId = parentId,
                Name = name,
                Path = path,
                Index = 0,
                IsDeleted = false,
                IsInherited = true,

                NodeCreationDate = now,
                NodeModificationDate = now,
                NodeCreatedById = userId,
                NodeModifiedById = userId,

                VersionId = 0,
                Version = versionNumber,
                CreationDate = now,
                ModificationDate = now,
                CreatedById = userId,
                ModifiedById = userId,

                Locked = false,
                LockedById = 0,
                ETag = null,
                LockType = 0,
                LockTimeout = 0,
                LockDate = DataProvider.Current.DateTimeMinValue,
                LockToken = null,
                LastLockUpdate = DataProvider.Current.DateTimeMinValue,
            };
            privateData.ModificationDateChanged = false;
            privateData.ModifiedByIdChanged = false;
            privateData.NodeModificationDateChanged = false;
            privateData.NodeModifiedByIdChanged = false;
            return privateData;
        }
Example #12
0
            public void DeleteContentListType(ContentListType contentListType)
			{
                _target.GetType().GetMethod("DeleteContentListType").Invoke(_target, new object[] { contentListType });
			}
Example #13
0
        public override void DeleteContentListType(ContentListType contentListType)
		{
			StringBuilder sb = new StringBuilder();
            if (contentListType == null)
                throw new ArgumentNullException("contentListType");
            sb.Append(CreateCommentLine("Delete ContentListType '", contentListType.Name, "'"));
			//-- <uj>
            sb.Append("DELETE FROM [dbo].[SchemaPropertySetsPropertyTypes] WHERE PropertySetId = ").Append(contentListType.Id).AppendLine();
			//-- <uj>
            sb.Append("DELETE FROM [dbo].[SchemaPropertySets] WHERE PropertySetId = ").Append(contentListType.Id).AppendLine();
			AddScript(sb);
		}
Example #14
0
		public void DeleteContentListType(ContentListType listType)
		{
            if (listType == null)
                throw new ArgumentNullException("listType");
            if (listType.SchemaRoot != this)
				throw new SchemaEditorCommandException(SR.Exceptions.Schema.Msg_InconsistentHierarchy);
            listType.PropertyTypes.Clear();
            this.ContentListTypes.Remove(listType);
		}
Example #15
0
		private bool RemoveUnusedFields(Dictionary<string, FieldDescriptor> fieldInfoList, Dictionary<string, List<string>> oldBindings, ContentListType listType, SchemaEditor editor)
		{
			bool hasChanges = false;
			for (int i = _fieldSettings.Count - 1; i >= 0; i--)
			{
				FieldSetting oldType = _fieldSettings[i];
				bool needtoDelete = !fieldInfoList.ContainsKey(oldType.Name);
				if (!needtoDelete)
				{
					FieldDescriptor newType = fieldInfoList[oldType.Name];
					if (oldType.DataTypes.Length != newType.DataTypes.Length)
					{
						needtoDelete = true;
					}
					else
					{
						for (int j = 0; j < oldType.DataTypes.Length; j++)
						{
							if (oldType.DataTypes[j] != newType.DataTypes[j])
							{
								needtoDelete = true;
								break;
							}
						}
					}
				}
				if (needtoDelete)
				{
					hasChanges = true;
					foreach (string binding in oldType.Bindings)
					{
						PropertyType oldPropertyType = editor.PropertyTypes[binding];
						editor.RemovePropertyTypeFromPropertySet(oldPropertyType, listType);
					}
					_fieldSettings.RemoveAt(i);
					oldBindings.Remove(oldType.Name);
				}
			}
			//-- Apply changes. Slot reusing prerequisit: values of unused slots must be null.
            //if (hasChanges)
            //    editor.Register();
            return hasChanges;
		}
Example #16
0
        protected override void OnLoaded(object sender, NodeEventArgs e)
        {
            base.OnLoaded(sender, e);

            _contentListType = (ContentListType)base.GetCachedData(CONTENTLISTTYPEKEY);
            if (_contentListType != null)
            {
                _fieldSettings = (List<FieldSetting>)base.GetCachedData(FIELDSETTINGSKEY);
                return;
            }

            Build();
            base.SetCachedData(FIELDSETTINGSKEY, _fieldSettings);
            base.SetCachedData(CONTENTLISTTYPEKEY, _contentListType);
        }
Example #17
0
		private static void ContentListTypeToXml(ContentListType lt, StringBuilder sb, string indent)
		{
			//		<NodeType itemID="1" name="NodeType1">
			sb.Append(indent).Append("<ContentListType");
			sb.Append(" itemID=\"").Append(lt.Id).Append("\"");
			sb.Append(" name=\"").Append(lt.Name).Append("\"");

			if (lt.PropertyTypes.Count == 0)
			{
                sb.AppendLine(" />");
				return;
			}
            sb.AppendLine(">");

			foreach (PropertyType pt in lt.PropertyTypes)
				PropertyTypeReferenceToXml(pt, sb, indent + "\t");

            sb.Append(indent).AppendLine("</ContentListType>");
		}