From 231dfb7372633acffafe4799c7ff66903eb32e46 Mon Sep 17 00:00:00 2001 From: stebjan Date: Thu, 5 Jun 2014 14:35:11 +0200 Subject: [PATCH 01/10] Environment for JUnit tests - Elastic search is temporarily set to ES-dev. --- src/test/resources/project.test.properties | 4 ++-- src/test/resources/test-context.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/resources/project.test.properties b/src/test/resources/project.test.properties index b828e19a..453b002b 100644 --- a/src/test/resources/project.test.properties +++ b/src/test/resources/project.test.properties @@ -33,8 +33,8 @@ hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider hibernate.connection.pool_size=10 #ES-dev: -elasticsearch.url=eeg2.kiv.zcu.cz:9300 -elasticsearch.clusterName=eegdatabase-dev +#elasticsearch.url=eeg2.kiv.zcu.cz:9300 +#elasticsearch.clusterName=eegdatabase-dev #ES-prod: #elasticsearch.url=eeg2.kiv.zcu.cz:9301 #elasticsearch.clusterName=eegdatabase-prod diff --git a/src/test/resources/test-context.xml b/src/test/resources/test-context.xml index 1cd67b01..8a98c33f 100644 --- a/src/test/resources/test-context.xml +++ b/src/test/resources/test-context.xml @@ -70,7 +70,7 @@ - + From 1fb69e5b8d9d8e51c40f4b68e3db47ca68e2e542 Mon Sep 17 00:00:00 2001 From: rinkesj Date: Thu, 5 Jun 2014 21:37:27 +0200 Subject: [PATCH 02/10] #84 fixed not working registration process for social sites. - NullPointerExceptions in SocialConnectionSignUp - DateOfBirth not null fixed in PersonServiceImpl --- .../social/OAuthCallbackController.java | 2 +- .../social/SocialConnectionSignUp.java | 28 ++++++------------- .../wui/core/person/PersonServiceImpl.java | 9 ++++++ src/main/webapp/WEB-INF/project.properties | 5 ++-- src/main/webapp/WEB-INF/socialContext.xml | 3 +- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/logic/controller/social/OAuthCallbackController.java b/src/main/java/cz/zcu/kiv/eegdatabase/logic/controller/social/OAuthCallbackController.java index ef7e3881..7f9d5003 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/logic/controller/social/OAuthCallbackController.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/logic/controller/social/OAuthCallbackController.java @@ -55,7 +55,7 @@ public class OAuthCallbackController extends MultiActionController { private Log log = LogFactory.getLog(getClass()); - + // XXX This redirect on some hello world jsp..why what is it ? I think its garbage. Remove ??? public ModelAndView oauthcallback(HttpServletRequest request, HttpServletResponse response) { ModelAndView mav = new ModelAndView("social/oauthcallback"); return mav; diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/logic/controller/social/SocialConnectionSignUp.java b/src/main/java/cz/zcu/kiv/eegdatabase/logic/controller/social/SocialConnectionSignUp.java index 5be81ab5..4ca1c8c8 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/logic/controller/social/SocialConnectionSignUp.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/logic/controller/social/SocialConnectionSignUp.java @@ -22,15 +22,14 @@ ******************************************************************************/ package cz.zcu.kiv.eegdatabase.logic.controller.social; -import cz.zcu.kiv.eegdatabase.data.pojo.Person; -import cz.zcu.kiv.eegdatabase.wui.core.person.PersonService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.social.connect.Connection; import org.springframework.social.connect.ConnectionSignUp; import org.springframework.social.connect.UserProfile; -import org.springframework.social.linkedin.api.LinkedIn; -import org.springframework.social.linkedin.api.LinkedInProfileFull; -import javax.inject.Inject; +import cz.zcu.kiv.eegdatabase.data.pojo.Person; +import cz.zcu.kiv.eegdatabase.wui.core.person.PersonService; /** * Class for signing in in via social networks. Invoked when no such @@ -39,10 +38,10 @@ * */ public final class SocialConnectionSignUp implements ConnectionSignUp { + + protected Log log = LogFactory.getLog(getClass()); private PersonService personService; - private @Inject LinkedIn linkedin; - public SocialConnectionSignUp(PersonService personService) { this.personService = personService; @@ -50,23 +49,12 @@ public SocialConnectionSignUp(PersonService personService) { @Override public String execute(Connection connection) { + UserProfile profile = connection.fetchUserProfile(); - String email = profile.getEmail(); - - if (email == null) { - LinkedIn ln = (LinkedIn) connection.getApi(); - LinkedInProfileFull full = ln.profileOperations().getUserProfileFull(); - System.out.println("xxxx " + full.getId()); - linkedin.profileOperations().getUserProfile().getId(); - - } - - SocialUser user = new SocialUser(profile.getEmail(), profile.getFirstName(), profile.getLastName()); - Person person = personService.createPerson(user, null); - + return person.getUsername(); } diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/core/person/PersonServiceImpl.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/core/person/PersonServiceImpl.java index 800e70d1..9fc36574 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/core/person/PersonServiceImpl.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/core/person/PersonServiceImpl.java @@ -33,8 +33,11 @@ import cz.zcu.kiv.eegdatabase.logic.controller.social.SocialUser; import cz.zcu.kiv.eegdatabase.logic.util.ControllerUtils; import cz.zcu.kiv.eegdatabase.wui.app.session.EEGDataBaseSession; + import org.apache.commons.logging.Log; + import cz.zcu.kiv.eegdatabase.wui.core.license.LicenseFacade; + import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @@ -42,6 +45,8 @@ import java.sql.Timestamp; import java.text.ParseException; +import java.util.Calendar; +import java.util.Date; import java.util.List; import java.util.Map; @@ -116,6 +121,10 @@ public Person createPerson(SocialUser userFb, Integer educationLevelId) { person.setGivenname(userFb.getFirstName()); person.setSurname(userFb.getLastName()); person.setGender('M'); + + Calendar cal = Calendar.getInstance(); + cal.set(1970, 1, 1); + person.setDateOfBirth(new Timestamp(cal.getTimeInMillis())); person.setLaterality(DEFAULT_LATERALITY); person.setEducationLevel(educationLevelId == null ? null : educationLevelDao.read(educationLevelId)); diff --git a/src/main/webapp/WEB-INF/project.properties b/src/main/webapp/WEB-INF/project.properties index db9fd936..cad90767 100644 --- a/src/main/webapp/WEB-INF/project.properties +++ b/src/main/webapp/WEB-INF/project.properties @@ -51,8 +51,9 @@ development=true # This url is the url which returns callback after authorization of users on social sites. # This url is same like app.domain if there isnt any problem with callback and proxies. -# If callback have to come back to app via another url or port change it. End it with slash. -app.appUrlForSocialSites=http://147.228.64.172:8080/ +# If callback have to come back to app via another url or port change it. +# !!!!!!!!!!!!!!!! Do not end it with slash. Facebook have problem with that. !!!!!!!!!!!!!!!! +app.appUrlForSocialSites=http://147.228.64.172:8080 # end url with slash for right generating url from app domain for email, etc. app.domain=http://147.228.64.172:8080/ email.smtp=smtp.zcu.cz diff --git a/src/main/webapp/WEB-INF/socialContext.xml b/src/main/webapp/WEB-INF/socialContext.xml index a14e5aed..956b6131 100644 --- a/src/main/webapp/WEB-INF/socialContext.xml +++ b/src/main/webapp/WEB-INF/socialContext.xml @@ -72,7 +72,6 @@ - @@ -102,7 +101,7 @@ providerSignInController providerSignInController - + oAuthCallbackController From 4c143df63aa78e61e77baadf0eb149464fb6dbde Mon Sep 17 00:00:00 2001 From: rinkesj Date: Mon, 9 Jun 2014 15:34:09 +0200 Subject: [PATCH 03/10] #85 fixed wrong url app settings for test server. Removed unused redirect_uri from facebook.properties. --- src/main/webapp/WEB-INF/facebook.properties | 5 +---- src/main/webapp/WEB-INF/project.properties | 11 ++++++----- src/main/webapp/WEB-INF/socialContext.xml | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/webapp/WEB-INF/facebook.properties b/src/main/webapp/WEB-INF/facebook.properties index 942aeb4e..d91d88f1 100644 --- a/src/main/webapp/WEB-INF/facebook.properties +++ b/src/main/webapp/WEB-INF/facebook.properties @@ -23,15 +23,12 @@ # *************** 1. LOCALHOST ******************** #facebook.appId = 134626213275344 #facebook.appSecret = a0e3aecb5b427c79d79bb9ac52542035 -#redirect.uri = http://localhost:8080/home-page - # *************** 2. TESTING SERVER *************** +# *************** 2. TESTING SERVER *************** facebook.appId = 218187598193669 facebook.appSecret = deef998440795611cb8f2ee635e47a0b -redirect.uri = http://147.228.64.172:8080/home-page # *************** 3. RELEASE SERVER *************** #facebook.appId = 187032288016286 #facebook.appSecret = 5cfe989052ced8e777822787c80da773 - #redirect.uri = http://eegdatabase.kiv.zcu.cz/home-page diff --git a/src/main/webapp/WEB-INF/project.properties b/src/main/webapp/WEB-INF/project.properties index cad90767..70f256ca 100644 --- a/src/main/webapp/WEB-INF/project.properties +++ b/src/main/webapp/WEB-INF/project.properties @@ -49,11 +49,12 @@ data.zip=Data # RUN APPLICATION IN DEVELOPMENT OR NOT (true/false) = show or hide exception for users. development=true -# This url is the url which returns callback after authorization of users on social sites. -# This url is same like app.domain if there isnt any problem with callback and proxies. -# If callback have to come back to app via another url or port change it. -# !!!!!!!!!!!!!!!! Do not end it with slash. Facebook have problem with that. !!!!!!!!!!!!!!!! -app.appUrlForSocialSites=http://147.228.64.172:8080 +# This URL is the URL which returns callback after authorization of users on social sites. +# This URL could be same like app.domain if there isn't any problem with callback and proxies. +# For Facebook API is this URL same like redirecet_uri in facebook application. +# !!!!!!!!!!!!!!!! Do not end it with slash. Facebook have problem with that. !!!!!!!!!!!!!!!! +app.appUrlForSocialSites=http://uu404p03-kiv.fav.zcu.cz:8080 + # end url with slash for right generating url from app domain for email, etc. app.domain=http://147.228.64.172:8080/ email.smtp=smtp.zcu.cz diff --git a/src/main/webapp/WEB-INF/socialContext.xml b/src/main/webapp/WEB-INF/socialContext.xml index 956b6131..c72807c3 100644 --- a/src/main/webapp/WEB-INF/socialContext.xml +++ b/src/main/webapp/WEB-INF/socialContext.xml @@ -85,7 +85,7 @@ - + From 9fef417b1128f74afdf7855a71eac26f2c9695f0 Mon Sep 17 00:00:00 2001 From: stebjan Date: Tue, 10 Jun 2014 11:41:31 +0200 Subject: [PATCH 04/10] Fixed access to adding scenarios. Readers have no access to it. Adding scenario schemas is temporarily removed. --- .../eegdatabase/wui/ui/scenarios/ScenariosPageLeftMenu.java | 4 ++-- .../eegdatabase/wui/ui/scenarios/form/ScenarioFormPage.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/scenarios/ScenariosPageLeftMenu.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/scenarios/ScenariosPageLeftMenu.java index 1e52dc2f..9f245b3e 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/scenarios/ScenariosPageLeftMenu.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/scenarios/ScenariosPageLeftMenu.java @@ -47,8 +47,8 @@ public enum ScenariosPageLeftMenu implements IButtonPageMenu { ListScenariosPage.MY_SCENARIOS_PARAM)), SEARCH_SCENARIOS(UnderConstructPage.class, "menuItem.searchScenario", null), - ADD_SCENARIOS(ScenarioFormPage.class, "menuItem.addScenario", null), - ADD_SCENARIOS_SCHEMA(ScenarioSchemaFormPage.class, "menuItem.addScenarioSchema", null), ; + ADD_SCENARIOS(ScenarioFormPage.class, "menuItem.addScenario", null),; + // ADD_SCENARIOS_SCHEMA(ScenarioSchemaFormPage.class, "menuItem.addScenarioSchema", null), ; private Class pageClass; private String pageTitleKey; diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/scenarios/form/ScenarioFormPage.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/scenarios/form/ScenarioFormPage.java index e78ac785..c3386892 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/scenarios/form/ScenarioFormPage.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/scenarios/form/ScenarioFormPage.java @@ -49,7 +49,7 @@ * @author Jakub Rinkes * */ -@AuthorizeInstantiation(value = { "ROLE_READER", "ROLE_USER", "ROLE_EXPERIMENTER", "ROLE_ADMIN" }) +@AuthorizeInstantiation(value = {"ROLE_USER", "ROLE_EXPERIMENTER", "ROLE_ADMIN" }) public class ScenarioFormPage extends MenuPage { private static final long serialVersionUID = -7987971485930885797L; From e45290763bbf2e555f6a178990a17b31d3d4f45b Mon Sep 17 00:00:00 2001 From: stebjan Date: Tue, 10 Jun 2014 21:12:29 +0200 Subject: [PATCH 05/10] JUnit tests refactoring --- .../eegdatabase/data/ExperimentGenerator.java | 192 ++++++++++++++++++ .../zcu/kiv/eegdatabase/data/TestUtils.java | 27 +++ .../data/dao/ExperimentDaoTest.java | 139 +------------ src/test/resources/test-context.xml | 2 + 4 files changed, 229 insertions(+), 131 deletions(-) create mode 100644 src/test/java/cz/zcu/kiv/eegdatabase/data/ExperimentGenerator.java diff --git a/src/test/java/cz/zcu/kiv/eegdatabase/data/ExperimentGenerator.java b/src/test/java/cz/zcu/kiv/eegdatabase/data/ExperimentGenerator.java new file mode 100644 index 00000000..835f2f86 --- /dev/null +++ b/src/test/java/cz/zcu/kiv/eegdatabase/data/ExperimentGenerator.java @@ -0,0 +1,192 @@ +/** + * ***************************************************************************** + * 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. + * + * *********************************************************************************************************************** + * + * ExperimentGenerator.java, 2014/06/10 00:01 Jan Stebetak + ***************************************************************************** + */ +package cz.zcu.kiv.eegdatabase.data; + +import cz.zcu.kiv.eegdatabase.data.dao.*; +import cz.zcu.kiv.eegdatabase.data.pojo.*; +import cz.zcu.kiv.eegdatabase.logic.Util; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.test.context.ContextConfiguration; + +import java.sql.Timestamp; +import java.util.Date; +import java.util.List; + +/** + * Created by Honza on 10.6.14. + */ +@ContextConfiguration(locations = {"classpath:/test-context.xml"}) +public class ExperimentGenerator { + + @Autowired + private PersonDao personDao; + @Autowired + private DigitizationDao digitizationDao; + + @Autowired + private ResearchGroupDao groupDao; + @Autowired + private HardwareDao hardwareDao; + @Autowired + private SimpleSoftwareDao softwareDao; + @Autowired + private WeatherDao weatherDao; + + @Autowired + private SimpleArtifactDao artifactDao; + + @Autowired + private ScenarioDao scenarioDao; + + @Autowired + @Qualifier("electrodeConfDao") + private GenericDao electrodeConfDao; + + @Autowired + @Qualifier("subjectGroupDao") + private GenericDao subjectGroupDao; + + private Person person; + private ResearchGroup group; + private Hardware hw; + private Software sw; + private Weather weather; + private Scenario scenario; + private Digitization digitization; + + public Experiment generateExperiment(Person person) { + this.person = person; + group = createGroup(); + hw = createHardware(); + sw = createSoftware(); + weather = createWeather(); + scenario = createScenario(); + + digitization = new Digitization(); + digitization.setFilter("testFilter"); + digitization.setGain(1f); + digitization.setSamplingRate(1000f); + digitizationDao.create(digitization); + return setUpExperiment(); + + } + + private ResearchGroup createGroup() { + ResearchGroup group = new ResearchGroup(); + group.setTitle("testTitle"); + group.setDescription("testDesc"); + group.setPerson(person); + groupDao.create(group); + return group; + } + private Hardware createHardware() { + Hardware hardware = new Hardware(); + hardware.setTitle("testTitle"); + hardware.setDescription("testDesc"); + hardware.setType("testType"); + hardwareDao.create(hardware); + return hardware; + } + + private Software createSoftware() { + Software software = new Software(); + software.setDescription("testDesc"); + software.setTitle("testTitleSW"); + softwareDao.create(software); + return software; + } + + private Weather createWeather() { + Weather weather = new Weather(); + weather.setTitle("testTitleWeather"); + weather.setDescription("testDesc"); + weatherDao.create(weather); + return weather; + } + + + private Scenario createScenario() { + + List list = scenarioDao.readByParameter("title", "testTitle"); + if (list.size() > 0) { + return list.get(0); + } + Scenario scenario = new Scenario(); + scenario.setDescription("testDesc"); + scenario.setTitle("testTitle"); + scenario.setScenarioLength(10); + scenario.setPerson(person); + scenario.setResearchGroup(group); + scenarioDao.create(scenario); + return scenario; + } + + private Experiment setUpExperiment() { + Experiment exp = new Experiment(); + exp.setScenario(scenario); + exp.setPersonByOwnerId(person); + exp.setResearchGroup(group); + exp.getHardwares().add(hw); + exp.getSoftwares().add(sw); + exp.setPersonBySubjectPersonId(person); + exp.setWeather(weather); + exp.setStartDate(new Date(10)); + exp.setStartTime(new Timestamp(11)); + exp.setEndTime(new Timestamp(13)); + exp.setFinishDate(new Date(12)); + exp.setDigitization(digitization); + exp.setArtifact(createArtifact()); + exp.setElectrodeConf(createElectrodeConf()); + exp.setSubjectGroup(createSubjectGroup()); + return exp; + } + + private SubjectGroup createSubjectGroup() { + SubjectGroup subjectGroup = new SubjectGroup(); + subjectGroup.setTitle("test-title"); + subjectGroup.setDescription("desc"); + subjectGroupDao.create(subjectGroup); + return subjectGroup; + } + + private ElectrodeConf createElectrodeConf() { + ElectrodeConf conf = new ElectrodeConf(); + conf.setImpedance(10); + electrodeConfDao.create(conf); + return conf; + } + + private Artifact createArtifact() { + Artifact artifact = new Artifact(); + artifact.setCompensation("test-comp"); + artifact.setRejectCondition("test-rej"); + artifactDao.create(artifact); + return artifact; + } +} diff --git a/src/test/java/cz/zcu/kiv/eegdatabase/data/TestUtils.java b/src/test/java/cz/zcu/kiv/eegdatabase/data/TestUtils.java index 08bba5e8..5857dd55 100644 --- a/src/test/java/cz/zcu/kiv/eegdatabase/data/TestUtils.java +++ b/src/test/java/cz/zcu/kiv/eegdatabase/data/TestUtils.java @@ -1,3 +1,30 @@ +/** + * ***************************************************************************** + * 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. + * + * *********************************************************************************************************************** + * + * TestUtils.java, 2014/04/31 00:01 Jan Stebetak + ***************************************************************************** + */ package cz.zcu.kiv.eegdatabase.data; import cz.zcu.kiv.eegdatabase.data.pojo.Person; diff --git a/src/test/java/cz/zcu/kiv/eegdatabase/data/dao/ExperimentDaoTest.java b/src/test/java/cz/zcu/kiv/eegdatabase/data/dao/ExperimentDaoTest.java index e8a6aab7..fd28c795 100644 --- a/src/test/java/cz/zcu/kiv/eegdatabase/data/dao/ExperimentDaoTest.java +++ b/src/test/java/cz/zcu/kiv/eegdatabase/data/dao/ExperimentDaoTest.java @@ -22,12 +22,13 @@ * * *********************************************************************************************************************** * - * ScenariosServiceImpl.java, 2014/04/31 00:01 Jan Stebetak + * ExperimentDaoTest.java, 2014/04/31 00:01 Jan Stebetak ***************************************************************************** */ package cz.zcu.kiv.eegdatabase.data.dao; import cz.zcu.kiv.eegdatabase.data.AbstractDataAccessTest; +import cz.zcu.kiv.eegdatabase.data.ExperimentGenerator; import cz.zcu.kiv.eegdatabase.data.TestUtils; import cz.zcu.kiv.eegdatabase.data.pojo.*; import cz.zcu.kiv.eegdatabase.logic.Util; @@ -52,58 +53,21 @@ public class ExperimentDaoTest extends AbstractDataAccessTest { @Autowired private PersonDao personDao; - @Autowired - private DigitizationDao digitizationDao; - @Autowired - private ExperimentDao experimentDao; - - @Autowired - private ResearchGroupDao groupDao; - @Autowired - private HardwareDao hardwareDao; - @Autowired - private SimpleSoftwareDao softwareDao; - @Autowired - private WeatherDao weatherDao; @Autowired - private SimpleArtifactDao artifactDao; - - @Autowired - private ScenarioDao scenarioDao; - - @Autowired - @Qualifier("electrodeConfDao") - private GenericDao electrodeConfDao; + private ExperimentDao experimentDao; @Autowired - @Qualifier("subjectGroupDao") - private GenericDao subjectGroupDao; + private ExperimentGenerator experimentGenerator; private Person person; - private ResearchGroup group; - private Hardware hw; - private Software sw; - private Weather weather; - private Scenario scenario; - private Digitization digitization; private Experiment experiment; @Before public void setUp() { - person = createPerson(); - group = createGroup(); - hw = createHardware(); - sw = createSoftware(); - weather = createWeather(); - scenario = createScenario(); - digitization = new Digitization(); - digitization.setFilter("testFilter"); - digitization.setGain(1f); - digitization.setSamplingRate(1000f); - digitizationDao.create(digitization); - experiment = setUpExperiment(); + person = createPerson(); + experiment = experimentGenerator.generateExperiment(person); } @@ -124,7 +88,7 @@ public void testGetCountExperimentsWhereOwner() { experimentDao.create(experiment); Person person1 = TestUtils.createPersonForTesting("test2@test.com", Util.ROLE_READER); personDao.create(person1); - Experiment exp = setUpExperiment(); + Experiment exp = experimentGenerator.generateExperiment(person); exp.setPersonByOwnerId(person1); experimentDao.create(exp); assertEquals(count + 1, experimentDao.getCountForExperimentsWhereOwner(person)); @@ -139,7 +103,7 @@ public void testGetCountExperimentsWhereSubject() { experimentDao.create(experiment); Person person1 = TestUtils.createPersonForTesting("test2@test.com", Util.ROLE_READER); personDao.create(person1); - Experiment exp = setUpExperiment(); + Experiment exp = experimentGenerator.generateExperiment(person); exp.setPersonBySubjectPersonId(person1); experimentDao.create(exp); assertEquals(countForOwner + 2, experimentDao.getCountForExperimentsWhereOwner(person)); @@ -171,7 +135,6 @@ public void clean() { personDao.delete(person); } } - private Person createPerson() { Person person = TestUtils.createPersonForTesting("test@test.com", Util.ROLE_READER); personDao.create(person); @@ -179,91 +142,5 @@ private Person createPerson() { return person; } - private ResearchGroup createGroup() { - ResearchGroup group = new ResearchGroup(); - group.setTitle("testTitle"); - group.setDescription("testDesc"); - group.setPerson(person); - groupDao.create(group); - return group; - } - private Hardware createHardware() { - Hardware hardware = new Hardware(); - hardware.setTitle("testTitle"); - hardware.setDescription("testDesc"); - hardware.setType("testType"); - hardwareDao.create(hardware); - return hardware; - } - - private Software createSoftware() { - Software software = new Software(); - software.setDescription("testDesc"); - software.setTitle("testTitleSW"); - softwareDao.create(software); - return software; - } - - private Weather createWeather() { - Weather weather = new Weather(); - weather.setTitle("testTitleWeather"); - weather.setDescription("testDesc"); - weatherDao.create(weather); - return weather; - } - - - private Scenario createScenario() { - Scenario scenario = new Scenario(); - scenario.setDescription("testDesc"); - scenario.setTitle("testTitle"); - scenario.setScenarioLength(10); - scenario.setPerson(person); - scenario.setResearchGroup(group); - scenarioDao.create(scenario); - return scenario; - } - - private Experiment setUpExperiment() { - Experiment exp = new Experiment(); - exp.setScenario(scenario); - exp.setPersonByOwnerId(person); - exp.setResearchGroup(group); - exp.getHardwares().add(hw); - exp.getSoftwares().add(sw); - exp.setPersonBySubjectPersonId(person); - exp.setWeather(weather); - exp.setStartDate(new Date(10)); - exp.setStartTime(new Timestamp(11)); - exp.setEndTime(new Timestamp(13)); - exp.setFinishDate(new Date(12)); - exp.setDigitization(digitization); - exp.setArtifact(createArtifact()); - exp.setElectrodeConf(createElectrodeConf()); - exp.setSubjectGroup(createSubjectGroup()); - return exp; - } - - private SubjectGroup createSubjectGroup() { - SubjectGroup subjectGroup = new SubjectGroup(); - subjectGroup.setTitle("test-title"); - subjectGroup.setDescription("desc"); - subjectGroupDao.create(subjectGroup); - return subjectGroup; - } - - private ElectrodeConf createElectrodeConf() { - ElectrodeConf conf = new ElectrodeConf(); - conf.setImpedance(10); - electrodeConfDao.create(conf); - return conf; - } - private Artifact createArtifact() { - Artifact artifact = new Artifact(); - artifact.setCompensation("test-comp"); - artifact.setRejectCondition("test-rej"); - artifactDao.create(artifact); - return artifact; - } } diff --git a/src/test/resources/test-context.xml b/src/test/resources/test-context.xml index 8a98c33f..feb8e8c9 100644 --- a/src/test/resources/test-context.xml +++ b/src/test/resources/test-context.xml @@ -418,6 +418,8 @@ + + From 6040553ef092bba0f04ad622a0f6e39139f30aa7 Mon Sep 17 00:00:00 2001 From: stebjan Date: Tue, 10 Jun 2014 22:47:43 +0200 Subject: [PATCH 06/10] First large data storing test. --- .../data/performance/LargeDataTest.java | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 src/test/java/cz/zcu/kiv/eegdatabase/data/performance/LargeDataTest.java diff --git a/src/test/java/cz/zcu/kiv/eegdatabase/data/performance/LargeDataTest.java b/src/test/java/cz/zcu/kiv/eegdatabase/data/performance/LargeDataTest.java new file mode 100644 index 00000000..84c74d93 --- /dev/null +++ b/src/test/java/cz/zcu/kiv/eegdatabase/data/performance/LargeDataTest.java @@ -0,0 +1,160 @@ +/** + * ***************************************************************************** + * 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. + * + * *********************************************************************************************************************** + * + * LargeDataTest.java, 2014/06/10 20:01 Jan Stebetak + ***************************************************************************** + */ +package cz.zcu.kiv.eegdatabase.data.performance; + +import cz.zcu.kiv.eegdatabase.data.AbstractDataAccessTest; +import cz.zcu.kiv.eegdatabase.data.ExperimentGenerator; +import cz.zcu.kiv.eegdatabase.data.TestUtils; +import cz.zcu.kiv.eegdatabase.data.dao.DataFileDao; +import cz.zcu.kiv.eegdatabase.data.dao.ExperimentDao; +import cz.zcu.kiv.eegdatabase.data.dao.PersonDao; +import cz.zcu.kiv.eegdatabase.data.pojo.DataFile; +import cz.zcu.kiv.eegdatabase.data.pojo.Experiment; +import cz.zcu.kiv.eegdatabase.data.pojo.Person; +import cz.zcu.kiv.eegdatabase.logic.Util; +import org.hibernate.SessionFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import java.io.*; +import java.sql.Blob; +import java.util.Arrays; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +/** + * Created by Honza on 10.6.14. + */ +public class LargeDataTest extends AbstractDataAccessTest { + + @Autowired + private ExperimentDao experimentDao; + + @Autowired + private DataFileDao dataFileDao; + + @Autowired + private PersonDao personDao; + + @Autowired + private ExperimentGenerator experimentGenerator; + + @Autowired + private SessionFactory factory; + + + private File tmpFile; + private Experiment experiment; + private DataFile dataFile; + + private final int KB = 1024; + private final int MEGABYTES = 300; + private final int KB_IN_MB = 1024; + private long startTime; + + + @Before + public void setUp() { + + try { + createFile(); + experiment = experimentGenerator.generateExperiment(createPerson()); + experimentDao.create(experiment); + } catch (IOException e) { + tmpFile = null; + } + + } + + @Test + @Transactional + public void SaveDataTest() { + if (tmpFile == null) { + fail("Data file is null"); + return; + } + int count = dataFileDao.getCountRecords(); + startTime = System.currentTimeMillis(); + System.out.println(tmpFile.length()); + System.out.println(tmpFile.getAbsolutePath()); + dataFile = new DataFile(); + dataFile.setDescription("testDesc"); + dataFile.setFilename(tmpFile.getName()); + dataFile.setMimetype("temp"); + dataFile.setExperiment(experiment); + InputStream ios; + try { + ios = new FileInputStream(tmpFile); + dataFile.setFileContentStream(ios); + Blob createBlob = factory.getCurrentSession().getLobHelper().createBlob(dataFile.getFileContentStream(), dataFile.getFileContentStream().available()); + dataFile.setFileContent(createBlob); + + dataFileDao.create(dataFile); + assertEquals(count + 1, dataFileDao.getCountRecords()); + + } catch (IOException e) { + fail("Unreadable data file"); + } finally { + tmpFile.delete(); + + } + } + + @After + public void stopTime() { + System.out.println(("Data File was stored in " + (System.currentTimeMillis() - startTime) / 1000) + " seconds"); + } + private void createFile() throws IOException { + if ((tmpFile == null) || (!tmpFile.exists())) { + FileOutputStream fos = null; + try { + tmpFile = File.createTempFile("tmpDataFile", null); + fos = new FileOutputStream(tmpFile); + byte[] buffer = new byte[KB]; + Arrays.fill(buffer, (byte) 0x0C); + for (int i = 0; i < MEGABYTES * KB_IN_MB; i++) { + fos.write(buffer); + } + } catch (IOException e) { + tmpFile = null; + } finally { + if (fos != null) fos.close(); + } + } + } + private Person createPerson() { + Person person = TestUtils.createPersonForTesting("test@test.com", Util.ROLE_READER); + personDao.create(person); + + return person; + } +} From f810775727bc6212e044cd6d409759218fb79f22 Mon Sep 17 00:00:00 2001 From: stebjan Date: Wed, 11 Jun 2014 14:50:23 +0200 Subject: [PATCH 07/10] Maven Surefire Plugin for JUnit testing added. Memory is set to 1024MB. Added test case including storing data files repeatedly. --- pom.xml | 8 +++ .../data/performance/LargeDataTest.java | 60 ++++++++++++++----- 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index d9d0a895..2752b8da 100644 --- a/pom.xml +++ b/pom.xml @@ -786,6 +786,14 @@ ${project.build.sourceEncoding} + + org.apache.maven.plugins + maven-surefire-plugin + 2.17 + + -Xmx1024m + + org.mortbay.jetty jetty-maven-plugin diff --git a/src/test/java/cz/zcu/kiv/eegdatabase/data/performance/LargeDataTest.java b/src/test/java/cz/zcu/kiv/eegdatabase/data/performance/LargeDataTest.java index 84c74d93..1a828e80 100644 --- a/src/test/java/cz/zcu/kiv/eegdatabase/data/performance/LargeDataTest.java +++ b/src/test/java/cz/zcu/kiv/eegdatabase/data/performance/LargeDataTest.java @@ -48,7 +48,7 @@ import java.sql.Blob; import java.util.Arrays; -import static org.junit.Assert.assertEquals; +import static junit.framework.Assert.assertEquals; import static org.junit.Assert.fail; /** @@ -71,34 +71,30 @@ public class LargeDataTest extends AbstractDataAccessTest { @Autowired private SessionFactory factory; - private File tmpFile; private Experiment experiment; private DataFile dataFile; private final int KB = 1024; - private final int MEGABYTES = 300; private final int KB_IN_MB = 1024; private long startTime; @Before public void setUp() { - - try { - createFile(); + if (experiment == null) { experiment = experimentGenerator.generateExperiment(createPerson()); experimentDao.create(experiment); - } catch (IOException e) { - tmpFile = null; } } @Test @Transactional - public void SaveDataTest() { - if (tmpFile == null) { + public void saveDataTest() throws IOException { + try { + createFile(100); + } catch (IOException e) { fail("Data file is null"); return; } @@ -111,7 +107,7 @@ public void SaveDataTest() { dataFile.setFilename(tmpFile.getName()); dataFile.setMimetype("temp"); dataFile.setExperiment(experiment); - InputStream ios; + InputStream ios = null; try { ios = new FileInputStream(tmpFile); dataFile.setFileContentStream(ios); @@ -124,16 +120,52 @@ public void SaveDataTest() { } catch (IOException e) { fail("Unreadable data file"); } finally { - tmpFile.delete(); + if (ios != null) ios.close(); + + } + } + + @Transactional + @Test + public void saveDataRepeatTest() throws IOException { + int count = dataFileDao.getCountRecords(); + int repeatLimit = 10; + startTime = System.currentTimeMillis(); + InputStream ios = null; + try { + createFile(30); + + } catch (IOException e) { + fail("Data file is null"); + return; + } + for (int i = 0; i < repeatLimit; i++) { + dataFile = new DataFile(); + dataFile.setDescription("testDesc"); + dataFile.setFilename(tmpFile.getName() + "" + i); + dataFile.setMimetype("temp"); + dataFile.setExperiment(experiment); + + try { + ios = new FileInputStream(tmpFile); + dataFile.setFileContentStream(ios); + Blob createBlob = factory.getCurrentSession().getLobHelper().createBlob(dataFile.getFileContentStream(), dataFile.getFileContentStream().available()); + dataFile.setFileContent(createBlob); + dataFileDao.create(dataFile); + } catch (IOException e) { + fail("Unreadable data file"); + } } + assertEquals(count + repeatLimit, dataFileDao.getCountRecords()); } @After public void stopTime() { System.out.println(("Data File was stored in " + (System.currentTimeMillis() - startTime) / 1000) + " seconds"); + tmpFile.delete(); } - private void createFile() throws IOException { + private void createFile(int megabytes) throws IOException { if ((tmpFile == null) || (!tmpFile.exists())) { FileOutputStream fos = null; try { @@ -141,7 +173,7 @@ private void createFile() throws IOException { fos = new FileOutputStream(tmpFile); byte[] buffer = new byte[KB]; Arrays.fill(buffer, (byte) 0x0C); - for (int i = 0; i < MEGABYTES * KB_IN_MB; i++) { + for (int i = 0; i < megabytes * KB_IN_MB; i++) { fos.write(buffer); } } catch (IOException e) { From fd1f58b5deac0f792d6c7cd41814e6751b7f1da2 Mon Sep 17 00:00:00 2001 From: rinkesj Date: Thu, 12 Jun 2014 10:48:51 +0200 Subject: [PATCH 08/10] Fixed facebook login for test : back old settings for portal and changed settings in facebook application. --- src/main/webapp/WEB-INF/project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/WEB-INF/project.properties b/src/main/webapp/WEB-INF/project.properties index 70f256ca..faf07016 100644 --- a/src/main/webapp/WEB-INF/project.properties +++ b/src/main/webapp/WEB-INF/project.properties @@ -53,7 +53,7 @@ development=true # This URL could be same like app.domain if there isn't any problem with callback and proxies. # For Facebook API is this URL same like redirecet_uri in facebook application. # !!!!!!!!!!!!!!!! Do not end it with slash. Facebook have problem with that. !!!!!!!!!!!!!!!! -app.appUrlForSocialSites=http://uu404p03-kiv.fav.zcu.cz:8080 +app.appUrlForSocialSites=http://147.228.64.172:8080 # end url with slash for right generating url from app domain for email, etc. app.domain=http://147.228.64.172:8080/ From f0d8333459a3a370f9840479efeca5d03c98a21e Mon Sep 17 00:00:00 2001 From: rinkesj Date: Thu, 12 Jun 2014 19:26:01 +0200 Subject: [PATCH 09/10] #87 implemented missing page for adding file(s) to experiment. --- .../wui/app/EEGDataBaseApplication.java | 3 +- .../wui/ui/data/AddDataFilePage.html | 52 +++++++ .../wui/ui/data/AddDataFilePage.java | 145 ++++++++++++++++++ .../ui/experiments/ExperimentsDetailPage.java | 3 +- .../wui/app/EEGDataBaseApplication.properties | 1 + 5 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/data/AddDataFilePage.html create mode 100644 src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/data/AddDataFilePage.java diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/app/EEGDataBaseApplication.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/app/EEGDataBaseApplication.java index b5f6d35a..90c5891c 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/app/EEGDataBaseApplication.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/app/EEGDataBaseApplication.java @@ -32,7 +32,6 @@ import org.apache.wicket.authroles.authorization.strategies.role.annotations.AnnotationsRoleAuthorizationStrategy; import org.apache.wicket.core.request.mapper.CryptoMapper; import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.request.Request; import org.apache.wicket.request.Response; import org.apache.wicket.settings.IExceptionSettings; @@ -77,6 +76,7 @@ import cz.zcu.kiv.eegdatabase.wui.ui.articles.ArticlesPage; import cz.zcu.kiv.eegdatabase.wui.ui.articles.ArticlesSettingsPage; import cz.zcu.kiv.eegdatabase.wui.ui.articles.ViewArticlePage; +import cz.zcu.kiv.eegdatabase.wui.ui.data.AddDataFilePage; import cz.zcu.kiv.eegdatabase.wui.ui.data.DataFileDetailPage; import cz.zcu.kiv.eegdatabase.wui.ui.experiments.ExperimentFormPage; import cz.zcu.kiv.eegdatabase.wui.ui.experiments.ExperimentsDetailPage; @@ -252,6 +252,7 @@ private void mountPages() { mountPage("experiments-detail", ExperimentsDetailPage.class); mountPage("experiments-form", ExperimentFormPage.class); mountPage("experiments-download", ExperimentsDownloadPage.class); + mountPage("experiments-add-file", AddDataFilePage.class); mountPage("file-detail", DataFileDetailPage.class); mountPage("groups-list", ListResearchGroupsPage.class); diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/data/AddDataFilePage.html b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/data/AddDataFilePage.html new file mode 100644 index 00000000..46dbec79 --- /dev/null +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/data/AddDataFilePage.html @@ -0,0 +1,52 @@ + + + + + +
+ +
+ +

