예제 #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;
            }
        }
        private async Task <bool> ReloadSecondaryMetadata()
        {
            var methods             = _conn.ApplyAsync(new Command(@"<AML>
  <Item type='Method' action='get' select='config_id,core,name,method_code,comments,execution_allowed_to,method_type'>
    <method_type condition='ne'>JavaScript</method_type>
  </Item>
  <Item type='Method' action='get' select='config_id,core,name,comments,method_type'>
    <method_type>JavaScript</method_type>
  </Item>
</AML>").WithAction(CommandAction.ApplyAML), true, false).ToTask();
            var sysIdents           = _conn.ApplyAsync(@"<Item type='Identity' action='get' select='id,name'>
  <name condition='in'>'World', 'Creator', 'Owner', 'Manager', 'Innovator Admin', 'Super User'</name>
</Item>", true, true).ToTask();
            var sqls                = _conn.ApplyAsync("<Item type='SQL' action='get' select='id,name,type'></Item>", true, false).ToTask();
            var customProps         = _conn.ApplyAsync(@"<Item type='Property' action='get' select='name,source_id(id,name)'>
  <created_by_id condition='ne'>AD30A6D8D3B642F5A2AFED1A4B02BEFA</created_by_id>
  <source_id>
    <Item type='ItemType' action='get'>
      <core>1</core>
      <created_by_id>AD30A6D8D3B642F5A2AFED1A4B02BEFA</created_by_id>
    </Item>
  </source_id>
</Item>", true, false).ToTask();
            var polyLists           = _conn.ApplyAsync(@"<Item type='Property' action='get' select='data_source(id)'>
  <name>itemtype</name>
  <data_type>list</data_type>
  <source_id>
    <Item type='ItemType' action='get'>
      <implementation_type>polymorphic</implementation_type>
    </Item>
  </source_id>
</Item>", true, false).ToTask();
            var sequences           = _conn.ApplyAsync(@"<Item type='Sequence' action='get' select='name'></Item>", true, false).ToTask();
            var elementTypes        = _conn.ApplyAsync(@"<Item action='get' type='cmf_ElementType' select='generated_type'>
  <Relationships>
    <Item action='get' type='cmf_PropertyType' select='generated_type'>
    </Item>
  </Relationships>
</Item>", true, false).ToTask();
            var contentTypes        = _conn.ApplyAsync(@"<Item action='get' type='cmf_ContentType' select='linked_item_type'>
  <linked_item_type>
    <Item type='ItemType' action='get'>
    </Item>
  </linked_item_type>
</Item>", true, false).ToTask();
            var presentationConfigs = _conn.ApplyAsync(@"<Item type='ITPresentationConfiguration' action='get' select='id,related_id'>
  <related_id>
    <Item type='PresentationConfiguration' action='get' select='id'>
      <name condition='like'>*_TOC_Configuration</name>
      <color condition='is null'></color>
      <Relationships>
        <Item action='get' type='cui_PresentConfigWinSection' select='id' />
        <Item action='get' type='PresentationCommandBarSection' select='id,related_id(id)' />
      </Relationships>
    </Item>
  </related_id>
</Item>", true, false).ToTask();
            var serverEvents        = _conn.ApplyAsync(@"<Item type='Server Event' action='get' related_expand='0' select='source_id,server_event,related_id,sort_order'>
</Item>", true, false).ToTask();
            var morphae             = _conn.ApplyAsync(@"<Item type='Morphae' action='get' related_expand='0' select='source_id,related_id'>
</Item>", true, false).ToTask();

            Methods = (await methods).Items().Select(i => new Method(i)).ToList();

            _systemIdentities = (await sysIdents).Items()
                                .Select(i =>
            {
                var itemRef       = ItemReference.FromFullItem(i, false);
                itemRef.KeyedName = i.Property("name").AsString("");
                return(itemRef);
            }).ToDictionary(i => i.Unique);


            _sql = (await sqls).Items()
                   .Select(i =>
            {
                var itemRef       = Sql.FromFullItem(i, false);
                itemRef.KeyedName = i.Property("name").AsString("");
                itemRef.Type      = i.Property("type").AsString("");
                return(itemRef);
            }).ToDictionary(i => i.KeyedName.ToLowerInvariant(), StringComparer.OrdinalIgnoreCase);

            var r = (await customProps);

            foreach (var customProp in r.Items())
            {
                var itemType = customProp.SourceItem();
                _customProps[new ItemProperty()
                             {
                                 ItemType = itemType.Property("name").Value,
                                 ItemTypeId = itemType.Id(),
                                 Property = customProp.Property("name").Value,
                                 PropertyId = customProp.Id()
                             }] = new ItemReference("Property", customProp.Id())
                {
                    KeyedName = customProp.Property("name").Value
                };
            }

            PolyItemLists = (await polyLists).Items()
                            .OfType <Innovator.Client.Model.Property>()
                            .Select(i => new ItemReference("List", i.DataSource().Value)
            {
                KeyedName = i.DataSource().KeyedName().Value
            }).ToArray();

            Sequences = (await sequences).Items().Select(i => ItemReference.FromFullItem(i, true)).ToArray();

            try
            {
                CmfGeneratedTypes = new HashSet <string>((await elementTypes).Items().SelectMany(x =>
                {
                    var relations = x.Relationships().Select(y => y.Property("generated_type").Value).ToList();
                    relations.Add(x.Property("generated_type").Value);
                    return(relations);
                }));

                CmfLinkedTypes = (await contentTypes).Items().ToDictionary(x => x.Property("linked_item_type").Value, y => ItemReference.FromFullItem(y, true));
            }
            catch (ServerException)
            {
                //TODO: Do something when cmf types don't exist
            }

            try
            {
                TocPresentationConfigs.Clear();
                TocPresentationConfigs.UnionWith((await presentationConfigs)
                                                 .Items()
                                                 .Select(i => i.RelatedItem())
                                                 .Where(i => i.Relationships().Count() == 1 &&
                                                        i.Relationships().Single().RelatedId().KeyedName().AsString("").EndsWith("_TOC_Content"))
                                                 .Select(i => i.Id()));
            }
            catch (ServerException)
            {
                //TODO: Do something
            }

            foreach (var serverEvent in (await serverEvents).Items())
            {
                var ev = new ServerEvent(serverEvent);
                if (_itemTypesById.TryGetValue(serverEvent.SourceId().Value, out var itemType))
                {
                    itemType.ServerEvents.Add(ev);
                }
                var method = Methods.FirstOrDefault(m => m.Unique == ev.Method.Unique);
                if (method != null)
                {
                    method.IsServerEvent = true;
                }
            }

            foreach (var poly in (await morphae).Items())
            {
                if (_itemTypesById.TryGetValue(poly.SourceId().Value, out var itemType))
                {
                    itemType.Morphae.Add(poly.RelatedId().Attribute("name").Value ?? poly.RelatedId().KeyedName().Value);
                }
            }

            return(true);
        }
예제 #3
0
        private async Task <bool> ReloadSecondaryMetadata()
        {
            var methods      = _conn.ApplyAsync("<Item type='Method' action='get' select='config_id,core,name'></Item>", true, false).ToTask();
            var sysIdents    = _conn.ApplyAsync(@"<Item type='Identity' action='get' select='id,name'>
                                      <name condition='in'>'World', 'Creator', 'Owner', 'Manager', 'Innovator Admin', 'Super User'</name>
                                    </Item>", true, true).ToTask();
            var sqls         = _conn.ApplyAsync("<Item type='SQL' action='get' select='id,name,type'></Item>", true, false).ToTask();
            var customProps  = _conn.ApplyAsync(@"<Item type='Property' action='get' select='name,source_id(id,name)'>
                                          <created_by_id condition='ne'>AD30A6D8D3B642F5A2AFED1A4B02BEFA</created_by_id>
                                          <source_id>
                                            <Item type='ItemType' action='get'>
                                              <core>1</core>
                                              <created_by_id>AD30A6D8D3B642F5A2AFED1A4B02BEFA</created_by_id>
                                            </Item>
                                          </source_id>
                                        </Item>", true, false).ToTask();
            var polyLists    = _conn.ApplyAsync(@"<Item type='Property' action='get' select='data_source(id)'>
                                          <name>itemtype</name>
                                          <data_type>list</data_type>
                                          <source_id>
                                            <Item type='ItemType' action='get'>
                                              <implementation_type>polymorphic</implementation_type>
                                            </Item>
                                          </source_id>
                                        </Item>", true, false).ToTask();
            var sequences    = _conn.ApplyAsync(@"<Item type='Sequence' action='get' select='name'></Item>", true, false).ToTask();
            var elementTypes = _conn.ApplyAsync(@"<Item action='get' type='cmf_ElementType' select='generated_type'>
                                                <Relationships>
                                                  <Item action='get' type='cmf_PropertyType' select='generated_type'>
                                                  </Item>
                                                </Relationships>
                                              </Item>", true, false).ToTask();
            var contentTypes = _conn.ApplyAsync(@"<Item action='get' type='cmf_ContentType' select='linked_item_type'>
                                              <linked_item_type>
                                                <Item type='ItemType' action='get'>
                                                </Item>
                                              </linked_item_type>
                                            </Item>", true, false).ToTask();

            _methods = (await methods).Items().Select(i =>
            {
                var method       = Method.FromFullItem(i, false);
                method.KeyedName = i.Property("name").AsString("");
                method.IsCore    = i.Property("core").AsBoolean(false);
                return(method);
            }).ToArray();


            _systemIdentities = (await sysIdents).Items()
                                .Select(i =>
            {
                var itemRef       = ItemReference.FromFullItem(i, false);
                itemRef.KeyedName = i.Property("name").AsString("");
                return(itemRef);
            }).ToDictionary(i => i.Unique);


            _sql = (await sqls).Items()
                   .Select(i =>
            {
                var itemRef       = Sql.FromFullItem(i, false);
                itemRef.KeyedName = i.Property("name").AsString("");
                itemRef.Type      = i.Property("type").AsString("");
                return(itemRef);
            }).ToDictionary(i => i.KeyedName.ToLowerInvariant(), StringComparer.OrdinalIgnoreCase);

            var           r = (await customProps);
            IReadOnlyItem itemType;

            foreach (var customProp in r.Items())
            {
                itemType = customProp.SourceItem();
                _customProps[new ItemProperty()
                             {
                                 ItemType = itemType.Property("name").Value,
                                 ItemTypeId = itemType.Id(),
                                 Property = customProp.Property("name").Value,
                                 PropertyId = customProp.Id()
                             }] = new ItemReference("Property", customProp.Id())
                {
                    KeyedName = customProp.Property("name").Value
                };
            }

            _polyItemLists = (await polyLists).Items()
                             .OfType <Innovator.Client.Model.Property>()
                             .Select(i => new ItemReference("List", i.DataSource().Value)
            {
                KeyedName = i.DataSource().KeyedName().Value
            }).ToArray();

            _sequences = (await sequences).Items().Select(i => ItemReference.FromFullItem(i, true)).ToArray();

            try
            {
                _cmfGeneratedTypes = new HashSet <string>((await elementTypes).Items().SelectMany(x =>
                {
                    var relations = x.Relationships().Select(y => y.Property("generated_type").Value).ToList();
                    relations.Add(x.Property("generated_type").Value);
                    return(relations);
                }));

                _cmfLinkedTypes = (await contentTypes).Items().ToDictionary(x => x.Property("linked_item_type").Value, y => ItemReference.FromFullItem(y, true));
            }
            catch (ServerException)
            {
                //TODO: Do something when cmf types don't exist
            }
            return(true);
        }
예제 #4
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;
            }
        }
예제 #5
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;
            }
        }