public override void update() { #region UPDATE VIEWS CswNbtMetaDataObjectClass userOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.UserClass ); CswNbtMetaDataObjectClassProp archivedOCP = userOC.getObjectClassProp( CswNbtObjClassUser.PropertyName.Archived ); foreach( CswNbtMetaDataNodeTypeProp relationshipProp in _CswNbtSchemaModTrnsctn.MetaData.getNodeTypeProps( CswNbtMetaDataFieldType.NbtFieldType.Relationship ) ) { if( relationshipProp.IsUserRelationship() ) { CswNbtView userView = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( relationshipProp.ViewId ); if( false == userView.IsEmpty() ) { CswNbtViewRelationship parent = userView.Root.ChildRelationships[0]; bool filterExists; bool viewPropExists; CswNbtViewProperty archivedVP = _viewPropAndFilterExists( out filterExists, out viewPropExists, userView, archivedOCP, CswNbtPropFilterSql.PropertyFilterMode.NotEquals, Tristate.True.ToString() ); if( false == viewPropExists ) //the view prop isn't there, add it with the filter { userView.AddViewPropertyAndFilter( parent, archivedOCP, FilterMode: CswNbtPropFilterSql.PropertyFilterMode.NotEquals, Value: Tristate.True.ToString() ); } else if( viewPropExists && false == filterExists ) //the view prop is there, but with no filter { userView.AddViewPropertyFilter( archivedVP, FilterMode: CswNbtPropFilterSql.PropertyFilterMode.NotEquals, Value: Tristate.True.ToString() ); } userView.save(); } } } #endregion }//Update()
public override void update() { const string ViewName = "PI Schedule ParentView"; CswNbtMetaDataNodeType InspectionGeneratorNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Inspection Schedule" ); if( null != InspectionGeneratorNT ) { CswNbtMetaDataNodeTypeProp ParentViewNTP = InspectionGeneratorNT.getNodeTypePropByObjectClassProp( CswNbtObjClassGenerator.PropertyName.ParentView ); CswNbtView ExistingView = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( ParentViewNTP.DefaultValue.AsViewReference.ViewId ); if( null != ExistingView && ExistingView.ViewName == ViewName ) { foreach( CswNbtObjClassGenerator InspectionSchedNode in InspectionGeneratorNT.getNodes( false, true, false, true ) ) { CswNbtView ParentView = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( InspectionSchedNode.ParentView.ViewId ); if( ParentView.IsEmpty() ) { ParentView.CopyFromView( ExistingView ); ParentView.save(); InspectionSchedNode.postChanges( false ); } } } else { throw new CswDniException( CswEnumErrorType.Error, "Default Value for Inspection Schedule Parent View is invalid", "InspectionSchedule.ParentView NTP default value got an unexpected view" ); } } } // update()
private void _initTargetParents() { //SI will have a ParentView to fetch InspectionTargets which will be used to find existing InsepctionDesign nodes or create new ones CswNbtView theParentView = null; if( ParentView.ViewId.isSet() ) { theParentView = _CswNbtResources.ViewSelect.restoreView( ParentView.ViewId ); } if( null != theParentView && false == theParentView.IsEmpty() && ParentType.SelectedNodeTypeIds.Count > 0 ) { // Case 20482 ( theParentView.Root.ChildRelationships[0] ).NodeIdsToFilterIn.Add( NodeId ); ICswNbtTree ParentsTree = _CswNbtResources.Trees.getTreeFromView( theParentView, false, false, false ); if( ParentType.SelectMode == CswEnumNbtPropertySelectMode.Single ) { Int32 ParentNtId = CswConvert.ToInt32( ParentType.SelectedNodeTypeIds[0] ); _TargetParents = ParentsTree.getNodeKeysOfNodeType( ParentNtId ); } } else { _TargetParents = new Collection<CswPrimaryKey> { Owner.RelatedNodeId }; } } // getTargetParents()
} // update() private CswNbtView _editView( string DocumentNodeType, CswNbtMetaDataObjectClass ObjectClassOfProperty, string DocumentObjClassProp ) { CswNbtView DocumentsView = null; CswNbtMetaDataNodeType DocumentNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( DocumentNodeType ); if( null != DocumentNT ) { CswNbtMetaDataNodeType NodeTypeOfProperty = ObjectClassOfProperty.FirstNodeType; if( null != NodeTypeOfProperty ) { // documents property that contains the viewxml CswNbtMetaDataNodeTypeProp DocumentsNTP = NodeTypeOfProperty.getNodeTypePropByObjectClassProp( DocumentObjClassProp ); if( null != DocumentsNTP ) { CswNbtMetaDataNodeTypeProp LinkNTP = DocumentNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetDocument.PropertyName.Link ); CswNbtMetaDataNodeTypeProp FileNTP = DocumentNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetDocument.PropertyName.File ); CswNbtMetaDataNodeTypeProp OpenFileNTP = DocumentNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetDocument.PropertyName.OpenFile ); DocumentsView = _CswNbtSchemaModTrnsctn.restoreView( DocumentsNTP.ViewId ); if( false == DocumentsView.IsEmpty() ) { // View.Root only gives us the <TreeView></TreeView> content. It does not give the first relationship. We are assuming // that these views have two relationships: An OC (or PS) and a Document relationship // To get at the Document relationship, we need to get the second relationship. If the view doesn't have this second relationship, // we will just ignore it and won't make any changes CswNbtViewRelationship ParentRel = DocumentsView.Root.ChildRelationships[0]; if( ParentRel.ChildRelationships.Count > 0 ) { DocumentsView.removeViewProperty( LinkNTP ); DocumentsView.removeViewProperty( FileNTP ); CswNbtViewRelationship ChildRel = ParentRel.ChildRelationships[0]; if( null == ChildRel.findProperty( OpenFileNTP.NodeTypeId ) ) { DocumentsView.AddViewProperty( ChildRel, OpenFileNTP ); } DocumentsView.save(); } } //if( false == DocumentsView.IsEmpty() ) }//if( null != DocumentsNTP ) }//if( null != NodeTypeOfProperty ) }//if( null != DocumentNT ) return DocumentsView; }//_editView()
public void onSetFk(CswNbtObjClassDesignNodeTypeProp DesignNTPNode) { CswNbtNodePropMetaDataList FkProp = DesignNTPNode.AttributeProperty[AttributeName.Target].AsMetaDataList; CswNbtNodePropViewReference ViewProp = DesignNTPNode.AttributeProperty[AttributeName.View].AsViewReference; if (null != FkProp && null != ViewProp && (FkProp.wasSubFieldModified(CswNbtFieldTypeRuleMetaDataList.SubFieldName.Type) || FkProp.wasSubFieldModified(CswNbtFieldTypeRuleMetaDataList.SubFieldName.Id)) && CswEnumNbtViewRelatedIdType.Unknown != FkProp.Type && Int32.MinValue != FkProp.Id) { CswNbtView View = _CswNbtFieldResources.CswNbtResources.ViewSelect.restoreView(ViewProp.ViewId); // don't override if view was also modified (case 31812) // but still override if the view is empty, to handle brand new properties (case 31858) if (View.IsEmpty() || false == ViewProp.wasSubFieldModified(CswNbtFieldTypeRuleViewReference.SubFieldName.ViewID)) { //We have valid values that are different that what is currently set CswNbtFieldTypeRuleDefaultImpl.setDefaultView(_CswNbtFieldResources.CswNbtResources.MetaData, DesignNTPNode, View, FkProp.Type, FkProp.Id, false); } } } // onSetFk()