Parcourir la source

Merge branch 'master' into patch-1

mackos il y a 9 ans
Parent
révision
7b732f7fc4
42 fichiers modifiés avec 721 ajouts et 850 suppressions
  1. 2
    0
      README.md
  2. 223
    303
      pom.xml
  3. 60
    0
      src/main/java/se/citerus/dddsample/Application.java
  4. 1
    1
      src/main/java/se/citerus/dddsample/application/impl/BookingServiceImpl.java
  5. 1
    1
      src/main/java/se/citerus/dddsample/application/impl/HandlingEventServiceImpl.java
  6. 302
    295
      src/main/java/se/citerus/dddsample/application/util/SampleDataGenerator.java
  7. 1
    1
      src/main/java/se/citerus/dddsample/infrastructure/persistence/hibernate/LocationRepositoryHibernate.java
  8. 1
    1
      src/main/java/se/citerus/dddsample/infrastructure/persistence/hibernate/VoyageRepositoryHibernate.java
  9. 6
    5
      src/main/java/se/citerus/dddsample/interfaces/booking/web/CargoAdminController.java
  10. 6
    6
      src/main/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingController.java
  11. 6
    0
      src/main/resources/application.properties
  12. 3
    2
      src/main/resources/context-interfaces.xml
  13. 0
    10
      src/main/resources/log4j.properties
  14. 0
    0
      src/main/resources/static/admin.css
  15. 82
    82
      src/main/resources/static/calendar.css
  16. 0
    0
      src/main/resources/static/css/bootstrap-datepicker.css
  17. 0
    0
      src/main/resources/static/css/bootstrap.css
  18. 0
    0
      src/main/resources/static/fonts/glyphicons-halflings-regular.ttf
  19. 0
    0
      src/main/resources/static/fonts/glyphicons-halflings-regular.woff
  20. 0
    0
      src/main/resources/static/fonts/glyphicons-halflings-regular.woff2
  21. 0
    0
      src/main/resources/static/images/calendarTrigger.gif
  22. 0
    0
      src/main/resources/static/images/cross.png
  23. 0
    0
      src/main/resources/static/images/dddsample_logotype.png
  24. 0
    0
      src/main/resources/static/images/dddsample_logotype_small.png
  25. 0
    0
      src/main/resources/static/images/error.png
  26. 0
    0
      src/main/resources/static/images/shade.png
  27. 0
    0
      src/main/resources/static/images/tick.png
  28. 0
    0
      src/main/resources/static/images/web_logo.png
  29. 21
    24
      src/main/resources/static/index.html
  30. 0
    0
      src/main/resources/static/js/bootstrap-datepicker.js
  31. 0
    0
      src/main/resources/static/js/jquery-2.1.4.js
  32. 0
    0
      src/main/resources/static/style.css
  33. 1
    1
      src/main/resources/templates/admin/list.html
  34. 1
    1
      src/main/resources/templates/admin/pickNewDestination.html
  35. 1
    1
      src/main/resources/templates/admin/registrationForm.html
  36. 1
    1
      src/main/resources/templates/admin/selectItinerary.html
  37. 1
    1
      src/main/resources/templates/admin/show.html
  38. 0
    0
      src/main/resources/templates/adminDecorator.html
  39. 1
    1
      src/main/resources/templates/track.html
  40. 0
    22
      src/main/webapp/WEB-INF/booking-servlet.xml
  41. 0
    22
      src/main/webapp/WEB-INF/tracking-servlet.xml
  42. 0
    69
      src/main/webapp/WEB-INF/web.xml

+ 2
- 0
README.md Voir le fichier

3
 
3
 
4
 Our intention is to move everything from SourceForge to GitHub in due time while starting upgrading both the technical aspects as well as the DDD aspects of the DDD Sample.
4
 Our intention is to move everything from SourceForge to GitHub in due time while starting upgrading both the technical aspects as well as the DDD aspects of the DDD Sample.
5
 
5
 
6
+The application uses Spring Boot. To start it go to the root directory and type `mvn spring-boot:run` or run the `main` method of the `Application` class from your IDE.
7
+
6
 Discussion group: https://groups.google.com/forum/#!forum/dddsample
8
 Discussion group: https://groups.google.com/forum/#!forum/dddsample
7
 
9
 
8
 Development blog: https://citerus.github.io/dddsample-core/
10
 Development blog: https://citerus.github.io/dddsample-core/

+ 223
- 303
pom.xml Voir le fichier

1
-<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">
2
-  <modelVersion>4.0.0</modelVersion>
3
-  <groupId>se.citerus</groupId>
4
-  <artifactId>dddsample</artifactId>
5
-  <packaging>war</packaging>
6
-  <name>DDDSample</name>
7
-  <version>2.0-SNAPSHOT</version>
8
-  <description>This application shows a few key concepts of
9
-    Domain Driven Design implemented in Enterprise Java.
10
-  </description>
11
-  <url>http://dddsample.sourceforge.net</url>
12
-  <distributionManagement>
13
-    <site>
14
-      <id>sf</id>
15
-      <url>scp://shell.sf.net/home/groups/d/dd/dddsample/htdocs/preview</url>
16
-    </site>
17
-  </distributionManagement>
18
-  <ciManagement />
19
-  <developers>
20
-    <developer>
21
-      <id>eric_evans</id>
22
-      <name>Eric Evans</name>
23
-      <organization>Domain Language, Inc.</organization>
24
-      <organizationUrl>http://www.domainlanguage.com</organizationUrl>
25
-      <timezone>-8</timezone>
26
-    </developer>
27
-    <developer>
28
-      <id>peba</id>
29
-      <name>Peter Backlund</name>
30
-      <organization>Citerus</organization>
31
-      <organizationUrl>http://www.citerus.se</organizationUrl>
32
-      <timezone>+1</timezone>
33
-    </developer>
34
-    <developer>
35
-      <id>patrikfr</id>
36
-      <name>Patrik Fredriksson</name>
37
-      <organization>Citerus</organization>
38
-      <organizationUrl>http://www.citerus.se</organizationUrl>
39
-      <timezone>+1</timezone>
40
-    </developer>
41
-    <developer>
42
-      <id>jeham</id>
43
-      <name>Jesper Hammarback</name>
44
-      <organization>Citerus</organization>
45
-      <organizationUrl>http://www.citerus.se</organizationUrl>
46
-      <timezone>+1</timezone>
47
-    </developer>
48
-    <developer>
49
-      <id>jorgen_falk</id>
50
-      <name>Jorgen Falk</name>
51
-      <organization>Citerus</organization>
52
-      <organizationUrl>http://www.citerus.se</organizationUrl>
53
-      <timezone>+1</timezone>
54
-    </developer>
55
-  </developers>
56
-  <licenses>
57
-    <license>
58
-      <name>MIT</name>
59
-      <url>http://www.opensource.org/licenses/mit-license.php</url>
60
-      <distribution>repo</distribution>
61
-    </license>
62
-  </licenses>
63
-  <scm>
64
-    <developerConnection>scm:git:https://github.com/citerus/dddsample-core</developerConnection>
65
-    <url>https://github.com/citerus/dddsample-core</url>
66
-  </scm>
67
-  <properties>
68
-    <java.version>1.8</java.version>
69
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
70
-    <!-- Dependencies -->
71
-    <spring.version>4.2.1.RELEASE</spring.version>
72
-    <cxf.version>3.0.3</cxf.version>
73
-    <!-- Plugin versions -->
74
-    <maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
75
-    <maven-jar-plugin.version>2.6</maven-jar-plugin.version>
76
-    <maven-assembly-plugin.version>2.5.5</maven-assembly-plugin.version>
77
-  </properties>
78
-  <build>
79
-    <plugins>
80
-      <!-- Compiler -->
81
-      <plugin>
82
-        <artifactId>maven-compiler-plugin</artifactId>
83
-        <version>${maven-compiler-plugin.version}</version>
84
-        <configuration>
85
-          <source>${java.version}</source>
86
-          <target>${java.version}</target>
87
-          <encoding>${project.build.sourceEncoding}</encoding>
88
-        </configuration>
89
-      </plugin>
1
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
+    <modelVersion>4.0.0</modelVersion>
4
+    <groupId>se.citerus</groupId>
5
+    <artifactId>dddsample</artifactId>
6
+    <name>DDDSample</name>
7
+    <version>2.0-SNAPSHOT</version>
8
+    <parent>
9
+        <groupId>org.springframework.boot</groupId>
10
+        <artifactId>spring-boot-starter-parent</artifactId>
11
+        <version>1.4.2.RELEASE</version>
12
+    </parent>
13
+    <description>This application shows a few key concepts of
14
+        Domain Driven Design implemented in Enterprise Java.
15
+    </description>
16
+    <url>http://dddsample.sourceforge.net</url>
17
+    <distributionManagement>
18
+        <site>
19
+            <id>sf</id>
20
+            <url>scp://shell.sf.net/home/groups/d/dd/dddsample/htdocs/preview</url>
21
+        </site>
22
+    </distributionManagement>
23
+    <ciManagement/>
24
+    <developers>
25
+        <developer>
26
+            <id>eric_evans</id>
27
+            <name>Eric Evans</name>
28
+            <organization>Domain Language, Inc.</organization>
29
+            <organizationUrl>http://www.domainlanguage.com</organizationUrl>
30
+            <timezone>-8</timezone>
31
+        </developer>
32
+        <developer>
33
+            <id>peba</id>
34
+            <name>Peter Backlund</name>
35
+            <organization>Citerus</organization>
36
+            <organizationUrl>http://www.citerus.se</organizationUrl>
37
+            <timezone>+1</timezone>
38
+        </developer>
39
+        <developer>
40
+            <id>patrikfr</id>
41
+            <name>Patrik Fredriksson</name>
42
+            <organization>Citerus</organization>
43
+            <organizationUrl>http://www.citerus.se</organizationUrl>
44
+            <timezone>+1</timezone>
45
+        </developer>
46
+        <developer>
47
+            <id>jeham</id>
48
+            <name>Jesper Hammarback</name>
49
+            <organization>Citerus</organization>
50
+            <organizationUrl>http://www.citerus.se</organizationUrl>
51
+            <timezone>+1</timezone>
52
+        </developer>
53
+        <developer>
54
+            <id>jorgen_falk</id>
55
+            <name>Jorgen Falk</name>
56
+            <organization>Citerus</organization>
57
+            <organizationUrl>http://www.citerus.se</organizationUrl>
58
+            <timezone>+1</timezone>
59
+        </developer>
60
+    </developers>
61
+    <licenses>
62
+        <license>
63
+            <name>MIT</name>
64
+            <url>http://www.opensource.org/licenses/mit-license.php</url>
65
+            <distribution>repo</distribution>
66
+        </license>
67
+    </licenses>
68
+    <scm>
69
+        <developerConnection>scm:git:https://github.com/citerus/dddsample-core</developerConnection>
70
+        <url>https://github.com/citerus/dddsample-core</url>
71
+    </scm>
72
+    <properties>
73
+        <java.version>1.8</java.version>
74
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
75
+        <!-- Plugin versions -->
76
+        <maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
77
+    </properties>
78
+    <build>
79
+        <plugins>
80
+            <!-- Compiler -->
81
+            <plugin>
82
+                <artifactId>maven-compiler-plugin</artifactId>
83
+                <version>${maven-compiler-plugin.version}</version>
84
+                <configuration>
85
+                    <source>${java.version}</source>
86
+                    <target>${java.version}</target>
87
+                    <encoding>${project.build.sourceEncoding}</encoding>
88
+                </configuration>
89
+            </plugin>
90
 
