Ejemplo n.º 1
0
        /// <summary>
        /// Convert the case item to attributeitem collection.
        /// </summary>
        /// <param name="errorSet">The Error set.</param>
        /// <returns>Attribute item collection.</returns>
        public Collection<AttributeItem> ToNewFormatAttribute(ErrorSet errorSet)
        {
            Collection<AttributeItem> convertedAttributes = new Collection<AttributeItem>();
            ArrayList caseValueList = ConvertIntoArray(Value, errorSet);
            foreach (object obj in caseValueList)
            {
                AttributeItem attributeItem = new AttributeItem(AttributeItem.CaseCategoryName,
                    obj.ToString());
                attributeItem.Status = Status;
                convertedAttributes.Add(attributeItem);
            }

            return convertedAttributes;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// AddAttributeValue.
        /// </summary>
        /// <param name="attrName">Attribute name.</param>
        /// <param name="attrValue">Attribute value.</param>
        public void AddAttributeValue(string attrName, string attrValue)
        {
            if (AttributeSet.ContainsKey(attrName))
            {
                AttributeItem attribute = AttributeSet[attrName].Find(x => x.Value == attrValue);

                // if there has same attribute in original, update status
                if (attribute != null)
                {
                    if (attribute.Status == Lexicon.LexiconStatus.Deleted)
                    {
                        if (Status == Lexicon.LexiconStatus.Added)
                        {
                            attribute.Status = Lexicon.LexiconStatus.Added;
                        }
                        else
                        {
                            attribute.Status = Lexicon.LexiconStatus.Original;
                        }

                        attribute.Value = attrValue;
                    }
                }
                else
                {
                    AttributeItem attributeItem = new AttributeItem(attrName, attrValue);
                    attributeItem.Status = Lexicon.LexiconStatus.Added;
                    AddAttribute(attributeItem);
                }
            }
            else
            {
                AttributeItem attributeItem = new AttributeItem(attrName, attrValue);
                attributeItem.Status = Lexicon.LexiconStatus.Added;
                AddAttribute(attributeItem);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load AttributeItem from XmlNode.
        /// </summary>
        /// <param name="parentProperty">LexiconItemProperty.</param>
        /// <param name="attributeNode">XmlNode.</param>
        /// <param name="nsmgr">XmlNamespaceManager.</param>
        /// <param name="contentController">Object.</param>
        /// <param name="errorSet">ErrorSet.</param>
        /// <returns>AttributeItem.</returns>
        internal static AttributeItem Load(LexiconItemProperty parentProperty, XmlNode attributeNode, XmlNamespaceManager nsmgr, Lexicon.ContentControler contentController, ErrorSet errorSet)
        {
            Debug.Assert(parentProperty != null && parentProperty.Parent != null && parentProperty.Parent.Parent != null &&
                attributeNode != null && contentController != null && nsmgr != null);

            AttributeItem attributeItem = new AttributeItem();

            XmlElement attributeElem = attributeNode as XmlElement;
            Debug.Assert(attributeElem != null);
            string attrStatusValue = attributeElem.GetAttribute("s");
            if (!string.IsNullOrEmpty(attrStatusValue))
            {
                attributeItem.Status = (Lexicon.LexiconStatus)Enum.Parse(
                    typeof(Lexicon.LexiconStatus), attrStatusValue, true);

                // Lexicon object is shared with lexicon reviewer tool,
                // We drop those items if they have "deleted" status when it is not loaded by lexicon reviewer tool
                if (attributeItem.Status == Lexicon.LexiconStatus.Deleted && !contentController.IsHistoryCheckingMode)
                {
                    attributeItem = null;
                }
            }

            if (attributeItem != null)
            {
                string category = attributeElem.GetAttribute("category");
                string value = attributeElem.GetAttribute("value");
                string originalValue = attributeElem.GetAttribute("vo");

                if (string.IsNullOrEmpty(category))
                {
                    Error error = new Error(LexicalAttributeError.EmptyCategory);
                    errorSet.Add(LexiconError.AttributeError,
                        error, parentProperty.Parent.Parent.Text, parentProperty.Parent.Symbolic);
                    attributeItem = null;
                }
                else if (string.IsNullOrEmpty(value))
                {
                    Error error = new Error(LexicalAttributeError.EmptyValue);
                    errorSet.Add(LexiconError.AttributeError,
                        error, parentProperty.Parent.Parent.Text, parentProperty.Parent.Symbolic);
                    attributeItem = null;
                }
                else
                {
                    attributeItem.Value = value;
                    attributeItem.CategoryName = category;
                    if (!string.IsNullOrEmpty(originalValue) &&
                        attributeItem.Status != Lexicon.LexiconStatus.Original)
                    {
                        attributeItem.OldValue = originalValue;
                    }
                    else
                    {
                        attributeItem.OldValue = value;
                    }
                }
            }

            return attributeItem;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Add an attribute to now attribute list.
        /// </summary>
        /// <param name="attribute">New attribute.</param>
        public void AddAttribute(AttributeItem attribute)
        {
            if (_attributes.ContainsKey(attribute.CategoryName))
            {
                // if there are no duplicate attribute, add new attribute.
                if (!_attributes[attribute.CategoryName].Contains(attribute))
                {
                    _attributes[attribute.CategoryName].Add(attribute);
                }
            }
            else
            {
                List<AttributeItem> attrList = new List<AttributeItem>()
                {
                    attribute
                };

                _attributes.Add(attribute.CategoryName, attrList);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Clone current attribute.
 /// </summary>
 /// <returns>Cloned AttributeItem.</returns>
 public AttributeItem Clone()
 {
     AttributeItem clonedItem = new AttributeItem();
     this.CopyTo(clonedItem);
     clonedItem.CategoryName = CategoryName;
     return clonedItem;
 }