started with a few interfaces that model course templates

Change-Id: I20019ab2e70de1f7b703900e1cf917a5a2daf3e4
This commit is contained in:
Axel Uhl committed 2019-07-03 18:20:53 +02:00
1 parent deaa6cbe6c
commit cb73994802
8 files changed
+123 -8

No files matched your search

@@ -13,8 +13,8 @@ import com.sap.sse.common.IsManagedByCache;
*
*/
public interface Mark extends ControlPoint, IsManagedByCache<SharedDomainFactory> {
public Color getColor();
public String getShape();
public String getPattern();
public MarkType getType();
Color getColor();
String getShape();
String getPattern();
MarkType getType();
}
@@ -0,0 +1,15 @@
package com.sap.sailing.domain.coursetemplate;
import com.sap.sailing.domain.base.ControlPoint;
import com.sap.sse.common.NamedWithID;
/**
* What a {@link WaypointTemplate} references. It is a template for the construction of a {@link ControlPoint} and
* references the {@link MarkTemplate}s from which this control point shall be constructed.
*
* @author Axel Uhl (d043530)
*
*/
public interface ControlPointTemplate extends NamedWithID {
Iterable<MarkTemplate> getMarks();
}
@@ -0,0 +1,15 @@
package com.sap.sailing.domain.coursetemplate;
import com.sap.sailing.domain.base.Course;
/**
* From a {@link CourseTemplate} constructs or updates a {@link Course}.
*
* @author Axel Uhl (d043530)
*
*/
public interface CourseFactory {
Course createCourse(CourseTemplate courseTemplate, int numberOfLaps);
void updateCourse(Course courseToUpdate, CourseTemplate courseTemplate, int numberOfLaps);
}
@@ -0,0 +1,35 @@
package com.sap.sailing.domain.coursetemplate;
import com.sap.sailing.domain.base.Course;
import com.sap.sse.common.NamedWithID;
/**
* A {@link Course} can be created from this template. The template defines {@link MarkTemplate}s,
* {@link ControlPointTemplate}s, and {@link WaypointTemplate}s and assembles the latter into a sequence. The sequence
* of waypoint templates can optionally have a repeatable part. When increasing or reducing the number of laps, more or,
* respectively, fewer occurrences of this repeatable part will be inserted into the {@link Course}.
* <p>
*
* The course template can define additional mark and control point templates that are not part of the waypoint
* sequence. This can be used, e.g., to define spare marks.
* <p>
*
* The course template has a globally unique ID and with this can have a life cycle. It is immutable. If a logical copy
* is created, the new copy will have a different ID ("Save as...").
* <p>
*
* The {@link MarkTemplate}s also have their globally unique IDs. When creating a variant, the new copy can reference
* the <em>same</em> set of a subset of the mark templates that the original references. This is helpful in case
* tracking options or bindings to physical marks are created and remembered. For example, a course template for an "I"
* (inner loop) course and a course template for an "O" (outer loop) course may share the mark templates for the start
* line and the "1" top mark, and when tracker bindings are established, they can automatically be applied to all marks
* created from the same {@link MarkTemplate}.
*
* @author Axel Uhl (d043530)
*
*/
public interface CourseTemplate extends NamedWithID {
Iterable<MarkTemplate> getMarks();
Iterable<WaypointTemplate> getWaypoints(int numberOfLaps);
}
@@ -0,0 +1,15 @@
package com.sap.sailing.domain.coursetemplate;
import com.sap.sailing.domain.base.ControlPointWithTwoMarks;
/**
* A template that can be used to construct a {@link ControlPointWithTwoMarks}.
*
* @author Axel Uhl (d043530)
*
*/
public interface MarkPairTemplate extends ControlPointTemplate {
MarkTemplate getLeft();
MarkTemplate getRight();
}
@@ -0,0 +1,22 @@
package com.sap.sailing.domain.coursetemplate;
import com.sap.sailing.domain.base.Mark;
import com.sap.sailing.domain.common.MarkType;
import com.sap.sse.common.Color;
/**
* A template for creating a {@link Mark}. It has a globally unique ID and can be used in zero or more
* {@link CourseTemplate}s. It is immutable. In addition to a {@link Mark}'s properties it offers an optional
* {@link #getShortName() short name}. Being a special {@link ControlPointTemplate}, a {@link MarkTemplate}
* returns a singleton collection containing itself when asked for its {@link #getMarks() marks}.
*
* @author Axel Uhl (d043530)
*
*/
public interface MarkTemplate extends ControlPointTemplate {
Color getColor();
String getShape();
String getPattern();
MarkType getType();
String getShortName();
}
@@ -0,0 +1,9 @@
package com.sap.sailing.domain.coursetemplate;
import com.sap.sailing.domain.common.PassingInstruction;
import com.sap.sse.common.WithID;
public interface WaypointTemplate extends WithID {
ControlPointTemplate getControlPoint();
PassingInstruction getPassingInstruction();
}
@@ -92,7 +92,7 @@ public class ReplicationMasterDescriptorImpl implements ReplicationMasterDescrip
public URL getReplicationRegistrationRequestURL(UUID uuid, String additional) throws MalformedURLException,
UnsupportedEncodingException {
final String[] replicableIdsAsString = StreamSupport.stream(replicables.spliterator(), /* parallel */ false).map(r->r.getId()).toArray(i->new String[i]);
return new URL("http", getHostname(), servletPort, REPLICATION_SERVLET + "?" + ReplicationServlet.ACTION + "="
return new URL(getHttpRequestProtocol(), getHostname(), servletPort, REPLICATION_SERVLET + "?" + ReplicationServlet.ACTION + "="
+ ReplicationServlet.Action.REGISTER.name() + "&" + ReplicationServlet.SERVER_UUID + "="
+ java.net.URLEncoder.encode(uuid.toString(), "UTF-8") + "&"
+ ReplicationServlet.ADDITIONAL_INFORMATION + "="
@@ -101,9 +101,13 @@ public class ReplicationMasterDescriptorImpl implements ReplicationMasterDescrip
+ java.net.URLEncoder.encode(String.join(",", replicableIdsAsString), "UTF-8"));
}
private String getHttpRequestProtocol() {
return servletPort==443?"https":"http";
}
@Override
public URL getReplicationDeRegistrationRequestURL(UUID uuid) throws MalformedURLException {
return new URL("http", getHostname(), servletPort, REPLICATION_SERVLET + "?" + ReplicationServlet.ACTION + "="
return new URL(getHttpRequestProtocol(), getHostname(), servletPort, REPLICATION_SERVLET + "?" + ReplicationServlet.ACTION + "="
+ ReplicationServlet.Action.DEREGISTER.name() + "&" + ReplicationServlet.SERVER_UUID + "="
+ uuid.toString());
}
@@ -160,14 +164,14 @@ public class ReplicationMasterDescriptorImpl implements ReplicationMasterDescrip
public URL getInitialLoadURL(Iterable<Replicable<?, ?>> replicables) throws MalformedURLException {
final String replicablesIdsAsStringSeparatedByCommas = StreamSupport.stream(replicables.spliterator(), /* parallel */ false).
map(r->r.getId().toString()).collect(Collectors.joining(","));
return new URL("http", getHostname(), servletPort, REPLICATION_SERVLET + "?" + ReplicationServlet.ACTION + "="
return new URL(getHttpRequestProtocol(), getHostname(), servletPort, REPLICATION_SERVLET + "?" + ReplicationServlet.ACTION + "="
+ ReplicationServlet.Action.INITIAL_LOAD.name() +
"&"+ReplicationServlet.REPLICABLES_IDS_AS_STRINGS_COMMA_SEPARATED+"="+replicablesIdsAsStringSeparatedByCommas);
}
@Override
public URL getSendReplicaInitiatedOperationToMasterURL(String replicableIdAsString) throws MalformedURLException {
return new URL("http", getHostname(), servletPort, REPLICATION_SERVLET);
return new URL(getHttpRequestProtocol(), getHostname(), servletPort, REPLICATION_SERVLET);
}
@Override