Example usage for org.hibernate Query setDate

List of usage examples for org.hibernate Query setDate

Introduction

In this page you can find the example usage for org.hibernate Query setDate.

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setDate(String name, Date val) 

Source Link

Document

Bind the val (time is truncated) of a given Date object to a named query parameter.

Usage

From source file:es.sm2.openppm.core.dao.EmployeeDAO.java

License:Open Source License

/**
 * Find unassigned employees by filters/*w w w  .j a  v  a  2  s  .c o  m*/
 *
 *
 * @param since
 * @param until
 * @param fullName
 * @param listResourcepool
 * @param idJobCategories
 */
public List<Employee> findUnassigned(Date since, Date until, String fullName,
        List<Resourcepool> listResourcepool, Integer[] idJobCategories) {

    // Add Restrictions
    //
    List<NamedRestriction> restrictions = new ArrayList<NamedRestriction>();

    MappingHql mappingHql = this.getMappingHql().setNamedQuery(EmployeeNamedQuery.FIND_UNSIGNED)
            .putRestrictions(EmployeeNamedRestriction.EXCLUDE_IN_DATES);

    if (ValidateUtil.isNotNull(fullName)) {
        mappingHql.putRestrictions(EmployeeNamedRestriction.LIKE_NAME);
    }

    if (ValidateUtil.isNotNull(listResourcepool)) {
        mappingHql.putRestrictions(EmployeeNamedRestriction.IN_POOLS);
    }

    if (ValidateUtil.isNotNull(idJobCategories)) {
        mappingHql.putRestrictions(EmployeeNamedRestriction.IN_CATEGORIES);
    }

    // Create query
    String statement = mappingHql.putOrders(GenericNamedOrder.BY_CONTACT_NAME).create();

    Query query = getSession().createQuery(statement);

    // Set parameters
    //
    if (ValidateUtil.isNotNull(listResourcepool)) {
        query.setParameterList(NamedParams.RESOURCEPOOL.name(), listResourcepool);
    }

    if (ValidateUtil.isNotNull(fullName)) {
        query.setString(NamedParams.FULLNAME.name(),
                StringPool.PERCENT + fullName.toLowerCase() + StringPool.PERCENT);
    }

    if (ValidateUtil.isNotNull(idJobCategories)) {
        query.setParameterList(NamedParams.CATEGORIES.name(), idJobCategories);
    }

    query.setDate(NamedParams.SINCE.name(), since);
    query.setDate(NamedParams.UNTIL.name(), until);
    query.setString(NamedParams.RESOURCE_ASSIGNED.name(), Constants.RESOURCE_ASSIGNED);

    return query.list();
}

From source file:es.sm2.openppm.core.dao.LearnedLessonDAO.java

License:Open Source License

/**
 * Add parameters// w  w w .  java 2  s.  co  m
 *
 * @param query
 * @param filter
 */
