Example #1
0
        internal static void FillItemRef(ItemReference result, IReadOnlyItem elem, bool getKeyedName)
        {
            result.Type = elem.Type().Value;
            if (elem.Attribute("id").Exists)
            {
                result.Unique = elem.Attribute("id").Value;
            }
            else if (elem.Attribute("where").Exists)
            {
                result.Unique = elem.Attribute("where").Value;
            }
            if (getKeyedName)
            {
                if (result.Type == "FileType" && elem.Property("mimetype").HasValue())
                {
                    result.KeyedName = elem.Property("extension").AsString("") + ", "
                                       + elem.Property("mimetype").AsString("");
                }
                else
                {
                    IReadOnlyProperty_Base node = elem.Property("id");
                    if (node.Exists && node.KeyedName().Exists)
                    {
                        result.KeyedName = node.KeyedName().Value;
                    }
                    else
                    {
                        result.KeyedName = node.Attribute("_keyed_name").Value
                                           ?? elem.KeyedName().AsString(null)
                                           ?? elem.Property("name").AsString(null);
                    }

                    node = elem.SourceId();
                    if (node.Exists && node.KeyedName().Exists)
                    {
                        if (result.KeyedName.IsGuid())
                        {
                            var related = elem.RelatedId();
                            if (related.Exists && related.KeyedName().Exists)
                            {
                                result.KeyedName = node.Attribute("keyed_name").Value + " > " + related.Attribute("keyed_name").Value;
                            }
                            else
                            {
                                result.KeyedName = node.Attribute("keyed_name").Value + ": " + result.KeyedName;
                            }
                        }
                        else if (!string.IsNullOrEmpty(node.Attribute("keyed_name").Value))
                        {
                            result.KeyedName += " {" + node.Attribute("keyed_name").Value + "}";
                        }
                    }
                }
            }
        }
Example #2
0
        public void Add(IReadOnlyItem item)
        {
            if (item.Attribute(XmlFlags.Attr_ScriptType).HasValue())
            {
                return;
            }

            switch (item.TypeName().ToLowerInvariant())
            {
            case "method":
                _methods.Add(new Method(item, _coreIds.Contains(item.ConfigId().Value ?? item.Id())));
                break;

            case "relationshiptype":
                if (item.Property("relationship_id").HasValue())
                {
                    Add(item.Property("relationship_id").AsItem());
                }
                break;

            case "itemtype":
                var itemType = new ItemType(item);
                if (string.IsNullOrEmpty(itemType.Name))
                {
                    return;
                }
                _itemTypesByName[itemType.Name] = itemType;
                Add(item.Relationships("Property"));
                break;

            case "sql":
                var sql = Sql.FromFullItem(item, false);
                sql.KeyedName = item.Property("name").Value
                                ?? item.KeyedName().Value
                                ?? item.IdProp().KeyedName().Value
                                ?? "";
                sql.Type = item.Property("type").AsString("");
                if (string.IsNullOrEmpty(sql.KeyedName))
                {
                    return;
                }
                _sql[sql.KeyedName.ToLowerInvariant()] = sql;
                break;

            case "property":
                _propertyNames[item.Id()] = item.Property("name").Value
                                            ?? item.KeyedName().Value
                                            ?? item.IdProp().KeyedName().Value;
                break;
            }
        }
Example #3
0
 /// <summary>Retrieve the <c>where</c> attribute of the item</summary>
 public static IReadOnlyAttribute Where(this IReadOnlyItem item)
 {
     return(item.Attribute("where"));
 }
Example #4
0
 /// <summary>Retrieve the <c>typeId</c> attribute of the item</summary>
 public static IReadOnlyAttribute TypeId(this IReadOnlyItem item)
 {
     return(item.Attribute("typeId"));
 }
Example #5
0
 /// <summary>Retrieve the <c>serverEvents</c> attribute of the item</summary>
 public static IReadOnlyAttribute ServerEvents(this IReadOnlyItem item)
 {
     return(item.Attribute("serverEvents"));
 }
Example #6
0
 /// <summary>Retrieve the <c>select</c> attribute of the item</summary>
 public static IReadOnlyAttribute Select(this IReadOnlyItem item)
 {
     return(item.Attribute("select"));
 }
Example #7
0
 /// <summary>Retrieve the <c>related_expand</c> attribute of the item</summary>
 public static IReadOnlyAttribute RelatedExpand(this IReadOnlyItem item)
 {
     return(item.Attribute("related_expand"));
 }
Example #8
0
 /// <summary>Retrieve the <c>queryType</c> attribute of the item</summary>
 public static IReadOnlyAttribute QueryType(this IReadOnlyItem item)
 {
     return(item.Attribute("queryType"));
 }
Example #9
0
 /// <summary>Retrieve the <c>pagesize</c> attribute of the item</summary>
 public static IReadOnlyAttribute PageSize(this IReadOnlyItem item)
 {
     return(item.Attribute("pagesize"));
 }
Example #10
0
 /// <summary>Retrieve the <c>orderBy</c> attribute of the item</summary>
 public static IReadOnlyAttribute OrderBy(this IReadOnlyItem item)
 {
     return(item.Attribute("orderBy"));
 }
Example #11
0
 /// <summary>Retrieve the <c>maxRecords</c> attribute of the item</summary>
 public static IReadOnlyAttribute MaxRecords(this IReadOnlyItem item)
 {
     return(item.Attribute("maxRecords"));
 }
