Example usage for org.hibernate.criterion Restrictions isNull

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

Introduction

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

Prototype

public static Criterion isNull(String propertyName) 

Source Link

Document

Apply an "is null" constraint to the named property

Usage

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

/**
 * ?//from  www . j  ava 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

private Criteria createCriteriaByCriteres(CritereRechercheContratDto criteres) {
    final Criteria crit = createCriteria(Contrat.class);
    crit.createAlias("statut", "statut");
    if (criteres != null && criteres.getIdAssure() != null) {
        crit.add(Restrictions.eq("uidAssure", criteres.getIdAssure()));
    }//from  ww  w . j  av a 2s  .com
    if (criteres != null && criteres.getIdSouscripteur() != null) {
        crit.add(Restrictions.eq("uidSouscripteur", criteres.getIdSouscripteur()));
    }
    if (criteres != null && criteres.isIdAssureNull()) {
        crit.add(Restrictions.isNull("uidAssure"));
    }
    if (criteres != null && StringUtils.isNotBlank(criteres.getNumeroContrat())) {
        crit.add(Restrictions.ilike("numeroContrat", criteres.getNumeroContrat() + "%"));
    }
    if (criteres != null && criteres.getHasContratEnCours() != null && criteres.getHasContratEnCours()) {
        crit.add(Restrictions.eq("statut.id", adherentMappingService.getIdStatutContratEnCours()));
    }
    if (criteres != null && criteres.getContratEid() != null
            && StringUtils.isNotBlank(criteres.getContratEid())) {
        crit.add(Restrictions.like("identifiantExterieur", "%" + criteres.getContratEid() + "%"));
    }
    crit.add(Restrictions.eq("isVisible", true));
    return crit;
}

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

License:Open Source License

@SuppressWarnings("unchecked")
@Override//w w  w.j a v  a 2 s .com
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();
}

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

License:Open Source License

@Override
@SuppressWarnings("unchecked")
public List<Contrat> getListeContratsPersonneMorale(Long uidPersonneMorale) {
    final Criteria crit = createCriteria(Contrat.class);
    crit.createAlias("statut", "statut");
    crit.createAlias("nature", "nature");
    crit.add(Restrictions.eq("uidSouscripteur", uidPersonneMorale));
    crit.add(Restrictions.isNull("uidAssure"));
    crit.add(Restrictions.eq("isVisible", true));
    crit.addOrder(Order.asc("statut.ordre"));
    crit.addOrder(Order.asc("nature.ordre"));
    crit.addOrder(Order.desc("dateSignature"));
    return crit.list();
}

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

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from w  w w  . j ava2  s.com
public Contrat getDernierContratRadiePersonneMorale(Long uidPersonneMorale) {
    final Criteria crit = createCriteria(Contrat.class);
    crit.add(Restrictions.eq("uidSouscripteur", uidPersonneMorale));
    crit.add(Restrictions.isNull("uidAssure"));
    crit.add(Restrictions.isNotNull("dateResiliation"));
    crit.add(Restrictions.eq("isVisible", true));
    crit.addOrder(Order.desc("dateResiliation"));
    final List<Contrat> listeConstrats = crit.list();
    if (listeConstrats != null && listeConstrats.size() > 0) {
        return listeConstrats.get(0);
    } else {
        return null;
    }
}

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

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from   w  w w .ja va 2s.  c  o  m
public Contrat getDernierContratPersonneMoraleByCriteres(Long uidPersonneMorale, Long uidNatureContrat,
        Long uidStatutContrat) {
    final Criteria crit = createCriteria(Contrat.class);
    crit.add(Restrictions.eq("uidSouscripteur", uidPersonneMorale));
    crit.add(Restrictions.isNull("uidAssure"));
    crit.createAlias("nature", "nature");
    crit.createAlias("statut", "statut");
    crit.add(Restrictions.eq("nature.id", uidNatureContrat));
    crit.add(Restrictions.eq("statut.id", uidStatutContrat));
    crit.add(Restrictions.eq("isVisible", true));
    crit.addOrder(Order.desc("dateEffet"));
    final List<Contrat> listeConstrats = crit.list();
    if (listeConstrats != null && listeConstrats.size() > 0) {
        return listeConstrats.get(0);
    } else {
        return null;
    }
}

From source file:com.square.core.dao.implementations.ActionDaoImplementation.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from w  ww. j a  v a 2  s. co  m
public List<Action> rechercherActionsSources(CritereActionSyntheseDto critereActionSyntheseDto) {
    final Criteria criteria = createCriteria(Action.class);

    // Critere de la personne
    criteria.createAlias("actionAffectation", "actionAffectationAlias");
    criteria.add(
            Restrictions.eq("actionAffectationAlias.personne.id", critereActionSyntheseDto.getIdPersonne()));
    // Critere action source : l'action source doit etre null ou rattache  une autre personne
    // (pb des actions sur personnes morales dont la source est une action sur personne physique)
    criteria.createAlias("actionSource", "actionSourceAlias", CriteriaSpecification.LEFT_JOIN);
    criteria.createAlias("actionSourceAlias.actionAffectation", "actionSourceAffectationAlias",
            CriteriaSpecification.LEFT_JOIN);
    final Junction disjunction = Restrictions.disjunction();
    disjunction.add(Restrictions.isNull("actionSource"));
    disjunction.add(Restrictions.not(Restrictions.eqProperty("actionSourceAffectationAlias.personne.id",
            "actionAffectationAlias.personne.id")));
    criteria.add(disjunction);
    // Critere sur les opportunits
    if (critereActionSyntheseDto.getIdOpportunite() != null) {
        criteria.add(Restrictions.eq("actionAffectationAlias.opportunite.id",
                critereActionSyntheseDto.getIdOpportunite()));
    }
    // Critre sur la date d'effet
    if (critereActionSyntheseDto.getFiltrerDateCreation() != null
            && critereActionSyntheseDto.getFiltrerDateCreation()) {
        criteria.add(Restrictions.le("dateCreation", Calendar.getInstance()));
    }
    criteria.add(Restrictions.eq("supprime", false));
    // Ordre
    criteria.addOrder(Order.desc(CHAMP_DATE));

    return criteria.list();
}

From source file:com.square.core.dao.implementations.ActionDaoImplementation.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*from www  .j  a v a2s  .  com*/
public List<Action> rechercherActionsSourcesParOpportunite(Long idOpportunite) {
    final Criteria criteria = creerCriteriaActionsParOpportunite(idOpportunite);
    // Critere action source
    criteria.add(Restrictions.isNull("actionSource"));
    criteria.addOrder(Order.asc(CHAMP_DATE));
    return criteria.list();
}

