Esempio n. 1
0
  public Page<Log> find(Page<Log> page, Map<String, Object> paramMap) {
    DetachedCriteria dc = logDao.createDetachedCriteria();

    Long createById = StringUtils.toLong(paramMap.get("createById"));
    if (createById > 0) {
      dc.add(Restrictions.eq("createBy.id", createById));
    }

    String requestUri = ObjectUtils.toString(paramMap.get("requestUri"));
    if (StringUtils.isNotBlank(requestUri)) {
      dc.add(Restrictions.like("requestUri", "%" + requestUri + "%"));
    }

    String exception = ObjectUtils.toString(paramMap.get("exception"));
    if (StringUtils.isNotBlank(exception)) {
      dc.add(Restrictions.eq("type", Log.TYPE_EXCEPTION));
    }

    Date beginDate = DateUtils.parseDate(paramMap.get("beginDate"));
    if (beginDate == null) {
      beginDate = DateUtils.setDays(new Date(), 1);
      paramMap.put("beginDate", DateUtils.formatDate(beginDate, "yyyy-MM-dd"));
    }
    Date endDate = DateUtils.parseDate(paramMap.get("endDate"));
    if (endDate == null) {
      endDate = DateUtils.addDays(DateUtils.addMonths(beginDate, 1), -1);
      paramMap.put("endDate", DateUtils.formatDate(endDate, "yyyy-MM-dd"));
    }
    dc.add(Restrictions.between("createDate", beginDate, endDate));

    dc.addOrder(Order.desc("id"));
    return logDao.find(page, dc);
  }
Esempio n. 2
0
  /**
   * Tìm kiếm nhanh
   *
   * @param idHangDienThoai id của HangDienThoai.
   * @param ten tên DienThoai.
   * @param giaTu giá chặn dưới.
   * @param giaDen giá chặn trên.
   * @return Danh sách DienThoai thỏa tiêu chí tìm kiếm.
   */
  @SuppressWarnings("unchecked")
  public List<DienThoai> quickSearch(int idHangDienThoai, String ten, double giaTu, double giaDen) {

    Session session = factory.getCurrentSession();
    Criteria criteria = session.createCriteria(DienThoai.class);

    if (idHangDienThoai > 0) {
      Criterion manufacture = Restrictions.eq("hangDienThoai.id", idHangDienThoai);
      criteria.add(manufacture);
    }

    if (ten != null) {
      Criterion name = Restrictions.like("ten", "%" + ten + "%");
      criteria.add(name);
    }

    if (giaTu >= 0.0) {
      Criterion minPrice = Restrictions.ge("giaHienHanh", giaTu);
      criteria.add(minPrice);
    }

    if (giaDen >= 0.0) {
      Criterion maxPrice = Restrictions.le("giaHienHanh", giaDen);
      criteria.add(maxPrice);
    }
    criteria.add(Restrictions.eq("xoa", false));

    return criteria.list();
  }
Esempio n. 3
0
 @Override
 public VerifyPO get(long uid, int type) {
   Criteria c = createCriteria();
   c.add(Restrictions.eq("uid", uid));
   c.add(Restrictions.eq("type", type));
   return (VerifyPO) c.uniqueResult();
 }
 @Override
 @SuppressWarnings("unchecked")
 public List<ProgramInstance> get(TrackedEntityInstance entityInstance, Program program) {
   return getCriteria(
           Restrictions.eq("entityInstance", entityInstance), Restrictions.eq("program", program))
       .list();
 }
