Package org.exoplatform.services.organization

Examples of org.exoplatform.services.organization.Query


            if (user != null) {
                String oldEmail = user.getEmail();
                String newEmail = uiForm.getUIStringInput("email").getValue();

                // Check if mail address is already used
                Query query = new Query();
                query.setEmail(newEmail);
                if (service.getUserHandler().findUsers(query).getAll().size() > 0 && !oldEmail.equals(newEmail)) {
                    // Be sure it keep old value
                    user.setEmail(oldEmail);
                    Object[] args = { userName };
                    uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.email-exist", args));
View Full Code Here


                }
            }

            // User provided his email address
            if (user == null && email != null) {
                Query query = new Query();
                // Querying on email won't work. PLIDM-12
                // Note that querying on email is inefficient as it loops over all users...
                query.setEmail(email);
                PageList<User> users = orgSrc.getUserHandler().findUsers(query);
                if (users.getAll().size() > 0) {
                    user = users.getAll().get(0);
                } else {
                    requestContext.getUIApplication().addMessage(
View Full Code Here

            uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.user-exist", args));
            return false;
        }

        // Check if mail address is already used
        Query query = new Query();
        query.setEmail(getEmail());
        if (userHandler.findUsers(query).getAll().size() > 0) {
            Object[] args = { username };
            uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.email-exist", args));
            return false;
        }
View Full Code Here

   public void testFindUsersByQuery() throws Exception
   {
      createUser("tolik");
      uHandler.authenticate("tolik", "pwd");

      Query query = new Query();
      query.setEmail("email@test");

      // try to find user by email
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name with mask
      query = new Query();
      query.setUserName("*tolik*");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name with mask
      query = new Query();
      query.setUserName("tol*");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name with mask
      query = new Query();
      query.setUserName("*lik");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name explicitly
      query = new Query();
      query.setUserName("tolik");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name explicitly, case sensitive search
      query = new Query();
      query.setUserName("Tolik");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by part of name without mask
      query = new Query();
      query.setUserName("tol");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by fist and last names, case sensitive search
      query = new Query();
      query.setFirstName("fiRst");
      query.setLastName("lasT");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      String skipDateTests = System.getProperty("orgservice.test.configuration.skipDateTests");
      if (!"true".equals(skipDateTests))
      {
         // try to find user by login date
         Calendar calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);

         query = new Query();
         query.setFromLoginDate(calc.getTime());
         query.setUserName("tolik");
         assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

         calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) + 1);

         query = new Query();
         query.setFromLoginDate(calc.getTime());
         assertEquals(uHandler.findUsersByQuery(query).getSize(), 0);

         calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);

         query = new Query();
         query.setToLoginDate(calc.getTime());
         assertEquals(uHandler.findUsersByQuery(query).getSize(), 0);

         calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) + 1);

         query = new Query();
         query.setToLoginDate(calc.getTime());
         query.setUserName("tolik");
         assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
      }

      createUser("rolik");
      createUser("bolik");
      createUser("volik");

      query = new Query();
      query.setUserName("olik");

      ListAccess<User> users = uHandler.findUsersByQuery(query);

      assertEquals(users.getSize(), 4);

View Full Code Here

   public void testFindUsers() throws Exception
   {
      createUser("tolik");
      uHandler.authenticate("tolik", "pwd");

      Query query = new Query();
      query.setEmail("email@test");

      // try to find user by email
      assertEquals(uHandler.findUsers(query).getAll().size(), 1);

      // try to find user by name with mask
      query = new Query();
      query.setUserName("*tolik*");
      assertEquals(uHandler.findUsers(query).getAll().size(), 1);

      // try to find user by name with mask
      query = new Query();
      query.setUserName("tol*");
      assertEquals(uHandler.findUsers(query).getAll().size(), 1);

      // try to find user by name with mask
      query = new Query();
      query.setUserName("*lik");
      assertEquals(uHandler.findUsers(query).getAll().size(), 1);

      // try to find user by name explicitly
      query = new Query();
      query.setUserName("tolik");
      assertEquals(uHandler.findUsers(query).getAll().size(), 1);

      // try to find user by name explicitly, case sensitive search
      query = new Query();
      query.setUserName("Tolik");
      assertEquals(uHandler.findUsers(query).getAll().size(), 1);

      // try to find user by part of name without mask
      query = new Query();
      query.setUserName("tol");
      assertEquals(uHandler.findUsers(query).getAll().size(), 1);

      // try to find user by fist and last names, case sensitive search
      query = new Query();
      query.setFirstName("fiRst");
      query.setLastName("lasT");
      assertEquals(uHandler.findUsers(query).getAll().size(), 1);

      String skipDateTests = System.getProperty("orgservice.test.configuration.skipDateTests");
      if (!"true".equals(skipDateTests))
      {
         // try to find user by login date
         Calendar calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);

         query = new Query();
         query.setFromLoginDate(calc.getTime());
         query.setUserName("tolik");
         assertEquals(uHandler.findUsers(query).getAll().size(), 1);

         calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) + 1);
        
         query = new Query();
         query.setFromLoginDate(calc.getTime());
         assertEquals(uHandler.findUsers(query).getAll().size(), 0);

         calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);

         query = new Query();
         query.setToLoginDate(calc.getTime());
         assertEquals(uHandler.findUsers(query).getAll().size(), 0);

         calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) + 1);

         query = new Query();
         query.setToLoginDate(calc.getTime());
         query.setUserName("tolik");
         assertEquals(uHandler.findUsers(query).getAll().size(), 1);
      }

   }
