Example #1
0
 public override void afterPropertySetPopulateProps()
 {
     if (Owner.RelatedNodeId != null)
     {
         CswNbtNode EquipmentOrAssemblyNode = _CswNbtResources.Nodes[Owner.RelatedNodeId];
         if (EquipmentOrAssemblyNode != null)
         {
             CswCommaDelimitedString NewYValues = new CswCommaDelimitedString();
             if (EquipmentOrAssemblyNode.getObjectClass().ObjectClass == CswEnumNbtObjectClass.EquipmentClass)
             {
                 CswNbtObjClassEquipment EquipmentNodeAsEquipment = (CswNbtObjClassEquipment)EquipmentOrAssemblyNode;
                 foreach (string YValue in EquipmentNodeAsEquipment.Parts.YValues)
                 {
                     if (EquipmentNodeAsEquipment.Parts.CheckValue(CswNbtObjClassEquipment.PartsXValueName, YValue))
                     {
                         NewYValues.Add(YValue);
                     }
                 }
             }
             else if (EquipmentOrAssemblyNode.getObjectClass().ObjectClass == CswEnumNbtObjectClass.EquipmentAssemblyClass)
             {
                 CswNbtObjClassEquipmentAssembly AssemblyNodeAsAssembly = (CswNbtObjClassEquipmentAssembly)EquipmentOrAssemblyNode;
                 foreach (string YValue in AssemblyNodeAsAssembly.AssemblyParts.YValues)
                 {
                     if (AssemblyNodeAsAssembly.AssemblyParts.CheckValue(CswNbtObjClassEquipmentAssembly.PartsXValueName, YValue))
                     {
                         NewYValues.Add(YValue);
                     }
                 }
             }
             this.Parts.YValues = NewYValues;
         } // if( EquipmentOrAssemblyNode != null )
     }     // if( Owner.RelatedNodeId != null )
 }         //afterPopulateProps()
        private CswNbtView _getSampleSizeUnitsView()
        {
            CswNbtObjClassCertDefSpec           RelatedCertDefSpec = _CswNbtResources.Nodes.GetNode(CertDefSpec.RelatedNodeId);
            CswNbtObjClassCertificateDefinition RelatedCertDef     = _CswNbtResources.Nodes.GetNode(RelatedCertDefSpec.CertDef.RelatedNodeId);
            CswNbtNode RelatedPart = _CswNbtResources.Nodes.GetNode(RelatedCertDef.Material.RelatedNodeId);

            CswNbtView SampleSizeUnitsView = null;

            if (CswEnumNbtObjectClass.ChemicalClass == RelatedPart.getObjectClass().ObjectClass)
            {
                SampleSizeUnitsView = _CswNbtResources.ViewSelect.restoreView(GramsViewName, CswEnumNbtViewVisibility.Hidden);
            }
            else if (CswEnumNbtObjectClass.EnterprisePartClass == RelatedPart.getObjectClass().ObjectClass)
            {
                SampleSizeUnitsView = _CswNbtResources.ViewSelect.restoreView(EachViewName, CswEnumNbtViewVisibility.Hidden);
            }

            return(SampleSizeUnitsView);
        }
