} // 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()