Ejemplo n.º 1
0
        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
Ejemplo n.º 2
0
        } //NodeTypeId

        public CswEnumNbtFieldType getFieldTypeValue()
        {
            CswEnumNbtFieldType ret = CswNbtResources.UnknownEnum;

            if (null != _NodeTypeProp)
            {
                ret = _NodeTypeProp.getFieldTypeValue();
            }
            else if (Int32.MinValue != _ObjectClassPropId)
            {
                CswNbtMetaDataObjectClassProp ocp = _CswNbtResources.MetaData.getObjectClassProp(_ObjectClassPropId);
                if (null != ocp)
                {
                    ret = ocp.getFieldTypeValue();
                }
            }
            return(ret);
        } // getFieldTypeValue()
Ejemplo n.º 3
0
        } // getObjectClasses()

        /// <summary>
        /// Get a list of all NodeTypes, optionally limited according to supplied parameters
        /// </summary>
        /// <param name="ObjectClass">(Optional) An Object Class to constrain results.</param>
        /// <param name="ExcludeNodeTypeIds">(Optional) A comma-delimited string of NodeTypeIds to exclude from the return.</param>
        /// <param name="RelationshipTargetNodeTypeId">(Optional [Requires RelationshipObjectClassPropName])
        /// <para>A related NodeTypeId to further constrain the results to nodetypes whose relationship targets the supplied RelationshipTargetNodeTypeId</para>
        /// <para>Use case: get all nodetypes of Size object class whose Material relationships target Chemicals.</para>
        /// </param>
        /// <param name="RelationshipObjectClassPropName">(Optional [Requires RelationshipObjectClassPropName])
        /// <para>The name of the Object Class Prop which defines the relationship to RelationshipTargetNodeTypeId</para>
        /// <param name="FilterToPermission">Restrict nodeTypes to those to which the user has this permission (default is 'View')</param>
        /// <param name="FilterToViewId">(Optional) Limit to nodetypes within this view</param>
        /// <param name="Searchable">If true, only include searchable nodetypes</param>
        /// <returns></returns>
        public JObject getNodeTypes(CswNbtMetaDataPropertySet PropertySet  = null,
                                    CswNbtMetaDataObjectClass ObjectClass  = null,
                                    string ExcludeNodeTypeIds              = "",
                                    Int32 RelationshipTargetNodeTypeId     = Int32.MinValue,
                                    string RelationshipObjectClassPropName = "",
                                    Int32 RelationshipNodeTypePropId       = Int32.MinValue,
                                    string FilterToPermission              = null,
                                    CswNbtView FilterToView = null,
                                    bool Searchable         = false)
        {
            JObject ReturnVal = new JObject();

            if (string.IsNullOrEmpty(FilterToPermission))
            {
                // We default the Permission type to 'View'
                FilterToPermission = CswEnumNbtNodeTypePermission.View;
            }

            CswCommaDelimitedString ExcludedNodeTypes = new CswCommaDelimitedString();
            Collection <Int32>      ExcludedIds       = new Collection <Int32>();

            if (false == string.IsNullOrEmpty(ExcludeNodeTypeIds))
            {
                ExcludedNodeTypes.FromString(ExcludeNodeTypeIds);
                ExcludedIds = ExcludedNodeTypes.ToIntCollection();
            }

            IEnumerable <CswNbtMetaDataNodeType> NodeTypes;

            if (Int32.MinValue != RelationshipNodeTypePropId)
            {
                CswNbtMetaDataNodeTypeProp RelationshipProp = _CswNbtResources.MetaData.getNodeTypeProp(RelationshipNodeTypePropId);
                NodeTypes = _CswNbtResources.MetaData.getNodeTypes().Where(nt => RelationshipProp.FkMatches(nt));
            }
            else if (null != FilterToView)
            {
                NodeTypes = new Collection <CswNbtMetaDataNodeType>();
                Collection <CswNbtViewRelationship> relationships = FilterToView.getAllNbtViewRelationships();
                foreach (CswNbtViewRelationship rel in relationships)
                {
                    if (rel.SecondType == CswEnumNbtViewRelatedIdType.NodeTypeId)
                    {
                        ((Collection <CswNbtMetaDataNodeType>)NodeTypes).Add(_CswNbtResources.MetaData.getNodeType(rel.SecondId));
                    }
                    else if (rel.SecondType == CswEnumNbtViewRelatedIdType.ObjectClassId)
                    {
                        NodeTypes = NodeTypes.Union(_CswNbtResources.MetaData.getObjectClass(rel.SecondId).getNodeTypes());
                    }
                    else if (rel.SecondType == CswEnumNbtViewRelatedIdType.PropertySetId)
                    {
                        NodeTypes = NodeTypes.Union(_CswNbtResources.MetaData.getPropertySet(rel.SecondId).getNodeTypes());
                    }
                }
            }
            else if (null != PropertySet)
            {
                List <CswNbtMetaDataNodeType> NTs = new List <CswNbtMetaDataNodeType>();
                foreach (CswNbtMetaDataObjectClass OC in PropertySet.getObjectClasses())
                {
                    NTs.AddRange(OC.getLatestVersionNodeTypes());
                }
                NodeTypes = NTs;
            }
            else if (null == ObjectClass)
            {
                NodeTypes = _CswNbtResources.MetaData.getNodeTypesLatestVersion();
            }
            else
            {
                NodeTypes = ObjectClass.getLatestVersionNodeTypes();
                ReturnVal["objectClassId"] = ObjectClass.ObjectClassId;
            }

            Int32 NodeTypeCount = 0;

            foreach (CswNbtMetaDataNodeType RetNodeType in NodeTypes
                     .Where(_RetNodeType => (false == Searchable || _RetNodeType.IsSearchResult()))
                     .OrderBy(_RetNodeType => _RetNodeType.NodeTypeName))
            {
                bool AddThisNodeType = false;
                if (false == ExcludedIds.Contains(RetNodeType.NodeTypeId))
                {
                    AddThisNodeType = true;
                    if (Int32.MinValue != RelationshipTargetNodeTypeId &&
                        false == string.IsNullOrEmpty(RelationshipObjectClassPropName))
                    {
                        CswNbtMetaDataNodeTypeProp RelationshipNtp = RetNodeType.getNodeTypePropByObjectClassProp(RelationshipObjectClassPropName);
                        if (null != RelationshipNtp &&
                            RelationshipNtp.getFieldTypeValue() == CswEnumNbtFieldType.Relationship)
                        {
                            CswNbtMetaDataNodeType RelatedNodeType = _CswNbtResources.MetaData.getNodeType(RelationshipTargetNodeTypeId);
                            if (null == RelatedNodeType ||
                                false == RelationshipNtp.FkMatches(RelatedNodeType, true))
                            {
                                AddThisNodeType = false;
                            }
                        }
                    }
                    if (false == _userHasPermission(FilterToPermission, RetNodeType))
                    {
                        AddThisNodeType = false;
                    }
                }

                if (AddThisNodeType)
                {
                    _addNodeTypeAttributes(RetNodeType, ReturnVal);
                    NodeTypeCount += 1;
                }
            }

            ReturnVal["count"] = NodeTypeCount;
            return(ReturnVal);
        } // getNodeTypes()
