List of usage examples for org.hibernate Criteria setResultTransformer
public Criteria setResultTransformer(ResultTransformer resultTransformer);
From source file:com.scopix.periscope.evaluationmanagement.dao.PendingEvaluationHibernateDAOImpl.java
License:Open Source License
/** * Busca un Pending Evaluacion para un observedSituation asociado * * @param observedSituationId id observedsituation * @return PendingEvaluation/*from ww w . java 2s. com*/ */ @Override public PendingEvaluation getPendingEvaluationFromObservedSituationId(Integer observedSituationId) { log.info("start [observedSituationId:" + observedSituationId + "]"); Session session = this.getSession(); PendingEvaluation pe = null; try { Criteria criteria = session.createCriteria(PendingEvaluation.class); criteria.add(Restrictions.eq("observedSituation.id", observedSituationId)); List<PendingEvaluation> lista = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); pe = null; if (!lista.isEmpty() && lista.size() > 0) { log.debug("lista size " + lista.size()); //recuperamos el primero retornado por la lista para ser devuelto pe = lista.get(0); } } catch (HibernateException e) { log.error(e, e); } finally { this.releaseSession(session); } log.info("end " + pe); return pe; }
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// w w w . ja va 2s . c o m * @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 w w . j a v a2 s . co 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();/* w w w . ja v a 2 s. c om*/ return list; }
From source file:com.scopix.periscope.extractionmanagement.dao.EvidenceFileDAO.java
License:Open Source License
public EvidenceFile findEvidenceFileByEERAndDate(Integer evidenceExtractionRequestId, Date date) throws ScopixException { EvidenceFile evidenceFile = null;//from w w w . jav a 2 s. c o m SimpleDateFormat sdfParse = new SimpleDateFormat("dd-MM-yyyy HH:mm"); SimpleDateFormat sdfFormat = new SimpleDateFormat("dd-MM-yyyy"); Criteria criteria = this.getSession().createCriteria(EvidenceFile.class); criteria.add(Restrictions.eq("evidenceExtractionRequest.id", evidenceExtractionRequestId)); try { criteria.add(Restrictions.between("evidenceDate", sdfParse.parse(sdfFormat.format(date) + " 00:00"), sdfParse.parse(sdfFormat.format(date) + " 23:59"))); } catch (ParseException ex) { log.error(ex, ex); throw new ScopixException("Error obteniendo evidenceFile: ", ex); } List<EvidenceFile> evidenceFiles = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); if (evidenceFiles != null && !evidenceFiles.isEmpty()) { evidenceFile = evidenceFiles.get(0); } return evidenceFile; }
From source file:com.scopix.periscope.extractionmanagement.dao.EvidenceFileDAO.java
License:Open Source License
public List<EvidenceFile> findEvidenceFileByAlternativeName(String fileNameNextLevel) { Criteria criteria = this.getSession().createCriteria(EvidenceFile.class); criteria.add(Restrictions.eq("alternativeFileName", fileNameNextLevel)); criteria.add(Restrictions.isNull("fileCreationDate")); List<EvidenceFile> evidenceFiles = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); return evidenceFiles; }
From source file:com.scopix.periscope.extractionplanmanagement.dao.ExtractionPlanCustomizingDAOImpl.java
License:Open Source License
/** * Retorna una lista ExtractionPlanCustomizing unicos que esten activos o nulos *//* w ww.ja va2s. 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 una lista ExtractionPlanCustomizing unicos que esten activos para un store, stituation template si llegan *///from w w w. jav a 2 s . c o m @Override public List<ExtractionPlanCustomizing> getExtractionPlanCustomizingActiveList( 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.eq("active", true)); 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 una lista ExtractionPlanCustomizing unicos que esten null para un store, stituation template si llegan *///from w ww . j a va 2s . c o m @Override public List<ExtractionPlanCustomizing> getExtractionPlanCustomizingNullList( 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.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
@Override public List<ExtractionPlanCustomizing> getExtractionPlanCustomizingNullListByIds(List<Integer> epcIds) { List<ExtractionPlanCustomizing> result = new ArrayList<ExtractionPlanCustomizing>(); Session session = this.getSession(); try {//w w w.j av a 2 s. c o m Criteria criteria = session.createCriteria(ExtractionPlanCustomizing.class); if (epcIds != null && !epcIds.isEmpty()) { criteria.add(Restrictions.in("id", epcIds)); } criteria.add(Restrictions.isNull("active")); result = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); } catch (HibernateException e) { log.error(e, e); } finally { this.releaseSession(session); } return result; }