Permalink
Browse files

Uncommitted files...not sure why. Moving to side branch in case I nee…

…d them later.
  • Loading branch information...
Craig Walls
Craig Walls committed Sep 17, 2012
1 parent 3e9bf92 commit 6dccf08a3ad549de0d99273c13ed5a1e4ef31011
Showing with 27,510 additions and 142 deletions.
  1. +14 −0 .springBeans
  2. +22 −3 pom.xml
  3. +1 −1 src/main/java/com/springsource/greenhouse/config/DataConfig.java
  4. +3 −1 src/main/java/com/springsource/greenhouse/config/security.xml
  5. +155 −116 src/main/java/com/springsource/greenhouse/config/test-data.sql
  6. +10 −1 src/main/java/com/springsource/greenhouse/database/DatabaseUpgrader.java
  7. +46 −4 src/main/java/com/springsource/greenhouse/database/install/Event.sql
  8. +9 −0 src/main/java/com/springsource/greenhouse/database/upgrade/v4/CreateTimeSlotTable.sql
  9. +12 −4 src/main/java/com/springsource/greenhouse/events/JdbcEventRepository.java
  10. +78 −0 src/main/java/com/springsource/greenhouse/events/load/EventData.java
  11. +47 −0 src/main/java/com/springsource/greenhouse/events/load/EventLoadController.java
  12. +34 −0 src/main/java/com/springsource/greenhouse/events/load/EventLoaderRepository.java
  13. +86 −0 src/main/java/com/springsource/greenhouse/events/load/EventSessionData.java
  14. +175 −0 src/main/java/com/springsource/greenhouse/events/load/JdbcEventLoaderRepository.java
  15. +60 −0 src/main/java/com/springsource/greenhouse/events/load/LeaderData.java
  16. +140 −0 src/main/java/com/springsource/greenhouse/events/load/NFJSLoader.java
  17. +44 −0 src/main/java/com/springsource/greenhouse/events/load/TimeSlotData.java
  18. +54 −0 src/main/java/com/springsource/greenhouse/events/load/VenueData.java
  19. +12 −0 src/main/webapp/WEB-INF/views/admin/load.jsp
  20. +10 −0 src/main/webapp/WEB-INF/views/admin/tiles.xml
  21. +2 −2 src/test/java/com/springsource/greenhouse/database/GreenhouseTestDatabaseBuilder.java
  22. +3 −3 src/test/java/com/springsource/greenhouse/events/JdbcEventRepositoryTest.java
  23. +17 −7 src/test/java/com/springsource/greenhouse/events/JdbcEventRepositoryTest.sql
  24. +18 −0 src/test/java/com/springsource/greenhouse/events/load/JdbcEventLoaderRepositoryTest-context.xml
  25. +262 −0 src/test/java/com/springsource/greenhouse/events/load/JdbcEventLoaderRepositoryTest.java
  26. +2 −0 src/test/java/com/springsource/greenhouse/events/load/JdbcEventLoaderRepositoryTest.sql
  27. +237 −0 src/test/java/com/springsource/greenhouse/events/load/NFJSLoaderTest.java
  28. +3,539 −0 src/test/java/com/springsource/greenhouse/events/load/show_schedule.json
  29. +3,554 −0 src/test/java/com/springsource/greenhouse/events/load/show_schedule_updated.json
  30. +47 −0 src/test/java/com/springsource/greenhouse/events/load/show_short.json
  31. +47 −0 src/test/java/com/springsource/greenhouse/events/load/show_short_updated.json
  32. +3,464 −0 src/test/java/com/springsource/greenhouse/events/load/show_speakers.json
  33. +3,502 −0 src/test/java/com/springsource/greenhouse/events/load/show_speakers_updated.json
  34. +5,887 −0 src/test/java/com/springsource/greenhouse/events/load/show_topics.json
  35. +5,917 −0 src/test/java/com/springsource/greenhouse/events/load/show_topics_updated.json
