How to use the breeze-client.Predicate function in breeze-client

To help you get started, we’ve selected a few breeze-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github forCrowd / WealthFramework / ng2Client / app / main / modules / data / resource-pool.service.ts View on Github external
getResourcePoolSet(searchKey: any) {
        searchKey = typeof searchKey !== "undefined" ? searchKey : "";

        var query = EntityQuery
            .from("ResourcePool")
            .expand(["User"])
            .orderBy("Name");

        if (searchKey !== "") {
            var resourcePoolNamePredicate = new Predicate("Name", "contains", searchKey);
            var userNamePredicate = new Predicate("User.UserName", "contains", searchKey);
            query = query.where(resourcePoolNamePredicate.or(userNamePredicate));
        }

        // Prepare the query
        //if (fetchFromServer) { // From remote
        query = query.using(FetchStrategy.FromServer);
        //    fetchFromServer = false; // Do it only once per user
        //}
        //else { // From local
        //query = query.using(FetchStrategy.FromLocalCache);
        //}

        return this.dataService.executeQuery(query)
            .map((response: any) => {
                return response.results;
            });
github forCrowd / WealthFramework / ngClient / _system / js / app / factories / resourcePoolFactory.ts View on Github external
// If it"s not newly created, check the fetched list
        fetchedEarlier = fetchedList.some(fetched => (resourcePoolUniqueKey === fetched));

        // Prepare the query
        var query = breeze.EntityQuery.from("ResourcePool");

        // Is authorized? No, then get only the public data, yes, then get include user"s own records
        if (currentUser.isAuthenticated()) {
            query = query.expand("User, UserResourcePoolSet, ElementSet.ElementFieldSet.UserElementFieldSet, ElementSet.ElementItemSet.ElementCellSet.UserElementCellSet");
        } else {
            query = query.expand("User, ElementSet.ElementFieldSet, ElementSet.ElementItemSet.ElementCellSet");
        }

        var userNamePredicate = new breeze.Predicate("User.UserName", "eq", resourcePoolUniqueKey.userName);
        var resourcePoolKeyPredicate = new breeze.Predicate("Key", "eq", resourcePoolUniqueKey.resourcePoolKey);

        query = query.where(userNamePredicate.and(resourcePoolKeyPredicate));

        // From server or local?
        if (!fetchedEarlier) {
            query = query.using(breeze.FetchStrategy.FromServer);
        } else {
            query = query.using(breeze.FetchStrategy.FromLocalCache);
        }

        return dataContext.executeQuery(query)
            .then(success)
            .catch(failed);

        function success(response: any) {
github forCrowd / WealthFramework / ng2Client / app / main / modules / data / resource-pool.service.ts View on Github external
// If it's not newly created, check the fetched list
        fetchedEarlier = this.fetchedList.some((item: any) => (resourcePoolUniqueKey.username === item.username
            && resourcePoolUniqueKey.resourcePoolKey === item.resourcePoolKey));

        // Prepare the query
        var query = EntityQuery.from("ResourcePool");

        // Is authorized? No, then get only the public data, yes, then get include user's own records
        if (this.dataService.currentUser.isAuthenticated()) {
            query = query.expand("User, UserResourcePoolSet, ElementSet.ElementFieldSet.UserElementFieldSet, ElementSet.ElementItemSet.ElementCellSet.UserElementCellSet");
        } else {
            query = query.expand("User, ElementSet.ElementFieldSet, ElementSet.ElementItemSet.ElementCellSet");
        }

        var userNamePredicate = new Predicate("User.UserName", "eq", resourcePoolUniqueKey.username);
        var resourcePoolKeyPredicate = new Predicate("Key", "eq", resourcePoolUniqueKey.resourcePoolKey);

        query = query.where(userNamePredicate.and(resourcePoolKeyPredicate));

        // From server or local?
        if (!fetchedEarlier) {
            query = query.using(FetchStrategy.FromServer);
        } else {
            query = query.using(FetchStrategy.FromLocalCache);
        }

        return this.dataService.executeQuery(query)
            .map((response: any): any => {

                // If there is no cmrp with this Id, return null
                if (response.results.length === 0) {
github forCrowd / WealthFramework / ng2Client / app / main / modules / data / resource-pool.service.ts View on Github external
getResourcePoolSet(searchKey: any) {
        searchKey = typeof searchKey !== "undefined" ? searchKey : "";

        var query = EntityQuery
            .from("ResourcePool")
            .expand(["User"])
            .orderBy("Name");

        if (searchKey !== "") {
            var resourcePoolNamePredicate = new Predicate("Name", "contains", searchKey);
            var userNamePredicate = new Predicate("User.UserName", "contains", searchKey);
            query = query.where(resourcePoolNamePredicate.or(userNamePredicate));
        }

        // Prepare the query
        //if (fetchFromServer) { // From remote
        query = query.using(FetchStrategy.FromServer);
        //    fetchFromServer = false; // Do it only once per user
        //}
        //else { // From local
        //query = query.using(FetchStrategy.FromLocalCache);
        //}

        return this.dataService.executeQuery(query)
            .map((response: any) => {
                return response.results;
github forCrowd / WealthFramework / ng2Client / app / main / modules / data / resource-pool.service.ts View on Github external
// If it's not newly created, check the fetched list
        fetchedEarlier = this.fetchedList.some((item: any) => (resourcePoolUniqueKey.username === item.username
            && resourcePoolUniqueKey.resourcePoolKey === item.resourcePoolKey));

        // Prepare the query
        var query = EntityQuery.from("ResourcePool");

        // Is authorized? No, then get only the public data, yes, then get include user's own records
        if (this.dataService.currentUser.isAuthenticated()) {
            query = query.expand("User, UserResourcePoolSet, ElementSet.ElementFieldSet.UserElementFieldSet, ElementSet.ElementItemSet.ElementCellSet.UserElementCellSet");
        } else {
            query = query.expand("User, ElementSet.ElementFieldSet, ElementSet.ElementItemSet.ElementCellSet");
        }

        var userNamePredicate = new Predicate("User.UserName", "eq", resourcePoolUniqueKey.username);
        var resourcePoolKeyPredicate = new Predicate("Key", "eq", resourcePoolUniqueKey.resourcePoolKey);

        query = query.where(userNamePredicate.and(resourcePoolKeyPredicate));

        // From server or local?
        if (!fetchedEarlier) {
            query = query.using(FetchStrategy.FromServer);
        } else {
            query = query.using(FetchStrategy.FromLocalCache);
        }

        return this.dataService.executeQuery(query)
            .map((response: any): any => {

                // If there is no cmrp with this Id, return null
                if (response.results.length === 0) {
                    return null;
github forCrowd / WealthFramework / ngClient / _system / js / app / factories / resourcePoolFactory.ts View on Github external
function getResourcePoolSet(searchKey: any) {
        searchKey = typeof searchKey !== "undefined" ? searchKey : "";

        var query = breeze.EntityQuery
            .from("ResourcePool")
            .expand(["User"]);

        if (searchKey !== "") {
            var resourcePoolNamePredicate = new breeze.Predicate("Name", "contains", searchKey);
            var userNamePredicate = new breeze.Predicate("User.UserName", "contains", searchKey);
            query = query.where(resourcePoolNamePredicate.or(userNamePredicate));
        }

        // Prepare the query
        //if (fetchFromServer) { // From remote
        query = query.using(breeze.FetchStrategy.FromServer);
        //    fetchFromServer = false; // Do it only once per user
        //}
        //else { // From local
        //query = query.using(breeze.FetchStrategy.FromLocalCache);
        //}

        return dataContext.executeQuery(query)
            .then(success).catch(failed);

        function success(response: any) {
github forCrowd / WealthFramework / ngClient / _system / js / app / factories / resourcePoolFactory.ts View on Github external
function getResourcePoolSet(searchKey: any) {
        searchKey = typeof searchKey !== "undefined" ? searchKey : "";

        var query = breeze.EntityQuery
            .from("ResourcePool")
            .expand(["User"]);

        if (searchKey !== "") {
            var resourcePoolNamePredicate = new breeze.Predicate("Name", "contains", searchKey);
            var userNamePredicate = new breeze.Predicate("User.UserName", "contains", searchKey);
            query = query.where(resourcePoolNamePredicate.or(userNamePredicate));
        }

        // Prepare the query
        //if (fetchFromServer) { // From remote
        query = query.using(breeze.FetchStrategy.FromServer);
        //    fetchFromServer = false; // Do it only once per user
        //}
        //else { // From local
        //query = query.using(breeze.FetchStrategy.FromLocalCache);
        //}

        return dataContext.executeQuery(query)
            .then(success).catch(failed);
github forCrowd / WealthFramework / ngClient / _system / js / app / factories / resourcePoolFactory.ts View on Github external
var fetchedEarlier = false;

        // If it"s not newly created, check the fetched list
        fetchedEarlier = fetchedList.some(fetched => (resourcePoolUniqueKey === fetched));

        // Prepare the query
        var query = breeze.EntityQuery.from("ResourcePool");

        // Is authorized? No, then get only the public data, yes, then get include user"s own records
        if (currentUser.isAuthenticated()) {
            query = query.expand("User, UserResourcePoolSet, ElementSet.ElementFieldSet.UserElementFieldSet, ElementSet.ElementItemSet.ElementCellSet.UserElementCellSet");
        } else {
            query = query.expand("User, ElementSet.ElementFieldSet, ElementSet.ElementItemSet.ElementCellSet");
        }

        var userNamePredicate = new breeze.Predicate("User.UserName", "eq", resourcePoolUniqueKey.userName);
        var resourcePoolKeyPredicate = new breeze.Predicate("Key", "eq", resourcePoolUniqueKey.resourcePoolKey);

        query = query.where(userNamePredicate.and(resourcePoolKeyPredicate));

        // From server or local?
        if (!fetchedEarlier) {
            query = query.using(breeze.FetchStrategy.FromServer);
        } else {
            query = query.using(breeze.FetchStrategy.FromLocalCache);
        }

        return dataContext.executeQuery(query)
            .then(success)
            .catch(failed);

        function success(response: any) {
github forCrowd / WealthFramework / AngularClient / src / main / core / project.service.ts View on Github external
getProjectSet(searchKey: string = "") {

    let query = EntityQuery
      .from("Project")
      .expand(["User"])
      .orderBy("Name");

    if (searchKey !== "") {
      const projectNamePredicate = new Predicate("Name", "contains", searchKey);
      const userNamePredicate = new Predicate("User.UserName", "contains", searchKey);
      query = query.where(projectNamePredicate.or(userNamePredicate));
    }

    return this.appEntityManager.executeQueryObservable(query).pipe(
      map(response => {
        return response.results;
      }));
  }
github forCrowd / WealthFramework / AngularClient / src / main / core / project.service.ts View on Github external
getProjectSet(searchKey: string = "") {

    let query = EntityQuery
      .from("Project")
      .expand(["User"])
      .orderBy("Name");

    if (searchKey !== "") {
      const projectNamePredicate = new Predicate("Name", "contains", searchKey);
      const userNamePredicate = new Predicate("User.UserName", "contains", searchKey);
      query = query.where(projectNamePredicate.or(userNamePredicate));
    }

    return this.appEntityManager.executeQueryObservable(query).pipe(
      map(response => {
        return response.results;
      }));
  }