private void addParameters(Query query, LearnedLessonSearch filter) {

    // LearnedLesson search parameters
    //

    // Name and id
    if (ValidateUtil.isNotNull(filter.getLlaaQuery())) {
        query.setString("llaaQuery", "%" + filter.getLlaaQuery().toUpperCase() + "%");
    }

    Integer[] idsLLAA = IntegerUtil.parseStringSequence(filter.getLlaaQuery(), StringPool.COMMA);

    if (ValidateUtil.isNotNull(idsLLAA)) {
        query.setParameterList("idsLLAA", idsLLAA);
    }

    // Programs
    if (ValidateUtil.isNotNull(filter.getLlaaPrograms())) {
        query.setParameterList("llaaPrograms", filter.getLlaaPrograms());
    }

    // Customers
    if (ValidateUtil.isNotNull(filter.getLlaaCustomers())) {
        query.setParameterList("llaaCustomers", filter.getLlaaCustomers());
    }

    // Sellers
    if (ValidateUtil.isNotNull(filter.getLlaaSellers())) {
        query.setParameterList("llaaSellers", filter.getLlaaSellers());
    }

    // Geographic Areas
    if (ValidateUtil.isNotNull(filter.getLlaaGeographicAreas())) {
        query.setParameterList("llaaGeographicAreas", filter.getLlaaGeographicAreas());
    }

    // Customer types
    if (ValidateUtil.isNotNull(filter.getLlaaCustomerTypes())) {
        query.setParameterList("llaaCustomerTypes", filter.getLlaaCustomerTypes());
    }

    // Funding sources
    if (ValidateUtil.isNotNull(filter.getLlaaFundingSources())) {
        query.setParameterList("llaaFundingSources", filter.getLlaaFundingSources());
    }

    // Knowledge Area
    if (ValidateUtil.isNotNull(filter.getLlaaKnowledgeArea())) {
        query.setParameterList("llaaKnowledgeArea", filter.getLlaaKnowledgeArea());
    }

    // Owners
    if (ValidateUtil.isNotNull(filter.getLlaaOwner())) {
        query.setParameterList("llaaOwner", filter.getLlaaOwner());
    }

    // Profiles
    if (ValidateUtil.isNotNull(filter.getLlaaJobProfile())) {
        query.setParameterList("llaaJobProfile", filter.getLlaaJobProfile());
    }

    // Min impact time
    if (filter.getLlaaMinImpactTime() != null) {
        query.setBigDecimal("llaaMinImpactTime", filter.getLlaaMinImpactTime());
    }

    // Max impact time
    if (filter.getLlaaMaxImpactTime() != null) {
        query.setBigDecimal("llaaMaxImpactTime", filter.getLlaaMaxImpactTime());
    }

    // Min impact cost
    if (filter.getLlaaMinImpactCost() != null) {
        query.setBigDecimal("llaaMinImpactCost", filter.getLlaaMinImpactCost());
    }

    // Max impact cost
    if (filter.getLlaaMaxImpactCost() != null) {
        query.setBigDecimal("llaaMaxImpactCost", filter.getLlaaMaxImpactCost());
    }

    // Min ranking
    if (filter.getLlaaMinRanking() != null) {
        query.setBigDecimal("llaaMinRanking", filter.getLlaaMinRanking());
    }

    // Max ranking
    if (filter.getLlaaMaxRanking() != null) {
        query.setBigDecimal("llaaMaxRanking", filter.getLlaaMaxRanking());
    }

    // Since
    if (filter.getLlaaSince() != null) {
        query.setDate("llaaSince", filter.getLlaaSince());
    }

    // Until
    if (filter.getLlaaUntil() != null) {
        query.setDate("llaaUntil", filter.getLlaaUntil());
    }
}

From source file:es.sm2.openppm.core.dao.ProjectActivityDAO.java

License:Open Source License

/**
 * Update Planned Dates of root activity
 * /*w w  w. j a  v a 2s  .  c o  m*/
 * @param project
 * @param rootActivity
 */
public void updatePlannedDates(Project project, Projectactivity rootActivity) {

    // Num of activities of project
    int numActivities = rowCountEq(Projectactivity.PROJECT, project);

    // Get max and min project activity dates
    Criteria crit = getSession().createCriteria(getPersistentClass())
            .setProjection(Projections.projectionList().add(Projections.min(Projectactivity.PLANINITDATE))
                    .add(Projections.max(Projectactivity.PLANENDDATE)))
            .add(Restrictions.eq(Projectactivity.PROJECT, project));

    // Exclude root activities
    if (numActivities > 1) {
        crit.add(Restrictions.ne(Projectactivity.IDACTIVITY, rootActivity.getIdActivity()));
    }

    Object[] row = (Object[]) crit.uniqueResult();

    // Init calculated plan dates
    Date calculatedPlanStartDate = null;
    Date calculatedPlanFinishDate = null;

    // If there is result set root activity
    if (row != null && row.length > 0) {

        Date planInitDate = (Date) row[0];
        Date planEndDate = (Date) row[1];

        rootActivity.setPlanInitDate(planInitDate);
        rootActivity.setPlanEndDate(planEndDate);
        rootActivity = makePersistent(rootActivity);

        // Set calculated plan dates 
        calculatedPlanStartDate = planInitDate == null ? project.getPlannedInitDate() : planInitDate;
        calculatedPlanFinishDate = planEndDate == null ? project.getPlannedFinishDate() : planEndDate;
    } else {

        // Set calculated plan dates 
        calculatedPlanStartDate = project.getPlannedInitDate();
        calculatedPlanFinishDate = project.getPlannedFinishDate();
    }

    // Update calculated planning dates
    Query query = getSession().createQuery("update Project p "
            + " set p.calculatedPlanStartDate = :calculatedPlanStartDate,"
            + " p.calculatedPlanFinishDate = :calculatedPlanFinishDate" + " where p.idProject = :idProject");
    query.setInteger("idProject", project.getIdProject());
    query.setDate("calculatedPlanStartDate", calculatedPlanStartDate);
    query.setDate("calculatedPlanFinishDate", calculatedPlanFinishDate);
    query.executeUpdate();
}