Esempio n. 5
0
 public static Group findByOrgAndName(Organisation org, String name, Session session) {
   Criteria crit = session.createCriteria(Group.class);
   crit.setCacheable(true);
   crit.add(Restrictions.eq("organisation", org));
   crit.add(Restrictions.eq("name", name));
   return (Group) crit.uniqueResult();
 }
 private Criteria getHBCriteria(Session session, SearchCriteria criteria) {
   Criteria newCriteria = session.createCriteria(WarrantyInformationType.class);
   if (criteria.getInternalId() != null) {
     newCriteria.add(Restrictions.eq("internalId", criteria.getInternalId()));
   }
   if ((criteria.ascending != null) && (criteria.ascending.contains("internalId")))
     newCriteria.addOrder(Order.asc("internalId"));
   else if ((criteria.descending != null) && (criteria.descending.contains("internalId")))
     newCriteria.addOrder(Order.desc("internalId"));
   if (criteria.getVersion() != null) {
     newCriteria.add(Restrictions.eq("version", criteria.getVersion()));
   }
   if ((criteria.ascending != null) && (criteria.ascending.contains("version")))
     newCriteria.addOrder(Order.asc("version"));
   else if ((criteria.descending != null) && (criteria.descending.contains("version")))
     newCriteria.addOrder(Order.desc("version"));
   if (criteria.getValue() != null) {
     newCriteria.add(Restrictions.eq("value", criteria.getValue()));
   }
   if ((criteria.ascending != null) && (criteria.ascending.contains("value")))
     newCriteria.addOrder(Order.asc("value"));
   else if ((criteria.descending != null) && (criteria.descending.contains("value")))
     newCriteria.addOrder(Order.desc("value"));
   if (criteria.getLanguageID() != null) {
     newCriteria.add(Restrictions.eq("languageID", criteria.getLanguageID()));
   }
   if ((criteria.ascending != null) && (criteria.ascending.contains("languageID")))
     newCriteria.addOrder(Order.asc("languageID"));
   else if ((criteria.descending != null) && (criteria.descending.contains("languageID")))
     newCriteria.addOrder(Order.desc("languageID"));
   return newCriteria;
 }
  @SuppressWarnings("unchecked")
  public List<DeliveryOrder> getUnexportDeliveryOrderByPlant(Plant plant) {
    DetachedCriteria criteria = DetachedCriteria.forClass(DeliveryOrder.class);
    criteria.createAlias("plantSupplier", "ps");

    criteria.add(Restrictions.eq("ps.plant", plant));
    criteria.add(Restrictions.eq("isPrint", true));
    criteria.add(Restrictions.eq("isExport", false));
    criteria.add(Restrictions.eq("status", "Confirm"));
    criteria.add(Restrictions.eq("ps.needExportDo", true));
    criteria.addOrder(Order.asc("createDate"));

    List<DeliveryOrder> deliveryOrderList = this.findByCriteria(criteria);

    if (deliveryOrderList != null && deliveryOrderList.size() > 0) {
      for (int i = 0; i < deliveryOrderList.size(); i++) {
        DeliveryOrder deliveryOrder = deliveryOrderList.get(i);

        if (deliveryOrder.getDeliveryOrderDetailList() != null
            && deliveryOrder.getDeliveryOrderDetailList().size() > 0) {}
      }
    }

    return deliveryOrderList;
  }
  private DetachedCriteria createActivityCriteria(Activity activity, String matchType) {
    DetachedCriteria criteria = DetachedCriteria.forClass(Activity.class);
    if (activity.getActivityName() != null) {
      if (matchType.equalsIgnoreCase("exact")) {
        criteria.add(
            Restrictions.eq("activityName", "" + activity.getActivityName() + "").ignoreCase());
      } else {
        criteria.add(
            Restrictions.like("activityName", "%" + activity.getActivityName() + "%").ignoreCase());
      }
    }
    if (activity.getActivityDescription() != null) {
      criteria.add(
          Restrictions.like("activityDescription", "%" + activity.getActivityDescription() + "%")
              .ignoreCase());
    }
    if (activity.getIsActive() != null) {
      /*criteria.add(Restrictions.like("isActive",
      "%" + activity.getIsActive() + "%").ignoreCase());*/
      criteria.add(Restrictions.eq("isActive", "" + activity.getIsActive() + ""));
    }
    if (activity.getOrganization() != null) {
      criteria.add(Restrictions.eq("organization", activity.getOrganization()));
    }

    return criteria;
  }
