List of usage examples for org.hibernate.criterion Restrictions ge
public static SimpleExpression ge(String propertyName, Object value)
From source file:com.ut.healthelink.dao.impl.transactionInDAOImpl.java
/** * The 'findsentBatches' function will return a list of sent batches for the organization passed in. * * @param orgId The organization Id to find pending transactions for. * * @return The function will return a list of sent transactions *///from w w w . ja va 2 s . c o m @Transactional public List<batchUploads> findsentBatches(int userId, int orgId, int toOrgId, int messageTypeId, Date fromDate, Date toDate) throws Exception { /* Get a list of connections the user has access to */ Criteria connections = sessionFactory.getCurrentSession() .createCriteria(configurationConnectionSenders.class); connections.add(Restrictions.eq("userId", userId)); List<configurationConnectionSenders> userConnections = connections.list(); List<Integer> messageTypeList = new ArrayList<Integer>(); List<Integer> targetOrgList = new ArrayList<Integer>(); if (userConnections.isEmpty()) { messageTypeList.add(0); targetOrgList.add(0); } else { for (configurationConnectionSenders userConnection : userConnections) { Criteria connection = sessionFactory.getCurrentSession() .createCriteria(configurationConnection.class); connection.add(Restrictions.eq("id", userConnection.getconnectionId())); configurationConnection connectionInfo = (configurationConnection) connection.uniqueResult(); /* Get the message type for the configuration */ Criteria sourceconfigurationQuery = sessionFactory.getCurrentSession() .createCriteria(configuration.class); sourceconfigurationQuery.add(Restrictions.eq("id", connectionInfo.getsourceConfigId())); configuration configDetails = (configuration) sourceconfigurationQuery.uniqueResult(); /* Add the message type to the message type list */ if (messageTypeId == 0) { messageTypeList.add(configDetails.getMessageTypeId()); } else { if (messageTypeId == configDetails.getMessageTypeId()) { messageTypeList.add(configDetails.getMessageTypeId()); } } /* Get the list of target orgs */ Criteria targetconfigurationQuery = sessionFactory.getCurrentSession() .createCriteria(configuration.class); targetconfigurationQuery.add(Restrictions.eq("id", connectionInfo.gettargetConfigId())); configuration targetconfigDetails = (configuration) targetconfigurationQuery.uniqueResult(); /* Add the target org to the target organization list */ if (toOrgId == 0) { targetOrgList.add(targetconfigDetails.getorgId()); } else { if (toOrgId == targetconfigDetails.getorgId()) { targetOrgList.add(targetconfigDetails.getorgId()); } } } } /* Get a list of available batches */ Criteria batchSummaries = sessionFactory.getCurrentSession().createCriteria(batchUploadSummary.class); batchSummaries.add(Restrictions.eq("sourceOrgId", orgId)); batchSummaries.add(Restrictions.in("messageTypeId", messageTypeList)); batchSummaries.add(Restrictions.in("targetOrgId", targetOrgList)); List<batchUploadSummary> batchUploadSummaryList = batchSummaries.list(); List<Integer> batchIdList = new ArrayList<Integer>(); if (batchUploadSummaryList.isEmpty()) { batchIdList.add(0); } else { for (batchUploadSummary summary : batchUploadSummaryList) { batchIdList.add(summary.getbatchId()); } } Criteria findBatches = sessionFactory.getCurrentSession().createCriteria(batchUploads.class); findBatches.add(Restrictions.in("id", batchIdList)); findBatches.add(Restrictions.or(Restrictions.eq("statusId", 4), /* Submission Being Processed */ Restrictions.eq("statusId", 22), /* Submission Delivery Locked */ Restrictions.eq("statusId", 23), /* Submission Delivery Completed */ Restrictions.eq("statusId", 24), /* Submission Processing Completed */ Restrictions.eq("statusId", 25), /* Target Batch Creation in process */ Restrictions.eq("statusId", 28), /* Target Batch Creation in process */ Restrictions.eq("statusId", 29), /* Submission Processed Errored */ Restrictions.eq("statusId", 30), /* Target Creation Errored */ Restrictions.eq("statusId", 32) /* Submission Cancelled */ )); if (!"".equals(fromDate)) { findBatches.add(Restrictions.ge("dateSubmitted", fromDate)); } if (!"".equals(toDate)) { findBatches.add(Restrictions.lt("dateSubmitted", toDate)); } findBatches.addOrder(Order.desc("dateSubmitted")); return findBatches.list(); }
From source file:com.ut.healthelink.dao.impl.transactionInDAOImpl.java
@SuppressWarnings("unchecked") @Override/*from w ww. j av a 2 s .c o m*/ @Transactional public List<batchUploads> getuploadedBatches(int userId, int orgId, Date fromDate, Date toDate, List<Integer> excludedStatusIds) throws Exception { /* Get a list of connections the user has access to */ Criteria connections = sessionFactory.getCurrentSession() .createCriteria(configurationConnectionSenders.class); connections.add(Restrictions.eq("userId", userId)); List<configurationConnectionSenders> userConnections = connections.list(); List<Integer> configIdList = new ArrayList<Integer>(); if (userConnections.isEmpty()) { configIdList.add(0); } else { for (configurationConnectionSenders userConnection : userConnections) { Criteria connection = sessionFactory.getCurrentSession() .createCriteria(configurationConnection.class); connection.add(Restrictions.eq("id", userConnection.getconnectionId())); configurationConnection connectionInfo = (configurationConnection) connection.uniqueResult(); if (!configIdList.contains(connectionInfo.getsourceConfigId())) { configIdList.add(connectionInfo.getsourceConfigId()); } } } // multiconfig is 0 so we need to add configIdList.add(0); Criteria findBatches = sessionFactory.getCurrentSession().createCriteria(batchUploads.class); findBatches.add(Restrictions.eq("orgId", orgId)); findBatches.add(Restrictions.not(Restrictions.in("statusId", excludedStatusIds))); findBatches.add(Restrictions.in("configId", configIdList)); findBatches.add(Restrictions.ne("transportMethodId", 2)); if (!"".equals(fromDate)) { findBatches.add(Restrictions.ge("dateSubmitted", fromDate)); } if (!"".equals(toDate)) { findBatches.add(Restrictions.lt("dateSubmitted", toDate)); } findBatches.addOrder(Order.desc("dateSubmitted")); return findBatches.list(); }
From source file:com.ut.healthelink.dao.impl.transactionInDAOImpl.java
/** * The 'getAllUploadedBatches' function will return a list of batches for the admin in the processing activities section. * * @param fromDate// ww w. j ava 2 s . co m * @param toDate * @return This function will return a list of batch uploads * @throws Exception */ @Override @Transactional public List<batchUploads> getAllUploadedBatches(Date fromDate, Date toDate, Integer fetchSize) throws Exception { int firstResult = 0; Criteria findBatches = sessionFactory.getCurrentSession().createCriteria(batchUploads.class); if (!"".equals(fromDate)) { findBatches.add(Restrictions.ge("dateSubmitted", fromDate)); } if (!"".equals(toDate)) { findBatches.add(Restrictions.lt("dateSubmitted", toDate)); } findBatches.addOrder(Order.desc("dateSubmitted")); if (fetchSize > 0) { findBatches.setMaxResults(fetchSize); } return findBatches.list(); }
From source file:com.ut.healthelink.dao.impl.transactionOutDAOImpl.java
/** * The 'findInboxBatches' will return a list of received batches for the logged in user. * * @param userId The id of the logged in user trying to view received batches * @param orgId The id of the organization the user belongs to * * @return The function will return a list of received batches *///from ww w . j a va 2 s . c om @Transactional @SuppressWarnings("UnusedAssignment") public List<batchDownloads> findInboxBatches(int userId, int orgId, int fromOrgId, int messageTypeId, Date fromDate, Date toDate) throws Exception { int firstResult = 0; /* Get a list of connections the user has access to */ Criteria connections = sessionFactory.getCurrentSession() .createCriteria(configurationConnectionReceivers.class); connections.add(Restrictions.eq("userId", userId)); List<configurationConnectionReceivers> userConnections = connections.list(); List<Integer> messageTypeList = new ArrayList<Integer>(); List<Integer> sourceOrgList = new ArrayList<Integer>(); if (userConnections.isEmpty()) { messageTypeList.add(0); sourceOrgList.add(0); } else { for (configurationConnectionReceivers userConnection : userConnections) { Criteria connection = sessionFactory.getCurrentSession() .createCriteria(configurationConnection.class); connection.add(Restrictions.eq("id", userConnection.getconnectionId())); configurationConnection connectionInfo = (configurationConnection) connection.uniqueResult(); /* Get the message type for the configuration */ Criteria targetconfigurationQuery = sessionFactory.getCurrentSession() .createCriteria(configuration.class); targetconfigurationQuery.add(Restrictions.eq("id", connectionInfo.gettargetConfigId())); configuration configDetails = (configuration) targetconfigurationQuery.uniqueResult(); /* Add the message type to the message type list */ if (messageTypeId == 0) { messageTypeList.add(configDetails.getMessageTypeId()); } else { if (messageTypeId == configDetails.getMessageTypeId()) { messageTypeList.add(configDetails.getMessageTypeId()); } } /* Get the list of source orgs */ Criteria sourceconfigurationQuery = sessionFactory.getCurrentSession() .createCriteria(configuration.class); sourceconfigurationQuery.add(Restrictions.eq("id", connectionInfo.getsourceConfigId())); configuration sourceconfigDetails = (configuration) sourceconfigurationQuery.uniqueResult(); /* Add the target org to the target organization list */ if (fromOrgId == 0) { sourceOrgList.add(sourceconfigDetails.getorgId()); } else { if (fromOrgId == sourceconfigDetails.getorgId()) { sourceOrgList.add(sourceconfigDetails.getorgId()); } } } } if (messageTypeList.isEmpty()) { messageTypeList.add(0); } /* Get a list of available batches */ Criteria batchSummaries = sessionFactory.getCurrentSession().createCriteria(batchDownloadSummary.class); batchSummaries.add(Restrictions.eq("targetOrgId", orgId)); batchSummaries.add(Restrictions.in("messageTypeId", messageTypeList)); batchSummaries.add(Restrictions.in("sourceOrgId", sourceOrgList)); List<batchDownloadSummary> batchDownloadSummaryList = batchSummaries.list(); List<Integer> batchIdList = new ArrayList<Integer>(); if (batchDownloadSummaryList.isEmpty()) { batchIdList.add(0); } else { for (batchDownloadSummary summary : batchDownloadSummaryList) { batchIdList.add(summary.getbatchId()); } } Criteria findBatches = sessionFactory.getCurrentSession().createCriteria(batchDownloads.class); findBatches.add(Restrictions.in("id", batchIdList)); findBatches.add(Restrictions.eq("transportMethodId", 2)); findBatches.add(Restrictions.and(Restrictions.ne("statusId", 29), /* Submission Processed Errored */ Restrictions.ne("statusId", 30), /* Target Creation Errored */ Restrictions.ne("statusId", 32) /* Submission Cancelled */ )); if (!"".equals(fromDate) && fromDate != null) { findBatches.add(Restrictions.ge("dateCreated", fromDate)); } if (!"".equals(toDate) && toDate != null) { findBatches.add(Restrictions.lt("dateCreated", toDate)); } findBatches.addOrder(Order.desc("dateCreated")); return findBatches.list(); }
From source file:com.ut.healthelink.dao.impl.transactionOutDAOImpl.java
/** * The 'getAllBatches' function will return a list of batches for the admin in the processing activities section. * * @param fromDate/*www. j ava2 s. co m*/ * @param toDate * @return This function will return a list of batch uploads * @throws Exception */ @Override @Transactional public List<batchDownloads> getAllBatches(Date fromDate, Date toDate) throws Exception { int firstResult = 0; Criteria findBatches = sessionFactory.getCurrentSession().createCriteria(batchDownloads.class); if (!"".equals(fromDate)) { findBatches.add(Restrictions.ge("dateCreated", fromDate)); } if (!"".equals(toDate)) { findBatches.add(Restrictions.lt("dateCreated", toDate)); } findBatches.addOrder(Order.desc("dateCreated")); return findBatches.list(); }
From source file:com.ut.healthelink.dao.impl.transactionOutDAOImpl.java
/** * The 'getdownloadableBatches' will return a list of received batches for the logged in user that are ready to be downloaded * * @param userId The id of the logged in user trying to view downloadable batches * @param orgId The id of the organization the user belongs to * * @return The function will return a list of downloadable batches *//* w w w. ja v a 2 s. co m*/ @Override @Transactional @SuppressWarnings("UnusedAssignment") public List<batchDownloads> getdownloadableBatches(int userId, int orgId, Date fromDate, Date toDate) throws Exception { int firstResult = 0; /* Get a list of connections the user has access to */ Criteria connections = sessionFactory.getCurrentSession() .createCriteria(configurationConnectionReceivers.class); connections.add(Restrictions.eq("userId", userId)); List<configurationConnectionReceivers> userConnections = connections.list(); List<Integer> messageTypeList = new ArrayList<Integer>(); List<Integer> sourceOrgList = new ArrayList<Integer>(); if (userConnections.isEmpty()) { messageTypeList.add(0); sourceOrgList.add(0); } else { for (configurationConnectionReceivers userConnection : userConnections) { Criteria connection = sessionFactory.getCurrentSession() .createCriteria(configurationConnection.class); connection.add(Restrictions.eq("id", userConnection.getconnectionId())); configurationConnection connectionInfo = (configurationConnection) connection.uniqueResult(); /* Get the message type for the configuration */ Criteria targetconfigurationQuery = sessionFactory.getCurrentSession() .createCriteria(configuration.class); targetconfigurationQuery.add(Restrictions.eq("id", connectionInfo.gettargetConfigId())); configuration configDetails = (configuration) targetconfigurationQuery.uniqueResult(); /* Need to make sure only file download configurations are displayed */ Criteria transportDetailsQuery = sessionFactory.getCurrentSession() .createCriteria(configurationTransport.class); transportDetailsQuery.add(Restrictions.eq("configId", configDetails.getId())); configurationTransport transportDetails = (configurationTransport) transportDetailsQuery .uniqueResult(); if (transportDetails.gettransportMethodId() == 1) { /* Add the message type to the message type list */ messageTypeList.add(configDetails.getMessageTypeId()); } /* Get the list of source orgs */ Criteria sourceconfigurationQuery = sessionFactory.getCurrentSession() .createCriteria(configuration.class); sourceconfigurationQuery.add(Restrictions.eq("id", connectionInfo.getsourceConfigId())); configuration sourceconfigDetails = (configuration) sourceconfigurationQuery.uniqueResult(); /* Add the target org to the target organization list */ sourceOrgList.add(sourceconfigDetails.getorgId()); } } if (messageTypeList.isEmpty()) { messageTypeList.add(0); } /* Get a list of available batches */ Criteria batchSummaries = sessionFactory.getCurrentSession().createCriteria(batchDownloadSummary.class); batchSummaries.add(Restrictions.eq("targetOrgId", orgId)); batchSummaries.add(Restrictions.in("messageTypeId", messageTypeList)); batchSummaries.add(Restrictions.in("sourceOrgId", sourceOrgList)); List<batchDownloadSummary> batchDownloadSummaryList = batchSummaries.list(); List<Integer> batchIdList = new ArrayList<Integer>(); if (batchDownloadSummaryList.isEmpty()) { batchIdList.add(0); } else { for (batchDownloadSummary summary : batchDownloadSummaryList) { batchIdList.add(summary.getbatchId()); } } Criteria findBatches = sessionFactory.getCurrentSession().createCriteria(batchDownloads.class); findBatches.add(Restrictions.in("id", batchIdList)); findBatches.add(Restrictions.eq("transportMethodId", 1)); findBatches.add(Restrictions.or(Restrictions.eq("statusId", 22), Restrictions.eq("statusId", 23), Restrictions.eq("statusId", 28))); if (!"".equals(fromDate)) { findBatches.add(Restrictions.ge("dateCreated", fromDate)); } if (!"".equals(toDate)) { findBatches.add(Restrictions.lt("dateCreated", toDate)); } findBatches.addOrder(Order.desc("dateCreated")); return findBatches.list(); }
From source file:com.ut.healthelink.dao.impl.transactionOutDAOImpl.java
/** * The 'getPendingTransactions' method will return all pending target transactions based on the org and message type passed in. * * @param orgId The id of the organzition to return pending transactions * @param messageType The id of the message type to return pending transactions * * @return This function will return a list of transactionTargets *///from w w w . j a v a2 s .c o m @Override @Transactional public List<transactionTarget> getPendingDeliveryTransactions(int orgId, int messageType, Date fromDate, Date toDate) throws Exception { List<Integer> configIds = new ArrayList<Integer>(); Criteria listConfigs = sessionFactory.getCurrentSession().createCriteria(configuration.class); listConfigs.add(Restrictions.eq("orgId", orgId)); listConfigs.add(Restrictions.eq("messageTypeId", messageType)); List<configuration> configs = listConfigs.list(); for (configuration config : configs) { if (!configIds.contains(config.getId())) { configIds.add(config.getId()); } } Criteria transactions = sessionFactory.getCurrentSession().createCriteria(transactionTarget.class); transactions.add(Restrictions.in("configId", configIds)); transactions.add(Restrictions.eq("statusId", 9)); transactions.add(Restrictions.eq("batchDLId", 0)); if (!"".equals(fromDate)) { transactions.add(Restrictions.ge("dateCreated", fromDate)); } if (!"".equals(toDate)) { transactions.add(Restrictions.lt("dateCreated", toDate)); } return transactions.list(); }
From source file:com.ut.tekir.contact.ContactStatusBean.java
License:LGPL
@SuppressWarnings("unchecked") private void calculateMonth(Integer month) { String rowKey = "MONTH" + (month < 10 ? "0" + month : month); Calendar cal = Calendar.getInstance(); cal.set(getYear(), month, 1);// w w w . j a va 2 s . c o m Date beginDate = cal.getTime(); if (month == 12) { cal.set(getYear() + 1, 1, 1); } else { cal.set(getYear(), month + 1, 1); } Date endDate = cal.getTime(); HibernateSessionProxy session = (HibernateSessionProxy) entityManager.getDelegate(); Criteria crit = session.createCriteria(FinanceTxn.class); crit.add(Restrictions.eq("contact", contact)).add(Restrictions.ge("date", beginDate)) .add(Restrictions.lt("date", endDate)).add(Restrictions.eq("active", true)); //Tarih kontrol yaplacak crit.setProjection(Projections.projectionList() .add(Projections.groupProperty("amount.currency"), "amountCurrency") .add(Projections.groupProperty("action"), "action").add(Projections.sum("amount.value"), "amount") .add(Projections.sum("localAmount.value"), "localAmount")); List ls = crit.list(); for (Iterator it = ls.iterator(); it.hasNext();) { Object obj[] = (Object[]) it.next(); dataTable.addRow(rowKey, (String) obj[0], (FinanceAction) obj[1], (Double) obj[2], (Double) obj[3]); } }
From source file:com.ut.tekir.documents.DocumentBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(DocumentFile.class); if (filterModel.getFirstDate() != null) { crit.add(Restrictions.ge("updateDate", filterModel.getFirstDate())); }/*from w w w . ja v a2 s .c om*/ if (filterModel.getSecondDate() != null) { crit.add(Restrictions.le("updateDate", filterModel.getSecondDate())); } if (filterModel.getName() != null && filterModel.getName().length() > 0) { crit.add(Restrictions.like("name", filterModel.getName() + "%")); } if (filterModel.getStatus() != DocumentFilterModel.Status.All) { if (filterModel.getStatus() == DocumentFilterModel.Status.Active) { crit.add(Restrictions.eq("active", true)); } else { crit.add(Restrictions.eq("active", false)); } } if (filterModel.getDocType() == DocumentFilterModel.DocType.Genel) { crit.add(Restrictions.eq("docType", DocumentFilterModel.DocType.Genel)); } if (filterModel.getDocType() == DocumentFilterModel.DocType.Genelge) { crit.add(Restrictions.eq("docType", DocumentFilterModel.DocType.Genelge)); } if (filterModel.getDocType() == DocumentFilterModel.DocType.Haber) { crit.add(Restrictions.eq("docType", DocumentFilterModel.DocType.Haber)); } if (filterModel.getDocType() == DocumentFilterModel.DocType.Sozlesme) { crit.add(Restrictions.eq("docType", DocumentFilterModel.DocType.Sozlesme)); } if (filterModel.getDocType() == DocumentFilterModel.DocType.Teblig) { crit.add(Restrictions.eq("docType", DocumentFilterModel.DocType.Teblig)); } if (filterModel.getDocType() == DocumentFilterModel.DocType.Basvuru) { crit.add(Restrictions.eq("docType", DocumentFilterModel.DocType.Basvuru)); } else if (filterModel.getDocType() != DocumentFilterModel.DocType.Hepsi) { crit.add(Restrictions.ne("docType", DocumentFilterModel.DocType.Basvuru)); } crit.addOrder(Order.desc("updateDate")); return crit; }
From source file:com.ut.tekir.finance.AccountCreditNoteBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(AccountCreditNote.class); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }//from w w w . ja va 2s.com if (isNotEmpty(filterModel.getReference())) { crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START)); } if (isNotEmpty(filterModel.getCode())) { crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START)); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("this.date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("this.date", filterModel.getEndDate())); } if (filterModel.getAccount() != null) { crit.add(Restrictions.le("this.account", filterModel.getAccount())); } crit.addOrder(Order.desc("serial")); crit.addOrder(Order.desc("date")); return crit; }