90
 
91
-      <!-- Jetty plugin -->
92
-      <plugin>
93
-        <groupId>org.mortbay.jetty</groupId>
94
-        <artifactId>maven-jetty-plugin</artifactId>
95
-      </plugin>
91
+            <plugin>
92
+                <groupId>org.springframework.boot</groupId>
93
+                <artifactId>spring-boot-maven-plugin</artifactId>
94
+            </plugin>
95
+        </plugins>
96
+    </build>
97
+    <dependencies>
98
+        <dependency>
99
+            <groupId>junit</groupId>
100
+            <artifactId>junit</artifactId>
101
+            <version>4.12</version>
102
+            <scope>test</scope>
103
+        </dependency>
104
+        <dependency>
105
+            <groupId>org.springframework.boot</groupId>
106
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
107
+        </dependency>
108
+        <dependency>
109
+            <groupId>org.springframework.boot</groupId>
110
+            <artifactId>spring-boot-starter-jdbc</artifactId>
111
+        </dependency>
112
+        <dependency>
113
+            <groupId>org.springframework.boot</groupId>
114
+            <artifactId>spring-boot-starter-test</artifactId>
115
+        </dependency>
116
+        <dependency>
117
+            <groupId>org.springframework</groupId>
118
+            <artifactId>spring-jms</artifactId>
119
+        </dependency>
120
+        <dependency>
121
+            <groupId>org.springframework</groupId>
122
+            <artifactId>spring-orm</artifactId>
123
+        </dependency>
124
+        <dependency>
125
+            <groupId>org.apache.cxf</groupId>
126
+            <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
127
+            <version>3.1.7</version>
128
+        </dependency>
129
+        <dependency>
130
+            <groupId>org.hibernate</groupId>
131
+            <artifactId>hibernate-core</artifactId>
132
+            <version>4.3.5.Final</version>
133
+            <!-- God, what is it with Java and logging frameworks... http://forum.hibernate.org/viewtopic.php?p=2401380 -->
134
+            <exclusions>
135
+                <exclusion>
136
+                    <groupId>org.slf4j</groupId>
137
+                    <artifactId>slf4j-api</artifactId>
138
+                </exclusion>
139
+            </exclusions>
140
+        </dependency>
141
+        <dependency>
142
+            <groupId>commons-collections</groupId>
143
+            <artifactId>commons-collections</artifactId>
144
+            <version>3.2.2</version>
145
+        </dependency>
146
+        <dependency>
147
+            <groupId>commons-lang</groupId>
148
+            <artifactId>commons-lang</artifactId>
149
+            <version>2.3</version>
150
+        </dependency>
151
+        <dependency>
152
+            <groupId>commons-io</groupId>
153
+            <artifactId>commons-io</artifactId>
154
+            <version>1.3.1</version>
155
+        </dependency>
156
+        <dependency>
157
+            <groupId>commons-dbcp</groupId>
158
+            <artifactId>commons-dbcp</artifactId>
159
+            <version>1.2.2</version>
160
+        </dependency>
161
+        <dependency>
162
+            <groupId>org.hsqldb</groupId>
163
+            <artifactId>hsqldb</artifactId>
164
+            <version>2.3.3</version>
165
+        </dependency>
166
+        <dependency>
167
+            <groupId>javax.servlet</groupId>
168
+            <artifactId>javax.servlet-api</artifactId>
169
+            <version>3.1.0</version>
170
+            <scope>provided</scope>
171
+        </dependency>
172
+        <dependency>
173
+            <groupId>org.apache.activemq</groupId>
174
+            <artifactId>activemq-core</artifactId>
175
+            <version>5.2.0</version>
176
+            <exclusions>
177
+                <exclusion>
178
+                    <groupId>commons-logging</groupId>
179
+                    <artifactId>commons-logging-api</artifactId>
180
+                </exclusion>
181
+            </exclusions>
182
+        </dependency>
183
+        <dependency>
184
+            <groupId>org.apache.xbean</groupId>
185
+            <artifactId>xbean-spring</artifactId>
186
+            <version>3.4.3</version>
187
+        </dependency>
188
+        <dependency>
189
+            <groupId>org.easymock</groupId>
190
+            <artifactId>easymock</artifactId>
191
+            <version>2.3</version>
192
+            <scope>test</scope>
193
+        </dependency>
194
+    </dependencies>
96
 
195
 
97
-      <plugin>
98
-        <artifactId>maven-jar-plugin</artifactId>
99
-        <version>${maven-jar-plugin.version}</version>
100
-        <executions>
101
-
102
-          <!-- Package booking service facade classes in separate jar -->
103
-          <execution>
104
-            <id>package-booking-facade</id>
105
-            <phase>package</phase>
106
-            <goals>
107
-              <goal>jar</goal>
108
-            </goals>
109
-            <configuration>
110
-              <classifier>booking-facade</classifier>
111
-              <includes>
112
-                <include>**/se/citerus/dddsample/interfaces/booking/facade/*.class</include>
113
-                <include>**/se/citerus/dddsample/interfaces/booking/facade/dto/*.class</include>
114
-              </includes>
115
-              <archive>
116
-                <addMavenDescriptor>false</addMavenDescriptor>
117
-              </archive>
118
-            </configuration>
119
-          </execution>
120
-        </executions>
121
-      </plugin>
122
-
123
-      <!-- Assembly -->
124
-      <plugin>
125
-        <artifactId>maven-assembly-plugin</artifactId>
126
-        <version>${maven-assembly-plugin.version}</version>
127
-        <configuration>
128
-          <descriptorRefs>
129
-            <descriptorRef>src</descriptorRef>
130
-          </descriptorRefs>
131
-        </configuration>
132
-      </plugin>
133
-      
134
-    </plugins>
135
-  </build>
136
-  <dependencies>
137
-    <dependency>
138
-      <groupId>junit</groupId>
139
-      <artifactId>junit</artifactId>
140
-      <version>4.12</version>
141
-      <scope>test</scope>
142
-    </dependency>
143
-    <dependency>
144
-      <groupId>org.springframework</groupId>
145
-      <artifactId>spring-webmvc</artifactId>
146
-      <version>${spring.version}</version>
147
-    </dependency>
148
-    <dependency>
149
-      <groupId>org.springframework</groupId>
150
-      <artifactId>spring-tx</artifactId>
151
-      <version>${spring.version}</version>
152
-    </dependency>
153
-    <dependency>
154
-      <groupId>org.springframework</groupId>
155
-      <artifactId>spring-jdbc</artifactId>
156
-      <version>${spring.version}</version>
157
-    </dependency>
158
-    <dependency>
159
-      <groupId>org.springframework</groupId>
160
-      <artifactId>spring-jms</artifactId>
161
-      <version>${spring.version}</version>
162
-    </dependency>
163
-    <dependency>
164
-      <groupId>org.springframework</groupId>
165
-      <artifactId>spring-orm</artifactId>
166
-      <version>${spring.version}</version>
167
-    </dependency>
168
-    <dependency>
169
-      <groupId>org.springframework</groupId>
170
-      <artifactId>spring-web</artifactId>
171
-      <version>${spring.version}</version>
172
-    </dependency>
173
-    <dependency>
174
-      <groupId>org.springframework</groupId>
175
-      <artifactId>spring-test</artifactId>
176
-      <version>${spring.version}</version>
177
-      <scope>test</scope>
178
-    </dependency>
179
-      <dependency>
180
-          <groupId>org.thymeleaf</groupId>
181
-          <artifactId>thymeleaf-spring4</artifactId>
182
-          <version>2.1.4.RELEASE</version>
183
-      </dependency>
184
-      <dependency>
185
-      <groupId>org.hibernate</groupId>
186
-      <artifactId>hibernate-core</artifactId>
187
-      <version>4.3.5.Final</version>
188
-      <!-- God, what is it with Java and logging frameworks... http://forum.hibernate.org/viewtopic.php?p=2401380 -->
189
-      <exclusions>
190
-        <exclusion>
191
-          <groupId>org.slf4j</groupId>
192
-          <artifactId>slf4j-api</artifactId>
193
-        </exclusion>
194
-      </exclusions>
195
-    </dependency>
196
-      <dependency>
197
-          <groupId>commons-collections</groupId>
198
-          <artifactId>commons-collections</artifactId>
199
-          <version>3.2.2</version>
200
-      </dependency>
201
-      <dependency>
202
-      <groupId>org.slf4j</groupId>
203
-      <artifactId>slf4j-log4j12</artifactId>
204
-      <version>1.5.6</version>
205
-    </dependency>
206
-    <dependency>
207
-      <groupId>org.slf4j</groupId>
208
-      <artifactId>jcl-over-slf4j</artifactId>
209
-      <version>1.5.6</version>
210
-    </dependency>
211
-    <dependency>
212
-      <groupId>org.slf4j</groupId>
213
-      <artifactId>slf4j-api</artifactId>
214
-      <version>1.5.6</version>
215
-    </dependency>
216
-    <dependency>
217
-      <groupId>commons-lang</groupId>
218
-      <artifactId>commons-lang</artifactId>
219
-      <version>2.3</version>
220
-    </dependency>
221
-    <dependency>
222
-      <groupId>commons-io</groupId>
223
-      <artifactId>commons-io</artifactId>
224
-      <version>1.3.1</version>
225
-    </dependency>
226
-    <dependency>
227
-      <groupId>commons-dbcp</groupId>
228
-      <artifactId>commons-dbcp</artifactId>
229
-      <version>1.2.2</version>
230
-    </dependency>
231
-    <dependency>
232
-      <groupId>org.hsqldb</groupId>
233
-      <artifactId>hsqldb</artifactId>
234
-      <version>2.3.3</version>
235
-    </dependency>
236
-      <dependency>
237
-          <groupId>javax.servlet</groupId>
238
-          <artifactId>javax.servlet-api</artifactId>
239
-          <version>3.1.0</version>
240
-          <scope>provided</scope>
241
-      </dependency>
242
-    <dependency>
243
-      <groupId>org.apache.activemq</groupId>
244
-      <artifactId>activemq-core</artifactId>
245
-      <version>5.2.0</version>
246
-      <exclusions>
247
-        <exclusion>
248
-          <groupId>commons-logging</groupId>
249
-          <artifactId>commons-logging-api</artifactId>
250
-        </exclusion>
251
-      </exclusions>
252
-    </dependency>
253
-    <dependency>
254
-      <groupId>org.apache.xbean</groupId>
255
-      <artifactId>xbean-spring</artifactId>
256
-      <version>3.4.3</version>
257
-    </dependency>
258
-    <dependency>
259
-      <groupId>org.easymock</groupId>
260
-      <artifactId>easymock</artifactId>
261
-      <version>2.3</version>
262
-      <scope>test</scope>
263
-    </dependency>
264
-    <dependency>
265
-      <groupId>org.apache.cxf</groupId>
266
-      <artifactId>cxf-rt-frontend-jaxws</artifactId>
267
-      <version>${cxf.version}</version>
268
-    </dependency>
269
-    <dependency>
270
-      <groupId>org.apache.cxf</groupId>
271
-      <artifactId>cxf-rt-transports-http</artifactId>
272
-      <version>${cxf.version}</version>
273
-    </dependency>
274
-  </dependencies>
275
-
276
-  <reporting>
277
-    <plugins>
278
-      <!-- Javadoc -->
279
-      <plugin>
280
-        <artifactId>maven-javadoc-plugin</artifactId>
281
-      </plugin>
282
-      <!-- Source code cross reference -->
283
-      <plugin>
284
-        <artifactId>maven-jxr-plugin</artifactId>
285
-      </plugin>
286
-      <!-- Test report -->
287
-      <plugin>
288
-        <artifactId>maven-surefire-report-plugin</artifactId>
289
-      </plugin>
290
-      <!-- Test coverage -->
291
-      <plugin>
292
-        <groupId>org.codehaus.mojo</groupId>
293
-        <artifactId>cobertura-maven-plugin</artifactId>
294
-      </plugin>
295
-      <!-- CheckStyle report -->
296
-      <plugin>
297
-        <artifactId>maven-checkstyle-plugin</artifactId>
298
-        <configuration>
299
-          <configLocation>src/main/config/checkstyle.xml</configLocation>
300
-          <!-- Java source code generated from WSDL -->
301
-          <excludes>**/com/aggregator/**/*</excludes>
302
-        </configuration>
303
-      </plugin>
304
-    </plugins>
305
-  </reporting>
196
+    <reporting>
197
+        <plugins>
198
+            <!-- Javadoc -->
199
+            <plugin>
200
+                <artifactId>maven-javadoc-plugin</artifactId>
201
+            </plugin>
202
+            <!-- Source code cross reference -->
203
+            <plugin>
204
+                <artifactId>maven-jxr-plugin</artifactId>
205
+            </plugin>
206
+            <!-- Test report -->
207
+            <plugin>
208
+                <artifactId>maven-surefire-report-plugin</artifactId>
209
+            </plugin>
210
+            <!-- Test coverage -->
211
+            <plugin>
212
+                <groupId>org.codehaus.mojo</groupId>
213
+                <artifactId>cobertura-maven-plugin</artifactId>
214
+            </plugin>
215
+            <!-- CheckStyle report -->
216
+            <plugin>
217
+                <artifactId>maven-checkstyle-plugin</artifactId>
218
+                <configuration>
219
+                    <configLocation>src/main/config/checkstyle.xml</configLocation>
220
+                    <!-- Java source code generated from WSDL -->
221
+                    <excludes>**/com/aggregator/**/*</excludes>
222
+                </configuration>
223
+            </plugin>
224
+        </plugins>
225
+    </reporting>
306
 </project>
226
 </project>

+ 60
- 0
src/main/java/se/citerus/dddsample/Application.java Voir le fichier

1
+package se.citerus.dddsample;
2
+
3
+import org.hibernate.SessionFactory;
4
+import org.springframework.beans.factory.annotation.Autowired;
5
+import org.springframework.boot.SpringApplication;
6
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
7
+import org.springframework.context.annotation.Bean;
8
+import org.springframework.context.annotation.Configuration;
9
+import org.springframework.context.annotation.ImportResource;
10
+import org.springframework.transaction.PlatformTransactionManager;
11
+import se.citerus.dddsample.application.util.SampleDataGenerator;
12
+import se.citerus.dddsample.domain.model.cargo.CargoRepository;
13
+import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
14
+import se.citerus.dddsample.domain.model.location.LocationRepository;
15
+import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
16
+
17
+import javax.annotation.PostConstruct;
18
+
19
+@Configuration
20
+@ImportResource({
21
+        "classpath:/com/pathfinder/internal/applicationContext.xml",
22
+        "classpath:context-infrastructure.xml",
23
+        "classpath:context-application.xml",
24
+        "classpath:context-domain.xml",
25
+        "classpath:context-interfaces.xml"})
26
+@EnableAutoConfiguration
27
+public class Application {
28
+
29
+    @Autowired
30
+    PlatformTransactionManager platformTransactionManager;
31
+
32
+    @Autowired
33
+    SessionFactory sessionFactory;
34
+
35
+    @Autowired
36
+    CargoRepository cargoRepository;
37
+
38
+    @Autowired
39
+    VoyageRepository voyageRepository;
40
+
41
+    @Autowired
42
+    LocationRepository locationRepository;
43
+
44
+    @Autowired
45
+    HandlingEventRepository handlingEventRepository;
46
+
47
+    @Bean
48
+    public SampleDataGenerator sampleDataGenerator() {
49
+        return new SampleDataGenerator(platformTransactionManager, sessionFactory, cargoRepository, voyageRepository, locationRepository, handlingEventRepository);
50
+    }
51
+
52
+    @PostConstruct
53
+    public void init() {
54
+        sampleDataGenerator().generate();
55
+    }
56
+
57
+    public static void main(String[] args) throws Exception {
58
+        SpringApplication.run(Application.class, args);
59
+    }
60
+}

+ 1
- 1
src/main/java/se/citerus/dddsample/application/impl/BookingServiceImpl.java Voir le fichier

14
 import java.util.Date;
14
 import java.util.Date;
15
 import java.util.List;
15
 import java.util.List;
16
 
16
 
