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; } }
public ItemType(IReadOnlyItem itemType, HashSet <string> coreIds = null) { Id = itemType.Id(); IsCore = itemType.Property("core").AsBoolean(coreIds?.Contains(itemType.Id()) == true); IsDependent = itemType.Property("is_dependent").AsBoolean(false); IsFederated = itemType.Property("implementation_type").Value == "federated"; IsPolymorphic = itemType.Property("implementation_type").Value == "polymorphic"; IsVersionable = itemType.Property("is_versionable").AsBoolean(false); Label = itemType.Property("label").Value; Name = itemType.Property("name").Value ?? itemType.KeyedName().Value ?? itemType.IdProp().KeyedName().Value; Reference = ItemReference.FromFullItem(itemType, true); Description = itemType.Property("description").Value; }
public ItemType(IReadOnlyItem itemType, HashSet <string> coreIds = null, bool defaultProperties = false, Func <string, string> getName = null) { var relType = itemType.Property("relationship_id").AsItem(); var sourceProp = itemType.SourceId(); SourceTypeName = sourceProp.Attribute("name").Value ?? sourceProp.KeyedName().Value; var relatedProp = itemType.RelatedId(); RelatedTypeName = relatedProp.Attribute("name").Value ?? relatedProp.KeyedName().Value; if (relType.Exists) { RelationshipTypeId = itemType.Id(); TabLabel = itemType.Property("label").Value; RelationshipView = itemType.Relationships("Relationship View") .FirstOrNullItem(i => i.Property("start_page").HasValue()) .Property("start_page").Value; itemType = relType; } Id = itemType.Id(); IsCore = itemType.Property("core").AsBoolean(coreIds?.Contains(itemType.Id()) == true); IsDependent = itemType.Property("is_dependent").AsBoolean(false); IsFederated = itemType.Property("implementation_type").Value == "federated"; IsRelationship = itemType.Property("is_relationship").AsBoolean(false); IsPolymorphic = itemType.Property("implementation_type").Value == "polymorphic"; IsVersionable = itemType.Property("is_versionable").AsBoolean(false); Label = itemType.Property("label").Value; Name = itemType.Property("name").Value ?? itemType.KeyedName().Value ?? itemType.IdProp().KeyedName().Value; Reference = ItemReference.FromFullItem(itemType, true); Description = itemType.Property("description").Value; if (itemType.Property("class_structure").HasValue()) { ClassStructure = new ClassStructure(itemType.Property("class_structure").Value); } DefaultPageSize = itemType.Property("default_page_size").AsInt(); MaxRecords = itemType.Property("maxrecords").AsInt(); HasLifeCycle = itemType.Relationships("ItemType Life Cycle").Any(); _properties = itemType.Relationships("Property") .Select(p => Property.FromItem(p, this, getName)) .ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase); if (_properties.Count > 0 || defaultProperties) { if (!_properties.ContainsKey("id")) { foreach (var property in ElementFactory.Local.FromXml(string.Format(_coreProperties, Id)) .Items() .Select(p => Property.FromItem(p, this)) .Where(p => !_properties.ContainsKey(p.Name))) { _properties[property.Name] = property; } } var propAml = @"<Item type='Property'> <column_alignment>left</column_alignment> <data_source keyed_name='{0}' type='ItemType' name='{0}'>{1}</data_source> <data_type>item</data_type> <is_hidden>{3}</is_hidden> <is_hidden2>1</is_hidden2> <is_indexed>1</is_indexed> <is_keyed>0</is_keyed> <is_multi_valued>0</is_multi_valued> <is_required>0</is_required> <item_behavior>float</item_behavior> <readonly>0</readonly> <sort_order>2944</sort_order> <name>{2}</name> </Item>"; if (sourceProp.Exists && !_properties.ContainsKey("source_id")) { _properties["source_id"] = Property.FromItem(ElementFactory.Local.FromXml(string.Format(propAml , SourceTypeName , sourceProp.Value , "source_id" , "1")).AssertItem(), this); } if (relatedProp.Exists && !_properties.ContainsKey("related_id")) { _properties["related_id"] = Property.FromItem(ElementFactory.Local.FromXml(string.Format(propAml , RelatedTypeName , relatedProp.Value , "related_id" , "0")).AssertItem(), this); } } WithExtra(itemType); }
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; } }
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; } }