Skip to content

Commit 56dabd7

Browse files
author
Jarkko Laitinen
committed
Merge branch 'development'
2 parents 95cb85e + 7a749a6 commit 56dabd7

37 files changed

+699
-322
lines changed

fi/cosky/sdk/API.java

+229-147
Large diffs are not rendered by default.

fi/cosky/sdk/BaseData.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ private Link concatLink(Link self, Link rel) {
3535
newRel = newRel.substring(newRel.indexOf("/")+1);
3636
}
3737
if (newRel.length() < 1) {
38-
return new Link(rel.getRel(), newSelf, rel.getMethod(), rel.isEnabled());
38+
return new Link(rel.getRel(), newSelf, rel.getMethod(), rel.getType(), rel.isEnabled());
3939
} else {
40-
return new Link(rel.getRel(), newSelf+"/"+newRel , rel.getMethod(), rel.isEnabled());
40+
return new Link(rel.getRel(), newSelf+"/"+newRel , rel.getMethod(), rel.getType(), rel.isEnabled());
4141
}
4242
}
43-
return new Link(rel.getRel(), self.getUri() + rel.getUri(), rel.getMethod(), rel.isEnabled());
43+
return new Link(rel.getRel(), self.getUri() + rel.getUri(), rel.getMethod(), rel.getType(), rel.isEnabled());
4444

4545
}
4646

fi/cosky/sdk/ErrorData.java

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66

