Esempio n. 1
0
        public override void update()
        {

            CswNbtMetaDataObjectClass RequestItemOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.RequestItemClass );
            CswNbtMetaDataObjectClassProp ItemNoOCP = RequestItemOC.getObjectClassProp( CswNbtObjClassRequestItem.PropertyName.ItemNumber );

            //First verify there is no sequence for any ItemNo NTPs
            Collection<CswNbtMetaDataNodeTypeProp> PropsWithNoSequences = new Collection<CswNbtMetaDataNodeTypeProp>();
            foreach( CswNbtMetaDataNodeTypeProp ItemNoNTP in ItemNoOCP.getNodeTypeProps() )
            {
                if( null == ItemNoNTP.Sequence )
                {
                    PropsWithNoSequences.Add( ItemNoNTP );
                }
            }

            if( PropsWithNoSequences.Any() )
            {
                CswNbtMetaDataObjectClass DesignSequenceOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.DesignSequenceClass );
                CswNbtMetaDataNodeType DesignSequenceNT = DesignSequenceOC.getNodeTypes().FirstOrDefault();
                if( null == DesignSequenceNT )
                {
                    throw new CswDniException( CswEnumErrorType.Error, "Error creating new Sequence for Item Number property", "Cannot create a new sequence because there is no DesignSequence NodeType" );
                }

                CswNbtObjClassDesignSequence ItemNoSequence = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( DesignSequenceNT.NodeTypeId, OnAfterMakeNode : delegate( CswNbtNode NewNode )
                    {
                        CswNbtObjClassDesignSequence AsSequence = NewNode;
                        AsSequence.Name.Text = "RequestItem_ItemNumber";
                        AsSequence.Pre.Text = "RI";
                        AsSequence.Pad.Value = 6;
                    } );

                foreach( CswNbtMetaDataNodeTypeProp SequenceslessProp in PropsWithNoSequences )
                {
                    //Update the NTP to have a sequence
                    CswNbtObjClassDesignNodeTypeProp DesignNodeProp = SequenceslessProp.DesignNode;
                    CswNbtMetaDataNodeTypeProp SequenceNTP = DesignNodeProp.NodeType.getNodeTypeProp( "Sequence" );
                    if( null == SequenceNTP )
                    {
                        throw new CswDniException(CswEnumErrorType.Error, "Error assigning sequence to Item Number property", "Cannot assign a sequence to the Item Number property because there is no Sequence relationship property to assign a value to");
                    }
                    DesignNodeProp.Node.Properties[SequenceNTP].AsRelationship.RelatedNodeId = ItemNoSequence.NodeId;
                    DesignNodeProp.postChanges( false );

                    //Update existing Request Items Item No prop to have a value
                    _updateRequestItems(SequenceslessProp.getNodeType(), SequenceslessProp);
                }
            }

        } // update()
Esempio n. 2
0
        public override void update()
        {
            CswNbtMetaDataObjectClass MailReportOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.MailReportClass );
            CswNbtMetaDataObjectClassProp NameOCP = MailReportOC.getObjectClassProp( CswNbtObjClassMailReport.PropertyName.Name );

            //Make sure all Mail reports have unique names
            foreach( CswNbtObjClassMailReport MailReport in MailReportOC.getNodes( false, true, false, true ) )
            {
                _makeNameUnique( MailReportOC, NameOCP, MailReport, MailReport.Name.Text, 0 );
            }

            //Make the Name property unique
            foreach( CswNbtMetaDataNodeTypeProp NameNTP in NameOCP.getNodeTypeProps() )
            {
                CswNbtObjClassDesignNodeTypeProp NamePropertyNode = NameNTP.DesignNode;
                NamePropertyNode.Unique.Checked = CswEnumTristate.True;
                NamePropertyNode.postChanges( false );
            }

        } // update()
