Beispiel #1
0
 private void _init(CswNbtMetaDataNodeType NbtNodeType, CswNbtMetaDataFieldType NbtFieldType, string NbtPropName)
 {
     if (null == NbtNodeType)
     {
         throw new CswDniException(CswEnumErrorType.Error, "Cannot create a NodeTypeProp DataContract without a valid Node Type", "Attempted to instance CswNbtWcfMetaDataModel.NodeTypeProp with a null NodeType.");
     }
     if (null == NbtFieldType)
     {
         throw new CswDniException(CswEnumErrorType.Error, "Cannot create a NodeTypeProp DataContract without a valid Field Type", "Attempted to instance CswNbtWcfMetaDataModel.NodeTypeProp with a null FieldType.");
     }
     if (string.IsNullOrEmpty(NbtPropName))
     {
         throw new CswDniException(CswEnumErrorType.Warning, "Property Name is required", "Attempted to create a new nodetype prop with a null propname");
     }
     NodeType     = NbtNodeType;
     NodeTypeId   = NodeType.NodeTypeId;
     FieldType    = NbtFieldType;
     PropName     = NbtPropName;
     UseNumbering = (NodeType.getObjectClass().ObjectClass == CswEnumNbtObjectClass.InspectionDesignClass &&
                     FieldType.FieldType == CswEnumNbtFieldType.Question);
     if (FieldType.FieldType == CswEnumNbtFieldType.NodeTypeSelect)
     {
         Multi = CswEnumTristate.False;
     }
     else
     {
         Multi = CswEnumTristate.Null;
     }
     ReadOnly = (FieldType.FieldType == CswEnumNbtFieldType.Barcode ||
                 FieldType.FieldType == CswEnumNbtFieldType.Sequence);
     IsUnique = (FieldType.FieldType == CswEnumNbtFieldType.Barcode ||
                 FieldType.FieldType == CswEnumNbtFieldType.Sequence);
 }
Beispiel #2
0
 public void AddToCache(CswNbtMetaDataNodeType NewObj)
 {
     _CollImpl.AddToCache(NewObj);
 }