View
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+ <version>1</version>
+ <pluginVersion><![CDATA[3.0.0.201207050701-M3]]></pluginVersion>
+ <configSuffixes>
+ <configSuffix><![CDATA[xml]]></configSuffix>
+ </configSuffixes>
+ <enableImports><![CDATA[false]]></enableImports>
+ <configs>
+ <config>src/test/java/com/springsource/greenhouse/events/load/JdbcEventLoaderRepositoryTest-context.xml</config>
+ </configs>
+ <configSets>
+ </configSets>
+</beansProjectDescription>
View
25 pom.xml
@@ -17,6 +17,7 @@
<properties>
<java-version>1.6</java-version>
<org.springframework-version>3.1.2.RELEASE</org.springframework-version>
+ <org.springframework.test-mvc-version>1.0.0.M1</org.springframework.test-mvc-version>
<org.springframework.security-version>3.1.0.RELEASE</org.springframework.security-version>
<org.springframework.security.oauth-version>1.0.0.RC2</org.springframework.security.oauth-version>
<org.springframework.integration-version>2.1.3.RELEASE</org.springframework.integration-version>
@@ -346,20 +347,38 @@
<!-- Test -->
<dependency>
<groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <artifactId>junit-dep</artifactId>
<version>4.10</version>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework-version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test-mvc</artifactId>
+ <version>${org.springframework.test-mvc-version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.8.5</version>
+ <artifactId>mockito-core</artifactId>
+ <version>1.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -19,10 +19,10 @@
import javax.sql.DataSource;
import org.h2.jdbcx.JdbcConnectionPool;
+import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
-import org.springframework.context.annotation.AdviceMode;
import org.springframework.core.env.Environment;
import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -35,7 +35,9 @@
<intercept-url pattern="/signin/*" access="permitAll" requires-channel="#{environment['application.secureChannel']}" />
<intercept-url pattern="/reset" access="permitAll" requires-channel="#{environment['application.secureChannel']}" />
<!-- TODO this would probably be better mapped to simply /invite?token={token} but not able to vary security policy here based on presence of a request parameter. Consider @Secured on @Controller. -->
- <intercept-url pattern="/invite/accept" access="permitAll" requires-channel="#{environment['application.secureChannel']}" />
+ <intercept-url pattern="/invite/accept" access="permitAll" requires-channel="#{environment['application.secureChannel']}" />
+ <!-- TODO this should be restricted to admin users only -->
+ <intercept-url pattern="/admin/**" access="permitAll" />
<intercept-url pattern="/**" access="isAuthenticated()" requires-channel="#{environment['application.secureChannel']}" />
<custom-filter ref="resourceServerFilter" before="EXCEPTION_TRANSLATION_FILTER" />
</http>

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -72,8 +72,9 @@ protected void addInstallChanges(DatabaseChangeSet changeSet) {}
return upgrader;
}
+ // Called for completely fresh DB only
private void addInstallChangeSet(GenericDatabaseUpgrader upgrader) {
- DatabaseChangeSet changeSet = new DatabaseChangeSet(DatabaseVersion.valueOf("3"));
+ DatabaseChangeSet changeSet = new DatabaseChangeSet(DatabaseVersion.valueOf("4"));
changeSet.add(installScript("Member.sql"));
changeSet.add(installScript("Group.sql"));
changeSet.add(installScript("Activity.sql"));
@@ -91,9 +92,11 @@ private DatabaseChange installScript(String resource) {
return SqlDatabaseChange.inResource(new ClassPathResource("install/" + resource, DatabaseUpgrader.class));
}
+ // Called to upgrade existing DB
private void addUpgradeChangeSets(GenericDatabaseUpgrader upgrader) {
upgrader.addChangeSet(version2ChangeSet());
upgrader.addChangeSet(version3ChangeSet());
+ upgrader.addChangeSet(version4ChangeSet());
}
private DatabaseChangeSet version2ChangeSet() {
@@ -110,6 +113,12 @@ private DatabaseChangeSet version3ChangeSet() {
changeSet.add(upgradeScript("v3/DropAccountConnectionTables.sql"));
return changeSet;
}
+
+ private DatabaseChangeSet version4ChangeSet() {
+ DatabaseChangeSet changeSet = new DatabaseChangeSet(DatabaseVersion.valueOf("4"));
+ changeSet.add(upgradeScript("v4/CreateTimeSlotTable.sql"));
+ return changeSet;
+ }
private DatabaseChange upgradeScript(String resource) {
return SqlDatabaseChange.inResource(new ClassPathResource("upgrade/" + resource, DatabaseUpgrader.class));
@@ -11,6 +11,14 @@ create table Leader (id identity,
primary key (id),
foreign key (member) references Member(id));
+create table ExternalLeader (leader bigint,
+ sourceId bigint,
+ source varchar,
+ lastUpdated timestamp not null,
+ primary key (leader, sourceId, source),
+ foreign key (leader) references Leader(id)
+);
+
create table Session (id identity,
title varchar not null,
slug varchar not null,
@@ -36,6 +44,14 @@ create table Event (id identity,
primary key (id),
foreign key (memberGroup) references MemberGroup(id));
+create table ExternalEvent (event bigint,
+ sourceId bigint,
+ source varchar,
+ lastUpdated timestamp not null,
+ primary key (event, sourceId, source),
+ foreign key (event) references Event(id)
+);
+
create table EventVenue (event bigint,
venue bigint,
primary key (event, venue),
@@ -51,10 +67,26 @@ create table EventTrack (event bigint,
foreign key (event) references Event(id),
foreign key (chair) references Member(id));
-create table EventSession (event bigint,
- id int not null,
+create table EventTimeSlot (
+ id identity,
+ event bigint not null,
+ label varchar,
startTime timestamp not null,
endTime timestamp not null,
+ primary key (id),
+ foreign key (event) references Event(id));
+
+create table ExternalEventTimeSlot (timeSlot bigint,
+ sourceId bigint,
+ source varchar,
+ lastUpdated timestamp not null,
+ primary key (timeSlot, sourceId, source),
+ foreign key (timeSlot) references EventTimeSlot(id)
+);
+
+
+create table EventSession (event bigint,
+ id int not null,
title varchar not null,
description varchar,
hashtag varchar,
@@ -63,12 +95,22 @@ create table EventSession (event bigint,
room varchar,
rating real,
master bigint,
+ timeslot bigint,
primary key (event, id),
foreign key (event) references Event(id),
foreign key (event, track) references EventTrack(event, code),
foreign key (venue, room) references VenueRoom(venue, id),
- foreign key (master) references Session(id));
-
+ foreign key (master) references Session(id),
+ foreign key (timeslot) references EventTimeSlot(id));
+
+create table ExternalEventSession (event bigint not null,
+ sessionId int not null,
+ sourceId bigint not null,
+ source varchar not null,
+ lastUpdated timestamp not null,
+ primary key (event, sessionId, sourceId, source)
+);
+
create table EventSessionLeader (event bigint,
session int,
leader bigint,
@@ -0,0 +1,9 @@
+create table EventTimeSlot (
+ id identity,
+ startTime timestamp not null,
+ endTime timestamp not null,
+ primary key (id)
+);
+
+alter table EventSession add column timeslot bigint;
+alter table EventSession add foreign key (timeslot) references EventTimeSlot(id);
@@ -107,11 +107,16 @@ public Float rate(Long eventId, Integer sessionId, Long attendeeId, Rating ratin
jdbcTemplate.update("update EventSession set rating = ? where event = ? and id = ?", newAvgRating, eventId, sessionId);
return newAvgRating;
}
+
+ @Transactional
+ public long addEvent() {
+ return 0;
+ }
// internal helpers
private boolean isSessionEnded(Long eventId, Integer sessionId) {
- Date endTime = jdbcTemplate.queryForObject("select endTime from EventSession where event = ? and id = ?", Date.class, eventId, sessionId);
+ Date endTime = jdbcTemplate.queryForObject("select ts.endTime from EventTimeSlot ts, EventSession s where s.event = ? and s.id = ? and ts.id = s.timeSlot", Date.class, eventId, sessionId);
return new Date().after(endTime);
}
@@ -142,7 +147,7 @@ protected void addChild(EventSession session, ResultSet rs) throws SQLException
}
};
- private static final String SELECT_FROM_EVENT_SESSION = "select s.id, s.title, s.startTime, s.endTime, s.description, s.hashtag, s.rating, s.venue, s.room, r.name as roomName, (f.attendee is not null) as favorite, l.name from EventSession s ";
+ private static final String SELECT_FROM_EVENT_SESSION = "select s.id, s.title, ts.startTime, ts.endTime, s.description, s.hashtag, s.rating, s.venue, s.room, r.name as roomName, (f.attendee is not null) as favorite, l.name from EventSession s ";
private static final String SELECT_EVENT = "select e.id, e.title, e.timeZone, e.startTime, e.endTime, e.slug, e.description, g.hashtag, g.slug as groupSlug, g.name as groupName, " +
"v.id as venueId, v.name as venueName, v.postalAddress as venuePostalAddress, v.latitude as venueLatitude, v.longitude as venueLongitude, v.locationHint as venueLocationHint from Event e " +
@@ -159,15 +164,17 @@ protected void addChild(EventSession session, ResultSet rs) throws SQLException
"left outer join EventSessionFavorite f on s.event = f.event and s.id = f.session and f.attendee = ? " +
"inner join EventSessionLeader sl on s.event = sl.event and s.id = sl.session " +
"inner join Leader l on sl.leader = l.id " +
- "where s.event = ? and s.startTime >= ? and s.endTime <= ? " +
- "order by s.startTime, s.id, sl.rank";
+ "inner join EventTimeSlot ts on ts.id = s.timeSlot " +
+ "where s.event = ? and ts.startTime >= ? and ts.endTime <= ? " +
+ "order by ts.startTime, s.id, sl.rank";
private static final String SELECT_EVENT_FAVORITES = SELECT_FROM_EVENT_SESSION +
"inner join (select top 10 session, count(*) as favoriteCount from EventSessionFavorite where event = ? group by session) top on s.id = top.session " +
"left outer join VenueRoom r on s.venue = r.venue and s.room = r.id " +
"left outer join EventSessionFavorite f on s.event = f.event and s.id = f.session and f.attendee = ? " +
"inner join EventSessionLeader sl on s.event = sl.event and s.id = sl.session " +
"inner join Leader l on sl.leader = l.id " +
+ "inner join EventTimeSlot ts on ts.id = s.timeSlot " +
"where s.event = ? " +
"order by top.favoriteCount desc, s.id, sl.rank";
@@ -176,6 +183,7 @@ protected void addChild(EventSession session, ResultSet rs) throws SQLException
"inner join EventSessionFavorite f on s.event = f.event and s.id = f.session and f.attendee = ? " +
"inner join EventSessionLeader sl on s.event = sl.event and s.id = sl.session " +
"inner join Leader l on sl.leader = l.id " +
+ "inner join EventTimeSlot ts on ts.id = s.timeSlot " +
"where s.event = ? " +
"order by f.rank, s.id, sl.rank";
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * 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.
+ */
+package com.springsource.greenhouse.events.load;
+
+class EventData {
+
+ private final long memberGroupId;
+ private final String name;
+ private final String description;
+ private final String abbreviation;
+ private final String firstDay;
+ private final String lastDay;
+ private final String timeZone;
+ private final String source;
+ private final long sourceId;
+
+ public EventData(long memberGroupId, String name, String description, String abbreviation, String firstDay, String lastDay, String timeZone, String source, long sourceId) {
+ this.memberGroupId = memberGroupId;
+ this.name = name;
+ this.description = description;
+ this.abbreviation = abbreviation;
+ this.firstDay = firstDay;
+ this.lastDay = lastDay;
+ this.timeZone = timeZone;
+ this.source = source;
+ this.sourceId = sourceId;
+ }
+
+ public long getMemberGroupId() {
+ return memberGroupId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getAbbreviation() {
+ return abbreviation;
+ }
+
+ public String getFirstDay() {
+ return firstDay;
+ }
+
+ public String getLastDay() {
+ return lastDay;
+ }
+
+ public String getTimeZone() {
+ return timeZone;
+ }
+
+ public String getSource() {
+ return source;
+ }
+
+ public long getSourceId() {
+ return sourceId;
+ }
+
+}
Oops, something went wrong.

0 comments on commit 6dccf08

Please sign in to comment.