17
-public final class BookingServiceImpl implements BookingService {
17
+public class BookingServiceImpl implements BookingService {
18
 
18
 
19
   private final CargoRepository cargoRepository;
19
   private final CargoRepository cargoRepository;
20
   private final LocationRepository locationRepository;
20
   private final LocationRepository locationRepository;

+ 1
- 1
src/main/java/se/citerus/dddsample/application/impl/HandlingEventServiceImpl.java Voir le fichier

15
 
15
 
16
 import java.util.Date;
16
 import java.util.Date;
17
 
17
 
18
-public final class HandlingEventServiceImpl implements HandlingEventService {
18
+public class HandlingEventServiceImpl implements HandlingEventService {
19
 
19
 
20
   private final ApplicationEvents applicationEvents;
20
   private final ApplicationEvents applicationEvents;
21
   private final HandlingEventRepository handlingEventRepository;
21
   private final HandlingEventRepository handlingEventRepository;

+ 302
- 295
src/main/java/se/citerus/dddsample/application/util/SampleDataGenerator.java Voir le fichier

1
 package se.citerus.dddsample.application.util;
1
 package se.citerus.dddsample.application.util;
2
 
2
 
3
-import org.hibernate.SessionFactory;
4
 import org.hibernate.Session;
3
 import org.hibernate.Session;
5
-import org.springframework.beans.factory.BeanFactoryUtils;
4
+import org.hibernate.SessionFactory;
6
 import org.springframework.jdbc.core.JdbcTemplate;
5
 import org.springframework.jdbc.core.JdbcTemplate;
7
 import org.springframework.transaction.PlatformTransactionManager;
6
 import org.springframework.transaction.PlatformTransactionManager;
8
 import org.springframework.transaction.TransactionStatus;
7
 import org.springframework.transaction.TransactionStatus;
9
 import org.springframework.transaction.support.TransactionCallbackWithoutResult;
8
 import org.springframework.transaction.support.TransactionCallbackWithoutResult;
10
 import org.springframework.transaction.support.TransactionTemplate;
9
 import org.springframework.transaction.support.TransactionTemplate;
11
-import org.springframework.web.context.WebApplicationContext;
12
-import org.springframework.web.context.support.WebApplicationContextUtils;
13
-import static se.citerus.dddsample.application.util.DateTestUtil.toDate;
14
 import se.citerus.dddsample.domain.model.cargo.*;
10
 import se.citerus.dddsample.domain.model.cargo.*;
15
 import se.citerus.dddsample.domain.model.handling.*;
11
 import se.citerus.dddsample.domain.model.handling.*;
16
 import se.citerus.dddsample.domain.model.location.Location;
12
 import se.citerus.dddsample.domain.model.location.Location;
17
 import se.citerus.dddsample.domain.model.location.LocationRepository;
13
 import se.citerus.dddsample.domain.model.location.LocationRepository;
18
 import se.citerus.dddsample.domain.model.location.SampleLocations;
14
 import se.citerus.dddsample.domain.model.location.SampleLocations;
19
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
20
-import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.*;
21
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
15
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
22
 
16
 
23
-import javax.servlet.ServletContextEvent;
24
-import javax.servlet.ServletContextListener;
25
-import javax.sql.DataSource;
26
 import java.sql.Timestamp;
17
 import java.sql.Timestamp;
27
 import java.text.ParseException;
18
 import java.text.ParseException;
28
 import java.text.SimpleDateFormat;
19
 import java.text.SimpleDateFormat;
29
-import static java.util.Arrays.asList;
30
 import java.util.Date;
20
 import java.util.Date;
31
 
21
 
22
+import static java.util.Arrays.asList;
23
+import static java.util.Objects.requireNonNull;
24
+import static se.citerus.dddsample.application.util.DateTestUtil.toDate;
25
+import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
26
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.*;
27
+
32
 /**
28
 /**
33
  * Provides sample data.
29
  * Provides sample data.
34
  */
30
  */
35
-public class SampleDataGenerator implements ServletContextListener {
36
-
37
-  private static final Timestamp base; 
38
-  static {
39
-    try {
40
-      Date date = new SimpleDateFormat("yyyy-MM-dd").parse("2008-01-01");
41
-      base = new Timestamp(date.getTime() - 1000L * 60 * 60 * 24 * 100);
42
-    } catch (ParseException e) {
43
-      throw new RuntimeException(e);
44
-    }
45
-  }
46
-
47
-  private static void loadHandlingEventData(JdbcTemplate jdbcTemplate) {
48
-    String handlingEventSql =
49
-      "insert into HandlingEvent (completionTime, registrationTime, type, location_id, voyage_id, cargo_id) " +
50
-      "values (?, ?, ?, ?, ?, ?)";
51
-
52
-    Object[][] handlingEventArgs = {
53
-        //XYZ (SESTO-FIHEL-DEHAM-CNHKG-JPTOK-AUMEL)
54
-        {ts(0),     ts((0)),    "RECEIVE",  1,  null,  1},
55
-        {ts((4)),   ts((5)),    "LOAD",     1,  1,     1},
56
-        {ts((14)),  ts((14)),   "UNLOAD",   5,  1,     1},
57
-        {ts((15)),  ts((15)),   "LOAD",     5,  1,     1},
58
-        {ts((30)),  ts((30)),   "UNLOAD",   6,  1,     1},
59
-        {ts((33)),  ts((33)),   "LOAD",     6,  1,     1},
60
-        {ts((34)),  ts((34)),   "UNLOAD",   3,  1,     1},
61
-        {ts((60)),  ts((60)),   "LOAD",     3,  1,     1},
62
-        {ts((70)),  ts((71)),   "UNLOAD",   4,  1,     1},
63
-        {ts((75)),  ts((75)),   "LOAD",     4,  1,     1},
64
-        {ts((88)),  ts((88)),   "UNLOAD",   2,  1,     1},
65
-        {ts((100)), ts((102)),  "CLAIM",    2,  null,  1},
66
-
67
-        //ZYX (AUMEL - USCHI - DEHAM -)
68
-        {ts((200)),   ts((201)),  "RECEIVE",  2,  null,  3},
69
-        {ts((202)),   ts((202)),  "LOAD",     2,  2,     3},
70
-        {ts((208)),   ts((208)),  "UNLOAD",   7,  2,     3},
71
-        {ts((212)),   ts((212)),  "LOAD",     7,  2,     3},
72
-        {ts((230)),   ts((230)),  "UNLOAD",   6,  2,     3},
73
-        {ts((235)),   ts((235)),  "LOAD",     6,  2,     3},
74
-
75
-        //ABC
76
-        {ts((20)),  ts((21)),   "CLAIM",    2,  null,  2},
77
-
78
-        //CBA
79
-        {ts((0)),   ts((1)),    "RECEIVE",  2,  null,  4},
80
-        {ts((10)),  ts((11)),   "LOAD",     2,  2,     4},
81
-        {ts((20)),  ts((21)),   "UNLOAD",   7,  2,     4},
82
-
83
-        //FGH
84
-        {ts(100),   ts(160),    "RECEIVE",  3,  null,   5},
85
-        {ts(150),   ts(110),    "LOAD",     3,  3,     5},
86
-
87
-        // JKL
88
-        {ts(200),   ts(220),    "RECEIVE",  6,  null,   6},
89
-        {ts(300),   ts(330),    "LOAD",     6,  3,     6},
90
-        {ts(400),   ts(440),    "UNLOAD",   5,  3,     6}  // Unexpected event
91
-    };
92
-    executeUpdate(jdbcTemplate, handlingEventSql, handlingEventArgs);
93
-  }
94
-
95
-  private static void loadCarrierMovementData(JdbcTemplate jdbcTemplate) {
96
-    String voyageSql =
97
-      "insert into Voyage (id, voyage_number) values (?, ?)";
98
-    Object[][] voyageArgs = {
99
-      {1,"0101"},
100
-      {2,"0202"},
101
-      {3,"0303"}
102
-    };
103
-    executeUpdate(jdbcTemplate, voyageSql, voyageArgs);
104
-
105
-    String carrierMovementSql =
106
-      "insert into CarrierMovement (id, voyage_id, departure_location_id, arrival_location_id, departure_time, arrival_time, cm_index) " +
107
-      "values (?,?,?,?,?,?,?)";
108
-
109
-    Object[][] carrierMovementArgs = {
110
-      // SESTO - FIHEL - DEHAM - CNHKG - JPTOK - AUMEL (voyage 0101)
111
-      {1,1,1,5,ts(1),ts(2),0},
112
-      {2,1,5,6,ts(1),ts(2),1},
113
-      {3,1,6,3,ts(1),ts(2),2},
114
-      {4,1,3,4,ts(1),ts(2),3},
115
-      {5,1,4,2,ts(1),ts(2),4},
116
-
117
-      // AUMEL - USCHI - DEHAM - SESTO - FIHEL (voyage 0202)
118
-      {7,2,2,7,ts(1),ts(2),0},
119
-      {8,2,7,6,ts(1),ts(2),1},
120
-      {9,2,6,1,ts(1),ts(2),2},
121
-      {6,2,1,5,ts(1),ts(2),3},
122
-
123
-      // CNHKG - AUMEL - FIHEL - DEHAM - SESTO - USCHI - JPTKO (voyage 0303)
124
-      {10,3,3,2,ts(1),ts(2),0},
125
-      {11,3,2,5,ts(1),ts(2),1},
126
-      {12,3,6,1,ts(1),ts(2),2},
127
-      {13,3,1,7,ts(1),ts(2),3},
128
-      {14,3,7,4,ts(1),ts(2),4}
129
-    };
130
-    executeUpdate(jdbcTemplate, carrierMovementSql, carrierMovementArgs);
131
-  }
132
-
133
-  private static void loadCargoData(JdbcTemplate jdbcTemplate) {
134
-    String cargoSql =
135
-      "insert into Cargo (id, tracking_id, origin_id, spec_origin_id, spec_destination_id, spec_arrival_deadline, transport_status, current_voyage_id, last_known_location_id, is_misdirected, routing_status, calculated_at, unloaded_at_dest) " +
136
-      "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
137
-
138
-    Object[][] cargoArgs = {
139
-      {1, "XYZ", 1, 1, 2, ts(10), "IN_PORT", null, 1, false, "ROUTED", ts(100), false},
140
-      {2, "ABC", 1, 1, 5, ts(20), "IN_PORT", null, 1, false, "ROUTED", ts(100), false},
141
-      {3, "ZYX", 2, 2, 1, ts(30), "IN_PORT", null, 1, false, "NOT_ROUTED", ts(100), false},
142
-      {4, "CBA", 5, 5, 1, ts(40), "IN_PORT", null, 1, false, "MISROUTED", ts(100), false},
143
-      {5, "FGH", 1, 3, 5, ts(50), "IN_PORT", null, 1, false, "ROUTED", ts(100), false},  // Cargo origin differs from spec origin
144
-      {6, "JKL", 6, 6, 4, ts(60), "IN_PORT", null, 1, true, "ROUTED", ts(100), false}
145
-    };
146
-    executeUpdate(jdbcTemplate, cargoSql, cargoArgs);
147
-  }
148
-
149
-  private static void loadLocationData(JdbcTemplate jdbcTemplate) {
150
-    String locationSql =
151
-      "insert into Location (id, unlocode, name) " +
152
-      "values (?, ?, ?)";
153
-
154
-    Object[][] locationArgs = {
155
-      {1, "SESTO", "Stockholm"},
156
-      {2, "AUMEL", "Melbourne"},
157
-      {3, "CNHKG", "Hongkong"},
158
-      {4, "JPTOK", "Tokyo"},
159
-      {5, "FIHEL", "Helsinki"},
160
-      {6, "DEHAM", "Hamburg"},
161
-      {7, "USCHI", "Chicago"}
162
-    };
163
-    executeUpdate(jdbcTemplate, locationSql, locationArgs);
164
-  }
165
-
166
-  private static void loadItineraryData(JdbcTemplate jdbcTemplate) {
167
-    String legSql =
168
-      "insert into Leg (id, cargo_id, voyage_id, load_location_id, unload_location_id, load_time, unload_time, leg_index) " +
169
-      "values (?,?,?,?,?,?,?,?)";
170
-
171
-    Object [][] legArgs = {
172
-      // Cargo 5: Hongkong - Melbourne - Stockholm - Helsinki
173
-      {1,5,1,3,2,ts(1),ts(2),0},
174
-      {2,5,1,2,1,ts(3),ts(4),1},
175
-      {3,5,1,1,5,ts(4),ts(5),2},
176
-      // Cargo 6: Hamburg - Stockholm - Chicago - Tokyo
177
-      {4,6,2,6,1,ts(1),ts(2),0},
178
-      {5,6,2,1,7,ts(3),ts(4),1},
179
-      {6,6,2,7,4,ts(5),ts(6),2}
180
-    };
181
-    executeUpdate(jdbcTemplate, legSql, legArgs);
182
-  }
183
-
184
-  public void contextInitialized(ServletContextEvent event) {
185
-    WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(event.getServletContext());
186
-    DataSource dataSource = (DataSource) BeanFactoryUtils.beanOfType(context, DataSource.class);
187
-    PlatformTransactionManager transactionManager = (PlatformTransactionManager) BeanFactoryUtils.beanOfType(context, PlatformTransactionManager.class);
188
-    TransactionTemplate tt = new TransactionTemplate(transactionManager);
189
-    //loadSampleData(new JdbcTemplate(dataSource), tt);
190
-
191
-
192
-    SessionFactory sf = (SessionFactory) BeanFactoryUtils.beanOfType(context, SessionFactory.class);
193
-    HandlingEventFactory handlingEventFactory = new HandlingEventFactory(
194
-      getBean(context, CargoRepository.class),
195
-      getBean(context, VoyageRepository.class),
196
-      getBean(context, LocationRepository.class));
197
-    loadHibernateData(tt, sf, handlingEventFactory, getBean(context, HandlingEventRepository.class));
198
-  }
199
-
200
-  private <T> T getBean(WebApplicationContext context, Class<T> cls) {
201
-    return (T) BeanFactoryUtils.beanOfType(context, cls);
202
-  }
203
-
204
-  public static void loadHibernateData(TransactionTemplate tt, final SessionFactory sf, final HandlingEventFactory handlingEventFactory, final HandlingEventRepository handlingEventRepository) {
205
-    System.out.println("*** Loading Hibernate data ***");
206
-    tt.execute(new TransactionCallbackWithoutResult() {
207
-      @Override
208
-      protected void doInTransactionWithoutResult(TransactionStatus status) {
209
-        Session session = sf.getCurrentSession();
210
-
211
-        for (Location location : SampleLocations.getAll()) {
212
-          session.save(location);
213
-        }
31
+public class SampleDataGenerator {
32
+
33
+    private static final Timestamp base;
214
 
34
 
215
-        session.save(HONGKONG_TO_NEW_YORK);
216
-        session.save(NEW_YORK_TO_DALLAS);
217
-        session.save(DALLAS_TO_HELSINKI);
218
-        session.save(HELSINKI_TO_HONGKONG);
219
-        session.save(DALLAS_TO_HELSINKI_ALT);
220
-
221
-        RouteSpecification routeSpecification = new RouteSpecification(HONGKONG, HELSINKI, toDate("2009-03-15"));
222
-        TrackingId trackingId = new TrackingId("ABC123");
223
-        Cargo abc123 = new Cargo(trackingId, routeSpecification);
224
-
225
-        Itinerary itinerary = new Itinerary(asList(
226
-          new Leg(HONGKONG_TO_NEW_YORK, HONGKONG, NEWYORK, toDate("2009-03-02"), toDate("2009-03-05")),
227
-          new Leg(NEW_YORK_TO_DALLAS, NEWYORK, DALLAS, toDate("2009-03-06"), toDate("2009-03-08")),
228
-          new Leg(DALLAS_TO_HELSINKI, DALLAS, HELSINKI, toDate("2009-03-09"), toDate("2009-03-12"))
229
-        ));
230
-        abc123.assignToRoute(itinerary);
231
-
232
-        session.save(abc123);
233
-        
35
+    static {
234
         try {
36
         try {
235
-          HandlingEvent event1 = handlingEventFactory.createHandlingEvent(
236
-            new Date(), toDate("2009-03-01"), trackingId, null, HONGKONG.unLocode(), HandlingEvent.Type.RECEIVE
237
-          );
238
-          session.save(event1);
239
-
240
-          HandlingEvent event2 = handlingEventFactory.createHandlingEvent(
241
-            new Date(), toDate("2009-03-02"), trackingId, HONGKONG_TO_NEW_YORK.voyageNumber(), HONGKONG.unLocode(), HandlingEvent.Type.LOAD
242
-          );
243
-          session.save(event2);
244
-
245
-          HandlingEvent event3 = handlingEventFactory.createHandlingEvent(
246
-            new Date(), toDate("2009-03-05"), trackingId, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.UNLOAD
247
-          );
248
-          session.save(event3);
249
-        } catch (CannotCreateHandlingEventException e) {
250
-          throw new RuntimeException(e);
37
+            Date date = new SimpleDateFormat("yyyy-MM-dd").parse("2008-01-01");
38
+            base = new Timestamp(date.getTime() - 1000L * 60 * 60 * 24 * 100);
39
+        } catch (ParseException e) {
40
+            throw new RuntimeException(e);
251
         }
41
         }
42
+    }
43
+
44
+    private final PlatformTransactionManager transactionManager;
45
+    private final SessionFactory sf;
46
+    private final CargoRepository cargoRepository;
47
+    private final VoyageRepository voyageRepository;
48
+    private final LocationRepository locationRepository;
49
+    private final HandlingEventRepository handlingEventRepository;
50
+
51
+    public SampleDataGenerator(PlatformTransactionManager transactionManager,
52
+                               SessionFactory sf,
53
+                               CargoRepository cargoRepository,
54
+                               VoyageRepository voyageRepository,
55
+                               LocationRepository locationRepository,
56
+                               HandlingEventRepository handlingEventRepository) {
57
+        this.transactionManager = requireNonNull(transactionManager);
58
+        this.sf = requireNonNull(sf);
59
+        this.cargoRepository = requireNonNull(cargoRepository);
60
+        this.voyageRepository = requireNonNull(voyageRepository);
61
+        this.locationRepository = requireNonNull(locationRepository);
62
+        this.handlingEventRepository = requireNonNull(handlingEventRepository);
63
+    }
252
 
64
 
253
-        HandlingHistory handlingHistory = handlingEventRepository.lookupHandlingHistoryOfCargo(trackingId);
254
-        abc123.deriveDeliveryProgress(handlingHistory);
65
+    private static void loadHandlingEventData(JdbcTemplate jdbcTemplate) {
66
+        String handlingEventSql =
67
+                "insert into HandlingEvent (completionTime, registrationTime, type, location_id, voyage_id, cargo_id) " +
68
+                        "values (?, ?, ?, ?, ?, ?)";
69
+
70
+        Object[][] handlingEventArgs = {
71
+                //XYZ (SESTO-FIHEL-DEHAM-CNHKG-JPTOK-AUMEL)
72
+                {ts(0), ts((0)), "RECEIVE", 1, null, 1},
73
+                {ts((4)), ts((5)), "LOAD", 1, 1, 1},
74
+                {ts((14)), ts((14)), "UNLOAD", 5, 1, 1},
75
+                {ts((15)), ts((15)), "LOAD", 5, 1, 1},
76
+                {ts((30)), ts((30)), "UNLOAD", 6, 1, 1},
77
+                {ts((33)), ts((33)), "LOAD", 6, 1, 1},
78
+                {ts((34)), ts((34)), "UNLOAD", 3, 1, 1},
79
+                {ts((60)), ts((60)), "LOAD", 3, 1, 1},
80
+                {ts((70)), ts((71)), "UNLOAD", 4, 1, 1},
81
+                {ts((75)), ts((75)), "LOAD", 4, 1, 1},
82
+                {ts((88)), ts((88)), "UNLOAD", 2, 1, 1},
83
+                {ts((100)), ts((102)), "CLAIM", 2, null, 1},
84
+
85
+                //ZYX (AUMEL - USCHI - DEHAM -)
86
+                {ts((200)), ts((201)), "RECEIVE", 2, null, 3},
87
+                {ts((202)), ts((202)), "LOAD", 2, 2, 3},
88
+                {ts((208)), ts((208)), "UNLOAD", 7, 2, 3},
89
+                {ts((212)), ts((212)), "LOAD", 7, 2, 3},
90
+                {ts((230)), ts((230)), "UNLOAD", 6, 2, 3},
91
+                {ts((235)), ts((235)), "LOAD", 6, 2, 3},
92
+
93
+                //ABC
94
+                {ts((20)), ts((21)), "CLAIM", 2, null, 2},
95
+
96
+                //CBA
97
+                {ts((0)), ts((1)), "RECEIVE", 2, null, 4},
98
+                {ts((10)), ts((11)), "LOAD", 2, 2, 4},
99
+                {ts((20)), ts((21)), "UNLOAD", 7, 2, 4},
100
+
101
+                //FGH
102
+                {ts(100), ts(160), "RECEIVE", 3, null, 5},
103
+                {ts(150), ts(110), "LOAD", 3, 3, 5},
104
+
105
+                // JKL
106
+                {ts(200), ts(220), "RECEIVE", 6, null, 6},
107
+                {ts(300), ts(330), "LOAD", 6, 3, 6},
108
+                {ts(400), ts(440), "UNLOAD", 5, 3, 6}  // Unexpected event
109
+        };
110
+        executeUpdate(jdbcTemplate, handlingEventSql, handlingEventArgs);
111
+    }
255
 
112
 
256
-        session.update(abc123);
113
+    private static void loadCarrierMovementData(JdbcTemplate jdbcTemplate) {
114
+        String voyageSql =
115
+                "insert into Voyage (id, voyage_number) values (?, ?)";
116
+        Object[][] voyageArgs = {
117
+                {1, "0101"},
118
+                {2, "0202"},
119
+                {3, "0303"}
120
+        };
121
+        executeUpdate(jdbcTemplate, voyageSql, voyageArgs);
122
+
123
+        String carrierMovementSql =
124
+                "insert into CarrierMovement (id, voyage_id, departure_location_id, arrival_location_id, departure_time, arrival_time, cm_index) " +
125
+                        "values (?,?,?,?,?,?,?)";
126
+
127
+        Object[][] carrierMovementArgs = {
128
+                // SESTO - FIHEL - DEHAM - CNHKG - JPTOK - AUMEL (voyage 0101)
129
+                {1, 1, 1, 5, ts(1), ts(2), 0},
130
+                {2, 1, 5, 6, ts(1), ts(2), 1},
131
+                {3, 1, 6, 3, ts(1), ts(2), 2},
132
+                {4, 1, 3, 4, ts(1), ts(2), 3},
133
+                {5, 1, 4, 2, ts(1), ts(2), 4},
134
+
135
+                // AUMEL - USCHI - DEHAM - SESTO - FIHEL (voyage 0202)
136
+                {7, 2, 2, 7, ts(1), ts(2), 0},
137
+                {8, 2, 7, 6, ts(1), ts(2), 1},
138
+                {9, 2, 6, 1, ts(1), ts(2), 2},
139
+                {6, 2, 1, 5, ts(1), ts(2), 3},
140
+
141
+                // CNHKG - AUMEL - FIHEL - DEHAM - SESTO - USCHI - JPTKO (voyage 0303)
142
+                {10, 3, 3, 2, ts(1), ts(2), 0},
143
+                {11, 3, 2, 5, ts(1), ts(2), 1},
144
+                {12, 3, 6, 1, ts(1), ts(2), 2},
145
+                {13, 3, 1, 7, ts(1), ts(2), 3},
146
+                {14, 3, 7, 4, ts(1), ts(2), 4}
147
+        };
148
+        executeUpdate(jdbcTemplate, carrierMovementSql, carrierMovementArgs);
149
+    }
257
 
150
 
258
-        // Cargo JKL567
151
+    private static void loadCargoData(JdbcTemplate jdbcTemplate) {
152
+        String cargoSql =
153
+                "insert into Cargo (id, tracking_id, origin_id, spec_origin_id, spec_destination_id, spec_arrival_deadline, transport_status, current_voyage_id, last_known_location_id, is_misdirected, routing_status, calculated_at, unloaded_at_dest) " +
154
+                        "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
155
+
156
+        Object[][] cargoArgs = {
157
+                {1, "XYZ", 1, 1, 2, ts(10), "IN_PORT", null, 1, false, "ROUTED", ts(100), false},
158
+                {2, "ABC", 1, 1, 5, ts(20), "IN_PORT", null, 1, false, "ROUTED", ts(100), false},
159
+                {3, "ZYX", 2, 2, 1, ts(30), "IN_PORT", null, 1, false, "NOT_ROUTED", ts(100), false},
160
+                {4, "CBA", 5, 5, 1, ts(40), "IN_PORT", null, 1, false, "MISROUTED", ts(100), false},
161
+                {5, "FGH", 1, 3, 5, ts(50), "IN_PORT", null, 1, false, "ROUTED", ts(100), false},  // Cargo origin differs from spec origin
162
+                {6, "JKL", 6, 6, 4, ts(60), "IN_PORT", null, 1, true, "ROUTED", ts(100), false}
163
+        };
164
+        executeUpdate(jdbcTemplate, cargoSql, cargoArgs);
165
+    }
259
 
166
 
260
-        RouteSpecification routeSpecification1 = new RouteSpecification(HANGZOU, STOCKHOLM, toDate("2009-03-18"));
261
-        TrackingId trackingId1 = new TrackingId("JKL567");
262
-        Cargo jkl567 = new Cargo(trackingId1, routeSpecification1);
167
+    private static void loadLocationData(JdbcTemplate jdbcTemplate) {
168
+        String locationSql =
169
+                "insert into Location (id, unlocode, name) " +
170
+                        "values (?, ?, ?)";
171
+
172
+        Object[][] locationArgs = {
173
+                {1, "SESTO", "Stockholm"},
174
+                {2, "AUMEL", "Melbourne"},
175
+                {3, "CNHKG", "Hongkong"},
176
+                {4, "JPTOK", "Tokyo"},
177
+                {5, "FIHEL", "Helsinki"},
178
+                {6, "DEHAM", "Hamburg"},
179
+                {7, "USCHI", "Chicago"}
180
+        };
181
+        executeUpdate(jdbcTemplate, locationSql, locationArgs);
182
+    }
263
 
183
 
264
-        Itinerary itinerary1 = new Itinerary(asList(
265
-          new Leg(HONGKONG_TO_NEW_YORK, HANGZOU, NEWYORK, toDate("2009-03-03"), toDate("2009-03-05")),
266
-          new Leg(NEW_YORK_TO_DALLAS, NEWYORK, DALLAS, toDate("2009-03-06"), toDate("2009-03-08")),
267
-          new Leg(DALLAS_TO_HELSINKI, DALLAS, STOCKHOLM, toDate("2009-03-09"), toDate("2009-03-11"))
268
-        ));
269
-        jkl567.assignToRoute(itinerary1);
184
+    private static void loadItineraryData(JdbcTemplate jdbcTemplate) {
185
+        String legSql =
186
+                "insert into Leg (id, cargo_id, voyage_id, load_location_id, unload_location_id, load_time, unload_time, leg_index) " +
187
+                        "values (?,?,?,?,?,?,?,?)";
188
+
189
+        Object[][] legArgs = {
190
+                // Cargo 5: Hongkong - Melbourne - Stockholm - Helsinki
191
+                {1, 5, 1, 3, 2, ts(1), ts(2), 0},
192
+                {2, 5, 1, 2, 1, ts(3), ts(4), 1},
193
+                {3, 5, 1, 1, 5, ts(4), ts(5), 2},
194
+                // Cargo 6: Hamburg - Stockholm - Chicago - Tokyo
195
+                {4, 6, 2, 6, 1, ts(1), ts(2), 0},
196
+                {5, 6, 2, 1, 7, ts(3), ts(4), 1},
197
+                {6, 6, 2, 7, 4, ts(5), ts(6), 2}
198
+        };
199
+        executeUpdate(jdbcTemplate, legSql, legArgs);
200
+    }
270
 
201
 
271
-        session.save(jkl567);
202
+    public void generate() {
203
+        TransactionTemplate tt = new TransactionTemplate(transactionManager);
204
+        //loadSampleData(new JdbcTemplate(dataSource), tt);
272
 
205
 
273
-        try {
274
-          HandlingEvent event1 = handlingEventFactory.createHandlingEvent(
275
-            new Date(), toDate("2009-03-01"), trackingId1, null, HANGZOU.unLocode(), HandlingEvent.Type.RECEIVE
276
-          );
277
-          session.save(event1);
278
-
279
-          HandlingEvent event2 = handlingEventFactory.createHandlingEvent(
280
-            new Date(), toDate("2009-03-03"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), HANGZOU.unLocode(), HandlingEvent.Type.LOAD
281
-          );
282
-          session.save(event2);
283
-
284
-          HandlingEvent event3 = handlingEventFactory.createHandlingEvent(
285
-            new Date(), toDate("2009-03-05"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.UNLOAD
286
-          );
287
-          session.save(event3);
288
-
289
-          HandlingEvent event4 = handlingEventFactory.createHandlingEvent(
290
-            new Date(), toDate("2009-03-06"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.LOAD
291
-          );
292
-          session.save(event4);
293
-
294
-        } catch (CannotCreateHandlingEventException e) {
295
-          throw new RuntimeException(e);
296
-        }
206
+        HandlingEventFactory handlingEventFactory = new HandlingEventFactory(
207
+                cargoRepository,
208
+                voyageRepository,
209
+                locationRepository);
210
+        loadHibernateData(tt, sf, handlingEventFactory, handlingEventRepository);
211
+    }
212
+
213
+    public static void loadHibernateData(TransactionTemplate tt, final SessionFactory sf, final HandlingEventFactory handlingEventFactory, final HandlingEventRepository handlingEventRepository) {
214
+        System.out.println("*** Loading Hibernate data ***");
215
+        tt.execute(new TransactionCallbackWithoutResult() {
216
+            @Override
217
+            protected void doInTransactionWithoutResult(TransactionStatus status) {
218
+                Session session = sf.getCurrentSession();
219
+
220
+                for (Location location : SampleLocations.getAll()) {
221
+                    session.save(location);
222
+                }
223
+
224
+                session.save(HONGKONG_TO_NEW_YORK);
225
+                session.save(NEW_YORK_TO_DALLAS);
226
+                session.save(DALLAS_TO_HELSINKI);
227
+                session.save(HELSINKI_TO_HONGKONG);
228
+                session.save(DALLAS_TO_HELSINKI_ALT);
229
+
230
+                RouteSpecification routeSpecification = new RouteSpecification(HONGKONG, HELSINKI, toDate("2009-03-15"));
231
+                TrackingId trackingId = new TrackingId("ABC123");
232
+                Cargo abc123 = new Cargo(trackingId, routeSpecification);
233
+
234
+                Itinerary itinerary = new Itinerary(asList(
235
+                        new Leg(HONGKONG_TO_NEW_YORK, HONGKONG, NEWYORK, toDate("2009-03-02"), toDate("2009-03-05")),
236
+                        new Leg(NEW_YORK_TO_DALLAS, NEWYORK, DALLAS, toDate("2009-03-06"), toDate("2009-03-08")),
237
+                        new Leg(DALLAS_TO_HELSINKI, DALLAS, HELSINKI, toDate("2009-03-09"), toDate("2009-03-12"))
238
+                ));
239
+                abc123.assignToRoute(itinerary);
240
+
241
+                session.save(abc123);
242
+
243
+                try {
244
+                    HandlingEvent event1 = handlingEventFactory.createHandlingEvent(
245
+                            new Date(), toDate("2009-03-01"), trackingId, null, HONGKONG.unLocode(), HandlingEvent.Type.RECEIVE
246
+                    );
247
+                    session.save(event1);
248
+
249
+                    HandlingEvent event2 = handlingEventFactory.createHandlingEvent(
250
+                            new Date(), toDate("2009-03-02"), trackingId, HONGKONG_TO_NEW_YORK.voyageNumber(), HONGKONG.unLocode(), HandlingEvent.Type.LOAD
251
+                    );
252
+                    session.save(event2);
253
+
254
+                    HandlingEvent event3 = handlingEventFactory.createHandlingEvent(
255
+                            new Date(), toDate("2009-03-05"), trackingId, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.UNLOAD
256
+                    );
257
+                    session.save(event3);
258
+                } catch (CannotCreateHandlingEventException e) {
259
+                    throw new RuntimeException(e);
260
+                }
261
+
262
+                HandlingHistory handlingHistory = handlingEventRepository.lookupHandlingHistoryOfCargo(trackingId);
263
+                abc123.deriveDeliveryProgress(handlingHistory);
264
+
265
+                session.update(abc123);
266
+
267
+                // Cargo JKL567
268
+
269
+                RouteSpecification routeSpecification1 = new RouteSpecification(HANGZOU, STOCKHOLM, toDate("2009-03-18"));
270
+                TrackingId trackingId1 = new TrackingId("JKL567");
271
+                Cargo jkl567 = new Cargo(trackingId1, routeSpecification1);
272
+
273
+                Itinerary itinerary1 = new Itinerary(asList(
274
+                        new Leg(HONGKONG_TO_NEW_YORK, HANGZOU, NEWYORK, toDate("2009-03-03"), toDate("2009-03-05")),
275
+                        new Leg(NEW_YORK_TO_DALLAS, NEWYORK, DALLAS, toDate("2009-03-06"), toDate("2009-03-08")),
276
+                        new Leg(DALLAS_TO_HELSINKI, DALLAS, STOCKHOLM, toDate("2009-03-09"), toDate("2009-03-11"))
277
+                ));
278
+                jkl567.assignToRoute(itinerary1);
279
+
280
+                session.save(jkl567);
281
+
282
+                try {
283
+                    HandlingEvent event1 = handlingEventFactory.createHandlingEvent(
284
+                            new Date(), toDate("2009-03-01"), trackingId1, null, HANGZOU.unLocode(), HandlingEvent.Type.RECEIVE
285
+                    );
286
+                    session.save(event1);
287
+
288
+                    HandlingEvent event2 = handlingEventFactory.createHandlingEvent(
289
+                            new Date(), toDate("2009-03-03"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), HANGZOU.unLocode(), HandlingEvent.Type.LOAD
290
+                    );
291
+                    session.save(event2);
292
+
293
+                    HandlingEvent event3 = handlingEventFactory.createHandlingEvent(
294
+                            new Date(), toDate("2009-03-05"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.UNLOAD
295
+                    );
296
+                    session.save(event3);
297
+
298
+                    HandlingEvent event4 = handlingEventFactory.createHandlingEvent(
299
+                            new Date(), toDate("2009-03-06"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.LOAD
300
+                    );
301
+                    session.save(event4);
302
+
303
+                } catch (CannotCreateHandlingEventException e) {
304
+                    throw new RuntimeException(e);
305
+                }
306
+
307
+                HandlingHistory handlingHistory1 = handlingEventRepository.lookupHandlingHistoryOfCargo(trackingId1);
308
+                jkl567.deriveDeliveryProgress(handlingHistory1);
309
+
310
+                session.update(jkl567);
311
+            }
312
+        });
313
+    }
314
+
315
+    public static void loadSampleData(final JdbcTemplate jdbcTemplate, TransactionTemplate transactionTemplate) {
316
+        transactionTemplate.execute(new TransactionCallbackWithoutResult() {
317
+            protected void doInTransactionWithoutResult(TransactionStatus status) {
318
+                loadLocationData(jdbcTemplate);
319
+                loadCarrierMovementData(jdbcTemplate);
320
+                loadCargoData(jdbcTemplate);
321
+                loadItineraryData(jdbcTemplate);
322
+                loadHandlingEventData(jdbcTemplate);
323
+            }
324
+        });
325
+    }
297
 
326
 
298
-        HandlingHistory handlingHistory1 = handlingEventRepository.lookupHandlingHistoryOfCargo(trackingId1);
299
-        jkl567.deriveDeliveryProgress(handlingHistory1);
300
-
301
-        session.update(jkl567);
302
-      }
303
-    });
304
-  }
305
-
306
-  public void contextDestroyed(ServletContextEvent event) {}
307
-
308
-  public static void loadSampleData(final JdbcTemplate jdbcTemplate, TransactionTemplate transactionTemplate) {
309
-    transactionTemplate.execute(new TransactionCallbackWithoutResult() {
310
-      protected void doInTransactionWithoutResult(TransactionStatus status) {
311
-        loadLocationData(jdbcTemplate);
312
-        loadCarrierMovementData(jdbcTemplate);
313
-        loadCargoData(jdbcTemplate);
314
-        loadItineraryData(jdbcTemplate);
315
-        loadHandlingEventData(jdbcTemplate);
316
-      }
317
-    });
318
-  }
319
-
320
-  private static void executeUpdate(JdbcTemplate jdbcTemplate, String sql, Object[][] args) {
321
-    for (Object[] arg : args) {
322
-      jdbcTemplate.update(sql, arg);
327
+    private static void executeUpdate(JdbcTemplate jdbcTemplate, String sql, Object[][] args) {
328
+        for (Object[] arg : args) {
329
+            jdbcTemplate.update(sql, arg);
330
+        }
323
     }
331
     }
324
-  }
325
 
332
 
326
-  private static Timestamp ts(int hours) {
327
-    return new Timestamp(base.getTime() + 1000L * 60 * 60 * hours);
328
-  }
333
+    private static Timestamp ts(int hours) {
334
+        return new Timestamp(base.getTime() + 1000L * 60 * 60 * hours);
335
+    }
329
 
336
 
330
-  public static Date offset(int hours) {
331
-    return new Date(ts(hours).getTime());
332
-  }
337
+    public static Date offset(int hours) {
338
+        return new Date(ts(hours).getTime());
339
+    }
333
 }
340
 }

+ 1
- 1
src/main/java/se/citerus/dddsample/infrastructure/persistence/hibernate/LocationRepositoryHibernate.java Voir le fichier

8
 import java.util.List;
8
 import java.util.List;
9
 
9
 
10
 @Repository
10
 @Repository
11
-public final class LocationRepositoryHibernate extends HibernateRepository implements LocationRepository {
11
+public class LocationRepositoryHibernate extends HibernateRepository implements LocationRepository {
12
 
12
 
13
   public Location find(final UnLocode unLocode) {
13
   public Location find(final UnLocode unLocode) {
14
     return (Location) getSession().
14
     return (Location) getSession().

+ 1
- 1
src/main/java/se/citerus/dddsample/infrastructure/persistence/hibernate/VoyageRepositoryHibernate.java Voir le fichier

9
  * Hibernate implementation of CarrierMovementRepository.
9
  * Hibernate implementation of CarrierMovementRepository.
10
  */
10
  */
11
 @Repository
11
 @Repository
12
-public final class VoyageRepositoryHibernate extends HibernateRepository implements VoyageRepository {
12
+public class VoyageRepositoryHibernate extends HibernateRepository implements VoyageRepository {
13
 
13
 
14
   public Voyage find(final VoyageNumber voyageNumber) {
14
   public Voyage find(final VoyageNumber voyageNumber) {
15
     return (Voyage) getSession().
15
     return (Voyage) getSession().

+ 6
- 5
src/main/java/se/citerus/dddsample/interfaces/booking/web/CargoAdminController.java Voir le fichier

33
  * @see se.citerus.dddsample.interfaces.tracking.CargoTrackingController
33
  * @see se.citerus.dddsample.interfaces.tracking.CargoTrackingController
34
  */
34
  */
35
 @Controller
35
 @Controller
36
+@RequestMapping("/admin")
36
 public final class CargoAdminController {
37
 public final class CargoAdminController {
37
 
38
 
38
     private BookingServiceFacade bookingServiceFacade;
39
     private BookingServiceFacade bookingServiceFacade;
54
 
55
 
55
         model.put("unlocodes", unLocodeStrings);
56
         model.put("unlocodes", unLocodeStrings);
56
         model.put("locations", dtoList);
57
         model.put("locations", dtoList);
57
-        return "templates/admin/registrationForm";
58
+        return "admin/registrationForm";
58
     }
59
     }
59
 
60
 
60
     @RequestMapping(value = "/register", method = RequestMethod.POST)
61
     @RequestMapping(value = "/register", method = RequestMethod.POST)
72
         List<CargoRoutingDTO> cargoList = bookingServiceFacade.listAllCargos();
73
         List<CargoRoutingDTO> cargoList = bookingServiceFacade.listAllCargos();
73
 
74
 
74
         model.put("cargoList", cargoList);
75
         model.put("cargoList", cargoList);
75
-        return "templates/admin/list";
76
+        return "admin/list";
76
     }
77
     }
77
 
78
 
78
     @RequestMapping("/show")
79
     @RequestMapping("/show")
80
         String trackingId = request.getParameter("trackingId");
81
         String trackingId = request.getParameter("trackingId");
81
         CargoRoutingDTO dto = bookingServiceFacade.loadCargoForRouting(trackingId);
82
         CargoRoutingDTO dto = bookingServiceFacade.loadCargoForRouting(trackingId);
82
         model.put("cargo", dto);
83
         model.put("cargo", dto);
83
-        return "templates/admin/show";
84
+        return "admin/show";
84
     }
85
     }
85
 
86
 
86
     @RequestMapping("/selectItinerary")
87
     @RequestMapping("/selectItinerary")
93
         CargoRoutingDTO cargoDTO = bookingServiceFacade.loadCargoForRouting(trackingId);
94
         CargoRoutingDTO cargoDTO = bookingServiceFacade.loadCargoForRouting(trackingId);
94
         model.put("cargo", cargoDTO);
95
         model.put("cargo", cargoDTO);
95
 
96
 
96
-        return "templates/admin/selectItinerary";
97
+        return "admin/selectItinerary";
97
     }
98
     }
98
 
99
 
99
     @RequestMapping(value = "/assignItinerary", method = RequestMethod.POST)
100
     @RequestMapping(value = "/assignItinerary", method = RequestMethod.POST)
126
         CargoRoutingDTO cargo = bookingServiceFacade.loadCargoForRouting(trackingId);
127
         CargoRoutingDTO cargo = bookingServiceFacade.loadCargoForRouting(trackingId);
127
         model.put("cargo", cargo);
128
         model.put("cargo", cargo);
128
 
129
 
129
-        return "templates/admin/pickNewDestination";
130
+        return "admin/pickNewDestination";
130
     }
131
     }
131
 
132
 
132
     @RequestMapping(value = "/changeDestination", method = RequestMethod.POST)
133
     @RequestMapping(value = "/changeDestination", method = RequestMethod.POST)

+ 6
- 6
src/main/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingController.java Voir le fichier

13
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
13
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
14
 
14
 
15
 import javax.servlet.http.HttpServletRequest;
15
 import javax.servlet.http.HttpServletRequest;
16
-import java.util.HashMap;
17
 import java.util.List;
16
 import java.util.List;
18
 import java.util.Locale;
17
 import java.util.Locale;
19
 import java.util.Map;
18
 import java.util.Map;
41
     private MessageSource messageSource;
40
     private MessageSource messageSource;
42
 
41
 
43
     @RequestMapping(method = RequestMethod.GET)
42
     @RequestMapping(method = RequestMethod.GET)
44
-    public TrackCommand get() {
45
-        return new TrackCommand();
43
+    public String get(final Map<String, Object> model) {
44
+        model.put("trackCommand", new TrackCommand());
45
+        return "track";
46
     }
46
     }
47
 
47
 
48
     @RequestMapping(method = RequestMethod.POST)
48
     @RequestMapping(method = RequestMethod.POST)
49
-    protected Map<String, CargoTrackingViewAdapter> onSubmit(final HttpServletRequest request,
49
+    protected String onSubmit(final HttpServletRequest request,
50
                                                              final TrackCommand command,
50
                                                              final TrackCommand command,
51
+                                                             final Map<String, Object> model,
51
                                                              final BindingResult bindingResult) {
52
                                                              final BindingResult bindingResult) {
52
         new TrackCommandValidator().validate(command, bindingResult);
53
         new TrackCommandValidator().validate(command, bindingResult);
53
 
54
 
54
         final TrackingId trackingId = new TrackingId(command.getTrackingId());
55
         final TrackingId trackingId = new TrackingId(command.getTrackingId());
55
         final Cargo cargo = cargoRepository.find(trackingId);
56
         final Cargo cargo = cargoRepository.find(trackingId);
56
 
57
 
57
-        final Map<String, CargoTrackingViewAdapter> model = new HashMap<String, CargoTrackingViewAdapter>();
58
         if (cargo != null) {
58
         if (cargo != null) {
59
             final Locale locale = RequestContextUtils.getLocale(request);
59
             final Locale locale = RequestContextUtils.getLocale(request);
60
             final List<HandlingEvent> handlingEvents = handlingEventRepository.lookupHandlingHistoryOfCargo(trackingId).distinctEventsByCompletionTime();
60
             final List<HandlingEvent> handlingEvents = handlingEventRepository.lookupHandlingHistoryOfCargo(trackingId).distinctEventsByCompletionTime();
62
         } else {
62
         } else {
63
             bindingResult.rejectValue("trackingId", "cargo.unknown_id", new Object[]{command.getTrackingId()}, "Unknown tracking id");
63
             bindingResult.rejectValue("trackingId", "cargo.unknown_id", new Object[]{command.getTrackingId()}, "Unknown tracking id");
64
         }
64
         }
65
-        return model;
65
+        return "track";
66
     }
66
     }
67
 
67
 
68
     public void setCargoRepository(CargoRepository cargoRepository) {
68
     public void setCargoRepository(CargoRepository cargoRepository) {

+ 6
- 0
src/main/resources/application.properties Voir le fichier

1
+server.contextPath=/dddsample
2
+cxf.path=/ws
3
+
4
+logging.level.org.hibernate.SQL=debug
5
+logging.level.org.hibernate.hbm2ddl=debug
6
+logging.level.net.sf.ehcache.config.ConfigurationFactory=error

+ 3
- 2
src/main/resources/context-interfaces.xml Voir le fichier

47
         <property name="voyageRepository" ref="voyageRepository"/>
47
         <property name="voyageRepository" ref="voyageRepository"/>
48
     </bean>
48
     </bean>
49
 
49
 
50
-    <bean name="/*" class="se.citerus.dddsample.interfaces.booking.web.CargoAdminController">
50
+    <bean id="trackCommandValidator" class="se.citerus.dddsample.interfaces.tracking.TrackCommandValidator"/>
51
+
52
+    <bean class="se.citerus.dddsample.interfaces.booking.web.CargoAdminController">
51
         <property name="bookingServiceFacade" ref="bookingServiceFacade"/>
53
         <property name="bookingServiceFacade" ref="bookingServiceFacade"/>
52
     </bean>
54
     </bean>
53
 
55
 
54
-
55
     <!-- Tracking web application support -->
56
     <!-- Tracking web application support -->
56
 
57
 
57
     <bean class="se.citerus.dddsample.interfaces.tracking.CargoTrackingController">
58
     <bean class="se.citerus.dddsample.interfaces.tracking.CargoTrackingController">

+ 0
- 10
src/main/resources/log4j.properties Voir le fichier

1
-log4j.rootLogger=info, stdout
2
-
3
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5
-log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
6
-
7
-log4j.logger.net.sf.ehcache.config.ConfigurationFactory=error
8
-
9
-log4j.logger.org.hibernate.SQL=debug
10
-log4j.logger.org.hibernate.hbm2ddl=debug

src/main/webapp/admin.css → src/main/resources/static/admin.css Voir le fichier


src/main/webapp/calendar.css → src/main/resources/static/calendar.css Voir le fichier

1
-.calendarTrigger {
2
-	width: 16px;
3
-	height: 16px;
4
-	cursor: pointer;
5
-	vertical-align: top;
6
-	margin-top: 1px;
7
-}
8
-
9
-.calendar {
10
-	position: absolute;
11
-	display: inherit;
12
-	
13
-	font-family: tahoma, verdana, arial, helvetica, sans-serif;
14
-	border: 1px solid blue;
15
-	background-color: white;
16
-}
17
-
18
-
19
-.calendar table {
20
-	border: 4px solid lightblue;
21
-	margin: 0px;
22
-	padding: 0px;
23
-	border-spacing: 2px;
24
-	border-collapse: separate;
25
-}
26
-
27
-.calendar table .goPrevious,
28
-.calendar table .goNext {
29
-	width: 12px;
30
-	background-repeat: no-repeat;
31
-	cursor: pointer;
32
-}
33
-
34
-.calendar table .goPrevious {
35
-	background-image: url( 'navigate_left.gif' );
36
-	background-position: left center;
37
-}
38
-
39
-.calendar table .goNext {
40
-	background-image: url( 'navigate_right.gif' );
41
-	background-position: right center;
42
-}
43
-
44
-.calendar table thead tr:first-child td {
45
-	font-weight: bold;
46
-}
47
-
48
-.calendar table td {
49
-	width: 15px;
50
-	height: 15px;
51
-	font-family: tahoma, verdana, arial, helvetica, sans-serif;
52
-	font-size: 8pt;
53
-	text-align: center;
54
-	padding: 0px 0px 0px 1px;
55
-	border: 0px;
56
-	vertical-align: middle;
57
-}
58
-.calendar table tbody td {
59
-	border: 1px solid gray;
60
-	cursor: pointer;
61
-}
62
-.calendar .disabled {
63
-	background-color: #BBBBBB;
64
-	color: #555555;
65
-}
66
-.calendar .past {
67
-	color: #AAAAAA;
68
-}
69
-.calendar .future {
70
-}
71
-.calendar .today {
72
-	background-color: pink;
73
-}
74
-.calendar .active {
75
-	background-color: #FFAA00;
76
-	border: 1px solid black;
77
-}
78
-
79
-.calendar table tbody td:hover {
80
-	border: 1px solid blue;
81
-	background-color: lightblue;
82
-}
1
+.calendarTrigger {
2
+	width: 16px;
3
+	height: 16px;
4
+	cursor: pointer;
5
+	vertical-align: top;
6
+	margin-top: 1px;
7
+}
8
+
9
+.calendar {
10
+	position: absolute;
11
+	display: inherit;
12
+	
13
+	font-family: tahoma, verdana, arial, helvetica, sans-serif;
14
+	border: 1px solid blue;
15
+	background-color: white;
16
+}
17
+
18
+
19
+.calendar table {
20
+	border: 4px solid lightblue;
21
+	margin: 0px;
22
+	padding: 0px;
23
+	border-spacing: 2px;
24
+	border-collapse: separate;
25
+}
26
+
27
+.calendar table .goPrevious,
28
+.calendar table .goNext {
29
+	width: 12px;
30
+	background-repeat: no-repeat;
31
+	cursor: pointer;
32
+}
33
+
34
+.calendar table .goPrevious {
35
+	background-image: url( 'navigate_left.gif' );
36
+	background-position: left center;
37
+}
38
+
39
+.calendar table .goNext {
40
+	background-image: url( 'navigate_right.gif' );
41
+	background-position: right center;
42
+}
43
+
44
+.calendar table thead tr:first-child td {
45
+	font-weight: bold;
46
+}
47
+
48
+.calendar table td {
49
+	width: 15px;
50
+	height: 15px;
51
+	font-family: tahoma, verdana, arial, helvetica, sans-serif;
52
+	font-size: 8pt;
53
+	text-align: center;
54
+	padding: 0px 0px 0px 1px;
55
+	border: 0px;
56
+	vertical-align: middle;
57
+}
58
+.calendar table tbody td {
59
+	border: 1px solid gray;
60
+	cursor: pointer;
61
+}
62
+.calendar .disabled {
63
+	background-color: #BBBBBB;
64
+	color: #555555;
65
+}
66
+.calendar .past {
67
+	color: #AAAAAA;
68
+}
69
+.calendar .future {
70
+}
71
+.calendar .today {
72
+	background-color: pink;
73
+}
74
+.calendar .active {
75
+	background-color: #FFAA00;
76
+	border: 1px solid black;
77
+}
78
+
79
+.calendar table tbody td:hover {
80
+	border: 1px solid blue;
81
+	background-color: lightblue;
82
+}

src/main/webapp/css/bootstrap-datepicker.css → src/main/resources/static/css/bootstrap-datepicker.css Voir le fichier


src/main/webapp/css/bootstrap.css → src/main/resources/static/css/bootstrap.css Voir le fichier


src/main/webapp/fonts/glyphicons-halflings-regular.ttf → src/main/resources/static/fonts/glyphicons-halflings-regular.ttf Voir le fichier


src/main/webapp/fonts/glyphicons-halflings-regular.woff → src/main/resources/static/fonts/glyphicons-halflings-regular.woff Voir le fichier


src/main/webapp/fonts/glyphicons-halflings-regular.woff2 → src/main/resources/static/fonts/glyphicons-halflings-regular.woff2 Voir le fichier


src/main/webapp/images/calendarTrigger.gif → src/main/resources/static/images/calendarTrigger.gif Voir le fichier


src/main/webapp/images/cross.png → src/main/resources/static/images/cross.png Voir le fichier


src/main/webapp/images/dddsample_logotype.png → src/main/resources/static/images/dddsample_logotype.png Voir le fichier


src/main/webapp/images/dddsample_logotype_small.png → src/main/resources/static/images/dddsample_logotype_small.png Voir le fichier


src/main/webapp/images/error.png → src/main/resources/static/images/error.png Voir le fichier


src/main/webapp/images/shade.png → src/main/resources/static/images/shade.png Voir le fichier


src/main/webapp/images/tick.png → src/main/resources/static/images/tick.png Voir le fichier


src/main/webapp/images/web_logo.png → src/main/resources/static/images/web_logo.png Voir le fichier


src/main/webapp/index.jsp → src/main/resources/static/index.html Voir le fichier

1
-<%
2
-    //response.sendRedirect("public/track");
3
-%>
4
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
-<head>
8
-    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
9
-    <title>DDDSample</title>
10
-</head>
11
-<body style="padding: 20px">
12
-<p><img src="images/web_logo.png"/></p>
13
-<p>Welcome to the <strong>DDDSample</strong> application.</p>
14
-<p>There are two web interfaces available:</p>
15
-<ul>
16
-<li>Public <a href="public/track">cargo tracking</a></li> 
17
-<li>Administration of <a href="admin/list">booking and routing</a>.</li>
18
-</ul>
19
-<p>The Incident Logging application, that is used to register handling events, is a stand-alone application and a separate download.</p>
20
-<p>Please visit the <a href="https://github.com/citerus/dddsample-core/">project website</a> for more information and a screencast demonstration of how the application works.</p>
21
-<p><i>This project is a joint effort by Eric Evans' company <a href="http://www.domainlanguage.com" class="externalLink">Domain Language</a>
22
- and the Swedish software consulting company <a href="http://www.citerus.se" class="externalLink">Citerus</a>.</i></p>
23
-</body>
24
-</html>
1
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+
3
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+<head>
5
+    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
6
+    <title>DDDSample</title>
7
+</head>
8
+<body style="padding: 20px">
9
+<p><img src="images/web_logo.png"/></p>
10
+<p>Welcome to the <strong>DDDSample</strong> application.</p>
11
+<p>There are two web interfaces available:</p>
12
+<ul>
13
+<li>Public <a href="track">cargo tracking</a></li>
14
+<li>Administration of <a href="admin/list">booking and routing</a>.</li>
15
+</ul>
16
+<p>The Incident Logging application, that is used to register handling events, is a stand-alone application and a separate download.</p>
17
+<p>Please visit the <a href="https://github.com/citerus/dddsample-core/">project website</a> for more information and a screencast demonstration of how the application works.</p>
18
+<p><i>This project is a joint effort by Eric Evans' company <a href="http://www.domainlanguage.com" class="externalLink">Domain Language</a>
19
+ and the Swedish software consulting company <a href="http://www.citerus.se" class="externalLink">Citerus</a>.</i></p>
20
+</body>
21
+</html>

src/main/webapp/js/bootstrap-datepicker.js → src/main/resources/static/js/bootstrap-datepicker.js Voir le fichier


src/main/webapp/js/jquery-2.1.4.js → src/main/resources/static/js/jquery-2.1.4.js Voir le fichier


src/main/webapp/style.css → src/main/resources/static/style.css Voir le fichier


src/main/webapp/WEB-INF/templates/admin/list.html → src/main/resources/templates/admin/list.html Voir le fichier

10
 
10
 
11
 <body>
11
 <body>
12
 <div id="outer">
12
 <div id="outer">
13
-    <div th:replace="templates/adminDecorator :: adminbody"/>
13
+    <div th:replace="adminDecorator :: adminbody"/>
14
     <div id="body">
14
     <div id="body">
15
         <table border="1" width="600">
15
         <table border="1" width="600">
16
             <caption>All cargos</caption>
16
             <caption>All cargos</caption>

src/main/webapp/WEB-INF/templates/admin/pickNewDestination.html → src/main/resources/templates/admin/pickNewDestination.html Voir le fichier

15
 </head>
15
 </head>
16
 
16
 
17
 <body>
17
 <body>
18
-<div th:replace="templates/adminDecorator :: adminbody"/>
18
+<div th:replace="adminDecorator :: adminbody"/>
19
 <div id="container">
19
 <div id="container">
20
   <form th:action="@{/admin/changeDestination}" method="post">
20
   <form th:action="@{/admin/changeDestination}" method="post">
21
   <input type="hidden" name="trackingId" th:value="${cargo.trackingId}"/>
21
   <input type="hidden" name="trackingId" th:value="${cargo.trackingId}"/>

src/main/webapp/WEB-INF/templates/admin/registrationForm.html → src/main/resources/templates/admin/registrationForm.html Voir le fichier

11
     <link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap-datepicker.css}"/>
11
     <link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap-datepicker.css}"/>
12
 </head>
12
 </head>
13
 <body>
13
 <body>
14
-<div th:replace="templates/adminDecorator :: adminbody"/>
14
+<div th:replace="adminDecorator :: adminbody"/>
15
 <div id="container">
15
 <div id="container">
16
     <form th:action="@{/admin/register}" method="post">
16
     <form th:action="@{/admin/register}" method="post">
17
         <table>
17
         <table>

src/main/webapp/WEB-INF/templates/admin/selectItinerary.html → src/main/resources/templates/admin/selectItinerary.html Voir le fichier

8
     <link rel="stylesheet" type="text/css" th:href="@{/admin.css}"/>
8
     <link rel="stylesheet" type="text/css" th:href="@{/admin.css}"/>
9
 </head>
9
 </head>
10
 <body>
10
 <body>
11
-<div th:replace="templates/adminDecorator :: adminbody"/>
11
+<div th:replace="adminDecorator :: adminbody"/>
12
 <div id="container">
12
 <div id="container">
13
     <table>
13
     <table>
14
         <caption>Select route</caption>
14
         <caption>Select route</caption>

src/main/webapp/WEB-INF/templates/admin/show.html → src/main/resources/templates/admin/show.html Voir le fichier

9
     <link rel="stylesheet" type="text/css" th:href="@{/admin.css}"/>
9
     <link rel="stylesheet" type="text/css" th:href="@{/admin.css}"/>
10
 </head>
10
 </head>
11
 <body>
11
 <body>
12
-<div th:replace="templates/adminDecorator :: adminbody"/>
12
+<div th:replace="adminDecorator :: adminbody"/>
13
 <div id="container">
13
 <div id="container">
14
     <table>
14
     <table>
15
         <caption th:text="'Details for cargo ' + ${cargo.trackingId}"></caption>
15
         <caption th:text="'Details for cargo ' + ${cargo.trackingId}"></caption>

src/main/webapp/WEB-INF/templates/adminDecorator.html → src/main/resources/templates/adminDecorator.html Voir le fichier


src/main/webapp/WEB-INF/templates/pub/track.html → src/main/resources/templates/track.html Voir le fichier

93
     }
93
     }
94
 </script>
94
 </script>
95
 </body>
95
 </body>
96
-</html>
96
+</html>

+ 0
- 22
src/main/webapp/WEB-INF/booking-servlet.xml Voir le fichier

1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<beans xmlns="http://www.springframework.org/schema/beans"
3
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
5
-
6
-    <bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
7
-        <property name="templateMode" value="HTML5"/>
8
-        <property name="prefix" value="/WEB-INF/"/>
9
-        <property name="suffix" value=".html"/>
10
-    </bean>
11
-
12
-    <bean id="templateEngine"
13
-          class="org.thymeleaf.spring4.SpringTemplateEngine">
14
-        <property name="templateResolver" ref="templateResolver"/>
15
-    </bean>
16
-
17
-    <bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
18
-        <property name="viewNames" value="templates/admin/*"/>
19
-        <property name="templateEngine" ref="templateEngine"/>
20
-    </bean>
21
-
22
-</beans>

+ 0
- 22
src/main/webapp/WEB-INF/tracking-servlet.xml Voir le fichier

1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<beans xmlns="http://www.springframework.org/schema/beans"
3
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
5
-
6
-  <bean id="trackCommandValidator" class="se.citerus.dddsample.interfaces.tracking.TrackCommandValidator"/>
7
-
8
-  <bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
9
-    <property name="templateMode" value="HTML5" />
10
-    <property name="prefix" value="/WEB-INF/templates/pub/"/>
11
-    <property name="suffix" value=".html"/>
12
-  </bean>
13
-
14
-  <bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
15
-    <property name="templateResolver" ref="templateResolver" />
16
-  </bean>
17
-
18
-  <bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
19
-    <property name="templateEngine" ref="templateEngine" />
20
-  </bean>
21
-
22
-</beans>

+ 0
- 69
src/main/webapp/WEB-INF/web.xml Voir le fichier

1
-<?xml version="1.0" encoding="UTF-8"?>
2
-
3
-<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
4
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
-         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
6
-
7
-  <display-name>DDDSample</display-name>
8
-
9
-  <listener>
10
-    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
11
-  </listener>
12
-
13
-  <context-param>
14
-    <param-name>log4jConfigLocation</param-name>
15
-    <param-value>classpath:log4j.properties</param-value>
16
-  </context-param>
17
-
18
-  <listener>
19
-    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
20
-  </listener>
21
-
22
-  <context-param>
23
-    <param-name>contextConfigLocation</param-name>
24
-    <param-value>
25
-      classpath:/com/pathfinder/internal/applicationContext.xml
26
-
27
-      classpath:context-infrastructure.xml
28
-      classpath:context-application.xml
29
-      classpath:context-domain.xml
30
-      classpath:context-interfaces.xml
31
-    </param-value>
32
-  </context-param>
33
-
34
-  <listener>
35
-    <listener-class>se.citerus.dddsample.application.util.SampleDataGenerator</listener-class>
36
-  </listener>
37
-  
38
-  <servlet>
39
-    <servlet-name>tracking</servlet-name>
40
-    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
41
-  </servlet>
42
-
43
-  <servlet-mapping>
44
-    <servlet-name>tracking</servlet-name>
45
-    <url-pattern>/public/*</url-pattern>
46
-  </servlet-mapping>
47
-
48
-  <servlet>
49
-    <servlet-name>booking</servlet-name>
50
-    <servlet-class>se.citerus.dddsample.interfaces.booking.web.BookingDispatcherServlet</servlet-class>
51
-  </servlet>
52
-
53
-  <servlet-mapping>
54
-    <servlet-name>booking</servlet-name>
55
-    <url-pattern>/admin/*</url-pattern>
56
-  </servlet-mapping>
57
-
58
-  <servlet>
59
-    <servlet-name>jaxws</servlet-name>
60
-    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
61
-  </servlet>
62
-
63
-  <servlet-mapping>
64
-    <servlet-name>jaxws</servlet-name>
65
-    <url-pattern>/ws/*</url-pattern>
66
-  </servlet-mapping>
67
-
68
-
69
-</web-app>