public ListAndPagingInfo<Customer> searchCustomer(String name) {

    // use findByCriteria4Page method

    name = JSFTools.processNull(name);
    DetachedCriteria criteria = DetachedCriteria.forClass(Customer.class);

    if (!StringUtil.isEmptyString(name)) {
      criteria.add(Restrictions.like("name", name, MatchMode.ANYWHERE));
    }
    if (PaginationContext.getPaginationSortOrderData() != null
        && PaginationContext.getPaginationSortOrderData().getSortValue() == null) {
      PaginationContext.getPaginationSortOrderData().setSortValue("updatedDt");
      PaginationContext.getPaginationSortOrderData().setAscending(false);
    }
    return findByCriteria4Page(criteria);

    // use find4Page method
    /*
     * name = JSFTools.processNull(name); String hql =
     * "FROM Customer customer " + "WHERE  customer.name like ? " +
     * "ORDER BY customer.updatedDt DESC";
     *
     * String hqlCount = "SELECT COUNT(*) FROM Customer customer " +
     * "WHERE  customer.name like ? " + "ORDER BY customer.updatedDt DESC";
     *
     * return this.find4Page(hql, hqlCount, new String[]{"%" + name + "%"});
     */

  }
  private static void populateHibernateDetachedCriteria(
      AbstractHibernateQuery hibernateQuery,
      org.hibernate.criterion.DetachedCriteria detachedCriteria,
      QueryableCriteria<?> queryableCriteria) {
    List<Query.Criterion> criteriaList = queryableCriteria.getCriteria();
    for (Query.Criterion criterion : criteriaList) {
      Criterion hibernateCriterion =
          HibernateQuery.HIBERNATE_CRITERION_ADAPTER.toHibernateCriterion(
              hibernateQuery, criterion, null);
      if (hibernateCriterion != null) {
        detachedCriteria.add(hibernateCriterion);
      }
    }

    List<Query.Projection> projections = queryableCriteria.getProjections();
    ProjectionList projectionList = Projections.projectionList();
    for (Query.Projection projection : projections) {
      Projection hibernateProjection =
          new HibernateProjectionAdapter(projection).toHibernateProjection();
      if (hibernateProjection != null) {
        projectionList.add(hibernateProjection);
      }
    }
    detachedCriteria.setProjection(projectionList);
  }
 @Override
 public ModelStaffAttendanceView getRecordByCondition(String staffId, Date day, String districtId)
     throws ServiceException {
   // TODO Auto-generated method stub
   DetachedCriteria criteria = DetachedCriteria.forClass(ModelStaffAttendanceView.class);
   if (UtilString.isNotEmpty(staffId)) {
     criteria.add(Restrictions.eq("staffId", staffId));
   }
   if (day != null) {
     criteria.add(Restrictions.eq("workDate", day));
   }
   if (UtilString.isNotEmpty(districtId)) {
     criteria.add(Restrictions.eq("districtId", districtId));
   }
   List<ModelStaffAttendanceView> list = null;
   try {
     list = this.getDaoStaffAttendanceView().getListByCriteria(criteria);
   } catch (DAOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   if (list != null && list.size() > 0) {
     return list.get(0);
   }
   return null;
 }
  /**
   * See Interface for functional description.
   *
   * @see UserAccountDaoInterface #retrieveCurrentGrant(java.lang.String, EscidocRole,
   *     java.lang.String)
   */
  @Override
  public RoleGrant retrieveCurrentGrant(
      final UserAccount userAccount, final EscidocRole role, final String objId)
      throws SqlDatabaseSystemException {

    RoleGrant result = null;
    if (userAccount != null && role != null) {

      try {
        DetachedCriteria criteria =
            DetachedCriteria.forClass(RoleGrant.class)
                .add(Restrictions.eq("userAccountByUserId", userAccount))
                .add(Restrictions.eq("escidocRole", role))
                .add(Restrictions.isNull("revocationDate"));
        if (objId != null) {
          criteria = criteria.add(Restrictions.eq("objectId", objId));
        }
        result = (RoleGrant) getUniqueResult(getHibernateTemplate().findByCriteria(criteria));
      } catch (final DataAccessException e) {
        throw new SqlDatabaseSystemException(e);
      } catch (final IllegalStateException e) {
        throw new SqlDatabaseSystemException(e);
      } catch (final HibernateException e) {
        //noinspection ThrowableResultOfMethodCallIgnored
        throw new SqlDatabaseSystemException(convertHibernateAccessException(e)); // Ignore FindBugs
      }
    }
    return result;
  }
  /** 获得资源列表 */
  public List getResourceList(String ResourceType, String key) {
    // TODO Auto-generated method stub
    List<LabelValueBean> resourceList = new ArrayList<LabelValueBean>();
    try {
      ResourceInfo resource = new ResourceInfo();
      resource.setResourceType(ResourceType);
      DetachedCriteria dc = DetachedCriteria.forClass(ResourceInfo.class);
      dc.add(Example.create(resource));
      MyQuery myQuery = new MyQueryImpl();
      myQuery.setDetachedCriteria(dc);
      Object[] objs = this.dao.findEntity(myQuery);

      if (null != objs && 0 < objs.length) {
        ResourceInfo res = new ResourceInfo();
        for (int i = 0; i < objs.length; i++) {
          LabelValueBean resourceInfo = new LabelValueBean();
          res = (ResourceInfo) objs[i];
          resourceInfo.setValue(res.getId());
          resourceInfo.setLabel(res.getResourceName());
          resourceList.add(resourceInfo);
        }
      }
    } catch (Exception e) {
      logger.debug(e);
    }
    return resourceList;
  }
Пример #6
0
  @Secured({"ROLE_DEVELOPER", "ROLE_TESTER"})
  @RequestMapping(value = "showBug/{bugId}.htm", method = RequestMethod.GET)
  public String showBug(@PathVariable Integer bugId, ModelMap map) {

    Bug bug = aService.findById(Bug.class, bugId);

    List<History> histories =
        aService.queryAllOfCondition(
            History.class,
            DetachedCriteria.forClass(History.class)
                .add(Restrictions.eq("objectType", "bug"))
                .add(Restrictions.eq("objectId", bug.getBugId()))
                .addOrder(Order.asc("operateTime")));
    List<Resource> resources =
        aService.queryAllOfCondition(
            Resource.class,
            DetachedCriteria.forClass(Resource.class)
                .add(Restrictions.eq("objectType", "bug"))
                .add(Restrictions.eq("objectId", bug.getBugId()))
                .addOrder(Order.asc("resourceId")));

    map.put("bug", bug);
    map.put("histories", histories);
    map.put("resources", resources);

    return "bug/showBug";
  }
Пример #7
0
 /**
  * 创建与会话无关的检索标准对象
  *
  * @param criterions Restrictions.eq("name", value);
  * @return
  */
 public DetachedCriteria createDetachedCriteria(Criterion... criterions) {
   DetachedCriteria dc = DetachedCriteria.forClass(entityClass);
   for (Criterion c : criterions) {
     dc.add(c);
   }
   return dc;
 }
Пример #8
0
  @Override
  public Long countConceptsAlignedToExtThes(String idThesaurus) {
    DetachedCriteria alignmentCriteria =
        DetachedCriteria.forClass(Alignment.class, "al")
            .add(Restrictions.isNotNull("al.externalTargetThesaurus"))
            .setProjection(
                Projections.projectionList()
                    .add(Projections.property(AL_SOURCE_CONCEPT_IDENTIFIER)));

    DetachedCriteria conceptCriteria =
        DetachedCriteria.forClass(ThesaurusConcept.class, "stc")
            .add(Restrictions.eq("stc.thesaurus.identifier", idThesaurus))
            .setProjection(
                Projections.projectionList().add(Projections.property("stc.identifier")));

    Criteria criteria =
        getCurrentSession()
            .createCriteria(ThesaurusConcept.class, "tc")
            .add(
                Restrictions.and(
                    Subqueries.propertyIn(TC_IDENTIFIER, alignmentCriteria),
                    Subqueries.propertyIn(TC_IDENTIFIER, conceptCriteria)))
            .setProjection(Projections.rowCount());
    return (Long) criteria.list().get(0);
  }
Пример #9
0
  /*
   * (non-Javadoc)
   * @see com.lzcp.service.ServiceAlbum#getAlbumPagesByCategoryContextPath(java.lang.String, int, int, java.lang.String, java.lang.Boolean)
   */
  @Override
  public PaginationSupport<ModelAlbum> getAlbumPagesByCategoryContextPath(
      String categoryContextPath, int pageSize, int startIndex, String order, Boolean isDesc)
      throws ServiceException {
    if (UtilString.isNotEmpty(categoryContextPath)) {
      try {
        ModelCategory category = this.daoCategory.getCategoryByContextPath(categoryContextPath);
        if (category == null) {
          LOGGER.error(
              "The cateogry with context path(" + categoryContextPath + ") does not exit!");
          return null;
        }

        DetachedCriteria criteria = DetachedCriteria.forClass(ModelAlbum.class);
        criteria.createCriteria("category").add(Restrictions.eq("id", category.getId()));

        return this.daoAlbum.findPageByCriteria(criteria, pageSize, startIndex);

      } catch (DAOException e) {
        LOGGER.error(
            "It failed to obtain the album with category context path: " + categoryContextPath, e);
      } catch (Exception e) {
        throw new ServiceException(
            "It failed to obtain the album with category context path: " + categoryContextPath, e);
      }
    }

    return null;
  }
  @Override
  public DetachedCriteria buildCriteria() {

    DetachedCriteria crit = DetachedCriteria.forClass(AccountCreditNote.class);

    if (isNotEmpty(filterModel.getSerial())) {
      crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getReference())) {
      crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getCode())) {
      crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START));
    }

    if (filterModel.getBeginDate() != null) {
      crit.add(Restrictions.ge("this.date", filterModel.getBeginDate()));
    }

    if (filterModel.getEndDate() != null) {
      crit.add(Restrictions.le("this.date", filterModel.getEndDate()));
    }

    if (filterModel.getAccount() != null) {
      crit.add(Restrictions.le("this.account", filterModel.getAccount()));
    }

    crit.addOrder(Order.desc("serial"));
    crit.addOrder(Order.desc("date"));

    return crit;
  }
  public void prepareDateRange() throws Exception {
    DetachedCriteria criteria = DetachedCriteria.forClass(ConfirmationRecord.class);
    ProjectionList pjl = Projections.projectionList();
    pjl.add(Projections.property("cycleFrom"));
    pjl.add(Projections.property("cycleTo"));
    criteria.setProjection(Projections.distinct(pjl));

    List<?> list = confirmationRecordService.findByCriteria(criteria);
    if (list.size() > 0) {
      Object[] objs = list.toArray();
      selectionCycleFrom = new ArrayList<>();
      selectionCycleFrom.add(new SelectItem(null, "Please Select"));
      cycleTos = new ArrayList<>();

      for (Object obj : objs) {
        if (obj instanceof Object[]) {
          Object[] innerObjs = (Object[]) obj;
          if (innerObjs.length == 2) {
            Date dFrom = DateUtil.convStringToDate(MS_SQL_DATE_PATTERN, innerObjs[0].toString());
            Date dTo = DateUtil.convStringToDate(MS_SQL_DATE_PATTERN, innerObjs[1].toString());
            selectionCycleFrom.add(
                new SelectItem(
                    DateUtil.convDateToString(SIMPLE_DATE_PATTERN, dFrom),
                    DateUtil.convDateToString(DISPLAY_DATE_PATTERN, dFrom)));
            cycleTos.add(DateUtil.convDateToString(SIMPLE_DATE_PATTERN, dTo));
          } else {
            System.err.println("ERR: obj[] length not eq to 2");
          }
        }
      }
    }
  }