Example #12
0
 /// <summary>Retrieve the <c>idlist</c> attribute of the item</summary>
 public static IReadOnlyAttribute IdList(this IReadOnlyItem item)
 {
     return(item.Attribute("idlist"));
 }
Example #13
0
 /// <summary>Retrieve the <c>doGetItem</c> attribute of the item</summary>
 public static IReadOnlyAttribute DoGetItem(this IReadOnlyItem item)
 {
     return(item.Attribute("doGetItem"));
 }
Example #14
0
 /// <summary>Retrieve the <c>action</c> attribute of the item</summary>
 public static IReadOnlyAttribute Action(this IReadOnlyItem item)
 {
     return(item.Attribute("action"));
 }
Example #15
0
        public void Add(IReadOnlyItem item)
        {
            if (item.Attribute(XmlFlags.Attr_ScriptType).HasValue())
            {
                return;
            }

            switch (item.TypeName().ToLowerInvariant())
            {
            case "method":
                _methods.Add(new Method(item, _coreIds.Contains(item.ConfigId().Value ?? item.Id())));
                break;

            case "relationshiptype":
                if (item.Property("relationship_id").HasValue())
                {
                    var relType = new ItemType(item, null, true);
                    if (string.IsNullOrEmpty(relType.Name))
                    {
                        return;
                    }
                    _itemTypesByName[relType.Name] = relType;
                    var source = _itemTypesByName.Values
                                 .FirstOrDefault(i => i.Id == item.SourceId().Value);
                    if (source != null)
                    {
                        source.Relationships.Add(relType);
                    }
                }
                break;

            case "itemtype":
                var itemType = new ItemType(item, null, item.Property("name").HasValue(), GetName);
                if (!string.IsNullOrEmpty(itemType.Name) && !_itemTypesByName.ContainsKey(itemType.Name))
                {
                    _itemTypesByName[itemType.Name] = itemType;
                    AddRange(item.Relationships("Property"));
                }
                else if (!string.IsNullOrEmpty(itemType.Id))
                {
                    _itemTypesByName.Values
                    .FirstOrDefault(i => i.Id == itemType.Id)
                    ?.WithScripts(item);
                }
                break;

            case "sql":
                var sql = Sql.FromFullItem(item, false);
                sql.KeyedName = item.Property("name").Value
                                ?? item.KeyedName().Value
                                ?? item.IdProp().KeyedName().Value
                                ?? "";
                sql.Type = item.Property("type").AsString("");
                if (string.IsNullOrEmpty(sql.KeyedName))
                {
                    return;
                }
                _sqlByName[sql.KeyedName.ToLowerInvariant()] = sql;
                break;

            case "property":
                _propertyNames[item.Id()] = item.Property("name").Value
                                            ?? item.KeyedName().Value
                                            ?? item.IdProp().KeyedName().Value;
                break;

            case "list":
                _listsById[item.Id()] = new DatabaseList(item);
                break;

            case "life cycle map":
            case "workflow map":
                if (item.Action().Value != "edit")
                {
                    Diagrams.Add(new StateDiagram(item));
                }
                break;
            }
        }
Example #16
0
        public void Add(IReadOnlyItem item)
        {
            if (item.Attribute(XmlFlags.Attr_ScriptType).HasValue())
            {
                return;
            }

            switch (item.TypeName().ToLowerInvariant())
            {
            case "method":
                var method = Method.FromFullItem(item, false);
                method.KeyedName = item.Property("name").AsString("");
                method.IsCore    = item.Property("core")
                                   .AsBoolean(_coreIds.Contains(item.ConfigId().Value ?? item.Id()));
                _methods.Add(method);
                break;

            case "itemtype":
                var itemType = new ItemType()
                {
                    Id     = item.Id(),
                    IsCore = item.Property("core")
                             .AsBoolean(_coreIds.Contains(item.Id())),
                    IsDependent   = item.Property("is_dependent").AsBoolean(false),
                    IsFederated   = item.Property("implementation_type").Value == "federated",
                    IsPolymorphic = item.Property("implementation_type").Value == "polymorphic",
                    IsVersionable = item.Property("is_versionable").AsBoolean(false),
                    Label         = item.Property("label").Value,
                    Name          = item.Property("name").Value
                                    ?? item.KeyedName().Value
                                    ?? item.IdProp().KeyedName().Value,
                    Reference = ItemReference.FromFullItem(item, true)
                };
                if (string.IsNullOrEmpty(itemType.Name))
                {
                    return;
                }
                _itemTypesByName[itemType.Name] = itemType;
                Add(item.Relationships("Property"));
                break;

            case "sql":
                var sql = Sql.FromFullItem(item, false);
                sql.KeyedName = item.Property("name").Value
                                ?? item.KeyedName().Value
                                ?? item.IdProp().KeyedName().Value
                                ?? "";
                sql.Type = item.Property("type").AsString("");
                if (string.IsNullOrEmpty(sql.KeyedName))
                {
                    return;
                }
                _sql[sql.KeyedName.ToLowerInvariant()] = sql;
                break;

            case "property":
                _propertyNames[item.Id()] = item.Property("name").Value
                                            ?? item.KeyedName().Value
                                            ?? item.IdProp().KeyedName().Value;
                break;
            }
        }