Example usage for org.hibernate.criterion Restrictions or

List of usage examples for org.hibernate.criterion Restrictions or

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions or.

Prototype

public static LogicalExpression or(Criterion lhs, Criterion rhs) 

Source Link

Document

Return the disjuction of two expressions

Usage

From source file:com.sccl.attech.modules.sys.service.SystemService.java

License:Open Source License

/**
 * ?id??//w  ww .jav a  2  s.co m
 * @param page
 * @param searchName
 * @param officeId
 * @return
 */
public Page<User> findByOffice(Page<User> page, String searchName, String officeId) {
    DetachedCriteria dc = userDao.createDetachedCriteria();

    dc.createAlias("office", "office");
    if (StringUtils.isNotBlank(officeId)) {
        dc.add(Restrictions.eq("office.id", officeId));
    }

    if (StringUtils.isNotBlank(searchName)) {
        dc.add(Restrictions.or(Restrictions.like("name", "%" + searchName + "%"),
                Restrictions.like("mobile", "%" + searchName + "%")));
    }
    dc.add(Restrictions.ne("userType", "2"));//
    dc.add(Restrictions.eq(User.FIELD_DEL_FLAG, User.DEL_FLAG_NORMAL));
    return userDao.find(page, dc);
}

From source file:com.sccl.attech.modules.sys.service.SystemService.java

License:Open Source License

/**
 * ?id?/*from   w w  w  .ja v  a2 s  . c  o  m*/
 * @param page
 * @param searchName
 * @param officeId
 * @return
 */
public Page<User> findWorkOutByOffice(Page<User> page, String searchName, String officeId) {
    DetachedCriteria dc = userDao.createDetachedCriteria();

    dc.createAlias("office", "office");
    if (StringUtils.isNotBlank(officeId)) {
        dc.add(Restrictions.eq("office.id", officeId));
    }

    if (StringUtils.isNotBlank(searchName)) {
        dc.add(Restrictions.or(Restrictions.like("name", "%" + searchName + "%"),
                Restrictions.like("mobile", "%" + searchName + "%")));
    }

    dc.add(Restrictions.eq("userType", "2"));//
    dc.add(Restrictions.eq(User.FIELD_DEL_FLAG, User.DEL_FLAG_NORMAL));
    return userDao.find(page, dc);
}

From source file:com.scopix.periscope.extractionplanmanagement.dao.ExtractionPlanCustomizingDAOImpl.java

License:Open Source License

/**
 * Retorna una lista ExtractionPlanCustomizing unicos que esten activos o nulos
 *///ww w  . ja v a2 s  . c  om
@Override
public List<ExtractionPlanCustomizing> getExtractionPlanCustomizingActiveOrNullList(
        ExtractionPlanCustomizing epcFilter) {
    List<ExtractionPlanCustomizing> result = new ArrayList<ExtractionPlanCustomizing>();
    Session session = this.getSession();
    try {
        Criteria criteria = session.createCriteria(ExtractionPlanCustomizing.class);
        //criteria.addOrder(Order.asc("evaluationOrder"));
        if (epcFilter != null) {
            if (epcFilter.getSituationTemplate() != null && epcFilter.getSituationTemplate().getId() != null
                    && epcFilter.getSituationTemplate().getId() > 0) {
                criteria.add(Restrictions.eq("situationTemplate.id", epcFilter.getSituationTemplate().getId()));
            }

            if (epcFilter.getStore() != null && epcFilter.getStore().getId() != null
                    && epcFilter.getStore().getId() > 0) {
                criteria.add(Restrictions.eq("store.id", epcFilter.getStore().getId()));
            }
        }

        criteria.add(Restrictions.or(Restrictions.eq("active", true), Restrictions.isNull("active")));

        result = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
    } catch (HibernateException e) {
        log.error(e, e);
    } finally {
        this.releaseSession(session);
    }
    return result;
}

From source file:com.scopix.periscope.extractionplanmanagement.dao.ExtractionPlanCustomizingDAOImpl.java

License:Open Source License

/**
 * retorna un ExtractionPlanCustomizing dado SituationTemplate, MetricTemplate, Store, EvidenceProvider Esto se genera por
 * cambio de generacion y extraccion del EPC
 *///from  w  w w . j  a v  a  2 s. c o m
@Override
public ExtractionPlanCustomizing getWizardCustomizing(ExtractionPlanCustomizing wizardCustomizing) {
    ExtractionPlanCustomizing extractionPlanCustomizing = null;
    Session session = this.getSession();
    try {
        Criteria criteria = session.createCriteria(ExtractionPlanCustomizing.class);
        //criteria.addOrder(Order.asc("evaluationOrder"));
        if (wizardCustomizing != null) {
            if (wizardCustomizing.getSituationTemplate() != null
                    && wizardCustomizing.getSituationTemplate().getId() != null
                    && wizardCustomizing.getSituationTemplate().getId() > 0) {
                criteria.add(Restrictions.eq("situationTemplate.id",
                        wizardCustomizing.getSituationTemplate().getId()));
            }
            //si existen metricas definidas
            if (!wizardCustomizing.getExtractionPlanMetrics().isEmpty()) {
                MetricTemplate metricTemplate = wizardCustomizing.getExtractionPlanMetrics().get(0)
                        .getMetricTemplate();
                if (metricTemplate != null && metricTemplate.getId() != null && metricTemplate.getId() > 0) {
                    criteria.add(Restrictions.eq("metricTemplate.id", metricTemplate.getId()));
                }
            }

            if (wizardCustomizing.getStore() != null && wizardCustomizing.getStore().getId() != null
                    && wizardCustomizing.getStore().getId() > 0) {
                criteria.add(Restrictions.eq("store.id", wizardCustomizing.getStore().getId()));
            }
        }
        criteria.add(Restrictions.or(Restrictions.eq("active", true), Restrictions.isNull("active")));
        List<ExtractionPlanCustomizing> l = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
        if (l.size() > 1) {
            for (ExtractionPlanCustomizing epc : l) {
                if (epc.isActive() == null) {
                    extractionPlanCustomizing = epc;
                    break;
                }
            }
            log.debug("lista de epc > 1 " + l.size());
            //todo revisar que paso
        } else if (l.size() == 1) {
            extractionPlanCustomizing = l.get(0);
        }
    } catch (HibernateException e) {
        log.error(e, e);
    } finally {
        this.releaseSession(session);
    }
    return extractionPlanCustomizing;
}

From source file:com.scopix.periscope.extractionplanmanagement.EServerDAO.java

License:Open Source License

public List<ExtractionPlan> getExtractionPlanListForADate(Date date, String storeName) {
    Criteria criteria = this.getSession().createCriteria(ExtractionPlan.class);
    criteria.addOrder(Order.asc("expirationDate"));
    criteria.add(/*from w w  w . j  a va 2  s.c  o  m*/
            Restrictions.or(Restrictions.isNull("expirationDate"), Restrictions.gt("expirationDate", date)));
    criteria.add(Restrictions.eq("storeName", storeName));
    List<ExtractionPlan> eps = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
    return eps;
}

From source file:com.scopix.periscope.extractionservicesserversmanagement.dao.ExtractionPlanDetailDAO.java

License:Open Source License

public List<ExtractionPlan> getExtractionPlanByExpirationDate(Date dateStart) {

    Criteria criteria = this.getSession().createCriteria(ExtractionPlan.class);
    criteria.add(Restrictions.or(Restrictions.gt("expiration", dateStart), Restrictions.isNull("expiration")));
    criteria.addOrder(Order.asc("expiration"));
    List<ExtractionPlan> extractionPlans = criteria.list();
    return extractionPlans;
}

From source file:com.selfsoft.business.service.impl.TbBusinessSpecialBalanceServiceImpl.java