Example #3
0
        // For validating object class casting
        protected static bool _Validate(CswNbtNode Node, CswEnumNbtObjectClass TargetObjectClass)
        {
            if (Node == null)
            {
                throw new CswDniException(CswEnumErrorType.Error, "Invalid node", "CswNbtObjClass._Validate was given a null node as a parameter");
            }

            if (!(Node.getObjectClass().ObjectClass == TargetObjectClass))
            {
                throw (new CswDniException(CswEnumErrorType.Error, "Invalid cast", "Can't cast current object class as " + TargetObjectClass.ToString() + "; Current object class is " + Node.getObjectClass().ObjectClass.ToString()));
            }
            return(true);
        }
 public static ICswNbtPropertySetScheduler AsPropertySetScheduler(CswNbtNode Node)
 {
     if (Node != null)
     {
         if (!(Node.ObjClass is ICswNbtPropertySetScheduler))
         {
             throw (new CswDniException(CswEnumErrorType.Error, "Invalid cast", "Can't cast current object class as ICswNbtPropertySetScheduler; Current object class is " + Node.getObjectClass().ObjectClass));
         }
         return((ICswNbtPropertySetScheduler)Node.ObjClass);
     }
     return(null);
 }//AsPropertySetScheduler
        /// <summary>
        /// for each method condition and method characteristic attached to this
        /// certDef, this method created a corresponding certDef condition
        /// and certDef characteristic. 
        /// </summary>
        private void _createCertDefSpecsAndCharacteristics()
        {
            
            CswNbtMetaDataObjectClass MethodOC = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.MethodClass );
            CswNbtMetaDataObjectClass MethodConditionOC = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.MethodConditionClass );
            CswNbtMetaDataObjectClass MethodCharacteristicOC = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.MethodCharacteristicClass);
            CswNbtMetaDataObjectClass CertDefConditionOC = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.CertDefConditionClass );
            CswNbtMetaDataObjectClass CertDefCharacteristicOC = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.CertDefCharacteristicLimitClass);

            CswNbtMetaDataNodeType CertDefConditionDefaultNT = CertDefConditionOC.FirstNodeType;
            CswNbtMetaDataNodeType CertDefCharacteristicDefaultNT = CertDefCharacteristicOC.FirstNodeType;

            CswNbtMetaDataObjectClassProp MethodConditionMethodOCP = _CswNbtResources.MetaData.getObjectClassProp(MethodConditionOC.ObjectClassId, 
                                                                                                                  CswNbtObjClassMethodCondition.PropertyName.Method);
            CswNbtMetaDataObjectClassProp MethodCharacteristicMethodOCP = _CswNbtResources.MetaData.getObjectClassProp(MethodCharacteristicOC.ObjectClassId, 
                                                                                                                  CswNbtObjClassMethodCharacteristic.PropertyName.Method);

            //create a view of all methodcondition and methodcharacteristics
            //attached to this method
            CswNbtView MethodConditionAndCharacteristicsView = new CswNbtView( _CswNbtResources );
            MethodConditionAndCharacteristicsView.ViewName = "View of all method characteristics and method conditions attached to a method";

            CswNbtViewRelationship MethodAsRootRelationship = MethodConditionAndCharacteristicsView.AddViewRelationship( MethodOC, false );
            MethodAsRootRelationship.NodeIdsToFilterIn.Add( Method.RelatedNodeId );

            MethodConditionAndCharacteristicsView.AddViewRelationship( MethodAsRootRelationship,
                                                                       CswEnumNbtViewPropOwnerType.Second,
                                                                       MethodConditionMethodOCP,
                                                                       false );
            MethodConditionAndCharacteristicsView.AddViewRelationship( MethodAsRootRelationship,
                                                                       CswEnumNbtViewPropOwnerType.Second,
                                                                       MethodCharacteristicMethodOCP,
                                                                       false );

            ICswNbtTree MethodConditionAndCharacteristicsTree = _CswNbtResources.Trees.getTreeFromView( MethodConditionAndCharacteristicsView, false, true, true, true );
            if( MethodConditionAndCharacteristicsTree.getChildNodeCount() > 0 )
            {
                MethodConditionAndCharacteristicsTree.goToNthChild( 0 );

                for( int i = 0; i < MethodConditionAndCharacteristicsTree.getChildNodeCount(); i++ )
                {
                    MethodConditionAndCharacteristicsTree.goToNthChild( i );
                    CswNbtNode thisNode = MethodConditionAndCharacteristicsTree.getNodeForCurrentPosition();

                    CswEnumNbtObjectClass thisNodeOC = thisNode.getObjectClass().ObjectClass;

                    if( thisNodeOC == CswEnumNbtObjectClass.MethodConditionClass)
                    {
                        if( CertDefConditionDefaultNT != null )
                        {
                        CswNbtObjClassMethodCondition thisMethodCondition = thisNode;
                        CswNbtObjClassCertDefCondition correspondingCertDefCondition = _CswNbtResources.Nodes.makeNodeFromNodeTypeId( CertDefConditionDefaultNT.NodeTypeId );

                        correspondingCertDefCondition.MethodCondition.RelatedNodeId = thisMethodCondition.NodeId;
                        correspondingCertDefCondition.CertDefSpec.RelatedNodeId = this.NodeId;
                        
                        correspondingCertDefCondition.postChanges( false );

                           
                        }

                        else
                        {
                            throw new CswDniException(CswEnumErrorType.Error,
                                                      "A CertDef Condition corresponding to an existing Method Condition could not be created because there is no CertDef Condition NodeType",
                                                      "CertDef Condition NodeType not found, so CertDef Condition cannot be created");
                        }
                    }

                    else if( thisNodeOC == CswEnumNbtObjectClass.MethodCharacteristicClass)
                    {
                        if( CertDefConditionDefaultNT != null )
                        {
                        CswNbtObjClassMethodCharacteristic thisMethodCharacteristic = thisNode;
                        CswNbtObjClassCertDefCharacteristicLimit correspondingCertDefCharacteristic = _CswNbtResources.Nodes.makeNodeFromNodeTypeId( CertDefCharacteristicDefaultNT.NodeTypeId );

                        correspondingCertDefCharacteristic.MethodCharacteristic.RelatedNodeId = thisMethodCharacteristic.NodeId;
                        correspondingCertDefCharacteristic.CertDefSpec.RelatedNodeId = this.NodeId;

                        correspondingCertDefCharacteristic.postChanges( false );

                        }
                        else 
                        {
                            throw new CswDniException(CswEnumErrorType.Error,
                                                      "A CertDef Characteristic Limit corresponding to an existing Method Characteristic Limit could not be created because there is no CertDef Characteristic Limit NodeType",
                                                      "CertDef Characteristic Limit NodeType not found, so CertDef Characteristic Limit cannot be created");
                        }
                    }

                    MethodConditionAndCharacteristicsTree.goToParentNode();

                }
            }
           
        }
        private void _trySetNodeTypeSelectDefaultValues()
        {
            //has owner and (is inspection schedule or has a view already)
            bool RequiresParentView = CswTools.IsPrimaryKey( Owner.RelatedNodeId ) &&
                            ( Node.getNodeType().getFirstVersionNodeType().NodeTypeName == InspectionGeneratorNodeTypeName ||
                            ( ParentView.ViewId != null &&
                              ParentView.ViewId.isSet() ) );

            if( RequiresParentView )
            {
                CswNbtNode OwnerNode = _CswNbtResources.Nodes.GetNode( Owner.RelatedNodeId );
                Collection<CswNbtMetaDataNodeType> MatchingInspectionTargetNts = new Collection<CswNbtMetaDataNodeType>();

                //parent is selectable and is inspection and owner is valid and (parent untouched or empty)
                bool SetDefaultParentType = ( ( false == ParentType.wasAnySubFieldModified() ||
                                                ParentType.SelectedNodeTypeIds.Count == 0 ) &&
                                                null != OwnerNode &&
                                                OwnerNode.getObjectClass().ObjectClass == CswEnumNbtObjectClass.InspectionTargetGroupClass &&
                                                ParentType.SelectMode != CswEnumNbtPropertySelectMode.Blank );
                if( SetDefaultParentType )
                {
                    ParentType.SelectedNodeTypeIds.Clear();
                    CswNbtMetaDataObjectClass InspectionTargetOc = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.InspectionTargetClass );
                    foreach( CswNbtMetaDataNodeType InspectionTargetNt in InspectionTargetOc.getNodeTypes() )
                    {
                        if( InspectionTargetNt.IsLatestVersion() )
                        {
                            CswNbtMetaDataNodeTypeProp TargetGroupNtp = InspectionTargetNt.getNodeTypePropByObjectClassProp( CswNbtObjClassInspectionTarget.PropertyName.InspectionTargetGroup );
                            if( _fkIsValid( TargetGroupNtp ) )
                            {
                                CswNbtMetaDataNodeType InspectionTargetGroupNt = _CswNbtResources.MetaData.getNodeType( TargetGroupNtp.FKValue ).getNodeTypeLatestVersion();
                                if( null != InspectionTargetGroupNt &&
                                    false == MatchingInspectionTargetNts.Contains( InspectionTargetNt ) &&
                                    InspectionTargetGroupNt == OwnerNode.getNodeTypeLatestVersion() )
                                {
                                    MatchingInspectionTargetNts.Add( InspectionTargetNt );
                                    ParentType.SelectedNodeTypeIds.Add( InspectionTargetNt.NodeTypeId.ToString(), false, true );
                                    if( ParentType.SelectMode == CswEnumNbtPropertySelectMode.Single )
                                    {
                                        break;
                                    }
                                }
                            } // is valid FK
                        } // if( InspectionTargetNt.IsLatestVersion )
                    } // foreach( CswNbtMetaDataNodeType InspectionTargetNt in InspectionTargetOc.NodeTypes )
                } // if( SetDefaultTargetType )

                //target is selectable and (parent or target not empty) and (target untouched or empty)
                bool SetDefaultTargetType = ( ( false == TargetType.wasAnySubFieldModified() ||
                                            TargetType.SelectedNodeTypeIds.Count == 0 ) &&
                                          TargetType.SelectMode != CswEnumNbtPropertySelectMode.Blank &&
                                          ( MatchingInspectionTargetNts.Count > 0 ||
                                            TargetType.SelectedNodeTypeIds.Count > 0 ) );
                if( SetDefaultTargetType )
                {
                    if( MatchingInspectionTargetNts.Count == 0 )
                    {
                        foreach( Int32 InspectionTargetNodeTypeId in TargetType.SelectedNodeTypeIds.ToIntCollection() )
                        {
                            CswNbtMetaDataNodeType InspectionTargetNt = _CswNbtResources.MetaData.getNodeType( InspectionTargetNodeTypeId );
                            if( null != InspectionTargetNt )
                            {
                                CswNbtMetaDataNodeType LatestInspectionTargetNt = InspectionTargetNt.getNodeTypeLatestVersion();
                                if( LatestInspectionTargetNt.getObjectClass().ObjectClass == CswEnumNbtObjectClass.InspectionTargetClass &&
                                    false == MatchingInspectionTargetNts.Contains( LatestInspectionTargetNt ) )
                                {
                                    MatchingInspectionTargetNts.Add( LatestInspectionTargetNt );
                                }
                            }
                        }
                    }
                    if( MatchingInspectionTargetNts.Count > 0 )
                    {
                        TargetType.SelectedNodeTypeIds.Clear();
                        CswNbtMetaDataObjectClass InspectionDesignOc = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.InspectionDesignClass );
                        foreach( CswNbtMetaDataNodeType InspectionDesignNt in InspectionDesignOc.getNodeTypes() )
                        {
                            if( InspectionDesignNt.IsLatestVersion() )
                            {
                                CswNbtMetaDataNodeTypeProp DesignTargetNtp = InspectionDesignNt.getNodeTypePropByObjectClassProp( CswNbtObjClassInspectionDesign.PropertyName.Target );
                                foreach( CswNbtMetaDataNodeType MatchingInspectionTargetNt in MatchingInspectionTargetNts )
                                {
                                    if( _fkIsValid( DesignTargetNtp ) && MatchingInspectionTargetNt.NodeTypeId == DesignTargetNtp.FKValue )
                                    {
                                        TargetType.SelectedNodeTypeIds.Add( InspectionDesignNt.NodeTypeId.ToString(), false, true );
                                        if( TargetType.SelectMode == CswEnumNbtPropertySelectMode.Single )
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }