public string GetName(IObject element)
        {
            // Returns the name by the uml logic.
            var dataLayer = _dataLayerLogic?.GetDataLayerOfObject(element);
            var metaLayer = _dataLayerLogic?.GetMetaLayerFor(dataLayer);
            var uml = _dataLayerLogic?.Get<_UML>(metaLayer);
            if (uml != null && element.isSet(_UML._CommonStructure._NamedElement.name))
            {
                var result = element.get(_UML._CommonStructure._NamedElement.name);
                if (result != null)
                {
                    return result.ToString();
                }
            }

            // If the element is not uml induced or the property is empty, check by
            // the default "name" property
            if (element.isSet("name"))
            {
                return element.get("name").ToString();
            }

            // Ok, finally, we don't know what to do, so request retrieve the name just via ToString
            return element.ToString();
        }
        public bool IsProperty(IObject element)
        {
            var attributeXmi = "{" + Namespaces.Xmi + "}type";

            return element.isSet(attributeXmi) &&
                   element.get(attributeXmi).ToString() == "uml:Property";
        }
示例#3
0
        public static string GetName(IObject value)
        {
            if (value.isSet("name"))
            {
                return value.get("name").ToString();
            }

            return null;
        }
        /// <summary>
        /// Converts a given element to a json string, dependent on the column definition as given by the 
        /// ColumnCreationResult
        /// </summary>
        /// <param name="element"></param>
        /// <param name="creatorResult"></param>
        /// <returns></returns>
        private Dictionary<string, object> ConvertToJson(IObject element, ColumnCreationResult creatorResult)
        {
            var result = new Dictionary<string, object>();

            foreach (var property in creatorResult.Properties
                .Where(property => element.isSet(property)))
            {
                var propertyAsString = ColumnCreator.ConvertPropertyToColumnName(property);

                var propertyValue = element.get(property);

                if (creatorResult.ColumnsOnProperty[property].isEnumeration)
                {
                    if (propertyValue is IEnumerable && !(propertyValue is string))
                    {
                        var list = new List<object>();
                        foreach (var listValue in (propertyValue as IEnumerable))
                        {
                            var asElement = listValue as IElement;
                            string url;
                            if (asElement != null)
                            {
                                url = asElement.GetUri();
                            }
                            else
                            {
                                url = null;
                            }

                            list.Add(new
                            {
                                u = url,
                                v = listValue == null ? "null" : _resolution.GetName(listValue)
                            });
                        }

                        result[propertyAsString] = list;
                    }
                    else
                    {
                        result[propertyAsString] = propertyValue == null ? "null" : _resolution.GetName(propertyValue);
                    }
                }
                else
                {
                    result[propertyAsString] = propertyValue == null ? "null" : _resolution.GetName(propertyValue);
                }
            }

            return result;
        }