Beispiel #3
0
 public CswNbtMetaDataNodeType getNodeTypeLatestVersion(CswNbtMetaDataNodeType NodeType)
 {
     return((CswNbtMetaDataNodeType)_CollImpl.getWhereFirst(@"where nodetypeid = (select max(nodetypeid) maxntid
                                                                                      from nodetypes 
                                                                                     where firstversionid = " + NodeType.FirstVersionNodeTypeId.ToString() + ")"));
 }
 public bool FkMatches(CswNbtMetaDataNodeType CompareNT)
 {
     return(CswNbtViewRelationship.Matches(_CswNbtMetaDataResources.CswNbtResources, FKType, FKValue, CompareNT));
 }
Beispiel #5
0
 public NodeTypeProp(CswNbtMetaDataNodeType NbtNodeType, CswNbtMetaDataFieldType NbtFieldType, string NbtPropName)
 {
     _init(NbtNodeType, NbtFieldType, NbtPropName);
 }
        /// <summary>
        /// Detects whether a nodetype is missing an object class prop, and creates the missing ones
        /// Mostly for use in Schema Update scripts
        /// </summary>
        public void makeMissingNodeTypeProps()
        {
            // First refresh our collection to catch any new changes in the database
            refreshAll();

            // BZ 7968
            // We need to prevent versioning.  Furthermore, even though we theoretically prevent any changes to locked NodeTypes,
            // we have to apply these changes to prior versions for compatibility.


            //foreach( CswNbtMetaDataNodeType NodeType in this.NodeTypesByObjectClass )
            //{
            //    foreach( CswNbtMetaDataObjectClassProp ObjectClassProp in NodeType.ObjectClass.ObjectClassProps )
            //    {
            //        // Find exact matches
            //        string PropName = ObjectClassProp.PropName;
            //        bool DoSync = false;
            //        CswNbtMetaDataNodeTypeProp MatchingNodeTypeProp = null;
            //        foreach( CswNbtMetaDataNodeTypeProp NodeTypeProp in NodeType.NodeTypeProps )
            //        {
            //            if( NodeTypeProp.ObjectClassProp != null && NodeTypeProp.ObjectClassProp.PropId == ObjectClassProp.PropId )
            //            {
            //                MatchingNodeTypeProp = NodeTypeProp;
            //                break;
            //            }
            //        }
            //        // Find name & fieldtype matches
            //        if( MatchingNodeTypeProp == null )
            //        {
            //            foreach( CswNbtMetaDataNodeTypeProp NodeTypeProp in NodeType.NodeTypeProps )
            //            {
            //                if( false == DoSync &&
            //                    NodeTypeProp.PropName.ToLower() == PropName.ToLower() &&
            //                    NodeTypeProp.FieldType.FieldType == ObjectClassProp.FieldType.FieldType )
            //                {
            //                    MatchingNodeTypeProp = NodeTypeProp;
            //                    DoSync = true;
            //                }
            //                else if( NodeTypeProp.PropName.ToLower() == PropName.ToLower() )
            //                {
            //                    PropName += " " + NodeTypeProp.FieldType.FieldType.ToString();
            //                }
            //            }
            //            while( null != NodeType.getNodeTypeProp( PropName ) )
            //            {
            //                PropName += " " + ObjectClassProp.ObjectClassPropId;
            //            }

            //        }
            //        // Make missing ones
            //        if( MatchingNodeTypeProp == null )
            //        {
            //            //CswNbtMetaDataNodeTypeTab Tab = NodeType.getFirstNodeTypeTab();
            //            makeNewProp( NodeType, null, ObjectClassProp.FieldType.FieldTypeId, PropName, Int32.MinValue, true, ObjectClassProp );
            //            DoSync = false;
            //        }

            //        if( DoSync )
            //        {
            //            CopyNodeTypePropFromObjectClassProp( ObjectClassProp, MatchingNodeTypeProp._DataRow );
            //            CopyNodeTypePropDefaultValueFromObjectClassProp( ObjectClassProp, MatchingNodeTypeProp );
            //        }

            //    } // foreach( CswNbtMetaDataObjectClassProp ObjectClassProp in NodeType.ObjectClass.ObjectClassProps )
            //} // foreach( CswNbtMetaDataNodeType NodeType in this.NodeTypes )


            foreach (Int32 ObjectClassId in this.getObjectClassIds().Keys)
            {
                foreach (CswNbtMetaDataObjectClassProp ObjectClassProp in _CswNbtMetaDataResources.CswNbtMetaData.getObjectClassProps(ObjectClassId))
                {
                    foreach (Int32 NodeTypeId in this.getNodeTypeIds(ObjectClassId).Keys)
                    {
                        // Find exact matches first
                        CswNbtMetaDataNodeTypeProp MatchingNTP = getNodeTypePropByObjectClassProp(NodeTypeId, ObjectClassProp.ObjectClassPropId);

                        if (MatchingNTP == null)
                        {
                            //string PropName = ObjectClassProp.PropName;
                            bool DoSync = false;

                            // Find name & fieldtype matches
                            // Our objective is either to find a match, or to determine a unique propname
                            bool   KeepSearching = true;
                            string PropName      = ObjectClassProp.PropName;
                            while (KeepSearching)
                            {
                                MatchingNTP = getNodeTypeProp(NodeTypeId, PropName);
                                if (MatchingNTP == null)
                                {
                                    KeepSearching = false;
                                }
                                else if (MatchingNTP.FieldTypeId == ObjectClassProp.FieldTypeId)
                                {
                                    DoSync        = true;
                                    KeepSearching = false;
                                }
                                else
                                {
                                    PropName += " " + ObjectClassProp.getFieldTypeValue().ToString();
                                    PropName += " " + ObjectClassProp.ObjectClassPropId;
                                }
                            } // while( KeepSearching )

                            // Make missing ones
                            if (MatchingNTP == null)
                            {
                                //CswNbtMetaDataNodeTypeTab Tab = NodeType.getFirstNodeTypeTab();
                                CswNbtMetaDataNodeType NodeType = getNodeType(NodeTypeId);
                                //makeNewPropDeprecated( NodeType, null, ObjectClassProp.FieldTypeId, PropName, Int32.MinValue, true, ObjectClassProp );
                                makeNewProp(new CswNbtWcfMetaDataModel.NodeTypeProp(NodeType, ObjectClassProp.getFieldType(), PropName)
                                {
                                    ObjectClassPropToCopy = ObjectClassProp,
                                    PreventVersioning     = true
                                });
                                DoSync = false;
                            }

                            if (DoSync)
                            {
                                CopyNodeTypePropFromObjectClassProp(ObjectClassProp, MatchingNTP);
                                CopyNodeTypePropDefaultValueFromObjectClassProp(ObjectClassProp, MatchingNTP);
                            }
                        } // if( MatchingNodeTypeProp == null )
                    }     // foreach( CswNbtMetaDataNodeType NodeType in this.getNodeTypesByObjectClass( ObjectClassId ) )
                }         // foreach( CswNbtMetaDataObjectClassProp ObjectClassProp in getObjectClassProps(ObjectClassId) )
            }             // foreach( Int32 ObjectClassId in this.getObjectClassIds() )



            // Now reset the "real" meta data collection in CswNbtResources for these changes
            CswNbtResources.MetaData.refreshAll();
        } // makeMissingNodeTypeProps()
        } // getPropNodesInLayout()

        public IEnumerable <CswNbtObjClassDesignNodeTypeProp> getPropNodesNotInLayout(CswNbtMetaDataNodeType NodeType, Int32 TabId, CswEnumNbtLayoutType LayoutType, CswDateTime Date = null)
        {
            Collection <CswNbtObjClassDesignNodeTypeProp> ret = new Collection <CswNbtObjClassDesignNodeTypeProp>();
            CswTableSelect PropsSelect = _CswNbtMetaDataResources.CswNbtResources.makeCswTableSelect("getPropNodesNotInLayout_select", "nodetype_props");
            string         WhereClause = "where nodetypepropid not in (select nodetypepropid " +
                                         "                               from nodetype_layout " +
                                         "                              where nodetypeid = " + NodeType.NodeTypeId.ToString() +
                                         "                                and nodetypetabsetid = " + TabId.ToString() +
                                         "                                and layouttype = '" + LayoutType.ToString() + "')";
            DataTable LayoutTable = PropsSelect.getTable(WhereClause);

            foreach (DataRow Row in LayoutTable.Rows)
            {
                Int32 PropId = CswConvert.ToInt32(Row["nodetypepropid"]);
                CswNbtObjClassDesignNodeTypeProp PropNode = _CswNbtMetaDataResources.CswNbtResources.Nodes.getNodeByRelationalId(new CswPrimaryKey("nodetype_props", PropId));
                ret.Add(PropNode);
            }
            return(ret);
        } // getPropNodesNotInLayout()
        } // getPropsInLayout()

        public IEnumerable <CswNbtMetaDataNodeTypeProp> getPropsNotInLayout(CswNbtMetaDataNodeType NodeType, Int32 TabId, CswEnumNbtLayoutType LayoutType, CswDateTime Date = null)
        {
            return(_CswNbtMetaDataResources.NodeTypePropsCollection.getLayoutProps(NodeType.NodeTypeId, TabId, LayoutType, Date, false));
        } // getPropsNotInLayout()