Skip to content

Commit 0191cc8

Browse files
committed
UMA-40 Parcel Track Result screen
1 parent 9e59a9d commit 0191cc8

File tree

3 files changed

+102
-104
lines changed

3 files changed

+102
-104
lines changed

myadmin-angular/projects/parcel-tracking-app/src/app/components/parcel-tracking-result/parcel-tracking-result.component.html

Lines changed: 70 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,59 +35,87 @@ <h5>Parcel Tracking</h5>
3535
CLAW - College of Law,<br>
3636
CSET&nbsp;&nbsp;- College of Science, Engineering and Technology,<br>
3737
CHS &nbsp;&nbsp;- College of Human Sciences,<br>
38-
CAES - College of Agriculture and Environmental Sciences,<br><br>The study material is sent via <b>DSV</b> Courier
38+
CAES - College of Agriculture and Environmental Sciences,<br><br>The study material is sent via <b>DSV</b>
39+
Courier
3940
Services.<br>
4041
Please use the link:<br><a href="https://distributionclientzone.go2uti.com/UTi.Unisa.TrackAndTrace/"
4142
target="_blank">https://distributionclientzone.go2uti.com/UTi.Unisa.TrackAndTrace/</a><br>
4243
</p>
4344

4445
</div>
4546
</div>
46-
<form #resultForm="ngForm">
47-
<div class="form-group row">
48-
<div class="col-sm-2">
49-
<p class="font-weight-bold">Student number</p>
47+
<div *ngIf="parcelTrackingInfo?.traceRecordInfoList">
48+
<form #resultForm="ngForm" *ngIf="!parcelTrackingInfo?.studentuser">
49+
<div class="form-group row">
50+
<div class="col-sm-2">
51+
<p class="font-weight-bold">Student number</p>
52+
</div>
53+
<div class="col-sm-2">
54+
<input type="text" class="form-control" id="studentNumber" name="studentNumber" pattern="([0-9])*"
55+
[(ngModel)]="studentNumber" minlength="7" maxlength="8" required>
56+
</div>
5057
</div>
51-
<div class="col-sm-2">
52-
<input type="text" class="form-control" id="studentNumber" name="studentNumber" pattern="([0-9])*" [(ngModel)]="studentNumber" minlength="7" maxlength="8" required >
58+
<div class="row" *ngIf="!parcelTrackingInfo?.studentuser">
59+
<div class="col-sm-1">
60+
<button class="btn btn-primary"
61+
(click)="getStudentParcelTracking(studentNumber)" [disabled]="resultForm.form.invalid">Display
62+
</button>
63+
</div>
64+
<div class="col-sm-1">
65+
<a class="btn btn-secondary" routerLink="/search">New Student</a>
66+
<!--<button type="reset" class="btn btn-secondary">New Student</button>-->
67+
</div>
5368
</div>
69+
</form>
70+
<hr>
71+
<h5>Student {{parcelTrackingInfo?.studentInfo.studentNumber}} : {{parcelTrackingInfo?.studentInfo.studentName}}
72+
</h5>
73+
<br/>
74+
<h6>SA Post Office Parcels ,open the link blow and enter in the tracking number listed below.<br><a
75+
href="https://www.postoffice.co.za/ContactUs/trackandtracedomestic.html" target="_blank">https://www.postoffice.co.za/ContactUs/trackandtracedomestic.html</a>
76+
</h6>
77+
<div class="table-responsive-sm col-sm-8">
78+
<table class="table table-sm table-hover">
79+
<thead class="thead-light">
80+
<tr>
81+
<th scope="col">Date Processed</th>
82+
<th scope="col">Agent</th>
83+
<th scope="col">Tracking Number</th>
84+
</tr>
85+
</thead>
86+
<tbody>
87+
<tr *ngFor="let traceRecordInfo of parcelTrackingInfo?.traceRecordInfoList">
88+
<td>{{ traceRecordInfo.trackTraceDate }}</td>
89+
<td>{{ traceRecordInfo.trackTraceAgent }}</td>
90+
<td>{{ traceRecordInfo.trackTraceNumber}}</td>
91+
</tr>
92+
</tbody>
93+
</table>
5494
</div>
55-
<div class="row" *ngIf="!parcelTrackingInfo?.studentuser">
56-
<div class="col-sm-1">
57-
<button class="btn btn-primary"
58-
(click)="getStudentParcelTracking(studentNumber)" [disabled]="resultForm.form.invalid">Display
59-
</button>
95+
</div>
96+
<div *ngIf="!parcelTrackingInfo?.traceRecordInfoList">
97+
<form #resultForm="ngForm" *ngIf="!parcelTrackingInfo?.studentuser">
98+
<div class="form-group row">
99+
<div class="col-sm-2">
100+
<p class="font-weight-bold">Student number</p>
101+
</div>
102+
<div class="col-sm-2">
103+
<input type="text" class="form-control" id="studentNumber" name="studentNumber" pattern="([0-9])*"
104+
[(ngModel)]="studentNumber" minlength="7" maxlength="8" required>
105+
</div>
60106
</div>
61-
<div class="col-sm-1">
62-
<a class="btn btn-secondary" routerLink="/search">New Student</a>
63-
<!--<button type="reset" class="btn btn-secondary">New Student</button>-->
107+
<div class="row" *ngIf="!parcelTrackingInfo?.studentuser">
108+
<div class="col-sm-1">
109+
<button class="btn btn-primary"
110+
(click)="getStudentParcelTracking(studentNumber)" [disabled]="resultForm.form.invalid">Display
111+
</button>
112+
</div>
113+
<div class="col-sm-1">
114+
<a class="btn btn-secondary" routerLink="/search">New Student</a>
115+
<!--<button type="reset" class="btn btn-secondary">New Student</button>-->
116+
</div>
64117
</div>
65-
</div>
66-
</form>
67-
<hr>
68-
<h5>Student {{parcelTrackingInfo?.studentInfo.studentNumber}} : {{parcelTrackingInfo?.studentInfo.studentName}}
69-
</h5>
70-
<br/>
71-
<h6>SA Post Office Parcels ,open the link blow and enter in the tracking number listed below.<br><a
72-
href="https://www.postoffice.co.za/ContactUs/trackandtracedomestic.html" target="_blank">https://www.postoffice.co.za/ContactUs/trackandtracedomestic.html</a>
73-
</h6>
74-
<div class="table-responsive-sm col-sm-8">
75-
<table class="table table-sm table-hover">
76-
<thead class="thead-light">
77-
<tr>
78-
<th scope="col">Date Processed</th>
79-
<th scope="col">Agent</th>
80-
<th scope="col">Tracking Number</th>
81-
</tr>
82-
</thead>
83-
<tbody>
84-
<tr *ngFor="let traceRecordInfo of parcelTrackingInfo?.traceRecordInfoList">
85-
<td>{{ traceRecordInfo.trackTraceDate }}</td>
86-
<td>{{ traceRecordInfo.trackTraceAgent }}</td>
87-
<td>{{ traceRecordInfo.trackTraceNumber}}</td>
88-
</tr>
89-
</tbody>
90-
</table>
118+
</form>
91119
</div>
92-
120+
<br/><br/>
93121
</div>