From source file:es.sm2.openppm.core.dao.ProjectcalendarDAO.java

License:Open Source License

/**
 * Check if is Exception day in project/*from   w w  w  .  j ava  2s.  c o  m*/
 * @param time
 * @param idActivity
 * @return
 */
public boolean isException(Date day, Projectcalendar projCal, Calendarbase calBase) {

    boolean isException = false;

    if (calBase != null) {

        Criteria crit = getSession().createCriteria(Calendarbase.class).setProjection(Projections.rowCount())
                .add(Restrictions.idEq(calBase.getIdCalendarBase()))
                .createCriteria(Calendarbase.CALENDARBASEEXCEPTIONSES)
                .add(Restrictions.and(Restrictions.le(Calendarbaseexceptions.STARTDATE, day),
                        Restrictions.ge(Calendarbaseexceptions.FINISHDATE, day)));

        isException = ((Integer) crit.uniqueResult()) > 0;
    }

    if (!isException && projCal != null) {
        Query query = getSession().createQuery("select count(calendar) " + "from Projectcalendar as calendar "
                + "left join calendar.projectcalendarexceptionses as exceptionsp "
                + "left join calendar.calendarbase as calendarb "
                + "left join calendarb.calendarbaseexceptionses as exceptionsb "
                + "where calendar.idProjectCalendar = :idProjectCalendar "
                + "and (:day between exceptionsp.startDate and exceptionsp.finishDate "
                + "or :day between exceptionsb.startDate and exceptionsb.finishDate)");

        query.setInteger("idProjectCalendar", projCal.getIdProjectCalendar());
        query.setDate("day", day);

        Long count = (Long) query.uniqueResult();

        isException = (count > 0);
    }
    return isException;
}

From source file:es.sm2.openppm.core.dao.ProjectDAO.java

License:Open Source License

/**
 * Add parameters//from w  w w .  j  av  a 2s .  co m
 *
 * @param query
 * @param filter
 */
