public DelegateContext(IServerConnection conn, IReadOnlyItem item) : base(conn, item) { var aml = conn.AmlContext; _assignment = aml.Item(aml.Type("Activity Assignment"), aml.Id(item.Property("AssignmentId").Value), aml.SourceId(aml.KeyedName(item.KeyedName()), aml.Type(item.Type().Value), item.Id()), aml.Property("id", item.Property("AssignmentId").Value) ); _delegate = aml.Item(aml.Type("Activity Assignment"), aml.Id(item.Property("ToAssignmentId").Value), aml.SourceId(aml.KeyedName(item.KeyedName()), aml.Type(item.Type().Value), item.Id()), aml.Property("id", item.Property("ToAssignmentId").Value) ); }
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; } }
/// <summary> /// Initializes a new instance of the <see cref="DelegateContext"/> class. /// </summary> /// <param name="conn">The connection.</param> /// <param name="item">The item.</param> public DelegateContext(IServerConnection conn, IReadOnlyItem item) : base(conn, item) { var aml = conn.AmlContext; Assignment = aml.Item(aml.Type("Activity Assignment"), aml.Id(item.Property("AssignmentId").Value), aml.SourceId(aml.KeyedName(item.KeyedName()), aml.Type(item.Type().Value), item.Id()), aml.Property("id", item.Property("AssignmentId").Value) ); DelegateTo = aml.Item(aml.Type("Activity Assignment"), aml.Id(item.Property("ToAssignmentId").Value), aml.SourceId(aml.KeyedName(item.KeyedName()), aml.Type(item.Type().Value), item.Id()), aml.Property("id", item.Property("ToAssignmentId").Value) ); }
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 + "}"; } } } } }
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 StateDiagram(IReadOnlyItem item) { Id = item.Id(); Type = item.TypeName(); Name = item.Property("name").Value ?? item.KeyedName().Value; Label = item.Property("label").Value; Nodes = item.Relationships("Life Cycle State") .Concat(item.Relationships("Workflow Map Activity") .Select(i => i.RelatedItem())) .Select(i => new StateNode(i)) .ToDictionary(n => n.Id); if (item.Property("start_state").HasValue() && Nodes.TryGetValue(item.Property("start_state").Value, out var startState)) { startState.Type = NodeType.Start; } Links = item.Relationships("Life Cycle Transition") .Concat(item.Relationships("Workflow Map Activity") .SelectMany(i => i.RelatedItem().Relationships("Workflow Map Path"))) .Select(i => new StateLink(i, Nodes)) .ToList(); }
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; } }