List of usage examples for org.hibernate Criteria createCriteria
public Criteria createCriteria(String associationPath) throws HibernateException;
From source file:es.sm2.openppm.core.dao.ProjectDAO.java
License:Open Source License
/** * Consult list of projects by seller/*w ww. ja v a 2 s . c om*/ * * @param seller * @return */ @SuppressWarnings("unchecked") public List<String> findBySeller(Seller seller) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.setProjection(Projections.property(Project.PROJECTNAME)); crit.createCriteria(Project.PROJECTACTIVITIES).createCriteria(Projectactivity.ACTIVITYSELLERS) .add(Restrictions.eq(Activityseller.SELLER, seller)); crit.addOrder(Order.asc(Project.PROJECTNAME)); return crit.list(); }
From source file:es.sm2.openppm.core.dao.ProjectDAO.java
License:Open Source License
public boolean hasPermission(Project project, Employee user, Company company, int tab) { Criteria crit = getSession().createCriteria(getPersistentClass()).setProjection(Projections.rowCount()) .add(Restrictions.idEq(project.getIdProject())); int rol = user.getResourceprofiles().getIdProfile(); if (rol == Constants.ROLE_PMO || rol == Constants.ROLE_FM || rol == Constants.ROLE_LOGISTIC) { crit.add(Restrictions.eq(Project.PERFORMINGORG, user.getPerformingorg())); } else if (rol == Constants.ROLE_PM) { crit.add(Restrictions.eq(Project.EMPLOYEEBYPROJECTMANAGER, user)); } else if (rol == Constants.ROLE_SPONSOR) { crit.add(Restrictions.eq(Project.EMPLOYEEBYSPONSOR, user)); } else if (rol == Constants.ROLE_PORFM) { crit.createCriteria(Project.PERFORMINGORG).add(Restrictions.eq(Performingorg.COMPANY, company)); } else if (rol == Constants.ROLE_IM && tab == Constants.TAB_INITIATION) { crit.add(Restrictions.eq(Project.EMPLOYEEBYINVESTMENTMANAGER, user)); } else if (rol == Constants.ROLE_PROGM) { crit.createCriteria(Project.PROGRAM).add(Restrictions.eq(Program.EMPLOYEE, user)); } else if (rol == Constants.ROLE_STAKEHOLDER) { crit.createCriteria(Project.STAKEHOLDERS).add(Restrictions.eq(Stakeholder.EMPLOYEE, user)); } else {/*from w ww .ja va 2s. co m*/ return false; } return ((Integer) crit.uniqueResult() > 0); }
From source file:es.sm2.openppm.core.dao.ProjectDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Project> find(String search, Performingorg performingorg, Company company) { Criteria crit = getSession().createCriteria(getPersistentClass()) .add(Restrictions.disjunction().add(Restrictions.ilike(Project.PROJECTNAME, "%" + search + "%")) .add(Restrictions.ilike(Project.CHARTLABEL, "%" + search + "%")) .add(Restrictions.ilike(Project.ACCOUNTINGCODE, "%" + search + "%"))); Criteria poCrit = crit.createCriteria(Project.PERFORMINGORG) .add(Restrictions.eq(Performingorg.COMPANY, company)); if (performingorg != null) { poCrit.add(Restrictions.eq(Performingorg.IDPERFORG, performingorg.getIdPerfOrg())); }//from w w w .j a va2s .c o m return crit.list(); }
From source file:es.sm2.openppm.core.dao.ProjectDAO.java
License:Open Source License
/** * // w w w . j a v a2s . c o m * @param employee * @return */ @SuppressWarnings("unchecked") public List<Project> findByEmployee(Employee employee, List<String> joins) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.createCriteria(Project.PROJECTACTIVITIES).createCriteria(Projectactivity.TEAMMEMBERS) .add(Restrictions.eq(Teammember.EMPLOYEE, employee)); crit.addOrder(Order.asc(Project.PROJECTNAME)); crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); return crit.list(); }
From source file:es.sm2.openppm.core.dao.ProjectDAO.java
License:Open Source License
/** * Find PMs by employee and dates/* w w w. j a v a 2 s . c o m*/ * * @param employee * @param dates * @return */ public List<Project> findPMs(Employee employee, List<Date> dates) { // Create criteria Criteria crit = getSession().createCriteria(getPersistentClass()); // Filter not null project managers crit.add(Restrictions.isNotNull(Project.EMPLOYEEBYPROJECTMANAGER)); // Filters teammember by assigned and employee Criteria teammembers = crit.createCriteria(Project.PROJECTACTIVITIES) .createCriteria(Projectactivity.TEAMMEMBERS) .add(Restrictions.eq(Teammember.STATUS, Constants.RESOURCE_ASSIGNED)) .add(Restrictions.eq(Teammember.EMPLOYEE, employee)); // Filter dates if (ValidateUtil.isNotNull(dates)) { for (Date date : dates) { teammembers.add(Restrictions.and(Restrictions.le(Teammember.DATEIN, date), Restrictions.ge(Teammember.DATEOUT, date))); } } return crit.list(); }
From source file:es.sm2.openppm.core.dao.ProjectFollowupDAO.java
License:Open Source License
/** * Find follow ups for notify//w ww .ja va 2 s. c om * @return */ @SuppressWarnings("unchecked") public List<Projectfollowup> findForNotify() { Calendar actualDate = DateUtil.getCalendar(); Criteria crit = getSession().createCriteria(getPersistentClass()) .add(Restrictions.le(Projectfollowup.FOLLOWUPDATE, actualDate.getTime())) .add(Restrictions.isNull(Projectfollowup.GENERALFLAG)) .add(Restrictions.isNull(Projectfollowup.RISKFLAG)) .add(Restrictions.isNull(Projectfollowup.COSTFLAG)) .add(Restrictions.isNull(Projectfollowup.SCHEDULEFLAG)) .setFetchMode(Projectfollowup.PROJECT, FetchMode.JOIN) .setFetchMode(Projectfollowup.PROJECT + "." + Project.EMPLOYEEBYPROJECTMANAGER, FetchMode.JOIN) .setFetchMode( Projectfollowup.PROJECT + "." + Project.EMPLOYEEBYPROJECTMANAGER + "." + Employee.CONTACT, FetchMode.JOIN); Criteria crit2 = crit.createCriteria(Projectfollowup.PROJECT); crit2.add(Restrictions.eq(Project.STATUS, Constants.STATUS_CONTROL)); return crit.list(); }
From source file:es.sm2.openppm.core.dao.ProjectfundingsourceDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Projectfundingsource> findFundingsByProjectAndNameOrder(Project project, String order) { List<Projectfundingsource> list = null; Criteria projectFundingSource = getSession().createCriteria(getPersistentClass()) .add(Restrictions.eq(Projectfollowup.PROJECT, project)); Criteria fundingSource = projectFundingSource.createCriteria(Projectfundingsource.FUNDINGSOURCE); if (Constants.ASCENDENT.equals(order)) { fundingSource.addOrder(Order.asc(Fundingsource.NAME)); } else if (Constants.DESCENDENT.equals(order)) { fundingSource.addOrder(Order.desc(Fundingsource.NAME)); }//from w w w . ja v a2s .c o m list = projectFundingSource.list(); return list; }
From source file:es.sm2.openppm.core.dao.ProjectKpiDAO.java
License:Open Source License
/** * Return aggregate kpis by filter project * @param aggregatekpi/* w w w .j a v a 2s . c o m*/ * @param ids * @param joins * @return */ @SuppressWarnings("unchecked") public List<Projectkpi> findAggregateProjects(String aggregatekpi, Integer[] ids, List<String> joins) { Criteria crit = getSession().createCriteria(getPersistentClass()) .add(Restrictions.eq(Projectkpi.AGGREGATEKPI, true)); addJoins(crit, joins); crit.createCriteria(Projectkpi.PROJECT).add(Restrictions.in(Project.IDPROJECT, ids)); return crit.list(); }
From source file:es.sm2.openppm.core.dao.ProjectKpiDAO.java
License:Open Source License
/** * Find by project and contains metrickpi type * * @param project/* ww w . j a va 2s . co m*/ * @return */ public List<Projectkpi> findByProjectAndMetricType(Project project) { // Find by project Criteria crit = getSession().createCriteria(getPersistentClass()) .add(Restrictions.eq(Projectkpi.PROJECT, project)); // Find by metrickpi contains type crit.createCriteria(Projectkpi.METRICKPI).add(Restrictions.isNotNull(Metrickpi.TYPE)); return crit.list(); }
From source file:es.sm2.openppm.core.dao.ResourcepoolDAO.java
License:Open Source License
/** * Resource pools by resource manager/*from w w w .j av a2 s. c om*/ * * @param user * @return */ @SuppressWarnings("unchecked") public List<Resourcepool> findByResourceManager(Employee user) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.createCriteria(Resourcepool.MANAGEPOOLS).add(Restrictions.eq(Managepool.EMPLOYEE, user)); crit.addOrder(Order.asc(Resourcepool.NAME)); return crit.list(); }