private void addParameters(Query query, ProjectSearch filter) {

    // Add parameter for priority
    if (!ValidateUtil.isNull(filter.getPriority())) {

        if ((ProjectSearch.GREATHER_EQUAL.equals(filter.getPriority())
                || ProjectSearch.LESS_EQUAL.equals(filter.getPriority())) && filter.getLastPriority() != null) {

            query.setInteger("lastPriority", filter.getLastPriority());
        } else if (ProjectSearch.BETWEEN.equals(filter.getPriority()) && filter.getLastPriority() != null
                && filter.getFirstPriority() != null) {

            query.setInteger("firstPriority", filter.getFirstPriority());
            query.setInteger("lastPriority", filter.getLastPriority());
        }
    }

    // Add parameter for risk rating
    if (ValidateUtil.isNotNull(filter.getRiskRating())) {

        if ((ProjectSearch.GREATHER_EQUAL.equals(filter.getRiskRating())
                || ProjectSearch.LESS_EQUAL.equals(filter.getRiskRating()))
                && filter.getLastRiskRating() != null) {

            query.setInteger("lastRiskRating", filter.getLastRiskRating());
        } else if (ProjectSearch.BETWEEN.equals(filter.getRiskRating()) && filter.getLastRiskRating() != null
                && filter.getFirstRiskRating() != null) {

            query.setInteger("firstRiskRating", filter.getFirstRiskRating());
            query.setInteger("lastRiskRating", filter.getLastRiskRating());
        }
    }

    if (filter.getIncludeDisabled() != null && !filter.getIncludeDisabled()) {
        query.setBoolean("disable", Boolean.TRUE);
    }

    if (filter.getSince() != null) {
        query.setDate("since", filter.getSince());
    }
    if (filter.getUntil() != null) {
        query.setDate("until", filter.getUntil());
    }
    if (filter.getInternalProject() != null) {
        query.setBoolean("internalProject", filter.getInternalProject());
    }
    if (filter.getIsGeoSelling() != null) {
        query.setBoolean("isGeoSelling", filter.getIsGeoSelling());
    }
    if (filter.getBudgetYear() != null) {
        query.setInteger("budgetYear", filter.getBudgetYear());
    }
    if (ValidateUtil.isNotNull(filter.getProjectName())) {
        query.setString("projectName", "%" + filter.getProjectName().toUpperCase() + "%");
    }

    Integer[] idsProject = IntegerUtil.parseStringSequence(filter.getProjectName(), StringPool.COMMA);

    if (SettingUtil.getBoolean(filter.getSettings(), VisibilityProjectSetting.PROJECT_COLUMN_IDPROJECT)
            && idsProject != null) {

        query.setParameterList("projectNameID", idsProject);
    }

    if (ValidateUtil.isNotNull(filter.getRag())) {
        query.setCharacter("rag", filter.getRag().charAt(0));
    }
    if (filter.getCompany() != null) {
        query.setEntity("company", filter.getCompany());
    }
    if (filter.getEmployeeByInvestmentManager() != null) {
        query.setEntity("employeeByInvestmentManager", filter.getEmployeeByInvestmentManager());
    }
    if (filter.getStakeholder() != null) {
        query.setEntity("stakeholder", filter.getStakeholder());
    }
    if (filter.getProgramManager() != null) {
        query.setEntity("programManager", filter.getProgramManager());
    }
    if (filter.getIsIndirectSeller() != null) {
        query.setBoolean("isIndirectSeller", filter.getIsIndirectSeller());
    }

    if (ValidateUtil.isNotNull(filter.getPerformingorgs())) {
        query.setParameterList("performingorgs", filter.getPerformingorgs());
    }
    if (ValidateUtil.isNotNull(filter.getEmployeeBySponsors())) {
        query.setParameterList("employeeBySponsors", filter.getEmployeeBySponsors());
    }
    if (ValidateUtil.isNotNull(filter.getEmployeeByProjectManagers())) {
        query.setParameterList("employeeByProjectManagers", filter.getEmployeeByProjectManagers());
    }
    if (ValidateUtil.isNotNull(filter.getCustomers())) {
        query.setParameterList("customers", filter.getCustomers());
    }
    if (ValidateUtil.isNotNull(filter.getCustomertypes())) {
        query.setParameterList("customertypes", filter.getCustomertypes());
    }
    if (ValidateUtil.isNotNull(filter.getPrograms())) {
        query.setParameterList("programs", filter.getPrograms());
    }
    if (ValidateUtil.isNotNull(filter.getCategories())) {
        query.setParameterList("categories", filter.getCategories());
    }
    if (ValidateUtil.isNotNull(filter.getSellers())) {
        query.setParameterList("sellers", filter.getSellers());
    }
    if (ValidateUtil.isNotNull(filter.getGeography())) {
        query.setParameterList("geography", filter.getGeography());
    }
    if (ValidateUtil.isNotNull(filter.getFundingsources())) {
        query.setParameterList("fundingsources", filter.getFundingsources());
    }
    if (ValidateUtil.isNotNull(filter.getProjects())) {
        query.setParameterList("projects", filter.getProjects());
    }
    if (ValidateUtil.isNotNull(filter.getStatus())) {
        query.setParameterList("status", filter.getStatus());
    }
    if (ValidateUtil.isNotNull(filter.getInvestmentStatus())) {
        query.setParameterList("investmentStatus", filter.getInvestmentStatus());
    }
    if (ValidateUtil.isNotNull(filter.getLabels())) {
        query.setParameterList("labels", filter.getLabels());
    }
    if (ValidateUtil.isNotNull(filter.getTechnologies())) {
        query.setParameterList("technologies", filter.getTechnologies());
    }
    if (ValidateUtil.isNotNull(filter.getStageGates())) {
        query.setParameterList("stagegate", filter.getStageGates());
    }
    if (ValidateUtil.isNotNull(filter.getContractTypes())) {
        query.setParameterList("contractTypes", filter.getContractTypes());
    }
    if (ValidateUtil.isNotNull(filter.getEmployeeByFunctionalManagers())) {
        query.setParameterList("employeeByFunctionalManagers", filter.getEmployeeByFunctionalManagers());
    }
    if (ValidateUtil.isNotNull(filter.getClassificationsLevel())) {
        query.setParameterList("classificationsLevel", filter.getClassificationsLevel());
    }

    if (filter.getShowInactivated() != null && !filter.getShowInactivated()) {

        query.setString("hideInactivated", Constants.INVESTMENT_INACTIVATED);
    }
}

