Просмотр исходного кода

Moved some parse calls out of a loop that only need to happen once per report.

peter_backlund 17 лет назад
Родитель
Сommit
cb2ef14e30

+ 13
- 9
dddsample/src/main/java/se/citerus/dddsample/interfaces/handling/ws/impl/HandlingReportServiceImpl.java Просмотреть файл

@@ -32,18 +32,22 @@ public class HandlingReportServiceImpl implements HandlingReportService {
32 32
 
33 33
   @Override
34 34
   public void submitReport(HandlingReport handlingReport) throws HandlingReportErrors {
35
-    final Date date = handlingReport.getCompletionTime().toGregorianCalendar().getTime();
36
-    
37
-    for (String trackingId : handlingReport.getTrackingIds()) {
38
-      List<String> errors = new ArrayList<String>();
35
+    final List<String> errors = new ArrayList<String>();
39 36
 
40
-      final TrackingId tid = parseTrackingId(trackingId, errors);
41
-      final VoyageNumber voyageNumber = parseVoyageNumber(handlingReport.getVoyageNumber(), errors);
42
-      final HandlingEvent.Type type = parseEventType(handlingReport.getType(), errors);
43
-      final UnLocode ul = parseUnLocode(handlingReport.getUnLocode(), errors);
37
+    final Date completionTime = handlingReport.getCompletionTime().toGregorianCalendar().getTime();
38
+    final VoyageNumber voyageNumber = parseVoyageNumber(handlingReport.getVoyageNumber(), errors);
39
+    final HandlingEvent.Type type = parseEventType(handlingReport.getType(), errors);
40
+    final UnLocode unLocode = parseUnLocode(handlingReport.getUnLocode(), errors);
41
+
42
+    for (String trackingIdStr : handlingReport.getTrackingIds()) {
43
+      final TrackingId trackingId = parseTrackingId(trackingIdStr, errors);
44 44
 
45 45
       if (errors.isEmpty()) {
46
-        final HandlingEventRegistrationAttempt attempt = new HandlingEventRegistrationAttempt(new Date(), date, tid, voyageNumber, type, ul);
46
+        final Date registrationTime = new Date();
47
+        final HandlingEventRegistrationAttempt attempt = new HandlingEventRegistrationAttempt(
48
+          registrationTime, completionTime, trackingId, voyageNumber, type, unLocode
49
+        );
50
+
47 51
         applicationEvents.receivedHandlingEventRegistrationAttempt(attempt);
48 52
       } else {
49 53
         logger.error("Parse error in handling report: " + errors);