mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 22:43:57 +00:00
Bug 5085: wired MarkTemplates into SharedSailingDataImpl
This commit is contained in:
1 parent
f4a374fa50
commit
2e229bddc9
4 files changed
+34
-23
No files matched your search
+10
@@ -4,6 +4,7 @@ import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sap.sailing.domain.common.MarkType;
|
||||
import com.sap.sailing.domain.coursetemplate.CommonMarkProperties;
|
||||
import com.sap.sailing.domain.coursetemplate.MarkTemplate;
|
||||
import com.sap.sse.common.Color;
|
||||
import com.sap.sse.common.impl.NamedWithUUIDImpl;
|
||||
@@ -34,6 +35,15 @@ public class MarkTemplateImpl extends NamedWithUUIDImpl implements MarkTemplate
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public MarkTemplateImpl(UUID id, CommonMarkProperties commonMarkProperties) {
|
||||
super(commonMarkProperties.getName(), id);
|
||||
this.shortName = commonMarkProperties.getShortName();
|
||||
this.color = commonMarkProperties.getColor();
|
||||
this.shape = commonMarkProperties.getShape();
|
||||
this.pattern = commonMarkProperties.getPattern();
|
||||
this.type = commonMarkProperties.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<MarkTemplate> getMarks() {
|
||||
return Collections.singleton(this);
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ public interface SharedSailingData {
|
||||
|
||||
Iterable<MarkProperties> getAllMarkProperties(Iterable<String> tagsToFilterFor);
|
||||
|
||||
Iterable<MarkTemplate> getAllMarkTemplates(Iterable<String> tagsToFilterFor);
|
||||
Iterable<MarkTemplate> getAllMarkTemplates();
|
||||
|
||||
Iterable<CourseTemplate> getAllCourseTemplates(Iterable<String> tagsToFilterFor);
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface SharedSailingData {
|
||||
*/
|
||||
void setTrackingDeviceIdentifierForMarkProperties(MarkProperties markProperties, DeviceIdentifier deviceIdentifier);
|
||||
|
||||
MarkTemplate createMarkTemplate(CommonMarkProperties properties, Iterable<String> tags);
|
||||
MarkTemplate createMarkTemplate(CommonMarkProperties properties);
|
||||
|
||||
MarkTemplate getMarkTemplateById(UUID id);
|
||||
|
||||
|
||||
+1
-2
@@ -17,8 +17,7 @@ public interface ReplicatingSharedSailingData extends SharedSailingData,
|
||||
Void internalCreateMarkProperties(UUID idOfNewMarkProperties, CommonMarkProperties properties,
|
||||
Iterable<String> tags);
|
||||
|
||||
Void internalCreateMarkTemplate(UUID idOfNewMarkTemplate, CommonMarkProperties properties,
|
||||
Iterable<String> tags);
|
||||
Void internalCreateMarkTemplate(UUID idOfNewMarkTemplate, CommonMarkProperties properties);
|
||||
|
||||
Void internalCreateCourseTemplate(UUID idOfNewCourseTemplate, String courseTemplateName, Iterable<MarkTemplate> marks,
|
||||
Iterable<WaypointTemplate> waypoints, int zeroBasedIndexOfRepeatablePartStart,
|
||||
|
||||
+21
-19
@@ -25,6 +25,7 @@ import com.sap.sailing.domain.coursetemplate.MarkProperties;
|
||||
import com.sap.sailing.domain.coursetemplate.MarkPropertiesBuilder;
|
||||
import com.sap.sailing.domain.coursetemplate.MarkTemplate;
|
||||
import com.sap.sailing.domain.coursetemplate.WaypointTemplate;
|
||||
import com.sap.sailing.domain.coursetemplate.impl.MarkTemplateImpl;
|
||||
import com.sap.sailing.domain.persistence.DomainObjectFactory;
|
||||
import com.sap.sailing.domain.persistence.MongoObjectFactory;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.DeviceIdentifierMongoHandler;
|
||||
@@ -60,8 +61,18 @@ public class SharedSailingDataImpl implements ReplicatingSharedSailingData, Clea
|
||||
this.mongoObjectFactory = mongoObjectFactory;
|
||||
this.deviceIdentifierServiceFinder = deviceIdentifierServiceFinder;
|
||||
this.securityServiceTracker = securityServiceTracker;
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
private void load() {
|
||||
// load mark templates before mark properties
|
||||
domainObjectFactory.loadAllMarkTemplates().forEach(m -> markTemplatesById.put(m.getId(), m));
|
||||
|
||||
domainObjectFactory.loadAllMarkProperties(v -> markTemplatesById.get(v))
|
||||
.forEach(m -> markPropertiesById.put(m.getId(), m));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearState() throws Exception {
|
||||
removeAll();
|
||||
@@ -77,15 +88,7 @@ public class SharedSailingDataImpl implements ReplicatingSharedSailingData, Clea
|
||||
|
||||
@Override
|
||||
public Iterable<MarkProperties> getAllMarkProperties(Iterable<String> tagsToFilterFor) {
|
||||
|
||||
// TODO: ensure mark templates are loaded
|
||||
|
||||
// TODO: synchronization
|
||||
if (markPropertiesById.isEmpty()) {
|
||||
domainObjectFactory.loadAllMarkProperties(v -> markTemplatesById.get(v))
|
||||
.forEach(m -> markPropertiesById.put(m.getId(), m));
|
||||
}
|
||||
|
||||
return markPropertiesById.values().stream().filter(m -> containsAny(m.getTags(), tagsToFilterFor))
|
||||
.filter(getSecurityService()::hasCurrentUserReadPermission)
|
||||
.collect(Collectors.toList());
|
||||
@@ -101,9 +104,8 @@ public class SharedSailingDataImpl implements ReplicatingSharedSailingData, Clea
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<MarkTemplate> getAllMarkTemplates(Iterable<String> tagsToFilterFor) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public Iterable<MarkTemplate> getAllMarkTemplates() {
|
||||
return markTemplatesById.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,8 +138,8 @@ public class SharedSailingDataImpl implements ReplicatingSharedSailingData, Clea
|
||||
properties.getType()).withTags(tags).build();
|
||||
|
||||
// TODO: synchronization
|
||||
markPropertiesById.put(markProperties.getId(), markProperties);
|
||||
mongoObjectFactory.storeMarkProperties(deviceIdentifierServiceFinder, markProperties);
|
||||
markPropertiesById.put(markProperties.getId(), markProperties);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -181,27 +183,27 @@ public class SharedSailingDataImpl implements ReplicatingSharedSailingData, Clea
|
||||
}
|
||||
|
||||
@Override
|
||||
public MarkTemplate createMarkTemplate(CommonMarkProperties properties, Iterable<String> tags) {
|
||||
public MarkTemplate createMarkTemplate(CommonMarkProperties properties) {
|
||||
final UUID idOfNewMarkTemplate = UUID.randomUUID();
|
||||
return getSecurityService().setOwnershipCheckPermissionForObjectCreationAndRevertOnError(
|
||||
SecuredDomainType.MARK_TEMPLATE, MarkTemplate.getTypeRelativeObjectIdentifier(idOfNewMarkTemplate),
|
||||
idOfNewMarkTemplate + "/" + properties.getName(), () -> {
|
||||
apply(s -> s.internalCreateMarkTemplate(idOfNewMarkTemplate, properties, tags));
|
||||
apply(s -> s.internalCreateMarkTemplate(idOfNewMarkTemplate, properties));
|
||||
return getMarkTemplateById(idOfNewMarkTemplate);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void internalCreateMarkTemplate(UUID idOfNewMarkTemplate, CommonMarkProperties properties,
|
||||
Iterable<String> tags) {
|
||||
// TODO Auto-generated method stub
|
||||
public Void internalCreateMarkTemplate(UUID idOfNewMarkTemplate, CommonMarkProperties properties) {
|
||||
MarkTemplate markTemplate = new MarkTemplateImpl(idOfNewMarkTemplate, properties);
|
||||
mongoObjectFactory.storeMarkTemplate(markTemplate);
|
||||
markTemplatesById.put(markTemplate.getId(), markTemplate);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MarkTemplate getMarkTemplateById(UUID id) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return markTemplatesById.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user