public List<TbBusinessSpecialBalance> findByTbBusinessSpecialBalance(
        TbBusinessSpecialBalance tbBusinessSpecialBalance) {

    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TbBusinessSpecialBalance.class);

    if (null != tbBusinessSpecialBalance) {

        if (null != tbBusinessSpecialBalance.getEditCode()
                && !"".equals(tbBusinessSpecialBalance.getEditCode())) {

            detachedCriteria//w w  w . java 2  s .  c  o m
                    .add(Restrictions.like("editCode", "%" + tbBusinessSpecialBalance.getEditCode() + "%"));
        }
        /*
         * if(null!=tbBusinessSpecialBalance.getBananceDateStart()){
         * detachedCriteria.add(Restrictions.ge("bananceDate",
         * tbBusinessSpecialBalance.getBananceDateStart())); }
         * if(null!=tbBusinessSpecialBalance.getBananceDateEnd()){
         * detachedCriteria.add(Restrictions.le("bananceDate",
         * tbBusinessSpecialBalance.getBananceDateEnd())); }
         */
        if (null != tbBusinessSpecialBalance.getSpecialType()) {
            detachedCriteria.add(Restrictions.eq("specialType", tbBusinessSpecialBalance.getSpecialType()));
        }
        if (null != tbBusinessSpecialBalance.getBalanceCodeDB()
                && !"".equals(tbBusinessSpecialBalance.getBalanceCodeDB())) {
            detachedCriteria.add(
                    Restrictions.like("balanceCode", "%" + tbBusinessSpecialBalance.getBalanceCodeDB() + "%"));
        }
        if (null != tbBusinessSpecialBalance.getBalanceCode()
                && !"".equals(tbBusinessSpecialBalance.getBalanceCode())) {

            List<TbBusinessBalance> tbBusinessBalanceList = tbBusinessBalanceService
                    .findTbBusinessBalanceByBalanceCode(tbBusinessSpecialBalance.getBalanceCode());

            if (null != tbBusinessBalanceList && tbBusinessBalanceList.size() > 0) {

                detachedCriteria
                        .add(Restrictions.eq("tbBusinessBalance.id", tbBusinessBalanceList.get(0).getId()));

            }

        }
        if (null != tbBusinessSpecialBalance.getEntrustCodeDB()
                && !"".equals(tbBusinessSpecialBalance.getEntrustCodeDB())) {
            detachedCriteria.add(
                    Restrictions.like("entrustCode", "%" + tbBusinessSpecialBalance.getEntrustCodeDB() + "%"));
        }
        // if(null!=tbBusinessSpecialBalance.getTbBusinessBalance()){

        /*
         * detachedCriteria.createAlias("tbBusinessBalance","tbBusinessBalance"
         * );
         * 
         * if(null!=tbBusinessSpecialBalance.getTbBusinessBalance().
         * getBalanceCode
         * ()&&!"".equals(tbBusinessSpecialBalance.getTbBusinessBalance
         * ().getBalanceCode())){ detachedCriteria.add(Restrictions.like(
         * "tbBusinessBalance.balanceCode",
         * "%"+tbBusinessSpecialBalance.getTbBusinessBalance
         * ().getBalanceCode()+"%")); }
         */

        if (null != tbBusinessSpecialBalance.getEntrustCode()
                && !"".equals(tbBusinessSpecialBalance.getEntrustCode())) {
            // detachedCriteria.createAlias("tbBusinessBalance.tbFixEntrust","tbFixEntrust");
            TbFixEntrust tbFixEntrust = tbFixEntrustService
                    .findByEntrustCode(tbBusinessSpecialBalance.getEntrustCode());

            if (null != tbFixEntrust) {

                TbBusinessBalance tbBusinessBalance = tbBusinessBalanceService
                        .findByEntrustId(tbFixEntrust.getId());

                if (null != tbBusinessBalance) {

                    detachedCriteria.add(
                            Restrictions.or(Restrictions.eq("tbBusinessBalance.id", tbBusinessBalance.getId()),
                                    Restrictions.like("entrustId", tbFixEntrust.getId())));

                }

                else {

                    detachedCriteria.add(Restrictions.like("entrustId", tbFixEntrust.getId()));

                }
            }

        }
        if (null != tbBusinessSpecialBalance.getBananceDateStart()) {
            detachedCriteria
                    .add(Restrictions.ge("bananceDate", tbBusinessSpecialBalance.getBananceDateStart()));
        }
        if (null != tbBusinessSpecialBalance.getBananceDateEnd()) {
            detachedCriteria.add(Restrictions.le("bananceDate",
                    CommonMethod.addDate(tbBusinessSpecialBalance.getBananceDateEnd(), 1)));
        }

        // }

    }

    return tbBusinessSpecialBalanceDao.findByCriteria(detachedCriteria, tbBusinessSpecialBalance);
}