Ejemplo n.º 4
0
 /// <summary>
 /// Reference to FieldType Meta Data object for this property
 /// </summary>
 public CswEnumNbtFieldType getFieldTypeValue()
 {
     return(_CswNbtMetaDataNodeTypeProp.getFieldTypeValue());
 }
Ejemplo n.º 5
0
        private void setupGridColumns(DataSet DS, CswNbtView View)
        {
            _Grid.Columns.Clear();

            // Edit column
            GridBoundColumn EditColumn = new GridBoundColumn();

            EditColumn.UniqueName = "EditColumn";
            EditColumn.HeaderText = "Edit";
            EditColumn.DataField  = "Edit";
            EditColumn.Display    = ShowActionColumns;
            _Grid.Columns.Add(EditColumn);

            // Node column
            GridBoundColumn NodeNameColumn = new GridBoundColumn();

            NodeNameColumn.UniqueName = "NodeName";
            NodeNameColumn.HeaderText = "Node Name";
            NodeNameColumn.DataField  = "NodeName";
            // BZ 6704
            NodeNameColumn.Visible = false;
            NodeNameColumn.Display = false;
            _Grid.Columns.Add(NodeNameColumn);

            // NodeKey column
            GridBoundColumn NodeKeyColumn = new GridBoundColumn();

            NodeKeyColumn.UniqueName = "NodeKey";
            NodeKeyColumn.HeaderText = "NodeKey";
            NodeKeyColumn.DataField  = "NodeKey";
            NodeKeyColumn.Display    = false;
            _Grid.Columns.Add(NodeKeyColumn);

            foreach (DataTable Table in DS.Tables)
            {
                foreach (DataColumn Column in Table.Columns)
                {
                    string ColumnName = Column.ColumnName;
                    if (ColumnName.Length > PropColumnPrefix.Length && ColumnName.Substring(0, PropColumnPrefix.Length) == PropColumnPrefix)
                    {
                        string NoPrefixColumnName = ColumnName.Substring(PropColumnPrefix.Length);
                        //Int32 CurrentNodeTypePropId = CswConvert.ToInt32( NoPrefixColumnName.Substring( 0, NoPrefixColumnName.IndexOf( '_' ) ) );
                        string RealColumnName = CswTools.XmlRealAttributeName(NoPrefixColumnName);   //.Substring( NoPrefixColumnName.IndexOf( '_' ) + 1 ) );
                        //CswNbtMetaDataNodeTypeProp CurrentNodeTypeProp = _CswNbtResources.MetaData.getNodeTypeProp( CurrentNodeTypePropId );
                        //CswNbtViewProperty CurrentViewProp = View.FindPropertyById( CswNbtPropType.NodeTypePropId, CurrentNodeTypePropId );
                        CswNbtViewProperty CurrentViewProp = View.findPropertyByName(RealColumnName);
                        //if( CurrentViewProp == null )
                        //    CurrentViewProp = View.FindPropertyByName( CurrentNodeTypeProp.PropName );
                        CswEnumNbtFieldType ColFieldType = CswNbtResources.UnknownEnum;
                        if (CurrentViewProp != null)
                        {
                            if (((CswNbtViewRelationship)CurrentViewProp.Parent).SecondType == CswEnumNbtViewRelatedIdType.NodeTypeId)
                            {
                                CswNbtMetaDataNodeType     CurrentNT  = _CswNbtResources.MetaData.getNodeType(((CswNbtViewRelationship)CurrentViewProp.Parent).SecondId);
                                CswNbtMetaDataNodeTypeProp CurrentNTP = CurrentNT.getNodeTypeProp(RealColumnName);
                                if (CurrentNTP != null)
                                {
                                    ColFieldType = CurrentNTP.getFieldTypeValue();
                                }
                            }
                            else if (((CswNbtViewRelationship)CurrentViewProp.Parent).SecondType == CswEnumNbtViewRelatedIdType.ObjectClassId)
                            {
                                CswNbtMetaDataObjectClass CurrentOC = _CswNbtResources.MetaData.getObjectClass(((CswNbtViewRelationship)CurrentViewProp.Parent).SecondId);
                                foreach (CswNbtMetaDataNodeType CurrentNT in CurrentOC.getNodeTypes())
                                {
                                    CswNbtMetaDataNodeTypeProp CurrentNTP = CurrentNT.getNodeTypeProp(RealColumnName);
                                    if (CurrentNTP != null)
                                    {
                                        ColFieldType = CurrentNTP.getFieldTypeValue();
                                    }
                                }
                            }
                        }

                        GridBoundColumn thisColumn = null;
                        //switch( CurrentNodeTypeProp.FieldType.FieldType )
                        switch (ColFieldType)
                        {
                        case CswEnumNbtFieldType.DateTime:
                            thisColumn = new GridDateTimeColumn();
                            thisColumn.DataFormatString = "{0:M/d/yyyy}";
                            thisColumn.DataType         = typeof(DateTime);
                            break;

                        //case CswEnumNbtFieldType.Time:
                        //    thisColumn = new GridDateTimeColumn();
                        //    thisColumn.DataFormatString = "{0:H:mm:ss}";
                        //    thisColumn.DataType = typeof( DateTime );
                        //    break;
                        default:
                            thisColumn = new GridBoundColumn();
                            break;
                        }
                        thisColumn.UniqueName = ColumnName;
                        thisColumn.HeaderText = RealColumnName;
                        thisColumn.DataField  = ColumnName;
                        if (CurrentViewProp != null && CurrentViewProp.Width != Int32.MinValue)
                        {
                            thisColumn.HeaderStyle.Width = Unit.Parse((CswConvert.ToInt32(CurrentViewProp.Width * 7)).ToString() + "px");        // average pixel width per character
                        }
                        //thisColumn.OrderIndex = CurrentViewProp.Order;
                        //Telerik.Web.UI.GridTableView GTV = new GridTableView( _Grid );
                        if (CurrentViewProp != null && CurrentViewProp.Order > 0 && _Grid.Columns.Count >= CurrentViewProp.Order)
                        {
                            _Grid.Columns.AddAt(CurrentViewProp.Order, thisColumn);
                        }
                        else
                        {
                            _Grid.Columns.Add(thisColumn);
                        }
                    }
                }
            }

            // Delete column
            GridBoundColumn DeleteColumn = new GridBoundColumn();

            DeleteColumn.UniqueName = "DeleteColumn";
            DeleteColumn.HeaderText = "Delete";
            DeleteColumn.DataField  = "Delete";
            DeleteColumn.Display    = ShowActionColumns;
            _Grid.Columns.Add(DeleteColumn);
        } // setupGridColumns()