Пример #12
0
  /**
   * bar info query
   *
   * @param global
   * @return
   * @throws JSONException
   */
  public String queryBarInfo(String global) throws JSONException {
    DetachedCriteria dc = DetachedCriteria.forClass(TNavigation.class);
    dc.add(Restrictions.eq("status", 1));
    dc.addOrder(Order.asc("ordinal")).addOrder(Order.desc("updatetime"));

    List<TNavigation> list = super.findByDetachedCriteria(dc);
    List<TBar> rootList = new ArrayList<TBar>();
    for (TNavigation navtion : list) {
      if ("0".equals(navtion.getObjid())) {
        TBar bar = new TBar();
        bar.setName(ActionUtils.getLanStr(navtion.getName(), navtion.getEname(), global));
        bar.setId(navtion.getOid());
        bar.setObjid(navtion.getObjid());

        rootList.add(bar);
      }
    }
    TNavigation record = new TNavigation();
    record.getBarList().add(rootList);
    record = this.convertBar(record, rootList, list, global);

    //		JSONArray itms = (JSONArray) JSONSerializer.toJSON(record.getBarList());
    //		return itms.toString();
    return JSONUtil.serialize(record.getBarList(), null, null, false, false, true);
  }
Пример #13
0
 @SuppressWarnings("unchecked")
 @Override
 public List<Comment> findByBookId(final Long bookId) {
   DetachedCriteria criteria = createCriteria();
   criteria.add(Restrictions.eq("book.id", bookId));
   return (List<Comment>) getHibernateTemplate().findByCriteria(criteria);
 }
