Skip to content

Commit

Permalink
Merge branch 'master' into Production
Browse files Browse the repository at this point in the history
  • Loading branch information
jezekp committed Jun 18, 2014
2 parents bea8b2b + 86f5890 commit ff4bcc7
Show file tree
Hide file tree
Showing 21 changed files with 666 additions and 172 deletions.
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,14 @@
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<argLine>-Xmx1024m</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,34 +38,23 @@
*
*/
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;
}

@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();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@
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;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Timestamp;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--
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.html, 2014/06/12 00:01 Jakub Rinkes
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" xml:lang="en" lang="en">
<body>
<wicket:extend>
<div class="leftMenu" wicket:id="leftMenu"></div>

<div class="mainContentWithMenu">

<h1>
<wicket:message key="pageTitle.addDataFile"></wicket:message>
</h1>

<form class="standardInputForm" wicket:id="uploadForm">
<fieldset>
<div class="itemBox">
<label for="file"> <wicket:message key="label.dataFile"></wicket:message></label>
<span wicket:id="fileFeedback"></span>
<br />
<div wicket:id="file"></div>
</div>

<div class="itemBox">
<input type="submit" wicket:id="submit" class="submitButton lightButtonLink" />
</div>
</fieldset>
</form>
</div>
</wicket:extend>
</body>
</html>
145 changes: 145 additions & 0 deletions src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/data/AddDataFilePage.java
Original file line number Diff line number Diff line change
@@ -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<List<FileUpload>> 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<FileUpload>(new ArrayList<FileUpload>());
fileUploadField = new MultiFileUploadField("file", model);

Form<List<FileUpload>> uploadForm = new Form<List<FileUpload>>("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<FileUpload> 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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -114,7 +115,7 @@ private void setupComponents(int experimentId) {
// TODO action box pages
boolean coexperiment = security.userIsOwnerOrCoexperimenter(experimentId);
BookmarkablePageLink<Void> addParameterLink = new BookmarkablePageLink<Void>("addParameterLink", UnderConstructPage.class, PageParametersUtils.getDefaultPageParameters(experimentId));
BookmarkablePageLink<Void> addFileLink = new BookmarkablePageLink<Void>("addFileLink", UnderConstructPage.class, PageParametersUtils.getDefaultPageParameters(experimentId));
BookmarkablePageLink<Void> addFileLink = new BookmarkablePageLink<Void>("addFileLink", AddDataFilePage.class, PageParametersUtils.getDefaultPageParameters(experimentId));
BookmarkablePageLink<Void> editExpLink = new BookmarkablePageLink<Void>("editExpLink", ExperimentFormPage.class, PageParametersUtils.getDefaultPageParameters(experimentId));
BookmarkablePageLink<Void> downloadExpLink = new BookmarkablePageLink<Void>("downloadExpLink", ExperimentsDownloadPage.class, PageParametersUtils.getDefaultPageParameters(experimentId));
add(addParameterLink.setVisibilityAllowed(coexperiment), addFileLink.setVisibilityAllowed(coexperiment), editExpLink.setVisibilityAllowed(coexperiment), downloadExpLink);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends MenuPage> pageClass;
private String pageTitleKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit ff4bcc7

Please sign in to comment.