Exemple #1
0
        /// <summary>
        /// DO NOT USE THIS METHOD DIRECTLY IN YOUR CODE.
        /// </summary>
        public static NodeQueryResult QueryNodesByType(NodeType nodeType, bool exactType)
        {
            if (nodeType == null)
            {
                throw new ArgumentNullException("nodeType");
            }
            var typeIds           = exactType ? new[] { nodeType.Id } : nodeType.GetAllTypes().ToIdArray();
            IEnumerable <int> ids = DataProvider.Current.QueryNodesByType(typeIds);

            return(new NodeQueryResult(new NodeList <Node>(ids)));
        }
Exemple #2
0
        /// <summary>
        /// Returns with the nodes by the given <see cref="NodeType"/> and name.
        /// CQL equivalent: if exactType is true: '+Name:{name} +Type:{nodeTypeName}'
        /// otherwise: '+Name:{name} +TypeIs:{nodeTypeName}'.
        /// </summary>
        /// <param name="nodeType">The <see cref="NodeType"/> that specifies the allowed type of nodes in the result.</param>
        /// <param name="exactType">True if inherited-type nodes are not in the result.</param>
        /// <param name="name">The name of the node. If null, the name filter will be not applied.</param>
        /// <exception cref="ArgumentNullException">If the given nodeType is null.</exception>
        /// <returns>A <see cref="QueryResult"/> instance.</returns>
        public static QueryResult QueryNodesByTypeAndName(NodeType nodeType, bool exactType, string name)
        {
            if (nodeType == null)
            {
                throw new ArgumentNullException(nameof(nodeType));
            }
            var typeIds           = exactType ? new[] { nodeType.Id } : nodeType.GetAllTypes().ToIdArray();
            IEnumerable <int> ids = DataProvider.Current.QueryNodesByTypeAndPathAndName(typeIds, (string[])null, false, name);

            return(new QueryResult(new NodeList <Node>(ids)));
        }
Exemple #3
0
        /// <summary>
        /// Returns with the nodes by the given <see cref="NodeType"/>.
        /// CQL equivalent: if exactType is true: 'Type:{nodeTypeName}' otherwise: 'TypeIs:{nodeTypeName}'.
        /// </summary>
        /// <param name="nodeType">The <see cref="NodeType"/> that specifies the allowed type of nodes in the result.</param>
        /// <param name="exactType">True if inherited-type nodes are not in the result.</param>
        /// <exception cref="ArgumentNullException">If the given nodeType is null.</exception>
        /// <returns>A <see cref="QueryResult"/> instance.</returns>
        public static QueryResult QueryNodesByType(NodeType nodeType, bool exactType)
        {
            if (nodeType == null)
            {
                throw new ArgumentNullException(nameof(nodeType));
            }
            var typeIds           = exactType ? new[] { nodeType.Id } : nodeType.GetAllTypes().ToIdArray();
            IEnumerable <int> ids = DataStore.QueryNodesByTypeAsync(typeIds, CancellationToken.None).GetAwaiter().GetResult();

            return(new QueryResult(new NodeList <Node>(ids)));
        }
Exemple #4
0
        /// <summary>
        /// DO NOT USE THIS METHOD DIRECTLY IN YOUR CODE.
        /// </summary>
        public static NodeQueryResult QueryNodesByTypeAndPathAndName(NodeType nodeType, bool exactType, string pathStart, bool orderByPath, string name)
        {
            int[] typeIds = null;
            if (nodeType != null)
            {
                typeIds = exactType ? new[] { nodeType.Id }
            }
            : nodeType.GetAllTypes().ToIdArray();
            IEnumerable <int> ids = DataProvider.Current.QueryNodesByTypeAndPathAndName(typeIds, pathStart, orderByPath, name);

            return(new NodeQueryResult(new NodeList <Node>(ids)));
        }