Пример #14
0
  @SuppressWarnings("unchecked")
  protected List<Object[]> getSavedSearchDetails(Long savedSearchQueryID, String type) {
    SavedSearchRetriever.AlertType alertType = SavedSearchRetriever.AlertType.valueOf(type);

    DetachedCriteria criteria =
        DetachedCriteria.forClass(UserProfile.class)
            .setProjection(
                Projections.distinct(
                    Projections.projectionList()
                        .add(Projections.property("ss.ID"))
                        .add(Projections.property("email"))
                        .add(Projections.property("ss.searchName"))))
            .createAlias("savedSearches", "ss")
            .createAlias("ss.searchQuery", "q")
            .add(Restrictions.eq("q.ID", savedSearchQueryID));

    if (alertType == SavedSearchRetriever.AlertType.WEEKLY) {
      criteria.add(Restrictions.eq("ss.weekly", true));
    }

    if (alertType == SavedSearchRetriever.AlertType.MONTHLY) {
      criteria.add(Restrictions.eq("ss.monthly", true));
    }

    return (List<Object[]>) hibernateTemplate.findByCriteria(criteria);
  }
Пример #15
0
 public Label findByName(String name, long parent) {
   final DetachedCriteria criteria = newCriteria();
   criteria.add(Expression.eq("parentId", parent));
   criteria.add(Expression.eq("name", name));
   final List<Label> labels = findByCriteria(criteria);
   return labels.size() > 0 ? labels.get(0) : null;
 }