From source file:com.selfsoft.business.service.impl.TbFixEntrustServiceImpl.java

public List<TbFixEntrust> findByTbFixEntrust(TbFixEntrust tbFixEntrust) {
    // TODO Auto-generated method stub
    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TbFixEntrust.class);

    if (null != tbFixEntrust) {

        if (null != tbFixEntrust.getId()) {
            detachedCriteria.add(Restrictions.eq("id", tbFixEntrust.getId()));
        }/*from   ww  w  .ja  v  a  2  s  .  c  o m*/

        if (null != tbFixEntrust.getEntrustCode() && !"".equals(tbFixEntrust.getEntrustCode())) {
            detachedCriteria.add(Restrictions.like("entrustCode", "%" + tbFixEntrust.getEntrustCode() + "%"));
        }
        if (null != tbFixEntrust.getFixDateStart()) {
            detachedCriteria.add(Restrictions.ge("fixDate", tbFixEntrust.getFixDateStart()));
        }
        if (null != tbFixEntrust.getFixDateEnd()) {
            detachedCriteria
                    .add(Restrictions.le("fixDate", CommonMethod.addDate(tbFixEntrust.getFixDateEnd(), 1)));
        }

        if (null != tbFixEntrust.getMinutes()) {

            Date newDate = new Date();

            tbFixEntrust.setEstimateDateStart(newDate);

            tbFixEntrust.setEstimateDateEnd(CommonMethod.addMinute(new Date(), tbFixEntrust.getMinutes()));

            if (null != tbFixEntrust.getEstimateDateStart()) {
                detachedCriteria.add(Restrictions.ge("estimateDate", tbFixEntrust.getEstimateDateStart()));
            }
            if (null != tbFixEntrust.getEstimateDateEnd()) {
                detachedCriteria.add(Restrictions.le("estimateDate", tbFixEntrust.getEstimateDateEnd()));
            }
        }

        if (null != tbFixEntrust.getTbCustomer()) {

            boolean customerCodeBoolean = (null != tbFixEntrust.getTbCustomer().getCustomerCode()
                    && !"".equals(tbFixEntrust.getTbCustomer().getCustomerCode()));

            boolean customerNameBoolean = (null != tbFixEntrust.getTbCustomer().getCustomerName()
                    && !"".equals(tbFixEntrust.getTbCustomer().getCustomerName()));

            boolean telephoneBoolean = (null != tbFixEntrust.getTbCustomer().getTelephone()
                    && !"".equals(tbFixEntrust.getTbCustomer().getTelephone()));

            if (customerCodeBoolean || customerNameBoolean || telephoneBoolean) {

                detachedCriteria.createAlias("tbCustomer", "tbCustomer");
            }

            if (null != tbFixEntrust.getTbCustomer().getCustomerCode()
                    && !"".equals(tbFixEntrust.getTbCustomer().getCustomerCode())) {
                detachedCriteria.add(Restrictions.like("tbCustomer.customerCode",
                        "%" + tbFixEntrust.getTbCustomer().getCustomerCode() + "%"));
            }

            if (null != tbFixEntrust.getTbCustomer().getCustomerName()
                    && !"".equals(tbFixEntrust.getTbCustomer().getCustomerName())) {
                detachedCriteria.add(Restrictions.like("tbCustomer.customerName",
                        "%" + tbFixEntrust.getTbCustomer().getCustomerName() + "%"));
            }

            if (null != tbFixEntrust.getTbCustomer().getTelephone()
                    && !"".equals(tbFixEntrust.getTbCustomer().getTelephone())) {
                detachedCriteria.add(Restrictions.like("tbCustomer.telephone",
                        "%" + tbFixEntrust.getTbCustomer().getTelephone() + "%"));
            }
        }

        if (null != tbFixEntrust.getTbCarInfo()) {
            detachedCriteria.createAlias("tbCarInfo", "tbCarInfo");

            if (null != tbFixEntrust.getTbCarInfo().getLicenseCode()) {
                detachedCriteria.add(Restrictions.like("tbCarInfo.licenseCode",
                        "%" + tbFixEntrust.getTbCarInfo().getLicenseCode() + "%"));
            }

            if (null != tbFixEntrust.getTbCarInfo().getChassisCode()) {
                detachedCriteria.add(Restrictions.like("tbCarInfo.chassisCode",
                        "%" + tbFixEntrust.getTbCarInfo().getChassisCode() + "%"));
            }

            if (null != tbFixEntrust.getTbCarInfo().getTmCarModelType()) {
                detachedCriteria.createAlias("tbCarInfo.tmCarModelType", "tmCarModelType");

                if (null != tbFixEntrust.getTbCarInfo().getTmCarModelType().getId()) {
                    detachedCriteria.add(Restrictions.eq("tmCarModelType.id",
                            tbFixEntrust.getTbCarInfo().getTmCarModelType().getId()));
                }
            }
        }

        if (null != tbFixEntrust.getIsvalid()) {
            detachedCriteria.add(Restrictions.eq("isvalid", tbFixEntrust.getIsvalid()));
        }

        if (null != tbFixEntrust.getIsFinish()) {
            detachedCriteria.add(Restrictions.eq("isFinish", tbFixEntrust.getIsFinish()));
        }

        if (null != tbFixEntrust.getEntrustStatus()) {
            detachedCriteria.add(Restrictions.eq("entrustStatus", tbFixEntrust.getEntrustStatus()));
        }

        if (null != tbFixEntrust.getWjg() && !"".equals(tbFixEntrust.getWjg())) {

            if ("wjg".equals(tbFixEntrust.getWjg())) {

                detachedCriteria.add(Restrictions.ne("entrustStatus", 2L));

                detachedCriteria.add(Restrictions.ne("entrustStatus", 3L));

            }

            else if ("yjg".equals(tbFixEntrust.getWjg())) {

                detachedCriteria.add(Restrictions.or(Restrictions.eq("entrustStatus", 2L),
                        Restrictions.eq("entrustStatus", 3L)));

            }
        }

        if (null != tbFixEntrust.getJsqk() && !"".equals(tbFixEntrust.getJsqk())) {

            if ("wjs".equals(tbFixEntrust.getJsqk())) {

                detachedCriteria.add(Restrictions.ne("entrustStatus", 3L));

            }

            else if ("yjs".equals(tbFixEntrust.getJsqk())) {

                detachedCriteria.add(Restrictions.eq("entrustStatus", 3L));

            }
        }

        if (null != tbFixEntrust.getTmUser() && null != tbFixEntrust.getTmUser().getId()) {

            detachedCriteria.add(Restrictions.eq("tmUser.id", tbFixEntrust.getTmUser().getId()));

        }

    }
    return tbFixEntrustDao.findByCriteria(detachedCriteria, tbFixEntrust);
}