Ejemplo n.º 6
0
        private static CswNbtNodePropWrapper _makeNodeProp(CswNbtResources CswNbtResources, CswNbtNodePropData CswNbtNodePropData, CswNbtMetaDataNodeTypeProp CswNbtMetaDataNodeTypeProp, CswNbtNode Node)
        {
            CswNbtNodePropWrapper ReturnVal = null;

            CswNbtNodeProp      InnerProperty = null;
            CswEnumNbtFieldType FieldType     = CswNbtMetaDataNodeTypeProp.getFieldTypeValue();

            switch (FieldType)
            {
            case CswEnumNbtFieldType.Barcode:
                InnerProperty = new CswNbtNodePropBarcode(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Button:
                InnerProperty = new CswNbtNodePropButton(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.CASNo:
                InnerProperty = new CswNbtNodePropCASNo(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.ChildContents:
                InnerProperty = new CswNbtNodePropChildContents(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Comments:
                InnerProperty = new CswNbtNodePropComments(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Composite:
                InnerProperty = new CswNbtNodePropComposite(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.DateTime:
                InnerProperty = new CswNbtNodePropDateTime(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.File:
                InnerProperty = new CswNbtNodePropBlob(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Formula:
                InnerProperty = new CswNbtNodePropFormula(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Grid:
                InnerProperty = new CswNbtNodePropGrid(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Image:
                InnerProperty = new CswNbtNodePropImage(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.ImageList:
                InnerProperty = new CswNbtNodePropImageList(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Link:
                InnerProperty = new CswNbtNodePropLink(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.List:
                InnerProperty = new CswNbtNodePropList(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Location:
                InnerProperty = new CswNbtNodePropLocation(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Logical:
                InnerProperty = new CswNbtNodePropLogical(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.LogicalSet:
                InnerProperty = new CswNbtNodePropLogicalSet(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.MetaDataList:
                InnerProperty = new CswNbtNodePropMetaDataList(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Memo:
                InnerProperty = new CswNbtNodePropMemo(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.MOL:
                InnerProperty = new CswNbtNodePropMol(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.MTBF:
                InnerProperty = new CswNbtNodePropMTBF(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            //case CswEnumNbtFieldType.MultiRelationship:
            //    InnerProperty = new CswNbtNodePropMultiRelationship( CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node );
            //    break;
            case CswEnumNbtFieldType.MultiList:
                //! As part of CIS-53434, remove this if statement.
                if (CswNbtMetaDataNodeTypeProp.PropName == CswNbtObjClassRole.PropertyName.NodeTypePermissions)
                {
                    InnerProperty = new CswNbtNodePropPermission(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                }
                else
                {
                    InnerProperty = new CswNbtNodePropMultiList(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                }
                break;

            case CswEnumNbtFieldType.NFPA:
                InnerProperty = new CswNbtNodePropNFPA(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.NodeTypeSelect:
                InnerProperty = new CswNbtNodePropNodeTypeSelect(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Number:
                InnerProperty = new CswNbtNodePropNumber(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.NumericRange:
                InnerProperty = new CswNbtNodePropNumericRange(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Password:
                InnerProperty = new CswNbtNodePropPassword(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Permission:
                InnerProperty = new CswNbtNodePropPermission(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.PropertyReference:
                InnerProperty = new CswNbtNodePropPropertyReference(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Quantity:
                InnerProperty = new CswNbtNodePropQuantity(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Question:
                InnerProperty = new CswNbtNodePropQuestion(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Relationship:
                InnerProperty = new CswNbtNodePropRelationship(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.ReportLink:
                InnerProperty = new CswNbtNodePropReportLink(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Scientific:
                InnerProperty = new CswNbtNodePropScientific(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Sequence:
                InnerProperty = new CswNbtNodePropSequence(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Static:
                InnerProperty = new CswNbtNodePropStatic(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.Text:
                InnerProperty = new CswNbtNodePropText(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.TimeInterval:
                InnerProperty = new CswNbtNodePropTimeInterval(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.UserSelect:
                InnerProperty = new CswNbtNodePropUserSelect(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.ViewPickList:
                InnerProperty = new CswNbtNodePropViewPickList(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            case CswEnumNbtFieldType.ViewReference:
                InnerProperty = new CswNbtNodePropViewReference(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node);
                break;

            default:
                throw new CswDniException(CswEnumErrorType.Error, "Internal System Error", "There is no CswNbtNodeProp Object for Field Type: " + FieldType.ToString());
            }

            ReturnVal = new CswNbtNodePropWrapper(CswNbtResources, Node, InnerProperty, CswNbtNodePropData);

            return(ReturnVal);
        } //makeNodeProp()
Ejemplo n.º 7
0
        }//ctor

        public void update(Int32 NodeTypeId, CswPrimaryKey RelationalId, DataTable PropsTable)
        {
            if (CswTools.IsPrimaryKey(RelationalId))
            {
                CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(NodeTypeId);
                string TableName = NodeType.TableName;
                if (TableName != "nodes")
                {
                    string         PkColumnName   = _CswNbtResources.getPrimeKeyColName(TableName);
                    CswTableUpdate CswTableUpdate = null;
                    DataTable      DataTable      = null;
                    DataRow        DataRow        = null;

                    // horrible special case for Design
                    // We need to use CswNbtMetaDataResources objects, or else we have dirty-write problems
                    if (NodeType.TableName.StartsWith("nodetype"))
                    {
                        switch (NodeType.TableName)
                        {
                        case "nodetypes":
                            CswTableUpdate = _CswNbtResources.MetaData._CswNbtMetaDataResources.NodeTypeTableUpdate;
                            CswNbtMetaDataNodeType relatedNT = _CswNbtResources.MetaData.getNodeType(RelationalId.PrimaryKey, null, true);
                            DataTable = relatedNT._DataRow.Table;
                            DataRow   = relatedNT._DataRow;
                            break;

                        case "nodetype_tabset":
                            CswTableUpdate = _CswNbtResources.MetaData._CswNbtMetaDataResources.NodeTypeTabTableUpdate;
                            CswNbtMetaDataNodeTypeTab relatedNTT = _CswNbtResources.MetaData.getNodeTypeTab(RelationalId.PrimaryKey, true);
                            DataTable = relatedNTT._DataRow.Table;
                            DataRow   = relatedNTT._DataRow;
                            break;

                        case "nodetype_props":
                            CswTableUpdate = _CswNbtResources.MetaData._CswNbtMetaDataResources.NodeTypePropTableUpdate;
                            CswNbtMetaDataNodeTypeProp relatedNTP = _CswNbtResources.MetaData.getNodeTypeProp(RelationalId.PrimaryKey, null, true);
                            DataTable = relatedNTP._DataRow.Table;
                            DataRow   = relatedNTP._DataRow;
                            break;
                        }
                    } // if( NodeType.TableName.StartsWith( "nodetype" ) )

                    if (null == DataTable || null == CswTableUpdate)
                    {
                        CswTableUpdate = _CswNbtResources.makeCswTableUpdate("CswNbtNodePropCollDataRelational_update", TableName);
                        DataTable      = CswTableUpdate.getTable(null, PkColumnName, RelationalId.PrimaryKey, string.Empty, false);
                        DataRow        = DataTable.Rows[0];
                    }

                    if (null != DataRow)
                    {
                        CswTableSelect MappingSelect = _CswNbtResources.makeCswTableSelect("PropCollDataRelational_mapping", "jct_dd_ntp");
                        DataTable      MappingTable  = MappingSelect.getTable("where nodetypepropid in (select nodetypepropid from nodetype_props where nodetypeid =" + NodeTypeId.ToString() + ")");

                        foreach (DataRow CurrentRow in PropsTable.Rows)
                        {
                            CswNbtMetaDataNodeTypeProp thisNTP = NodeType.getNodeTypeProp(CswConvert.ToInt32(CurrentRow["nodetypepropid"]));
                            if (null != thisNTP)
                            {
                                foreach (CswNbtSubField CurrentSubField in thisNTP.getFieldTypeRule().SubFields)
                                {
                                    DataRow MappingRow = MappingTable.Rows.Cast <DataRow>()
                                                         .FirstOrDefault(r => CswConvert.ToInt32(r["nodetypepropid"]) == thisNTP.PropId &&
                                                                         r["subfieldname"].ToString() == CurrentSubField.Name.ToString());
                                    if (null != MappingRow)
                                    {
                                        _CswNbtResources.DataDictionary.setCurrentColumn(CswConvert.ToInt32(MappingRow["datadictionaryid"]));
                                        if (_CswNbtResources.DataDictionary.ColumnName != string.Empty)
                                        {
                                            if (CurrentRow[CurrentSubField.Column.ToString()].ToString() == string.Empty)
                                            {
                                                DataRow[_CswNbtResources.DataDictionary.ColumnName] = DBNull.Value;
                                            }
                                            else if (_CswNbtResources.DataDictionary.ColumnName == CswEnumNbtPropertyAttributeColumn.Defaultvalueid)
                                            {
                                                // Special case for Default Value: we need to sync the jctnodepropid row, not the value
                                                DataRow[_CswNbtResources.DataDictionary.ColumnName] = CurrentRow["jctnodepropid"];
                                            }
                                            else
                                            {
                                                object value = CurrentRow[CurrentSubField.Column.ToString()];

                                                // Special case for Multi: translate "Single" and "Multiple" to 0 and 1 resp.
                                                if (_CswNbtResources.DataDictionary.ColumnName == CswEnumNbtPropertyAttributeColumn.Multi)
                                                {
                                                    if (value.ToString() == CswEnumNbtPropertySelectMode.Single.ToString())
                                                    {
                                                        value = 1;
                                                    }
                                                    else
                                                    {
                                                        value = 0;
                                                    }
                                                }
                                                // Special case for booleans and tristates
                                                else if (thisNTP.getFieldTypeValue() == CswEnumNbtFieldType.Logical)
                                                {
                                                    value = CswConvert.TristateToDbVal(CswConvert.ToTristate(CurrentRow[CurrentSubField.Column.ToString()]));
                                                }
                                                // Special case for relationships and locations, if the related entity is also relational
                                                else if (CurrentSubField.Name == CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID &&
                                                         (thisNTP.getFieldTypeValue() == CswEnumNbtFieldType.Relationship ||
                                                          thisNTP.getFieldTypeValue() == CswEnumNbtFieldType.Location))
                                                {
                                                    CswNbtNode RelatedNode = _CswNbtResources.Nodes[new CswPrimaryKey("nodes", CswConvert.ToInt32(value))];
                                                    if (null != RelatedNode && RelatedNode.getNodeType().DoRelationalSync)
                                                    {
                                                        // Remap the foreign key reference to the relational primary key
                                                        value = RelatedNode.RelationalId.PrimaryKey;
                                                    }
                                                }

                                                DataRow[_CswNbtResources.DataDictionary.ColumnName] = value; //CurrentRow[CurrentSubField.Column.ToString()];
                                            }
                                        } // if( _CswNbtResources.DataDictionary.ColumnName != string.Empty )
                                    } // if( null != MappingRow )
                                }     // foreach( CswNbtSubField CurrentSubField in thisNTP.getFieldTypeRule().SubFields )
                            }         // if( null != thisNTP )
                        }             // foreach( DataRow CurrentRow in PropsTable.Rows )

                        CswTableUpdate.update(DataTable);
                    } // if( null != DataRow )
                }     // if( TableName != "nodes" )
            }         // if( CswTools.IsPrimaryKey( RelationalId ) )
        }             //update()