Esempio n. 3
0
        /// <summary>
        /// Create properties based from the object class
        /// </summary>
        private void _setPropertyValuesFromObjectClass()
        {
            Dictionary <Int32, CswNbtObjClassDesignNodeTypeProp> NewNTPropsByOCPId = new Dictionary <Int32, CswNbtObjClassDesignNodeTypeProp>();

            //int DisplayRow = 1;

            // Create/convert object class props
            foreach (CswNbtMetaDataObjectClassProp OCProp in ObjectClassPropertyValue.getObjectClassProps())
            {
                CswNbtObjClassDesignNodeTypeProp PropNode = null;
                if (null != RelationalNodeType)
                {
                    PropNode = (from Prop in RelationalNodeType.getNodeTypeProps()
                                where (Prop.PropName == OCProp.PropName || Prop.getObjectClassPropName() == OCProp.PropName) && Prop.FieldTypeId == OCProp.FieldTypeId
                                select Prop.DesignNode
                                ).FirstOrDefault();
                }
                // If converting, need to detect existing properties
                if (null != PropNode)
                {
                    PropNode.ObjectClassPropName.Value = OCProp.PropId.ToString();
                    NewNTPropsByOCPId.Add(OCProp.PropId, PropNode);
                }
                else
                {
                    string NewPropName = OCProp.PropName;
                    while (null != RelationalNodeType &&
                           null != RelationalNodeType.getNodeTypeProp(NewPropName))
                    {
                        NewPropName = NewPropName + " (new)";
                    }

                    CswNbtMetaDataNodeType DesignNodeTypePropNT = _CswNbtResources.MetaData.getNodeType(CswNbtObjClassDesignNodeTypeProp.getNodeTypeName(OCProp.getFieldTypeValue()));
                    PropNode = _CswNbtResources.Nodes.makeNodeFromNodeTypeId(DesignNodeTypePropNT.NodeTypeId, delegate(CswNbtNode NewNode)
                    {
                        ((CswNbtObjClassDesignNodeTypeProp)NewNode).NodeTypeValue.RelatedNodeId = this.NodeId;
                        ((CswNbtObjClassDesignNodeTypeProp)NewNode).ObjectClassPropName.Value   = OCProp.PropId.ToString();
                        ((CswNbtObjClassDesignNodeTypeProp)NewNode).FieldType.Value             = OCProp.FieldTypeId.ToString();
                        ((CswNbtObjClassDesignNodeTypeProp)NewNode).PropName.Text = NewPropName;
                    });

                    NewNTPropsByOCPId.Add(OCProp.ObjectClassPropId, PropNode);
                } // if-else( null != PropNode )

                //only update the layout when we're not overriding an existing nodetype
                PropNode.syncFromObjectClassProp(false == _overrideNodeConversionCheck);
            } // foreach( CswNbtMetaDataObjectClassProp OCProp in ObjectClassPropertyValue.getObjectClassProps() )

            // Now that we're done with all object class props, we can handle filters
            foreach (CswNbtMetaDataObjectClassProp OCProp in ObjectClassPropertyValue.getObjectClassProps())
            {
                if (OCProp.hasFilter())
                {
                    CswNbtObjClassDesignNodeTypeProp NTProp = NewNTPropsByOCPId[OCProp.ObjectClassPropId];
                    if (null != NTProp)
                    {
                        CswNbtObjClassDesignNodeTypeProp TargetOfFilter = NewNTPropsByOCPId[OCProp.FilterObjectClassPropId];
                        if (TargetOfFilter != null)
                        {
                            CswNbtSubField       SubField   = null;
                            CswEnumNbtFilterMode FilterMode = CswEnumNbtFilterMode.Unknown;
                            string FilterValue = string.Empty;
                            OCProp.getFilter(ref SubField, ref FilterMode, ref FilterValue);

                            // We don't have to worry about versioning in this function
                            NTProp.DisplayConditionProperty.RelatedNodeId = TargetOfFilter.NodeId;
                            NTProp.DisplayConditionSubfield.Value         = SubField.Name.ToString();
                            NTProp.DisplayConditionFilterMode.Value       = FilterMode.ToString();
                            NTProp.DisplayConditionValue.Text             = FilterValue;
                            NTProp.postChanges(false);
                        } // if( TargetOfFilter != null )
                    }     // if( null != NTProp )
                }         // if( OCProp.hasFilter() )
            }             // foreach( CswNbtMetaDataObjectClassProp OCProp in ObjectClassProps )


            // Handle search defer inheritance from object classes
            if (Int32.MinValue != ObjectClassPropertyValue.SearchDeferPropId)
            {
                //if( CswNbtMetaDataObjectClass.NotSearchableValue != ObjectClassPropertyValue.SearchDeferPropId )
                //{
                CswNbtObjClassDesignNodeTypeProp SearchDeferProp = NewNTPropsByOCPId[ObjectClassPropertyValue.SearchDeferPropId];
                this.DeferSearchTo.RelatedNodeId = SearchDeferProp.NodeId;
                //}
                //else
                //{
                //    this.DeferSearchTo.RelatedNodeId = null;
                //}
            }
        } // _setPropertyValuesFromObjectClass()