Пример #16
0
  @Override
  public String input() throws Exception {
    this.sysUser = service.getUser(userid);
    set("sysUser", sysUser);

    // 也显示全国律协的以及系统层级的

    System.out.println("===================" + sysUser.getCityid());
    this.datavisible.setProvinceid(sysUser.getProvinceid());
    this.datavisible.setCityid(sysUser.getCityid());
    this.datavisible.setOfficeid(sysUser.getOfficeid());

    this.datavisible.getVisibleDatas(this.getLoginUser(), true);

    SysRole sysrole = this.getLoginUser().getSysRole();
    if (sysrole != null) {
      BasicService bs = (BasicService) this.getBean("basicService");
      DetachedCriteria dc = DetachedCriteria.forClass(SysRole.class);
      Criterion c1 = null;
      if (sysrole.getCansamegrade()) c1 = Restrictions.ge("gradeid", sysrole.getGradeid());
      else c1 = Restrictions.gt("gradeid", sysrole.getGradeid());
      Criterion c2 = Restrictions.eq("roleid", sysrole.getRoleid());
      dc.add(Restrictions.or(c1, c2));
      allroles = bs.findAllByCriteria(dc);

    } else { // 没角色的话,显示所有的角色
      SysRoleService roleService = (SysRoleService) this.getBean("sysRoleService");
      allroles = roleService.getRoles();
    }

    return INPUT;
  }
