Exemple #1
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;
            }
        }
Exemple #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())
                {
                    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;
            }
        }
Exemple #3
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;
            }
        }