Skip to content

Commit

Permalink
gdrs
Browse files Browse the repository at this point in the history
  • Loading branch information
trevlenb2 committed Oct 16, 2024
1 parent d6624f7 commit d37209c
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.fasterxml.jackson.databind.ObjectReader;
import com.revealprecision.revealserver.api.v1.controller.querying.KafkaGenerateIndividualTasksController.ListObj;
import com.revealprecision.revealserver.enums.ActionTitleEnum;
import com.revealprecision.revealserver.enums.TaskGenerateRequestValidationStateEnum;
import com.revealprecision.revealserver.integration.mail.EmailService;
import com.revealprecision.revealserver.messaging.message.EventTrackerMessage;
import com.revealprecision.revealserver.persistence.domain.Action;
Expand All @@ -28,7 +27,6 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.data.util.Pair;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -157,7 +155,6 @@ public void etl(EventTrackerMessage eventTrackerMessage) {
List.of(indexIndividualId), targetPlan, actions,
ActionTitleEnum.INDEX_CASE_MEMBER));


}
}
}
Expand Down Expand Up @@ -218,11 +215,10 @@ protected void submitTasks(String owner, List<UUID> entityIds, UUID planIdentifi
if (optionalAction.isPresent()) {
ListObj uuidsObj = new ListObj();
uuidsObj.setUuids(entityIds);
Pair<String, Map<TaskGenerateRequestValidationStateEnum, List<UUID>>> stringMapPair = taskService.generateIndividualTaskWithOwner(
taskService.generateIndividualTaskWithOwnerDirect(
planIdentifier,
optionalAction.get().getIdentifier(),
uuidsObj, owner);
// log.debug("stringMapPair {}",stringMapPair);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public void processPlanUpdatePerActionForTasks(Action action, Plan plan, String
}


public Map<TaskGenerateRequestValidationStateEnum, List<UUID>> validateImportedLocationsForTaskGeneration(
public Map<TaskGenerateRequestValidationStateEnum, List<UUID>> validateImportedLocationsForTaskGenerationDirect(
List<UUID> suppliedLocationUuidList, Action action, Plan plan) {
List<UUID> uuidsThatShouldBeInPlan = getUuidsForTaskGeneration(action, plan, null);

Expand Down Expand Up @@ -312,6 +312,45 @@ public Map<TaskGenerateRequestValidationStateEnum, List<UUID>> validateImportedL

}

public Map<TaskGenerateRequestValidationStateEnum, List<UUID>> validateImportedLocationsForTaskGeneration(
List<UUID> suppliedLocationUuidList, Action action, Plan plan) {
List<UUID> uuidsThatShouldBeInPlan = getUuidsForTaskGeneration(action, plan, null);

List<UUID> existingTaskUuids = taskRepository.findUniqueByPlanAndActionidentifier(
plan, action.getIdentifier())
.stream().map(
existingTask -> new TaskProjectionObj(existingTask.getIdentifier(),
existingTask.getBaseEntityIdentifier()))
.map(TaskProjectionObj::getBaseIdentifier)
.map(UUID::fromString)
.collect(
Collectors.toList());

List<UUID> alreadyExistingTasks = new ArrayList<>(uuidsThatShouldBeInPlan);
alreadyExistingTasks.retainAll(existingTaskUuids);
List<UUID> requestedButExisting = new ArrayList<>(suppliedLocationUuidList);
requestedButExisting.retainAll(alreadyExistingTasks);

List<UUID> alreadyExistingTasksCanGenerate = new ArrayList<>(uuidsThatShouldBeInPlan);
alreadyExistingTasksCanGenerate.removeAll(existingTaskUuids);
List<UUID> canGenerate = new ArrayList<>(suppliedLocationUuidList);
canGenerate.retainAll(alreadyExistingTasksCanGenerate);

List<UUID> shouldNotGenerateList = new ArrayList<>(suppliedLocationUuidList);
shouldNotGenerateList.removeAll(uuidsThatShouldBeInPlan);

List<UUID> alreadyExistingTasksShouldBeCreated = new ArrayList<>(uuidsThatShouldBeInPlan);
alreadyExistingTasksShouldBeCreated.removeAll(existingTaskUuids);
alreadyExistingTasksShouldBeCreated.removeAll(suppliedLocationUuidList);

return Map.of(TaskGenerateRequestValidationStateEnum.ALREADY_EXISTING, requestedButExisting,
TaskGenerateRequestValidationStateEnum.CAN_GENERATE, canGenerate,
TaskGenerateRequestValidationStateEnum.NOT_IN_PLAN, shouldNotGenerateList,
TaskGenerateRequestValidationStateEnum.SHOULD_GENERATE_BUT_NOT_REQUESTED,
alreadyExistingTasksShouldBeCreated);

}

public Pair<String, Map<TaskGenerateRequestValidationStateEnum, List<UUID>>> generateIndividualTask(
UUID planIdentifier,
UUID actionIdentifier, ListObj uuidsObj) {
Expand Down Expand Up @@ -373,6 +412,24 @@ public Pair<String, Map<TaskGenerateRequestValidationStateEnum, List<UUID>>> gen

}

public void generateIndividualTaskWithOwnerDirect(
UUID planIdentifier,
UUID actionIdentifier, ListObj uuidsObj, String owner) {
Action action = actionService.getByIdentifier(actionIdentifier);

Plan plan = action.getGoal().getPlan();

List<UUID> uuids = uuidsObj.getUuids();


ProcessTracker newProcessTracker = processTrackerService.createProcessTracker(
UUID.randomUUID(),
ProcessType.INDIVIDUAL_TASK_GENERATE, planIdentifier);

log.debug("running process tracker");
processLocationListForTasks(action, plan,owner ,
newProcessTracker, uuids, true, false, false);
}

public void processLocationListForTasks(Action action, Plan plan, String ownerId,
ProcessTracker processTracker, List<UUID> uuids, boolean generate, boolean reactivate,
Expand Down

0 comments on commit d37209c

Please sign in to comment.