List of usage examples for org.hibernate Criteria createCriteria
public Criteria createCriteria(String associationPath) throws HibernateException;
From source file:com.scopix.periscope.evaluationmanagement.dao.EvaluationHibernateDAOImpl.java
License:Open Source License
@Override public List<EvidenceEvaluation> getEvidenceEvaluationByObservedMetric(Integer observedMetricId) throws ScopixException { log.info("start [observedMetricId:" + observedMetricId + "]"); List<EvidenceEvaluation> ret = null; // recuperar datos completos de las evaluaciones evaluaciones y proofs Session session = this.getSession(); try {/*from w ww .jav a2 s . c o m*/ // only evaluations is not rejected Criteria criteria = session.createCriteria(EvidenceEvaluation.class); criteria.createCriteria("observedMetric").add(Restrictions.eq("id", observedMetricId)); criteria.add(Restrictions.eq("rejected", Boolean.FALSE)); ret = criteria.list(); } catch (DataAccessResourceFailureException e) { log.error(e, e); } catch (IllegalStateException e) { log.error(e, e); } catch (HibernateException e) { log.error(e, e); } finally { this.releaseSession(session); } log.info("end"); return ret; }
From source file:com.scopix.periscope.evaluationmanagement.dao.ObservedSituationHibernateDAOImpl.java
License:Open Source License
@Override public List<Formula> getFormulaList(Formula filter) { Session session = this.getSession(); List<Formula> formulas = null; try {/* w w w .j a va2 s . c om*/ Criteria criteria = session.createCriteria(Formula.class); criteria.addOrder(Order.asc("description")); if (filter != null) { if (filter.getDescription() != null && filter.getDescription().length() > 0) { criteria.add(Restrictions.ilike("description", filter.getDescription(), MatchMode.ANYWHERE)); } if (filter.getSituationTemplates() != null && !filter.getSituationTemplates().isEmpty()) { List<Integer> stIds = new ArrayList<Integer>(); for (SituationTemplate st : filter.getSituationTemplates()) { stIds.add(st.getId()); } criteria.createCriteria("situationTemplates").add(Restrictions.in("id", stIds)); } if (filter.getStores() != null && !filter.getStores().isEmpty()) { List<Integer> sIds = new ArrayList<Integer>(); for (Store s : filter.getStores()) { sIds.add(s.getId()); } criteria.createCriteria("stores").add(Restrictions.in("id", sIds)); } if (filter.getType() != null) { criteria.add(Restrictions.eq("type", filter.getType())); } if (filter.getCompliantType() != null) { criteria.add(Restrictions.eq("compliantType", filter.getCompliantType())); } } formulas = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); } catch (HibernateException e) { log.error(e, e); } finally { this.releaseSession(session); } return formulas; }
From source file:com.scopix.periscope.extractionmanagement.dao.EvidenceExtractionDAOImpl.java
License:Open Source License
/** * Obtiene las situaciones a partir del ID del sensor. * * @param camId ID del sensor//from w ww . j a va 2s . com * @return Lista de situaciones * @throws com.scopix.periscope.periscopefoundation.exception.PeriscopeException */ @Override public List<SituationRequest> findSituationsForASensor(String sensorId) throws ScopixException { List<SituationRequest> listSituations = null; try { Criteria criteria = this.getSession().createCriteria(SituationRequest.class); criteria.createCriteria("situationSensors").add(Restrictions.eq("name", sensorId)); criteria.createCriteria("extractionPlan").add(Restrictions.isNull("expirationDate")); //.add(Restrictions.eq("storeName", storeName)); listSituations = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); } catch (Exception e) { throw new ScopixException(e); } return listSituations; }
From source file:com.scopix.periscope.extractionmanagement.dao.EvidenceExtractionDAOImpl.java
License:Open Source License
/** * Obtiene las situaciones a partir del ID de la camara. * * @param camId ID de la camara// w ww. jav a2s . c o m * @return Lista de situaciones * @throws com.scopix.periscope.periscopefoundation.exception.PeriscopeException */ @Override public List<SituationRequest> findSituationsForAEvidenceProvider(String camId) throws ScopixException { List<SituationRequest> listSituations = null; try { Criteria criteria = this.getSession().createCriteria(SituationRequest.class); criteria.createCriteria("metricRequests").createCriteria("evidenceProviderRequests") .add(Restrictions.eq("uniqueDeviceId", camId)); criteria.createCriteria("extractionPlan").add(Restrictions.isNull("expirationDate")); //.add(Restrictions.eq("storeName", storeName)); listSituations = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); } catch (Exception e) { throw new ScopixException(e); } return listSituations; }
From source file:com.scopix.periscope.extractionmanagement.dao.EvidenceExtractionDAOImpl.java
License:Open Source License
@Override public List<SituationMetricExtractionRequest> getSituationMetricExtractionRequest(Integer erId) throws ScopixException { Criteria criteria = this.getSession().createCriteria(SituationMetricExtractionRequest.class); criteria.createCriteria("evidenceExtractionRequest").add(Restrictions.eq("id", erId)); List<SituationMetricExtractionRequest> list = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .list();/*from w w w .j a v a 2s . c o m*/ return list; }
From source file:com.scopix.periscope.extractionplanmanagement.dao.ExtractionPlanCustomizingDAOImpl.java
License:Open Source License
@Override public List<EvidenceRequest> getEvidenceRequestList(EvidenceRequest evidenceRequest, Date init, Date end) { List<EvidenceRequest> list = null; Session session = this.getSession(); try {/*from ww w . jav a 2 s . co m*/ Criteria criteria = session.createCriteria(EvidenceRequest.class); criteria.addOrder(Order.asc("id")); if (evidenceRequest != null) { if (init != null && end != null) { criteria.add(Restrictions.ge("evidenceTime", init)); criteria.add(Restrictions.le("evidenceTime", end)); } else if (init != null) { criteria.add(Restrictions.ge("evidenceTime", init)); } else if (end != null) { criteria.add(Restrictions.le("evidenceTime", end)); } else if (evidenceRequest.getEvidenceTime() != null) { criteria.add(Restrictions.eq("evidenceTime", evidenceRequest.getEvidenceTime())); } if (evidenceRequest.getType() != null) { criteria.add(Restrictions.eq("type", evidenceRequest.getType())); } if (evidenceRequest.getEvidenceProvider() != null && evidenceRequest.getEvidenceProvider().getId() != null && evidenceRequest.getEvidenceProvider().getId() > 0) { criteria.add( Restrictions.eq("evidenceProvider.id", evidenceRequest.getEvidenceProvider().getId())); } ExtractionPlanMetric epm = evidenceRequest.getMetric().getExtractionPlanMetric(); if (evidenceRequest.getMetric() != null && epm != null && epm.getExtractionPlanCustomizing() != null && epm.getExtractionPlanCustomizing().isActive() != null) { criteria.createCriteria("metric").createCriteria("extractionPlanCustomizing") .add(Restrictions.eq("active", epm.getExtractionPlanCustomizing().isActive())); } } list = criteria.list(); } catch (HibernateException e) { log.error(e, e); } finally { this.releaseSession(session); } return list; }
From source file:com.scopix.periscope.extractionplanmanagement.dao.ExtractionPlanCustomizingDAOImpl.java
License:Open Source License
@Override public List<Metric> getMetricList(Metric metric) { log.info("start"); List<Metric> metrics = null; Session session = this.getSession(); try {// ww w . j av a2 s .c om Criteria criteria = session.createCriteria(Metric.class); criteria.addOrder(Order.asc("id")); if (metric != null) { registerLogs(metric); if (metric.getArea() != null && metric.getArea().getId() != null && metric.getArea().getId() > 0) { log.debug("criteria metric.getArea().getId(): [" + metric.getArea().getId() + "]"); criteria.add(Restrictions.eq("area.id", metric.getArea().getId())); } if (metric.getMetricOrder() != null && metric.getMetricOrder() >= 0) { log.debug("criteria metric.getMetricOrder(): [" + metric.getMetricOrder() + "]"); criteria.add(Restrictions.eq("metricOrder", metric.getMetricOrder())); } if (metric.getMetricTemplate() != null && metric.getMetricTemplate().getId() != null && metric.getMetricTemplate().getId() > 0) { log.debug("criteria metric.getMetricTemplate().getId(): [" + metric.getMetricTemplate().getId() + "]"); criteria.add(Restrictions.eq("metricTemplate.id", metric.getMetricTemplate().getId())); } if (metric.getSituation() != null && metric.getSituation().getId() != null && metric.getSituation().getId() > 0) { log.debug("criteria metric.getSituation().getId(): [" + metric.getSituation().getId() + "]"); criteria.add(Restrictions.eq("situation.id", metric.getSituation().getId())); } if (metric.getArea() != null && metric.getArea().getAreaType() != null && metric.getArea().getAreaType().getId() != null && metric.getArea().getAreaType().getId() > 0) { log.debug("criteria metric.getArea().getAreaType().getId(): [" + metric.getArea().getAreaType().getId() + "]"); criteria.createCriteria("area") .add(Restrictions.eq("areaType.id", metric.getArea().getAreaType().getId())); } ExtractionPlanMetric epm = metric.getExtractionPlanMetric(); if (epm != null && epm.getExtractionPlanCustomizing().isActive() != null) { log.debug("criteria epm.getExtractionPlanCustomizing().isActive(): [" + epm.getExtractionPlanCustomizing().isActive() + "]"); criteria.createCriteria("extractionPlanCustomizing") .add(Restrictions.eq("active", epm.getExtractionPlanCustomizing().isActive())); } } log.debug("antes de criteria.list()"); metrics = criteria.list(); } catch (HibernateException e) { log.error(e, e); } finally { this.releaseSession(session); } log.info("end, metrics: [" + metrics + "]"); return metrics; }
From source file:com.scopix.periscope.extractionplanmanagement.dao.ExtractionPlanCustomizingDAOImpl.java
License:Open Source License
@Override public List<Situation> getSituationList(Situation situation) { List<Situation> list = null; Session session = this.getSession(); try {//from w w w. j a v a 2 s. c o m Criteria criteria = session.createCriteria(Situation.class); criteria.addOrder(Order.asc("id")); //Agregando un filtro fijo: situation que tengan asociadas metricas cuyo extraction plan customizing tenga estado activo Criteria criteriaMetric = criteria.createCriteria("metrics"); Criteria criteriaExtraction = criteriaMetric.createCriteria("extractionPlanCustomizing"); criteriaExtraction.add(Restrictions.eq("active", true)); //********************************************************************************************************************** if (situation != null) { if (situation.getSituationTemplate() != null && situation.getSituationTemplate().getId() != null && situation.getSituationTemplate().getId() >= 0) { criteria.add(Restrictions.eq("situationTemplate.id", situation.getSituationTemplate().getId())); } } list = criteria.list(); } catch (HibernateException e) { log.error(e, e); } finally { this.releaseSession(session); } return list; }
From source file:com.scopix.periscope.extractionservicesserversmanagement.dao.EvidenceExtractionServicesServerDAO.java
License:Open Source License
/** * Metodo que retorna el evidence extraction a partir del id existente en business services. * * @param eessId/*from w w w .j a v a 2 s . com*/ * @return */ public EvidenceExtractionServicesServer getEvidenceExtractionServicesServerByEvidenceExtractionServicesIdInBusinessServices( Integer eessId, String storeName) { EvidenceExtractionServicesServer evidenceExtractionServicesServer = null; Criteria criteria = this.getSession().createCriteria(EvidenceExtractionServicesServer.class); criteria.add(Restrictions.eq("idAtBusinessServices", eessId)); Criteria criteriaExtractionPlans = criteria.createCriteria("extractionPlans"); criteriaExtractionPlans.add(Restrictions.isNull("expiration")); criteriaExtractionPlans.add(Restrictions.eq("storeName", storeName)); List<EvidenceExtractionServicesServer> evidenceExtractionServicesServers = criteria.list(); if (evidenceExtractionServicesServers != null && !evidenceExtractionServicesServers.isEmpty()) { evidenceExtractionServicesServer = evidenceExtractionServicesServers.get(0); } return evidenceExtractionServicesServer; }
From source file:com.scopix.periscope.extractionservicesserversmanagement.dao.EvidenceExtractionServicesServerDAO.java
License:Open Source License
public EvidenceExtractionServicesServer getEvidenceExtractionServicesServerByServerId(Integer serverId) { EvidenceExtractionServicesServer evidenceExtractionServicesServer = null; Criteria criteria = this.getSession().createCriteria(EvidenceExtractionServicesServer.class); criteria.add(Restrictions.eq("serverId", serverId)); criteria.createCriteria("extractionPlans").add(Restrictions.isNull("expiration")); List<EvidenceExtractionServicesServer> evidenceExtractionServicesServers = criteria.list(); if (evidenceExtractionServicesServers != null && !evidenceExtractionServicesServers.isEmpty()) { evidenceExtractionServicesServer = evidenceExtractionServicesServers.get(0); }/*from w w w . ja v a 2 s. c o m*/ return evidenceExtractionServicesServer; }