Esempio n. 9
0
 public StorageDevice getDeviceById(final Integer datacenterId, final Integer deviceId) {
   Criteria criteria =
       createCriteria(Restrictions.eq("datacenter.id", datacenterId))
           .add(Restrictions.eq("id", deviceId));
   Object obj = criteria.uniqueResult();
   return (StorageDevice) obj;
 }
  @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";
  }
Esempio n. 11
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();
  }
  @Secured({"ROLE_DEVELOPER", "ROLE_TESTER"})
  @RequestMapping("goAddBug.htm")
  public ModelAndView goAddBug(HttpServletRequest request) {

    Company company = (Company) request.getSession().getAttribute("company");
    DetachedCriteria dCriteria = DetachedCriteria.forClass(Project.class);
    dCriteria.add(Restrictions.eq("company", company));
    List<Project> projectList = aService.queryAllOfCondition(Project.class, dCriteria);

    DetachedCriteria dCriteria1 = DetachedCriteria.forClass(Department.class);
    dCriteria1.add(Restrictions.eq("company", company));
    List<Department> deptList = aService.queryAllOfCondition(Department.class, dCriteria1);

    DetachedCriteria dCriteria2 = DetachedCriteria.forClass(Developer.class);
    dCriteria2.createCriteria("user").add(Restrictions.in("department", deptList));
    List<Developer> userList = aService.queryAllOfCondition(Developer.class, dCriteria2);

    DetachedCriteria dCriteria3 = DetachedCriteria.forClass(User.class);
    dCriteria3.add(Restrictions.in("department", deptList));
    List<User> userList1 = aService.queryAllOfCondition(User.class, dCriteria3);

    ModelMap map = new ModelMap();
    map.put("projectList", projectList);
    map.put("userList", userList);
    map.put("userList1", userList1);

    return new ModelAndView("/bug/addBug", map);
  }
  @Test
  @SuppressWarnings("unchecked")
  public void testGrantAllResourceToDept() throws Exception {
    // 岗位ID
    String deptId = "8a8140ef4c112cf6014c112d6efd0000";

    // 查询出所有有效的菜单的ID(在权限表中,资源的id对应的是菜单的id)
    List<String> resourceIds =
        session
            .createCriteria(Menu.class)
            .setProjection(Projections.id())
            .add(Restrictions.eq("status", CommonStatus.ACTIVE.getValue()))
            .add(Restrictions.eq("show", true))
            .list();
    Assert.assertNotNull("没有查询到菜单资源数据!", resourceIds);
    Assert.assertTrue("没有查询到菜单资源数据!", !resourceIds.isEmpty());

    logger.info("开始将[菜单资源]授予岗位:" + deptId);
    int i = 0;
    for (String id : resourceIds) {
      AccreditMenu accreditMenu = new AccreditMenu();
      accreditMenu.setResourceId(id);
      accreditMenu.setDeptId(deptId);
      accreditMenu.setId(UUIDGenerator.generate());
      session.save(accreditMenu);
      if (i++ % 10 == 0) {
        session.flush();
        session.clear();
      }
    }
  }
  @SuppressWarnings("unchecked")
  @Override
  public List<PersonneStatut> rechercherStatutParCriteres(DimensionCriteresRechercheDto criteres) {

    final Criteria criteria = createCriteria(PersonneStatut.class);

    // Critère sur l'identifiant
    if (criteres.getId() != null) {
      criteria.add(Restrictions.eq("id", criteres.getId()));
    }
    // Critère sur le libelle
    if (criteres.getLibelle() != null && !criteres.getLibelle().equals("")) {
      criteria.add(Restrictions.ilike("libelle", criteres.getLibelle().toLowerCase() + "%"));
    }
    // Critère sur la visibilité
    if (criteres.getVisible() != null) {
      criteria.add(Restrictions.eq("visible", criteres.getVisible()));
    }
    // Maxresults
    if (criteres.getMaxResults() != null) {
      criteria.setFirstResult(0);
      criteria.setMaxResults(criteres.getMaxResults());
    }
    // Ordonner les éléments
    criteria.addOrder(Order.asc("ordre"));
    criteria.addOrder(Order.asc("libelle"));

    return criteria.list();
  }
