Skip to content

Commit

Permalink
Merge branch 'master' into Production
Browse files Browse the repository at this point in the history
added new annotations
  • Loading branch information
jezekp committed Aug 15, 2014
2 parents 26d4418 + cd523da commit 607f62e
Show file tree
Hide file tree
Showing 24 changed files with 1,273 additions and 13 deletions.
62 changes: 62 additions & 0 deletions README.textile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
h1. EEGBase

h2. An database portal specialized for EEG/ERP experiments

h3. "http://eegdatabase.kiv.zcu.cz":http://eegdatabase.kiv.zcu.cz

EEG Database enables community researchers to store, update, download and search data and metadata from EEG/ERP experiments. The system is developed as a standalone product; the database access is available through a web interface.

h2. Technical Overview

EEGBase as a web application uses modern web and database technologies:
* SQL and NoSQL databases
** PostgreSQL
** Elasticsearch
* Application
** Spring MVC architecture
** Hibernate JPA
** Wicket framework
* Web Server
** Jetty

h2. Getting Started
* Prerequisites
** Installed PostgreSQL v9.2 (http://www.postgresql.org/)
** Installed Jetty web server and servlet container v7.5.0 (http://www.eclipse.org/jetty/)
** Installed Java SE 6 JDK (http://www.oracle.com/technetwork/java/javase/downloads/index.html)
** Installed and "configured":https://github.com/INCF/eeg-database/wiki/Elasticsearch Elasticsearch v1.3 (http://www.elasticsearch.org/);
** Installed your favourite IDE (Eclipse, Netbeans, IntelliJ etc.) with configured GIT
* EEG Database
** Create new database in PostgreSQL (default name is "eeg"); tables will be created automatically by Hibernate framework
** Clone eegdatabase GITHub repository to local destination
** Open eegdatabase Maven project in your IDE and let the Maven to download dependencies
** Edit database accesses in @eeb-database/src/main/webapp/WEB-INF/db.properties.sample@ and save the file as @db.properties@
** Set-up run and deployment configuration
*** Select Jetty as a main deploying server
*** Edit Jetty start up options; increase permanent generation memory size @-XX:MaxPermSize=256m@
*** Set-up deployment artefacts
** Set-up Java SE 6 JDK as a default project SDK
* Frequent problems
** Ensure you have set JAVA_HOME variable in system environment variables
** Elasticsearch requires JAVA 7.
** Jetty port (8080 by default) is occupied by another service application (e.g. Apache Tomcat, Glassfish).
** db.properties file is not set properly.
** DB user has not enough privileges to the database schema.

h1. License

<pre>
This software is licensed under the Apache 2 license, quoted below.

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
</pre>
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ public Map getInfoForAccountOverview(Person loggedPerson) {

public boolean userNameInGroup(String userName, int groupId) {
String hqlQuery = "select p.personId from Person p left join p.researchGroupMemberships rgm where p.username = :userName and rgm.researchGroup.researchGroupId = :groupId";
String ownerGroupQuery = "from ResearchGroup r where r.researchGroupId = :groupId and r.person.username = :userName";
String[] paramNames = {"userName", "groupId"};
Object[] values = {userName, groupId};
List list = getHibernateTemplate().findByNamedParam(hqlQuery, paramNames, values);
return (list.size() > 0);
List ownerList = getHibernateTemplate().findByNamedParam(ownerGroupQuery, paramNames,values);
return (list.size() > 0 || ownerList.size() > 0);
}

public List<Person> getPersonSearchResults(List<SearchRequest> requests) throws NumberFormatException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
/**
* Artifact generated by hbm2java
*/
@Form
@Entity
@Table(name = "ARTEFACT")
public class Artifact implements java.io.Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
/**
* Digitization generated by hbm2java
*/
@Form
@Entity
@Table(name = "DIGITIZATION")
public class Digitization implements Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
/**
* ElectrodeConf generated by hbm2java
*/
@Form
@Entity
@Table(name = "ELECTRODE_CONF")
public class ElectrodeConf implements Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
/**
* ElectrodeSystem generated by hbm2java
*/
@Form
@Entity
@Table(name = "ELECTRODE_SYSTEM")
public class ElectrodeSystem implements Serializable {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/cz/zcu/kiv/eegdatabase/data/pojo/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
/**
* Person generated by hbm2java
*/
@Form
@Entity
@Table(name = "PERSON")
public class Person implements Serializable, Comparable<Person>, IAutoCompletable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
/**
* ResearchGroup generated by hbm2java
*/
@Form
@Entity
@Table(name = "RESEARCH_GROUP")
public class ResearchGroup implements java.io.Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
/**
* Scenario generated by hbm2java
*/
@Form
@Entity
@Table(name = "SCENARIO")
@XmlRootElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
/**
* SubjectGroup generated by hbm2java
*/
@Form
@Entity
@Table(name = "SUBJECT_GROUP")
public class SubjectGroup implements java.io.Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
/**
* Weather generated by hbm2java
*/
@Form
@Entity
@Table(name = "WEATHER")
public class Weather implements java.io.Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ public List<ResearchGroup> getUnique(ResearchGroup example) {
@Override
@Transactional
public ResearchGroupMembershipId createMemberhip(ResearchGroupMembership newInstance) {
if (newInstance.getId() == null) {
ResearchGroupMembershipId id = new ResearchGroupMembershipId(newInstance.getPerson().getPersonId(), newInstance.getResearchGroup().getResearchGroupId());
newInstance.setId(id);
}
return membershipDao.create(newInstance);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*******************************************************************************
* This file is part of the EEG-database project
*
* ==========================================
*
* Copyright (C) 2013 by University of West Bohemia (http://www.zcu.cz/en/)
*
* ***********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* ***********************************************************************************************************************
*
* ArtifactServiceTest.java, 2014/08/10 00:01 Jan Stebetak
******************************************************************************/
package cz.zcu.kiv.eegdatabase.services;

import cz.zcu.kiv.eegdatabase.data.TestUtils;
import cz.zcu.kiv.eegdatabase.data.dao.PersonDao;
import cz.zcu.kiv.eegdatabase.data.dao.ResearchGroupDao;
import cz.zcu.kiv.eegdatabase.data.pojo.Artifact;
import cz.zcu.kiv.eegdatabase.data.pojo.Person;
import cz.zcu.kiv.eegdatabase.data.pojo.ResearchGroup;
import cz.zcu.kiv.eegdatabase.logic.Util;
import cz.zcu.kiv.eegdatabase.wui.core.common.ArtifactService;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
* Created by Honza on 10.8.14.
*/
@Transactional
public class ArtifactServiceTest extends AbstractServicesTest {

@Autowired
private ArtifactService artifactService;

@Autowired
private ResearchGroupDao researchGroupDao;
@Autowired
private PersonDao personDao;
private Artifact artifact;
private ResearchGroup researchGroup;

@Before
public void setUp() throws Exception {
Person person = TestUtils.createPersonForTesting("test@test.com", Util.ROLE_ADMIN);

personDao.create(person);

researchGroup = new ResearchGroup();
researchGroup.setDescription("test-description");
researchGroup.setTitle("test-title");
researchGroup.setPerson(person);
researchGroupDao.create(researchGroup);
artifact = new Artifact();
artifact.setCompensation("test comp");
artifact.setRejectCondition("test condition");
}

@Test
public void testCreateArtifact() {
int artifactCountBefore = artifactService.getAllRecords().size();
int id = artifactService.create(artifact);
assertEquals(artifactCountBefore + 1, artifactService.getAllRecords().size());
assertEquals(id, artifact.getArtifactId());
}


@Test
public void testCreateArtifactGroupRel() {
int artifactCountBefore = artifactService.getAllRecords().size();
int artifactGroupBefore = artifactService.getRecordsByGroup(researchGroup.getResearchGroupId()).size();
int id = artifactService.create(artifact);
assertEquals(artifactCountBefore + 1, artifactService.getAllRecords().size());

List<Artifact> list = artifactService.getRecordsByGroup(researchGroup.getResearchGroupId());
assertEquals(artifactGroupBefore, list.size());
assertFalse(artifactService.hasGroupRel(id));
}

}
111 changes: 111 additions & 0 deletions src/test/java/cz/zcu/kiv/eegdatabase/services/DiseaseServiceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*******************************************************************************
* This file is part of the EEG-database project
*
* ==========================================
*
* Copyright (C) 2013 by University of West Bohemia (http://www.zcu.cz/en/)
*
* ***********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* ***********************************************************************************************************************
*
* DiseaseServiceTest.java, 2014/08/08 00:01 Jan Stebetak
******************************************************************************/
package cz.zcu.kiv.eegdatabase.services;

import cz.zcu.kiv.eegdatabase.data.TestUtils;
import cz.zcu.kiv.eegdatabase.data.dao.PersonDao;
import cz.zcu.kiv.eegdatabase.data.dao.ResearchGroupDao;
import cz.zcu.kiv.eegdatabase.data.pojo.Disease;
import cz.zcu.kiv.eegdatabase.data.pojo.Person;
import cz.zcu.kiv.eegdatabase.data.pojo.ResearchGroup;
import cz.zcu.kiv.eegdatabase.logic.Util;
import cz.zcu.kiv.eegdatabase.wui.core.common.DiseaseService;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
* Created by Honza on 8.8.14.
*/
@Transactional
public class DiseaseServiceTest extends AbstractServicesTest {

@Autowired
private DiseaseService diseaseService;

@Autowired
private ResearchGroupDao researchGroupDao;
@Autowired
private PersonDao personDao;
private Disease disease;
private ResearchGroup researchGroup;

@Before
public void setUp() throws Exception {
Person person = TestUtils.createPersonForTesting("test@test.com", Util.ROLE_ADMIN);

personDao.create(person);

researchGroup = new ResearchGroup();
researchGroup.setDescription("test-description");
researchGroup.setTitle("test-title");
researchGroup.setPerson(person);
researchGroupDao.create(researchGroup);
disease = createDisease("new Disease");
}

@Test
public void testCreateDisease() {
int diseaseCountBefore = diseaseService.getAllRecords().size();
int diseaseID = diseaseService.create(disease);
assertEquals(diseaseCountBefore + 1, diseaseService.getAllRecords().size());
assertEquals(diseaseID, disease.getDiseaseId());
}


@Test
public void testCreateDiseaseGroupRel() {
int diseaseCountBefore = diseaseService.getAllRecords().size();
int diseaseGroupBefore = diseaseService.getRecordsByGroup(researchGroup.getResearchGroupId()).size();
diseaseService.createGroupRel(disease, researchGroup);
int id = diseaseService.create(disease);
assertEquals(diseaseCountBefore + 1, diseaseService.getAllRecords().size());

List<Disease> list = diseaseService.getRecordsByGroup(researchGroup.getResearchGroupId());
assertEquals(diseaseGroupBefore + 1, list.size());
assertTrue(diseaseService.hasGroupRel(id));
}


@Test
public void testCanSaveTitle() {
diseaseService.createGroupRel(disease, researchGroup);
int id = diseaseService.create(disease);
assertTrue(diseaseService.canSaveTitle(disease.getTitle(), researchGroup.getResearchGroupId(), id));
assertFalse(diseaseService.canSaveTitle(disease.getTitle(), researchGroup.getResearchGroupId(), -1));
}

private Disease createDisease(String title) {
Disease newDisease = new Disease();
newDisease.setTitle(title);
newDisease.setDescription("This is new testing Disease");
return newDisease;
}
}
Loading

0 comments on commit 607f62e

Please sign in to comment.