77
public class ErrorData extends BaseData {
8+
public static final String MimeType = "application/vnd.jyu.nfleet.error";
9+
public static final double MimeVersion = 2.0;
10+
811
private int Code;
912
private String Message;
1013
public ErrorData() {

fi/cosky/sdk/ImportData.java

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import java.util.List;
77

88
public class ImportData extends BaseData {
9+
public static final String MimeType = "application/vnd.jyu.nfleet.import";
10+
public static final double MimeVersion = 2.1;
11+
912
private int VersionNumber;
1013
private int ErrorCount;
1114
private String State;

fi/cosky/sdk/ImportRequest.java

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* file 'LICENSE.txt', which is part of this source code package.
55
*/
66
public class ImportRequest {
7+
public static final String MimeType = ImportData.MimeType;
8+
public static final double MimeVersion = ImportData.MimeVersion;
9+
710
private VehicleSetImportRequest Vehicles;
811
private TaskSetImportRequest Tasks;
912

fi/cosky/sdk/Link.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,29 @@ public class Link {
88
private String Uri;
99
private String Method;
1010
private String Rel;
11+
private String Type;
1112
private boolean Enabled;
1213

13-
14+
@Deprecated
1415
public Link(String rel, String uri, String method) {
16+
this.Uri = uri;
17+
this.Rel = rel;
18+
this.Method = method;
19+
this.Enabled = true;
20+
}
21+
22+
public Link(String rel, String uri, String method, String type) {
1523
this.Uri = uri;
1624
this.Method = method;
1725
this.Rel = rel;
26+
this.Type = type;
1827
this.Enabled = true;
1928
}
20-
public Link(String rel, String uri, String method, boolean enabled) {
29+
public Link(String rel, String uri, String method,String type, boolean enabled) {
2130
this.Uri = uri;
2231
this.Method = method;
2332
this.Rel = rel;
33+
this.Type = type;
2434
this.Enabled = enabled;
2535
}
2636

@@ -35,6 +45,7 @@ public String toString() {
3545
", Method='" + Method + '\'' +
3646
", Rel='" + Rel + '\'' +
3747
", Enabled=" + Enabled +
48+
", Type=" + Type +
3849
'}';
3950
}
4051

@@ -66,4 +77,10 @@ public String getRel() {
6677
return this.Rel;
6778

6879
}
80+
public String getType() {
81+
return Type;
82+
}
83+
public void setType(String type) {
84+
Type = type;
85+
}
6986
}

fi/cosky/sdk/MimeTypeHelper.java

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package fi.cosky.sdk;
2+
3+
import java.util.HashMap;
4+
5+
public class MimeTypeHelper {
6+
private final String versionPrefix = "-";
7+
private final String versionPostfix = "+json";
8+
9+
private static final HashMap<String,String> supportedTypes = new HashMap<String,String>();
10+
11+
public MimeTypeHelper() {
12+
initialize();
13+
}
14+
15+
private void initialize() {
16+
supportedTypes.put(UserData.MimeType, UserData.MimeType + versionPrefix + UserData.MimeVersion + versionPostfix);
17+
supportedTypes.put(UserDataSet.MimeType, UserDataSet.MimeType + versionPrefix + UserDataSet.MimeVersion + versionPostfix );
18+
supportedTypes.put(ImportData.MimeType, ImportData.MimeType + versionPrefix + ImportData.MimeVersion + versionPostfix);
19+
supportedTypes.put(ObjectiveValueDataSet.MimeType, ObjectiveValueDataSet.MimeType + versionPrefix + ObjectiveValueDataSet.MimeVersion + versionPostfix);
20+
supportedTypes.put(PlanData.MimeType, PlanData.MimeType + versionPrefix + PlanData.MimeVersion + versionPostfix);
21+
supportedTypes.put(RouteData.MimeType, RouteData.MimeType + versionPrefix + RouteData.MimeVersion + versionPostfix);
22+
supportedTypes.put(RouteEventData.MimeType, RouteEventData.MimeType + versionPrefix + RouteEventData.MimeVersion + versionPostfix);
23+
supportedTypes.put(RouteEventDataSet.MimeType, RouteEventDataSet.MimeType + versionPrefix + RouteEventDataSet.MimeVersion + versionPostfix);
24+
supportedTypes.put(RoutingProblemData.MimeType, RoutingProblemData.MimeType + versionPrefix + RoutingProblemData.MimeVersion + versionPostfix);
25+
supportedTypes.put(RoutingProblemDataSet.MimeType, RoutingProblemDataSet.MimeType + versionPrefix + RoutingProblemDataSet.MimeVersion + versionPostfix);
26+
supportedTypes.put(RoutingProblemSettingsData.MimeType, RoutingProblemSettingsData.MimeType + versionPrefix + RoutingProblemSettingsData.MimeVersion + versionPostfix);
27+
supportedTypes.put(TaskData.MimeType, TaskData.MimeType + versionPrefix + TaskData.MimeVersion + versionPostfix);
28+
supportedTypes.put(TaskDataSet.MimeType, TaskDataSet.MimeType + versionPrefix + TaskDataSet.MimeVersion + versionPostfix);
29+
supportedTypes.put(VehicleData.MimeType, VehicleData.MimeType + versionPrefix + VehicleData.MimeVersion + versionPostfix);
30+
supportedTypes.put(VehicleDataSet.MimeType, VehicleDataSet.MimeType + versionPrefix + VehicleDataSet.MimeVersion + versionPostfix);
31+
supportedTypes.put(VehicleTypeData.MimeType, VehicleTypeData.MimeType + versionPrefix + VehicleTypeData.MimeVersion + versionPostfix);
32+
supportedTypes.put(ErrorData.MimeType, ErrorData.MimeType + versionPrefix + ErrorData.MimeVersion + versionPostfix);
33+
}
34+
35+
public String getSupportedType(String type) {
36+
if (type == null || type.length() < 1) return "application/json";
37+
String[] parts = type.split("-");
38+
return supportedTypes.containsKey(parts[0]) ? supportedTypes.get(parts[0]) : "application/json";
39+
}
40+
}

fi/cosky/sdk/ObjectiveValueDataSet.java

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88

99
public class ObjectiveValueDataSet extends BaseData {
10+
public static final String MimeType = "application/vnd.jyu.nfleet.objectivevalueset";
11+
public static final double MimeVersion = 2.0;
12+
1013
private ArrayList<ObjectiveValueData> Items;
1114

1215
public ArrayList<ObjectiveValueData> getItems() {

fi/cosky/sdk/PlanData.java

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import java.util.List;
88

99
public class PlanData extends BaseData {
10+
public static final String MimeType = "application/vnd.jyu.nfleet.plan";
11+
public static final double MimeVersion = 2.0;
12+
1013
private int VersionNumber;
1114
private List<FieldsItem> Items;
1215
private KPIData KPIs;

fi/cosky/sdk/ProblemData.java

-68
This file was deleted.

fi/cosky/sdk/ProblemDataSet.java

-19
This file was deleted.

fi/cosky/sdk/RouteData.java

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77

88
public class RouteData extends BaseData {
9+
public static final String MimeType = "application/vnd.jyu.nfleet.route";
10+
public static final double MimeVersion = 2.0;
11+
912
private int[] Items;
1013
private int VersionNumber;
1114

fi/cosky/sdk/RouteEventData.java

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import java.util.Date;
99

1010
public class RouteEventData extends BaseData {
11+
public static final String MimeType = "application/vnd.jyu.nfleet.routeevent";
12+
public static final double MimeVersion = 2.0;
13+
1114
private int TaskEventId;
1215
private int VersionNumber;
1316
private String DataState;

fi/cosky/sdk/RouteEventDataSet.java

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44

55
public class RouteEventDataSet extends BaseData {
6+
public static final String MimeType = "application/vnd.jyu.nfleet.routeeventset";
7+
public static final double MimeVersion = 2.0;
8+
69
private int VersionNumber;
710
private ArrayList<RouteEventData> Items;
811

fi/cosky/sdk/RouteEventUpdateRequest.java

+4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
import java.util.Date;
44

55
public class RouteEventUpdateRequest extends BaseData {
6+
public static final String MimeType = RouteEventData.MimeType;
7+
public static final double MimeVersion = RouteEventData.MimeVersion;
8+
69
private int clientId;
710
private int userId;
811
private int problemId;
912
private int vehicleId;
1013
private int eventSequenceNumber;
1114
private Date actualArrivalTime;
1215
private String state;
16+
1317
public int getClientId() {
1418
return clientId;
1519
}

fi/cosky/sdk/RouteUpdateRequest.java

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77

88
public class RouteUpdateRequest extends BaseData {
9+
public static final String MimeType = "application/vnd.jyu.nfleet.route";
10+
public static final double MimeVersion = 2.0;
11+
912
private int ClientId;
1013
private int UserId;
1114
private int ProblemId;

fi/cosky/sdk/RoutingProblemData.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
* file 'LICENSE.txt', which is part of this source code package.
77
*/
88

9-
public class RoutingProblemData extends BaseData{
9+
public class RoutingProblemData extends BaseData {
10+
public static final String MimeType = "application/vnd.jyu.nfleet.problem";
11+
public static final double MimeVersion = 2.0;
12+
1013
private int Id;
1114
private Date CreationDate;
12-
13-
14-
private Date ModifiedDate;
15+
private Date ModifiedDate;
1516
private String Name;
1617
private String State;
1718
private int Progress;

fi/cosky/sdk/RoutingProblemDataSet.java

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
*/
88

99
public class RoutingProblemDataSet extends BaseData {
10+
public static final String MimeType = "application/vnd.jyu.nfleet.problemset";
11+
public static final double MimeVersion = 2.0;
12+
13+
1014
private List<RoutingProblemData> Items;
1115
private int VersionNumber;
1216

fi/cosky/sdk/RoutingProblemSettingsData.java

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77

88
public class RoutingProblemSettingsData extends BaseData {
9+
public static final String MimeType = "application/vnd.jyu.nfleet.problemsettings";
10+
public static final double MimeVersion = 2.0;
11+
912
private int VersionNumber;
1013
private double DefaultVehicleSpeedFactor;
1114
private String DefaultVehicleSpeedProfile;

fi/cosky/sdk/RoutingProblemSettingsUpdateRequest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
*/
77

88
public class RoutingProblemSettingsUpdateRequest {
9-
9+
public static final String MimeType = "application/vnd.jyu.nfleet.problemsettings";
10+
public static final double MimeVersion = 2.0;
11+
1012
private double DefaultVehicleSpeedFactor;
1113
private SpeedProfile DefaultVehicleSpeedProfile;
1214

fi/cosky/sdk/RoutingProblemUpdateRequest.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88

99
public class RoutingProblemUpdateRequest extends BaseData {
10+
public static final String MimeType = RoutingProblemData.MimeType;
11+
public static final double MimeVersion = RoutingProblemData.MimeVersion;
12+
1013
private int Id;
1114
private Date CreationDate;
1215
private Date ModifiedDate;
@@ -50,8 +53,6 @@ public void setModifiedDate(Date date) {
5053
this.ModifiedDate = date;
5154
}
5255

53-
54-
5556
public void setName(String name) {
5657
this.Name = name;
5758
}
@@ -66,7 +67,11 @@ public Date getCreationDate() {
6667
public Date getModifiedDate() {
6768
return ModifiedDate;
6869
}
69-
70+
71+
public String getName() {
72+
return Name;
73+
}
74+
7075
@Override
7176
public String toString() {
7277
/* return "RoutingProblemUpdateRequest{" +
@@ -77,10 +82,4 @@ public String toString() {
7782
'}';*/
7883
return API.gson.toJson(this);
7984
}
80-
81-
public String getName() {
82-
return Name;
83-
}
84-
85-
8685
}

0 commit comments

Comments
 (0)