Пример #17
0
  /**
   * Search Value2 by detached criteria Test
   *
   * @throws ApplicationException
   */
  @SuppressWarnings("unchecked")
  public void testIvlRealValue3ByDetachedCriteria() throws ApplicationException {
    DetachedCriteria criteria = DetachedCriteria.forClass(IvlRealDataType.class);
    LogicalExpression exp1 =
        Restrictions.or(
            Property.forName("value3.high.value").isNotNull(),
            Property.forName("value3.low.value").isNotNull());
    LogicalExpression exp2 =
        Restrictions.or(
            Property.forName("value3.width.value").isNotNull(),
            Property.forName("value3.width.nullFlavor").isNotNull());
    LogicalExpression exp3 = Restrictions.or(exp1, exp2);
    criteria.add(Restrictions.or(Property.forName("value3.nullFlavor").isNotNull(), exp3));

    criteria.addOrder(Order.asc("id"));

    Collection<IvlRealDataType> result =
        search(criteria, "gov.nih.nci.cacoresdk.domain.other.datatype.IvlRealDataType");
    assertEquals(10, result.size());
    List index = new ArrayList();
    index.add("13");
    index.add("14");
    index.add("15");
    index.add("16");
    index.add("17");
    index.add("18");
    index.add("19");
    index.add("20");
    index.add("21");
    index.add("22");
    assertValue3(result, index);
  }
Пример #18
0
  /*
   * (non-Javadoc)
   * @see com.lzcp.service.ServiceAlbum#getAlbumByCategoryId(java.lang.String)
   */
  @Override
  public List<ModelAlbum> getAlbumByCategoryId(String categoryId, String parentEntryId)
      throws ServiceException {
    // if (UtilString.isNotEmpty(categoryId))
    // {
    try {
      DetachedCriteria criteria = DetachedCriteria.forClass(ModelAlbum.class);

      if (UtilString.isNotEmpty(categoryId)) {
        criteria.createCriteria("category").add(Restrictions.eq("id", categoryId));
      }

      if (UtilString.isNotEmpty(parentEntryId)) {
        criteria.createCriteria("parentEntry").add(Restrictions.eq("id", parentEntryId));
      }

      return this.daoAlbum.getListByCriteria(criteria);
    } catch (DAOException e) {
      LOGGER.error("It failed to obtain the album with category id: " + categoryId, e);
    } catch (Exception e) {
      throw new ServiceException(
          "It failed to obtain the album with category id: " + categoryId, e);
    }
    // }

    return null;
  }
Пример #19
0
 /**
  * 构建 查询条件
  *
  * @param clazz
  * @return
  */
 public DetachedCriteria toCriteria(Class<?> clazz) {
   DetachedCriteria criteria = DetachedCriteria.forClass(clazz, "entity");
   for (WhereCondition con : cons) {
     criteria.add(con.getCriterion());
   }
   return criteria;
 }
Пример #20
0
  @Override
  public List<ThesaurusConcept> getPaginatedAvailableConceptsOfGroup(
      Integer startIndex,
      Integer limit,
      String groupId,
      String thesaurusId,
      Boolean onlyValidatedConcepts,
      String like) {

    DetachedCriteria dc = DetachedCriteria.forClass(ThesaurusConceptGroup.class, "gr");
    dc.createCriteria("concepts", "tc", JoinType.RIGHT_OUTER_JOIN);
    dc.setProjection(Projections.projectionList().add(Projections.property("tc.identifier")));
    dc.add(Restrictions.eq("gr.identifier", groupId));

    Criteria criteria = selectPaginatedConceptsByAlphabeticalOrder(startIndex, limit);
    criteria.add(Subqueries.propertyNotIn("tc.identifier", dc));

    selectThesaurus(criteria, thesaurusId);
    criteria.add(
        Restrictions.not(
            Restrictions.and(
                Restrictions.eq("topConcept", false),
                Restrictions.or(
                    Restrictions.isNull("tc.parentConcepts"),
                    Restrictions.isEmpty("tc.parentConcepts")))));

    if (null != like) {
      conceptNameIsLike(criteria, like);
    }
    onlyValidatedConcepts(criteria, onlyValidatedConcepts);

    return criteria.list();
  }
 public List<Standard> selectByType(String type) {
   List<Standard> get = null;
   DetachedCriteria criteria = DetachedCriteria.forClass(Standard.class);
   criteria.add(Restrictions.eq("type", type));
   get = (List<Standard>) this.hibernateTemplate.findByCriteria(criteria);
   return get;
 }
 @Override
 protected void setReferenceDataModel(ReferenceDataModel refDataModel, PackageLine entity) {
   super.setReferenceDataModel(refDataModel, entity);
   DetachedCriteria dc = daoHelper.getDao(Item.class).getCriteria();
   dc.add(Restrictions.eq("product", entity.getProduct()));
   refDataModel.putRefDataList(REF_ITEMS, daoHelper.getDao(Item.class).findByCriteria(dc));
 }