Exemple #5
0
        /// <summary>
        /// DO NOT USE THIS METHOD DIRECTLY IN YOUR CODE.
        /// </summary>
        public static NodeQueryResult QueryNodesByTypeAndPathAndProperty(NodeType nodeType, bool exactType, string pathStart, bool orderByPath, List <QueryPropertyData> properties)
        {
            int[] typeIds = null;
            if (nodeType != null)
            {
                typeIds = exactType ? new[] { nodeType.Id }
            }
            : nodeType.GetAllTypes().ToIdArray();

            var ids = DataProvider.Current.QueryNodesByTypeAndPathAndProperty(typeIds, pathStart, orderByPath, properties);

            return(new NodeQueryResult(new NodeList <Node>(ids)));
        }
Exemple #6
0
        /// <summary>
        /// Return with nodes that are in the subtree of the node identified by the pathStart filtered by the given <see cref="NodeType"/> and name.
        /// Note that the pathStart will be suffixed with the trailing slash ('/') if it does not ends with it.
        /// Similar CQL without ordering: if exactType is true: '+InTree:{pathStart} +Type:{nodeTypeName} +Name:{name}'
        /// otherwise: '+InTree:{pathStart} +TypeIs:{nodeTypeName} +Name:{name}'.
        /// Note that the result of the CQL example contains the root but the result of method does not.
        /// </summary>
        /// <param name="nodeType">The <see cref="NodeType"/> that specifies the allowed type of nodes in the result.
        /// If null, the type filter is not applied.</param>
        /// <param name="exactType">True if inherited-type nodes are not in the result.</param>
        /// <param name="pathStart">The path of the root node.</param>
        /// <param name="orderByPath">Specifies that the result will be sorted or not.</param>
        /// <param name="name">The name of the node. If null, the name filter will be not applied.</param>
        /// <returns>A <see cref="QueryResult"/> instance.</returns>
        public static QueryResult QueryNodesByTypeAndPathAndName(NodeType nodeType, bool exactType, string pathStart, bool orderByPath, string name)
        {
            int[] typeIds = null;
            if (nodeType != null)
            {
                typeIds = exactType ? new[] { nodeType.Id }
            }
            : nodeType.GetAllTypes().ToIdArray();
            IEnumerable <int> ids = DataStore.QueryNodesByTypeAndPathAndNameAsync(typeIds, pathStart, orderByPath, name, CancellationToken.None)
                                    .GetAwaiter().GetResult();

            return(new QueryResult(new NodeList <Node>(ids)));
        }
Exemple #7
0
        /// <summary>
        /// DO NOT USE THIS METHOD DIRECTLY IN YOUR CODE.
        /// </summary>
        public static NodeQueryResult QueryNodesByReferenceAndType(string referenceName, int referredNodeId, NodeType nodeType, bool exactType)
        {
            int[] typeIds = null;
            if (nodeType != null)
            {
                typeIds = exactType ? new[] { nodeType.Id }
            }
            : nodeType.GetAllTypes().ToIdArray();

            var ids = DataProvider.Current.QueryNodesByReferenceAndType(referenceName, referredNodeId, typeIds);

            return(new NodeQueryResult(new NodeList <Node>(ids)));
        }
    }
