diff --git a/pom.xml b/pom.xml index 91263991..a551ab96 100644 --- a/pom.xml +++ b/pom.xml @@ -35,11 +35,11 @@ UTF-8 ${maven.build.timestamp} - 3.1.4.RELEASE - 3.1.0.RELEASE - 1.0.2.RELEASE - 1.0.1.RELEASE - 1.0.0.RC1 + 4.2.4.RELEASE + 4.0.3.RELEASE + 1.1.4.RELEASE + 1.1.1.RELEASE + 1.0.0.RELEASE 2.5.6.SEC02 1.6.1 @@ -84,7 +84,7 @@ hibernate-profiler 1.0 - + cz.zcu.kiv @@ -96,7 +96,7 @@ odml-java-lib 1.1.7 - + junit @@ -202,35 +202,35 @@ - - com.sun.xml.bind - jaxb-impl - 2.2.6 - - - com.sun.xml.bind - jaxb-xjc - 2.2.6 - - - com.sun.xml.ws - jaxws-rt - 2.2.7 - - - com.sun.xml.ws - policy - 2.3.1 - + + + + + + + + + + + + + + + + + + + + com.sun.xml.fastinfoset FastInfoset - 1.2.12 + 1.2.13 com.sun.xml.ws jaxws-tools - 2.2.7 + 2.2.8 javax.xml @@ -246,26 +246,23 @@ org.codehaus.jackson jackson-jaxrs - 1.9.9 + 1.9.13 org.codehaus.jackson jackson-xc - 1.9.9 + 1.9.13 - - org.springframework.data - spring-data-elasticsearch - 1.0.0 - + org.springframework spring-core ${spring.version} + org.springframework @@ -287,14 +284,14 @@ spring-aop ${spring.version} - + org.springframework spring-test ${spring.version} test - + org.springframework spring-tx @@ -310,19 +307,14 @@ spring-orm ${spring.version} - - - org.springframework - spring-expression - ${spring.version} - - + + org.springframework spring-web ${spring.version} - + org.springframework spring-webmvc @@ -334,17 +326,17 @@ ${spring.webmvc.struts.version} - + org.springframework.security spring-security-core ${spring.security.version} - - org.springframework.security - spring-security-acl - ${spring.security.version} - + + + + + org.springframework.security spring-security-config @@ -355,13 +347,13 @@ spring-security-web ${spring.security.version} - - org.springframework.security - spring-security-taglibs - ${spring.security.version} - + + + + + - + org.springframework.social spring-social-core @@ -382,6 +374,11 @@ spring-social-linkedin ${org.springframework.social.linkedin-version} + + org.springframework.data + spring-data-elasticsearch + 1.0.0 + @@ -443,7 +440,7 @@ org.hibernate hibernate-core - 4.3.5.Final + 4.2.11.Final xml-apis @@ -455,7 +452,7 @@ org.hibernate hibernate-tools - 4.3.2.Final + 4.0.0.Final @@ -464,17 +461,17 @@ 3.4.ga - - cglib - cglib - 2.2 - + + + + + - - asm - asm-attrs - 1.5.3 - + + + + + com.mchange @@ -532,7 +529,7 @@ commons-fileupload commons-fileupload - 1.2.2 + 1.3.1 jar compile @@ -608,29 +605,38 @@ - - org.apache.cxf - cxf-distribution-manifest - 2.6.2 - - - org.slf4j - slf4j-jdk14 - - - + + + + + + + + + + + + + + + org.apache.cxf cxf-rt-frontend-jaxrs - 2.6.2 + 3.1.1 + + org.apache.cxf + cxf-rt-frontend-jaxws + 3.1.1 + org.apache.ws.xmlschema xmlschema-core - 2.0.3 + 2.2.0 diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/GenericDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/GenericDao.java index edb4cd7e..1c2343d6 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/GenericDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/GenericDao.java @@ -22,13 +22,13 @@ ******************************************************************************/ package cz.zcu.kiv.eegdatabase.data.dao; +import org.apache.lucene.queryparser.classic.ParseException; +import org.hibernate.SessionFactory; + import java.io.Serializable; import java.util.List; import java.util.Map; -import org.apache.lucene.queryparser.classic.ParseException; -import org.hibernate.SessionFactory; - /** * Interface for connecting logic and data layer. * This interface makes create, showing, delete, diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleArticleDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleArticleDao.java index 911f7b65..0374d640 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleArticleDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleArticleDao.java @@ -44,8 +44,7 @@ public SimpleArticleDao() { @Override public List
getAllArticles() { String HQLSelect = "from Article order by time desc"; - List
articles = getHibernateTemplate().find(HQLSelect); - return articles; + return currentSession().createQuery(HQLSelect).list(); } @Override @@ -56,7 +55,7 @@ public List
getArticlesForUser(Person person) { if (person.getAuthority().equals("ROLE_ADMIN")) { // We can simply load the newest articles query = "select DISTINCT a from Article a left join fetch a.articleComments order by a.time desc"; - articles = getSession().createQuery(query).list(); + articles = currentSession().createQuery(query).list(); } else { // We need to load only articles which can be viewed by the logged user. // That is, we need to load only public articles or articles from the groups the logged user is member of. @@ -65,7 +64,7 @@ public List
getArticlesForUser(Person person) { "a.researchGroup.researchGroupId in " + "(select rm.id.researchGroupId from ResearchGroupMembership rm where rm.id.personId = :personId) " + "order by a.time desc"; - articles = getSession().createQuery(query).setParameter("personId", person.getPersonId()).list(); + articles = currentSession().createQuery(query).setParameter("personId", person.getPersonId()).list(); } return articles; @@ -79,7 +78,7 @@ public List
getArticlesForUser(Person person, int limit) { if (person.getAuthority().equals("ROLE_ADMIN")) { // We can simply load the newest articles query = "select DISTINCT a from Article a left join fetch a.articleComments order by a.time desc"; - articles = getSession().createQuery(query).setMaxResults(limit).list(); + articles = currentSession().createQuery(query).setMaxResults(limit).list(); } else { // We need to load only articles which can be viewed by the logged user. // That is, we need to load only public articles or articles from the groups the logged user is member of. @@ -88,7 +87,7 @@ public List
getArticlesForUser(Person person, int limit) { "a.researchGroup.researchGroupId in " + "(select rm.id.researchGroupId from ResearchGroupMembership rm where rm.id.personId = :personId) " + "order by a.time desc"; - articles = getSession().createQuery(query).setParameter("personId", person.getPersonId()).setMaxResults(limit).list(); + articles = currentSession().createQuery(query).setParameter("personId", person.getPersonId()).setMaxResults(limit).list(); } return articles; @@ -102,7 +101,7 @@ public List
getArticlesForList(Person person, int min, int count) { if (person.getAuthority().equals("ROLE_ADMIN")) { // We can simply load the newest articles query = "from Article a order by a.time desc"; - articles = getSession().createQuery(query).setFirstResult(min).setMaxResults(count).list(); + articles = currentSession().createQuery(query).setFirstResult(min).setMaxResults(count).list(); } else { // We need to load only articles which can be viewed by the logged user. // That is, we need to load only public articles or articles from the groups the logged user is member of. @@ -111,7 +110,7 @@ public List
getArticlesForList(Person person, int min, int count) { "a.researchGroup.researchGroupId in " + "(select rm.id.researchGroupId from ResearchGroupMembership rm where rm.id.personId = :personId) " + "order by a.time desc"; - articles = getSession().createQuery(query).setFirstResult(min).setMaxResults(count).setParameter("personId", person.getPersonId()).list(); + articles = currentSession().createQuery(query).setFirstResult(min).setMaxResults(count).setParameter("personId", person.getPersonId()).list(); } return articles; @@ -120,13 +119,13 @@ public List
getArticlesForList(Person person, int min, int count) { @Override public int getArticleCountForPerson(Person person) { if (person.getAuthority().equals("ROLE_ADMIN")) { - return ((Long) getSession().createQuery("select count(*) from Article").uniqueResult()).intValue(); + return ((Long) currentSession().createQuery("select count(*) from Article").uniqueResult()).intValue(); } String query = "select count(*) from Article a where a.person.personId = :personId or " + "a.researchGroup.researchGroupId is null or " + "a.researchGroup.researchGroupId in " + "(select rm.id.researchGroupId from ResearchGroupMembership rm where rm.id.personId = :personId)"; - return ((Long) getSession().createQuery(query).setParameter("personId", person.getPersonId()).uniqueResult()).intValue(); + return ((Long) currentSession().createQuery(query).setParameter("personId", person.getPersonId()).uniqueResult()).intValue(); } /** @@ -143,20 +142,19 @@ public Article getArticleDetail(int id, Person loggedPerson) { if (loggedPerson.getAuthority().equals("ROLE_ADMIN")) { String query = "from Article a left join fetch a.subscribers left join fetch a.articleComments " + "where a.articleId = :id"; - return (Article) getSession().createQuery(query).setParameter("id", id).uniqueResult(); + return (Article) currentSession().createQuery(query).setParameter("id", id).uniqueResult(); } else { String query = "from Article a left join fetch a.subscribers left join fetch a.articleComments "+ "where a.articleId = :id and (" + "a.researchGroup.researchGroupId is null or " + "a.researchGroup.researchGroupId in " + "(select rm.id.researchGroupId from ResearchGroupMembership rm where rm.id.personId = :personId))"; - return (Article) getSession().createQuery(query).setParameter("id", id).setParameter("personId", loggedPerson.getPersonId()).uniqueResult(); + return (Article) currentSession().createQuery(query).setParameter("id", id).setParameter("personId", loggedPerson.getPersonId()).uniqueResult(); } } public List
getAllUserArticles() { String HQLSelect = "from Article order by time desc"; - List
articles = getHibernateTemplate().find(HQLSelect); - return articles; + return currentSession().createQuery(HQLSelect).list(); } } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleArtifactRemovingDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleArtifactRemovingDao.java index 7f0e0953..63e92c41 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleArtifactRemovingDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleArtifactRemovingDao.java @@ -88,7 +88,7 @@ public void createDefaultRecord(ArtifactRemoveMethod persistent) { @Override public List getDefaultRecords() { String hqlQuery = "from ArtifactRemoveMethod ar where ar.defaultNumber = 1"; - return getHibernateTemplate().find(hqlQuery); + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } @Override diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleAuthorizationManager.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleAuthorizationManager.java index 7373aead..c093e1ed 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleAuthorizationManager.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleAuthorizationManager.java @@ -167,7 +167,7 @@ private List getGroupsWhereBothPersons(int personId1, int personId2) { String[] paramNames = {"loggedUserId", "personId"}; Object[] values = {personId1, personId2}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, paramNames, values); + List list = (List) getHibernateTemplate().findByNamedParam(hqlQuery, paramNames, values); return list; } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleDigitizationDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleDigitizationDao.java index 411f20e5..3d3caa18 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleDigitizationDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleDigitizationDao.java @@ -46,7 +46,7 @@ public Digitization getDigitizationByParams(float samplingRate, float gain, Stri String[] paramNames = {"samplingRate", "gain", "filter"}; Object[] values = {samplingRate, gain, filter}; String HQLQuery = "from Digitization d where d.samplingRate = :samplingRate and d.gain = :gain and d.filter = :filter"; - List list = getHibernateTemplate().findByNamedParam(HQLQuery, paramNames, values); + List list = (List) getHibernateTemplate().findByNamedParam(HQLQuery, paramNames, values); if (list.size() > 0) { return list.get(0); } @@ -75,18 +75,14 @@ public List getRecordsByGroup(int groupId) { @Override public boolean canDelete(int id) { String hqlQuery = "select dig.experiments from Digitization dig where dig.digitizationId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @Override public boolean hasGroupRel(int id) { String hqlQuery = "from Digitization dig where dig.digitizationId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return list.get(0).getResearchGroups().size() > 0; } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleDiseaseDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleDiseaseDao.java index da8067bb..d51eab0e 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleDiseaseDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleDiseaseDao.java @@ -63,18 +63,15 @@ public List getRecordsByGroup(int groupId) { @Override public boolean canDelete(int id) { String hqlQuery = "select dis.experiments from Disease dis where dis.diseaseId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @Override public boolean hasGroupRel(int id) { String hqlQuery = "from Disease dis where dis.diseaseId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return list.get(0).getResearchGroups().size() > 0; } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleEducationLevelDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleEducationLevelDao.java index 65b9ee5e..2285113a 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleEducationLevelDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleEducationLevelDao.java @@ -47,8 +47,8 @@ public SimpleEducationLevelDao() { * @return List of EducationLevel entities with searched title */ public List getEducationLevels(String title) { - String HQLselect = "from EducationLevel level where level.title = :title"; - return getHibernateTemplate().findByNamedParam(HQLselect, "title", title); + String hqlQuery = "from EducationLevel level where level.title = :title"; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("title", title).list(); } @Override @@ -72,18 +72,14 @@ public List getRecordsByGroup(int groupId) { @Override public boolean canDelete(int id) { String hqlQuery = "select ed.persons from EducationLevel ed where ed.educationLevelId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @Override public boolean hasGroupRel(int id) { String hqlQuery = "from EducationLevel ed where ed.educationLevelId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return list.get(0).getResearchGroups().size() > 0; } @@ -102,7 +98,7 @@ public void createDefaultRecord(EducationLevel educationLevel) { @Override public List getDefaultRecords() { String hqlQuery = "from EducationLevel ed where ed.defaultNumber = 1"; - return getHibernateTemplate().find(hqlQuery); + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } @Override diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeFixDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeFixDao.java index 354a7533..71de018a 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeFixDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeFixDao.java @@ -64,7 +64,7 @@ public boolean canDelete(int id) { String hqlQuery = "select el.electrodeLocations from ElectrodeFix el where el.electrodeFixId = :id"; String[] names = {"id"}; Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @@ -73,7 +73,7 @@ public boolean hasGroupRel(int id) { String hqlQuery = "from ElectrodeFix el where el.electrodeFixId = :id"; String[] names = {"id"}; Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return list.get(0).getResearchGroups().size() > 0; } @@ -92,7 +92,7 @@ public void createDefaultRecord(ElectrodeFix persistent) { @Override public List getDefaultRecords() { String hqlQuery = "from ElectrodeFix el where el.defaultNumber = 1"; - return getHibernateTemplate().find(hqlQuery); + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } @Override diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeLocationDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeLocationDao.java index 1b1c4e64..c3f0c69b 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeLocationDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeLocationDao.java @@ -62,18 +62,14 @@ public List getRecordsByGroup(int groupId) { @Override public boolean canDelete(int id) { String hqlQuery = "select el.electrodeConfs from ElectrodeLocation el where el.electrodeLocationId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @Override public boolean hasGroupRel(int id) { String hqlQuery = "from ElectrodeLocation el where el.electrodeLocationId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return list.get(0).getResearchGroups().size() > 0; } @@ -92,7 +88,7 @@ public void createDefaultRecord(ElectrodeLocation persistent) { @Override public List getDefaultRecords() { String hqlQuery = "from ElectrodeLocation el where el.defaultNumber = 1"; - return getHibernateTemplate().find(hqlQuery); + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } @Override diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeSystemDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeSystemDao.java index 53f66983..15359bb8 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeSystemDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeSystemDao.java @@ -64,7 +64,7 @@ public boolean canDelete(int id) { String hqlQuery = "select el.electrodeConfs from ElectrodeSystem el where el.electrodeSystemId = :id"; String[] names = {"id"}; Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @@ -73,7 +73,7 @@ public boolean hasGroupRel(int id) { String hqlQuery = "from ElectrodeSystem el where el.electrodeSystemId = :id"; String[] names = {"id"}; Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return list.get(0).getResearchGroups().size() > 0; } @@ -92,7 +92,7 @@ public void createDefaultRecord(ElectrodeSystem persistent) { @Override public List getDefaultRecords() { String hqlQuery = "from ElectrodeSystem el where el.defaultNumber=1"; - return getHibernateTemplate().find(hqlQuery); + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } @Override diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeTypeDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeTypeDao.java index 1d3bbe39..972ead14 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeTypeDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleElectrodeTypeDao.java @@ -62,18 +62,14 @@ public List getRecordsByGroup(int groupId) { @Override public boolean canDelete(int id) { String hqlQuery = "select el.electrodeLocations from ElectrodeType el where el.electrodeTypeId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @Override public boolean hasGroupRel(int id) { String hqlQuery = "from ElectrodeType el where el.electrodeFixId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return list.get(0).getResearchGroups().size() > 0; } @@ -92,7 +88,7 @@ public void createDefaultRecord(ElectrodeType persistent) { @Override public List getDefaultRecords() { String hqlQuery = "from ElectrodeType el where el.defaultNumber = 1"; - return getHibernateTemplate().find(hqlQuery); + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } @Override diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentDao.java index 0c22ac3e..ee5a40f5 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentDao.java @@ -37,6 +37,7 @@ import java.util.Date; import java.util.List; +import com.hp.hpl.jena.sparql.function.library.e; import org.apache.commons.lang.NotImplementedException; import org.elasticsearch.index.query.AndFilterBuilder; import org.elasticsearch.index.query.BoolFilterBuilder; @@ -91,13 +92,13 @@ public void setElasticsearchTemplate(ElasticsearchTemplate elasticsearchTemplate } public List getDataFilesWhereExpId(int experimentId) { - String HQLselect = "from DataFile file where file.experiment.experimentId = :experimentId"; - return getHibernateTemplate().findByNamedParam(HQLselect, "experimentId", experimentId); + String hqlQuery = "from DataFile file where file.experiment.experimentId = :experimentId"; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("experimentId", experimentId).list(); } public List getDataFilesWhereId(int dataFileId) { - String HQLselect = "from DataFile file where file.dataFileId = :dataFileId"; - return getHibernateTemplate().findByNamedParam(HQLselect, "dataFileId", dataFileId); + String hqlQuery = "from DataFile file where file.dataFileId = :dataFileId"; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } @Override @@ -217,9 +218,7 @@ public List getRecordsNewerThan(int personId) { + "epl.license.licenseId = pl.license.licenseId and " + "pl.person.personId = :personId) " + " ORDER BY ex.startTime DESC"; - String[] stringParams = {"personId"}; - Object[] objectParams = {personId}; - return getHibernateTemplate().findByNamedParam(HQLselect, stringParams, objectParams); + return getSessionFactory().getCurrentSession().createQuery(HQLselect).setParameter("personId", personId).list(); } public List getExperimentSearchResults(List requests, int personId) throws NumberFormatException { @@ -272,7 +271,7 @@ public List getExperimentSearchResults(List requests, + "epc.experimentPackage.experimentPackageId = epl.experimentPackage.experimentPackageId and " + "epl.license.licenseId = pl.license.licenseId and " + "pl.person.personId = " + personId + ")"; - Session ses = getSession(); + Session ses = currentSession(); Query q = ses.createQuery(hqlQuery); int i = 0; for (Date date : datas) { diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentLicenceDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentLicenceDao.java index 6cdde918..67f3d2bf 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentLicenceDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentLicenceDao.java @@ -39,7 +39,7 @@ public SimpleExperimentLicenceDao() { @Override public void remove(Experiment experiment, License license) { String hqlQuery = "delete from ExperimentLicence el where el.experiment = :ex and el.license = :lic"; - this.getSession().createQuery(hqlQuery).setParameter("ex",experiment).setParameter("lic",license).executeUpdate(); + this.currentSession().createQuery(hqlQuery).setParameter("ex",experiment).setParameter("lic",license).executeUpdate(); } } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentOptParamDefDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentOptParamDefDao.java index 16a2369a..e2c5220f 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentOptParamDefDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentOptParamDefDao.java @@ -35,15 +35,14 @@ public SimpleExperimentOptParamDefDao() { public List getItemsForList() { String hqlQuery = "from ExperimentOptParamDef i order by i.paramName"; - List list = getHibernateTemplate().find(hqlQuery); - return list; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } public boolean canDelete(int id) { String hqlQuery = "select def.experimentOptParamVals from ExperimentOptParamDef def where def.experimentOptParamDefId = :id"; String[] names = {"id"}; Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @@ -60,8 +59,7 @@ public void createDefaultRecord(ExperimentOptParamDef experimentOptParamDef) { public List getDefaultRecords() { String hqlQuery = "from ExperimentOptParamDef h where h.defaultNumber = 1"; - List list = getHibernateTemplate().find(hqlQuery); - return list; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } public boolean hasGroupRel(int id) { diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentPackageConnectionDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentPackageConnectionDao.java index f0f6b58d..f3c86a92 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentPackageConnectionDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentPackageConnectionDao.java @@ -81,7 +81,7 @@ public boolean isExperimentInPackage(int experimentId, int packageId) { @Override public boolean removeExperimentFromPackage(int experimentId, int packageId) { String hqlQuery = "delete from ExperimentPackageConnection epc where epc.experiment = :experiment and epc.experimentPackage = :package"; - int i = this.getSession().createQuery(hqlQuery).setInteger("experiment", experimentId).setInteger("package", packageId).executeUpdate(); + int i = this.currentSession().createQuery(hqlQuery).setInteger("experiment", experimentId).setInteger("package", packageId).executeUpdate(); return i > 0; } @@ -100,7 +100,7 @@ public Integer create(ExperimentPackageConnection newInstance) { @Override public void removeAllConnections(ExperimentPackage pack) { String hqlQuery = "delete from ExperimentPackageConnection epc where epc.experimentPackage = :ep"; - this.getSession().createQuery(hqlQuery).setInteger("ep", pack.getExperimentPackageId()).executeUpdate(); + this.currentSession().createQuery(hqlQuery).setInteger("ep", pack.getExperimentPackageId()).executeUpdate(); } @Override diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentPackageLicenseDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentPackageLicenseDao.java index a337a478..fdaad991 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentPackageLicenseDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleExperimentPackageLicenseDao.java @@ -45,13 +45,13 @@ public SimpleExperimentPackageLicenseDao() { public void removeLicenseFromPackage(int packageId, int licenseId ) { String hqlQuery = "delete from ExperimentPackageLicense epl where epl.experimentPackage = :ep and epl.license = :l"; - Session session = getSession(); + Session session = currentSession(); session.createQuery(hqlQuery).setInteger("ep", packageId).setInteger("l", licenseId).executeUpdate(); } @Override public void removeAllConnections(ExperimentPackage pack) { String hqlQuery = "delete from ExperimentPackageLicense epl where epl.experimentPackage = :ep"; - this.getSession().createQuery(hqlQuery).setInteger("ep", pack.getExperimentPackageId()).executeUpdate(); + this.currentSession().createQuery(hqlQuery).setInteger("ep", pack.getExperimentPackageId()).executeUpdate(); } } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleFileMetadataParamDefDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleFileMetadataParamDefDao.java index 37b6c00a..5bf26e44 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleFileMetadataParamDefDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleFileMetadataParamDefDao.java @@ -35,15 +35,12 @@ public SimpleFileMetadataParamDefDao() { public List getItemsForList() { String hqlQuery = "from FileMetadataParamDef d order by d.paramName"; - List list = getHibernateTemplate().find(hqlQuery); - return list; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } public boolean canDelete(int id) { String hqlQuery = "select def.fileMetadataParamVals from FileMetadataParamDef def where def.fileMetadataParamDefId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @@ -59,8 +56,7 @@ public void createDefaultRecord(FileMetadataParamDef fileMetadataParamDef) { public List getDefaultRecords() { String hqlQuery = "from FileMetadataParamDef h where h.defaultNumber = 1"; - List list = getHibernateTemplate().find(hqlQuery); - return list; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } public boolean hasGroupRel(int id) { diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleFormLayoutDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleFormLayoutDao.java index 4244ac1c..a03e39a7 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleFormLayoutDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleFormLayoutDao.java @@ -24,16 +24,15 @@ **********************************************************************************************************************/ package cz.zcu.kiv.eegdatabase.data.dao; -import java.util.List; - +import cz.zcu.kiv.eegdatabase.data.pojo.FormLayout; +import cz.zcu.kiv.eegdatabase.data.pojo.FormLayoutType; +import cz.zcu.kiv.eegdatabase.data.pojo.Person; import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; import org.springframework.dao.support.DataAccessUtils; -import cz.zcu.kiv.eegdatabase.data.pojo.FormLayout; -import cz.zcu.kiv.eegdatabase.data.pojo.FormLayoutType; -import cz.zcu.kiv.eegdatabase.data.pojo.Person; +import java.util.List; /** @@ -94,7 +93,7 @@ public List getFormNames(Person owner) { if (owner != null) criteria.add(Restrictions.eq("person.personId", owner.getPersonId())); - return getHibernateTemplate().findByCriteria(criteria); + return (List) getHibernateTemplate().findByCriteria(criteria); } @@ -183,7 +182,7 @@ public List getLayouts(Person owner, String formName, FormLayoutType if (templateType != null) criteria.add(Restrictions.eq("type", templateType)); - return getHibernateTemplate().findByCriteria(criteria); + return (List) getHibernateTemplate().findByCriteria(criteria); } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleGenericDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleGenericDao.java index 1fa575b7..e70d2d56 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleGenericDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleGenericDao.java @@ -22,14 +22,7 @@ ******************************************************************************/ package cz.zcu.kiv.eegdatabase.data.dao; -import java.io.IOException; -import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - +import cz.zcu.kiv.eegdatabase.logic.indexing.PojoIndexer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.lucene.queryparser.classic.ParseException; @@ -41,9 +34,15 @@ import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; +import org.springframework.orm.hibernate4.support.HibernateDaoSupport; -import cz.zcu.kiv.eegdatabase.logic.indexing.PojoIndexer; +import java.io.IOException; +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Iterator; +import java.util.List; +import java.util.Map; /** * Class implements interface for connecting logic and data layer. @@ -174,7 +173,8 @@ public void delete(T persistentObject) { */ public List getAllRecords() { DetachedCriteria forClass = DetachedCriteria.forClass(type); - return getHibernateTemplate().findByCriteria(forClass); + // return getHibernateTemplate().findByCriteria(forClass); + return forClass.getExecutableCriteria(currentSession()).list(); //return getHibernateTemplate().loadAll(type); } @@ -214,8 +214,9 @@ public List getAllRecordsFull() { * @return list that includes specific count of records */ public List getRecordsAtSides(int first, int max) { - return getHibernateTemplate().findByCriteria( + return (List) getHibernateTemplate().findByCriteria( DetachedCriteria.forClass(type), first, max); + } /** diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleHardwareDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleHardwareDao.java index 7b96a93a..f64c58a9 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleHardwareDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleHardwareDao.java @@ -35,16 +35,13 @@ public SimpleHardwareDao() { public boolean canDelete(int id) { String hqlQuery = "select h.experiments from Hardware h where h.hardwareId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } public List getItemsForList() { String hqlQuery = "from Hardware h order by h.title, h.type"; - List list = getHibernateTemplate().find(hqlQuery); - return list; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } public List getRecordsByGroup(int groupId) { @@ -60,8 +57,7 @@ public void createDefaultRecord(Hardware hardware) { public List getDefaultRecords() { String hqlQuery = "from Hardware h where h.defaultNumber = 1"; - List list = getHibernateTemplate().find(hqlQuery); - return list; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } public boolean canSaveTitle(String title, int groupId, int hwId) { diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleHistoryDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleHistoryDao.java index 128647cf..dbb49829 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleHistoryDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleHistoryDao.java @@ -64,12 +64,11 @@ public List getHistory(ChoiceHistory historyType, boolean isGroupAdmin, leftJoin = getLeftJoin(isGroupAdmin, groupId); whereCondition = getWhereCondition(historyType); groupCondition = getGroupCondition(isGroupAdmin, groupId); - String HQLselect = "select distinct h from History as h" + leftJoin + whereCondition + groupCondition; + String hqlQuery = "select distinct h from History as h" + leftJoin + whereCondition + groupCondition; if (!isGroupAdmin) { - return getHibernateTemplate().find(HQLselect); + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } - results = getHibernateTemplate().find(HQLselect); - return results; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } /** * Returns string left join for hql query if user has some group and his role is GROUP_ADMIN @@ -122,9 +121,9 @@ public long getCountOfFilesHistory(ChoiceHistory historyType, boolean isGroupAdm whereCondition = getWhereCondition(historyType); groupCondition = getGroupCondition(isGroupAdmin, groupId); - String HQLselect = "select distinct new cz.zcu.kiv.eegdatabase.logic.controller.history.DownloadStatistic(count(h.historyId)) from History as h" + leftJoin + whereCondition + groupCondition; + String hqlQuery = "select distinct new cz.zcu.kiv.eegdatabase.logic.controller.history.DownloadStatistic(count(h.historyId)) from History as h" + leftJoin + whereCondition + groupCondition; - dCount = getHibernateTemplate().find(HQLselect); + dCount = getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); return dCount.get(0).getCount(); } /** @@ -243,7 +242,7 @@ public List getTopDownloadHistory(ChoiceHistory historyType, * Returns search results * @param requests - search request * @param isGroupAdmin - determined role GROUP_ADMIN - * @param groupId - group id + * @param groupsId - group id * @return list of search results */ public List getHistorySearchResults(List requests, boolean isGroupAdmin, List groupsId) { @@ -271,7 +270,7 @@ public List getHistorySearchResults(List requests, boole hqlQuery += getGroupsCondition(isGroupAdmin, groupsId); List results; try { - results = getHibernateTemplate().find(hqlQuery); + results = getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); System.out.println(results.size()); } catch (Exception e) { return new ArrayList(); @@ -281,7 +280,7 @@ public List getHistorySearchResults(List requests, boole /** * Returns groups cnodition * @param isGroupAdmin - determined role GROUP_ADMIN - * @param groupId - group id + * @param groupsId - group id * @return groups condition for history search */ private String getGroupsCondition(boolean isGroupAdmin, List groupsId) { diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleKeywordsDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleKeywordsDao.java index 1ef941a2..b9788b90 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleKeywordsDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleKeywordsDao.java @@ -52,7 +52,7 @@ public SimpleKeywordsDao() { */ public String getKeywords(int groupId){ String hqlQuery = "select k.keywordsText " +"from Keywords k " + "left join k.researchGroup rg " + "where rg.researchGroupId = :groupId and k.keywordsText is not null" ; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, "groupId", groupId); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("groupId", groupId).list(); if(!list.isEmpty()){ return list.get(0); }else{ @@ -73,7 +73,7 @@ public List getKeywordsFromPackage(ExperimentPackage pck) { */ public int getID(int groupId){ String hqlQuery = "select k.keywordsId " +"from Keywords k " + "left join k.researchGroup rg " + "where rg.researchGroupId = :groupId" ; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, "groupId", groupId); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("groupId", groupId).list(); if(!list.isEmpty()){ return list.get(0); }else{ diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleLicenseDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleLicenseDao.java index 87a4fa32..b95bc825 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleLicenseDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleLicenseDao.java @@ -59,13 +59,13 @@ public List getLicensesByType(LicenseType licenseType) { @Override public List getLicensesByType(List licenseType) { String hqlQuery = "select l from License l where l.licenseType IN (:licenseType)"; - return this.getSession().createQuery(hqlQuery).setParameterList("licenseType", licenseType).list(); + return this.currentSession().createQuery(hqlQuery).setParameterList("licenseType", licenseType).list(); } @Override public byte[] getLicenseAttachmentContent(int licenseId) { String query = "from License l where l.licenseId = :id"; - License result = (License) this.getSession().createQuery(query).setInteger("id", licenseId).uniqueResult(); + License result = (License) this.currentSession().createQuery(query).setInteger("id", licenseId).uniqueResult(); try { return result.getAttachmentContent() != null ? result.getAttachmentContent().getBytes(1, (int) result.getAttachmentContent().length()) : new byte[0]; } catch (SQLException e) { @@ -83,7 +83,7 @@ public List getLicenseForPackageAndOwnedByPerson(int personId, int pack + "select epl.license.licenseId from ExperimentPackageLicense as epl where epl.experimentPackage.experimentPackageId = :packageId" + ") and pl.license.researchGroup IS NOT NULL"; - return (List) this.getSession().createQuery(query) + return (List) this.currentSession().createQuery(query) .setParameter("personId", personId) .setParameter("state", PersonalLicenseState.AUTHORIZED) .setParameter("packageId", packageId).list(); @@ -91,7 +91,7 @@ public List getLicenseForPackageAndOwnedByPerson(int personId, int pack @Override public void update(License transientObject) { - this.getSession().merge(transientObject); + this.currentSession().merge(transientObject); } @Override @@ -140,7 +140,7 @@ public License getLicenseForPurchasedExpPackage(int experimentPackageId, int per public List getLicensesForExperiment(int experimentId) { List ret; String query = "select l from License l where l.licenseId IN(select license.licenseId from ExperimentLicence where experiment.experimentId = :exId)"; - ret = (List) this.getSession().createQuery(query).setParameter("exId",experimentId).list(); + ret = (List) this.currentSession().createQuery(query).setParameter("exId",experimentId).list(); return ret; @@ -150,7 +150,7 @@ public List getLicensesForExperiment(int experimentId) { public List getPersonLicenses(int personId) { List ret; String query = "select distinct l.license from ExperimentLicence l where l.experiment.personByOwnerId.personId = :personId"; - ret = (List) this.getSession().createQuery(query).setParameter("personId",personId).list(); + ret = (List) this.currentSession().createQuery(query).setParameter("personId",personId).list(); return ret; diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleMembershipPlanDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleMembershipPlanDao.java index fb2e72a7..aac697f8 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleMembershipPlanDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleMembershipPlanDao.java @@ -38,7 +38,7 @@ public class SimpleMembershipPlanDao extends SimpleGenericDao getAvailableGroupMembershipPlans() { String query = "select m from MembershipPlan m where m.type = :membershipPlanType and m.valid = 'TRUE'"; - List ret = this.getSession().createQuery(query).setParameter("membershipPlanType", MembershipPlanType.GROUP.getType()).list(); //set parameters + List ret = this.currentSession().createQuery(query).setParameter("membershipPlanType", MembershipPlanType.GROUP.getType()).list(); //set parameters return ret; } @@ -46,14 +46,14 @@ public List getAvailableGroupMembershipPlans() { public List getAvailablePersonMembershipPlans() { String query = "select m from MembershipPlan m where m.type = :membershipPlanType and m.valid = 'TRUE'"; - List ret = this.getSession().createQuery(query).setParameter("membershipPlanType",MembershipPlanType.PERSON.getType()).list(); //set parameters + List ret = this.currentSession().createQuery(query).setParameter("membershipPlanType",MembershipPlanType.PERSON.getType()).list(); //set parameters return ret; } @Override public MembershipPlan getMembershipPlanById(Integer id) { String query = "select m from MembershipPlan m where m.membershipId = :id"; - MembershipPlan ret = (MembershipPlan) this.getSession().createQuery(query).setParameter("id",id).uniqueResult(); + MembershipPlan ret = (MembershipPlan) this.currentSession().createQuery(query).setParameter("id",id).uniqueResult(); return ret; } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonDao.java index f6b9b89f..e3099d7f 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonDao.java @@ -99,8 +99,8 @@ public Person getPersonByFbUid(String facebookId) { * @return */ public List getPersonsWherePendingRequirement() { - String HQLselect = "from Person person where person.requiresWriting = 'T' and person.authority = 'ROLE_READER'"; - return getHibernateTemplate().find(HQLselect); + String hqlQuery = "from Person person where person.requiresWriting = 'T' and person.authority = 'ROLE_READER'"; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } /** @@ -113,9 +113,8 @@ public List getPersonsWherePendingRequirement() { * else return false */ public boolean usernameExists(String userName) { - String HQLselect = "from Person person where person.username = :userName"; - List list = getHibernateTemplate(). - findByNamedParam(HQLselect, "userName", userName); + String hqlQuery = "from Person person where person.username = :userName"; + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("userName", userName).list(); return (!list.isEmpty()); } @@ -129,9 +128,8 @@ public boolean usernameExists(String userName) { * else return false */ public boolean fbUidExists(String facebookId) { - String HQLselect = "from Person person where person.facebookId = :facebookId"; - List list = getHibernateTemplate(). - findByNamedParam(HQLselect, "facebookId", facebookId); + String hqlQuery = "from Person person where person.facebookId = :facebookId"; + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("facebookId", facebookId).list(); return (!list.isEmpty()); } @@ -142,8 +140,8 @@ public boolean fbUidExists(String facebookId) { * @return list of Person with supervisor's authority. */ public List getSupervisors() { - String HQLselect = "from Person person where person.authority = 'ROLE_SUPERVISOR'"; - return getHibernateTemplate().find(HQLselect); + String hqlQuery = "from Person person where person.authority = 'ROLE_SUPERVISOR'"; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } /** @@ -210,7 +208,7 @@ public List getPersonSearchResults(List requests) throws List results; try { - results = getHibernateTemplate().find(hqlQuery); + results = getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } catch (Exception e) { return new ArrayList(); } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonMembershipPlanDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonMembershipPlanDao.java index 76988cba..cae0673a 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonMembershipPlanDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonMembershipPlanDao.java @@ -39,7 +39,7 @@ public class SimplePersonMembershipPlanDao extends SimpleGenericDao getPersonMembershipPlans(Person person) { String query = "select m from PersonMembershipPlan m where m.person = :person"; - List ret = this.getSession().createQuery(query).setParameter("person",person).list(); //set parameters + List ret = this.currentSession().createQuery(query).setParameter("person",person).list(); //set parameters return ret; } @@ -47,7 +47,7 @@ public List getPersonMembershipPlans(Person person) { public boolean isPlanUsed(int membershipPlanId) { String query = "select membershipPlan from PersonMembershipPlan m where m.membershipPlan.membershipId = :plan"; - return (!this.getSession().createQuery(query).setParameter("plan",membershipPlanId).list().isEmpty()); + return (!this.currentSession().createQuery(query).setParameter("plan",membershipPlanId).list().isEmpty()); } @Override @@ -57,7 +57,7 @@ public boolean hasActiveMembershipPlan(Person person) { String query = "select m from PersonMembershipPlan m where m.person = :person and m.to > :time"; - return (!this.getSession().createQuery(query).setParameter("person",person).setParameter("time",time).list().isEmpty()); //set parameters + return (!this.currentSession().createQuery(query).setParameter("person",person).setParameter("time",time).list().isEmpty()); //set parameters } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonOptParamDefDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonOptParamDefDao.java index 16dfc94a..282df278 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonOptParamDefDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonOptParamDefDao.java @@ -35,15 +35,12 @@ public SimplePersonOptParamDefDao() { public List getItemsForList() { String hqlQuery = "from PersonOptParamDef i order by i.paramName"; - List list = getHibernateTemplate().find(hqlQuery); - return list; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } public boolean canDelete(int id) { String hqlQuery = "select def.personOptParamVals from PersonOptParamDef def where def.personOptParamDefId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @@ -60,8 +57,7 @@ public void createDefaultRecord(PersonOptParamDef personOptParamDef) { public List getDefaultRecords() { String hqlQuery = "from PersonOptParamDef h where h.defaultNumber = 1"; - List list = getHibernateTemplate().find(hqlQuery); - return list; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } public boolean hasGroupRel(int id) { diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonalLicenseDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonalLicenseDao.java index d3af0af9..8379026a 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonalLicenseDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePersonalLicenseDao.java @@ -54,7 +54,7 @@ public SimplePersonalLicenseDao() { @Override public List getLicenseRequests(ResearchGroup group, PersonalLicenseState state) { if (group != null) { - Criteria criteria = this.getSession().createCriteria(PersonalLicense.class); + Criteria criteria = this.currentSession().createCriteria(PersonalLicense.class); criteria.add(Restrictions.eq("licenseState", state)); criteria.createAlias("license", "l"); //criteria.add(Restrictions.ne("l.licenseType", LicenseType.OWNER)); @@ -67,7 +67,7 @@ public List getLicenseRequests(ResearchGroup group, PersonalLic @Override public List getLicenseRequests(Person applicant, PersonalLicenseState state) { - Criteria criteria = this.getSession().createCriteria(PersonalLicense.class); + Criteria criteria = this.currentSession().createCriteria(PersonalLicense.class); criteria.add(Restrictions.eq("person.personId", applicant.getPersonId())); criteria.add(Restrictions.eq("licenseState", state)); return criteria.list(); @@ -96,7 +96,7 @@ public Integer create(PersonalLicense newInstance) { @Override public List getUsersLicenses(Person person) { - Criteria criteria = this.getSession().createCriteria(PersonalLicense.class); + Criteria criteria = this.currentSession().createCriteria(PersonalLicense.class); criteria.add(Restrictions.eq("person.personId", person.getPersonId())); criteria.setProjection(Projections.property("license")); return criteria.list(); @@ -105,7 +105,7 @@ public List getUsersLicenses(Person person) { @Override public byte[] getAttachmentContent(int personalLicenseId) { String query = "from PersonalLicense pl where pl.personalLicenseId = :id"; - PersonalLicense result = (PersonalLicense) this.getSession().createQuery(query).setInteger("id", personalLicenseId).uniqueResult(); + PersonalLicense result = (PersonalLicense) this.currentSession().createQuery(query).setInteger("id", personalLicenseId).uniqueResult(); try { return result.getAttachmentContent().getBytes(1, (int) result.getAttachmentContent().length()); } catch (SQLException e) { diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePharmaceuticalDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePharmaceuticalDao.java index 8e07d441..54ef56d7 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePharmaceuticalDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePharmaceuticalDao.java @@ -52,7 +52,7 @@ public void createGroupRel(Pharmaceutical persistent, ResearchGroup researchGrou @Override public List getItemsForList() { String hqlQuery = "from Pharmaceutical ph order by ph.title"; - return getHibernateTemplate().find(hqlQuery); + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } @Override @@ -64,18 +64,14 @@ public List getRecordsByGroup(int groupId) { @Override public boolean canDelete(int id) { String hqlQuery = "select ph.experiments from Pharmaceutical ph where ph.pharmaceuticalId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @Override public boolean hasGroupRel(int id) { String hqlQuery = "from Pharmaceutical ph where ph.pharmaceuticalId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return list.get(0).getResearchGroups().size() > 0; } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleProjectTypeDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleProjectTypeDao.java index aa7b7413..f29b5a5d 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleProjectTypeDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleProjectTypeDao.java @@ -50,7 +50,7 @@ public void createGroupRel(ProjectType persistent, ResearchGroup researchGroup) @Override public List getItemsForList() { String hqlQuery = "from ProjectType pr order by pr.title"; - return getHibernateTemplate().find(hqlQuery); + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } @Override @@ -62,18 +62,14 @@ public List getRecordsByGroup(int groupId) { @Override public boolean canDelete(int id) { String hqlQuery = "select pr.experiments from ProjectType pr where pr.projectTypeId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @Override public boolean hasGroupRel(int id) { String hqlQuery = "from ProjectType pr where pr.projectTypeId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return list.get(0).getResearchGroups().size() > 0; } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePromoCodeDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePromoCodeDao.java index a98bdedd..2b499f7b 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePromoCodeDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimplePromoCodeDao.java @@ -39,20 +39,20 @@ public class SimplePromoCodeDao extends SimpleGenericDao impl public List getAvailableGroupPromoCodes() { String query = "select m from PromoCode m where m.type = :promoCodeType and m.valid = 'TRUE'"; - List ret = this.getSession().createQuery(query).setParameter("promoCodeType", MembershipPlanType.GROUP.getType()).list(); //set parameters + List ret = this.currentSession().createQuery(query).setParameter("promoCodeType", MembershipPlanType.GROUP.getType()).list(); //set parameters return ret; } public List getAvailablePersonPromoCodes() { String query = "select m from PromoCode m where m.type = :promoCodeType and m.valid = 'TRUE'"; - List ret = this.getSession().createQuery(query).setParameter("promoCodeType", MembershipPlanType.PERSON.getType()).list(); //set parameters + List ret = this.currentSession().createQuery(query).setParameter("promoCodeType", MembershipPlanType.PERSON.getType()).list(); //set parameters return ret; } public PromoCode getPromoCodeById(Integer id) { String query = "select m from PromoCode m where m.promoCodeId = :id"; - PromoCode ret = (PromoCode) this.getSession().createQuery(query).setParameter("id",id).uniqueResult(); + PromoCode ret = (PromoCode) this.currentSession().createQuery(query).setParameter("id",id).uniqueResult(); return ret; } @@ -60,7 +60,7 @@ public PromoCode getPromoCodeByKeyword(String keyWord) { Timestamp time = new Timestamp(new Date().getTime()); String query = "select m from PromoCode m where m.keyword = :keyword and m.valid='TRUE' and :time between m.from and m.to"; - PromoCode ret = (PromoCode) this.getSession().createQuery(query).setParameter("keyword",keyWord).setParameter("time",time).uniqueResult(); + PromoCode ret = (PromoCode) this.currentSession().createQuery(query).setParameter("keyword",keyWord).setParameter("time",time).uniqueResult(); return ret; } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleResearchGroupDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleResearchGroupDao.java index 3a999b37..13094866 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleResearchGroupDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleResearchGroupDao.java @@ -54,7 +54,7 @@ public List getResearchGroupsWhereMember(Person person) { String hqlQuery = "from ResearchGroup researchGroup " + "where researchGroupId in (select rgm.id.researchGroupId from ResearchGroupMembership rgm where id.personId = :personId) " + "order by researchGroup.title"; - return getHibernateTemplate().findByNamedParam(hqlQuery, "personId", person.getPersonId()); + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("personId", person.getPersonId()).list(); } public List getResearchGroupsWhereMember(Person person, int limit) { @@ -62,8 +62,8 @@ public List getResearchGroupsWhereMember(Person person, int limit + "where researchGroupId in (select rgm.id.researchGroupId from ResearchGroupMembership rgm where id.personId = :personId) " + "order by researchGroup.title"; - getHibernateTemplate().setMaxResults(limit); - List list = getHibernateTemplate().findByNamedParam(hqlQuery, "personId", person.getPersonId()); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter + ("personId", person.getPersonId()).setMaxResults(limit).list(); getHibernateTemplate().setMaxResults(0); return list; } @@ -77,7 +77,7 @@ public List getResearchGroupsWhereMember(Person person, int limit public List getResearchGroupsWhereOwner(Person person) { String hqlQuery = "from ResearchGroup researchGroup " + "where researchGroup.person.personId = :ownerId"; - return getHibernateTemplate().findByNamedParam(hqlQuery, "ownerId", person.getPersonId()); + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("ownerId", person.getPersonId()).list(); } public List getResearchGroupsWhereAbleToWriteInto(Person person) { @@ -89,7 +89,7 @@ public List getResearchGroupsWhereAbleToWriteInto(Person person) String[] names = {"personId", "experimenter", "admin"}; Object[] params = {person.getPersonId(), Util.GROUP_EXPERIMENTER, Util.GROUP_ADMIN}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, params); + List list = (List) getHibernateTemplate().findByNamedParam(hqlQuery, names, params); return list; } @@ -101,8 +101,7 @@ public List getGroupDataForAccountOverview(Person pers + "from ResearchGroup g " + "left join g.researchGroupMemberships m " + "where m.person.personId = :personId"; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, "personId", person.getPersonId()); - return list; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("personId", person.getPersonId()).list(); } public List getListOfGroupMembers(int groupId) { @@ -130,7 +129,7 @@ public List getResearchGroupsWhereUserIsGroupAdmin(Person person) String[] names = {"personId", "admin"}; Object[] params = {person.getPersonId(), Util.GROUP_ADMIN}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, params); + List list = (List) getHibernateTemplate().findByNamedParam(hqlQuery, names, params); return list; } @@ -149,7 +148,7 @@ public boolean canSaveTitle(String title, int id) { String hqlQuery = "from ResearchGroup g where g.title = :title and g.researchGroupId != :id"; String[] names = {"title", "id"}; Object[] values = {title, id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = (List) getHibernateTemplate().findByNamedParam(hqlQuery, names, values); return (list.size() == 0); } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleResearchGroupMembershipPlanDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleResearchGroupMembershipPlanDao.java index 2160e033..c257e257 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleResearchGroupMembershipPlanDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleResearchGroupMembershipPlanDao.java @@ -37,7 +37,7 @@ public class SimpleResearchGroupMembershipPlanDao extends SimpleGenericDao getGroupMembershipPlans(ResearchGroup researchGroup) { String query = "select m from ResearchGroupMembershipPlan m where m.researchGroup = :group"; - List ret = this.getSession().createQuery(query).setParameter("group",researchGroup).list(); //set parameters + List ret = this.currentSession().createQuery(query).setParameter("group",researchGroup).list(); //set parameters return ret; } @@ -45,7 +45,7 @@ public List getGroupMembershipPlans(ResearchGroup r public boolean isPlanUsed(int membershipPlanId) { String query = "select membershipPlan from ResearchGroupMembershipPlan m where m.membershipPlan.membershipId = :plan"; - return (!this.getSession().createQuery(query).setParameter("plan",membershipPlanId).list().isEmpty()); + return (!this.currentSession().createQuery(query).setParameter("plan",membershipPlanId).list().isEmpty()); } } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleReservationDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleReservationDao.java index 07d81d3c..268e074d 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleReservationDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleReservationDao.java @@ -52,7 +52,7 @@ public int createChecked(Reservation newInstance) throws DaoException { if (newInstance.getStartTime().getTime() >= newInstance.getEndTime().getTime()) { throw new DaoException("Time of start cannot be lower than or equal to time of end!"); } - Criteria overlapCriteria = getSession().createCriteria(Reservation.class); + Criteria overlapCriteria = currentSession().createCriteria(Reservation.class); //start overlap LogicalExpression startOverlap = Restrictions.and( Restrictions.and( @@ -101,20 +101,20 @@ public List getReservationsBetween(GregorianCalendar start, Gregori } String hqlQuery = "from Reservation reservation where reservation.startTime < (:endtime) AND reservation.endTime > (:starttime)" + filterGroup + " order by reservation.startTime"; - Session session = getSession(); + Session session = currentSession(); return session.createQuery(hqlQuery).setTimestamp("starttime", start.getTime()).setTimestamp("endtime", end.getTime()).list(); } public Reservation getReservationById(int id) { String hqlQuery = "from Reservation reservation where reservation.reservationId = :id"; - Session session = getSession(); + Session session = currentSession(); List res = session.createQuery(hqlQuery).setInteger("id", id).list(); return res.size() == 1 ? (Reservation) res.get(0) : null; } public boolean deleteReservation(int id) { String hqlQuery = "delete from Reservation reservation where reservation.reservationId = :id"; - Session session = getSession(); + Session session = currentSession(); return session.createQuery(hqlQuery).setInteger("id", id).executeUpdate() == 1; } } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleScenarioDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleScenarioDao.java index f232cd93..eba821ba 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleScenarioDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleScenarioDao.java @@ -52,8 +52,7 @@ public SimpleScenarioDao() { public List getScenariosWhereOwner(Person owner) { String hqlQuery = "from Scenario s where s.person.personId = :ownerId"; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, "ownerId", owner.getPersonId()); - return list; + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("ownerId", owner.getPersonId()).list(); } public List getScenariosWhereOwner(Person person, int limit) { @@ -94,7 +93,7 @@ public List getScenarioSearchResults(List requests, int hqlQuery += ")"; try { - results = getHibernateTemplate().find(hqlQuery); + results = getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } catch (Exception e) { return new ArrayList(); } @@ -105,7 +104,7 @@ public boolean canSaveTitle(String title, int id) { String hqlQuery = "from Scenario s where s.title = :title and s.scenarioId != :id"; String[] names = {"title", "id"}; Object[] values = {title, id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = (List) getHibernateTemplate().findByNamedParam(hqlQuery, names, values); return (list.size() == 0); } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleScenarioSchemasDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleScenarioSchemasDao.java index 1f49b6a3..8168958c 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleScenarioSchemasDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleScenarioSchemasDao.java @@ -49,8 +49,8 @@ public SimpleScenarioSchemasDao() { */ @Deprecated public List getSchemaNames() { - String hqlSelect = "from ScenarioSchemas scenarioSchemas where scenarioSchemas.approved='y'"; - List list = getHibernateTemplate().find(hqlSelect); + String hqlQuery = "from ScenarioSchemas scenarioSchemas where scenarioSchemas.approved='y'"; + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); return list; } @@ -59,22 +59,22 @@ public List getSchemaNames() { */ @Deprecated public List getSchemaDescriptions() { - String hqlSelect = "from ScenarioSchemas scenarioSchemas where scenarioSchemas.approved='y'"; - List list = getHibernateTemplate().find(hqlSelect); + String hqlQuery = "from ScenarioSchemas scenarioSchemas where scenarioSchemas.approved='y'"; + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); return list; } public int getNextSchemaId() { - String hqlSelect = "select max(schema.schemaId) from ScenarioSchemas schema"; - List idList = getHibernateTemplate().find(hqlSelect); + String hqlQuery= "select max(schema.schemaId) from ScenarioSchemas schema"; + List idList = getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); int id = idList.get(0) + 1; return id; } @Override public List getListOfScenarioSchemas() { - String hqlSelect = "from ScenarioSchemas scenarioSchemas where scenarioSchemas.approved='y'"; - List list = getHibernateTemplate().find(hqlSelect); + String hqlQuery = "from ScenarioSchemas scenarioSchemas where scenarioSchemas.approved='y'"; + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); return list; } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleServiceResultDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleServiceResultDao.java index b6f5c8dd..a10bed4a 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleServiceResultDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleServiceResultDao.java @@ -44,7 +44,7 @@ public SimpleServiceResultDao() { @Override public List getResultByPerson(int personId) { String hqlQuery = "from ServiceResult s where s.owner.personId = :personId"; - return getHibernateTemplate().findByNamedParam(hqlQuery, "personId", personId); + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("personId", personId).list(); } @Override diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleSoftwareDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleSoftwareDao.java index c17782f9..0f94e3f4 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleSoftwareDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleSoftwareDao.java @@ -61,18 +61,14 @@ public List getRecordsByGroup(int groupId) { @Override public boolean canDelete(int id) { String hqlQuery = "select st.experiments from Software st where st.softwareId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @Override public boolean hasGroupRel(int id) { String hqlQuery = "from Software st where st.softwareId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return list.get(0).getResearchGroups().size() > 0; } @@ -91,7 +87,7 @@ public void createDefaultRecord(Software persistent) { @Override public List getDefaultRecords() { String hqlQuery = "from Software st where st.defaultNumber = 1"; - return getHibernateTemplate().find(hqlQuery); + return getSessionFactory().getCurrentSession().createQuery(hqlQuery).list(); } @Override diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleStimulusTypeDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleStimulusTypeDao.java index 5b2235dc..11bf7c10 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleStimulusTypeDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleStimulusTypeDao.java @@ -62,18 +62,14 @@ public List getRecordsByGroup(int groupId) { @Override public boolean canDelete(int id) { String hqlQuery = "select st.stimulusRels from StimulusType st where st.stimulusTypeId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return (list.size() == 0); } @Override public boolean hasGroupRel(int id) { String hqlQuery = "from StimulusType st where st.stimulusTypeId = :id"; - String[] names = {"id"}; - Object[] values = {id}; - List list = getHibernateTemplate().findByNamedParam(hqlQuery, names, values); + List list = getSessionFactory().getCurrentSession().createQuery(hqlQuery).setParameter("id", id).list(); return list.get(0).getResearchGroups().size() > 0; } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleTemplateDao.java b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleTemplateDao.java index e674e868..48254c30 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleTemplateDao.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/data/dao/SimpleTemplateDao.java @@ -47,9 +47,8 @@ public List