/* * (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; }
@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); }
/* * (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; }
private List<GeneralSeries> getSeriesList( List<String> seriesUids, List<SiteData> authorizedPublicSites) { DetachedCriteria criteria = DetachedCriteria.forClass(GeneralSeries.class); criteria.add(Restrictions.in("seriesInstanceUID", seriesUids)); criteria.add(Restrictions.eq("visibility", "1")); criteria = criteria.createCriteria("study"); criteria = criteria.createCriteria("patient"); criteria = criteria.createCriteria("dataProvenance"); if (authorizedPublicSites != null) { setAuthorizedSiteData(criteria, authorizedPublicSites); } List<GeneralSeries> seriesList = getHibernateTemplate().findByCriteria(criteria); return seriesList; }
/* (non-Javadoc) * @see cn.commonframework.util.BaseDAO#getAllByExample(java.lang.Object) */ @SuppressWarnings("unchecked") @Override public List<Structure> getAllByExample(Structure structure) { DetachedCriteria criteria = DetachedCriteria.forClass(Structure.class); criteria.add( Example.create(structure).ignoreCase().enableLike(MatchMode.ANYWHERE).excludeZeroes()); if (structure.getParentOrgan() != null) { criteria.createCriteria("parentOrgan").add(Example.create(structure.getParentOrgan())); } return this.getHibernateTemplate().findByCriteria(criteria); }
@Override public Page getFixedShippingOrder(Warehouse warehouse, String status, int pageNo, int perPage) { DetachedCriteria criteria = DetachedCriteria.forClass(FixedShippingOrder.class); if (warehouse != null) { DetachedCriteria whCriteria = criteria.createCriteria("shippingOrder"); whCriteria.add(Restrictions.eq("warehouse", warehouse)); } if (StringUtils.isNotBlank(status)) { criteria.add(Restrictions.eq("status", status)); } criteria.addOrder(org.hibernate.criterion.Order.desc("createDate")); return list(criteria, pageNo, perPage); }
public PaginatedList<Keyword> findKeywords( Keyword keyword, final boolean ignoreCase, final Order order, final Integer firstResult, final Integer maxResults) throws IllegalArgumentException { if (keyword == null) { throw new IllegalArgumentException("keyword cannot be null"); } final MatchMode matchMode = MatchMode.ANYWHERE; Example criterionKeyword = Example.create(keyword); criterionKeyword.enableLike(matchMode); if (ignoreCase) { criterionKeyword.ignoreCase(); } // Normally, Hibernate performs a left-outer join, when searching for // an object with collections using Criteria. This returns a ResultSet // that contains duplicate objects. In order to get a unique list of // Keywords with paginated support, we need to a nested query to find // distinct matching ids, then get the Keywords. The end result is a // subselect in the main query, but only one query is sent. DetachedCriteria dc = DetachedCriteria.forClass(Keyword.class); dc.add(criterionKeyword); dc.setResultTransformer(DISTINCT_ROOT_ENTITY); Conjunction conjunction = createTranslationConditions(keyword.getTranslations(), ignoreCase, matchMode); if (conjunction != null) dc.createCriteria(FIELD_TRANSLATIONS).add(conjunction); dc.setProjection(Projections.id()); Criteria criteria = getSession().createCriteria(Keyword.class); criteria.add(Subqueries.propertyIn(FIELD_ID, dc)); if (Order.desc == order) criteria.addOrder(desc(FIELD_KEYWORD)); else criteria.addOrder(asc(FIELD_KEYWORD)); if (firstResult != null) criteria.setFirstResult(firstResult); if (maxResults != null) criteria.setMaxResults(maxResults); final List<Keyword> criteriaList = criteria.list(); int maxListSize = 0; if (criteriaList.size() > 0) { maxListSize = calculateMaxListSize(criterionKeyword, conjunction); } return new PaginatedList<Keyword>(criteriaList, maxListSize); }
@Secured({"ROLE_TESTER"}) @RequestMapping("goBugFromUc.htm") public ModelAndView goBugFromUc(HttpServletRequest request) { String ucId = request.getParameter("usercaseId"); UserCase uc = aService.findById(UserCase.class, Integer.parseInt(ucId)); 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); DetachedCriteria dCriteria4 = DetachedCriteria.forClass(Step.class); dCriteria4.add(Restrictions.eq("userCase", uc)); List<Step> stepList = aService.queryAllOfCondition(Step.class, dCriteria4); ModelMap map = new ModelMap(); map.put("projectList", projectList); map.put("userList", userList); map.put("userList1", userList1); map.put("uc", uc); map.put("stepList", stepList); return new ModelAndView("/usecase/ucToBug", map); }
public void createCriteria(String name, String value) { detachedCriteria.createCriteria(name, value); }
@Override protected DetachedCriteria getCriteriaForView() { DetachedCriteria dc = super.getCriteriaForView(); dc.createCriteria("listProfiles").add(Restrictions.eq("type", PartnerProfileTypeEnum.SUPPLIER)); return dc; }
@Secured({"ROLE_DEVELOPER", "ROLE_TESTER"}) @RequestMapping("goeditBug.htm") public ModelAndView goeditBug(HttpServletRequest request) { String bugId = request.getParameter("bugId"); Bug bug = aService.findById(Bug.class, Integer.parseInt(bugId)); Project project = bug.getModule().getProject(); List<ModuleBean> modulebean = ModuleUtil.getModuleNameList(aService, project); Company company = (Company) request.getSession().getAttribute("company"); DetachedCriteria dCriteria1 = DetachedCriteria.forClass(Project.class); dCriteria1 .add(Restrictions.eq("company", company)) .add(Restrictions.ne("projectId", project.getProjectId())); List<Project> projectList = aService.queryAllOfCondition(Project.class, dCriteria1); DetachedCriteria dCriteria2 = DetachedCriteria.forClass(Version.class); dCriteria2.add(Restrictions.eq("project", project)); List<Version> versionList = aService.queryAllOfCondition(Version.class, dCriteria2); DetachedCriteria dCriteria3 = DetachedCriteria.forClass(AffectedVersion.class); dCriteria3.add(Restrictions.eq("bug", bug)); List<AffectedVersion> avList = aService.queryAllOfCondition(AffectedVersion.class, dCriteria3); List<Version> aList = new ArrayList<Version>(); for (AffectedVersion aversion : avList) { aList.add(aversion.getVersion()); } DetachedCriteria dCriteria5 = DetachedCriteria.forClass(Department.class); dCriteria5.add(Restrictions.eq("company", company)); List<Department> deptList = aService.queryAllOfCondition(Department.class, dCriteria5); DetachedCriteria dCriteria4 = DetachedCriteria.forClass(Developer.class) .add(Restrictions.ne("developerId", bug.getAssignedTo().getDeveloperId())); dCriteria4.createCriteria("user").add(Restrictions.in("department", deptList)); List<Developer> userList = aService.queryAllOfCondition(Developer.class, dCriteria4); DetachedCriteria dCriteria7 = DetachedCriteria.forClass(History.class); dCriteria7 .add(Restrictions.eq("objectId", bug.getBugId())) .add(Restrictions.eq("objectType", "bug")) .addOrder(Order.asc("operateTime")); List<History> hisList = aService.queryAllOfCondition(History.class, dCriteria7); DetachedCriteria dCriteria6 = DetachedCriteria.forClass(User.class); dCriteria6.add(Restrictions.in("department", deptList)); List<User> userList1 = aService.queryAllOfCondition(User.class, dCriteria6); String mailto = bug.getMailto(); String[] name = mailto.split(";"); List<User> userlist = new ArrayList<User>(); for (int i = 0; i < name.length; i++) { User user1 = new User(); user1.setRealName(name[i]); userlist.add(user1); } ModelMap map = new ModelMap(); map.put("bug", bug); map.put("modulebean", modulebean); map.put("projectList", projectList); map.put("versionList", versionList); map.put("userlist", userlist); map.put("userList", userList); map.put("userList1", userList1); map.put("aList", aList); map.put("hisList", hisList); return new ModelAndView("/bug/editBug", map); }
/* (non-Javadoc) * @see com.mg.framework.api.orm.DetachedCriteria#createCriteria(java.lang.String, java.lang.String) */ @Override public DetachedCriteria createCriteria(String associationPath, String alias) { delegate.createCriteria(associationPath, alias); return this; }