Skip to content

Commit

Permalink
Merge MissionModelService and PlanService
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienmaillard committed Sep 25, 2023
1 parent 08935e5 commit 90b6438
Show file tree
Hide file tree
Showing 19 changed files with 256 additions and 240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1171,8 +1171,6 @@ public void testCoexistenceUncontrollableJustFits() {
assertEquals(3, problem.getSimulationFacade().countSimulationRestarts());
}



@Test
public void testCoexistenceExternalResource() {
Interval period = Interval.betweenClosedOpen(Duration.of(0, Duration.SECONDS), Duration.of(25, Duration.SECONDS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void main(final String[] args) {
final var schedulerService = new CachedSchedulerService(stores.results());
final var scheduleAction = new ScheduleAction(specificationService, schedulerService);

final var generateSchedulingLibAction = new GenerateSchedulingLibAction(merlinService, merlinService);
final var generateSchedulingLibAction = new GenerateSchedulingLibAction(merlinService);

//establish bindings to the service layers
final var bindings = new SchedulerBindings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import gov.nasa.jpl.aerie.json.SchemaCache;
import gov.nasa.jpl.aerie.scheduler.server.models.ActivityType;
import gov.nasa.jpl.aerie.scheduler.server.models.SchedulingDSL;
import gov.nasa.jpl.aerie.scheduler.server.services.MissionModelService;
import gov.nasa.jpl.aerie.scheduler.server.services.MerlinService;

import static gov.nasa.jpl.aerie.constraints.json.ConstraintParsers.profileExpressionP;
import static gov.nasa.jpl.aerie.constraints.json.ConstraintParsers.structExpressionF;
Expand All @@ -20,7 +20,7 @@ public class ActivityTemplateJsonParser implements JsonParser<SchedulingDSL.Acti

private final Map<String, ActivityType> activityTypesByName = new HashMap<>();

public ActivityTemplateJsonParser(MissionModelService.MissionModelTypes activityTypes){
public ActivityTemplateJsonParser(MerlinService.MissionModelTypes activityTypes){
activityTypes.activityTypes().forEach((actType)-> activityTypesByName.put(actType.name(), actType));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import gov.nasa.jpl.aerie.scheduler.TimeUtility;
import gov.nasa.jpl.aerie.scheduler.constraints.timeexpressions.TimeAnchor;
import gov.nasa.jpl.aerie.scheduler.server.http.ActivityTemplateJsonParser;
import gov.nasa.jpl.aerie.scheduler.server.services.MissionModelService;
import gov.nasa.jpl.aerie.scheduler.server.services.MerlinService;
import org.apache.commons.lang3.tuple.Pair;

import java.util.List;
Expand Down Expand Up @@ -57,7 +57,7 @@ public class SchedulingDSL {
$ -> tuple($.duration(), $.occurrence()));

private static JsonObjectParser<GoalSpecifier.RecurrenceGoalDefinition> recurrenceGoalDefinitionP(
MissionModelService.MissionModelTypes activityTypes)
MerlinService.MissionModelTypes activityTypes)
{
return productP
.field("activityTemplate", new ActivityTemplateJsonParser(activityTypes))
Expand Down Expand Up @@ -112,7 +112,7 @@ private static JsonObjectParser<GoalSpecifier.RecurrenceGoalDefinition> recurren
(TimingConstraint.ActivityTimingConstraintFlexibleRange $) -> tuple($.lowerBound(), $.upperBound(), $.singleton()));

private static final JsonObjectParser<GoalSpecifier.CoexistenceGoalDefinition> coexistenceGoalDefinitionP(
MissionModelService.MissionModelTypes activityTypes)
MerlinService.MissionModelTypes activityTypes)
{
return
productP
Expand Down Expand Up @@ -146,7 +146,7 @@ private static final JsonObjectParser<GoalSpecifier.CoexistenceGoalDefinition> c
}

private static final JsonObjectParser<GoalSpecifier.CardinalityGoalDefinition> cardinalityGoalDefinitionP(
MissionModelService.MissionModelTypes activityTypes) {
MerlinService.MissionModelTypes activityTypes) {
return
productP
.field("activityTemplate", new ActivityTemplateJsonParser(activityTypes))
Expand Down Expand Up @@ -195,7 +195,7 @@ private static JsonObjectParser<GoalSpecifier.GoalApplyWhen> goalApplyWhenF(fina
}


private static JsonParser<GoalSpecifier> goalSpecifierF(MissionModelService.MissionModelTypes missionModelTypes) {
private static JsonParser<GoalSpecifier> goalSpecifierF(MerlinService.MissionModelTypes missionModelTypes) {
return recursiveP(self -> SumParsers.sumP("kind", GoalSpecifier.class, List.of(
SumParsers.variant(
"ActivityRecurrenceGoal",
Expand Down Expand Up @@ -243,7 +243,7 @@ private static JsonObjectParser<ConditionSpecifier.AndCondition> conditionAndF(f
globalSchedulingConditionP)
)));

public static final JsonParser<GoalSpecifier> schedulingJsonP(MissionModelService.MissionModelTypes missionModelTypes){
public static final JsonParser<GoalSpecifier> schedulingJsonP(MerlinService.MissionModelTypes missionModelTypes){
return goalSpecifierF(missionModelTypes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public final class ConstraintsTypescriptCodeGenerationHelper
{
private ConstraintsTypescriptCodeGenerationHelper() { }

public static Map<String, TypescriptCodeGenerationService.ActivityType> activityTypes(final MissionModelService.MissionModelTypes missionModelTypes) {
public static Map<String, TypescriptCodeGenerationService.ActivityType> activityTypes(final MerlinService.MissionModelTypes missionModelTypes) {
return missionModelTypes
.activityTypes()
.stream()
Expand All @@ -27,7 +27,7 @@ public static Map<String, TypescriptCodeGenerationService.ActivityType> activity
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}

public static Map<String, ValueSchema> resources(final MissionModelService.MissionModelTypes missionModelTypes) {
public static Map<String, ValueSchema> resources(final MerlinService.MissionModelTypes missionModelTypes) {
return missionModelTypes
.resourceTypes()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
import gov.nasa.jpl.aerie.scheduler.server.models.PlanId;

public record GenerateSchedulingLibAction(
MissionModelService missionModelService,
PlanService.ReaderRole planService
MerlinService.ReaderRole merlinService
) {
public GenerateSchedulingLibAction {
Objects.requireNonNull(planService);
Objects.requireNonNull(merlinService);
}

/**
Expand Down Expand Up @@ -46,10 +45,10 @@ public Response run(final MissionModelId missionModelId, final Optional<PlanId>
final var temporalPolyfillTypes = getTypescriptResource("constraints/TemporalPolyfillTypes.ts");


var missionModelTypes = missionModelService.getMissionModelTypes(missionModelId);
var missionModelTypes = merlinService.getMissionModelTypes(missionModelId);
if(planId.isPresent()) {
final var allResourceTypes = planService.getResourceTypes(planId.get());
missionModelTypes = new MissionModelService.MissionModelTypes(missionModelTypes.activityTypes(), allResourceTypes);
final var allResourceTypes = merlinService.getResourceTypes(planId.get());
missionModelTypes = new MerlinService.MissionModelTypes(missionModelTypes.activityTypes(), allResourceTypes);
}

final var generatedSchedulerCode = TypescriptCodeGenerationService.generateTypescriptTypesFromMissionModel(missionModelTypes);
Expand All @@ -66,7 +65,7 @@ public Response run(final MissionModelId missionModelId, final Optional<PlanId>
"file:///mission-model-generated-code.ts", generatedConstraintsCode,
"file:///%s".formatted(temporalPolyfillTypes.basename), temporalPolyfillTypes.source
));
} catch (final IOException | MissionModelService.MissionModelServiceException | PlanServiceException |
} catch (final IOException | MerlinServiceException |
NoSuchPlanException | NoSuchMissionModelException e) {
return new Response.Failure(e.getMessage());
}
Expand Down
Loading

0 comments on commit 90b6438

Please sign in to comment.