public void onSetFk(CswNbtObjClassDesignNodeTypeProp DesignNTPNode) { Collection <CswNbtFieldTypeAttribute> Attributes = getAttributes(); CswNbtFieldTypeAttribute FkTypeAttr = Attributes.FirstOrDefault(a => a.Column == CswEnumNbtPropertyAttributeColumn.Fktype); if (DesignNTPNode.AttributeProperty.ContainsKey(FkTypeAttr.Name)) { CswNbtNodePropWrapper FkTypeProp = DesignNTPNode.AttributeProperty[FkTypeAttr.Name]; if (null != FkTypeProp && FkTypeProp.wasAnySubFieldModified(false)) { CswNbtNodePropMetaDataList FkProp = FkTypeProp.AsMetaDataList; CswNbtViewId ViewId = DesignNTPNode.AttributeProperty[AttributeName.UnitView].AsViewReference.ViewId; CswNbtView View = _CswNbtFieldResources.CswNbtResources.ViewSelect.restoreView(ViewId); if (CswEnumNbtViewRelatedIdType.Unknown != FkProp.Type && Int32.MinValue != FkProp.Id) { //We have valid values that are different that what is currently set CswNbtFieldTypeRuleDefaultImpl.setDefaultView(_CswNbtFieldResources.CswNbtResources.MetaData, DesignNTPNode, View, FkProp.Type, FkProp.Id, false); } else { //Make sure a default view is set CswEnumNbtViewRelatedIdType TargetType = DesignNTPNode.AttributeProperty[AttributeName.UnitTarget].AsMetaDataList.Type; Int32 TargetId = DesignNTPNode.AttributeProperty[AttributeName.UnitTarget].AsMetaDataList.Id; if (CswEnumNbtViewRelatedIdType.Unknown != TargetType && Int32.MinValue != TargetId) { CswNbtFieldTypeRuleDefaultImpl.setDefaultView(_CswNbtFieldResources.CswNbtResources.MetaData, DesignNTPNode, View, TargetType, TargetId, true); } } } } // if( DesignNTPNode.AttributeProperty.ContainsKey( FkTypeAttr.Name ) ) } // onSetFk()
public CswViewBuilderProp(CswNbtMetaDataNodeTypeProp NodeTypeProp) { CswNbtMetaDataNodeType nt = NodeTypeProp.getNodeType(); if (null != nt) { OwnerName = nt.NodeTypeName; } FieldType = NodeTypeProp.getFieldTypeValue(); //ListOptions.FromString( NodeTypeProp.ListOptions ); ListOptions.FromString(NodeTypeProp.DesignNode.AttributeProperty[CswEnumNbtPropertyAttributeName.Options].AsText.Text); RelatedIdType = CswEnumNbtViewRelatedIdType.NodeTypeId; MetaDataPropNameWithQuestionNo = NodeTypeProp.PropNameWithQuestionNo; MetaDataPropId = NodeTypeProp.FirstPropVersionId; MetaDataPropName = NodeTypeProp.PropName; MetaDataTypeName = NodeTypeProp.getNodeType().NodeTypeName; FieldTypeRule = NodeTypeProp.getFieldTypeRule(); Type = CswEnumNbtViewPropType.NodeTypePropId; PropName = MetaDataPropName; AssociatedPropIds.Add(MetaDataPropId.ToString()); if (NodeTypeProp.ObjectClassPropId != Int32.MinValue) { AssociatedPropIds.Add(NodeTypeProp.ObjectClassPropId.ToString()); } } //ctor Ntp
void CswNodeTypeSelect_SelectedIndexChanged(object sender, EventArgs e) { CswEnumNbtViewRelatedIdType SelectedType = CswEnumNbtViewRelatedIdType.Unknown; Int32 SelectedVal = Int32.MinValue; if (this.SelectedValue.StartsWith(_NodeTypePrefix)) { SelectedType = CswEnumNbtViewRelatedIdType.NodeTypeId; SelectedVal = Convert.ToInt32(this.SelectedValue.Substring(_NodeTypePrefix.Length)); } else if (this.SelectedValue.StartsWith(_ObjectClassPrefix)) { SelectedType = CswEnumNbtViewRelatedIdType.ObjectClassId; SelectedVal = SelectedObjectClassId; } else if (this.SelectedValue.StartsWith(_PropertySetPrefix)) { SelectedType = CswEnumNbtViewRelatedIdType.PropertySetId; SelectedVal = SelectedPropertySetId; } if (SelectedNodeTypeChanged != null) { SelectedNodeTypeChanged(SelectedType, SelectedVal); } }
} // setObjectClassPropListOptions() private string _getOwnerName(CswNbtViewProperty ViewProperty) { string ret = string.Empty; CswNbtViewRelationship parent = (CswNbtViewRelationship)ViewProperty.Parent; CswEnumNbtViewRelatedIdType ownerType = parent.getOwnerType(); if (ownerType == CswEnumNbtViewRelatedIdType.NodeTypeId) { CswNbtMetaDataNodeType ntOwner = parent.getNodeTypeOwner(); ret = ntOwner.NodeTypeName; } else if (ownerType == CswEnumNbtViewRelatedIdType.ObjectClassId) { CswNbtMetaDataObjectClass ocOwner = parent.getObjClassOwner(); ret = ocOwner.ObjectClass.ToString(); } else { CswNbtMetaDataPropertySet psOwner = parent.getPropSetOwner(); ret = psOwner.Name; } return(ret); }
} // _getVbProperties() /// <summary> /// Fetches all props and all prop filters for a NodeType /// </summary> private JObject _getVbProperties(CswEnumNbtViewRelatedIdType RelationshipType, Int32 RelationshipId) { JObject ViewBuilderProps = new JObject(); if (Int32.MinValue != RelationshipId) { IEnumerable <CswViewBuilderProp> ViewBuilderProperties = null; if (RelationshipType == CswEnumNbtViewRelatedIdType.NodeTypeId) { CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(RelationshipId); Dictionary <Int32, string> UniqueProps = new Dictionary <int, string>(); ViewBuilderProperties = _getNodeTypeProps(NodeType, ref UniqueProps); } else if (RelationshipType == CswEnumNbtViewRelatedIdType.ObjectClassId) { CswNbtMetaDataObjectClass ObjectClass = _CswNbtResources.MetaData.getObjectClass(RelationshipId); ViewBuilderProperties = _getObjectClassProps(ObjectClass); } else if (RelationshipType == CswEnumNbtViewRelatedIdType.PropertySetId) { ViewBuilderProperties = new Collection <CswViewBuilderProp>(); foreach (CswNbtMetaDataObjectClass ObjectClass in _CswNbtResources.MetaData.getObjectClassesByPropertySetId(RelationshipId)) { ViewBuilderProperties = ViewBuilderProperties.Union(_getObjectClassProps(ObjectClass)); } } ViewBuilderProps = _getVbProperties(ViewBuilderProperties, RelationshipType); } return(ViewBuilderProps); } // _getVbProperties()
private void _setValue(CswEnumNbtViewRelatedIdType inType, Int32 inId, string inText) { Type = inType; Id = inId; Text = inText; SyncGestalt(); }
/// <summary> /// Returns true if the relationship is invalid /// </summary> private bool _isInvalidRelationship(CswEnumNbtViewRelatedIdType RelatedIdType, Int32 FkValue, CswEnumNbtViewPropIdType inValuePropType, Int32 inValuePropId) { bool RetIsInvalid = false; //if( RelatedIdType == NbtViewRelatedIdType.NodeTypeId ) //{ // CswNbtMetaDataNodeType FkRelationshipTargetNt = _CswNbtFieldResources.CswNbtResources.MetaData.getNodeType( FkValue ); // RetIsInvalid = ( null == FkRelationshipTargetNt ); // if( false == RetIsInvalid ) // { // CswNbtMetaDataNodeTypeProp ValueNtp = _CswNbtFieldResources.CswNbtResources.MetaData.getNodeTypeProp( inValuePropId ); // RetIsInvalid = ( null == ValueNtp || // _CswNbtFieldResources.CswNbtResources.MetaData.getNodeTypeFirstVersion( ValueNtp.NodeTypeId ) != FkRelationshipTargetNt.getFirstVersionNodeType() ); // } //} //else if( RelatedIdType == NbtViewRelatedIdType.ObjectClassId ) //{ // CswNbtMetaDataObjectClass FkRelationshipTargetOc = _CswNbtFieldResources.CswNbtResources.MetaData.getObjectClass( FkValue ); // RetIsInvalid = ( null == FkRelationshipTargetOc ); // if( false == RetIsInvalid ) // { // CswNbtMetaDataObjectClassProp ValueOcp = _CswNbtFieldResources.CswNbtResources.MetaData.getObjectClassProp( inValuePropId ); // RetIsInvalid = ( null == ValueOcp || ( ValueOcp.getObjectClass().ObjectClass != FkRelationshipTargetOc.ObjectClass ) ); // } //} //else if( RelatedIdType == NbtViewRelatedIdType.PropertySetId ) //{ // CswNbtMetaDataPropertySet FkRelationshipTargetPs = _CswNbtFieldResources.CswNbtResources.MetaData.getPropertySet( FkValue ); // RetIsInvalid = ( null == FkRelationshipTargetPs ); // if( false == RetIsInvalid ) // { // CswNbtMetaDataObjectClassProp ValueOcp = _CswNbtFieldResources.CswNbtResources.MetaData.getObjectClassProp( inValuePropId ); // RetIsInvalid = ( null == ValueOcp || // null == ValueOcp.getObjectClass().getPropertySet() || // ValueOcp.getObjectClass().getPropertySet().Name != FkRelationshipTargetPs.Name ); // } //} if (inValuePropType == CswEnumNbtViewPropIdType.NodeTypePropId) { CswNbtMetaDataNodeTypeProp ValuePropNTP = _CswNbtFieldResources.CswNbtResources.MetaData.getNodeTypeProp(inValuePropId); RetIsInvalid = false == (CswNbtViewRelationship.Matches(_CswNbtFieldResources.CswNbtResources, RelatedIdType, FkValue, ValuePropNTP.getNodeType())); } else if (inValuePropType == CswEnumNbtViewPropIdType.ObjectClassPropId) { CswNbtMetaDataObjectClassProp ValuePropOCP = _CswNbtFieldResources.CswNbtResources.MetaData.getObjectClassProp(inValuePropId); RetIsInvalid = false == (CswNbtViewRelationship.Matches(_CswNbtFieldResources.CswNbtResources, RelatedIdType, FkValue, ValuePropOCP.getObjectClass())); } return(RetIsInvalid); }
} //ctor Ntp public CswViewBuilderProp(CswNbtViewProperty ViewProperty) { if (ViewProperty.Type == CswEnumNbtViewPropType.NodeTypePropId && null != ViewProperty.NodeTypeProp) { OwnerName = _getOwnerName(ViewProperty); FieldType = ViewProperty.NodeTypeProp.getFieldTypeValue(); //ListOptions.FromString( ViewProperty.NodeTypeProp.ListOptions ); if (ViewProperty.NodeTypeProp.DesignNode.AttributeProperty.ContainsKey(CswEnumNbtPropertyAttributeName.Options)) { ListOptions.FromString(ViewProperty.NodeTypeProp.DesignNode.AttributeProperty[CswEnumNbtPropertyAttributeName.Options].AsText.Text); } RelatedIdType = CswEnumNbtViewRelatedIdType.NodeTypeId; MetaDataPropNameWithQuestionNo = ViewProperty.NodeTypeProp.PropNameWithQuestionNo; MetaDataPropId = ViewProperty.NodeTypeProp.FirstPropVersionId; MetaDataPropName = ViewProperty.NodeTypeProp.PropName; MetaDataTypeName = ViewProperty.NodeTypeProp.getNodeType().NodeTypeName; FieldTypeRule = ViewProperty.NodeTypeProp.getFieldTypeRule(); AssociatedPropIds.Add(MetaDataPropId.ToString()); if (ViewProperty.NodeTypeProp.ObjectClassPropId != Int32.MinValue) { AssociatedPropIds.Add(ViewProperty.NodeTypeProp.ObjectClassPropId.ToString()); } } else if (ViewProperty.Type == CswEnumNbtViewPropType.ObjectClassPropId && null != ViewProperty.ObjectClassProp) { CswNbtMetaDataObjectClass oc = ViewProperty.ObjectClassProp.getObjectClass(); if (null != oc) { OwnerName = oc.ObjectClass.Value; } FieldType = ViewProperty.ObjectClassProp.getFieldTypeValue(); setObjectClassPropListOptions(ViewProperty.ObjectClassProp); RelatedIdType = CswEnumNbtViewRelatedIdType.ObjectClassId; MetaDataPropNameWithQuestionNo = ViewProperty.ObjectClassProp.PropNameWithQuestionNo; MetaDataPropId = ViewProperty.ObjectClassProp.ObjectClassPropId; MetaDataPropName = ViewProperty.ObjectClassProp.PropName; MetaDataTypeName = ViewProperty.ObjectClassProp.getObjectClass().ObjectClass.ToString().Replace("Class", ""); FieldTypeRule = ViewProperty.ObjectClassProp.getFieldTypeRule(); AssociatedPropIds.Add(MetaDataPropId.ToString()); } ViewProp = ViewProperty; FieldType = ViewProperty.FieldType; Filters = ViewProperty.Filters; Type = ViewProperty.Type; Width = ViewProperty.Width; SortBy = ViewProperty.SortBy; SortMethod = ViewProperty.SortMethod; PropName = ViewProperty.Name ?? MetaDataPropName; } //ctor Vp
public JObject getVbProp(CswNbtView View, CswViewBuilderProp VbProp) { JObject Ret = new JObject(); if (null != VbProp) { CswEnumNbtViewRelatedIdType Relationship = VbProp.RelatedIdType; Int32 NodeTypeOrObjectClassId = VbProp.MetaDataPropId; if (Int32.MinValue != NodeTypeOrObjectClassId && CswEnumNbtViewRelatedIdType.Unknown != Relationship) { _getVbPropData(Ret, VbProp); } } return(Ret); }
} //ctor Ntp public CswViewBuilderProp(CswNbtMetaDataObjectClassProp ObjectClassProp) { CswNbtMetaDataObjectClass oc = ObjectClassProp.getObjectClass(); if (null != oc) { OwnerName = oc.ObjectClass.Value; } FieldType = ObjectClassProp.getFieldTypeValue(); setObjectClassPropListOptions(ObjectClassProp); RelatedIdType = CswEnumNbtViewRelatedIdType.NodeTypeId; MetaDataPropNameWithQuestionNo = ObjectClassProp.PropNameWithQuestionNo; MetaDataPropId = ObjectClassProp.ObjectClassPropId; MetaDataPropName = ObjectClassProp.PropName; MetaDataTypeName = ObjectClassProp.getObjectClass().ObjectClass.ToString(); FieldTypeRule = ObjectClassProp.getFieldTypeRule(); Type = CswEnumNbtViewPropType.ObjectClassPropId; PropName = MetaDataPropName; AssociatedPropIds.Add(MetaDataPropId.ToString()); } //ctor Ntp
public void setValue(CswEnumNbtViewRelatedIdType Type, Int32 Id) { CswNbtNodeTypePropListOption selOption = null; if (Type == CswEnumNbtViewRelatedIdType.NodeTypeId) { selOption = Options.FindByValue(NodeTypePrefix + Id.ToString()); } else if (Type == CswEnumNbtViewRelatedIdType.ObjectClassId) { selOption = Options.FindByValue(ObjectClassPrefix + Id.ToString()); } else if (Type == CswEnumNbtViewRelatedIdType.PropertySetId) { selOption = Options.FindByValue(PropertySetPrefix + Id.ToString()); } if (null != selOption) { _setValue(Type, Id, selOption.Text); } }
} // _getObjectClassProps() /// <summary> /// Fetches all props and all prop filters for a ViewProp collection /// </summary> private JObject _getVbProperties(IEnumerable <CswViewBuilderProp> ViewBuilderProperties, CswEnumNbtViewRelatedIdType RelatedIdType) { JObject PropObj = new JObject(); PropObj["properties"] = new JObject(); PropObj["properties"]["Specific Properties"] = new JObject(); PropObj["properties"]["Generic Properties"] = new JObject(); bool Selected = true; if (null != ViewBuilderProperties) { foreach (CswViewBuilderProp Prop in from ViewBuilderProp in ViewBuilderProperties where !_ProhibittedFieldTypes.Contains(ViewBuilderProp.FieldType) orderby ViewBuilderProp.MetaDataPropName select ViewBuilderProp) { JObject PropNodeObj = new JObject(); PropNodeObj["type"] = RelatedIdType.ToString(); PropNodeObj["name"] = Prop.MetaDataPropName; PropNodeObj["id"] = Prop.MetaDataPropId.ToString(); if (Selected) { PropNodeObj["selected"] = true; PropObj["defaultprop"] = Prop.MetaDataPropName; Selected = false; } if (RelatedIdType == CswEnumNbtViewRelatedIdType.NodeTypeId) { PropObj["properties"]["Specific Properties"][Prop.MetaDataPropName] = PropNodeObj; } else if (RelatedIdType == CswEnumNbtViewRelatedIdType.ObjectClassId || RelatedIdType == CswEnumNbtViewRelatedIdType.PropertySetId) { PropObj["properties"]["Generic Properties"][Prop.MetaDataPropName] = PropNodeObj; } _getVbPropData(PropNodeObj, Prop); } } return(PropObj); } // _getVbProperties()
private void _addOptionsRecurse( CswNbtResources NbtResources, Dictionary<CswPrimaryKey, string> Options, ICswNbtTree CswNbtTree, CswEnumNbtViewRelatedIdType TargetType, Int32 TargetId ) //, Int32 TargetNodeTypeId, Int32 TargetObjectClassId ) { for( Int32 c = 0; c < CswNbtTree.getChildNodeCount(); c++ ) { CswNbtTree.goToNthChild( c ); CswPrimaryKey currentNodeId = CswNbtTree.getNodeIdForCurrentPosition(); CswNbtMetaDataNodeType NodeType = NbtResources.MetaData.getNodeType( CswNbtTree.getNodeKeyForCurrentPosition().NodeTypeId ); if( currentNodeId != this.NodeId && // No self-referencing relationships CswNbtViewRelationship.Matches( NbtResources, TargetType, TargetId, NodeType ) ) { Options.Add( CswNbtTree.getNodeIdForCurrentPosition(), CswNbtTree.getNodeNameForCurrentPosition() ); } _addOptionsRecurse( NbtResources, Options, CswNbtTree, TargetType, TargetId ); CswNbtTree.goToParentNode(); } // for( Int32 c = 0; c < CswNbtTree.getChildNodeCount(); c++ ) } // _addOptionsRecurse()
} // getAttributes() public static CswNbtView setDefaultView(CswNbtMetaData MetaData, CswNbtObjClassDesignNodeTypeProp DesignNTPNode, CswNbtView View, CswEnumNbtViewRelatedIdType RelatedIdType, Int32 inFKValue, bool OnlyCreateIfNull) { if (RelatedIdType != CswEnumNbtViewRelatedIdType.Unknown && (null == View || View.Root.ChildRelationships.Count == 0 || false == OnlyCreateIfNull)) { if (null != View) { View.Root.ChildRelationships.Clear(); } ICswNbtMetaDataDefinitionObject targetObj = MetaData.getDefinitionObject(RelatedIdType, inFKValue); if (null != targetObj) { CswNbtViewId OldViewId = View.ViewId; View = targetObj.CreateDefaultView(); View.ViewId = OldViewId; } else { throw new CswDniException(CswEnumErrorType.Error, "Cannot create a relationship without a valid target.", "setDefaultView() got an invalid RelatedIdType: " + RelatedIdType + " or value: " + inFKValue); } View.Visibility = CswEnumNbtViewVisibility.Property; View.ViewMode = CswEnumNbtViewRenderingMode.Tree; View.ViewName = DesignNTPNode.PropName.Text; View.save(); } return(View); }
private void _addProp(ICswNbtMetaDataProp prop) { CswNbtViewRoot.forEachRelationship eachRelationship = relationship => { //we have to iterate a temp view, but use the relationships on the "real" view relationship = (CswNbtViewRelationship)CurrentView.FindViewNodeByArbitraryId(relationship.ArbitraryId); //For property views, we ignore the top lvl relationship if ((false == (relationship.Parent is CswNbtViewRoot) && CurrentView.Visibility == CswEnumNbtViewVisibility.Property) || CurrentView.Visibility != CswEnumNbtViewVisibility.Property) { int Id = relationship.SecondId; CswEnumNbtViewRelatedIdType type = relationship.SecondType; if (relationship.PropOwner.Equals(CswEnumNbtViewPropOwnerType.First) && Int32.MinValue != relationship.FirstId && CurrentView.Visibility == CswEnumNbtViewVisibility.Property) { Id = relationship.FirstId; type = relationship.FirstType; } CswNbtViewProperty existingViewProp = relationship.findPropertyByName(prop.PropName); if (null != existingViewProp) { existingViewProp.ShowInGrid = true; } else { if (null != Request.Relationship) { int ownerTargetId = Request.Relationship.SecondId; Collection <CswNbtViewRelationship> relations = getViewChildRelationshipOptions(CurrentView, relationship.ArbitraryId); foreach (CswNbtViewRelationship related in relations) { ICswNbtMetaDataProp relProp = related.getProp(); int relatedTargetId = related.SecondId; if (ownerTargetId == relatedTargetId && Request.Relationship.getRelatedType() == related.getRelatedType()) { if (related.getRelatedType() == CswEnumNbtViewRelatedIdType.NodeTypeId) { CswNbtMetaDataNodeType ownerNT = _CswNbtResources.MetaData.getNodeType(relatedTargetId); foreach (CswNbtMetaDataNodeTypeProp ntp in ownerNT.getNodeTypeProps().Where(ntp => ntp.PropName == prop.PropName)) { CswNbtViewRelationship parentRel = (CswNbtViewRelationship)CurrentView.FindViewNodeByArbitraryId(related.ParentArbitraryId); CswNbtViewRelationship relToAddPropTo = relationship.findChildRelationshipByNodeTypeId(relatedTargetId); if (null == relToAddPropTo) { relToAddPropTo = CurrentView.AddViewRelationship(parentRel, related.PropOwner, relProp, false); } CurrentView.AddViewProperty(relToAddPropTo, ntp); } } else if (related.getRelatedType() == CswEnumNbtViewRelatedIdType.ObjectClassId) { CswNbtMetaDataObjectClass ownerOC = _CswNbtResources.MetaData.getObjectClass(relatedTargetId); foreach (CswNbtMetaDataObjectClassProp ocp in ownerOC.getObjectClassProps().Where(ocp => ocp.PropName == prop.PropName)) { CswNbtViewRelationship parentRel = (CswNbtViewRelationship)CurrentView.FindViewNodeByArbitraryId(related.ParentArbitraryId); CswNbtViewRelationship relToAddPropTo = relationship.findChildRelationshipByObjClassId(relatedTargetId); if (null == relToAddPropTo) { relToAddPropTo = CurrentView.AddViewRelationship(parentRel, related.PropOwner, relProp, false); } CurrentView.AddViewProperty(relToAddPropTo, ocp); } } else { CswNbtMetaDataPropertySet ownerPS = _CswNbtResources.MetaData.getPropertySet(relatedTargetId); foreach (CswNbtMetaDataObjectClass oc in ownerPS.getObjectClasses()) { foreach (CswNbtMetaDataNodeType nt in oc.getNodeTypes()) { foreach (CswNbtMetaDataNodeTypeProp ntp in nt.getNodeTypeProps()) { if (ntp.PropName == prop.PropName) { CswNbtViewRelationship parentRel = (CswNbtViewRelationship)CurrentView.FindViewNodeByArbitraryId(related.ParentArbitraryId); CswNbtViewRelationship relToAddPropTo = relationship.findChildRelationshipByPropSetId(relatedTargetId); if (null == relToAddPropTo) { relToAddPropTo = CurrentView.AddViewRelationship(parentRel, related.PropOwner, relProp, false); } CurrentView.AddViewProperty(relToAddPropTo, ntp); } } } } } } } } else { CswNbtViewRelationship realRelationship = (CswNbtViewRelationship)CurrentView.FindViewNodeByArbitraryId(relationship.ArbitraryId); if (type.Equals(CswEnumNbtViewRelatedIdType.NodeTypeId)) { CswNbtMetaDataNodeType nt = _CswNbtResources.MetaData.getNodeType(Id); CswNbtMetaDataNodeTypeProp ntp = nt.getNodeTypeProp(prop.PropName); if (null != ntp) { CurrentView.AddViewProperty(realRelationship, ntp); } } else if (type.Equals(CswEnumNbtViewRelatedIdType.ObjectClassId)) { CswNbtMetaDataObjectClass oc = _CswNbtResources.MetaData.getObjectClass(Id); CswNbtMetaDataObjectClassProp ocp = oc.getObjectClassProp(prop.PropName); if (null != ocp) { CurrentView.AddViewProperty(realRelationship, prop); } else { foreach (CswNbtMetaDataNodeType nt in oc.getNodeTypes()) { CswNbtMetaDataNodeTypeProp ntp = nt.getNodeTypeProp(prop.PropName); if (null != ntp) { CurrentView.AddViewProperty(realRelationship, prop); } } } } else { CswNbtMetaDataPropertySet ps = _CswNbtResources.MetaData.getPropertySet(Id); CswNbtMetaDataObjectClassProp ocp = ps.getPropertySetProps().FirstOrDefault(PropSetProp => PropSetProp.PropName == prop.PropName); if (null != ocp) { CurrentView.AddViewProperty(realRelationship, prop); } else { foreach (CswNbtMetaDataObjectClass oc in ps.getObjectClasses()) { foreach (CswNbtMetaDataNodeType nt in oc.getNodeTypes()) { CswNbtMetaDataNodeTypeProp ntp = nt.getNodeTypeProp(prop.PropName); if (null != ntp) { CurrentView.AddViewProperty(realRelationship, prop); } } } } } } } } }; CswNbtView tempView = _CswNbtResources.ViewSelect.restoreView(CurrentView.ToString()); tempView.Root.eachRelationship(eachRelationship, null); }
private static void _recurseForRelatedNTs(CswNbtResources NbtResources, CswNbtExplorerReturn Return, int NodeTypeId, int level, string OwnerIdStr) { if (false == SEEN.Contains(NodeTypeId) && level <= MAX_DEPTH) { CswNbtMetaDataNodeType NodeType = NbtResources.MetaData.getNodeType(NodeTypeId); CswNbtView View = new CswNbtView(NbtResources); CswNbtViewRelationship Relationship = View.AddViewRelationship(NodeType, false); CswNbtViewEditorRule ViewRule = new CswNbtViewEditorRuleAddViewLevels(NbtResources, new CswNbtViewEditorData() { CurrentView = View }); string DisplayName = string.Empty; string TargetIdStr = string.Empty; string IconFilename = string.Empty; string Id = string.Empty; Random rand = new Random(DateTime.Now.Millisecond); Collection <CswNbtViewRelationship> RelatedTypes = ViewRule.getViewChildRelationshipOptions(View, Relationship.ArbitraryId); foreach (CswNbtViewRelationship Related in RelatedTypes) { bool WasNT = false; bool ObjClassAllowed = false; DisplayName = Related.TextLabel; string MetaDataName = string.Empty; int id = (Related.PropOwner == CswEnumNbtViewPropOwnerType.First && Related.FirstId != Int32.MinValue ? Related.FirstId : Related.SecondId); CswEnumNbtViewRelatedIdType IdType = (Related.PropOwner == CswEnumNbtViewPropOwnerType.First && Related.FirstId != Int32.MinValue ? Related.FirstType : Related.SecondType); if (Related.PropOwner == CswEnumNbtViewPropOwnerType.Second) { if (IdType == CswEnumNbtViewRelatedIdType.NodeTypeId) { CswNbtMetaDataNodeType RelatedNodeType = NbtResources.MetaData.getNodeType(id); IconFilename = RelatedNodeType.IconFileName; TargetIdStr = OwnerIdStr + "_NT_" + RelatedNodeType.NodeTypeId + "_" + rand.Next(); Id = "NT_" + RelatedNodeType.NodeTypeId; CswNbtMetaDataObjectClass ObjClass = RelatedNodeType.getObjectClass(); ObjClassAllowed = FilterVal.Contains("OC_" + ObjClass.ObjectClassId); MetaDataName = RelatedNodeType.NodeTypeName; WasNT = true; } else if (IdType == CswEnumNbtViewRelatedIdType.ObjectClassId) { CswNbtMetaDataObjectClass RelatedObjClass = NbtResources.MetaData.getObjectClass(id); IconFilename = RelatedObjClass.IconFileName; TargetIdStr = OwnerIdStr + "_OC_" + RelatedObjClass.ObjectClassId + "_" + rand.Next(); Id = "OC_" + RelatedObjClass.ObjectClassId; MetaDataName = RelatedObjClass.ObjectClassName; } if (((IdType == CswEnumNbtViewRelatedIdType.NodeTypeId && FilterVal.Contains("NT_" + id) || ObjClassAllowed)) || (IdType == CswEnumNbtViewRelatedIdType.ObjectClassId && FilterVal.Contains("OC_" + id))) { _addToGraph(Return, DisplayName, OwnerIdStr, TargetIdStr, IconFilename, level, "Category", Id, MetaDataName, Related.PropId); if (level + 1 <= MAX_DEPTH && WasNT) { _recurseForRelatedNTs(NbtResources, Return, id, level + 1, TargetIdStr); } } } } } }