Examples of PageSearchControl


Examples of org.jboss.identity.idm.impl.api.PageSearchControl

   {
      checkIOType(identityType);

      checkControls(controls);

      PageSearchControl pageSearchControl = null;
      SortByNameSearchControl sortSearchControl = null;
      AttributeFilterSearchControl attributeFilterControl = null;
      NameFilterSearchControl nameFilterSearchControl = null;

      if (controls != null)
      {
         for (IdentityObjectSearchControl control : controls)
         {
            if (control instanceof PageSearchControl)
            {
               pageSearchControl = (PageSearchControl)control;
            }
            else if (control instanceof SortByNameSearchControl)
            {
               sortSearchControl = (SortByNameSearchControl)control;
            }
            else if (control instanceof AttributeFilterSearchControl)
            {
               attributeFilterControl = (AttributeFilterSearchControl)control;
            }
            else if (control instanceof NameFilterSearchControl)
            {
               nameFilterSearchControl = (NameFilterSearchControl)control;
            }
         }
      }

      HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx, identityType);

      List<IdentityObject> results;

      Session hibernateSession = getHibernateSession(ctx);

      try
      {

         Query q = null;

         if (sortSearchControl != null)
         {
            if (sortSearchControl.isAscending())
            {
               q = hibernateSession.createQuery(HibernateIdentityObject.findIdentityObjectsByTypeOrderedByNameAsc);
            }
            else
            {
               q = hibernateSession.createQuery(HibernateIdentityObject.findIdentityObjectsByTypeOrderedByNameDesc);
            }
         }
         else
         {
            q = hibernateSession.createQuery(HibernateIdentityObject.findIdentityObjectsByType);
         }

         if (pageSearchControl != null)
         {
            if (pageSearchControl.getLimit() > 0)
            {
               q.setMaxResults(pageSearchControl.getLimit());
            }
            q.setFirstResult(pageSearchControl.getOffset());

         }

         q.setParameter("realm", getRealm(hibernateSession, ctx))
          .setParameter("typeName", hibernateType.getName());
View Full Code Here

Examples of org.jboss.identity.idm.impl.api.PageSearchControl

      List<IdentityObject> results;

      checkControls(controls);

      PageSearchControl pageSearchControl = null;
      SortByNameSearchControl sortSearchControl = null;
      AttributeFilterSearchControl attributeFilterControl = null;
      NameFilterSearchControl nameFilterSearchControl = null;

      if (controls != null)
      {
         for (IdentityObjectSearchControl control : controls)
         {
            if (control instanceof PageSearchControl)
            {
               pageSearchControl = (PageSearchControl)control;
            }
            else if (control instanceof SortByNameSearchControl)
            {
               sortSearchControl = (SortByNameSearchControl)control;
            }
            else if (control instanceof AttributeFilterSearchControl)
            {
               attributeFilterControl = (AttributeFilterSearchControl)control;
            }
            else if (control instanceof NameFilterSearchControl)
            {
               nameFilterSearchControl = (NameFilterSearchControl)control;
            }
         }
      }

      boolean orderByName = false;
      boolean ascending = true;

      if (sortSearchControl != null)
      {
         orderByName = true;
         ascending = sortSearchControl.isAscending();
      }

      try
      {
         org.hibernate.Query q = null;

         StringBuilder hqlString = new StringBuilder("");

//         if (orderByName)
//         {
//            hqlString.append(" orderBy ior.toIdentityObject.name");
//            if (ascending)
//            {
//               hqlString.append(" asc");
//            }
//         }

         if (parent)
         {

            if (relationshipType != null)
            {

               hqlString.append("select distinct ior.toIdentityObject from HibernateIdentityObjectRelationship ior where " +
                  "ior.toIdentityObject.name like :nameFilter and ior.type.name like :relType and ior.fromIdentityObject like :identity");
            }
            else
            {
               hqlString.append("select distinct ior.toIdentityObject from HibernateIdentityObjectRelationship ior where " +
                  "ior.toIdentityObject.name like :nameFilter and ior.fromIdentityObject like :identity");
            }
            if (orderByName)
            {
               hqlString.append(" orderBy ior.toIdentityObject.name");
               if (ascending)
               {
                  hqlString.append(" asc");
               }
            }
         }
         else
         {
            if (relationshipType != null)
            {
               hqlString.append("select distinct ior.fromIdentityObject from HibernateIdentityObjectRelationship ior where " +
                  "ior.fromIdentityObject.name like :nameFilter and ior.type.name like :relType and ior.toIdentityObject like :identity");
            }
            else
            {
              hqlString.append("select distinct ior.fromIdentityObject from HibernateIdentityObjectRelationship ior where " +
                  "ior.fromIdentityObject.name like :nameFilter and ior.toIdentityObject like :identity");
            }

            if (orderByName)
            {
               hqlString.append(" orderBy ior.toIdentityObject.name");
               if (ascending)
               {
                  hqlString.append(" asc");
               }
            }
         }



         q = getHibernateSession(ctx).createQuery(hqlString.toString())
            .setParameter("identity",hibernateObject);

         if (relationshipType != null)
         {
            q.setParameter("relType", relationshipType.getName());
         }

         if (nameFilterSearchControl != null)
         {
            q.setParameter("nameFilter", nameFilterSearchControl.getFilter().replaceAll("\\*", "%"));
         }
         else
         {
            q.setParameter("nameFilter", "%");
         }

        
         if (pageSearchControl != null)
         {
            q.setFirstResult(pageSearchControl.getOffset());
            if (pageSearchControl.getLimit() > 0)
            {
               q.setMaxResults(pageSearchControl.getLimit());
            }
         }



View Full Code Here

Examples of org.jboss.identity.idm.impl.api.PageSearchControl

      Session em = getHibernateSession(ctx);

      checkControls(controls);

      PageSearchControl pageSearchControl = null;
      SortByNameSearchControl sortSearchControl = null;
      AttributeFilterSearchControl attributeFilterControl = null;
      NameFilterSearchControl nameFilterSearchControl = null;

      if (controls != null)
      {
         for (IdentityObjectSearchControl control : controls)
         {
            if (control instanceof PageSearchControl)
            {
               pageSearchControl = (PageSearchControl)control;
            }
            else if (control instanceof SortByNameSearchControl)
            {
               sortSearchControl = (SortByNameSearchControl)control;
            }
            else if (control instanceof AttributeFilterSearchControl)
            {
               attributeFilterControl = (AttributeFilterSearchControl)control;
            }
            else if (control instanceof NameFilterSearchControl)
            {
               nameFilterSearchControl = (NameFilterSearchControl)control;
            }
         }
      }


      try
      {
         Query q = null;

         if (sortSearchControl != null)
         {
            if (sortSearchControl.isAscending())
            {
               q = em.createQuery(HibernateIdentityObjectRelationshipName.findIdentityObjectRelationshipNamesOrderedByNameAsc);
            }
            else
            {
               q = em.createQuery(HibernateIdentityObjectRelationshipName.findIdentityObjectRelationshipNamesOrderedByNameDesc);
            }
         }
         else
         {
            q = em.createQuery(HibernateIdentityObjectRelationshipName.findIdentityObjectRelationshipNames);
         }

         q.setParameter("realm", getRealm(em, ctx));

         if (nameFilterSearchControl != null)
         {
            q.setParameter("nameFilter", nameFilterSearchControl.getFilter().replaceAll("\\*", "%"));
         }
         else
         {
            q.setParameter("nameFilter", "%");
         }


         if (pageSearchControl != null)
         {
            q.setFirstResult(pageSearchControl.getOffset());
            if (pageSearchControl.getLimit() > 0)
            {
               q.setMaxResults(pageSearchControl.getLimit());
            }
         }

         List<String> results = (List<String>)q.list();

View Full Code Here

Examples of org.jboss.identity.idm.impl.api.PageSearchControl

      Session em = getHibernateSession(ctx);

      checkControls(controls);

      PageSearchControl pageSearchControl = null;
      SortByNameSearchControl sortSearchControl = null;

      if (controls != null)
      {
         for (IdentityObjectSearchControl control : controls)
         {
            if (control instanceof PageSearchControl)
            {
               pageSearchControl = (PageSearchControl)control;
            }
            else if (control instanceof SortByNameSearchControl)
            {
               sortSearchControl = (SortByNameSearchControl)control;
            }
         }
      }

      try
      {
         Query q = null;

         if (sortSearchControl != null)
         {
            if (sortSearchControl.isAscending())
            {
               q = em.createQuery(HibernateIdentityObjectRelationshipName.findIdentityObjectRelationshipNamesForIdentityObjectOrderedByNameAsc);
            }
            else
            {
               q = em.createQuery(HibernateIdentityObjectRelationshipName.findIdentityObjectRelationshipNamesForIdentityObjectOrdereByNameDesc);
            }
         }
         else
         {
            q = em.createQuery(HibernateIdentityObjectRelationshipName.findIdentityObjectRelationshipNamesForIdentityObject);
         }

         q.setParameter("identityObject", hibernateObject);

         if (pageSearchControl != null)
         {
            q.setFirstResult(pageSearchControl.getOffset());
            if (pageSearchControl.getLimit() > 0)
            {
               q.setMaxResults(pageSearchControl.getLimit());
            }
         }

         List<String> results = (List<String>)q.list();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.