Skip to content

Commit

Permalink
Updated kie-editors-standalone dependency, bumped version to 2.6.7
Browse files Browse the repository at this point in the history
oas committed Sep 30, 2021
1 parent a031d15 commit 8c17171
Showing 2 changed files with 51 additions and 48 deletions.
2 changes: 1 addition & 1 deletion client/src/pages/_workspace/model.vue
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@
</template>
<div style="width: 100%" v-else>
<p class="text-center text-muted mb-2">
<small>The import failed, no further information is available.</small>
<small>The import of this model failed, no further information is available.</small>
</p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.materna.dmn.tester.servlets.model;

import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.Sets;
import de.materna.dmn.tester.drools.helpers.DroolsHelper;
import de.materna.dmn.tester.helpers.SynchronizationHelper;
import de.materna.dmn.tester.persistence.WorkspaceManager;
@@ -56,65 +55,69 @@ public Response getModels(@PathParam("workspace") String workspaceUUID) throws I
@Path("/model")
@Consumes("application/json")
public Response importModels(@PathParam("workspace") String workspaceUUID, String body) throws Exception {
Workspace workspace = WorkspaceManager.getInstance().get(workspaceUUID);

List<Map<String, String>> models = SerializationHelper.getInstance().toClass(body, new TypeReference<LinkedList<Map<String, String>>>() {
});

SynchronizationHelper.getWorkspaceLock(workspaceUUID).writeLock().lock();

// Remove all old models and clear the decision session.
workspace.getModelManager().removeAllFiles();
workspace.clearDecisionSession();

boolean successful = true;

ImportResult globalImportResult = new ImportResult();
Workspace workspace = WorkspaceManager.getInstance().get(workspaceUUID);

List<Map<String, String>> importedModels = new LinkedList<>();
// Import the provided models, collect all import messages.
for (Map<String, String> model : models) {
try {
ImportResult importResult = workspace.getDecisionSession().importModel(model.get("namespace"), model.get("source"));
globalImportResult.getMessages().addAll(importResult.getMessages());
}
catch (ModelImportException exception) {
successful = false;
globalImportResult.getMessages().addAll(exception.getResult().getMessages());
SynchronizationHelper.getWorkspaceLock(workspaceUUID).writeLock().lock();
try {
// Remove all old models and clear the decision session.
workspace.getModelManager().removeAllFiles();
workspace.clearDecisionSession();

boolean successful = true;

ImportResult globalImportResult = new ImportResult();

List<Map<String, String>> importedModels = new LinkedList<>();
// Import the provided models, collect all import messages.
for (Map<String, String> model : models) {
try {
ImportResult importResult = workspace.getDecisionSession().importModel(model.get("namespace"), model.get("source"));
globalImportResult.getMessages().addAll(importResult.getMessages());
}
catch (ModelImportException exception) {
successful = false;
globalImportResult.getMessages().addAll(exception.getResult().getMessages());
}

String uuid = UUID.randomUUID().toString();
workspace.getModelManager().persistFile(uuid, model.get("source"));
model.put("uuid", uuid);
model.remove("source");

importedModels.add(model);
}

String uuid = UUID.randomUUID().toString();
workspace.getModelManager().persistFile(uuid, model.get("source"));
model.put("uuid", uuid);
model.remove("source");

importedModels.add(model);
}
Configuration configuration = workspace.getConfig();
configuration.setModels(importedModels);

Configuration configuration = workspace.getConfig();
configuration.setModels(importedModels);

// Check if the configured decision service still exists.
Configuration.DecisionService decisionService = configuration.getDecisionService();
if (decisionService != null) {
if (configuration.getModels().size() == 0 || workspace.getDecisionSession().getModel(DroolsHelper.getMainModelNamespace(workspace)).getDecisionServices().stream().noneMatch(name -> name.equals(decisionService.getName()))) {
// If the decision service does not exist anymore, we will remove the reference from the configuration.
configuration.setDecisionService(null);
// Check if the configured decision service still exists.
Configuration.DecisionService decisionService = configuration.getDecisionService();
if (decisionService != null) {
if (configuration.getModels().size() == 0 || workspace.getDecisionSession().getModel(DroolsHelper.getMainModelNamespace(workspace)).getDecisionServices().stream().noneMatch(name -> name.equals(decisionService.getName()))) {
// If the decision service does not exist anymore, we will remove the reference from the configuration.
configuration.setDecisionService(null);
}
}
}

// Update the configuration and add an access log entry.
configuration.setModifiedDate(System.currentTimeMillis());
configuration.serialize();
// Update the configuration and add an access log entry.
configuration.setModifiedDate(System.currentTimeMillis());
configuration.serialize();

SynchronizationHelper.getWorkspaceLock(workspaceUUID).writeLock().unlock();
SynchronizationHelper.getWorkspaceLock(workspaceUUID).writeLock().unlock();

workspace.getAccessLog().writeMessage("Imported models", configuration.getModifiedDate());
workspace.getAccessLog().writeMessage("Imported models", configuration.getModifiedDate());

// Notify all sessions.
SessionManager.getInstance().notify(workspaceUUID, "{\"type\": \"imported\"}");
// Notify all sessions.
SessionManager.getInstance().notify(workspaceUUID, "{\"type\": \"imported\"}");

return Response.status(successful ? Response.Status.OK : Response.Status.BAD_REQUEST).entity(SerializationHelper.getInstance().toJSON(globalImportResult)).build();
return Response.status(successful ? Response.Status.OK : Response.Status.BAD_REQUEST).entity(SerializationHelper.getInstance().toJSON(globalImportResult)).build();
}
finally {
SynchronizationHelper.getWorkspaceLock(workspaceUUID).writeLock().unlock();
}
}

@GET

0 comments on commit 8c17171

Please sign in to comment.