+ +

+ +
+
+
+ + +
+
+
+ +
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/data/AddDataFilePage.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/data/AddDataFilePage.java new file mode 100644 index 00000000..d5577f58 --- /dev/null +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/data/AddDataFilePage.java @@ -0,0 +1,145 @@ +/******************************************************************************* + * 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. + * + * *********************************************************************************************************************** + * + * AddDataFilePage.java, 2014/06/12 00:01 Jakub Rinkes + ******************************************************************************/ +package cz.zcu.kiv.eegdatabase.wui.ui.data; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.wicket.RestartResponseAtInterceptPageException; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.form.AjaxButton; +import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation; +import org.apache.wicket.feedback.ComponentFeedbackMessageFilter; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.MultiFileUploadField; +import org.apache.wicket.markup.html.panel.FeedbackPanel; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.util.ListModel; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.spring.injection.annot.SpringBean; +import org.apache.wicket.util.string.StringValue; + +import cz.zcu.kiv.eegdatabase.data.pojo.DataFile; +import cz.zcu.kiv.eegdatabase.data.pojo.Experiment; +import cz.zcu.kiv.eegdatabase.wui.components.menu.button.ButtonPageMenu; +import cz.zcu.kiv.eegdatabase.wui.components.page.MenuPage; +import cz.zcu.kiv.eegdatabase.wui.components.utils.PageParametersUtils; +import cz.zcu.kiv.eegdatabase.wui.components.utils.ResourceUtils; +import cz.zcu.kiv.eegdatabase.wui.core.experiments.ExperimentsFacade; +import cz.zcu.kiv.eegdatabase.wui.core.file.FileFacade; +import cz.zcu.kiv.eegdatabase.wui.ui.experiments.ExperimentsDetailPage; +import cz.zcu.kiv.eegdatabase.wui.ui.experiments.ExperimentsPageLeftMenu; +import cz.zcu.kiv.eegdatabase.wui.ui.experiments.ListExperimentsPage; + +@AuthorizeInstantiation(value = { "ROLE_USER", "ROLE_EXPERIMENTER", "ROLE_ADMIN" }) +public class AddDataFilePage extends MenuPage { + + private static final long serialVersionUID = -1065232841030454856L; + protected Log log = LogFactory.getLog(getClass()); + + @SpringBean + private ExperimentsFacade facade; + + @SpringBean + private FileFacade fileFacade; + + private MultiFileUploadField fileUploadField; + private IModel> model; + + public AddDataFilePage(PageParameters parameters) { + + StringValue stringValue = parameters.get(DEFAULT_PARAM_ID); + if (stringValue.isNull() || stringValue.isEmpty()) { + throw new RestartResponseAtInterceptPageException(ListExperimentsPage.class); + } + + int experimentId = stringValue.toInt(); + + setPageTitle(ResourceUtils.getModel("pageTitle.addDataFile")); + add(new ButtonPageMenu("leftMenu", ExperimentsPageLeftMenu.values())); + + setupComponents(experimentId); + } + + private void setupComponents(final int experimentId) { + + final Experiment experiment = facade.read(experimentId); + model = new ListModel(new ArrayList()); + fileUploadField = new MultiFileUploadField("file", model); + + Form> uploadForm = new Form>("uploadForm"); + + ComponentFeedbackMessageFilter fileFilter = new ComponentFeedbackMessageFilter(fileUploadField); + final FeedbackPanel fileFeedback = new FeedbackPanel("fileFeedback", fileFilter); + fileFeedback.setOutputMarkupId(true); + + uploadForm.add(fileUploadField); + uploadForm.add(fileFeedback); + + AjaxButton submit = new AjaxButton("submit", ResourceUtils.getModel("button.addDataFile")) { + + private static final long serialVersionUID = 1L; + + @Override + protected void onError(AjaxRequestTarget target, Form form) { + target.add(fileFeedback); + target.add(getFeedback()); + } + + @Override + protected void onSubmit(AjaxRequestTarget target, Form form) { + + try { + + List fileUploadList = model.getObject(); + if (!fileUploadList.isEmpty()) { + for (FileUpload fileUpload : fileUploadList) { + + DataFile file = new DataFile(); + file.setMimetype(fileUpload.getContentType()); + file.setFilename(fileUpload.getClientFileName()); + file.setFileContentStream(fileUpload.getInputStream()); + file.setExperiment(experiment); + fileFacade.create(file); + } + } + + setResponsePage(ExperimentsDetailPage.class, + PageParametersUtils.getDefaultPageParameters(experimentId)); + } + catch (Exception ex) { + error(ResourceUtils.getString("error.file.add.error")); + log.error(ex.getMessage(), ex); + target.add(getFeedback()); + target.add(fileFeedback); + } + } + }; + uploadForm.add(submit); + add(uploadForm); + } + +} diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/ExperimentsDetailPage.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/ExperimentsDetailPage.java index 3e376fff..50c46933 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/ExperimentsDetailPage.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/ExperimentsDetailPage.java @@ -55,6 +55,7 @@ import cz.zcu.kiv.eegdatabase.wui.core.Gender; import cz.zcu.kiv.eegdatabase.wui.core.experiments.ExperimentsFacade; import cz.zcu.kiv.eegdatabase.wui.core.security.SecurityFacade; +import cz.zcu.kiv.eegdatabase.wui.ui.data.AddDataFilePage; import cz.zcu.kiv.eegdatabase.wui.ui.data.DataFileDetailPage; import cz.zcu.kiv.eegdatabase.wui.ui.experiments.canvas.ExperimentSignalViewCanvasPanel; import cz.zcu.kiv.eegdatabase.wui.ui.people.PersonDetailPage; @@ -114,7 +115,7 @@ private void setupComponents(int experimentId) { // TODO action box pages boolean coexperiment = security.userIsOwnerOrCoexperimenter(experimentId); BookmarkablePageLink addParameterLink = new BookmarkablePageLink("addParameterLink", UnderConstructPage.class, PageParametersUtils.getDefaultPageParameters(experimentId)); - BookmarkablePageLink addFileLink = new BookmarkablePageLink("addFileLink", UnderConstructPage.class, PageParametersUtils.getDefaultPageParameters(experimentId)); + BookmarkablePageLink addFileLink = new BookmarkablePageLink("addFileLink", AddDataFilePage.class, PageParametersUtils.getDefaultPageParameters(experimentId)); BookmarkablePageLink editExpLink = new BookmarkablePageLink("editExpLink", ExperimentFormPage.class, PageParametersUtils.getDefaultPageParameters(experimentId)); BookmarkablePageLink downloadExpLink = new BookmarkablePageLink("downloadExpLink", ExperimentsDownloadPage.class, PageParametersUtils.getDefaultPageParameters(experimentId)); add(addParameterLink.setVisibilityAllowed(coexperiment), addFileLink.setVisibilityAllowed(coexperiment), editExpLink.setVisibilityAllowed(coexperiment), downloadExpLink); diff --git a/src/main/resources/cz/zcu/kiv/eegdatabase/wui/app/EEGDataBaseApplication.properties b/src/main/resources/cz/zcu/kiv/eegdatabase/wui/app/EEGDataBaseApplication.properties index 71956db4..357ed19f 100644 --- a/src/main/resources/cz/zcu/kiv/eegdatabase/wui/app/EEGDataBaseApplication.properties +++ b/src/main/resources/cz/zcu/kiv/eegdatabase/wui/app/EEGDataBaseApplication.properties @@ -1004,6 +1004,7 @@ error.mustBeOwnerOfExperimentOrCoexperimenter=You must be owner of the experimen required.userRole=User role is required. error.valueAlreadyInDatabase=Value already in database. error.titleAlreadyInDatabase=Title already in database. +error.file.add.error=File saving failed. Error will be reported. ##enum values LicenseType.ACADEMIC=Academic From 86f5890153b84eb46818823a93a866eaf4688ab9 Mon Sep 17 00:00:00 2001 From: rinkesj Date: Wed, 18 Jun 2014 14:07:21 +0200 Subject: [PATCH 10/10] fixed : hided license header panel on list of experiment for next release. Some NPE error. --- .../wui/ui/experiments/components/ExperimentPackagePanel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/components/ExperimentPackagePanel.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/components/ExperimentPackagePanel.java index dd934015..ded0e579 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/components/ExperimentPackagePanel.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/components/ExperimentPackagePanel.java @@ -223,8 +223,9 @@ protected void onConfigure() { cont.add(ddc); cont.add(licenseBuyLink); - + // XXX HIDE LICENSE DROP DOWN CHOICE FOR NOW. FIX EXCEPTION !!! + cont.setVisibilityAllowed(false); }