From source file:com.square.notificateur.core.dao.implementations.MessageDaoImplementation.java

License:Open Source License

@SuppressWarnings({ "unchecked" })
@Override/* ww  w .j  ava  2s  .  co  m*/
public List<Message> rechercherMessageParCriteres(MessageCriteresDto criteres) {
    final Long idUtilisateur = criteres.getIdUtilisateur();
    final Calendar datePublication = criteres.getDatePublication();
    final Boolean inclureAquites = criteres.getInclureAquites();
    final Criteria criteria = createCriteria(Message.class);
    if (idUtilisateur != null) {
        criteria.add(Restrictions.eq("idUtilisateur", idUtilisateur));
    }
    if (datePublication != null) {
        criteria.add(Expression.le("datePublication", datePublication));
    }
    if (inclureAquites != null && inclureAquites.equals(false)) {
        criteria.add(Restrictions.isNull("dateReception"));
    }

    // Tri croissant par le nom des Messages trouvs suivant la date de publication
    criteria.addOrder(Order.asc("datePublication"));
    return (List<Message>) criteria.list();
}

From source file:com.square.tarificateur.noyau.dao.implementations.DevisDaoImpl.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
public List<Devis> getListeDevisByCriteres(CriteresRechercheDevisDto criteres) {
    final Criteria crit = createCriteria(Devis.class);
    if (criteres.getCloturer() != null) {
        if (criteres.getCloturer()) {
            crit.add(Restrictions.isNotNull("dateCloture"));
        } else {/*from w  w w .ja v  a  2s  .  c o m*/
            crit.add(Restrictions.isNull("dateCloture"));
        }
    }
    if (criteres.getOrigineSiteWeb() != null) {
        if (criteres.getOrigineSiteWeb()) {
            crit.add(Restrictions.eq("origineSiteWeb", true));
        } else {
            crit.add(Restrictions.or(Restrictions.isNull("origineSiteWeb"),
                    Restrictions.eq("origineSiteWeb", false)));
        }
    }
    if (criteres.getIdFinalite() != null) {
        crit.add(Restrictions.eq("finalite.id", criteres.getIdFinalite()));
    }
    if (criteres.getIdsFinalite() != null && criteres.getIdsFinalite().size() > 0) {
        crit.add(Restrictions.in("finalite.id", criteres.getIdsFinalite()));
    }
    if (criteres.getIdPersonne() != null || criteres.getEidPersonne() != null) {
        final Criteria personne = crit.createAlias("personnePrincipale", "personne");
        if (criteres.getIdPersonne() != null) {
            personne.add(Restrictions.eq("personne.id", criteres.getIdPersonne()));
        }
        if (criteres.getEidPersonne() != null) {
            personne.add(Restrictions.eq("personne.eidPersonne", criteres.getEidPersonne()));
        }
    }
    if (criteres.getIdDevis() != null) {
        crit.add(Restrictions.eq("id", criteres.getIdDevis()));
    }
    return (ArrayList<Devis>) crit.list();
}