Esempio n. 15
0
  @RequestMapping("/self/message/list")
  public String listMessage(
      String type,
      Integer pageNum,
      Integer pageSize,
      Model model,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    User user = getCurrentUser();
    EntityView ev = new EntityView();
    Boolean sendbox = false;
    if (StringUtils.isNotBlank(type) && type.equals("send")) {
      sendbox = true;
      ev.add(Restrictions.eq("sender", user.getUserId()));
    } else {
      ev.add(Restrictions.eq("receiver", user.getUserId()));
    }

    PageContext<Message> pageCtx = messageMng.queryUsePage(ev, pageNum, 10);
    model.addAttribute("pageCtx", pageCtx);
    model.addAttribute("sendbox", sendbox);
    return "self/message/list";
  }
Esempio n. 16
0
 public StorageDevice findDeviceById(final Integer datacenterId, final String managementIp) {
   Criteria criteria =
       createCriteria(Restrictions.eq("datacenter.id", datacenterId))
           .add(Restrictions.eq("managementIp", managementIp));
   Object obj = criteria.uniqueResult();
   return (StorageDevice) obj;
 }
  @Override
  public Long countParceirosInscritos(
      Integer idCursoSelecionado, Integer idGradeOficina, List<Integer> idsParceiros) {

    List<Integer> idsStatus = new ArrayList<Integer>();
    idsStatus.add(Status.CANCELADO);
    idsStatus.add(Status.AGUARDANDO_VAGA_PRIORIDADE);
    idsStatus.add(Status.AGUARDANDO_VAGA);

    Criteria criteria = getSession().createCriteria(InscricaoGrade.class);
    criteria.createAlias("inscricaoCurso", "ic");
    criteria.createAlias("ic.curso", "c");
    criteria.add(Restrictions.eq("c.id", idCursoSelecionado));
    criteria.createAlias("ic.ultimoStatus", "us");
    criteria.createAlias("us.status", "s");
    criteria.add(Restrictions.not(Restrictions.in("s.id", idsStatus)));
    criteria.createAlias("gradeOficina", "go");
    criteria.add(Restrictions.eq("go.id", idGradeOficina));
    if (idsParceiros != null && !idsParceiros.isEmpty()) {
      criteria.createAlias("ic.candidato", "cand");
      criteria.add(Restrictions.in("cand.id", idsParceiros));
    }
    criteria.setProjection(Projections.rowCount());
    Long result = (Long) criteria.list().get(0);
    return result;
  }
Esempio n. 18
0
  public ArrayList<Election> getElectionByConstituency(Long constituency) {
    Session session = null;

    ArrayList<Election> eleclist = new ArrayList<Election>();
    Criteria ctr, tempctr;
    try {
      session = getSessionFactory().openSession();
      ctr = session.createCriteria(Locations.class);
      ctr.add(Restrictions.eq("constituency", constituency));
      for (int i = 0; ctr.list().size() > 0 && i < ctr.list().size(); i++) {
        tempctr = session.createCriteria(Election.class);
        tempctr.add(Restrictions.eq("validity", Election.NOTDONE));
        tempctr.add(Restrictions.idEq(((Locations) ctr.list().get(i)).getElecid()));
        tempctr.add(Restrictions.le("start", new Timestamp(new Date().getTime())));
        tempctr.add(Restrictions.ge("end", new Timestamp(new Date().getTime())));
        if (tempctr.list().size() > 0) eleclist.add((Election) tempctr.list().get(0));
      }

    } catch (HibernateException e) {
      System.err.println("Error: file: LocationsDAO method: getNumOfCOnsti()");
    } finally {
      if (session != null) session.close();
    }

    return eleclist;
  }