From source file:com.sjc.cc.instance.service.impl.VmServiceImpl.java

/**
 * ?//from ww w  .  j  av a 2s. c o m
 */
@SuppressWarnings("unchecked")
public boolean expandVm(Long srtApplyedhostAssId) throws Exception, Throwable {
    TccSrtApplyedhostAss srtApplyedhostAss = vmAssistService.getSrtApplyedhostAss(srtApplyedhostAssId);
    TccSrt srt = srtApplyedhostAss.getTccSrt();
    TccExpdCapacity expdCapacity = vmAssistService.getExpdCapacity(srt.getSrtId());
    TccApplyedHostinfo applyedHostinfo = srtApplyedhostAss.getTccApplyedHostinfo();
    TccApplyedHostResource applyedHostResource = vmAssistService
            .getApplyedHostResource(applyedHostinfo.getApplyResourceId());
    applyedHostResource.setProcessStatus(BusinessEnvironment.RESOURCE_TYPE_INSTALL); // 
    vmAssistService.updateApplyedHostResource(applyedHostResource);
    applyedHostResource = vmAssistService.getApplyedHostResource(applyedHostResource.getApplyResourceId());
    boolean flag = false;
    String VirtualType = applyedHostResource.getVirtualType();
    // ?
    // 01.VCVC?
    if (BusinessEnvironment.VIRTUAL_TYPE_VC.equals(VirtualType)) {
        flag = capacityMgmtService.upgradeVmVC(srt.getSrtId());
    }
    // 02.CSCS?
    else if (BusinessEnvironment.VIRTUAL_TYPE_CS.equals(VirtualType)) {
        flag = capacityMgmtService.upgradeVmCS(srt.getSrtId());// ?
    }
    if (!flag) {
        applyedHostResource.setProcessStatus(BusinessEnvironment.RESOURCE_TYPE_FAIL); // 
        vmAssistService.updateApplyedHostResource(applyedHostResource);
        return flag;
    }

    // ???
    TccApplyedHostResource newApplyedHostResource = new TccApplyedHostResource();
    BeanUtils.copyProperties(newApplyedHostResource, applyedHostResource);
    newApplyedHostResource.setCpuCoreCount(expdCapacity.getCpuCoreCount());
    newApplyedHostResource.setRamSize(expdCapacity.getRamSize());
    if (null != expdCapacity.getStoreSize()) {
        newApplyedHostResource.setStorageSize(newApplyedHostResource.getStorageSize() == null ? 0
                : newApplyedHostResource.getStorageSize() + expdCapacity.getStoreSize());
    } else if (null != expdCapacity.getNasStoreSize()) {
        newApplyedHostResource.setNasStorageSize(newApplyedHostResource.getNasStorageSize() == null ? 0
                : newApplyedHostResource.getNasStorageSize() + expdCapacity.getNasStoreSize());
    }
    newApplyedHostResource.setOrginResourceID(applyedHostResource.getOrginResourceID());
    newApplyedHostResource.setRunStatusCd(BusinessEnvironment.VM_RUN_STATUS_RUNNING);
    // ?
    newApplyedHostResource.setApplyResourceId(null);
    newApplyedHostResource.setLastuptDttm(null); // ?
    newApplyedHostResource.setProcessStatus(BusinessEnvironment.RESOURCE_TYPE_SUCCESS); // ??
    // ?
    newApplyedHostResource = vmAssistService.mergeApplyedHostResource(newApplyedHostResource);

    // ??
    applyedHostResource.setRunStatusCd(BusinessEnvironment.RESOURCE_RUNTYPE_EXPDEND);// ?
    applyedHostResource.setProcessStatus(BusinessEnvironment.RESOURCE_TYPE_SUCCESS);// ?
    applyedHostResource.setEnableFlg(EnvironmentConstant.DISENABLE); // 
    vmAssistService.updateApplyedHostResource(applyedHostResource);

    // ????
    srtApplyedhostAss.setTccApplyedHostinfo(newApplyedHostResource);
    vmAssistService.updateSrtApplyedhostAss(srtApplyedhostAss);
    // ?
    List<TccProjectAss> newProjectAssList = new ArrayList<TccProjectAss>();
    TccProjectAss newTccProjectAss = new TccProjectAss();

    // ??
    TccProjectAss projectAss = new TccProjectAss();
    projectAss.setTccApplyedHostinfo(applyedHostResource);

    // ***** by zhachaoy *****
    DetachedCriteria criteria = DetachedCriteria.forClass(TccProjectAss.class);
    if (null != projectAss && null != projectAss.getProjectAssId()) {
        criteria.add(Restrictions.eq("projectAssId", projectAss.getProjectAssId()));
    }
    if (null != projectAss && null != projectAss.getTccProjectInfo()) {
        criteria.add(Restrictions.eq("tccProjectInfo", projectAss.getTccProjectInfo()));
    }
    if (null != projectAss && null != projectAss.getTccApplyedHostinfo()) {
        criteria.add(Restrictions.eq("tccApplyedHostinfo", projectAss.getTccApplyedHostinfo()));
    }
    // ?1
    criteria.add(Restrictions.or(Restrictions.eq("enableFlg", EnvironmentConstant.ENABLE),
            Restrictions.isNull("enableFlg")));

    List<TccProjectAss> projectAssList = commonDao.findByCriteria(criteria);
    // ##### by zhachaoy #####

    for (TccProjectAss pa : projectAssList) {
        // ?
        BeanUtils.copyProperties(newTccProjectAss, pa);
        newTccProjectAss.setProjectAssId(null);
        newTccProjectAss.setTccInstanceInfo(null);
        newTccProjectAss.setTccApplyedHostinfo(newApplyedHostResource);
        newProjectAssList.add(newTccProjectAss);
        pa.setEnableFlg(EnvironmentConstant.DISENABLE);
    }
    vmAssistService.updateProjectAssList(projectAssList);
    // ??
    this.commonDao.saveOrUpdateAll(newProjectAssList);

    // 
    List<Object> list = snapshotCategoryService
            .getVmSnapshotCategory(applyedHostResource.getApplyResourceId().toString());
    List<TccSnapshotCfg> tccSnapshotCfgsList = null;
    List<TccSnapshotHistory> tccSnapshotHistories = null;
    if (list != null && list.size() > 0) {
        for (int k = 0; k < list.size(); k++) {
            if (k == 0) {
                // ??
                tccSnapshotCfgsList = (List<TccSnapshotCfg>) list.get(0);
            } else if (k == 1) {
                // ?
                tccSnapshotHistories = (List<TccSnapshotHistory>) list.get(1);
            }
        }
        // ?resourceId? ?resourceId?
        if (tccSnapshotCfgsList != null && tccSnapshotCfgsList.size() > 0) {
            for (TccSnapshotCfg sc : tccSnapshotCfgsList) {
                sc.setHostId(newApplyedHostResource.getApplyResourceId());
                this.commonDao.saveOrUpdate(sc);
            }
        }
        if (tccSnapshotHistories != null && tccSnapshotHistories.size() > 0) {
            // ??resourceId? ?resourceId?
            for (TccSnapshotHistory sh : tccSnapshotHistories) {
                sh.setVmId(newApplyedHostResource.getApplyResourceId());
                this.commonDao.saveOrUpdate(sh);
            }
        }

    }
    LoginUserInfo loginUserInfo = LoginUserInfoHolder.getInstance().getCurrentUser();
    logService.saveOperLog("?",
            "" + loginUserInfo.getEmpName() + "cloudstack"
                    + newApplyedHostResource.getHostNane() + BusinessEnvironment.OPER_RESULT_SUCCESS,
            newApplyedHostResource, 2);
    return true;
}

From source file:com.square.adherent.noyau.dao.implementations.contrat.ContratDaoImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from  w ww. j a  v  a  2s.c  o  m
public List<AjustementTarif> getListeAjustementsFromContrat(Long uidContrat) {
    final Criteria crit = createCriteria(AjustementTarif.class);
    crit.createAlias("contrat", "contrat");
    crit.add(Restrictions.eq("contrat.id", uidContrat));
    crit.add(Restrictions.eq("contrat.isVisible", true));
    crit.add(Restrictions.or(Restrictions.ltProperty("dateDebut", "dateFin"), Restrictions.isNull("dateFin")));
    return crit.list();
}