myadmin-angular/projects/parcel-tracking-app/src/app/components/parcel-tracking-result/parcel-tracking-result.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class ParcelTrackingResultComponent implements OnInit {
5252
this.errorMessage = response.message;
5353
}
5454
this.blockUI.stop();
55+
this.router.navigateByUrl("search");
5556
})
5657
}
5758
}

myadmin-service-impls/parcel-tracking-service/src/main/java/za/ac/unisa/myadmin/service/parceltracking/impl/ParcelTrackingServiceImpl.java

Lines changed: 31 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import java.awt.event.ActionListener;
1313
import java.beans.PropertyVetoException;
14+
import java.time.LocalDate;
15+
import java.time.temporal.ChronoField;
1416
import java.util.ArrayList;
1517
import java.util.Calendar;
1618
import java.util.List;
@@ -21,90 +23,61 @@
2123
*/
2224
@Service("ParcelTrackingService")
2325
public class ParcelTrackingServiceImpl implements ParcelTrackingService {
26+
/**
27+
* Get an instance of the StudyFee proxy
28+
*
29+
* @return
30+
* @throws PropertyVetoException
31+
*/
32+
private Smsij01sMntGenDespatchInfo getProxyInstance() throws PropertyVetoException {
33+
Smsij01sMntGenDespatchInfo despatchProxy = new Smsij01sMntGenDespatchInfo();
34+
despatchProxy.clear();
35+
despatchProxy.setInCsfClientServerCommunicationsClientVersionNumber((short) 3);
36+
despatchProxy.setInCsfClientServerCommunicationsClientRevisionNumber((short) 1);
37+
despatchProxy.setInCsfClientServerCommunicationsAction("D");
38+
despatchProxy.setInCsfClientServerCommunicationsClientDevelopmentPhase("C");
39+
despatchProxy.setInSecurityWsPrinterCode("MYUNISA");
40+
return despatchProxy;
41+
}
2442

2543
@Override
2644
public ParcelTrackingInfo trackAndTraceParcel(Integer studentNumber) throws OperationFailedException {
2745
try {
28-
//ParcelTrackingInfo parcelTrackingInfo = new ParcelTrackingInfo();
29-
// ParcelTrackingDisplayForm parcelTrackingDisplayForm = (ParcelTrackingDisplayForm) form;
30-
// ActionMessages messages = new ActionMessages();
31-
//
32-
// messages = (ActionMessages) parcelTrackingDisplayForm.validate(mapping, request);
33-
//
34-
// eventTrackingService = (EventTrackingService) ComponentManager.get(EventTrackingService.class);
35-
// toolManager = (ToolManager) ComponentManager.get(ToolManager.class);
36-
37-
int tmpStudentNr = 0;
38-
39-
// if (!messages.isEmpty()) {
40-
// addErrors(request, messages);
41-
// return mapping.findForward("TrackandTraceInput");
42-
// }
43-
tmpStudentNr = studentNumber;
44-
/** Current Year */
45-
46-
short currentYear;
47-
48-
if (Calendar.getInstance().get(Calendar.MONTH) < 11) {
49-
currentYear = new Integer(Calendar.getInstance().get(Calendar.YEAR)).shortValue();
50-
51-
//System.out.println( "year "+currentYear);
52-
} else {
53-
currentYear = new Integer(Calendar.getInstance().get(Calendar.YEAR)).shortValue();
54-
//System.out.println(currentYear);
55-
}
46+
Integer currentYear = Calendar.getInstance().get(Calendar.YEAR);
47+
//LocalDate.now().get(ChronoField.YEAR);
5648

57-
Smsij01sMntGenDespatchInfo despatchProxy = new Smsij01sMntGenDespatchInfo();
49+
Smsij01sMntGenDespatchInfo despatchProxy = getProxyInstance();
5850
final AtomicReference<OperationFailedException> exceptionReference = new AtomicReference<>();
5951
final ActionListener exceptionListener = e -> exceptionReference.set(new OperationFailedException(e.getActionCommand()));
60-
//operListener opl = new operListener();
6152
despatchProxy.addExceptionListener(exceptionListener);
62-
despatchProxy.clear();
53+
//Populate fields
54+
despatchProxy.setInStudentAnnualRecordMkStudentNr(studentNumber);
55+
despatchProxy.setInStudentAnnualRecordMkAcademicYear(currentYear.shortValue());
6356

64-
despatchProxy.setInCsfClientServerCommunicationsClientVersionNumber((short) 3);
65-
despatchProxy.setInCsfClientServerCommunicationsClientRevisionNumber((short) 1);
66-
despatchProxy.setInCsfClientServerCommunicationsAction("D");
67-
despatchProxy.setInCsfClientServerCommunicationsClientDevelopmentPhase("C");
68-
despatchProxy.setInStudentAnnualRecordMkStudentNr(tmpStudentNr);
69-
despatchProxy.setInStudentAnnualRecordMkAcademicYear(currentYear);
70-
despatchProxy.setInSecurityWsPrinterCode("MYUNISA");
71-
72-
//System.out.println(tmpStudentNr);
7357
despatchProxy.execute();
7458
if (exceptionReference.get() != null) {
7559
throw exceptionReference.get();
7660
}
7761
return buildResponse(despatchProxy, currentYear);
7862
} catch (PropertyVetoException ex) {
7963
throw new OperationFailedException(ex);
80-
//ActionMessages messages = new ActionMessages();
81-
//messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
82-
// "errors.exceptionhappened", "An unepxected Error has happened, please close this tool and log on again"));
83-
//return mapping.findForward("displayforward");
8464
}
8565
}
8666

87-
private ParcelTrackingInfo buildResponse(Smsij01sMntGenDespatchInfo despatchProxy, short currentYear) throws OperationFailedException {
67+
private ParcelTrackingInfo buildResponse(Smsij01sMntGenDespatchInfo despatchProxy, Integer currentYear) throws OperationFailedException {
8868
ParcelTrackingInfo parcelTrackingInfo = new ParcelTrackingInfo();
8969
String errorMessage = despatchProxy.getOutCsfStringsString500();
9070
if (StringUtils.hasText(errorMessage)) {
9171
throw new OperationFailedException(errorMessage);
92-
// messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
93-
// "error.coolgenerror", Errormsg));
94-
// addErrors(request, messages);
95-
// return mapping.findForward("TrackandTraceInput");
9672
}
9773
StudentInfo student = new StudentInfo();
9874
student.setStudentNumber(String.valueOf(despatchProxy.getOutStudentAnnualRecordMkStudentNr()));
9975
student.setStudentName((String.valueOf(despatchProxy.getOutWsStudentMkTitle()) + " " + String.valueOf(despatchProxy.getOutWsStudentFirstNames() + " " + String.valueOf(despatchProxy.getOutWsStudentSurname()))));
10076
parcelTrackingInfo.setStudentInfo(student);
10177

102-
int count = despatchProxy.getOutLuGroupCount();//count gives total no. of records belongs to that student
10378
List records = new ArrayList<>();
10479

105-
106-
for (int i = 0; i < count; i++) {
107-
80+
for (int i = 0; i < despatchProxy.getOutLuGroupCount(); i++) {
10881

10982
if (!("".equals(despatchProxy.getOutGWsTrackAndTraceNumber(i)))) {
11083
//DateFormat strDate = new SimpleDateFormat("dd-MM-yyyy");
@@ -132,10 +105,8 @@ private ParcelTrackingInfo buildResponse(Smsij01sMntGenDespatchInfo despatchProx
132105
tempday = Integer.toString(day);
133106
}
134107

135-
136108
int year = tmpDate.get(Calendar.YEAR);
137-
if (currentYear == (new Integer(year).shortValue()) ||
138-
((currentYear - 1) == (new Integer(year).shortValue()) && month > 10)) {
109+
if (currentYear == year || ((currentYear - 1) == year && month > 10)) {
139110
//set date in array list
140111
TrackAndTraceRecordInfo trackAndTraceRecord = new TrackAndTraceRecordInfo();
141112
if (despatchProxy.getOutGWsTrackAndTraceNumber(i).substring(0, 1).equals("C") ||
@@ -160,13 +131,11 @@ private ParcelTrackingInfo buildResponse(Smsij01sMntGenDespatchInfo despatchProx
160131
}
161132
}
162133
parcelTrackingInfo.setTraceRecordInfoList(records);
163-
parcelTrackingInfo.setStudentuser(false);
164-
//request.setAttribute("records", records);
165-
//parcelTrackingDisplayForm1.setTrackRecords(records);
134+
parcelTrackingInfo.setStudentuser(true);
135+
136+
//TODO Unisa tool logs some event.
166137
//eventTrackingService.post(
167138
// eventTrackingService.newEvent(EventTrackingTypes.EVENT_TRACKANDTRACE_VIEW, toolManager.getCurrentPlacement().getContext(), false));
168-
169-
//return mapping.findForward("displayforward");
170139
return parcelTrackingInfo;
171140
}
172141

@@ -178,4 +147,4 @@ private boolean isInteger(String i) {
178147
return false;
179148
}
180149
}
181-
}
150+
}

0 commit comments

Comments
 (0)