Esempio n. 19
0
  /**
   * 查询一个对象的属性值在数据库中是不是唯一
   *
   * @param entity 实体对象
   * @param propertyNames 属性的名称,可多个 如:"prop1,prop2"
   * @return 针对 编辑 对象保存时 如果和其它 对象 属性名称相同 抛出异常问题 重写此方法
   */
  public boolean isUnique(Object entity, String propertyNames) {
    Class<?> clazz = getTrueClass(entity);
    Criteria criteria = createCriteria(clazz).setProjection(Projections.rowCount());
    String[] nameList = propertyNames.split(",");
    try {
      boolean isQuery = false;
      for (String name : nameList) {
        Object obj = PropertyUtils.getProperty(entity, name);
        if (obj != null) {
          criteria.add(Restrictions.eq(name, obj));
          isQuery = true;
        } else {
          isQuery = false;
        }
      }
      if (!isQuery) {
        return true;
      }

      String idName = getIdName(clazz);
      Serializable id = getId(clazz, entity);
      if (id != null) {
        criteria.add(Restrictions.not(Restrictions.eq(idName, id)));
      }
    } catch (Exception e) {
      ReflectionUtils.handleReflectionException(e);
    }
    this.getSession().evict(entity);
    return (Integer) criteria.uniqueResult() == 0;
  }
Esempio n. 20
0
  public ArrayList<Candidate> getNumOfCandidateConstituency(Long constituency, String elecid) {
    Session session = null;
    ArrayList<String> numcon = new ArrayList<String>();
    ArrayList<Candidate> numcan = new ArrayList<Candidate>();
    Criteria ctr;
    try {
      session = getSessionFactory().openSession();
      ctr = session.createCriteria(Locations.class);
      ctr.add(Restrictions.eq("elecid", elecid));
      ctr.add(Restrictions.eq("constituency", constituency));
      if (ctr.list().size() > 0) {
        ctr = session.createCriteria(Candidate.class);
        ctr.add(Restrictions.eq("constituency", constituency));
        ctr.add(Restrictions.eq("validity", Candidate.ACCEPTED));
        for (int i = 0; ctr.list().size() > 0 && i < ctr.list().size(); i++)
          numcan.add((Candidate) ctr.list().get(i));
      }

    } catch (HibernateException e) {
      System.err.println("Error: file: LocationsDAO method: getNumOfCOnsti()");
    } finally {
      if (session != null) session.close();
    }

    return numcan;
  }
 public PagingWrapper<ChallengeChallengeReferral> getAllforChallengeReferralAndChallenge(
     final UUID challengeReferralId, final UUID challengeId, final SortingAndPaging sAndP) {
   final Criteria query = createCriteria();
   query.add(Restrictions.eq("challengeReferral.id", challengeReferralId));
   query.add(Restrictions.eq("challenge.id", challengeId));
   return processCriteriaWithStatusSortingAndPaging(query, sAndP);
 }
  @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);
  }
  @Override
  @SuppressWarnings("unchecked")
  public List<ProgramInstance> getByStatus(
      ProgramStatus status,
      Program program,
      Collection<Integer> orgunitIds,
      Date startDate,
      Date endDate,
      Integer min,
      Integer max) {
    Criteria criteria =
        getCriteria(
                Restrictions.eq("program", program),
                Restrictions.between("enrollmentDate", startDate, endDate))
            .createAlias("entityInstance", "entityInstance")
            .createAlias("entityInstance.organisationUnit", "organisationUnit")
            .add(Restrictions.in("organisationUnit.id", orgunitIds))
            .add(Restrictions.eq("status", status));

    if (min != null) {
      criteria.setFirstResult(min);
    }

    if (max != null) {
      criteria.setMaxResults(max);
    }

    return criteria.list();
  }
