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 @@ -248,7 +248,7 @@ class ImportHelper {
superCreator.setAllToSuperUser()
}

Optional<PetriNet> importProcess(String message, String netIdentifier, String netFileName) {
Optional<PetriNet> importProcessOnce(String message, String netIdentifier, String netFileName) {
PetriNet filter = petriNetService.getNewestVersionByIdentifier(netIdentifier)
if (filter != null) {
log.info("${message} has already been imported.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public Path saveNetFile(PetriNet net, InputStream xmlFile) throws IOException {
@Transactional
protected Optional<PetriNet> createPetriNet() throws MissingPetriNetMetaDataException, MissingIconKeyException {
net = new com.netgrif.application.engine.adapter.spring.petrinet.domain.PetriNet();
net.setVersion(null);

documentValidator.checkConflictingAttributes(document, document.getUsersRef(), document.getUserRef(), "usersRef", "userRef");
documentValidator.checkDeprecatedAttributes(document);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ public class DashboardManagementServiceImpl implements DashboardManagementServic
@Override
public Case createDashboardManagement(DashboardManagementBody body) throws TransitionNotExecutableException {
Case managementCase;
MenuItemUtils.sanitize(body.getId());

managementCase = findDashboardManagement(body.getId());
managementCase = findDashboardManagement(MenuItemUtils.sanitize(body.getId()));
if (managementCase != null) {
log.info("Dashboard management with id:{} already exists", body.getId());
return managementCase;
Expand All @@ -80,7 +79,6 @@ public Case createDashboardManagement(DashboardManagementBody body) throws Trans
*/
@Override
public Case updateDashboardManagement(Case managementCase, DashboardManagementBody body) throws TransitionNotExecutableException {
MenuItemUtils.sanitize(body.getId());
addReferencedMenuItems(body);
ToDataSetOutcome outcome = body.toDataSet();
managementCase = setDataWithExecute(managementCase, DashboardItemConstants.TASK_CONFIGURE, outcome.getDataSet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.netgrif.application.engine.objects.utils.MenuItemUtils;
import com.netgrif.application.engine.objects.workflow.domain.Case;
import com.netgrif.application.engine.objects.workflow.domain.Task;
import com.netgrif.application.engine.objects.workflow.domain.TaskPair;
import com.netgrif.application.engine.objects.workflow.domain.menu.FilterBody;
import com.netgrif.application.engine.objects.workflow.domain.menu.MenuItemBody;
import com.netgrif.application.engine.objects.workflow.domain.menu.MenuItemConstants;
Expand Down Expand Up @@ -333,7 +332,6 @@ public Case duplicateItem(Case originItem, I18nString newTitle, String newIdenti
duplicated.setTitle(newTitle.getDefaultValue());
duplicated = workflowService.save(duplicated);

parentPath(String.valueOf(originItem.getDataSet().get(MenuItemConstants.FIELD_NODE_PATH)));
String newNodePath = createNodePath(parentPath(String.valueOf(originItem.getDataSet().get(MenuItemConstants.FIELD_NODE_PATH))), sanitizedIdentifier);

Map<String, Map<String, Object>> dataSet = new HashMap<>();
Expand Down Expand Up @@ -619,47 +617,6 @@ protected Case getOrCreateFolderRecursive(String path, MenuItemBody body, Case c
return folderCase;
}

protected Case getOrCreateFolderRecursive2(String path, MenuItemBody body, Case childFolderCase) throws TransitionNotExecutableException {
Case folderCase = findFolderCase(path);
if (folderCase != null) {
if (childFolderCase != null) {
folderCase = appendChildCaseIdAndSave(folderCase, childFolderCase.getStringId());
initializeParentId(childFolderCase, folderCase.getStringId());
}
return folderCase;
}

folderCase = createCase(MenuProcessRunner.MENU_NET_IDENTIFIER, body.getMenuName().toString(), ActorTransformer.toLoggedUser(userService.getLoggedOrSystem()));
if (childFolderCase != null) {
folderCase = appendChildCaseIdAndSave(folderCase, childFolderCase.getStringId());
initializeParentId(childFolderCase, folderCase.getStringId());
} else {
folderCase = workflowService.save(folderCase);
}

Optional<TaskPair> newItemTask = folderCase.getTasks().stream().filter(taskPair -> taskPair.getTransition().equals(MenuItemConstants.TRANS_INIT_ID)).findFirst();

ToDataSetOutcome dataSetOutcome = body.toDataSet(null, path, null);
if (childFolderCase != null) {
appendChildCaseIdInDataSet(folderCase, childFolderCase.getStringId(), dataSetOutcome.getDataSet());
}

if (newItemTask.isPresent()) {
setDataWithExecute(folderCase, MenuItemConstants.TRANS_INIT_ID, dataSetOutcome.getDataSet());
}

if (hasParent(path)) {
body = new com.netgrif.application.engine.objects.workflow.domain.menu.MenuItemBody(new I18nString(nameFromPath(path)), "folder");
String parentPath = parentPath(path);
getOrCreateFolderRecursive(parentPath, body, folderCase);
}

folderCase = setDataWithExecute(folderCase, MenuItemConstants.TRANS_INIT_ID, dataSetOutcome.getDataSet());

return folderCase;
}


private Case initializeParentId(Case childFolderCase, String parentFolderCaseId) {
childFolderCase.getDataField(MenuItemConstants.FIELD_PARENT_ID).setValue(Collections.singletonList(parentFolderCaseId));
return workflowService.save(childFolderCase);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,19 @@ public ImportPetriNetEventOutcome importPetriNet(InputStream xmlFile, VersionTyp
PetriNet net = imported.get();

PetriNet existingNet = getNewestVersionByIdentifier(net.getIdentifier());
if (existingNet != null && net.getVersion() == null) {
net.setVersion(existingNet.getVersion());
net.incrementVersion(releaseType);

if (existingNet != null) {
if (existingNet.getVersion().equals(net.getVersion())) {
throw new IllegalArgumentException("Provided Petri net version is already present in the system");
}
if (net.getVersion() == null) {
net.setVersion(existingNet.getVersion());
net.incrementVersion(releaseType);
}
} else if (net.getVersion() == null) {
net.setVersion(new Version());
}
Comment thread
machacjozef marked this conversation as resolved.

processRoleService.saveAll(net.getRoles().values());
net.setAuthor(ActorTransformer.toActorRef(author));
functionCacheService.cachePetriNetFunctions(net);
Expand Down Expand Up @@ -357,8 +366,8 @@ public Page<PetriNetReference> getReferencesByVersion(Version version, LoggedUse
GroupOperation groupByIdentifier = Aggregation.group("identifier").max("version").as("version");
Aggregation aggregation;
if (pageable == null || pageable.isUnpaged()) {
aggregation = Aggregation.newAggregation(
groupByIdentifier
aggregation = Aggregation.newAggregation(
groupByIdentifier
);
} else {
aggregation = Aggregation.newAggregation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class DashboardManagementRunner implements ApplicationEngineStartupRunner

@Override
public void run(ApplicationArguments args) throws Exception {
helper.importProcess("Petri net for dashboard management", DASHBOARD_MANAGEMENT_NET_IDENTIFIER, DASHBOARD_MANAGEMENT_FILE_NAME);
helper.importProcess("Petri net for dashboard items", DASHBOARD_ITEM_NET_IDENTIFIER, DASHBOARD_ITEM_FILE_NAME);
helper.importProcessOnce("Petri net for dashboard management", DASHBOARD_MANAGEMENT_NET_IDENTIFIER, DASHBOARD_MANAGEMENT_FILE_NAME);
helper.importProcessOnce("Petri net for dashboard items", DASHBOARD_ITEM_NET_IDENTIFIER, DASHBOARD_ITEM_FILE_NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.netgrif.application.engine.startup.annotation.RunnerOrder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
Expand All @@ -28,7 +27,7 @@ public class DashboardRunner implements ApplicationEngineStartupRunner {

@Override
public void run(ApplicationArguments args) throws Exception {
helper.importProcess("Petri net for dashboard", DASHBOARD_NET_IDENTIFIER, DASHBOARD_FILE_NAME);
helper.importProcess("Petri net for dashboard tile", DASHBOARD_TILE_NET_IDENTIFIER, DASHBOARD_TILE_FILE_NAME);
helper.importProcessOnce("Petri net for dashboard", DASHBOARD_NET_IDENTIFIER, DASHBOARD_FILE_NAME);
helper.importProcessOnce("Petri net for dashboard tile", DASHBOARD_TILE_NET_IDENTIFIER, DASHBOARD_TILE_FILE_NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ public class FilterRunner implements ApplicationEngineStartupRunner {
public static final String FILTER_PETRI_NET_IDENTIFIER = "filter";

private static final String EXPORT_FILTER_FILE_NAME = "engine-processes/export_filters.xml";
private static final String EXPORT_NET_IDENTIFIER = "export_filters";
public static final String EXPORT_NET_IDENTIFIER = "export_filters";

private static final String IMPORT_FILTER_FILE_NAME = "engine-processes/import_filters.xml";
private static final String IMPORT_NET_IDENTIFIER = "import_filters";
public static final String IMPORT_NET_IDENTIFIER = "import_filters";


@Override
public void run(ApplicationArguments args) throws Exception {
helper.importProcess("Petri net for filters", FILTER_PETRI_NET_IDENTIFIER, FILTER_FILE_NAME);
helper.importProcess("Petri net for importing filters", IMPORT_NET_IDENTIFIER, IMPORT_FILTER_FILE_NAME);
helper.importProcess("Petri net for exporting filters", EXPORT_NET_IDENTIFIER, EXPORT_FILTER_FILE_NAME);
helper.importProcessOnce("Petri net for filters", FILTER_PETRI_NET_IDENTIFIER, FILTER_FILE_NAME);
helper.importProcessOnce("Petri net for importing filters", IMPORT_NET_IDENTIFIER, IMPORT_FILTER_FILE_NAME);
helper.importProcessOnce("Petri net for exporting filters", EXPORT_NET_IDENTIFIER, EXPORT_FILTER_FILE_NAME);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class MenuProcessRunner implements ApplicationEngineStartupRunner {

@Override
public void run(ApplicationArguments args) throws Exception {
helper.importProcess("Petri net for filter preferences", MENU_NET_IDENTIFIER, MENU_ITEM_FILE_NAME);
helper.importProcessOnce("Petri net for filter preferences", MENU_NET_IDENTIFIER, MENU_ITEM_FILE_NAME);
createConfigurationNets();
}

Expand All @@ -37,7 +37,7 @@ private List<PetriNet> createConfigurationNets() {
.map(view -> {
String processIdentifier = view.getIdentifier() + "_configuration";
String filePath = String.format("engine-processes/menu/%s.xml", processIdentifier);
return helper.importProcess(
return helper.importProcessOnce(
String.format("Petri net for %s", processIdentifier),
processIdentifier,
filePath
Expand Down
2 changes: 1 addition & 1 deletion application-engine/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ netgrif:
RoleActionsRunner: debug
CaseFieldsExpressionRunner: debug
actions:
imports: com.netgrif.application.engine.objects.workflow.domain.menu.MenuItemBody,com.netgrif.application.engine.objects.petrinet.domain.I18nString,com.netgrif.application.engine.objects.workflow.domain.menu.dashboard.DashboardManagementBody
imports: com.netgrif.application.engine.objects.workflow.domain.menu.MenuItemBody,com.netgrif.application.engine.objects.petrinet.domain.I18nString,com.netgrif.application.engine.objects.workflow.domain.menu.dashboard.DashboardManagementBody,com.netgrif.application.engine.objects.workflow.domain.menu.dashboard.DashboardItemBody
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@

change inherit_icon value { true }
change inherit_name value { true }
if (menu_items_list.value != null &amp;&amp; menu_items_list.value != null) {
if (menu_items_list.value != null &amp;&amp; menu_items_list.value != "") {
Comment thread
machacjozef marked this conversation as resolved.
make [inherit_name, inherit_icon, icon_color, font_color, font_weight], editable on trans when { true }
make [menu_item_taskRef, filter_divider], visible on trans when { true }
def menuItemCase = workflowService.findOne(menu_items_list.value)
Expand Down Expand Up @@ -309,7 +309,7 @@
change external_icon value { false }
if (inherit_icon.value) {
make [item_icon, item_icon_preview, external_icon], visible on trans when { true }
if (menu_items_list.value != null) {
if (menu_items_list.value != null &amp;&amp; menu_items_list.value != "") {
def menuItemCase = workflowService.findOne(menu_items_list.value)
change item_icon value { menuItemCase.dataSet["menu_icon"].value }
} else {
Expand Down Expand Up @@ -338,7 +338,7 @@
menu_items_list: f.menu_items_list;

if (inherit_name.value) {
if (menu_items_list.value != null) {
if (menu_items_list.value != null &amp;&amp; menu_items_list.value != "") {
def menuItemCase = workflowService.findOne(menu_items_list.value)
change item_name value { menuItemCase.dataSet["menu_name"].value }
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class TestHelper {
@Autowired
private FinisherRunner finisherRunner

@Autowired
private MenuProcessRunner menuProcessRunner

@Autowired
private ImpersonationRunner impersonationRunner

Expand Down Expand Up @@ -100,6 +103,7 @@ class TestHelper {
systemUserRunner.run()
groupRunner.run()
filterRunner.run()
menuProcessRunner.run()
impersonationRunner.run()
superCreator.run()
finisherRunner.run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.netgrif.application.engine.startup.runner.FilterRunner
import com.netgrif.application.engine.startup.ImportHelper
import com.netgrif.application.engine.objects.workflow.domain.Case
import com.netgrif.application.engine.adapter.spring.workflow.domain.QCase
import com.netgrif.application.engine.startup.runner.MenuProcessRunner
import com.netgrif.application.engine.workflow.service.interfaces.IDataService
import com.netgrif.application.engine.workflow.service.interfaces.ITaskService
import com.netgrif.application.engine.workflow.service.interfaces.IWorkflowService
Expand Down Expand Up @@ -107,9 +108,9 @@ class MenuItemApiTest {
assert tabbedTaskView.dataSet[TabbedTaskViewConstants.FIELD_VIEW_FILTER_CASE].value == []
assert tabbedTaskView.dataSet[TabbedTaskViewConstants.FIELD_DEFAULT_HEADERS].value == "meta-title,meta-title"

Case testFolder = findCasesElastic("processIdentifier:$FilterRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue.keyword:\"/netgrif/test\"", PageRequest.of(0, 1))[0]
Case netgrifFolder = findCasesElastic("processIdentifier:$FilterRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue.keyword:\"/netgrif\"", PageRequest.of(0, 1))[0]
Case rootFolder = findCasesElastic("processIdentifier:$FilterRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue.keyword:\"/\"", PageRequest.of(0, 1))[0]
Case testFolder = findCasesElastic("processIdentifier:$MenuProcessRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue.keyword:\"/netgrif/test\"", PageRequest.of(0, 1))[0]
Case netgrifFolder = findCasesElastic("processIdentifier:$MenuProcessRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue.keyword:\"/netgrif\"", PageRequest.of(0, 1))[0]
Case rootFolder = findCasesElastic("processIdentifier:$MenuProcessRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue.keyword:\"/\"", PageRequest.of(0, 1))[0]

assert testFolder.dataSet[MenuItemConstants.FIELD_PARENT_ID].value == [netgrifFolder.stringId]
assert (testFolder.dataSet[MenuItemConstants.FIELD_CHILD_ITEM_IDS].value as ArrayList).contains(item.stringId)
Expand Down Expand Up @@ -200,7 +201,7 @@ class MenuItemApiTest {
Case viewCase = workflowService.findOne(viewId)
Thread.sleep(2000)

Case folderCase = findCasesElastic("processIdentifier:$FilterRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue:\"/netgrif2\"", PageRequest.of(0, 1))[0]
Case folderCase = findCasesElastic("processIdentifier:$MenuProcessRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue:\"/netgrif2\"", PageRequest.of(0, 1))[0]

ArrayList<String> childIds = folderCase.dataSet[MenuItemConstants.FIELD_CHILD_ITEM_IDS].value as ArrayList<String>
assert childIds.contains(viewId) && childIds.size() == 2
Expand All @@ -224,11 +225,11 @@ class MenuItemApiTest {
])
Thread.sleep(2000)

folderCase = findCasesElastic("processIdentifier:$FilterRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue:\"/netgrif/test3\"", PageRequest.of(0, 1))[0]
Case folderCase2 = findCasesElastic("processIdentifier:$FilterRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue:\"/netgrif\"", PageRequest.of(0, 1))[0]
folderCase = findCasesElastic("processIdentifier:$MenuProcessRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue:\"/netgrif/test3\"", PageRequest.of(0, 1))[0]
Case folderCase2 = findCasesElastic("processIdentifier:$MenuProcessRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue:\"/netgrif\"", PageRequest.of(0, 1))[0]
assert folderCase != null && folderCase.dataSet[MenuItemConstants.FIELD_PARENT_ID].value == [folderCase2.stringId]

folderCase = findCasesElastic("processIdentifier:$FilterRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue:\"/netgrif/test3/netgrif2\"", PageRequest.of(0, 1))[0]
folderCase = findCasesElastic("processIdentifier:$MenuProcessRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue:\"/netgrif/test3/netgrif2\"", PageRequest.of(0, 1))[0]
assert folderCase != null
assert folderCase.dataSet[MenuItemConstants.FIELD_NODE_PATH].value == "/netgrif/test3/netgrif2"

Expand Down Expand Up @@ -321,7 +322,7 @@ class MenuItemApiTest {
Case leafItemCase = getMenuItem(apiCase)

sleep(2000)
Case testFolder = findCasesElastic("processIdentifier:$FilterRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue:\"/netgrif/test\"", PageRequest.of(0, 1))[0]
Case testFolder = findCasesElastic("processIdentifier:$MenuProcessRunner.MENU_NET_IDENTIFIER AND dataSet.${MenuItemConstants.FIELD_NODE_PATH}.textValue:\"/netgrif/test\"", PageRequest.of(0, 1))[0]
String netgrifFolderId = (testFolder.dataSet[MenuItemConstants.FIELD_PARENT_ID].value as ArrayList<String>)[0]

Case netgrifFolder = workflowService.findOne(netgrifFolderId)
Expand Down
Loading
Loading