Package org.beangle.model.query.builder

Examples of org.beangle.model.query.builder.OqlBuilder


    return CollectUtils.newArrayList(resources);
  }

  @SuppressWarnings({ "unchecked", "rawtypes" })
  public Set<String> getResourceNames(int scope) {
    OqlBuilder query = OqlBuilder.from(Resource.class, "resource");
    query.where("resource.scope=:scope and resource.enabled=true", Integer.valueOf(scope));
    query.select("resource.name");
    return CollectUtils.newHashSet(entityDao.search(query));
  }
View Full Code Here


   */
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public Set<String> getResourceNamesByGroup(String group) {
    String hql = "select m.name from " + Group.class.getName() + " as r join r.authorities as a"
        + " join a.resource as m where  r.name = :groupName and m.enabled = true";
    OqlBuilder query = OqlBuilder.hql(hql).param("groupName", group).cacheable();
    return (Set<String>) new HashSet(entityDao.search(query));
  }
View Full Code Here

    publish(new GroupAuthorityEvent(group));
  }

  @SuppressWarnings({ "unchecked", "rawtypes" })
  public void updateState(Long[] resourceIds, boolean isEnabled) {
    OqlBuilder query = OqlBuilder.from(Resource.class, "resource");
    query.where("resource.id in (:ids)", resourceIds);
    List<Resource> resources = entityDao.search(query);
    for (Resource resource : resources) {
      resource.setEnabled(isEnabled);
    }
    entityDao.saveOrUpdate(resources);
View Full Code Here

    entityDao.saveOrUpdate(resources);
  }

  @SuppressWarnings({ "rawtypes", "unchecked" })
  public Collection<Group> filter(Collection<Group> groups, Resource resource) {
    OqlBuilder builder = OqlBuilder.from(Authority.class, "au");
    builder.where("au.group in (:groups) and au.resource = :resource", groups, resource);
    builder.select("au.group");
    return entityDao.search(builder);
  }
View Full Code Here

  // workground for no session
  @SuppressWarnings({ "rawtypes", "unchecked" })
  public List<Group> getGroups(User user, GroupMember.Ship ship) {
    if (isAdmin(user) && !ObjectUtils.equals(ship, GroupMember.Ship.MEMBER)) return entityDao
        .getAll(Group.class);
    OqlBuilder builder = OqlBuilder.from(GroupMember.class, "gm");
    builder.where("gm.user=:user", user).select("gm.group");
    if (null != ship) {
      if (ship.equals(GroupMember.Ship.MEMBER)) builder.where("gm.member=true");
      if (ship.equals(GroupMember.Ship.MANAGER)) builder.where("gm.manager=true");
      if (ship.equals(GroupMember.Ship.GRANTER)) builder.where("gm.granter=true");
    }
    builder.cacheable();
    return entityDao.search(builder);
  }
View Full Code Here

    Validate.notNull(sessioninfoBuilder, "sessioninfoBuilder must set");
  }

  @SuppressWarnings({ "rawtypes", "unchecked" })
  public boolean isRegisted(String principal) {
    OqlBuilder builder = OqlBuilder.from(sessioninfoBuilder.getSessioninfoClass(), "info");
    builder.where("info.username=:username and info.expiredAt is null", principal).select("info.id")
        .cacheable();
    return !entityDao.search(builder).isEmpty();
  }
View Full Code Here

    remove(event.getId());
  }

  @SuppressWarnings({ "rawtypes", "unchecked" })
  public int count() {
    OqlBuilder builder = OqlBuilder.from(Sessioninfo.class, "info");
    builder.select("count(id)");
    List<Number> numbers = entityDao.search(builder);
    if (numbers.isEmpty()) return 0;
    else return (numbers.get(0)).intValue();
  }
View Full Code Here

  }

  @SuppressWarnings({ "rawtypes", "unchecked" })
  public int getMaxSessions(Authentication auth) {
    String category = ((CategoryPrincipal) auth.getPrincipal()).getCategory();
    OqlBuilder builder = OqlBuilder.from(CategorySessionStat.class, "stat");
    builder.select("stat.userMaxSessions")
        .where("stat.category=:category and stat.serverName=:server", category, getServerName())
        .cacheable();
    List nums = entityDao.search(builder);
    if (nums.isEmpty()) return 1;
    else return ((Number) nums.get(0)).intValue();
View Full Code Here

  // workgroup for no session
  @SuppressWarnings({ "rawtypes", "unchecked" })
  public List<Group> getGroups(User user, GroupMember.Ship ship) {
    if (isAdmin(user)) return entityDao.getAll(Group.class);
    OqlBuilder builder = OqlBuilder.from(GroupMember.class, "gm");
    builder.where("gm.user=:user", user).select("gm.group");
    if (null != ship) {
      if (ship.equals(GroupMember.Ship.MEMBER)) builder.where("gm.member=true");
      if (ship.equals(GroupMember.Ship.MANAGER)) builder.where("gm.manager=true");
      if (ship.equals(GroupMember.Ship.GRANTER)) builder.where("gm.granter=true");
    }
    return entityDao.search(builder);
  }
View Full Code Here

    return CollectUtils.newArrayList(resources);
  }

  @SuppressWarnings({"unchecked","rawtypes"})
  public Set<String> getResourceNames(int scope) {
    OqlBuilder query = OqlBuilder.from(Resource.class, "resource");
    query.where("resource.scope=:scope and resource.enabled=true", Integer.valueOf(scope));
    query.select("resource.name");
    return CollectUtils.newHashSet(entityDao.search(query));
  }
View Full Code Here

TOP

Related Classes of org.beangle.model.query.builder.OqlBuilder

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.