Пример #23
0
  @Override
  public int getFormsCount(Person owner) {
    DetachedCriteria criteria = DetachedCriteria.forClass(type);
    criteria.setProjection(Projections.distinct(Projections.countDistinct("formName")));
    if (owner != null) criteria.add(Restrictions.eq("person.personId", owner.getPersonId()));

    return DataAccessUtils.intResult(getHibernateTemplate().findByCriteria(criteria));
  }
 /** Use this inside subclasses as a convenience method. */
 @SuppressWarnings("unchecked")
 protected List<T> findByCriteria(Criterion... detachedCriterias) {
   DetachedCriteria crit = DetachedCriteria.forClass(persistentClass);
   for (Criterion c : detachedCriterias) {
     crit.add(c);
   }
   return getHibernateTemplate().findByCriteria(crit);
 }
Пример #25
0
 /**
  * Return a {@link SocialAccount} by id and {@link Account}.
  *
  * @param socialAccountId
  * @param account
  * @return
  */
 @SuppressWarnings("unchecked")
 public final SocialAccount getSocialAccount(final Long socialAccountId, final Account account) {
   final DetachedCriteria criteria = DetachedCriteria.forClass(SocialAccount.class);
   criteria.add(Restrictions.eq("account", account));
   criteria.add(Restrictions.eq("id", socialAccountId));
   return (SocialAccount)
       DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
 }
  public boolean isExsitsByPrivilNameOrPattern(String privilName, String pattern) {
    DetachedCriteria dc = super.getDetachedCriteria();
    dc.add(
        Restrictions.or(
            Restrictions.eq("privilName", privilName), Restrictions.eq("pattern", pattern)));

    return super.findList(dc).size() > 0;
  }
Пример #27
0
 public Estado getEstadoBySigla(String sigla) {
   DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Estado.class);
   detachedCriteria.add(Restrictions.ilike("sigla", sigla));
   Estado estado = new Estado();
   estado = Dao().getEntityByDetachedCriteria(detachedCriteria);
   System.out.println("sigla " + sigla);
   return estado;
 }
Пример #28
0
  public List<Cliente> buscaCliente(Long id) {

    DetachedCriteria dc = DetachedCriteria.forClass(Cliente.class);
    dc.add(Restrictions.eq("id", id));
    List<Cliente> lista = listar(dc);

    return lista;
  }
  public List<String> getElementsOrderByWeight(User u) {
    DetachedCriteria det = DetachedCriteria.forClass(RecipientFavourite.class);
    det.add(Restrictions.eq("owner", u));
    det.addOrder(Order.asc("weight"));
    List<RecipientFavourite> listElement = findByCriteria(det);

    return transformRecipientFavouriteToRecipient(listElement);
  }
Пример #30
0
 @RequestMapping(value = "/leavepolicy/admin/edit/{id}", method = RequestMethod.GET)
 public String getCreateForm(@PathVariable Long id, Model model) {
   DetachedCriteria dc = DetachedCriteria.forClass(LeavePolicy.class);
   dc.add(Restrictions.idEq(id));
   LeavePolicy lp = service.get(dc);
   model.addAttribute("leavePolicy", lp);
   return "leavepolicy/edit";
 }