const double Factor = 0.375; // 0.375; #endregion Fields #region Methods /// <summary> /// Creates list of attributes for entity and supertypes. /// </summary> /// <param name="entity"></param> /// <returns></returns> public static void BuildAttributeList(DocEntity entity, List<DocAttribute> list, Dictionary<string, DocObject> map) { DocObject docBase = null; if (entity.BaseDefinition != null && map.TryGetValue(entity.BaseDefinition, out docBase)) { BuildAttributeList((DocEntity)docBase, list, map); } foreach (DocAttribute docAttr in entity.Attributes) { if (!String.IsNullOrEmpty(docAttr.Derived)) { // remove existing foreach (DocAttribute exist in list) { if (exist.Name.Equals(docAttr.Name)) { list.Remove(exist); break; } } } else { list.Add(docAttr); } } }
public string FormatEntity(DocEntity docEntity, Dictionary <string, DocObject> map, Dictionary <DocObject, bool> included) { StringBuilder sb = new StringBuilder(); sb.Append("CREATE TABLE "); sb.Append(docEntity.Name); sb.Append(" (oid INTEGER"); BuildFields(sb, docEntity, map); sb.Append(");"); sb.AppendLine(); foreach (DocAttribute docAttr in docEntity.Attributes) { if (docAttr.GetAggregation() != DocAggregationEnum.NONE && docAttr.Inverse == null) { sb.AppendLine(); sb.Append("CREATE TABLE "); sb.Append(docEntity.Name); sb.Append("_"); sb.Append(docAttr.Name); sb.Append(" (source INTEGER, sequence INTEGER, target INTEGER);"); } } return(sb.ToString()); }
private void CtlExpressG_DragDrop(object sender, DragEventArgs e) { DocEntity docEnt = e.Data.GetData(typeof(DocEntity)) as DocEntity; if (docEnt != null) { e.Effect = DragDropEffects.Move; if (!String.IsNullOrEmpty(docEnt.BaseDefinition)) { DocObject docBase = null; if (this.m_map.TryGetValue(docEnt.BaseDefinition, out docBase)) { if (docBase is DocEntity) { DocEntity docEntBase = (DocEntity)docBase; //...docEntBase. } } } foreach (DocAttribute docAttr in docEnt.Attributes) { //111docAttr. } } }
private void LoadPredefined() { if ((this.m_options & SelectDefinitionOptions.Predefined) == 0) { return; } this.labelPredefined.Enabled = false; this.comboBoxPredefined.Enabled = false; this.comboBoxPredefined.Items.Clear(); this.comboBoxPredefined.SelectedIndex = -1; this.comboBoxPredefined.Text = String.Empty; if (this.treeViewInheritance.SelectedNode == null) { return; } DocEntity entity = this.treeViewInheritance.SelectedNode.Tag as DocEntity; if (entity == null) { return; } foreach (DocAttribute docAttr in entity.Attributes) { if (docAttr.Name.Equals("PredefinedType")) { // resolve the type foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocType docType in docSchema.Types) { if (docType is DocEnumeration && docType.Name.Equals(docAttr.DefinedType)) { this.comboBoxPredefined.Items.Clear(); // found it DocEnumeration docEnum = (DocEnumeration)docType; foreach (DocConstant docConst in docEnum.Constants) { // new: in combobox this.comboBoxPredefined.Items.Add(docConst); } this.labelPredefined.Enabled = true; this.comboBoxPredefined.Enabled = true; //return; } } } } } } }
private void toolStripButtonRuleRef_Click(object sender, EventArgs e) { TreeNode tnSelect = this.treeViewTemplate.SelectedNode; DocModelRuleEntity docRule = (DocModelRuleEntity)tnSelect.Tag as DocModelRuleEntity; if (docRule == null) { return; } DocEntity docEntity = this.m_project.GetDefinition(docRule.Name) as DocEntity; if (docEntity == null) { return; } using (FormSelectTemplate form = new FormSelectTemplate(null, this.Project, docEntity)) { if (form.ShowDialog(this) == DialogResult.OK && form.SelectedTemplate != null) { // check for possible recursion if (form.SelectedTemplate == this.m_template || form.SelectedTemplate.IsTemplateReferenced(this.m_template)) { MessageBox.Show("Recursive template referencing is not supported."); return; } docRule.References.Add(form.SelectedTemplate); LoadTemplateGraph(tnSelect, docRule); } } }
private void CtlInheritance_MouseMove(object sender, MouseEventArgs e) { this.m_highlight = this.Pick(e.Location, out this.m_rcHighlight); switch (this.m_mode) { case ToolMode.Select: if (m_highlight != null) { this.Cursor = Cursors.Hand; } else { this.Cursor = Cursors.Default; } break; case ToolMode.Move: if (m_highlight != null) { this.Cursor = Cursors.UpArrow; } else { this.Cursor = Cursors.Default; } break; } this.Invalidate(); }
public static CvtValuePath FromTemplateDefinition(DocTemplateDefinition dtd, DocProject docProject) { if (dtd.Rules.Count > 0 && dtd.Rules[0] is DocModelRuleAttribute) { DocModelRuleAttribute docRuleAtt = (DocModelRuleAttribute)dtd.Rules[0]; DocEntity docEnt = docProject.GetDefinition(dtd.Type) as DocEntity; if (docEnt != null) { CvtValuePath pathInner = null; if (docRuleAtt.Rules.Count > 0 && docRuleAtt.Rules[0] is DocModelRuleEntity) { pathInner = FromModelRule((DocModelRuleEntity)docRuleAtt.Rules[0], docProject); } DocAttribute docAtt = docEnt.ResolveAttribute(docRuleAtt.Name, docProject); string identifier = null; if (docRuleAtt.Name.Equals("IsDefinedBy")) { // hack for compat docRuleAtt.ToString(); // look for identifier if (docRuleAtt.Rules.Count > 0) { try { DocModelRuleConstraint docRuleIndexCon = (DocModelRuleConstraint)docRuleAtt.Rules[0].Rules[0].Rules[0].Rules[1].Rules[0].Rules[0]; if (docRuleIndexCon != null) { if (docRuleIndexCon.Expression is DocOpStatement) { DocOpStatement docOpStatement = (DocOpStatement)docRuleIndexCon.Expression; if (docOpStatement.Value != null) { identifier = docOpStatement.Value.ToString(); if (identifier.StartsWith("'") && identifier.EndsWith("'")) { identifier = identifier.Substring(1, identifier.Length - 2); } } } } } catch { } } } CvtValuePath pathRoot = new CvtValuePath(docEnt, docAtt, identifier, pathInner); return(pathRoot); } } return(null); }
public FormSelectAttribute(DocEntity entity, DocProject project, string selection, bool freeform) : this() { this.textBoxAttributeName.Enabled = freeform; this.textBoxAttributeName.Text = selection; this.LoadEntity(entity, project, selection); }
public FormSelectAttribute(DocEntity entity, DocProject project, string selection, bool freeform) : this() { this.textBoxAttributeName.Enabled = freeform; this.textBoxAttributeName.Text = selection; this.LoadEntity(entity, project, selection); }
private void CtlExpressG_DragEnter(object sender, DragEventArgs e) { DocEntity docEnt = e.Data.GetData(typeof(DocEntity)) as DocEntity; if (docEnt != null) { e.Effect = DragDropEffects.Move; } }
private void LoadEntity(TreeNode tnParent, DocEntity entity) { if (entity == null) { return; // no such entity } if (this.m_mapInherit.ContainsKey(entity)) { return; } // add entity TreeNode tn = new TreeNode(); tn.Tag = entity; tn.Text = entity.Name; this.m_mapInherit.Add(entity, tn); if (tnParent != null) { tnParent.Nodes.Add(tn); } else { this.treeViewInheritance.Nodes.Add(tn); } if (this.m_selection == entity) { this.treeViewInheritance.SelectedNode = tn; } this.LoadPredefined(); // add subtypes SortedList <string, DocEntity> list = new SortedList <string, DocEntity>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { if (docEntity.BaseDefinition != null && docEntity.BaseDefinition.Equals(entity.Name)) { list.Add(docEntity.Name, docEntity); } } } } foreach (DocEntity ent in list.Values) { LoadEntity(tn, ent); } }
public void MainTest() { using (var session = Domain.OpenSession()) { using (var transaction = session.OpenTransaction()) { var interfacesDic = new Dictionary <int, Dictionary <Guid, string> >(); var numeratorsDict = new Dictionary <int, List <NumeratorInfo> >(); var fieldsDict = new Dictionary <int, List <DocFieldInfo> >(); var enEntityType = new DocEntity() { Name = "enEntityType", SysName = "enEntityType SysName", Description = "enEntityType Description" }; var linkedEntity = new DocEntity() { Name = "linkedEntity", SysName = "linkedEntity SysName", Description = "linkedEntity Description" }; var ownerEntity = new DocEntity() { Name = "ownerEntity", SysName = "ownerEntity SysName", Description = "ownerEntity Description" }; var docEntity = new DocEntity { Description = "docEntity Description", Name = "docEntity", SysName = "docEntity SysName", EnEntityType = enEntityType, LinkedEntity = linkedEntity, OwnerEntity = ownerEntity, }; session.SaveChanges(); var query = session.Query.All <DocEntity>().Select( q => new DocEntityInfo() { Caption = q.Name, Id = q.Id, Name = q.SysName, Description = q.Description, EntityTypeId = q.EnEntityType.Id, EntityTypeName = q.EnEntityType.SysName, LinkedEntitySysName = q.LinkedEntity != null ? q.LinkedEntity.SysName : null, OwnerEntitySysName = q.OwnerEntity != null ? q.OwnerEntity.SysName : null, FieldsInfo = fieldsDict.ContainsKey(q.Id) ? fieldsDict[q.Id] : new List <DocFieldInfo>(), NumeratorInfo = numeratorsDict.ContainsKey(q.Id) ? numeratorsDict[q.Id] : new List <NumeratorInfo>(), Interfaces = interfacesDic.ContainsKey(q.Id) ? interfacesDic[q.Id] : new Dictionary <Guid, string>() }).ToList(); var result = query.ToList(); } } }
private void LoadTemplates(List <DocTemplateDefinition> list) { foreach (DocTemplateDefinition docTemplate in list) { #if false bool include = false; // check for inheritance DocObject docApplicableEntity = null; if (this.m_entity == null) { include = true; } else if (docTemplate.Type != null && m_map.TryGetValue(docTemplate.Type, out docApplicableEntity) && docApplicableEntity is DocEntity) { // check for inheritance DocEntity docBase = this.m_entity; while (docBase != null) { if (docBase == docApplicableEntity) { include = true; break; } if (docBase.BaseDefinition == null) { break; } DocObject docEach = null; if (this.m_map.TryGetValue(docBase.BaseDefinition, out docEach)) { docBase = (DocEntity)docEach; } else { docBase = null; } } } else if (docTemplate.Type == null) { // recurse LoadTemplates(docTemplate.Templates); } if (include) { LoadTemplate(null, docTemplate); } #endif LoadTemplate(null, docTemplate); } }
public CheckGridEntity(DocConceptRoot docRoot, DocModelView docView, DocProject docProject, Dictionary <string, DocObject> map) { this.m_root = docRoot; this.m_view = docView; this.m_project = docProject; this.m_listTemplate = new List <DocTemplateDefinition>(); List <DocTemplateDefinition> listTemplate = docProject.GetTemplateList(); //... filter out templates to only those that apply to entity... foreach (DocTemplateDefinition docTemplate in listTemplate) { if (docTemplate.Rules != null && docTemplate.Rules.Count > 0) // don't include abstract/organizational templates { bool include = false; // check for inheritance DocObject docApplicableEntity = null; if (docTemplate.Type != null && map.TryGetValue(docTemplate.Type, out docApplicableEntity) && docApplicableEntity is DocEntity) { // check for inheritance DocEntity docBase = docRoot.ApplicableEntity; while (docBase != null) { if (docBase == docApplicableEntity) { include = true; break; } if (docBase.BaseDefinition == null) { break; } DocObject docEach = null; if (map.TryGetValue(docBase.BaseDefinition, out docEach)) { docBase = (DocEntity)docEach; } else { docBase = null; } } } if (include) { this.m_listTemplate.Add(docTemplate); } } } }
public CellValue GetCell(int row, int col) { if (col >= this.m_listTemplate.Count || row >= this.m_view.ConceptRoots.Count) { return(CellValue.Unavailable); } DocTemplateDefinition docTemplate = this.m_listTemplate[col]; DocConceptRoot docRoot = this.m_view.ConceptRoots[row]; // return Unavailable if template is incompatible with root bool applicable = false; DocDefinition docDef = this.m_project.GetDefinition(docTemplate.Type); DocEntity docEnt = docRoot.ApplicableEntity; while (docEnt != null) { if (docEnt == docDef) { applicable = true; break; } docEnt = this.m_project.GetDefinition(docEnt.BaseDefinition) as DocEntity; } if (!applicable) { return(CellValue.Unavailable); } foreach (DocTemplateUsage docUsage in docRoot.Concepts) { if (docUsage.Definition == docTemplate) { foreach (DocExchangeItem docExchangeItem in docUsage.Exchanges) { if (docExchangeItem.Exchange == this.m_exchange && docExchangeItem.Applicability == DocExchangeApplicabilityEnum.Export) { switch (docExchangeItem.Requirement) { case DocExchangeRequirementEnum.Mandatory: return(CellValue.Required); case DocExchangeRequirementEnum.Optional: return(CellValue.Optional); } } } } } return(CellValue.None); }
public EntityNode(DocEntity entity, Model model) { _entity = entity; _model = model; _children = model .Get <DocEntity>(e => string.Equals(_entity.Name, e.BaseDefinition, StringComparison.CurrentCultureIgnoreCase)) .Select(e => new EntityNode(e, model)) .OrderBy(e => e.Name) .ToList(); _children.ForEach(c => c.Parent = this); }
private static CvtValuePath FromModelRule(DocModelRuleEntity docRuleEntity, DocProject docProject) { DocDefinition docDef = docProject.GetDefinition(docRuleEntity.Name); DocAttribute docAtt = null; string identifier = null; CvtValuePath pathInner = null; if (docDef is DocEntity && docRuleEntity.Rules.Count > 0 && docRuleEntity.Rules[0] is DocModelRuleAttribute) { DocModelRuleAttribute docRuleAtt = (DocModelRuleAttribute)docRuleEntity.Rules[0]; DocEntity docEnt = (DocEntity)docDef; docAtt = docEnt.ResolveAttribute(docRuleAtt.Name, docProject); if (docRuleAtt.Rules.Count > 0 && docRuleAtt.Rules[0] is DocModelRuleEntity) { DocModelRuleEntity docRuleInner = (DocModelRuleEntity)docRuleAtt.Rules[0]; pathInner = FromModelRule(docRuleInner, docProject); // look for identifier if (docRuleInner.Rules.Count > 1 && docRuleInner.Rules[1] is DocModelRuleAttribute) { DocModelRuleAttribute docRuleIndexAtt = (DocModelRuleAttribute)docRuleInner.Rules[1]; if (docRuleIndexAtt.Rules.Count > 0) { DocModelRuleEntity docRuleIndexEnt = (DocModelRuleEntity)docRuleIndexAtt.Rules[0]; if (docRuleIndexEnt.Rules.Count > 0 && docRuleIndexEnt.Rules[0] is DocModelRuleConstraint) { DocModelRuleConstraint docRuleIndexCon = (DocModelRuleConstraint)docRuleIndexEnt.Rules[0]; if (docRuleIndexCon.Expression is DocOpStatement) { DocOpStatement docOpStatement = (DocOpStatement)docRuleIndexCon.Expression; if (docOpStatement.Value != null) { identifier = docOpStatement.Value.ToString(); if (identifier.StartsWith("'") && identifier.EndsWith("'")) { identifier = identifier.Substring(1, identifier.Length - 2); } } } } } } } } CvtValuePath pathOuter = new CvtValuePath(docDef, docAtt, identifier, pathInner); return(pathOuter); }
private void WriteList(System.IO.StreamWriter writer, SortedList <string, DocObject> sortlist) { foreach (string key in sortlist.Keys) { DocObject docEntity = sortlist[key]; WriteItem(writer, docEntity, 0, docEntity.Name); if (docEntity is DocEntity) { DocEntity docEnt = (DocEntity)docEntity; foreach (DocAttribute docAttr in docEnt.Attributes) { WriteItem(writer, docAttr, 1, docEntity.Name); } } else if (docEntity is DocEnumeration) { DocEnumeration docEnum = (DocEnumeration)docEntity; foreach (DocConstant docConst in docEnum.Constants) { WriteItem(writer, docConst, 1, docEntity.Name); } } else if (docEntity is DocPropertySet) { DocPropertySet docPset = (DocPropertySet)docEntity; foreach (DocProperty docProp in docPset.Properties) { WriteItem(writer, docProp, 1, docEntity.Name); } } else if (docEntity is DocPropertyEnumeration) { DocPropertyEnumeration docPE = (DocPropertyEnumeration)docEntity; foreach (DocPropertyConstant docPC in docPE.Constants) { WriteItem(writer, docPC, 1, docEntity.Name); } } else if (docEntity is DocQuantitySet) { DocQuantitySet docQset = (DocQuantitySet)docEntity; foreach (DocQuantity docQuan in docQset.Quantities) { WriteItem(writer, docQuan, 1, docEntity.Name); } } } }
public FormSelectProperty(DocEntity docEntity, DocProject docProject, bool multiselect) : this() { this.m_entity = docEntity; this.m_project = docProject; if (multiselect) { this.treeViewProperty.CheckBoxes = true; this.Text = "Include Property Sets"; this.comboBoxPort.Enabled = false; } else { // find applicable ports this.comboBoxPort.Items.Add("(object)"); this.comboBoxPort.SelectedIndex = 0; if (docEntity != null) { foreach (DocModelView docView in docProject.ModelViews) { foreach (DocConceptRoot docRoot in docView.ConceptRoots) { if (docRoot.ApplicableEntity == docEntity) { foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if (docConcept.Definition != null && docConcept.Definition.Uuid == DocTemplateDefinition.guidPortNesting) { foreach (DocTemplateItem docItem in docConcept.Items) { string name = docItem.GetParameterValue("Name"); if (name != null && !this.comboBoxPort.Items.Contains(name)) { this.comboBoxPort.Items.Add(name); } } } } } } } } } this.LoadPropertySets(); }
private void treeViewAlphabetical_AfterSelect(object sender, TreeViewEventArgs e) { if (this.treeViewAlphabetical.SelectedNode == null) { return; } DocEntity entity = this.treeViewAlphabetical.SelectedNode.Tag as DocEntity; if (entity != null) { this.treeViewInheritance.SelectedNode = this.m_mapInherit[entity]; } this.LoadPredefined(); }
public void AdditionalTest() { using (var session = Domain.OpenSession()) { using (var transaction = session.OpenTransaction()) { var interfacesDic = new Dictionary <int, Dictionary <Guid, string> >(); var numeratorsDict = new Dictionary <int, List <NumeratorInfo> >(); var fieldsDict = new Dictionary <int, List <DocFieldInfo> >(); var enEntityType = new DocEntity() { Name = "enEntityType", SysName = "enEntityType SysName", Description = "enEntityType Description" }; var linkedEntity = new DocEntity() { Name = "linkedEntity", SysName = "linkedEntity SysName", Description = "linkedEntity Description" }; var ownerEntity = new DocEntity() { Name = "ownerEntity", SysName = "ownerEntity SysName", Description = "ownerEntity Description" }; var docEntity = new DocEntity { Description = "docEntity Description", Name = "docEntity", SysName = "docEntity SysName", EnEntityType = enEntityType, LinkedEntity = linkedEntity, OwnerEntity = ownerEntity, }; session.SaveChanges(); var q = session.Query.All <DocEntity>() .GroupBy(tpf => tpf.EnEntityType.Id) .Select(gr => new { V = gr.Select(a => new DynamicFilterInfo() { SourceSysName = a.OwnerEntity != null ? a.OwnerEntity.SysName : null, FilteredSysName = a.LinkedEntity != null ? a.LinkedEntity.SysName : null, }) }) .First(); } } }
private void toolStripButtonTemplate_Click(object sender, EventArgs e) { DocEntity docBaseEntity = this.m_project.GetDefinition(this.m_template.Type) as DocEntity; if (this.m_conceptroot != null && this.m_conceptroot.ApplicableEntity != null) { docBaseEntity = this.m_conceptroot.ApplicableEntity; } using (FormSelectTemplate form = new FormSelectTemplate(this.Template, this.m_project, docBaseEntity)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { this.ChangeTemplate(form.SelectedTemplate); } } }
private DocEntity Pick(Point pt, out Rectangle rectangle) { rectangle = Rectangle.Empty; pt.X -= this.AutoScrollPosition.X; pt.Y -= this.AutoScrollPosition.Y; foreach (Rectangle rc in this.m_hitmap.Keys) { if (rc.Contains(pt)) { rectangle = rc; DocEntity docEnt = this.m_hitmap[rc]; return(docEnt); } } return(null); }
private void LoadEntity(DocEntity entity, DocProject project, string selection) { if (entity == null) { return; } // recurse to base if (entity.BaseDefinition != null) { DocEntity docBase = project.GetDefinition(entity.BaseDefinition) as DocEntity; LoadEntity(docBase, project, selection); } // load attributes foreach (DocAttribute docAttr in entity.Attributes) { // if attribute is derived, dont add, but remove existing if (!String.IsNullOrEmpty(docAttr.Derived)) { foreach (ListViewItem lvi in this.listView.Items) { if (lvi.Text.Equals(docAttr.Name)) { lvi.Remove(); break; } } } else { ListViewItem lvi = new ListViewItem(); lvi.Tag = docAttr; lvi.Text = docAttr.Name; lvi.SubItems.Add(docAttr.DefinedType); // INVERSE / SET / LIST / OPTIONAL... this.listView.Items.Add(lvi); if (selection != null && lvi.Text.Equals(selection)) { lvi.Selected = true; } } } }
private void LoadEntity(DocEntity entity, DocProject project, string selection) { if (entity == null) return; // recurse to base if (entity.BaseDefinition != null) { DocEntity docBase = project.GetDefinition(entity.BaseDefinition) as DocEntity; LoadEntity(docBase, project, selection); } // load attributes foreach (DocAttribute docAttr in entity.Attributes) { // if attribute is derived, dont add, but remove existing if (!String.IsNullOrEmpty(docAttr.Derived)) { foreach (ListViewItem lvi in this.listView.Items) { if (lvi.Text.Equals(docAttr.Name)) { lvi.Remove(); break; } } } else { ListViewItem lvi = new ListViewItem(); lvi.Tag = docAttr; lvi.Text = docAttr.Name; lvi.SubItems.Add(docAttr.DefinedType); // INVERSE / SET / LIST / OPTIONAL... this.listView.Items.Add(lvi); if(selection != null && lvi.Text.Equals(selection)) { lvi.Selected = true; } } } }
private void toolStripButtonQuantity_Click(object sender, EventArgs e) { DocEntity docBaseEntity = this.m_project.GetDefinition(this.m_template.Type) as DocEntity; if (this.m_conceptroot != null && this.m_conceptroot.ApplicableEntity != null) { docBaseEntity = this.m_conceptroot.ApplicableEntity; } using (FormSelectQuantity form = new FormSelectQuantity(docBaseEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string value = form.GenerateValuePath(); Dictionary <string, DocObject> mapEntity = new Dictionary <string, DocObject>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { mapEntity.Add(docEntity.Name, docEntity); } foreach (DocType docType in docSchema.Types) { mapEntity.Add(docType.Name, docType); } } } CvtValuePath valuepath = CvtValuePath.Parse(value, mapEntity); this.ChangeTemplate(valuepath.ToTemplateDefinition()); this.LoadTemplateGraph(); this.ContentChanged(this, EventArgs.Empty); } } }
private void CtlInheritance_MouseDown(object sender, MouseEventArgs e) { this.m_selection = this.Pick(e.Location, out this.m_rcSelection); switch (this.m_mode) { case ToolMode.Select: if (this.SelectionChanged != null) { this.SelectionChanged(this, EventArgs.Empty); } break; case ToolMode.Move: if (this.m_selection != null) { this.m_selection._InheritanceDiagramFlag = !this.m_selection._InheritanceDiagramFlag; this.m_selection.Status = (this.m_selection._InheritanceDiagramFlag ? "H" : String.Empty); this.Render(); } break; } }
public async Task Write(int numberOfDocuments, int docSize) { using (var bulkInsert = store.BulkInsert()) { for (long i = 0; i < numberOfDocuments; i++) { if ((i % (16 * 1024)) == 0) { Console.WriteLine($"{SystemTime.UtcNow:G} : Progress {i:##,###} out of {numberOfDocuments} ..."); } var entity = new DocEntity { SerialId = i, RandomId = _random.Next(), }; await bulkInsert.StoreAsync(entity, $"items|").ConfigureAwait(false); } await bulkInsert.DisposeAsync().ConfigureAwait(false); } }
/// <summary> /// /// </summary> /// <param name="selection">Selected template.</param> /// <param name="project">Projet containing templates.</param> /// <param name="entity">The entity for which templates are filtered.</param> public FormSelectTemplate(DocTemplateDefinition selection, DocProject project, DocEntity entity) : this() { this.m_selection = selection; this.m_project = project; this.m_entity = entity; // build map this.m_map = new Dictionary<string, DocObject>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { if(!this.m_map.ContainsKey(docEntity.Name)) { m_map.Add(docEntity.Name, docEntity); } } foreach (DocType docType in docSchema.Types) { try { m_map.Add(docType.Name, docType); } catch { } } } } LoadTemplates(project.Templates); }
/// <summary> /// /// </summary> /// <param name="selection">Selected template.</param> /// <param name="project">Projet containing templates.</param> /// <param name="entity">The entity for which templates are filtered.</param> public FormSelectTemplate(DocTemplateDefinition selection, DocProject project, DocEntity entity) : this() { this.m_selection = selection; this.m_project = project; this.m_entity = entity; // build map this.m_map = new Dictionary <string, DocObject>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { if (!this.m_map.ContainsKey(docEntity.Name)) { m_map.Add(docEntity.Name, docEntity); } } foreach (DocType docType in docSchema.Types) { try { m_map.Add(docType.Name, docType); } catch { } } } } LoadTemplates(null, project.Templates); }
private static string FormatConceptTable( DocProject docProject, DocModelView docModelView, DocEntity entity, DocConceptRoot root, DocTemplateUsage usage, Dictionary<string, DocObject> mapEntity, Dictionary<string, string> mapSchema) { StringBuilder sb = new StringBuilder(); DocTemplateItem[] listItems = FindTemplateItems(docProject, entity, usage.Definition, docModelView); if(listItems.Length == 0) { // scenario for referenced inner templates listItems = usage.Items.ToArray(); } // new way with table DocModelRule[] parameters = usage.Definition.GetParameterRules(); if (parameters != null && parameters.Length > 0 && listItems.Length > 0) { // check if descriptions are provided bool showdescriptions = false; foreach (DocTemplateItem item in listItems) { if (item.Documentation != null) { showdescriptions = true; break; } } sb.AppendLine("<table class=\"gridtable\">"); // header sb.Append("<tr>"); foreach (DocModelRule parameter in parameters) { sb.Append("<th><b>"); sb.Append(parameter.Identification); sb.Append("</b></th>"); } if (showdescriptions) { sb.Append("<th><b>Description</b></th>"); } sb.AppendLine("</tr>"); // items foreach (DocTemplateItem item in listItems) { sb.Append("<tr>"); foreach (DocModelRule parameter in parameters) { string value = item.GetParameterValue(parameter.Identification); string schema = null; if(parameter.Name.Equals("Columns")) { parameter.ToString(); } sb.Append("<td>"); //if (value != null) { DocDefinition docDef = usage.Definition.GetParameterType(parameter.Identification, mapEntity); if (docDef is DocEnumeration) { if(value != null) { schema = mapSchema[docDef.Name]; sb.Append("<a href=\"../../"); sb.Append(schema.ToLower()); sb.Append("/lexical/"); sb.Append(docDef.Name.ToLower()); sb.Append(".htm\">"); sb.Append(value); sb.Append("</a>"); } } else if (docDef is DocEntity) { DocTemplateDefinition docTemplateInner = null; if (parameter is DocModelRuleAttribute) { DocModelRuleAttribute dma = (DocModelRuleAttribute)parameter; foreach(DocModelRule docInnerRule in dma.Rules) { if (docInnerRule is DocModelRuleEntity) { DocModelRuleEntity dme = (DocModelRuleEntity)docInnerRule; if (dme.References.Count == 1) { docTemplateInner = dme.References[0]; DocTemplateUsage docConceptInner = item.GetParameterConcept(parameter.Identification, docTemplateInner); if (docConceptInner != null) { string inner = FormatConceptTable(docProject, docModelView, (DocEntity)docDef, root, docConceptInner, mapEntity, mapSchema); sb.Append("<a href=\"../../templates/" + MakeLinkName(docTemplateInner) + ".htm\">" + docTemplateInner.Name + "</a><br/>"); sb.Append(inner); } } } } } if (docTemplateInner == null && value != null && mapSchema.TryGetValue(value, out schema)) { if(value.StartsWith("Pset_")) { value.ToString(); } sb.Append("<a href=\"../../"); sb.Append(schema.ToLower()); sb.Append("/lexical/"); sb.Append(value.ToLower()); sb.Append(".htm\">"); sb.Append(value); sb.Append("</a>"); } else if(docDef.Name.Equals("IfcReference")) { // ...hyperlinks if(value != null) { string[] parts = value.Split('\\'); foreach(string part in parts) { string[] tokens = part.Split('.'); if (tokens.Length > 0) { sb.Append("\\"); DocDefinition docToken = docProject.GetDefinition(tokens[0]); if (docToken != null) { DocSchema docSchema = docProject.GetSchemaOfDefinition(docToken); string relative = @"../../"; string hyperlink = relative + docSchema.Name.ToLower() + @"/lexical/" + docToken.Name.ToLower() + ".htm"; string format = "<a href=\"" + hyperlink + "\">" + tokens[0] + "</a>"; sb.Append(format); } if (tokens.Length > 1) { sb.Append("."); sb.Append(tokens[1]); } sb.Append("<br>"); } } } //sb.Append(value); } else if(value != null) { sb.Append(value); } } else if (docDef != null && value != null) { value = FormatField(docProject, value, value, docDef.Name, value); sb.Append(value); } else if (value != null) { sb.Append(value); } else { sb.Append(" "); } } /* else { sb.Append(" "); }*/ sb.Append("</td>"); } if (showdescriptions) { sb.Append("<td>"); if (item.Documentation != null) { sb.Append(item.Documentation); } else { sb.Append(" "); } sb.Append("</td>"); } sb.AppendLine("</tr>"); } sb.AppendLine("</table>"); } return sb.ToString(); }
public void Load() { svg s = null; using (FormatXML format = new FormatXML(this.m_filename, typeof(svg), "http://www.w3.org/2000/svg")) { format.Load(); s = format.Instance as svg; } if (s == null) { return; } // apply diagram to existing schema elements foreach (g group in s.g) { // primitive DocDefinition docDef = null; switch (group.id) { case "INTEGER": case "REAL": case "BOOLEAN": case "LOGICAL": case "STRING": case "BINARY": docDef = new DocPrimitive(); docDef.Name = group.id; m_schema.Primitives.Add((DocPrimitive)docDef); break; default: docDef = this.m_schema.GetDefinition(group.id); break; } if (docDef != null) { docDef.DiagramRectangle = LoadRectangle(group); // attributes, supertype... if (docDef is DocEntity) { DocEntity docEnt = (DocEntity)docDef; LoadTree(group, docEnt.Tree); foreach (g subgroup in group.groups) { foreach (DocAttribute docAttr in docEnt.Attributes) { if (docAttr.Name.Equals(subgroup.id)) { LoadLine(subgroup, docAttr.DiagramLine); if (subgroup.text.Count == 1) { double ax = Double.Parse(subgroup.text[0].x) / CtlExpressG.Factor; double ay = Double.Parse(subgroup.text[0].y) / CtlExpressG.Factor; docAttr.DiagramLabel = new DocRectangle(); docAttr.DiagramLabel.X = ax; docAttr.DiagramLabel.Y = ay; } break; } } } // base type??? } else if (docDef is DocDefined) { DocDefined docDefined = (DocDefined)docDef; LoadLine(group, docDefined.DiagramLine); } else if (docDef is DocSelect) { DocSelect docSelect = (DocSelect)docDef; LoadTree(group, docSelect.Tree); } } else { // schema ref DocSchema docTargetSchema = this.m_project.GetSchema(group.id); if (docTargetSchema != null) { DocSchemaRef docSchemaRef = new DocSchemaRef(); docSchemaRef.Name = group.id; this.m_schema.SchemaRefs.Add(docSchemaRef); foreach (g subgroup in group.groups) { DocDefinition docTargetDef = docTargetSchema.GetDefinition(subgroup.id); if (docTargetDef != null) { DocDefinitionRef docDefRef = new DocDefinitionRef(); docDefRef.Name = subgroup.id; docSchemaRef.Definitions.Add(docDefRef); docDefRef.DiagramRectangle = LoadRectangle(subgroup); LoadTree(subgroup, docDefRef.Tree); } } } else { // primitive? // page targets DocPageTarget docPageTarget = new DocPageTarget(); docPageTarget.Name = group.id; this.m_schema.PageTargets.Add(docPageTarget); docPageTarget.DiagramRectangle = LoadRectangle(group); //...docPageTarget.Definition = LoadLine(group, docPageTarget.DiagramLine); foreach (g subgroup in group.groups) { DocPageSource docPageSource = new DocPageSource(); docPageSource.Name = subgroup.id; docPageTarget.Sources.Add(docPageSource); docPageSource.DiagramRectangle = LoadRectangle(subgroup); } } } } }
private static bool EntityIncludes(DocEntity docEntity, string defname, Dictionary<string, DocObject> map) { // traverse subtypes DocObject docTest = null; if (!map.TryGetValue(defname, out docTest)) return false; if (!(docTest is DocEntity)) return false; DocEntity docTestEntity = (DocEntity)docTest; if (docTestEntity.BaseDefinition == null) return false; if (docTestEntity.BaseDefinition == docEntity.Name) return true; // recurse upwards return EntityIncludes(docEntity, docTestEntity.BaseDefinition, map); }
public string FormatEntity(DocEntity docEntity, Dictionary<string, DocObject> map, Dictionary<DocObject, bool> included) { return FormatEntityFull(docEntity, map, included, false); }
internal static void ImportCnfAttribute(IfcDoc.Schema.CNF.exp_attribute exp_attribute, bool keep, Schema.CNF.boolean_or_unspecified tagless, DocEntity docEntity, DocAttribute docAttribute, DocModelView docView) { DocXsdFormatEnum xsdformat = DocXsdFormatEnum.Default; if (exp_attribute == Schema.CNF.exp_attribute.attribute_content) { xsdformat = DocXsdFormatEnum.Content; } else if (exp_attribute == Schema.CNF.exp_attribute.attribute_tag) { xsdformat = DocXsdFormatEnum.Attribute; } else if (exp_attribute == Schema.CNF.exp_attribute.double_tag) { xsdformat = DocXsdFormatEnum.Element; } else if (!keep) { xsdformat = DocXsdFormatEnum.Hidden; } else { xsdformat = DocXsdFormatEnum.Element; } bool? booltagless = null; switch (tagless) { case Schema.CNF.boolean_or_unspecified.boolean_true: booltagless = true; break; case Schema.CNF.boolean_or_unspecified.boolean_false: booltagless = false; break; } if (docView != null) { // configure specific model view DocXsdFormat docFormat = new DocXsdFormat(); docFormat.Entity = docEntity.Name; docFormat.Attribute = docAttribute.Name; docFormat.XsdFormat = xsdformat; docFormat.XsdTagless = booltagless; docView.XsdFormats.Add(docFormat); } else { // configure default docAttribute.XsdFormat = xsdformat; docAttribute.XsdTagless = booltagless; } }
internal static void ImportXsdComplex(IfcDoc.Schema.XSD.complexType complex, DocSchema docSchema, DocEntity docEntity) { if (complex == null) return; foreach (IfcDoc.Schema.XSD.attribute att in complex.attribute) { ImportXsdAttribute(att, docSchema, docEntity); } if (complex.choice != null) { foreach (IfcDoc.Schema.XSD.element sub in complex.choice.element) { ImportXsdElement(sub, docEntity, true); } } if (complex.sequence != null) { foreach (IfcDoc.Schema.XSD.element sub in complex.sequence.element) { ImportXsdElement(sub, docEntity, true); } } if (complex.all != null) { foreach (IfcDoc.Schema.XSD.element sub in complex.all.element) { ImportXsdElement(sub, docEntity, true); } } if (complex.complexContent != null) { if(complex.complexContent.extension != null) { docEntity.BaseDefinition = complex.complexContent.extension.basetype; foreach (IfcDoc.Schema.XSD.attribute att in complex.complexContent.extension.attribute) { ImportXsdAttribute(att, docSchema, docEntity); } if(complex.complexContent.extension.choice != null) { foreach (IfcDoc.Schema.XSD.element sub in complex.complexContent.extension.choice.element) { ImportXsdElement(sub, docEntity, true); } } } } }
internal static DocSchema ImportXsd(IfcDoc.Schema.XSD.schema schema, DocProject docProject) { // use resource-level section DocSection docSection = docProject.Sections[6]; // source schemas DocSchema docSchema = new DocSchema(); docSchema.Name = schema.id;//?? docSchema.Code = schema.id; docSchema.Version = schema.version; docSection.Schemas.Add(docSchema); foreach(IfcDoc.Schema.XSD.simpleType simple in schema.simpleType) { ImportXsdSimple(simple, docSchema, null); } foreach (IfcDoc.Schema.XSD.complexType complex in schema.complexType) { DocEntity docEntity = new DocEntity(); docSchema.Entities.Add(docEntity); docEntity.Name = complex.name; docEntity.Documentation = ImportXsdAnnotation(complex.annotation); ImportXsdComplex(complex, docSchema, docEntity); } foreach (IfcDoc.Schema.XSD.element element in schema.element) { DocEntity docEntity = new DocEntity(); docSchema.Entities.Add(docEntity); docEntity.Name = element.name; docEntity.Documentation = ImportXsdAnnotation(element.annotation); ImportXsdComplex(element.complexType, docSchema, docEntity); } return docSchema; }
private static void DrawAttribute( Graphics g, int lane, List<int> lanes, DocEntity docEntity, DocModelView docView, DocModelRuleAttribute ruleAttribute, Dictionary<string, DocObject> map, int offset, Dictionary<Rectangle, DocModelRule> layout, DocProject docProject, DocSchema docSchema, SEntity instance) { int x = lane * CX + FormatPNG.Border; int y = lanes[lane] + FormatPNG.Border; // find the index of the attribute List<DocAttribute> listAttr = new List<DocAttribute>(); BuildAttributeList(docEntity, listAttr, map); int iAttr = -1; for (int i = 0; i < listAttr.Count; i++) { if (listAttr[i].Name.Equals(ruleAttribute.Name)) { // found it iAttr = i; break; } } if (iAttr >= 0) { DocAttribute docAttr = listAttr[iAttr]; object valueinstance = null; if (instance != null) { System.Reflection.FieldInfo field = instance.GetType().GetField(docAttr.Name); if(field != null) { valueinstance = field.GetValue(instance); } } // map it foreach (DocModelRule ruleEach in ruleAttribute.Rules) { if (ruleEach is DocModelRuleEntity) { DocModelRuleEntity ruleEntity = (DocModelRuleEntity)ruleEach; DocObject docObj = null; if (docSchema != null) { docObj = docSchema.GetDefinition(ruleEntity.Name); if (docObj is DocDefinitionRef) docObj = null; } if (docObj == null) { map.TryGetValue(ruleEntity.Name, out docObj); } { int dest = FormatPNG.Border; if (lanes.Count > lane + 1) { dest = lanes[lane + 1] + FormatPNG.Border; } if (docObj is DocEntity) { DocEntity docEntityTarget = (DocEntity)docObj; // resolve inverse attribute List<DocAttribute> listTarget = new List<DocAttribute>(); BuildAttributeList(docEntityTarget, listTarget, map); for (int i = 0; i < listTarget.Count; i++) { DocAttribute docAttrTarget = listTarget[i]; if (docAttr.Inverse != null && docAttrTarget.Name.Equals(docAttr.Inverse)) { // found it dest += CY * (i + 1); break; } else if (docAttrTarget.Inverse != null && docAttr.Name.Equals(docAttrTarget.Inverse)) { //...also need to check for type compatibility bool found = false; DocEntity docTest = docEntity; while (docTest != null) { if (docTest.Name.Equals(docAttrTarget.DefinedType)) { found = true; break; } if (docTest.BaseDefinition == null) break; DocObject docBase = null; if (map.TryGetValue(docTest.BaseDefinition, out docBase)) { docTest = docBase as DocEntity; } else { break; } } // found it if (found) { dest += CY * (i + 1); break; } } } // draw the entity, recurse DrawEntity(g, lane + 1, lanes, docEntityTarget, docView, null, ruleEntity, map, layout, docProject, docSchema, valueinstance); } else { int targetY = lanes[lane + 1] + FormatPNG.Border; if (g != null) { Brush brush = Brushes.Black; if (instance != null) { if (valueinstance == null) { brush = Brushes.Red; } else if(valueinstance is System.Collections.IList) { brush = Brushes.Blue; } else { string typename = valueinstance.GetType().Name; if (typename == ruleEntity.Name) { brush = Brushes.Lime; } else { brush = Brushes.Red; } } } g.FillRectangle(brush, x + CX, targetY, CX - DX, CY); g.DrawRectangle(Pens.Black, x + CX, targetY, CX - DX, CY); using (Font font = new Font(FontFamily.GenericSansSerif, 8.0f)) { string content = ruleEntity.Name;//docObj.Name; foreach (DocModelRule ruleConstraint in ruleEntity.Rules) { if (ruleConstraint.Description != null && ruleConstraint.Description.StartsWith("Value=")) { content = ruleConstraint.Description.Substring(6); using (StringFormat fmt = new StringFormat()) { fmt.Alignment = StringAlignment.Far; g.DrawString(content, font, Brushes.White, new RectangleF(x + CX, targetY, CX - DX, CY), fmt); } } } g.DrawString(ruleEntity.Name, font, Brushes.White, x + CX, targetY); if (ruleEntity.Identification == "Value") { // mark rule serving as default value g.FillEllipse(Brushes.Green, new Rectangle(x + CX - DX - CY, y, CY, CY)); } } } // record rectangle if (layout != null) { layout.Add(new Rectangle(x + CX, targetY, CX - DX, CY), ruleEntity); } // increment lane offset for all lanes int minlane = targetY + CY * 2; int i = lane + 1; if (lanes[i] < minlane) { lanes[i] = minlane; } } // draw arrow if (g != null) { int x0 = x + CX - DX; int y0 = y + CY * (iAttr + 1) + CY / 2; int x1 = x + CX; int y1 = dest + CY / 2; int xM = x0 + DX / 2 - offset * 2; if(!String.IsNullOrEmpty(ruleAttribute.Identification)) { // mark the attribute as using parameter //g.DrawRectangle(Pens.Blue, x, y + CY * (iAttr + 1), CX - DX, CY); using (Font font = new Font(FontFamily.GenericSansSerif, 8.0f, FontStyle.Regular)) { using (StringFormat fmt = new StringFormat()) { fmt.Alignment = StringAlignment.Near; g.DrawString(docAttr.Name, font, Brushes.Blue, x, y + CY * (iAttr + 1), fmt); } } } g.DrawLine(Pens.Black, x0, y0, xM, y0); g.DrawLine(Pens.Black, xM, y0, xM, y1); g.DrawLine(Pens.Black, xM, y1, x1, y1); } } } } if (g != null && ruleAttribute.Identification == "Name") { // mark rule serving as default name g.FillEllipse(Brushes.Blue, new Rectangle(x + CX - DX - CY, y + CY * (iAttr+1), CY, CY)); } #if false string card = ruleAttribute.GetCardinalityExpression(); if (g != null && card != null) { card = card.Trim(); switch (docAttr.GetAggregation()) { case DocAggregationEnum.SET: card = "S" + card; break; case DocAggregationEnum.LIST: card = "L" + card; break; } int px = x + CX - DX; int py = y + CY * (iAttr + 1); g.FillRectangle(Brushes.White, px - CX / 5, py, CX / 5, CY); using (Font font = new Font(FontFamily.GenericSansSerif, 8.0f, FontStyle.Regular)) { using (StringFormat fmt = new StringFormat()) { fmt.Alignment = StringAlignment.Far; g.DrawString(card, font, Brushes.Blue, px, py, fmt); } } } #endif } }
/// <summary> /// Creates an inheritance diagram filtered according to model views in scope. /// </summary> /// <param name="docProject">The project.</param> /// <param name="included">Map of included entities according to filtered model view(s).</param> /// <param name="docRoot">Root of hierarchy to draw.</param> /// <param name="docEntity">Target entity to highlight, if any.</param> /// <param name="font"></param> /// <param name="map"></param> /// <returns></returns> public static Image CreateInheritanceDiagram(DocProject docProject, Dictionary<DocObject, bool> included, DocEntity docRoot, DocEntity docEntity, Font font, Dictionary<Rectangle, DocEntity> map) { Rectangle rc = DrawHierarchy(null, new Point(DX, DX), docRoot, docEntity, docProject, included, font, null); if (rc.IsEmpty) return null; Image image = new Bitmap(rc.Width + CY, rc.Height + CY); using (Graphics g = Graphics.FromImage(image)) { DrawHierarchy(g, new Point(CY/2, CY/2), docRoot, docEntity, docProject, included, font, map); } return image; }
/// <summary> /// Creates a concept diagram for a particular entity, including all concepts at specified view and base view(s). /// </summary> /// <param name="docEntity"></param> /// <param name="docView"></param> /// <param name="map"></param> /// <param name="layout"></param> /// <param name="docProject"></param> /// <param name="instance"></param> /// <returns></returns> internal static Image CreateConceptDiagram(DocEntity docEntity, DocModelView docView, Dictionary<string, DocObject> map, Dictionary<Rectangle, DocModelRule> layout, DocProject docProject, SEntity instance) { DocSchema docSchema = docProject.GetSchemaOfDefinition(docEntity); layout.Clear(); List<int> lanes = new List<int>(); // keep track of position offsets in each lane for (int i = 0; i < 16; i++) { lanes.Add(0); } // determine boundaries DrawEntity(null, 0, lanes, docEntity, docView, null, null, map, layout, docProject, docSchema, instance); Rectangle rcBounds = Rectangle.Empty; foreach (Rectangle rc in layout.Keys) { if (rc.Right > rcBounds.Width) { rcBounds.Width = rc.Right; } if (rc.Bottom > rcBounds.Bottom) { rcBounds.Height = rc.Bottom; } } rcBounds.Width += FormatPNG.Border; rcBounds.Height += FormatPNG.Border; Image image = new Bitmap(rcBounds.Width, rcBounds.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); using (Graphics g = Graphics.FromImage(image)) { g.FillRectangle(Brushes.White, new Rectangle(0, 0, image.Width, image.Height)); layout.Clear(); lanes = new List<int>(); // keep track of position offsets in each lane for (int i = 0; i < 16; i++) { lanes.Add(0); } DrawEntity(g, 0, lanes, docEntity, docView, null, null, map, layout, docProject, docSchema, instance); g.DrawRectangle(Pens.Black, 0, 0, rcBounds.Width - 1, rcBounds.Height - 1); } return image; }
/// <summary> /// Builds list of items in order, using inherited concepts. /// </summary> /// <param name="entity"></param> /// <param name="template"></param> /// <param name="view"></param> private static DocTemplateItem[] FindTemplateItems(DocProject docProject, DocEntity entity, DocTemplateDefinition template, DocModelView view) { // inherited concepts first List<DocTemplateItem> listItems = new List<DocTemplateItem>(); DocEntity basetype = entity; bool inherit = true; while (basetype != null) { // find templates for base foreach (DocModelView docView in docProject.ModelViews) { if (view == docView || view.BaseView == docView.Name) { foreach (DocConceptRoot docRoot in docView.ConceptRoots) { if (docRoot.ApplicableEntity == basetype) { foreach (DocTemplateUsage eachusage in docRoot.Concepts) { if (eachusage.Definition == template) { // found it string[] parameters = template.GetParameterNames(); foreach (DocTemplateItem eachitem in eachusage.Items) { string[] values = new string[parameters.Length]; for (int iparam = 0; iparam < parameters.Length; iparam++) { values[iparam] = eachitem.GetParameterValue(parameters[iparam]); } // new (IfcDoc 4.9d): only add if we don't override by parameters matching exactly bool include = true; foreach (DocTemplateItem existitem in listItems) { bool samevalues = true; for (int iparam = 0; iparam < parameters.Length; iparam++) { string value = values[iparam]; string match = existitem.GetParameterValue(parameters[iparam]); if (match != value || (match != null && !match.Equals(value, StringComparison.Ordinal))) { samevalues = false; break; } } if (samevalues) { include = false; break; } } if (include) { listItems.Add(eachitem); } } inherit = !eachusage.Override; } } } } } } // inherit concepts from supertypes unless overriding if (basetype.BaseDefinition != null && inherit) { basetype = docProject.GetDefinition(basetype.BaseDefinition) as DocEntity; } else { basetype = null; } } return listItems.ToArray(); }
/// <summary> /// Draws entity and subtypes recursively to image /// </summary> /// <param name="g">Graphics where to draw; if null, then just return rectangle</param> /// <param name="pt">Point where to draw</param> /// <param name="docEntity">Entity to draw</param> /// <returns>Bounding rectangle of what was drawn.</returns> private static Rectangle DrawHierarchy(Graphics g, Point pt, DocEntity docEntity, DocEntity docTarget, DocProject docProject, Dictionary<DocObject, bool> included, Font font, Dictionary<Rectangle, DocEntity> map) { if (docEntity == null) return Rectangle.Empty; Rectangle rc = new Rectangle(pt.X, pt.Y, CX, CY); Point ptSub = new Point(pt.X + CY, pt.Y + CY + CY); SortedList<string, DocEntity> subtypes = new SortedList<string, DocEntity>(); // sort to match Visual Express foreach(DocSection docSection in docProject.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach(DocEntity docEnt in docSchema.Entities) { if (included == null || included.ContainsKey(docEnt)) { if (docEnt.BaseDefinition != null && docEnt.BaseDefinition.Equals(docEntity.Name)) { subtypes.Add(docEnt.Name, docEnt); } } } } } foreach(string s in subtypes.Keys) { DocEntity docEnt = subtypes[s];//docProject.GetDefinition(docSub.DefinedType) as DocEntity; if(docEnt != null) { bool vert = (docEnt.Status != "H");//hack Rectangle rcSub = DrawHierarchy(g, ptSub, docEnt, docTarget, docProject, included, font, map); if (g != null) { g.DrawLine(Pens.Black, rcSub.X - CY, pt.Y + CY, rcSub.X - CY, rcSub.Y + CY / 2); g.DrawLine(Pens.Black, rcSub.X - CY, rcSub.Y + CY / 2, rcSub.X, rcSub.Y + CY / 2); } if (vert) { ptSub.Y += rcSub.Height + CY; } else { ptSub.Y = pt.Y + CY + CY; ptSub.X += rcSub.Width + CY + CY + CY + CY + CY; } if (rc.Height < (rcSub.Y + rcSub.Height) - rc.Y) { rc.Height = (rcSub.Y + rcSub.Height) - rc.Y; } if (rc.Width < (rcSub.X + rcSub.Width) - rc.X + CY) { rc.Width = (rcSub.X + rcSub.Width) - rc.X + CY; } } } if (g != null) { Brush brush = Brushes.Black; if(docEntity.IsAbstract()) { brush = Brushes.Gray; } if(docEntity == docTarget) { brush = Brushes.Blue; } g.FillRectangle(brush, pt.X, pt.Y, rc.Width - CY, CY); g.DrawString(docEntity.Name, font, Brushes.White, pt); g.DrawRectangle(Pens.Black, pt.X, pt.Y, rc.Width - CY, CY); } if(map != null && docEntity != docTarget) { Rectangle rcKey = new Rectangle(pt.X, pt.Y, rc.Width - CY, CY); if (!map.ContainsKey(rcKey)) { map.Add(rcKey, docEntity); } } return rc; }
/// <summary> /// Create an inheritance diagram for a particular entity, its entire hierarchy of supertypes, and one level of subtypes, within scope. /// </summary> /// <param name="docEntity"></param> /// <param name="font"></param> /// <param name="map"></param> /// <returns></returns> public static Image CreateInheritanceDiagramForEntity(DocProject docProject, Dictionary<DocObject, bool> included, DocEntity docEntity, Font font, Dictionary<Rectangle, DocEntity> map) { // determine items within scope Dictionary<DocObject, bool> hierarchy = new Dictionary<DocObject,bool>(); DocEntity docBase = docEntity; DocEntity docRoot = docBase; while (docBase != null) { docRoot = docBase; if (included == null || included.ContainsKey(docBase)) { hierarchy.Add(docBase, true); } docBase = docProject.GetDefinition(docBase.BaseDefinition) as DocEntity; } foreach (DocSection docSection in docProject.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEnt in docSchema.Entities) { if (docEnt.BaseDefinition == docEntity.Name) { if (included == null || included.ContainsKey(docEnt)) { hierarchy.Add(docEnt, true); } } } } } return CreateInheritanceDiagram(docProject, hierarchy, docRoot, docEntity, font, map); }
/// <summary> /// Draws entity and recurses. /// </summary> /// <param name="g">Graphics device.</param> /// <param name="lane">Horizontal lane for which to draw the entity.</param> /// <param name="lanes">List of lanes left-to-right.</param> /// <param name="docEntity">The entity to draw.</param> /// <param name="docView">The model view for which to draw the entity.</param> /// <param name="docTemplate">The template to draw.</param> /// <param name="docRule">Optional rule for recursing.</param> /// <param name="map">Map of definitions.</param> /// <param name="layout">Optional layout to receive rectangles for building image map</param> /// <param name="docProject">Required project.</param> /// <param name="instance">Optional instance where included or missing attributes are highlighted.</param> private static void DrawEntity( Graphics g, int lane, List<int> lanes, DocEntity docEntity, DocModelView docView, DocTemplateDefinition docTemplate, DocModelRuleEntity docRule, Dictionary<string, DocObject> map, Dictionary<Rectangle, DocModelRule> layout, DocProject docProject, DocSchema docSchema, object instance) { List<DocAttribute> listAttr = new List<DocAttribute>(); BuildAttributeList(docEntity, listAttr, map); while(lanes.Count < lane + 1) { int miny = 0; if (lanes.Count > lane) { miny = lanes[lane]; } lanes.Add(miny); } int x = lane * CX + FormatPNG.Border; int y = lanes[lane] + FormatPNG.Border; if (g != null) { Brush brush = Brushes.Black; if (instance != null) { brush = Brushes.Red; if (instance is System.Collections.IList) { string typename = instance.GetType().Name; // keep going until matching instance System.Collections.IList list = (System.Collections.IList)instance; foreach (object member in list) { string membertypename = member.GetType().Name; DocEntity docType = docProject.GetDefinition(membertypename) as DocEntity; while (docType != null) { if (docType == docEntity) { brush = Brushes.Lime; instance = member; break; } docType = docProject.GetDefinition(docType.BaseDefinition) as DocEntity; } if (brush != Brushes.Red) break; } } else { string typename = instance.GetType().Name; DocEntity docType = docProject.GetDefinition(typename) as DocEntity; while (docType != null) { if (docType == docEntity) { brush = Brushes.Lime; break; } docType = docProject.GetDefinition(docType.BaseDefinition) as DocEntity; } } } else if (docEntity.IsAbstract()) { brush = Brushes.Gray; } else { brush = Brushes.Black; } g.FillRectangle(brush, x, y, CX - DX, CY); g.DrawRectangle(Pens.Black, x, y, CX - DX, CY); using (Font font = new Font(FontFamily.GenericSansSerif, 8.0f, FontStyle.Bold)) { g.DrawString(docEntity.Name, font, Brushes.White, x, y); } if (docRule != null && docRule.Identification == "Value") { // mark rule serving as default value g.FillEllipse(Brushes.Green, new Rectangle(x + CX - DX - CY, y, CY, CY)); } g.DrawRectangle(Pens.Black, x, y + CY, CX - DX, CY * listAttr.Count); using (Font font = new Font(FontFamily.GenericSansSerif, 8.0f, FontStyle.Regular)) { for (int iAttr = 0; iAttr < listAttr.Count; iAttr++) { DocAttribute docAttr = listAttr[iAttr]; string display = docAttr.GetAggregationExpression(); brush = Brushes.Black; if (docAttr.Inverse != null) { brush = Brushes.Gray; } if(String.IsNullOrEmpty(display)) { if(docAttr.IsOptional) { display = "[0:1]"; } else { display = "[1:1]"; } } g.DrawString(docAttr.Name, font, brush, x, y + CY * (iAttr + 1)); using (StringFormat fmt = new StringFormat()) { fmt.Alignment = StringAlignment.Far; g.DrawString(display, font, brush, new RectangleF(x, y + CY * (iAttr + 1), CX - DX, CY), fmt); } } } } // record rectangle if (layout != null) { layout.Add(new Rectangle(x, y, CX - DX, CY + CY * listAttr.Count), docRule); } SortedList<int, List<DocModelRuleAttribute>> mapAttribute = new SortedList<int, List<DocModelRuleAttribute>>(); Dictionary<DocModelRuleAttribute, DocTemplateDefinition> mapTemplate = new Dictionary<DocModelRuleAttribute,DocTemplateDefinition>(); if (docRule != null && docRule.Rules != null) { // map inner rules // sort foreach (DocModelRule rule in docRule.Rules) { if (rule is DocModelRuleAttribute) { DocModelRuleAttribute ruleAttribute = (DocModelRuleAttribute)rule; for (int i = 0; i < listAttr.Count; i++) { if (listAttr[i].Name.Equals(ruleAttribute.Name)) { // found it if (!mapAttribute.ContainsKey(i)) { mapAttribute.Add(i, new List<DocModelRuleAttribute>()); } mapAttribute[i].Add(ruleAttribute); break; } } } } } else if (docTemplate != null) { if (docTemplate.Rules != null) { foreach (DocModelRuleAttribute ruleAttribute in docTemplate.Rules) { for (int i = 0; i < listAttr.Count; i++) { if (listAttr[i].Name != null && listAttr[i].Name.Equals(ruleAttribute.Name)) { // found it //iAttr = i; if (!mapAttribute.ContainsKey(i)) { mapAttribute.Add(i, new List<DocModelRuleAttribute>()); } mapAttribute[i].Add(ruleAttribute); break; } } } } } else { // map each use definition at top-level // build list of inherited views List<DocModelView> listViews = new List<DocModelView>(); DocModelView docBaseView = docView; while (docBaseView != null) { listViews.Add(docBaseView); if (!String.IsNullOrEmpty(docBaseView.BaseView)) { Guid guidBase = Guid.Parse(docBaseView.BaseView); if (guidBase != docBaseView.Uuid) { docBaseView = docProject.GetView(guidBase); } else { docBaseView = null; } } else { docBaseView = null; } } // build from inherited entities too List<DocTemplateDefinition> listTemplates = new List<DocTemplateDefinition>(); // keep track of templates so we don't repeat at supertypes List<DocTemplateDefinition> listSuppress = new List<DocTemplateDefinition>(); // list of templates that are suppressed DocEntity docEntitySuper = docEntity; while(docEntitySuper != null) { foreach (DocModelView docEachView in docProject.ModelViews) { if (docView == null || listViews.Contains(docEachView)) { foreach (DocConceptRoot docRoot in docEachView.ConceptRoots) { if (docRoot.ApplicableEntity == docEntitySuper) { foreach (DocTemplateUsage docUsage in docRoot.Concepts) { if (docUsage.Definition != null && docUsage.Definition.Rules != null && !listTemplates.Contains(docUsage.Definition) && !listSuppress.Contains(docUsage.Definition)) { if (docUsage.Suppress) { listSuppress.Add(docUsage.Definition); } else { listTemplates.Add(docUsage.Definition); foreach (DocModelRuleAttribute ruleAttribute in docUsage.Definition.Rules) { for (int i = 0; i < listAttr.Count; i++) { if (listAttr[i].Name.Equals(ruleAttribute.Name)) { // found it if (!mapAttribute.ContainsKey(i)) { mapAttribute.Add(i, new List<DocModelRuleAttribute>()); } mapAttribute[i].Add(ruleAttribute); if (!mapTemplate.ContainsKey(ruleAttribute)) { mapTemplate.Add(ruleAttribute, docUsage.Definition); } break; } } } } } } } } } } DocObject docTest = null; if (docEntitySuper.BaseDefinition != null && map.TryGetValue(docEntitySuper.BaseDefinition, out docTest)) { docEntitySuper = docTest as DocEntity; } else { docEntitySuper = null; } } } int offset = -mapAttribute.Values.Count / 2; DocTemplateDefinition lastTemplate = null; foreach (List<DocModelRuleAttribute> listSort in mapAttribute.Values) { if (docRule == null && docTemplate == null) { // offset all lanes int maxlane = 0; for (int i = 1; i < lanes.Count; i++) { if (lanes[i] > maxlane) { maxlane = lanes[i]; } } for (int i = 1; i < lanes.Count; i++) { lanes[i] = maxlane; } } foreach (DocModelRuleAttribute ruleAttributeSort in listSort) { // indicate each template DocTemplateDefinition eachTemplate = null; if (mapTemplate.TryGetValue(ruleAttributeSort, out eachTemplate)) { // offset for use definition int minlan = 0; for (int i = 1; i < lanes.Count; i++) { if (eachTemplate != lastTemplate) { lanes[i] += CY * 2; } if (lanes[i] > minlan) { minlan = lanes[i]; } } // verify this... for (int i = 1; i < lanes.Count; i++) { if (lanes[i] < minlan) { lanes[i] = minlan; } } if (g != null && eachTemplate != lastTemplate) { using (Font font = new Font(FontFamily.GenericSansSerif, 8.0f, FontStyle.Italic)) { g.DrawString(eachTemplate.Name, font, Brushes.Gray, CX + FormatPNG.Border, lanes[1] - CY * 2 + FormatPNG.Border); } int lineY = lanes[1] - CY * 2 + FormatPNG.Border; g.DrawLine(Pens.Gray, CX + FormatPNG.Border, lineY, 1920, lineY); } lastTemplate = eachTemplate; } DrawAttribute(g, lane, lanes, docEntity, docView, ruleAttributeSort, map, offset, layout, docProject, docSchema, instance as SEntity); } offset++; } // increment lane offset int minlane = y + CY * (listAttr.Count + 2); if (lanes[lane] < minlane) { lanes[lane] = minlane; } }
internal static void ImportXsdElement(IfcDoc.Schema.XSD.element sub, DocEntity docEntity, bool list) { DocAttribute docAttr = new DocAttribute(); docEntity.Attributes.Add(docAttr); if (!String.IsNullOrEmpty(sub.name)) { docAttr.Name = sub.name; } else { docAttr.Name = sub.reftype; } if (!String.IsNullOrEmpty(sub.type)) { docAttr.DefinedType = sub.type; } else { docAttr.DefinedType = sub.reftype; } // list or set??... if (list || sub.minOccurs != null) { if (list || sub.maxOccurs != null) { // list if (list || sub.maxOccurs == "unbounded") { docAttr.AggregationType = 1; // list if (!String.IsNullOrEmpty(sub.minOccurs)) { docAttr.AggregationLower = sub.minOccurs; } else { docAttr.AggregationLower = "0"; } docAttr.AggregationUpper = "?"; } } else if (sub.minOccurs == "0") { docAttr.IsOptional = true; } } docAttr.Documentation = ImportXsdAnnotation(sub.annotation); }
public bool CanCache (DocEntity entity) { return true; }
public string FormatEntity(DocEntity docEntity, Dictionary<string, DocObject> map, Dictionary<DocObject, bool> included) { string basedef = docEntity.BaseDefinition; if (String.IsNullOrEmpty(basedef)) { basedef = "IfcBase"; } StringBuilder sb = new StringBuilder(); sb.AppendLine("public class " + docEntity.Name + " extends " + basedef); sb.AppendLine("{"); // fields foreach (DocAttribute docAttribute in docEntity.Attributes) { string deftype = docAttribute.DefinedType; // if defined type, use raw type (avoiding extra memory allocation) DocObject docDef = null; if (deftype != null) { map.TryGetValue(deftype, out docDef); } if (docDef is DocDefined) { deftype = ((DocDefined)docDef).DefinedType; switch (deftype) { case "STRING": deftype = "string"; break; case "INTEGER": deftype = "int"; break; case "REAL": deftype = "double"; break; case "BOOLEAN": deftype = "bool"; break; case "LOGICAL": deftype = "int"; break; case "BINARY": deftype = "byte[]"; break; } } switch (docAttribute.GetAggregation()) { case DocAggregationEnum.SET: sb.AppendLine("\tprivate " + deftype + "[] " + docAttribute.Name + ";"); break; case DocAggregationEnum.LIST: sb.AppendLine("\tprivate " + deftype + "[] " + docAttribute.Name + ";"); break; default: sb.AppendLine("\tprivate " + deftype + " " + docAttribute.Name + ";"); break; } } sb.AppendLine("}"); return sb.ToString(); }
private static void FormatEntityUsage(DocProject docProject, DocEntity entity, DocConceptRoot docRoot, DocTemplateUsage eachusage, Dictionary<string, DocObject> mapEntity, Dictionary<string, string> mapSchema, List<ContentRef> listFigures, List<ContentRef> listTables, Dictionary<DocObject, bool> included, StringBuilder sb) { if (eachusage.Definition != null) { if (included == null || included.ContainsKey(eachusage.Definition)) { if (eachusage.Documentation != null) { eachusage.Documentation = UpdateNumbering(eachusage.Documentation, listFigures, listTables, entity); } string eachtext = FormatConcept(docProject, entity, docRoot, eachusage, mapEntity, mapSchema, listFigures, listTables); sb.Append(eachtext); sb.AppendLine(); if (eachusage.Concepts.Count > 0) { sb.AppendLine("<details>"); sb.AppendLine("<summary>Concept alternates</summary>"); foreach (DocTemplateUsage innerusage in eachusage.Concepts) { FormatEntityUsage(docProject, entity, docRoot, innerusage, mapEntity, mapSchema, listFigures, listTables, included, sb); } sb.AppendLine("</details>"); } } } }
internal static void ImportXsdAttribute(IfcDoc.Schema.XSD.attribute att, DocSchema docSchema, DocEntity docEntity) { DocAttribute docAttr = new DocAttribute(); docEntity.Attributes.Add(docAttr); docAttr.Name = att.name; docAttr.IsOptional = (att.use == Schema.XSD.use.optional); if (att.simpleType != null) { string refname = docEntity.Name + "_" + att.name; docAttr.DefinedType = refname; ImportXsdSimple(att.simpleType, docSchema, refname); } else { docAttr.DefinedType = ImportXsdType(att.type); } }
private static string FormatEntityConcepts( DocProject docProject, DocEntity entity, Dictionary<string, DocObject> mapEntity, Dictionary<string, string> mapSchema, Dictionary<DocObject, bool> included, List<ContentRef> listFigures, List<ContentRef> listTables) { StringBuilder sb = new StringBuilder(); // find concepts for entity foreach (DocModelView docView in docProject.ModelViews) { if (included == null || included.ContainsKey(docView)) { // check if there are any applicable concepts bool hasConceptsAtEntity = false; foreach (DocConceptRoot docRoot in docView.ConceptRoots) { if (docRoot.ApplicableEntity == entity) { hasConceptsAtEntity = true; } } // inherited use definitions // build list of inherited views DocModelView[] listViews = docProject.GetViewInheritance(docView); List<string> listLines = new List<string>(); Dictionary<DocTemplateDefinition, DocTemplateUsage> mapSuper = new Dictionary<DocTemplateDefinition, DocTemplateUsage>(); List<DocTemplateDefinition> listSuppress = new List<DocTemplateDefinition>(); DocEntity docSuper = entity; while (docSuper != null) { // find parent concept roots bool renderclass = false; foreach (DocModelView docViewBase in listViews) { foreach (DocConceptRoot docSuperRoot in docViewBase.ConceptRoots) { if (docSuperRoot.ApplicableEntity == docSuper) { StringBuilder sbSuper = new StringBuilder(); string schema = mapSchema[docSuper.Name].ToLower(); if (!renderclass) { renderclass = true; sbSuper.Append("<tr><td colspan=\"3\">"); sbSuper.Append("<a href=\"../../" + schema + "/lexical/" + MakeLinkName(docSuper) + ".htm\">"); if (docSuper.IsAbstract()) { sbSuper.Append("<i>"); sbSuper.Append(docSuper.Name); sbSuper.Append("</i>"); } else { sbSuper.Append(docSuper.Name); } sbSuper.Append("</a></td></tr>"); } foreach (DocTemplateUsage docSuperUsage in docSuperRoot.Concepts) { if (docSuperUsage.Suppress && !listSuppress.Contains(docSuperUsage.Definition)) { listSuppress.Add(docSuperUsage.Definition); } else if (docSuperUsage.Definition != null && !mapSuper.ContainsKey(docSuperUsage.Definition)) { bool suppress = listSuppress.Contains(docSuperUsage.Definition); sbSuper.Append("<tr><td> </td><td>"); mapSuper.Add(docSuperUsage.Definition, docSuperUsage); string templateid = MakeLinkName(docSuperUsage.Definition); sbSuper.Append("<a href=\"../../"); sbSuper.Append(schema); sbSuper.Append("/lexical/" + MakeLinkName(docSuper) + ".htm#" + templateid + "\">"); if (suppress) { sbSuper.Append("<del>"); } sbSuper.Append(docSuperUsage.Definition.Name); if (suppress) { sbSuper.Append("</del>"); } sbSuper.Append("</a>"); sbSuper.Append("</td><td>"); sbSuper.Append(docViewBase.Name); sbSuper.Append("</td></tr>"); } } listLines.Add(sbSuper.ToString()); } } } // go to base type docSuper = docProject.GetDefinition(docSuper.BaseDefinition) as DocEntity; } if (hasConceptsAtEntity || listLines.Count > 0) { sb.AppendLine("<section>"); sb.AppendLine("<h5 class=\"num\">Definitions applying to " + docView.Name + "</h5>"); // link to instance diagram if (hasConceptsAtEntity) { string linkdiagram = MakeLinkName(docView) + "/" + MakeLinkName(entity) + ".htm"; sb.Append("<p><a href=\"../../../annex/annex-d/" + linkdiagram + "\"><img style=\"border: 0px\" src=\"../../../img/diagram.png\" /> Instance diagram</a></p>"); } sb.AppendLine("<hr />"); foreach (DocConceptRoot docRoot in docView.ConceptRoots) { if (docRoot.ApplicableEntity == entity) { sb.Append(docRoot.Documentation); if (docRoot.Concepts.Count > 0) { sb.AppendLine("<details>"); sb.AppendLine("<summary>Concept usage</summary>"); foreach (DocTemplateUsage eachusage in docRoot.Concepts) { FormatEntityUsage(docProject, entity, docRoot, eachusage, mapEntity, mapSchema, listFigures, listTables, included, sb); } sb.AppendLine("</details>"); } } } } // now format inherited use definitions if (listLines.Count > 0) { sb.AppendLine("<section>"); sb.AppendLine("<details>"); sb.AppendLine("<summary>Concept inheritance</summary>"); sb.AppendLine("<p><table class=\"attributes\">"); sb.AppendLine("<tr><th><b>#</b></th><th><b>Concept</b></td><th><b>Model View</b></th></tr>"); for (int iLine = listLines.Count - 1; iLine >= 0; iLine--) { // reverse order sb.AppendLine(listLines[iLine]); } sb.AppendLine("</table>"); sb.AppendLine("</details>"); sb.AppendLine("</section>"); } sb.AppendLine("</section>"); } } sb = sb.Replace("<EPM-HTML>", ""); sb = sb.Replace("</EPM-HTML>", ""); return sb.ToString(); }
private DocAttribute FindAttribute(DocEntity entity, string name) { foreach (DocAttribute eachattr in entity.Attributes) { if (eachattr.Name.Equals(name)) return eachattr; } // recurse if (entity.BaseDefinition != null) { DocEntity basetype = (DocEntity)this.m_map[entity.BaseDefinition]; return FindAttribute(basetype, name); } return null; // not found }
public FormSelectProperty(DocEntity docEntity, DocProject docProject, bool multiselect) : this() { this.m_entity = docEntity; this.m_project = docProject; if (multiselect) { this.treeViewProperty.CheckBoxes = true; this.Text = "Include Property Sets"; } foreach(DocSection docSection in this.m_project.Sections) { foreach(DocSchema docSchema in docSection.Schemas) { foreach(DocPropertySet docPset in docSchema.PropertySets) { bool include = false; if (docPset.ApplicableType != null) { string[] parts = docPset.ApplicableType.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach(string part in parts) { DocEntity docBase = docEntity; while (docBase != null) { if (part.Contains(docBase.Name)) { include = true; break; } docBase = this.m_project.GetDefinition(docBase.BaseDefinition) as DocEntity; } } } if (this.m_entity == null || include) { TreeNode tnPset = new TreeNode(); tnPset.Tag = docPset; tnPset.Text = docPset.Name; this.treeViewProperty.Nodes.Add(tnPset); if (!this.treeViewProperty.CheckBoxes) { foreach (DocProperty docProp in docPset.Properties) { TreeNode tnProp = new TreeNode(); tnProp.Tag = docProp; tnProp.Text = docProp.Name; tnPset.Nodes.Add(tnProp); } } } } } } this.treeViewProperty.ExpandAll(); }
public string FormatEntityFull(DocEntity docEntity, Dictionary<string, DocObject> map, Dictionary<DocObject, bool> included, bool fullListing) { // entity StringBuilder sb = new StringBuilder(); // object properties StringBuilder sbProps = new StringBuilder(); // lists StringBuilder sbLists = new StringBuilder(); sb.AppendLine("ifc:" + docEntity.Name); // superclass if (docEntity.BaseDefinition != null) { DocEntity super = map[docEntity.BaseDefinition] as DocEntity; if (super != null) { sb.AppendLine("\trdfs:subClassOf \tifc:" + super.Name + " ;"); // disjoint if (subTypesOfEntity.ContainsKey(super.Name)) { string tmp = ""; foreach (string subtype in subTypesOfEntity[super.Name]) { if (subtype != docEntity.Name) { if (tmp.Length > 0) tmp += ", "; tmp += ToOwlClass(subtype) + " "; } } if (tmp.Length > 0) sb.AppendLine("\towl:disjointWith " + tmp + ";"); } } } // abstract class if (docEntity.IsAbstract()) { sb.AppendLine("\trdfs:subClassOf "); sb.AppendLine("\t\t[ "); sb.AppendLine("\t\t\trdf:type owl:Class ;"); sb.Append("\t\t\towl:unionOf ( "); if (subTypesOfEntity.ContainsKey(docEntity.Name)) { foreach (string subtype in subTypesOfEntity[docEntity.Name]) { sb.Append(ToOwlClass(subtype) + " "); } } sb.Append(")"); sb.AppendLine(); sb.AppendLine("\t\t] ;"); } // attributes -> create properties and restrictions foreach (DocAttribute docAttr in docEntity.Attributes) { // check if Attr must be skipped (1) - not included attribute if (included != null) if (!included.ContainsKey(docAttr)) continue; string propname = ""; string propfullname = ""; string invpropname = ""; string invpropfullname = ""; string targetString = docAttr.DefinedType; DocEntity targetEntity = null; if (map.ContainsKey(targetString)) { targetEntity = map[targetString] as DocEntity; } // check if Attr must be skipped (2) - DERIVE attribute if (docAttr.Derived != null) continue; // check if Attr must be skipped (3) - not manageable INVERSE attribute invpropname = docAttr.Inverse; if (invpropname != null) { // check if there are problems with inverse and in this case skip the attribute! // 1) the inverse is an inverse of two or more properties // 2) a list/array is involved as range in the property or its inverse // 1) var key = new Tuple<string, string>(docAttr.Inverse, targetString); if (attribInverses.ContainsKey(key)) if (attribInverses[key] > 1) continue; // 2.a) if (docAttr.GetAggregation() == DocAggregationEnum.LIST || docAttr.GetAggregation() == DocAggregationEnum.ARRAY) continue; // 2.b) if (targetEntity != null) { bool toBeSkipped = false; foreach (DocAttribute docAttrInv in targetEntity.Attributes) { if (docAttrInv.Name == invpropname) if (docAttrInv.GetAggregation() == DocAggregationEnum.LIST || docAttrInv.GetAggregation() == DocAggregationEnum.ARRAY) { toBeSkipped = true; break; } } if (toBeSkipped) continue; } } // set actual target string actualTargetString = ToOwlClass(targetString); if (docAttr.GetAggregation() == DocAggregationEnum.LIST || docAttr.GetAggregation() == DocAggregationEnum.ARRAY) { string newlistdef = createListClass(actualTargetString); actualTargetString = actualTargetString + "_List"; if (newlistdef.Length > 0) sbLists.Append(newlistdef); DocAttribute docAggregate = docAttr.AggregationAttribute; while (docAggregate != null) { newlistdef = createListClass(actualTargetString); actualTargetString = actualTargetString + "_List"; if (newlistdef.Length > 0) sbLists.Append(newlistdef); docAggregate = docAggregate.AggregationAttribute; } } // create property propname = docAttr.Name; propfullname = propname + "_" + docEntity.Name; if (propfullname.Length > 0) propfullname = char.ToLower(propfullname[0]) + propfullname.Substring(1); propfullname = "ifc:" + propfullname; sbProps.AppendLine(propfullname); sbProps.Append("\trdf:type \towl:ObjectProperty "); // functional if (docAttr.GetAggregation() == DocAggregationEnum.NONE || docAttr.GetAggregation() == DocAggregationEnum.LIST || docAttr.GetAggregation() == DocAggregationEnum.ARRAY || (docAttr.GetAggregation() == DocAggregationEnum.SET && docAttr.GetAggregationNestingUpper() == 1)) { sbProps.Append(", owl:FunctionalProperty "); } sbProps.Append(";"); sbProps.AppendLine(); // inverse if (invpropname != null && targetEntity != null) { invpropfullname = invpropname + "_" + targetEntity.Name; if (invpropfullname.Length > 0) invpropfullname = char.ToLower(invpropfullname[0]) + invpropfullname.Substring(1); invpropfullname = "ifc:" + invpropfullname; sbProps.AppendLine("\towl:inverseOf \t" + invpropfullname + " ;"); } // domain sbProps.AppendLine("\trdfs:domain " + ToOwlClass(docEntity.Name) + " ;"); // range sbProps.AppendLine("\trdfs:range " + actualTargetString + " ;"); // label sbProps.AppendLine("\trdfs:label \"" + propname + "\" ."); sbProps.AppendLine(); // create restrictions { // only sb.AppendLine("\trdfs:subClassOf "); sb.AppendLine("\t\t[ "); sb.AppendLine("\t\t\trdf:type owl:Restriction ;"); sb.AppendLine("\t\t\towl:allValuesFrom " + actualTargetString + " ;"); sb.AppendLine("\t\t\towl:onProperty " + propfullname); sb.AppendLine("\t\t] ;"); if (docAttr.GetAggregation() == DocAggregationEnum.NONE || docAttr.GetAggregation() == DocAggregationEnum.LIST || docAttr.GetAggregation() == DocAggregationEnum.ARRAY) { sb.AppendLine("\t" + "rdfs:subClassOf "); sb.AppendLine("\t\t" + "["); sb.AppendLine("\t\t\t" + "rdf:type owl:Restriction ;"); if (docAttr.IsOptional) sb.AppendLine("\t\t\t" + "owl:maxQualifiedCardinality \"" + 1 + "\"^^xsd:nonNegativeInteger ;"); else sb.AppendLine("\t\t\t" + "owl:qualifiedCardinality \"" + 1 + "\"^^xsd:nonNegativeInteger ;"); sb.AppendLine("\t\t\towl:onProperty " + propfullname + " ;"); sb.AppendLine("\t\t\t" + "owl:onClass " + actualTargetString); sb.AppendLine("\t\t] ;"); } if (docAttr.GetAggregation() == DocAggregationEnum.SET) { int mincard = 0; if (docAttr.AggregationLower != null) mincard = Int32.Parse(docAttr.AggregationLower); int maxcard = 0; if (String.IsNullOrEmpty(docAttr.AggregationUpper) || !Int32.TryParse(docAttr.AggregationUpper, out maxcard)) maxcard = 0; if (docAttr.IsOptional) mincard = 0; if (mincard == maxcard && mincard > 0) { sb.AppendLine("\t" + "rdfs:subClassOf "); sb.AppendLine("\t\t" + "["); sb.AppendLine("\t\t\t" + "rdf:type owl:Restriction ;"); sb.AppendLine("\t\t\t" + "owl:qualifiedCardinality \"" + mincard + "\"^^xsd:nonNegativeInteger ;"); sb.AppendLine("\t\t\towl:onProperty " + propfullname + " ;"); sb.AppendLine("\t\t\t" + "owl:onClass " + actualTargetString); sb.AppendLine("\t\t] ;"); } else { if (mincard > 0) { sb.AppendLine("\t" + "rdfs:subClassOf "); sb.AppendLine("\t\t" + "["); sb.AppendLine("\t\t\t" + "rdf:type owl:Restriction ;"); sb.AppendLine("\t\t\t" + "owl:minQualifiedCardinality \"" + mincard + "\"^^xsd:nonNegativeInteger ;"); sb.AppendLine("\t\t\towl:onProperty " + propfullname + " ;"); sb.AppendLine("\t\t\t" + "owl:onClass " + actualTargetString); sb.AppendLine("\t\t] ;"); } if (maxcard > 0) { sb.AppendLine("\t" + "rdfs:subClassOf "); sb.AppendLine("\t\t" + "["); sb.AppendLine("\t\t\t" + "rdf:type owl:Restriction ;"); sb.AppendLine("\t\t\t" + "owl:maxQualifiedCardinality \"" + maxcard + "\"^^xsd:nonNegativeInteger ;"); sb.AppendLine("\t\t\towl:onProperty " + propfullname + " ;"); sb.AppendLine("\t\t\t" + "owl:onClass " + actualTargetString); sb.AppendLine("\t\t] ;"); } } } if (docAttr.GetAggregation() == DocAggregationEnum.LIST || docAttr.GetAggregation() == DocAggregationEnum.ARRAY) { int mincard = 0; if (docAttr.AggregationLower != null) mincard = Int32.Parse(docAttr.AggregationLower); int maxcard = 0; if (String.IsNullOrEmpty(docAttr.AggregationUpper) || !Int32.TryParse(docAttr.AggregationUpper, out maxcard)) maxcard = 0; if (docAttr.GetAggregation() == DocAggregationEnum.ARRAY) { mincard = maxcard - mincard + 1; maxcard = mincard; } if (mincard >= 1) { string cards = ""; cards += WriteMinCardRestr(actualTargetString, propfullname, mincard, true); cards += " ;"; sb.AppendLine(cards); } if (maxcard > 1) { string cards = ""; string emptyListTgt = actualTargetString.Substring(0, actualTargetString.Length - 4) + "EmptyList"; cards += WriteMaxCardRestr(emptyListTgt, propfullname, maxcard, true); cards += " ;"; sb.AppendLine(cards); } } } } sb.AppendLine("\trdf:type \towl:Class ."); sb.AppendLine(); if (fullListing) { sb.Append(sbProps.ToString()); sb.Append(sbLists.ToString()); } return sb.ToString(); }
private static string FormatEntityDescription( DocProject docProject, DocEntity entity, List<ContentRef> listFigures, List<ContentRef> listTables) { StringBuilder sb = new StringBuilder(); entity.Documentation = UpdateNumbering(entity.Documentation, listFigures, listTables, entity); sb.Append(entity.Documentation); return sb.ToString(); }
private static string FormatEntityConcepts( DocProject docProject, DocEntity entity, Dictionary<string, DocObject> mapEntity, Dictionary<string, string> mapSchema, Dictionary<DocObject, bool> included, List<ContentRef> listFigures, List<ContentRef> listTables, string path, DocPublication docPublication) { StringBuilder sb = new StringBuilder(); // find concepts for entity foreach (DocModelView docView in docProject.ModelViews) { if (included == null || included.ContainsKey(docView)) { // check if there are any applicable concepts bool hasConceptsAtEntity = false; foreach (DocConceptRoot docRoot in docView.ConceptRoots) { if (docRoot.ApplicableEntity == entity) { hasConceptsAtEntity = true; } } // inherited use definitions // build list of inherited views DocModelView[] listViews = docProject.GetViewInheritance(docView); List<string> listLines = new List<string>(); Dictionary<DocTemplateDefinition, DocTemplateUsage> mapSuper = new Dictionary<DocTemplateDefinition, DocTemplateUsage>(); List<DocTemplateDefinition> listSuppress = new List<DocTemplateDefinition>(); List<DocTemplateDefinition> listOverride = new List<DocTemplateDefinition>(); DocEntity docSuper = entity; while (docSuper != null) { StringBuilder sbSuper = new StringBuilder(); // find parent concept roots bool renderclass = false; foreach (DocModelView docViewBase in listViews) { foreach (DocConceptRoot docSuperRoot in docViewBase.ConceptRoots) { if (docSuperRoot.ApplicableEntity == docSuper) { string schema = mapSchema[docSuper.Name].ToLower(); foreach (DocTemplateUsage docSuperUsage in docSuperRoot.Concepts) { bool flag = false; if (docSuperUsage.Suppress) { if (!listSuppress.Contains(docSuperUsage.Definition)) { listSuppress.Add(docSuperUsage.Definition); flag = true; } } else if (docSuperUsage.Override) { if (!listOverride.Contains(docSuperUsage.Definition)) { listOverride.Add(docSuperUsage.Definition); flag = true; } } if (docSuperUsage.Definition != null && !mapSuper.ContainsKey(docSuperUsage.Definition) && !docSuperUsage.Suppress) { if (!renderclass) { renderclass = true; sbSuper.Append("<tr><td colspan=\"3\">"); sbSuper.Append("<a href=\"../../" + schema + "/lexical/" + MakeLinkName(docSuper) + ".htm\">"); if (docSuper.IsAbstract()) { sbSuper.Append("<i>"); sbSuper.Append(docSuper.Name); sbSuper.Append("</i>"); } else { sbSuper.Append(docSuper.Name); } sbSuper.Append("</a></td></tr>"); } bool suppress = listSuppress.Contains(docSuperUsage.Definition); bool overiden = listOverride.Contains(docSuperUsage.Definition); foreach(DocTemplateDefinition dtd in listSuppress) { if (docSuperUsage.Definition == dtd || docSuperUsage.Definition.Templates.Contains(dtd)) { suppress = true; break; } } foreach (DocTemplateDefinition dtd in listOverride) { if (docSuperUsage.Definition == dtd || docSuperUsage.Definition.Templates.Contains(dtd)) { overiden = true; break; } } if(flag) { suppress = false; overiden = false; } sbSuper.Append("<tr><td> </td><td>"); mapSuper.Add(docSuperUsage.Definition, docSuperUsage); string templateid = MakeLinkName(docSuperUsage.Definition); sbSuper.Append("<a href=\"../../"); sbSuper.Append(schema); sbSuper.Append("/lexical/" + MakeLinkName(docSuper) + ".htm#" + templateid + "\">"); if (suppress || overiden) { sbSuper.Append("<del>"); } if (!String.IsNullOrEmpty(docSuperUsage.Name)) { sbSuper.Append(docSuperUsage.Name); } else { sbSuper.Append(docSuperUsage.Definition.Name); } if (suppress || overiden) { sbSuper.Append("</del>"); } sbSuper.Append("</a>"); if(overiden) { sbSuper.Append(" (overridden)"); } else if(suppress) { sbSuper.Append(" (suppressed)"); } sbSuper.Append("</td><td>"); sbSuper.Append("<a href=\"../../templates/" + MakeLinkName(docSuperUsage.Definition) + ".htm\">" + docSuperUsage.Definition + "</a>"); sbSuper.Append("</td><td>"); sbSuper.Append(docViewBase.Name); sbSuper.Append("</td></tr>"); sbSuper.AppendLine(); } } } } } if (sbSuper.Length > 0) { listLines.Add(sbSuper.ToString()); } // go to base type docSuper = docProject.GetDefinition(docSuper.BaseDefinition) as DocEntity; } if (hasConceptsAtEntity || listLines.Count > 0) { sb.AppendLine("<section>"); sb.AppendLine("<h5 class=\"num\">Definitions applying to " + docView.Name + "</h5>"); // link to instance diagram if (hasConceptsAtEntity) { string linkdiagram = MakeLinkName(docView) + "/" + MakeLinkName(entity) + ".htm"; sb.Append("<p><a href=\"../../../annex/annex-d/" + linkdiagram + "\"><img style=\"border: 0px\" src=\"../../../img/diagram.png\" /> Instance diagram</a></p>"); } sb.AppendLine("<hr />"); foreach (DocConceptRoot docRoot in docView.ConceptRoots) { if (docRoot.ApplicableEntity == entity) { sb.Append("<h5>" + docRoot.Name + "</h5>"); if (docRoot.ApplicableTemplate != null) { string applicabletemplatetable = FormatConceptTable(docProject, docView, entity, docRoot, null, mapEntity, mapSchema); sb.Append(applicabletemplatetable); } sb.Append(docRoot.Documentation); if (docRoot.Concepts.Count > 0) { sb.AppendLine("<details open=\"open\">"); sb.AppendLine("<summary>Concept usage</summary>"); foreach (DocTemplateUsage eachusage in docRoot.Concepts) { FormatEntityUsage(docProject, entity, docRoot, eachusage, mapEntity, mapSchema, listFigures, listTables, included, sb, path, docPublication); } sb.AppendLine("</details>"); //... mvdXML for entire root ConceptRoot mvdConceptRoot = new ConceptRoot(); Program.ExportMvdConceptRoot(mvdConceptRoot, docRoot, false); XmlSerializer ser = new XmlSerializer(typeof(ConceptRoot)); StringBuilder mvdOutput = new StringBuilder(); using (System.IO.Stream streamMVD = new System.IO.MemoryStream()) { ser.Serialize(streamMVD, mvdConceptRoot, null); streamMVD.Position = 0; using (System.IO.StreamReader reader = new System.IO.StreamReader(streamMVD)) { while (!reader.EndOfStream) { string mvdLine = reader.ReadLine(); int pos = 0; while (pos < mvdLine.Length && mvdLine[pos] == ' ') { mvdOutput.Append("\t"); pos++; } // replace any leading spaces with tabs for proper formatting string mvdMark = mvdLine.Substring(pos, mvdLine.Length - pos); mvdOutput.AppendLine(mvdMark); } } } string html = System.Web.HttpUtility.HtmlEncode(mvdOutput.ToString()); html = html.Replace("\r\n", "<br/>\r\n"); html = html.Replace("\t", " "); //sb.AppendLine("<section>"); sb.AppendLine("<details><summary>mvdXML Specification</summary>"); sb.AppendLine("<div class=\"xsd\"><code class=\"xsd\">"); sb.AppendLine(html); //... need to use tabs... //sb.AppendLine(mvdOutput.ToString()); sb.AppendLine("</code></div></details>"); //sb.AppendLine("</section>"); } } } } // now format inherited use definitions if (listLines.Count > 0) { sb.AppendLine("<section>"); sb.AppendLine("<details>"); sb.AppendLine("<summary>Concept inheritance</summary>"); sb.AppendLine("<p><table class=\"attributes\">"); sb.AppendLine("<tr><th><b>#</b></th><th><b>Concept</b></th><th><b>Template</b></th><th><b>Model View</b></th></tr>"); for (int iLine = listLines.Count - 1; iLine >= 0; iLine--) { // reverse order sb.AppendLine(listLines[iLine]); } sb.AppendLine("</table>"); sb.AppendLine("</details>"); sb.AppendLine("</section>"); } sb.AppendLine("</section>"); } } sb = sb.Replace("<EPM-HTML>", ""); sb = sb.Replace("</EPM-HTML>", ""); return sb.ToString(); }
/// <summary> /// Formats a template given an entity and optional template /// </summary> /// <param name="entity">The entity to format.</param> /// <param name="usage">Use definition to format, or null for all use definitions for entity.</param> /// <param name="iFigure">The last figure number used.</param> /// /// <param name="iFigure">The last table number used.</param> /// <returns></returns> private static string FormatConcept( DocProject docProject, DocEntity entity, DocConceptRoot root, DocTemplateUsage usage, Dictionary<string, DocObject> mapEntity, Dictionary<string, string> mapSchema, List<ContentRef> listFigures, List<ContentRef> listTables) { if (usage.Definition == null) return String.Empty; StringBuilder sb = new StringBuilder(); string anchorid = MakeLinkName(usage.Definition); // anchor sb.Append("<a id=\""); sb.Append(anchorid); sb.Append("\" />"); sb.AppendLine(); // Caption sb.Append("<p class=\"use-head\">"); sb.Append(usage.Definition.Name); sb.Append("</p>"); sb.AppendLine(); // filter by particular model view DocModelView docModelView = null; if (root != null) { foreach (DocModelView docView in docProject.ModelViews) { if (docView.ConceptRoots.Contains(root)) { docModelView = docView; break; } } } // new (2.0): capture inherited properties too DocTemplateItem[] listItems = FindTemplateItems(docProject, entity, usage.Definition, docModelView); // add stock sentence // typical values: "Material Constituents", "Documents", "Aggregation", "Nesting", "Representations" // Usage of the <i>Material Constituents</i> concept is shown in Table XXXX. // Usage of the <i>Nesting</i> concept is shown in Table XXXX. // Usage of the <i>Aggregation</i> concept is shown in Table XXXX: // get link of usage string deflink = MakeLinkName(usage.Definition) + ".htm"; if (listItems.Length > 0) { listTables.Add(new ContentRef(entity.Name + " " + usage.Definition.Name, entity)); sb.Append("<p>The <a href=\"../../templates/"); sb.Append(deflink); sb.Append("\">"); sb.Append(usage.Definition.Name); sb.Append("</a> concept applies to this entity as shown in Table "); sb.Append(listTables.Count); sb.Append("."); sb.AppendLine("<table>"); sb.AppendLine("<tr><td>"); string table = FormatConceptTable(docProject, docModelView, entity, root, usage, mapEntity, mapSchema); sb.Append(table); sb.AppendLine("</td></tr>"); sb.Append("<tr><td><p class=\"table\">Table "); sb.Append(listTables.Count); sb.Append(" — "); sb.Append(entity.Name); sb.Append(" "); sb.Append(usage.Definition.Name); sb.AppendLine("</td></tr></table>"); sb.AppendLine(); } else { sb.Append("<p>The <a href=\"../../templates/"); sb.Append(deflink); sb.Append("\">"); sb.Append(usage.Definition.Name); sb.Append("</a> concept applies to this entity.</p>"); } // add figure if it exists string fig = FormatFigure(docProject, entity, usage.Definition, entity.Text, listFigures); if (fig != null) { sb.Append(fig); } if (usage.Documentation != null) { sb.AppendLine(usage.Documentation); // special case if definition provides description, such as for classification } string req = FormatRequirements(usage, docModelView, true); if (req != null) { sb.AppendLine(req); } sb.AppendLine("<br/><br/>"); return sb.ToString(); }
private g SaveDefinition(DocObject docObj, string displayname) { g group = new g(); group.id = docObj.Name; DocDefinition docDef = docObj as DocDefinition; if (docDef == null || docDef.DiagramRectangle == null) { return(group); } double x = docDef.DiagramRectangle.X * CtlExpressG.Factor; double y = docDef.DiagramRectangle.Y * CtlExpressG.Factor; double cx = docDef.DiagramRectangle.Width * CtlExpressG.Factor; double cy = docDef.DiagramRectangle.Height * CtlExpressG.Factor; rect r = new rect(); r.x = x.ToString(); r.y = y.ToString(); r.width = cx.ToString(); r.height = cy.ToString(); r.stroke = "black"; group.rect.Add(r); text t = new text(); t.x = (x + cx * 0.5).ToString(); t.y = (y + cy * 0.5).ToString(); t.fill = "black"; t.alignment_baseline = "middle"; t.text_anchor = "middle"; t.font_size = "10"; t.font_family = "Arial, Helvetica, sans-serif"; if (displayname != null) { t.value = displayname; } else { t.value = docDef.Name; } group.text.Add(t); if (this.m_format == DiagramFormat.UML) { y += 10; group.fill = "lightyellow"; t.y = y.ToString(); t.alignment_baseline = "top"; t.font_weight = "bold"; t.value = docDef.Name; // separator line y += 2; List <DocPoint> listPoint = new List <DocPoint>(); listPoint.Add(new DocPoint(x / CtlExpressG.Factor, y / CtlExpressG.Factor)); listPoint.Add(new DocPoint((x + cx) / CtlExpressG.Factor, y / CtlExpressG.Factor)); SaveLine(group, listPoint, null, false); y += 2; // add attributes if (docDef is DocDefinitionRef) { DocDefinitionRef docDefRef = (DocDefinitionRef)docDef; DocObject docObjRef = this.m_project.GetDefinition(docDefRef.Name); if (docObjRef is DocEntity) { DocEntity docEnt = (DocEntity)docObjRef; foreach (DocAttribute docAtt in docEnt.Attributes) { if (docAtt.Derived == null && docAtt.Inverse == null) { DocObject docAttrType = this.m_project.GetDefinition(docAtt.DefinedType); // include native types, enumerations, and defined types if (docAttrType == null || docAttrType is DocEnumeration || docAttrType is DocDefined) { y += 12; string agg = "[1]"; if (docAtt.AggregationType != 0) { string lower = docAtt.AggregationLower; string upper = docAtt.AggregationUpper; if (String.IsNullOrEmpty(lower)) { lower = "0"; } if (String.IsNullOrEmpty(upper) || upper == "0") { upper = "*"; } agg = "[" + lower + ".." + upper + "]"; } else if (docAtt.IsOptional) { agg = "[0..1]"; } text ta = new text(); ta.x = (x + 4).ToString(); ta.y = y.ToString(); ta.fill = "black"; ta.alignment_baseline = "top"; ta.text_anchor = "start"; ta.font_size = "9"; ta.font_family = "Arial, Helvetica, sans-serif"; ta.value = docAtt.Name + agg + " : " + docAtt.DefinedType; group.text.Add(ta); } } } // UML only (not in original EXPRESS-G diagrams) foreach (DocAttributeRef docAttrRef in docDefRef.AttributeRefs) { DocAttribute docAtt = docAttrRef.Attribute; //if (docAtt.Inverse == null) { //... also need to capture attribute name... //DrawLine(g, Pens.Black, docAttrRef.DiagramLine, format); SaveLine(group, docAttrRef.DiagramLine, null, false); // draw diamond at beginning of line #if false /// not yet correct if (this.m_format == DiagramFormat.UML) { DocPoint ptHead = docAttrRef.DiagramLine[0]; DocPoint ptNext = docAttrRef.DiagramLine[1]; double ux = ptNext.X - ptHead.X; double uy = ptNext.Y - ptHead.Y; double uv = Math.Sqrt(ux * ux + uy * uy); ux = ux / uv; uy = uy / uv; DocPoint ptR = new DocPoint(ptHead.X + uy * 8, ptHead.Y + ux * 8); DocPoint ptF = new DocPoint(ptHead.X + ux * 16, ptHead.Y + uy * 8); DocPoint ptL = new DocPoint(ptHead.X + uy * 8, ptHead.Y - ux * 8); List <DocPoint> listP = new List <DocPoint>(); listP.Add(ptHead); listP.Add(ptR); listP.Add(ptF); listP.Add(ptL); listP.Add(ptHead); SaveLine(group, listP, null, false); } #endif if (docAtt.Name == "Items") { docAtt.ToString(); } string agg = "[1]"; if (docAtt.AggregationType != 0) { string lower = docAtt.AggregationLower; string upper = docAtt.AggregationUpper; if (String.IsNullOrEmpty(lower)) { lower = "0"; } if (String.IsNullOrEmpty(upper)) { upper = "*"; } agg = "[" + lower + ".." + upper + "]"; } else if (docAtt.IsOptional) { agg = "[0..1]"; } double ty = docAttrRef.DiagramLine[0].Y * CtlExpressG.Factor; if (docAttrRef.DiagramLine[1].Y > docAttrRef.DiagramLine[0].Y) { ty -= 10; } else { ty += 10; } text tr = new text(); tr.x = (docAttrRef.DiagramLine[0].X * CtlExpressG.Factor + 4).ToString(); tr.y = (ty).ToString(); tr.fill = "black"; tr.alignment_baseline = "top"; tr.text_anchor = "start"; tr.font_size = "9"; tr.font_family = "Arial, Helvetica, sans-serif"; tr.value = docAtt.Name + agg; group.text.Add(tr); } } } } } else { if (docDef is DocEntity) { group.fill = "yellow"; } else if (docDef is DocType) { group.fill = "green"; } else if (docDef is DocPageTarget) { group.fill = "blue"; r.rx = "10"; r.ry = "10"; } else if (docDef is DocPageSource) { group.fill = "silver"; r.rx = "10"; r.ry = "10"; } else { group.fill = "grey"; } } return(group); }
private void LoadPropertySets() { this.treeViewProperty.Nodes.Clear(); DocEntity docEntity = this.m_entity; if (this.m_portname != null) { docEntity = this.m_project.GetDefinition("IfcDistributionPort") as DocEntity; } foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocPropertySet docPset in docSchema.PropertySets) { bool include = false; if (docEntity != null && docPset.ApplicableType != null) { string[] parts = docPset.ApplicableType.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string part in parts) { DocEntity docBase = docEntity; while (docBase != null) { if (part.Contains(docBase.Name)) { include = true; break; } docBase = this.m_project.GetDefinition(docBase.BaseDefinition) as DocEntity; } } } if (this.m_entity == null || include) { TreeNode tnPset = new TreeNode(); tnPset.Tag = docPset; tnPset.Text = docPset.Name; tnPset.ImageIndex = 0; tnPset.SelectedImageIndex = 0; this.treeViewProperty.Nodes.Add(tnPset); // only select psets if no entity defined if (this.m_entity != null && !this.treeViewProperty.CheckBoxes) { foreach (DocProperty docProp in docPset.Properties) { TreeNode tnProp = new TreeNode(); tnProp.Tag = docProp; tnProp.Text = docProp.Name; tnProp.ImageIndex = 1; tnProp.SelectedImageIndex = 1; tnPset.Nodes.Add(tnProp); // also add min/max if bounded if (docProp.PropertyType == DocPropertyTemplateTypeEnum.P_BOUNDEDVALUE) { tnProp.Nodes.Add(new TreeNode("UpperBoundValue", 1, 1)); tnProp.Nodes.Add(new TreeNode("LowerBoundValue", 1, 1)); } } } } } } } this.treeViewProperty.ExpandAll(); }
/// <summary> /// /// </summary> /// <param name="docEntity">If entity specified, shows property sets and properties applicable to entity; if null, shows all property sets.</param> /// <param name="docProject">Required project.</param> /// <param name="multiselect">True to select multiple properties; False to select single property; Null to show properties that can be merged.</param> public FormSelectProperty(DocEntity docEntity, DocProject docProject, bool?multiselect) : this() { this.m_entity = docEntity; this.m_project = docProject; if (multiselect != null) { if (multiselect == true) { this.treeViewProperty.CheckBoxes = true; this.Text = "Include Property Sets"; this.comboBoxPort.Enabled = false; } else if (multiselect == false) { // find applicable ports this.comboBoxPort.Items.Add("(object)"); this.comboBoxPort.SelectedIndex = 0; if (docEntity != null) { foreach (DocModelView docView in docProject.ModelViews) { foreach (DocConceptRoot docRoot in docView.ConceptRoots) { if (docRoot.ApplicableEntity == docEntity) { foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if (docConcept.Definition != null && docConcept.Definition.Uuid == DocTemplateDefinition.guidPortNesting) { foreach (DocTemplateItem docItem in docConcept.Items) { string name = docItem.GetParameterValue("Name"); if (name != null && !this.comboBoxPort.Items.Contains(name)) { this.comboBoxPort.Items.Add(name); } } } } } } } } } this.LoadPropertySets(); } else if (multiselect == null) { this.Text = "Merge Duplicate Properties"; this.treeViewProperty.CheckBoxes = true; this.comboBoxPort.Enabled = false; // build list of shared properties //Dictionary<string, DocProperty> duplicateProperties = new Dictionary<string, DocProperty>(); this.m_sharedproperties = new Dictionary <string, DocProperty>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocPropertySet docPset in docSchema.PropertySets) { // first, capture all unique properties... THEN, only shared properties if (!docPset.IsVisible()) { foreach (DocProperty docProp in docPset.Properties) { if (!this.m_sharedproperties.ContainsKey(docProp.Name)) { this.m_sharedproperties.Add(docProp.Name, docProp); } /* * else if(!duplicateProperties.ContainsKey(docProp.Name)) * { * duplicateProperties.Add(docProp.Name, docProp); * }*/ } } } } } //this.m_sharedproperties = duplicateProperties; // find all duplicate properties foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocPropertySet docPset in docSchema.PropertySets) { if (docPset.IsVisible()) { TreeNode tnPset = null; foreach (DocProperty docProp in docPset.Properties) { DocProperty docExist = null; if (this.m_sharedproperties.TryGetValue(docProp.Name, out docExist) && docExist != docProp) { if (tnPset == null) { tnPset = new TreeNode(); tnPset.Tag = docPset; tnPset.Text = docPset.Name; tnPset.ImageIndex = 0; tnPset.SelectedImageIndex = 0; tnPset.Checked = true; this.treeViewProperty.Nodes.Add(tnPset); } TreeNode tnProp = new TreeNode(); tnProp.Tag = docProp; tnProp.Text = docProp.Name; tnProp.ImageIndex = 1; tnProp.SelectedImageIndex = 1; tnProp.Checked = true; tnPset.Nodes.Add(tnProp); tnPset.Expand(); } } } } } } } }
public static void BuildAttributeListInverse(List<DocAttribute> list, Dictionary<string, DocObject> map, DocEntity docEntity) { // recurse to base type first if (docEntity.BaseDefinition != null) { DocEntity docSuper = map[docEntity.BaseDefinition] as DocEntity; BuildAttributeListInverse(list, map, docSuper); } // then add direct attributes foreach (DocAttribute docAttribute in docEntity.Attributes) { if (docAttribute.Inverse != null) { list.Add(docAttribute); } } }