Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public GetDataEventOutcome getData(String taskId, Map<String, String> params) {
}

@Override
public SetDataEventOutcome setData(String taskId, Map<String, Map<String, String>> dataSet, Map<String, String> params) throws JsonProcessingException {
public SetDataEventOutcome setData(String taskId, Map<String, Map<String, Object>> dataSet, Map<String, String> params) throws JsonProcessingException {
log.debug("Setting data for task [{}] with params: [{}]", taskId, params == null ? "null" : params.toString());
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(dataSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public List<EventOutcome> runActions(List<Action> actions, Case useCase, Optiona
List<Function> functions = useCase == null ? Collections.emptyList() : useCase.getPetriNet().getFunctions();
actions.forEach(action -> {
List<EventOutcome> outcomes = actionsRunner.run(action, useCase, task, params, functions);
if (useCase != null) {
workflowService.updateCaseFromDb(useCase);
}
Comment thread
renczesstefan marked this conversation as resolved.
outcomes.stream().filter(SetDataEventOutcome.class::isInstance)
.forEach(outcome -> {
if (((SetDataEventOutcome) outcome).getChangedFields().isEmpty()) return;
Expand All @@ -75,6 +78,9 @@ public List<EventOutcome> runEventActions(Case useCase, Task task, List<Action>
List<Function> functions = useCase == null ? Collections.emptyList() : useCase.getPetriNet().getFunctions();
actions.forEach(action -> {
List<EventOutcome> outcomes = actionsRunner.run(action, useCase, taskOpt, params, functions);
if (useCase != null) {
workflowService.updateCaseFromDb(useCase);
}
outcomes.stream().filter(SetDataEventOutcome.class::isInstance)
.forEach(outcome -> {
if (((SetDataEventOutcome) outcome).getChangedFields().isEmpty()) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ public Case resolveActorRef(Case useCase, boolean canSaveUseCase) {
return useCase;
}

@Override
public void updateCaseFromDb(Case useCase) {
Case actual = findOne(useCase.getStringId());
actual.getDataSet().forEach((id, dataField) -> {
if (dataField.isNewerThen(useCase.getDataField(id))) {
useCase.getDataSet().put(id, dataField);
}
});
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

/**
* Resolves actor permissions for the useCase based on the actor list data field.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public interface IWorkflowService {

Case resolveActorRef(Case useCase, boolean canSaveUseCase);

void updateCaseFromDb(Case useCase);

CreateCaseEventOutcome createCase(CreateCaseParams createCaseParams);

Page<Case> findAllByAuthor(String authorId, String petriNet, Pageable pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ public final class Nullable<T> implements Serializable {
private static final long serialVersionUID = 8683452581122892189L;

private final T value;

private final Class<T> type;

private Nullable(T value) {
private Nullable(T value, Class<T> type) {
this.value = value;
this.type = type;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

/**
Expand All @@ -39,14 +42,35 @@ public T get() {
return value;
}

/**
* Returns the runtime class type of the value that can be held by this {@code Nullable} instance.
*
* @return the {@code Class} object representing the type {@code T}, or {@code null} if no type was specified
*/
public Class<T> getType() {
return type;
}

/**
* Creates a new {@code Nullable} instance containing the given value.
*
* @param value the value to wrap in a {@code Nullable} instance, can be {@code null}
* @return a {@code Nullable} instance wrapping the provided value
*/
public static <T> Nullable<T> of(T value) {
return new Nullable<>(value);
return new Nullable<>(value, null);
}

/**
* Creates a new {@code Nullable} instance containing the given value and explicit type information.
*
* @param <T> the type of the value to wrap
* @param value the value to wrap in a {@code Nullable} instance, can be {@code null}
* @param type the {@code Class} object representing the type {@code T}, can be {@code null}
* @return a {@code Nullable} instance wrapping the provided value with type information
*/
public static <T> Nullable<T> of(T value, Class<T> type) {
return new Nullable<>(value, type);
}

/**
Expand All @@ -56,7 +80,18 @@ public static <T> Nullable<T> of(T value) {
* @return an empty {@code Nullable} instance
*/
public static <T> Nullable<T> empty() {
return new Nullable<>(null);
return new Nullable<>(null, null);
Comment thread
machacjozef marked this conversation as resolved.
}

/**
* Returns an empty {@code Nullable} instance holding no value but with explicit type information.
*
* @param <T> the type of the value that can be held by this {@code Nullable} instance
* @param type the {@code Class} object representing the type {@code T}, can be {@code null}
* @return an empty {@code Nullable} instance with type information
*/
public static <T> Nullable<T> empty(Class<T> type) {
return new Nullable<>(null, type);
}

/**
Expand Down Expand Up @@ -125,7 +160,7 @@ public Nullable<T> filter(Predicate<? super T> predicate) {
if (isEmpty()) {
return this;
} else {
return predicate.test(value) ? this : empty();
return predicate.test(value) ? this : empty(type);
}
}

Expand Down Expand Up @@ -276,7 +311,8 @@ public boolean equals(Object obj) {
}

return obj instanceof Nullable<?> other
&& Objects.equals(value, other.value);
&& Objects.equals(value, other.value)
&& Objects.equals(type, other.type);
}

/**
Expand All @@ -287,7 +323,7 @@ public boolean equals(Object obj) {
*/
@Override
public int hashCode() {
return Objects.hashCode(value);
return Objects.hash(value, type);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public interface ActionApi {
* @return the outcome of the set data operation
* @throws JsonProcessingException if there is an error processing JSON data
*/
SetDataEventOutcome setData(String taskId, Map<String, Map<String, String>> dataSet, Map<String, String> params) throws JsonProcessingException;
SetDataEventOutcome setData(String taskId, Map<String, Map<String, Object>> dataSet, Map<String, String> params) throws JsonProcessingException;

/**
* Finds a specific case by its ID.
Expand Down
Loading