Esempio n. 24
0
  @SuppressWarnings("unchecked")
  @Override
  public Object tryAndFindLookupValue(
      final String systemName,
      final String tableName,
      final String columnName,
      final String lookupValue)
      throws ClassNotFoundException {

    final List<PhysicalToPhysicalLookupView> physicalLookups =
        getSession()
            .createCriteria(PhysicalToPhysicalLookupView.class)
            .add(Restrictions.eq("id.systemName", systemName))
            .add(Restrictions.eq("id.tableName", tableName))
            .add(Restrictions.eq("id.columnNume", columnName))
            .list();

    if (physicalLookups == null || physicalLookups.size() != 2) {
      // do nothing - return a warning if > 2
      return null;
    }

    String lookupSystem = "";
    String lookupTable = "";
    String lookupColumn = "";
    String projection = "";

    for (final PhysicalToPhysicalLookupView lookup : physicalLookups) {
      if (lookup.getId().getNameRuleType().equals(LOOKUP_KEY)) {
        lookupSystem = lookup.getId().getSystemName();
        lookupTable = lookup.getId().getLookupTable();
        lookupColumn = lookup.getId().getLookupColumn();
      }
      if (lookup.getId().getNameRuleType().equals(LOOKUP_VALUE)) {
        projection = lookup.getId().getLookupColumn();
      }
    }

    if (lookupSystem == null || lookupTable == null || lookupColumn == null || projection == null) {
      throw new RuntimeException(
          "Unable to create a lookup map for system name: "
              + systemName
              + " on table "
              + tableName
              + " with column "
              + columnName);
    }

    final Class<?> clazz = null; // explorer.getClass(lookupTable,
    // systemName.toLowerCase(),"com.equityopschange.systems");

    final Object lookedUpValue =
        getSession()
            .createCriteria(clazz)
            .add(Restrictions.eq(lookupColumn, lookupValue))
            .setProjection(Projections.property(projection))
            .uniqueResult();

    return lookedUpValue;
  }
Esempio n. 25
0
 /**
  * Xử lý các tiêu chí tìm kiếm theo multi-media
  *
  * @param criteria Bộ lọc tiêu chí
  * @param c Tiêu chí tìm kiếm theo multi-media
  */
 private void processMediaCriteria(Criteria criteria, MediaCriteria c) {
   if (c.getHasFMRadio()) {
     criteria.add(Restrictions.eq("multiMedia.FMRadio", true));
   }
   if (c.getHasGame()) {
     criteria.add(Restrictions.isNotNull("multiMedia.troChoi"));
   }
   if (c.getHasJavaApps()) {
     criteria.add(Restrictions.eq("javaApp", true));
   }
   if (c.getHasMusicPlayer()) {
     criteria.add(Restrictions.isNotNull("multiMedia.ngheNhac"));
   }
   if (c.getHasOfficeApps()) {
     criteria.add(Restrictions.eq("office", true));
   }
   if (c.getHasTivi()) {
     criteria.add(Restrictions.eq("multiMedia.xemTivi", true));
   }
   if (c.getHasVideoPlayer()) {
     criteria.add(Restrictions.isNotNull("multiMedia.xemPhim"));
   }
   if (c.getHasVideoRecorder()) {
     criteria.add(Restrictions.isNotNull("multiMedia.quayPhim"));
   }
   if (c.getHasVoiceRecorder()) {
     criteria.add(Restrictions.isNotNull("multiMedia.ghiAm"));
   }
 }
Esempio n. 26
0
 public Sample getSample(Long projectId, String sampleName, Session session) throws DAOException {
   Sample retVal = null;
   try {
     Criteria crit = session.createCriteria(Sample.class);
     crit.add(
         Restrictions.and(
             Restrictions.eq("sampleName", sampleName), Restrictions.eq("projectId", projectId)));
     List results = crit.list();
     if (results != null) {
       if (results.size() == 1) {
         retVal = (Sample) results.get(0);
       } else if (results.size() > 1) {
         throw new DAOException(
             "Found "
                 + results.size()
                 + " samples for sample name "
                 + sampleName
                 + " but expected only 1.");
       }
     }
   } catch (Exception ex) {
     throw new DAOException(ex);
   }
   return retVal;
 }