From source file:es.sm2.openppm.core.dao.ProjectDAO.java

License:Open Source License

/**
 * //from w  w  w  . ja v  a2  s. c  om
 * @param filter
 * @return
 */
@SuppressWarnings("unchecked")
public List<ProjectWrap> findProjectsForExecutiveReport(ProjectSearch filter) {

    String q = "SELECT DISTINCT NEW es.sm2.openppm.core.model.wrap.ProjectWrap(" + "p, "
            + "(SELECT CASE WHEN SUM(ch.cost) IS NULL THEN 0d ELSE SUM(ch.cost) END FROM Chargescosts ch WHERE ch.project = p AND (ch.idChargeType = 1 OR ch.idChargeType = 2 OR ch.idChargeType = 3)) "
            + ") " + "FROM Projectactivity pa " + "JOIN pa.project p " + "JOIN p.program pr "
            + "JOIN p.performingorg po " + "LEFT JOIN p.stakeholders stk "
            + "LEFT JOIN pa.activitysellers actSell " + "LEFT JOIN p.projectfundingsources fs "
            + "LEFT JOIN p.projectlabels pl " + "JOIN pa.wbsnode w ";

    String where = "";

    // Create filter for priority
    if (!ValidateUtil.isNull(filter.getPriority())) {

        if (ProjectSearch.GREATHER_EQUAL.equals(filter.getPriority()) && filter.getLastPriority() != null) {

            where += FilterUtil.addFilterAnd(where, "p.priority >= :lastPriority ");
        } else if (ProjectSearch.LESS_EQUAL.equals(filter.getPriority()) && filter.getLastPriority() != null) {

            where += FilterUtil.addFilterAnd(where, "p.priority <= :lastPriority ");
        } else if (ProjectSearch.BETWEEN.equals(filter.getPriority()) && filter.getLastPriority() != null
                && filter.getFirstPriority() != null) {

            where += FilterUtil.addFilterAnd(where, "(p.priority BETWEEN :firstPriority AND :lastPriority) ");
        }
    }

    // Filter by since and until dates
    if (filter.getSince() != null && filter.getUntil() != null) {
        where += FilterUtil.addFilterAnd(where,
                "((p.startDate BETWEEN :since AND :until) OR (p.finishDate BETWEEN :since AND :until) OR (p.startDate <= :since AND p.finishDate >= :until))");
    } else if (filter.getSince() != null) {
        where += FilterUtil.addFilterAnd(where, "p.startDate >= :since ");
    } else if (filter.getUntil() != null) {
        where += FilterUtil.addFilterAnd(where, "p.finishDate <= :since ");
    }

    where += FilterUtil.addFilterAnd(filter.getInternalProject(), where,
            "p.internalProject = :internalProject ");
    where += FilterUtil.addFilterAnd(filter.getBudgetYear(), where, "p.budgetYear = :budgetYear ");
    where += FilterUtil.addFilterAnd(filter.getProjectName(), where,
            "(UPPER(p.projectName) LIKE :projectName OR UPPER(p.chartLabel) LIKE :projectName OR UPPER(p.accountingCode) LIKE :projectName) ");
    where += FilterUtil.addFilterAnd(filter.getRag(), where, "p.rag = :rag ");
    where += FilterUtil.addFilterAnd(filter.getCompany(), where, "po.company = :company ");
    where += FilterUtil.addFilterAnd(filter.getEmployeeByInvestmentManager(), where,
            "p.employeeByInvestmentManager = :employeeByInvestmentManager ");
    if (ValidateUtil.isNotNull(filter.getEmployeeByFunctionalManagers())) {
        where += FilterUtil.addFilterAnd(where,
                "p.employeeByFunctionalManager.idEmployee IN (:employeeByFunctionalManagers) ");
    }
    where += FilterUtil.addFilterAnd(filter.getStakeholder(), where, "stk.employee = :stakeholder ");
    where += FilterUtil.addFilterAnd(filter.getProgramManager(), where, "pr.employee = :programManager ");

    if (ValidateUtil.isNotNull(filter.getPerformingorgs())) {
        where += FilterUtil.addFilterAnd(where, "po.idPerfOrg IN (:performingorgs) ");
    }
    if (ValidateUtil.isNotNull(filter.getEmployeeBySponsors())) {
        where += FilterUtil.addFilterAnd(where, "p.employeeBySponsor.idEmployee IN (:employeeBySponsors) ");
    }
    if (ValidateUtil.isNotNull(filter.getEmployeeByProjectManagers())) {
        where += FilterUtil.addFilterAnd(where,
                "p.employeeByProjectManager.idEmployee IN (:employeeByProjectManagers) ");
    }
    if (ValidateUtil.isNotNull(filter.getCustomers())) {
        where += FilterUtil.addFilterAnd(where, "p.customer.idCustomer IN (:customers) ");
    }
    if (ValidateUtil.isNotNull(filter.getCustomertypes())) {
        where += FilterUtil.addFilterAnd(where, "p.contracttype.idContractType IN (:customertypes) ");
    }
    if (ValidateUtil.isNotNull(filter.getPrograms())) {
        where += FilterUtil.addFilterAnd(where, "p.program.idProgram IN (:programs) ");
    }
    if (ValidateUtil.isNotNull(filter.getCategories())) {
        where += FilterUtil.addFilterAnd(where, "p.category.idCategory IN (:categories) ");
    }
    if (ValidateUtil.isNotNull(filter.getSellers())) {
        where += FilterUtil.addFilterAnd(where, "actSell.seller.idSeller IN (:sellers) ");
    }
    if (ValidateUtil.isNotNull(filter.getGeography())) {
        where += FilterUtil.addFilterAnd(where, "p.geography.idGeography IN (:geography) ");
    }
    if (ValidateUtil.isNotNull(filter.getFundingsources())) {
        where += FilterUtil.addFilterAnd(where, "fs.fundingsource.idFundingSource IN (:fundingsources) ");
    }
    if (ValidateUtil.isNotNull(filter.getProjects())) {
        where += FilterUtil.addFilterAnd(where, "p.idProject IN (:projects) ");
    }
    if (ValidateUtil.isNotNull(filter.getStatus())) {
        where += FilterUtil.addFilterAnd(where, "p.status IN (:status) ");
    }
    if (ValidateUtil.isNotNull(filter.getInvestmentStatus())) {
        where += FilterUtil.addFilterAnd(where, "p.investmentStatus IN (:investmentStatus) ");
    }
    if (ValidateUtil.isNotNull(filter.getLabels())) {
        where += FilterUtil.addFilterAnd(where, "pl.label.idLabel IN (:labels) ");
    }

    Query query = getSession().createQuery(q + where);

    // Add parameter for priority
    if (!ValidateUtil.isNull(filter.getPriority())) {

        if ((ProjectSearch.GREATHER_EQUAL.equals(filter.getPriority())
                || ProjectSearch.LESS_EQUAL.equals(filter.getPriority())) && filter.getLastPriority() != null) {

            query.setInteger("lastPriority", filter.getLastPriority());
        } else if (ProjectSearch.BETWEEN.equals(filter.getPriority()) && filter.getLastPriority() != null
                && filter.getFirstPriority() != null) {

            query.setInteger("firstPriority", filter.getFirstPriority());
            query.setInteger("lastPriority", filter.getLastPriority());
        }
    }

    if (filter.getSince() != null) {
        query.setDate("since", filter.getSince());
    }
    if (filter.getUntil() != null) {
        query.setDate("until", filter.getUntil());
    }
    if (filter.getInternalProject() != null) {
        query.setBoolean("internalProject", filter.getInternalProject());
    }
    if (filter.getBudgetYear() != null) {
        query.setInteger("budgetYear", filter.getBudgetYear());
    }
    if (ValidateUtil.isNotNull(filter.getProjectName())) {
        query.setString("projectName", "%" + filter.getProjectName().toUpperCase() + "%");
    }
    if (ValidateUtil.isNotNull(filter.getRag())) {
        query.setCharacter("rag", filter.getRag().charAt(0));
    }
    if (filter.getCompany() != null) {
        query.setEntity("company", filter.getCompany());
    }
    if (filter.getEmployeeByInvestmentManager() != null) {
        query.setEntity("employeeByInvestmentManager", filter.getEmployeeByInvestmentManager());
    }
    if (ValidateUtil.isNotNull(filter.getEmployeeByFunctionalManagers())) {
        query.setParameterList("employeeByFunctionalManagers", filter.getEmployeeByFunctionalManagers());
    }
    if (filter.getStakeholder() != null) {
        query.setEntity("stakeholder", filter.getStakeholder());
    }
    if (filter.getProgramManager() != null) {
        query.setEntity("programManager", filter.getProgramManager());
    }

    if (ValidateUtil.isNotNull(filter.getPerformingorgs())) {
        query.setParameterList("performingorgs", filter.getPerformingorgs());
    }
    if (ValidateUtil.isNotNull(filter.getEmployeeBySponsors())) {
        query.setParameterList("employeeBySponsors", filter.getEmployeeBySponsors());
    }
    if (ValidateUtil.isNotNull(filter.getEmployeeByProjectManagers())) {
        query.setParameterList("employeeByProjectManagers", filter.getEmployeeByProjectManagers());
    }
    if (ValidateUtil.isNotNull(filter.getCustomers())) {
        query.setParameterList("customers", filter.getCustomers());
    }
    if (ValidateUtil.isNotNull(filter.getCustomertypes())) {
        query.setParameterList("customertypes", filter.getCustomertypes());
    }
    if (ValidateUtil.isNotNull(filter.getPrograms())) {
        query.setParameterList("programs", filter.getPrograms());
    }
    if (ValidateUtil.isNotNull(filter.getCategories())) {
        query.setParameterList("categories", filter.getCategories());
    }
    if (ValidateUtil.isNotNull(filter.getSellers())) {
        query.setParameterList("sellers", filter.getSellers());
    }
    if (ValidateUtil.isNotNull(filter.getGeography())) {
        query.setParameterList("geography", filter.getGeography());
    }
    if (ValidateUtil.isNotNull(filter.getFundingsources())) {
        query.setParameterList("fundingsources", filter.getFundingsources());
    }
    if (ValidateUtil.isNotNull(filter.getProjects())) {
        query.setParameterList("projects", filter.getProjects());
    }
    if (ValidateUtil.isNotNull(filter.getStatus())) {
        query.setParameterList("status", filter.getStatus());
    }
    if (ValidateUtil.isNotNull(filter.getInvestmentStatus())) {
        query.setParameterList("investmentStatus", filter.getInvestmentStatus());
    }
    if (ValidateUtil.isNotNull(filter.getLabels())) {
        query.setParameterList("labels", filter.getLabels());
    }

    return query.list();
}

