List of usage examples for org.hibernate.criterion DetachedCriteria add
public DetachedCriteria add(Criterion criterion)
From source file:com.headstrong.teevra.services.component.dao.impl.ComponentTemplateDAOImpl.java
License:Open Source License
public void saveComponentTemplate(ComponentTemplateEO compTemplateToSave) throws ComponentServiceException { DetachedCriteria criteria = DetachedCriteria.forClass(ComponentTemplateEO.class); criteria.add(Restrictions.eq("compId", compTemplateToSave.getCompId())); criteria.add(Restrictions.eq("templateName", compTemplateToSave.getTemplateName())); // fetch the template if it already exists and update it, else insert a // new record List<ComponentTemplateEO> compTemplateList = super.getByCriteria(criteria); if (!compTemplateList.isEmpty()) { // matching template exists already. Hence update it with just the // serialized configurations ComponentTemplateEO existingTemplate = compTemplateList.get(0); existingTemplate.setConfigurations(compTemplateToSave.getConfigurations()); existingTemplate.setModifiedBy(System.getProperty("user.name")); existingTemplate.setModifiedDate(new Timestamp(System.currentTimeMillis())); compTemplateToSave = existingTemplate; } else {//from w w w .j a v a 2s . c om // given template is a fresh one for the component compTemplateToSave.setCreatedBy(System.getProperty("user.name")); compTemplateToSave.setCreatedDate(new Timestamp(System.currentTimeMillis())); } super.saveOrUpdate(compTemplateToSave); }
From source file:com.headstrong.teevra.services.process.dao.impl.ProcessDAOImpl.java
License:Open Source License
public void saveProcess(ProcessEO processToSave) throws ProcessServiceException { DetachedCriteria criteria = DetachedCriteria.forClass(ProcessEO.class); criteria.add(Restrictions.eq("prcsName", processToSave.getPrcsName())); // processToSave.getPrcsId() != null, it means the process is not new so // we set the modified details whenever the process is to be saved if (processToSave.getPrcsId() != null) { criteria.add(Restrictions.ne("prcsId", processToSave.getPrcsId())); // set process modified details processToSave.setModifiedBy(System.getProperty("user.name")); processToSave.setModifiedDate(new Timestamp(System.currentTimeMillis())); }/*from w w w . java2 s . c o m*/ List<ProcessEO> processList = super.getByCriteria(criteria); if (!processList.isEmpty()) { logger.error("Couldn't save process: " + processToSave.getPrcsName() + ". A process with the same name already exists in the system"); throw new UniqueProcessException("A process with the name " + "'" + processToSave.getPrcsName() + "'" + " already exists in the system"); } else { super.saveOrUpdate(processToSave); } }
From source file:com.headstrong.teevra.services.processadmin.dao.impl.ProcessScheduleDAOImpl.java
License:Open Source License
public void deleteProcessSchedule(Long prcsId) throws ProcessAdminServiceException { DetachedCriteria criteria = DetachedCriteria.forClass(ProcessScheduleEO.class); criteria.add(Restrictions.eq("prcsId", prcsId)); // fetch the schedule to delete List<ProcessScheduleEO> prcsScheduleList = super.getByCriteria(criteria); // delete the process schedule if it exits if (!prcsScheduleList.isEmpty()) { super.delete(prcsScheduleList.get(0)); }/*www . java 2s .com*/ }
From source file:com.headstrong.teevra.services.processadmin.dao.impl.ProcessScheduleDAOImpl.java
License:Open Source License
public void saveProcessSchedule(ProcessScheduleEO processScheduleToSave) throws ProcessAdminServiceException { DetachedCriteria criteria = DetachedCriteria.forClass(ProcessScheduleEO.class); criteria.add(Restrictions.eq("prcsId", processScheduleToSave.getPrcsId())); // fetch the schedule, if it already exists update it, else insert a // new record List<ProcessScheduleEO> prcsScheduleList = super.getByCriteria(criteria); if (!prcsScheduleList.isEmpty()) { // matching schedule exists already. update the modified fields ProcessScheduleEO temp = prcsScheduleList.get(0); temp.setRecurrenceType(processScheduleToSave.getRecurrenceType()); temp.setRecurrence(processScheduleToSave.getRecurrence()); temp.setModifiedBy(System.getProperty("user.name")); temp.setModifiedDate(new Timestamp(System.currentTimeMillis())); processScheduleToSave = temp;//from www . j a v a 2 s . c o m } else { // given schedule is a fresh one, hence update the created fileds processScheduleToSave.setCreatedBy(System.getProperty("user.name")); processScheduleToSave.setCreatedDate(new Timestamp(System.currentTimeMillis())); } // save or update the schedule super.saveOrUpdate(processScheduleToSave); }
From source file:com.headstrong.teevra.services.refdata.dao.impl.CacheReloadScheduleDAOImpl.java
License:Open Source License
public void deleteCacheReloadSchedule(String cacheName) throws SchedulingException { DetachedCriteria criteria = DetachedCriteria.forClass(CacheReloadScheduleEO.class); criteria.add(Restrictions.eq("cacheName", cacheName)); // fetch the schedule to delete List<CacheReloadScheduleEO> cacheReloadScheduleList = super.getByCriteria(criteria); // delete the cache schedule if it exits if (!cacheReloadScheduleList.isEmpty()) { super.delete(cacheReloadScheduleList.get(0)); }/* w ww . ja v a 2s. co m*/ }
From source file:com.headstrong.teevra.services.refdata.dao.impl.CacheReloadScheduleDAOImpl.java
License:Open Source License
public void saveCacheReloadSchedule(CacheReloadScheduleEO scheduleToSave) throws SchedulingException { DetachedCriteria criteria = DetachedCriteria.forClass(CacheReloadScheduleEO.class); criteria.add(Restrictions.eq("cacheName", scheduleToSave.getCacheName())); // fetch the schedule, if it already exists update it, else insert a // new record List<CacheReloadScheduleEO> scheduleList = super.getByCriteria(criteria); if (!scheduleList.isEmpty()) { // matching schedule exists already. update the modified fields CacheReloadScheduleEO temp = scheduleList.get(0); temp.setRecurrenceType(scheduleToSave.getRecurrenceType()); temp.setRecurrence(scheduleToSave.getRecurrence()); temp.setModifiedBy(System.getProperty("user.name")); temp.setModifiedDate(new Timestamp(System.currentTimeMillis())); scheduleToSave = temp;//from www. j a v a2s.c o m } else { // given schedule is a fresh one, hence update the created fields scheduleToSave.setCreatedBy(System.getProperty("user.name")); scheduleToSave.setCreatedDate(new Timestamp(System.currentTimeMillis())); } // save or update the schedule super.saveOrUpdate(scheduleToSave); }
From source file:com.headstrong.teevra.services.refdata.dao.impl.DataSourceConfigDAOImpl.java
License:Open Source License
public void saveDataSourceConfig(DataSourceConfigEO dataSourceConfigToSave) throws RefDataServiceException { DetachedCriteria criteria = DetachedCriteria.forClass(DataSourceConfigEO.class); criteria.add(Restrictions.eq("dataSourceName", dataSourceConfigToSave.getDataSourceName())); if (dataSourceConfigToSave.getDataSourceId() != null) { criteria.add(Restrictions.ne("dataSourceId", dataSourceConfigToSave.getDataSourceId())); }/*w ww .j a v a2 s.c om*/ List<DataSourceConfigEO> configList = super.getByCriteria(criteria); if (!configList.isEmpty()) { logger.error("A process with the same name already exists in the system"); throw new UniqueDataSourceConfigException("A data source with the name " + "'" + dataSourceConfigToSave.getDataSourceName() + "'" + " is already exists in the system"); } else { super.saveOrUpdate(dataSourceConfigToSave); } }
From source file:com.headstrong.teevra.services.refdata.dao.impl.RefDataConfigDAOImpl.java
License:Open Source License
public void saveRefDataConfig(RefDataConfigEO refDataConfigToSave) throws RefDataServiceException { DetachedCriteria criteria = DetachedCriteria.forClass(RefDataConfigEO.class); criteria.add(Restrictions.eq("refDataName", refDataConfigToSave.getRefDataName())); if (refDataConfigToSave.getRefDataId() != null) { criteria.add(Restrictions.ne("refDataId", refDataConfigToSave.getRefDataId())); }//from www .java 2s. co m List<RefDataConfigEO> configList = super.getByCriteria(criteria); if (!configList.isEmpty()) { logger.error("A Refdata with the same name already exists in the system"); throw new UniqueRefDataConfigException("A reference data with the name " + "'" + refDataConfigToSave.getRefDataName() + "'" + " is already exists in the system"); } else { super.saveOrUpdate(refDataConfigToSave); } }
From source file:com.headstrong.teevra.services.serveradmin.dao.impl.ServerConfigDAOImpl.java
License:Open Source License
public void registerServer(ServerConfigEO serverToRegister) throws ServerAdminServiceException { DetachedCriteria criteria = DetachedCriteria.forClass(ServerConfigEO.class); criteria.add(Restrictions.eq("serverName", serverToRegister.getServerName())); if (serverToRegister.getServerId() != null) { criteria.add(Restrictions.ne("serverId", serverToRegister.getServerId())); }//from w w w . j av a 2 s .c o m List<ServerConfigEO> serverList = super.getByCriteria(criteria); if (!serverList.isEmpty()) { logger.error("A server with the same name already exists in the system"); throw new UniqueServerException("A server with the name " + "'" + serverToRegister.getServerName() + "'" + " is already exists in the system"); } else { super.saveOrUpdate(serverToRegister); } }
From source file:com.headstrong.teevra.services.statemachine.dao.impl.StateMachineDAOImpl.java
License:Open Source License
public void saveStateMachine(StateMachineEO stateMachineToSave) throws StateMachineServiceException { DetachedCriteria criteria = DetachedCriteria.forClass(StateMachineEO.class); criteria.add(Restrictions.eq("stateMachineName", stateMachineToSave.getStateMachineName())); if (stateMachineToSave.getStateMachineId() != null) { criteria.add(Restrictions.ne("stateMachineId", stateMachineToSave.getStateMachineId())); }/*w w w . j a va 2 s .c o m*/ List<StateMachineEO> stateMachineList = super.getByCriteria(criteria); if (!stateMachineList.isEmpty()) { logger.error("A state machine with the same name already exists in the system"); throw new UniqueStateMachineException("A state machine with the name " + "'" + stateMachineToSave.getStateMachineName() + "'" + " already exists in the system"); } else { super.saveOrUpdate(stateMachineToSave); } }