List of usage examples for org.hibernate Criteria createCriteria
public Criteria createCriteria(String associationPath) throws HibernateException;
From source file:es.sm2.openppm.core.dao.EmployeeDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Employee> consEmployeesByUser(Contact contact) { Criteria crit = getSession().createCriteria(getPersistentClass()).add( Restrictions.or(Restrictions.isNull(Employee.DISABLE), Restrictions.ne(Employee.DISABLE, true))); crit.createCriteria(Employee.RESOURCEPROFILES).addOrder(Order.asc(Resourceprofiles.PROFILENAME)); crit.setFetchMode(Employee.RESOURCEPROFILES, FetchMode.JOIN).setFetchMode(Employee.PERFORMINGORG, FetchMode.JOIN);// w ww . j av a 2 s . c om crit.createCriteria(Employee.CONTACT).add(Restrictions.idEq(contact.getIdContact())) .add(Restrictions.or(Restrictions.isNull(Contact.DISABLE), Restrictions.ne(Contact.DISABLE, true))) .createCriteria(Contact.COMPANY) .add(Restrictions.or(Restrictions.isNull(Company.DISABLE), Restrictions.ne(Company.DISABLE, true))); return crit.list(); }
From source file:es.sm2.openppm.core.dao.EmployeeDAO.java
License:Open Source License
/** * Find Approvals Expenses by Functional Manager * @param user/*from www . j a va 2 s . c o m*/ * @param since * @param until * @return */ @SuppressWarnings("unchecked") public List<Employee> findApprovalsExpense(Employee user, Date since, Date until) { Criteria crit = getSession().createCriteria(getPersistentClass()) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).setFetchMode(Employee.CONTACT, FetchMode.JOIN); crit.createCriteria(Employee.EXPENSESHEETS) .add(Restrictions.between(Expensesheet.EXPENSEDATE, since, until)) .add(Restrictions.or(Restrictions.eq(Expensesheet.STATUS, Constants.TIMESTATUS_APP2), Restrictions.eq(Expensesheet.STATUS, Constants.TIMESTATUS_APP3))); crit.add(Restrictions.eq(Employee.PERFORMINGORG, user.getPerformingorg())); return crit.list(); }
From source file:es.sm2.openppm.core.dao.EmployeeDAO.java
License:Open Source License
/** * Find Employees where inputed hours is approval * /*www . j av a 2 s .c o m*/ * @param project * @param since * @param until * @return */ @SuppressWarnings("unchecked") public List<Employee> findInputedInProject(Project project, Date since, Date until) { Criteria crit = getSession().createCriteria(getPersistentClass()) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); Criteria members = crit.createCriteria(Employee.TEAMMEMBERS) .add(Restrictions.or(Restrictions.eq(Teammember.STATUS, Constants.RESOURCE_ASSIGNED), Restrictions.eq(Teammember.STATUS, Constants.RESOURCE_RELEASED))); if (since != null && until != null) { members.add(Restrictions.disjunction().add(Restrictions.between(Teammember.DATEIN, since, until)) .add(Restrictions.between(Teammember.DATEOUT, since, until)) .add(Restrictions.and(Restrictions.le(Teammember.DATEIN, since), Restrictions.ge(Teammember.DATEOUT, until)))); } members.createCriteria(Teammember.PROJECTACTIVITY).add(Restrictions.eq(Projectactivity.PROJECT, project)); Criteria sheets = crit.createCriteria(Employee.TIMESHEETS) .add(Restrictions.eq(Timesheet.STATUS, Constants.TIMESTATUS_APP3)); if (since != null && until != null) { sheets.add(Restrictions.disjunction().add(Restrictions.between(Timesheet.INITDATE, since, until)) .add(Restrictions.between(Timesheet.ENDDATE, since, until)) .add(Restrictions.and(Restrictions.le(Timesheet.INITDATE, since), Restrictions.ge(Timesheet.ENDDATE, until)))); } sheets.createCriteria(Timesheet.PROJECTACTIVITY).add(Restrictions.eq(Projectactivity.PROJECT, project)); crit.createCriteria(Employee.CONTACT).addOrder(Order.asc(Contact.FULLNAME)); crit.setFetchMode(Employee.CALENDARBASE, FetchMode.JOIN); return crit.list(); }
From source file:es.sm2.openppm.core.dao.EmployeeDAO.java
License:Open Source License
/** * List employees by company/*from ww w .j ava 2 s.co m*/ * @param company * @param joins * @return */ @SuppressWarnings("unchecked") public List<Employee> findByCompany(Company company, List<String> joins) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.createCriteria(Employee.CONTACT).add(Restrictions.eq(Contact.COMPANY, company)); addJoins(crit, joins); return crit.list(); }
From source file:es.sm2.openppm.core.dao.EmployeeDAO.java
License:Open Source License
/** * Find by Resource Manager/* w ww.j a v a2s . co m*/ * @param listResourcepool * @param fullName * @param joins * @param typeOrder * @return */ @SuppressWarnings("unchecked") public List<Employee> findByManager(List<Resourcepool> listResourcepool, String fullName, List<String> joins, String typeOrder) { Criteria crit = getSession().createCriteria(getPersistentClass()); if (ValidateUtil.isNotNull(listResourcepool)) { crit.add(Restrictions.in(Employee.RESOURCEPOOL, listResourcepool)); } Criteria critContact = crit.createCriteria(Employee.CONTACT) .add(Restrictions.ilike(Contact.FULLNAME, "%" + fullName + "%")); // Order by contact addOrder(critContact, Contact.FULLNAME, typeOrder); addJoins(crit, joins); return crit.list(); }
From source file:es.sm2.openppm.core.dao.EmployeeDAO.java
License:Open Source License
/** * Find imputed in projects//ww w . java 2s .co m * * @param projects * @param since * @param until * @param idResourcePool * @param activities * @return */ @SuppressWarnings("unchecked") public List<Employee> findInputedInProjects(List<Project> projects, Date since, Date until, Integer idResourcePool, List<Projectactivity> activities) { List<Employee> employees = null; if (ValidateUtil.isNotNull(projects) || ValidateUtil.isNotNull(activities)) { Criteria crit = getSession().createCriteria(getPersistentClass()) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); if (idResourcePool != null) { crit.add(Restrictions.eq(Employee.RESOURCEPOOL, new Resourcepool(idResourcePool))); } // Timesheet filter by status app3 and dates and projects // Criteria sheets = crit.createCriteria(Employee.TIMESHEETS) .add(Restrictions.eq(Timesheet.STATUS, Constants.TIMESTATUS_APP3)); if (since != null && until != null) { sheets.add(Restrictions.disjunction().add(Restrictions.between(Timesheet.INITDATE, since, until)) .add(Restrictions.between(Timesheet.ENDDATE, since, until)) .add(Restrictions.and(Restrictions.le(Timesheet.INITDATE, since), Restrictions.ge(Timesheet.ENDDATE, until)))); } if (projects != null) { Criteria activitiesCrit = sheets.createCriteria(Timesheet.PROJECTACTIVITY) .add(Restrictions.in(Projectactivity.PROJECT, projects)); // Select employees whose activity is control account Criteria wbsnodeCrit = activitiesCrit.createCriteria(Projectactivity.WBSNODE) .add(Restrictions.eq(Wbsnode.ISCONTROLACCOUNT, true)); } else if (activities != null) { sheets.add(Restrictions.in(Timesheet.PROJECTACTIVITY, activities)); } crit.createCriteria(Employee.CONTACT).addOrder(Order.asc(Contact.FULLNAME)); employees = crit.list(); } return employees; }
From source file:es.sm2.openppm.core.dao.EmployeeDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Employee> findInputedInOperations(List<Employee> employees, Date since, Date until, Integer idResourcePool) { List<Employee> returnEmployees = null; if (ValidateUtil.isNotNull(employees)) { Criteria crit = getSession().createCriteria(getPersistentClass()) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); List<Integer> ids = new ArrayList<Integer>(); for (Employee item : employees) { ids.add(item.getIdEmployee()); }/*from www . j ava 2 s .c om*/ crit.add(Restrictions.not(Restrictions.in(Employee.IDEMPLOYEE, ids))); if (idResourcePool != null) { crit.add(Restrictions.eq(Employee.RESOURCEPOOL, new Resourcepool(idResourcePool))); } Criteria sheets = crit.createCriteria(Employee.TIMESHEETS) .add(Restrictions.eq(Timesheet.STATUS, Constants.TIMESTATUS_APP3)) .add(Restrictions.isNotNull(Timesheet.OPERATION)); if (since != null && until != null) { sheets.add(Restrictions.disjunction().add(Restrictions.between(Timesheet.INITDATE, since, until)) .add(Restrictions.between(Timesheet.ENDDATE, since, until)) .add(Restrictions.and(Restrictions.le(Timesheet.INITDATE, since), Restrictions.ge(Timesheet.ENDDATE, until)))); } crit.createCriteria(Employee.CONTACT).addOrder(Order.asc(Contact.FULLNAME)); returnEmployees = crit.list(); } return returnEmployees; }
From source file:es.sm2.openppm.core.dao.EmployeeDAO.java
License:Open Source License
/** * Cons employees for login and profile//from w ww. j av a 2s.com * * @param contact * @param profile * @return */ @SuppressWarnings("unchecked") public List<Employee> consEmployeesByUserAndRol(Contact contact, int profile) { Criteria crit = getSession().createCriteria(getPersistentClass()).add( Restrictions.or(Restrictions.isNull(Employee.DISABLE), Restrictions.ne(Employee.DISABLE, true))); crit.createCriteria(Employee.RESOURCEPROFILES).add(Restrictions.eq(Resourceprofiles.IDPROFILE, profile)); crit.setFetchMode(Employee.RESOURCEPROFILES, FetchMode.JOIN).setFetchMode(Employee.PERFORMINGORG, FetchMode.JOIN); crit.createCriteria(Employee.CONTACT).add(Restrictions.idEq(contact.getIdContact())) .add(Restrictions.or(Restrictions.isNull(Contact.DISABLE), Restrictions.ne(Contact.DISABLE, true))) .createCriteria(Contact.COMPANY) .add(Restrictions.or(Restrictions.isNull(Company.DISABLE), Restrictions.ne(Company.DISABLE, true))); return crit.list(); }
From source file:es.sm2.openppm.core.dao.EmployeeDAO.java
License:Open Source License
/** * Employees by profile and company/* w ww . j av a2 s. co m*/ * * @param profile * @param company * @return */ @SuppressWarnings("unchecked") public List<Employee> consEmployeesByRol(int profile, Company company) { Criteria crit = getSession().createCriteria(getPersistentClass()).add( Restrictions.or(Restrictions.isNull(Employee.DISABLE), Restrictions.ne(Employee.DISABLE, true))); crit.createCriteria(Employee.RESOURCEPROFILES).add(Restrictions.eq(Resourceprofiles.IDPROFILE, profile)); crit.setFetchMode(Employee.RESOURCEPROFILES, FetchMode.JOIN).setFetchMode(Employee.PERFORMINGORG, FetchMode.JOIN); Criteria critContact = crit.createCriteria(Employee.CONTACT); critContact.createCriteria(Contact.COMPANY).add(Restrictions.and( Restrictions.eq(Company.IDCOMPANY, company.getIdCompany()), Restrictions.or(Restrictions.isNull(Company.DISABLE), Restrictions.ne(Company.DISABLE, true)))); return crit.list(); }
From source file:es.sm2.openppm.core.dao.EmployeeDAO.java
License:Open Source License
/** * Consult resource managers by employee * /*from w w w . j ava 2s.c om*/ * @param employee * @return */ @SuppressWarnings("unchecked") public List<Employee> consResourceManagers(Employee employee) { List<Employee> listEmployee = null; if (employee != null && employee.getResourcepool() != null) { Criteria crit = getSession().createCriteria(getPersistentClass()); crit.createCriteria(Employee.MANAGEPOOLS) .add(Restrictions.eq(Managepool.RESOURCEPOOL, employee.getResourcepool())); Criteria critContact = crit.createCriteria(Employee.CONTACT); critContact.createCriteria(Contact.COMPANY).add( Restrictions.or(Restrictions.isNull(Company.DISABLE), Restrictions.ne(Company.DISABLE, true))); listEmployee = crit.list(); } return listEmployee; }