Permalink
Browse files

- registration double click issue fix, made it more robust but less p…

…erforming due locking

- better link to login/register after playing anonymous
- fixed score issue in recap summary (matches with others)
- fixed tag overview in recap not showing geo/person matches
- made social links configurable
- removed debugger; line in javascript
- added gtaa dictionary insert script
- cosmetics
- [NEED TO RE-BRANCH to europeana-0.0.2-SNAPSHOT]
  • Loading branch information...
sdengineering77 committed Mar 26, 2013
1 parent 9694c23 commit 7e94718cc1ef5e5416e4740060da80fb28bb0d1c
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
- <wb-module deploy-name="manbijthond">
+ <wb-module deploy-name="waisda">
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
- <property name="java-output-path" value="/manbijthond/target/classes"/>
- <property name="context-root" value="manbijthond-web"/>
+ <property name="java-output-path" value="/waisda/target/classes"/>
+ <property name="context-root" value="waisda-web"/>
</wb-module>
</project-modules>
View
@@ -9,11 +9,6 @@
<webroots>
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
</webroots>
- <sourceRoots>
- <root url="file://$MODULE_DIR$/src/main/java" />
- <root url="file://$MODULE_DIR$/src/main/resources" />
- <root url="file://$MODULE_DIR$/target/generated-sources/annotations" />
- </sourceRoots>
</configuration>
</facet>
<facet type="jpa" name="JPA">
@@ -46,6 +41,7 @@
<excludeFolder url="file://$MODULE_DIR$/target/surefire" />
<excludeFolder url="file://$MODULE_DIR$/target/surefire-reports" />
<excludeFolder url="file://$MODULE_DIR$/target/test-classes" />
+ <excludeFolder url="file://$MODULE_DIR$/target/waisda-web-0.0.2-SNAPSHOT" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
View
@@ -1,10 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>manbijthond</groupId>
- <artifactId>manbijthond-web</artifactId>
+ <groupId>waisda</groupId>
+ <artifactId>waisda-web</artifactId>
<packaging>war</packaging>
- <name>manbijthond</name>
+ <name>waisda</name>
<version>0.0.2-SNAPSHOT</version>
<properties>
@@ -385,7 +385,7 @@
<dependency>
<groupId>org.codehaus.btm</groupId>
<artifactId>btm</artifactId>
- <version>2.0.1</version>
+ <version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.codehaus.btm</groupId>
View
115,822 sql/gtaa.sql

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,22 +1,22 @@
-/* This file is part of Waisda
-
- Copyright (c) 2012 Netherlands Institute for Sound and Vision
- https://github.com/beeldengeluid/waisda
-
- Waisda is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Waisda is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Waisda. If not, see <http://www.gnu.org/licenses/>.
-*/
-
+/* This file is part of Waisda
+
+ Copyright (c) 2012 Netherlands Institute for Sound and Vision
+ https://github.com/beeldengeluid/waisda
+
+ Waisda is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Waisda is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Waisda. If not, see <http://www.gnu.org/licenses/>.
+*/
+
package nl.waisda.controllers;
import javax.servlet.http.HttpSession;
@@ -87,18 +87,43 @@ public String register(ModelMap model, HttpSession session) {
}
@RequestMapping(value = "/registreren", method = RequestMethod.POST)
- public String register(@Valid @ModelAttribute("form") RegisterForm form,
- Errors errors, HttpSession session) {
- if (errors.hasErrors()) {
- return "register";
- } else {
- User user = new User();
- form.applyTo(user);
- userRepo.store(user);
- userSessionService.login(session, user);
- log.info(String.format("Registered %s!", user.getShortDescription()));
- return "redirect:/";
- }
+ public String register(@ModelAttribute("form") RegisterForm form,
+ Errors errors, HttpSession session) {
+ // this provides as much safety against double clicks as possible
+ // without requiring a table lock...
+ synchronized(AccountController.class) { // hopefully registrations don't occur too much
+ User user = userSessionService.getCurrentUser(session);
+ if (user == null || user.isAnonymous()) {
+ validator.validate(form, errors);
+ if (!errors.hasErrors()) {
+ try {
+ user = new User();
+ form.applyTo(user);
+ userRepo.store(user);
+ userSessionService.login(session, user);
+ log.info(String.format("Registered %s!", user.getShortDescription()));
+ } catch(Exception e) {
+ // this exception may have been caused by duplicate user
+ // so we'll simply validate again. If validation fails
+ // we'll return this page, otherwise we'll rethrow,
+ // resulting in the error page
+ validator.validate(form, errors);
+ if (!errors.hasErrors()) {
+ if (e instanceof RuntimeException) {
+ throw (RuntimeException) e;
+ }
+ throw new RuntimeException(e);
+ }
+ // show form again
+ return "register";
+ }
+ } else {
+ // show form again
+ return "register";
+ }
+ }
+ }
+ return "redirect:/";
}
@RequestMapping("/inloggen")
@@ -0,0 +1,92 @@
+package nl.waisda.interceptors;
+
+import java.io.Serializable;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+
+/**
+ * Pushes per user statics onto the session
+ * @author Danny Sedney sdengineering77@gmail.com
+ */
+@Component
+public class StaticModelInterceptor extends HandlerInterceptorAdapter {
+
+ private static final String STATIC_MODEL_ATTR_NAME = "staticModel";
+
+ // STATIC FIELDS NEED GETTERS WHEN USING BEANUTILS TO POPULATE
+ @Value("${waisda.socialreference.title}")
+ private String socialReferenceTitle;
+ @Value("${waisda.socialreference.homeurl}")
+ private String socialReferenceHome;
+ @Value("${waisda.socialreference.description}")
+ private String socialReferenceDescription;
+
+ // this object must be constructed and pushed onto the session
+ // when not there yet. It, ofcourse, may contain user specific data
+ // and therefor is constructed once per session
+ public class StaticModel implements Serializable {
+ private static final long serialVersionUID = 1l;
+
+ private String socialReferenceTitle;
+ private String socialReferenceHome;
+ private String socialReferenceDescription;
+
+ public String getSocialReferenceTitle() {
+ return socialReferenceTitle;
+ }
+
+ public void setSocialReferenceTitle(String socialReferenceTitle) {
+ this.socialReferenceTitle = socialReferenceTitle;
+ }
+
+ public String getSocialReferenceHome() {
+ return socialReferenceHome;
+ }
+
+ public void setSocialReferenceHome(String socialReferenceHome) {
+ this.socialReferenceHome = socialReferenceHome;
+ }
+
+ public String getSocialReferenceDescription() {
+ return socialReferenceDescription;
+ }
+
+ public void setSocialReferenceDescription(String socialReferenceDescription) {
+ this.socialReferenceDescription = socialReferenceDescription;
+ }
+ }
+
+ @Override
+ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+
+ HttpSession session = request.getSession();
+ if (session != null && session.getAttribute(STATIC_MODEL_ATTR_NAME) == null) {
+ StaticModel staticModel = new StaticModel();
+ BeanUtils.copyProperties(this, staticModel);
+ session.setAttribute(STATIC_MODEL_ATTR_NAME, staticModel);
+ }
+
+ return super.preHandle(request, response, handler);
+ }
+
+ public String getSocialReferenceTitle() {
+ return socialReferenceTitle;
+ }
+
+ public String getSocialReferenceHome() {
+ return socialReferenceHome;
+ }
+
+ public String getSocialReferenceDescription() {
+ return socialReferenceDescription;
+ }
+
+
+}
@@ -53,7 +53,7 @@ public static TagEntrySummary fromEntries(List<TagEntry> entries) {
TagEntrySummary summary = new TagEntrySummary();
for (TagEntry tag : entries) {
summary.countTags++;
- if (tag.getMatchingTagEntry() != null) {
+ if (tag.getMatchingTagEntry() != null && tag.getScore() > 0) { // only count it if it has points
summary.countMatchingTags++;
if (tag.isPioneer()) {
summary.countPioneerTags++;
@@ -1,22 +1,22 @@
-/* This file is part of Waisda
-
- Copyright (c) 2012 Netherlands Institute for Sound and Vision
- https://github.com/beeldengeluid/waisda
-
- Waisda is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Waisda is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Waisda. If not, see <http://www.gnu.org/licenses/>.
-*/
-
+/* This file is part of Waisda
+
+ Copyright (c) 2012 Netherlands Institute for Sound and Vision
+ https://github.com/beeldengeluid/waisda
+
+ Waisda is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Waisda is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Waisda. If not, see <http://www.gnu.org/licenses/>.
+*/
+
package nl.waisda.repositories;
import java.util.ArrayList;
@@ -1,22 +1,22 @@
-/* This file is part of Waisda
-
- Copyright (c) 2012 Netherlands Institute for Sound and Vision
- https://github.com/beeldengeluid/waisda
-
- Waisda is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Waisda is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Waisda. If not, see <http://www.gnu.org/licenses/>.
-*/
-
+/* This file is part of Waisda
+
+ Copyright (c) 2012 Netherlands Institute for Sound and Vision
+ https://github.com/beeldengeluid/waisda
+
+ Waisda is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Waisda is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Waisda. If not, see <http://www.gnu.org/licenses/>.
+*/
+
package nl.waisda.services;
import java.util.ArrayList;
@@ -57,6 +57,9 @@
@Autowired
private TagEntryRepository tagRepo;
+ @Autowired
+ private ScoringServiceIF scoringService;
+
private Cache<List<Game>> currentGamesCache;
{
@@ -128,6 +131,9 @@ public Recap getRecap(Game game, User owner) {
for (TagEntry tag : entries) {
User u = tag.getOwner();
+ // set special dictionary flag
+ tag.setSpecialMatch(scoringService.isSpecialDictionaryMatch(tag.getDictionary()));
+
if (u.getId() == owner.getId()) {
ownerEntries.add(tag);
ownerScore += tag.getScore();
@@ -139,6 +145,8 @@ public Recap getRecap(Game game, User owner) {
scores.put(u, score);
}
score.count(tag);
+
+
}
ArrayList<UserScore> participants = new ArrayList<UserScore>(
@@ -111,6 +111,13 @@ public void updateDictionary(TagEntry tagEntry) {
}
}
+ public boolean isSpecialDictionaryMatch(final String dictionaryName) {
+ if (StringUtils.isNotEmpty(dictionaryName)) {
+ return specialDictionaryList.contains(dictionaryName);
+ }
+ return false;
+ }
+
@Transactional
public void updateMatchAndStore(TagEntry tagEntry,
boolean updateReverseMatches) {
@@ -15,4 +15,6 @@
void updateMatchAndStore(TagEntry tagEntry, boolean updateReverseMatches);
GlobalStats getGlobalStats();
+ boolean isSpecialDictionaryMatch(final String dictionaryName);
+
}
Oops, something went wrong.

0 comments on commit 7e94718

Please sign in to comment.