From source file:es.sm2.openppm.core.dao.TeamMemberDAO.java

License:Open Source License

/**
 * Search Team Member by criteria/*from  ww w . ja  v  a2 s .c  o m*/
 * 
 * @param employee
 * @param projectactivity
 * @param datein
 * @param dateout
 * @return
 */
public Teammember searchByCriteria(Employee employee, Projectactivity projectactivity, Date datein,
        Date dateout) {

    Query query = getSession().createQuery("select teammember " + "from Teammember as teammember "
            + "join fetch teammember.employee as employee "
            + "join fetch employee.resourceprofiles as resourceprofiles "
            + "join teammember.projectactivity as projAc "
            + "where ((teammember.dateIn between :datein and :dateout) "
            + "or (teammember.dateOut between :datein and :dateout) "
            + "or (:datein between teammember.dateIn and teammember.dateOut) "
            + "or (:dateout between teammember.dateIn and teammember.dateOut)) "
            + "and employee.idEmployee = :idEmployee and projAc.idActivity = :idActivity ");
    query.setInteger("idEmployee", employee.getIdEmployee());
    query.setInteger("idActivity", projectactivity.getIdActivity());
    query.setDate("datein", datein);
    query.setDate("dateout", dateout);

    Teammember teammember = null;

    if (!query.list().isEmpty()) {
        teammember = (Teammember) query.list().get(0);
    }

    return teammember;
}

