Skip to content

Commit 6cecd1f

Browse files
Finja Averhausmartingr
authored andcommitted
Add support for multiple order types in order sequences
* A new `orderTypes` set has been added that replaces the single `type` field. This set defines the allowed order types for the order sequence, meaning that each order in the sequence must match one of these types. * The request body of the `POST /orderSequences/{NAME}` endpoint has been extended so that it can accept either a list of order types or a single type, but not both simultaneously. Additionally, the responses of the order sequence endpoints (e.g., GET /orderSequences/) now also return the order types. Merged-by: Martin Grzenia <martin.grzenia@iml.fraunhofer.de>
1 parent 4109b5f commit 6cecd1f

File tree

29 files changed

+708
-374
lines changed

29 files changed

+708
-374
lines changed

opentcs-api-base/src/main/java/org/opentcs/access/to/order/OrderConstantsTO.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@
22
// SPDX-License-Identifier: MIT
33
package org.opentcs.access.to.order;
44

5+
import org.opentcs.data.order.OrderSequence;
6+
import org.opentcs.util.annotations.ScheduledApiChange;
7+
58
/**
69
* Defines some constants for {@link TransportOrderCreationTO}s and
710
* {@link OrderSequenceCreationTO}s.
811
*/
912
public interface OrderConstantsTO {
1013

14+
/**
15+
* A special type used to indicate that an order sequence's type is not set.
16+
* An order sequence's type should not be set to this value by a user.
17+
*
18+
* @deprecated This sole purpose of this type is to serve as the default value for
19+
* {@link OrderSequence#getType() an order sequence's type}, which is scheduled for removal with
20+
* openTCS 8.0.
21+
*/
22+
@Deprecated
23+
@ScheduledApiChange(when = "8.0", details = "Will be removed.")
24+
String TYPE_UNSET = "";
1125
/**
1226
* The string representing the <em>any</em> type.
1327
* Primarily intended to be used for a vehicle to indicate there are no restrictions to its

opentcs-api-base/src/main/java/org/opentcs/access/to/order/OrderSequenceCreationTO.java

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import jakarta.annotation.Nullable;
99
import java.io.Serializable;
1010
import java.util.Map;
11+
import java.util.Set;
1112
import org.opentcs.access.to.CreationTO;
13+
import org.opentcs.util.annotations.ScheduledApiChange;
1214

1315
/**
1416
* A transfer object describing a transport order.
@@ -28,7 +30,13 @@ public class OrderSequenceCreationTO
2830
/**
2931
* The type of the order sequence.
3032
*/
33+
@Deprecated
3134
private final String type;
35+
/**
36+
* The set of order types allowed in this order sequence.
37+
* Each order in the sequence must match one of these types.
38+
*/
39+
private final Set<String> orderTypes;
3240
/**
3341
* The (optional) name of the vehicle that is supposed to execute the transport order.
3442
*/
@@ -44,13 +52,15 @@ public class OrderSequenceCreationTO
4452
*
4553
* @param name The name of this transport order.
4654
*/
55+
@SuppressWarnings("deprecation")
4756
public OrderSequenceCreationTO(
4857
@Nonnull
4958
String name
5059
) {
5160
super(name);
5261
this.incompleteName = false;
53-
this.type = OrderConstantsTO.TYPE_NONE;
62+
this.type = OrderConstantsTO.TYPE_UNSET;
63+
this.orderTypes = Set.of(OrderConstantsTO.TYPE_ANY);
5464
this.intendedVehicleName = null;
5565
this.failureFatal = false;
5666
}
@@ -63,13 +73,16 @@ private OrderSequenceCreationTO(
6373
boolean incompleteName,
6474
@Nonnull
6575
String type,
76+
@Nonnull
77+
Set<String> orderTypes,
6678
@Nullable
6779
String intendedVehicleName,
6880
boolean failureFatal
6981
) {
7082
super(name, properties);
7183
this.incompleteName = incompleteName;
72-
this.type = requireNonNull(type, "type");
84+
this.type = requireNonNull(type);
85+
this.orderTypes = requireNonNull(orderTypes);
7386
this.intendedVehicleName = intendedVehicleName;
7487
this.failureFatal = failureFatal;
7588
}
@@ -90,6 +103,7 @@ public OrderSequenceCreationTO withName(
90103
getModifiableProperties(),
91104
incompleteName,
92105
type,
106+
orderTypes,
93107
intendedVehicleName,
94108
failureFatal
95109
);
@@ -111,6 +125,7 @@ public OrderSequenceCreationTO withProperties(
111125
properties,
112126
incompleteName,
113127
type,
128+
orderTypes,
114129
intendedVehicleName,
115130
failureFatal
116131
);
@@ -138,6 +153,7 @@ public OrderSequenceCreationTO withProperty(
138153
propertiesWith(key, value),
139154
incompleteName,
140155
type,
156+
orderTypes,
141157
intendedVehicleName,
142158
failureFatal
143159
);
@@ -169,6 +185,7 @@ public OrderSequenceCreationTO withIncompleteName(boolean incompleteName) {
169185
getModifiableProperties(),
170186
incompleteName,
171187
type,
188+
orderTypes,
172189
intendedVehicleName,
173190
failureFatal
174191
);
@@ -178,7 +195,10 @@ public OrderSequenceCreationTO withIncompleteName(boolean incompleteName) {
178195
* Returns the (optional) type of the order sequence.
179196
*
180197
* @return The (optional) type of the order sequence.
198+
* @deprecated Use {@link OrderSequenceCreationTO#getOrderTypes()} instead.
181199
*/
200+
@Deprecated
201+
@ScheduledApiChange(when = "8.0", details = "Will be removed.")
182202
@Nonnull
183203
public String getType() {
184204
return type;
@@ -189,7 +209,10 @@ public String getType() {
189209
*
190210
* @param type The type.
191211
* @return A copy of this object, differing in the given type.
212+
* @deprecated Use {@link OrderSequenceCreationTO#withOrderTypes(Set)} instead.
192213
*/
214+
@Deprecated
215+
@ScheduledApiChange(when = "8.0", details = "Will be removed.")
193216
public OrderSequenceCreationTO withType(
194217
@Nonnull
195218
String type
@@ -199,6 +222,38 @@ public OrderSequenceCreationTO withType(
199222
getModifiableProperties(),
200223
incompleteName,
201224
type,
225+
orderTypes,
226+
intendedVehicleName,
227+
failureFatal
228+
);
229+
}
230+
231+
/**
232+
* Returns the order types of the order sequence.
233+
*
234+
* @return The order types of the order sequence.
235+
*/
236+
@Nonnull
237+
public Set<String> getOrderTypes() {
238+
return orderTypes;
239+
}
240+
241+
/**
242+
* Creates a copy of this object with the given order types.
243+
*
244+
* @param orderTypes The order types.
245+
* @return A copy of this object, differing in the given type.
246+
*/
247+
public OrderSequenceCreationTO withOrderTypes(
248+
@Nonnull
249+
Set<String> orderTypes
250+
) {
251+
return new OrderSequenceCreationTO(
252+
getName(),
253+
getModifiableProperties(),
254+
incompleteName,
255+
type,
256+
orderTypes,
202257
intendedVehicleName,
203258
failureFatal
204259
);
@@ -230,6 +285,7 @@ public OrderSequenceCreationTO withIntendedVehicleName(
230285
getModifiableProperties(),
231286
incompleteName,
232287
type,
288+
orderTypes,
233289
intendedVehicleName,
234290
failureFatal
235291
);
@@ -258,6 +314,7 @@ public OrderSequenceCreationTO withFailureFatal(boolean failureFatal) {
258314
getModifiableProperties(),
259315
incompleteName,
260316
type,
317+
orderTypes,
261318
intendedVehicleName,
262319
failureFatal
263320
);

0 commit comments

Comments
 (0)