Esempio n. 27
0
  /**
   * Tìm kiếm nhanh
   *
   * @param c Tiêu chí tìm kiếm
   * @return Danh sách các điện thoại thỏa tiêu chí tìm kiếm
   */
  @SuppressWarnings("unchecked")
  public List<DienThoai> quickSearch(QuickSearchCriteria c) {

    Session session = factory.getCurrentSession();
    Criteria criteria = session.createCriteria(DienThoai.class);

    if (c.getIdHangDienThoai() > 0) {
      Criterion manufacture = Restrictions.eq("hangDienThoai.id", c.getIdHangDienThoai());
      criteria.add(manufacture);
    }

    if (c.getTenDienThoai() != null) {
      Criterion name = Restrictions.like("ten", "%" + c.getTenDienThoai() + "%");
      criteria.add(name);
    }

    if (c.getGiaTu() >= 0.0) {
      Criterion minPrice = Restrictions.ge("giaHienHanh", c.getGiaTu());
      criteria.add(minPrice);
    }

    if (c.getGiaDen() >= 0.0) {
      Criterion maxPrice = Restrictions.le("giaHienHanh", c.getGiaDen());
      criteria.add(maxPrice);
    }
    criteria.add(Restrictions.eq("xoa", false));

    return criteria.list();
  }
Esempio n. 28
0
 public List getChildPersons(String userId, boolean withSelfUser) {
   Criteria objCriteria = null;
   Session objSession = null;
   List objList = null;
   try {
     logger.info("GETTING ALL USERS");
     objSession = HibernateUtil.getSession();
     objCriteria =
         objSession.createCriteria(UsersVO.class).add(Restrictions.eq("valid", new Boolean(true)));
     if (withSelfUser)
       objCriteria.add(
           Restrictions.or(
               Restrictions.eq("userId", userId), Restrictions.eq("parentUser.userId", userId)));
     else objCriteria.add(Restrictions.eq("parentUser.userId", userId));
     objCriteria.addOrder(Order.asc("userId"));
     objList = objCriteria.list();
     logger.info("GET ALL USERS ENDS");
   } catch (HibernateException e) {
     logger.error("HIBERNATE EXCEPTION DURING GET ALL USERS", e);
     e.printStackTrace();
   } finally {
     if (objSession != null) {
       objSession.close();
     }
   }
   return objList;
 }
Esempio n. 29
0
 public EnhancedRule setRule(EnhancedRule rule, BlogCommentQuery query) {
   if (query != null) {
     if (query.name != null) {
       rule.add(Restrictions.like("name", query.name, MatchMode.ANYWHERE));
     }
     if (query.content != null) {
       rule.add(Restrictions.like("content", query.content, MatchMode.ANYWHERE));
     }
     if (query.email != null) {
       rule.add(Restrictions.like("email", query.email, MatchMode.ANYWHERE));
     }
     if (query.im != null) {
       rule.add(Restrictions.like("im", query.im, MatchMode.ANYWHERE));
     }
     if (query.ip != null) {
       rule.add(Restrictions.like("ip", query.ip, MatchMode.ANYWHERE));
     }
     if (query.website != null) {
       rule.add(Restrictions.like("website", query.website, MatchMode.ANYWHERE));
     }
     if (query.userId != null) {
       rule.add(Restrictions.eq("user.id", query.userId));
     }
     if (query.blogId != null) {
       rule.add(Restrictions.eq("blog.id", query.blogId));
     }
     if (query.getOrder() != null) {
       rule.addOrder(query.getDesc() ? Order.desc(query.getOrder()) : Order.asc(query.getOrder()));
     }
   }
   return rule;
 }
Esempio n. 30
0
 public StoragePool findPoolById(final Integer deviceId, final String poolId) {
   Criteria criteria =
       createCriteria(Restrictions.eq("device.id", deviceId))
           .add(Restrictions.eq("idStorage", poolId));
   Object obj = criteria.uniqueResult();
   return (StoragePool) obj;
 }