From source file:es.sm2.openppm.core.dao.TeamMemberDAO.java

License:Open Source License

/**
 * Get Employees to a time sheet pending approve
 * @param project//  w  w  w . jav a2 s .com
 * @param initdate
 * @param enddate
 * @return
 */
public List<Employee> membersTracking(Project project, Date initdate, Date enddate) {

    List<Employee> employees = new ArrayList<Employee>();

    String queryString = "select distinct employee.idEmployee " + "from Teammember as teammember "
            + "join teammember.employee as employee " + "join teammember.projectactivity as projAc "
            + "join projAc.project as project " + "right join employee.weektimesheets as weekTs "
            + "join weekTs.projecttimesheets as timesheet " + "where project.idProject = :idProject "
            + "and (timesheet.appLevel = :minAppLevel " + "or timesheet.appLevel = :maxAppLevel ) "
            + "and timesheet.timeSheetDate between :initdate and :enddate ";

    Query query = getSession().createQuery(queryString);
    query.setInteger("idProject", project.getIdProject());
    query.setDate("initdate", initdate);
    query.setDate("enddate", enddate);

    query.setCharacter("minAppLevel", Constants.APP1);
    query.setCharacter("maxAppLevel", Constants.APP2);

    List<Integer> idEmployees = query.list();
    StringBuilder ids = new StringBuilder();

    for (Integer id : idEmployees) {
        if (ids.toString().equals(StringPool.BLANK)) {
            ids.append(id.toString());
        } else {
            ids.append(StringPool.COMMA + id.toString());
        }
    }

    if (!ids.toString().equals(StringPool.BLANK)) {
        Query query2 = getSession().createQuery("select employee " + "from Teammember as teammember "
                + "join teammember.employee as employee " + "join fetch employee.contact as contact "
                + "join fetch employee.resourceprofiles as resourceprofiles "
                + "join fetch employee.employee as rm " + "where employee.idEmployee in (" + ids.toString()
                + ")");

        employees = query2.list();
    }

    return employees;
}