View Full Code Here

                }
            }

            // User provided his email address
            if (user == null && email != null) {
                Query query = new Query();
                // Querying on email won't work. PLIDM-12
                // Note that querying on email is inefficient as it loops over all users...
                query.setEmail(email);
                PageList<User> users = orgSrc.getUserHandler().findUsers(query);
                if (users.getAll().size() > 0) {
                    user = users.getAll().get(0);
                } else {
                    requestContext.getUIApplication().addMessage(
View Full Code Here

            if (user != null) {
                String oldEmail = user.getEmail();
                String newEmail = uiForm.getUIStringInput("email").getValue();

                // Check if mail address is already used
                Query query = new Query();
                query.setEmail(newEmail);
                if (service.getUserHandler().findUsers(query).getAll().size() > 0 && !oldEmail.equals(newEmail)) {
                    // Be sure it keep old value
                    user.setEmail(oldEmail);
                    Object[] args = { userName };
                    uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.email-exist", args));
View Full Code Here

    */
   public void testFindUsersByQuery() throws Exception
   {
      createUser("tolik");

      Query query = new Query();
      query.setEmail("email@test");

      // try to find user by email
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name with mask
      query = new Query();
      query.setUserName("*tolik*");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name with mask
      query = new Query();
      query.setUserName("tol*");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name with mask
      query = new Query();
      query.setUserName("*lik");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name explicitly
      query = new Query();
      query.setUserName("tolik");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name explicitly, case sensitive search
      query = new Query();
      query.setUserName("Tolik");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by part of name without mask
      query = new Query();
      query.setUserName("tol");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by fist and last names, case sensitive search
      query = new Query();
      query.setFirstName("fiRst");
      query.setLastName("lasT");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      String skipDateTests = System.getProperty("orgservice.test.configuration.skipDateTests");
      if (!"true".equals(skipDateTests))
      {
         // try to find user by login date
         Calendar calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);

         query = new Query();
         query.setFromLoginDate(calc.getTime());
         query.setUserName("tolik");
         assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

         calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) + 1);

         query = new Query();
         query.setFromLoginDate(calc.getTime());
         assertEquals(uHandler.findUsersByQuery(query).getSize(), 0);

         calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);

         query = new Query();
         query.setToLoginDate(calc.getTime());
         assertEquals(uHandler.findUsersByQuery(query).getSize(), 0);

         calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) + 1);

         query = new Query();
         query.setToLoginDate(calc.getTime());
         query.setUserName("tolik");
         assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      }
   }
View Full Code Here

    */
   public void testFindUsers() throws Exception
   {
      createUser("tolik");

      Query query = new Query();
      query.setEmail("email@test");

      // try to find user by email
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name with mask
      query = new Query();
      query.setUserName("*tolik*");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name with mask
      query = new Query();
      query.setUserName("tol*");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name with mask
      query = new Query();
      query.setUserName("*lik");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name explicitly
      query = new Query();
      query.setUserName("tolik");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by name explicitly, case sensitive search
      query = new Query();
      query.setUserName("Tolik");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by part of name without mask
      query = new Query();
      query.setUserName("tol");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      // try to find user by fist and last names, case sensitive search
      query = new Query();
      query.setFirstName("fiRst");
      query.setLastName("lasT");
      assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

      String skipDateTests = System.getProperty("orgservice.test.configuration.skipDateTests");
      if (!"true".equals(skipDateTests))
      {
         // try to find user by login date
         Calendar calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);

         query = new Query();
         query.setFromLoginDate(calc.getTime());
         query.setUserName("tolik");
         assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);

         calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) + 1);
        
         query = new Query();
         query.setFromLoginDate(calc.getTime());
         assertEquals(uHandler.findUsersByQuery(query).getSize(), 0);

         calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);

         query = new Query();
         query.setToLoginDate(calc.getTime());
         assertEquals(uHandler.findUsersByQuery(query).getSize(), 0);

         calc = Calendar.getInstance();
         calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) + 1);

         query = new Query();
         query.setToLoginDate(calc.getTime());
         query.setUserName("tolik");
         assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
      }

   }
View Full Code Here

     */
    @Override
    public void processRender(WebuiRequestContext context) throws Exception {
        int curPage = grid_.getUIPageIterator().getCurrentPage();
        if (lastQuery_ == null)
            lastQuery_ = new Query();
        search(lastQuery_);
        grid_.getUIPageIterator().setCurrentPage(curPage);
        grid_.getUIPageIterator().getCurrentPageData();
        super.processRender(context);
    }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.organization.Query

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.