List of usage examples for org.hibernate.criterion Restrictions idEq
public static Criterion idEq(Object value)
From source file:eionet.webq.dao.UserFileStorageImpl.java
License:Mozilla Public License
@Override public void update(final UserFile file, final String userId) { UserFile userFile = (UserFile) getCriteria().add(Restrictions.idEq(file.getId())).uniqueResult(); getCurrentSession().evict(userFile); if (userId.equals(userFile.getUserId())) { getCurrentSession().update(file); }// w w w . j av a 2 s .c o m }
From source file:es.sm2.openppm.core.dao.CalendarbaseexceptionsDAO.java
License:Open Source License
/** * Get Base exceptions by employee/*from w w w. j a v a 2s . co m*/ * @param idEmployee * @return */ @SuppressWarnings("unchecked") public List<Calendarbaseexceptions> findByEmployee(Integer idEmployee) { Criteria crit = getSession().createCriteria(getPersistentClass()) .createCriteria(Calendarbaseexceptions.CALENDARBASE).createCriteria(Calendarbase.EMPLOYEES) .add(Restrictions.idEq(idEmployee)); return crit.list(); }
From source file:es.sm2.openppm.core.dao.CalendarbaseexceptionsDAO.java
License:Open Source License
/** * /*from w ww .j a v a 2 s . c om*/ * @param base * @param idEmployee * @param initDate * @param endDate * @return */ @SuppressWarnings("unchecked") public List<Calendarbaseexceptions> findByCalendarBase(Calendarbase base, Integer idEmployee, Date initDate, Date endDate) { Criteria crit = getSession().createCriteria(getPersistentClass()) .add(Restrictions.eq(Calendarbaseexceptions.CALENDARBASE, base)) .add(Restrictions.ge(Calendarbaseexceptions.STARTDATE, initDate)) .add(Restrictions.le(Calendarbaseexceptions.FINISHDATE, endDate)) .createCriteria(Calendarbaseexceptions.CALENDARBASE).createCriteria(Calendarbase.EMPLOYEES) .add(Restrictions.idEq(idEmployee)); return crit.list(); }
From source file:es.sm2.openppm.core.dao.CompanyDAO.java
License:Open Source License
/** * Search company of employee//ww w . j av a2 s .co m * @param user * @return */ public Company searchByEmployee(Employee user) { Criteria crit = getSession().createCriteria(getPersistentClass()) .setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY).createCriteria(Company.CONTACTS) .createCriteria(Contact.EMPLOYEES).add(Restrictions.idEq(user.getIdEmployee())); return (Company) crit.uniqueResult(); }
From source file:es.sm2.openppm.core.dao.ContactDAO.java
License:Open Source License
/** * Search Contacts by filter// w w w . j a va 2 s. c o m * @param resourcepools * @param fullName * @param fileAs * @param performingorg * @param company * @param skills *@param jobcategories @return */ @SuppressWarnings("unchecked") public List<Contact> searchByFilter(String fullName, String fileAs, Performingorg performingorg, Company company, List<Resourcepool> resourcepools, List<Skill> skills, List<Jobcategory> jobcategories) { Contact example = new Contact(); example.setFileAs(fileAs); example.setFullName(fullName); Criteria crit = getSession().createCriteria(getPersistentClass()) .setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY) .add(Example.create(example).ignoreCase().enableLike(MatchMode.ANYWHERE)) .add(Restrictions.or(Restrictions.isNull(Contact.DISABLE), Restrictions.ne(Contact.DISABLE, true))); // Company // crit.createCriteria(Contact.COMPANY).add(Restrictions.idEq(company.getIdCompany())) .add(Restrictions.or(Restrictions.isNull(Company.DISABLE), Restrictions.ne(Company.DISABLE, true))); // Employee Criteria critEmployee = crit.createCriteria(Contact.EMPLOYEES, CriteriaSpecification.LEFT_JOIN); if (performingorg != null && performingorg.getIdPerfOrg() != null && performingorg.getIdPerfOrg() != -1) { critEmployee.createCriteria(Employee.PERFORMINGORG) .add(Restrictions.idEq(performingorg.getIdPerfOrg())); } if (ValidateUtil.isNotNull(resourcepools)) { critEmployee.add(Restrictions.in(Employee.RESOURCEPOOL, resourcepools)); } if (ValidateUtil.isNotNull(skills)) { critEmployee.createCriteria(Employee.SKILLSEMPLOYEES) .add(Restrictions.in(Skillsemployee.SKILL, skills)); } if (ValidateUtil.isNotNull(jobcategories)) { critEmployee.createCriteria(Employee.JOBCATEMPLOYEES) .add(Restrictions.in(Jobcatemployee.JOBCATEGORY, jobcategories)); } return crit.list(); }
From source file:es.sm2.openppm.core.dao.ContactDAO.java
License:Open Source License
/** * These contact has profile in company/*from ww w . jav a 2 s . c o m*/ * @param perfOrg * @param contact * @param profile * @return */ public boolean hasProfile(Performingorg perfOrg, Contact contact, Resourceprofiles profile) { Criteria crit = getSession().createCriteria(getPersistentClass()).setProjection(Projections.rowCount()) .add(Restrictions.idEq(contact.getIdContact())); crit.createCriteria(Contact.EMPLOYEES).add(Restrictions.eq(Employee.RESOURCEPROFILES, profile)) .add(Restrictions.eq(Employee.PERFORMINGORG, perfOrg)); return ((Integer) crit.uniqueResult() > 0); }
From source file:es.sm2.openppm.core.dao.ContactDAO.java
License:Open Source License
/** * These contact has a resource pool in company * @param contact//from ww w . j a va2 s . c om * @return */ public boolean hasResourcePool(Contact contact, Resourceprofiles teamMember) { Criteria crit = getSession().createCriteria(getPersistentClass()).setProjection(Projections.rowCount()) .add(Restrictions.idEq(contact.getIdContact())); crit.createCriteria(Contact.EMPLOYEES).add(Restrictions.eq(Employee.RESOURCEPROFILES, teamMember)) .add(Restrictions.isNotNull(Employee.RESOURCEPOOL)); return ((Integer) crit.uniqueResult() > 0); }
From source file:es.sm2.openppm.core.dao.ContentFileDAO.java
License:Open Source License
/** * Find by entity and ID/*from www . j ava 2 s .c om*/ * * @param entity * @param id * @return */ public Contentfile findByEntity(String entity, Integer id) { Contentfile content = null; Criteria crit = getSession().createCriteria(getPersistentClass()).createCriteria(entity) .add(Restrictions.idEq(id)); content = (Contentfile) crit.uniqueResult(); return content; }
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);/*from w w w .j a va2 s .c o m*/ 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
/** * Cons employees for login and profile/*from w ww.ja v a 2 s . c o m*/ * * @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(); }