From source file:es.sm2.openppm.core.dao.TeamMemberDAO.java

License:Open Source License

/**
 * List Team Members by program//from   w ww .  j  av a 2  s.  c  o m
 * 
 * @param idProgram
 * @param initdate
 * @param enddate
 * @return
 */
public List<Teammember> membersByProgram(Integer idProgram, Date initdate, Date enddate) {

    String queryString = "select distinct teammember " + "from Teammember as teammember "
            + "join fetch teammember.employee as e " + "join fetch e.resourceprofiles as resProf "
            + "join teammember.projectactivity as projAc " + "join projAc.project as project "
            + "join project.program as program " + "where program.idProgram = :idProgram "
            + "and ((teammember.dateIn between :initdate and :enddate) "
            + "or (teammember.dateOut between :initdate and :enddate) "
            + "or (:initdate between teammember.dateIn and teammember.dateOut) "
            + "or (:enddate between teammember.dateIn and teammember.dateOut)) ";

    Query query = getSession().createQuery(queryString);
    query.setInteger("idProgram", idProgram);
    query.setDate("initdate", initdate);
    query.setDate("enddate", enddate);

    return query.list();
}

From source file:es.sm2.openppm.core.dao.TeamMemberDAO.java

License:Open Source License

/**
 * Update dates teammember//  w  ww.jav  a  2 s . c  o  m
 *
 * @param teammember
 * @param dateIn
 * @param dateOut
 */
public void updateDates(Teammember teammember, Date dateIn, Date dateOut) {

    Query query = getSession().createQuery("update Teammember t "
            + " set t.dateIn = :dateIn , t.dateOut = :dateOut" + " where t.idTeamMember = :idTeamMember");

    query.setInteger("idTeamMember", teammember.getIdTeamMember());
    query.setDate("dateIn", dateIn);
    query.setDate("dateOut", dateOut);

    query.executeUpdate();
}