Exemple #8
0
        /// <summary>
        /// Return with nodes that are in the subtree of the node identified by the pathStart filtered by the given <see cref="NodeType"/> and properties.
        /// Note that the pathStart will be suffixed with the trailing slash ('/') if it does not ends with it.
        /// Note that the result does not contain the root.
        /// Every result node need to meet every property filter.
        /// Every property filter has a name-value pair and an <see cref="Operator"/>.
        /// By the filtering concept, the property predicates are linked with AND logical operator.
        /// Logical OR cannot be applied in this case.
        /// </summary>
        /// <param name="nodeType">The <see cref="NodeType"/> that specifies the allowed type of nodes in the result.</param>
        /// <param name="exactType">True if inherited-type nodes are not in the result.</param>
        /// <param name="pathStart">The path of the root node.</param>
        /// <param name="orderByPath">Specifies that the result will be sorted or not.</param>
        /// <param name="properties">A <see cref="List&lt;QueryPropertyData&gt;"/> containing property predicates.</param>
        /// <returns>A <see cref="QueryResult"/> instance.</returns>
        public static QueryResult QueryNodesByTypeAndPathAndProperty(NodeType nodeType, bool exactType, string pathStart, bool orderByPath, List <QueryPropertyData> properties)
        {
            int[] typeIds = null;
            if (nodeType != null)
            {
                typeIds = exactType ? new[] { nodeType.Id }
            }
            : nodeType.GetAllTypes().ToIdArray();

            var ids = DataStore.QueryNodesByTypeAndPathAndPropertyAsync(typeIds, pathStart, orderByPath, properties, CancellationToken.None)
                      .GetAwaiter().GetResult();

            return(new QueryResult(new NodeList <Node>(ids)));
        }
Exemple #9
0
        /// <summary>
        /// DO NOT USE THIS METHOD DIRECTLY IN YOUR CODE.
        /// </summary>
        public static NodeQueryResult QueryNodesByTypeAndPath(NodeType nodeType, bool exactType, string pathStart, bool orderByPath)
        {
            if (nodeType == null)
            {
                throw new ArgumentNullException("nodeType");
            }
            if (pathStart == null)
            {
                throw new ArgumentNullException("pathStart");
            }
            var typeIds           = exactType ? new[] { nodeType.Id } : nodeType.GetAllTypes().ToIdArray();
            IEnumerable <int> ids = DataProvider.Current.QueryNodesByTypeAndPath(typeIds, pathStart, orderByPath);

            return(new NodeQueryResult(new NodeList <Node>(ids)));
        }
Exemple #10
0
        /// <summary>
        /// Returns with the nodes that references the given node. The result is filtered by the given type or type family.
        /// CQL equivalent: '+Type:{nodeTypeName} +{referenceName}:{referredNodeId}' or '+TypeIs:{nodeTypeName} +{referenceName}:{referredNodeId}'.
        /// </summary>
        public static QueryResult QueryNodesByReferenceAndType(string referenceName, int referredNodeId, NodeType nodeType, bool exactType)
        {
            int[] typeIds = null;
            if (nodeType != null)
            {
                typeIds = exactType ? new[] { nodeType.Id }
            }
            : nodeType.GetAllTypes().ToIdArray();

            var ids = DataStore.QueryNodesByReferenceAndTypeAsync(referenceName, referredNodeId, typeIds, CancellationToken.None)
                      .GetAwaiter().GetResult();

            return(new QueryResult(new NodeList <Node>(ids)));
        }
    }
Exemple #11
0
        //============================================================================================================================ NodeQuery replacement

        /// <summary>
        /// DO NOT USE THIS METHOD DIRECTLY IN YOUR CODE.
        /// </summary>
        public static int InstanceCount(NodeType nodeType, bool exactType)
        {
            return(DataProvider.Current.InstanceCount(exactType ? new[] { nodeType.Id } : nodeType.GetAllTypes().ToIdArray()));
        }
Exemple #12
0
 /// <summary>
 /// Returns with the count of the stored instances by the given <see cref="NodeType"/>.
 /// CQL equivalent: if exactType is true: 'Type:{nodeTypeName} .COUNTONLY' otherwise: 'TypeIs:{nodeTypeName} .COUNTONLY'.
 /// </summary>
 /// <param name="nodeType">The <see cref="NodeType"/> that specifies the allowed type of nodes in the result.</param>
 /// <param name="exactType">True if inherited-type nodes are not in the result.</param>
 /// <returns>Count of instances.</returns>
 public static int InstanceCount(NodeType nodeType, bool exactType)
 {
     return(DataStore.InstanceCountAsync(exactType ? new[] { nodeType.Id } : nodeType.GetAllTypes().ToIdArray(), CancellationToken.None)
            .GetAwaiter().GetResult());
 }