From bd5b9cf3e4e81386bd8949563c15422b5b45f098 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Thu, 4 Mar 2021 20:28:34 +0100 Subject: [PATCH] Controller for managing Workflow templates Former-commit-id: 03c06e69b6f7d6957c24ad7d7e4d44c20e14d05b --- .../ConfigurationLifecyclesController.java | 126 ++- .../ConfigurationWorkflowController.java | 902 +++++++++++++++++- .../SelectedLifecycleDefinitionModel.java | 2 +- .../SelectedPhaseDefinitionModel.java | 73 ++ .../SelectedWorkflowTaskTemplateModel.java | 90 ++ .../SelectedWorkflowTemplateModel.java | 77 ++ .../WorkflowTaskTemplateListModel.java | 84 ++ .../WorkflowTemplateListModel.java | 54 ++ 8 files changed, 1356 insertions(+), 52 deletions(-) create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedPhaseDefinitionModel.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedWorkflowTaskTemplateModel.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedWorkflowTemplateModel.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contentsections/WorkflowTaskTemplateListModel.java create mode 100644 ccm-cms/src/main/java/org/librecms/ui/contentsections/WorkflowTemplateListModel.java diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/ConfigurationLifecyclesController.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/ConfigurationLifecyclesController.java index a8c376179..95b7d2207 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/ConfigurationLifecyclesController.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/ConfigurationLifecyclesController.java @@ -70,7 +70,10 @@ public class ConfigurationLifecyclesController { private PhaseDefinititionRepository phaseDefinititionRepo; @Inject - private SelectedLifecycleDefinitionModel selectedDefinitionModel; + private SelectedLifecycleDefinitionModel selectedLifecycleDefModel; + + @Inject + private SelectedPhaseDefinitionModel selectedPhaseDefModel; @GET @Path("/") @@ -130,8 +133,8 @@ public class ConfigurationLifecyclesController { ); } final LifecycleDefinition definition = definitionResult.get(); - selectedDefinitionModel.setUuid(definition.getUuid()); - selectedDefinitionModel.setLabel( + selectedLifecycleDefModel.setUuid(definition.getUuid()); + selectedLifecycleDefModel.setLabel( definition .getLabel() .getValues() @@ -144,7 +147,7 @@ public class ConfigurationLifecyclesController { ) ) ); - selectedDefinitionModel.setDescription( + selectedLifecycleDefModel.setDescription( definition .getDescription() .getValues() @@ -157,7 +160,7 @@ public class ConfigurationLifecyclesController { ) ) ); - selectedDefinitionModel.setPhaseDefinitions( + selectedLifecycleDefModel.setPhaseDefinitions( definition .getPhaseDefinitions() .stream() @@ -523,6 +526,79 @@ public class ConfigurationLifecyclesController { ); } + @GET + @Path("/{lifecycleIdentifier}/phases/{phaseIdentifier}") + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public String showPhase( + @PathParam("sectionIdentifier") final String sectionIdentifierParam, + @PathParam("lifecycleIdentifier") final String lifecycleIdentiferParam, + @PathParam("phaseIdentifier") final String phaseIdentifierParam + ) { + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional definitionResult + = findLifecycleDefinition(section, sectionIdentifierParam); + if (!definitionResult.isPresent()) { + return showLifecycleDefinitionNotFound( + section, sectionIdentifierParam + ); + } + final LifecycleDefinition definition = definitionResult.get(); + final Optional phaseDefinitionResult + = findPhaseDefinition(definition, sectionIdentifierParam); + if (!phaseDefinitionResult.isPresent()) { + return showPhaseDefinitionNotFound( + section, + sectionIdentifierParam, + phaseIdentifierParam + ); + } + final PhaseDefinition phaseDefinition = phaseDefinitionResult.get(); + selectedPhaseDefModel.setDefaultDelay(phaseDefinition.getDefaultDelay()); + selectedPhaseDefModel.setDefaultDuration( + phaseDefinition.getDefaultDuration() + ); + selectedPhaseDefModel.setDefinitionId(phaseDefinition.getDefinitionId()); + selectedPhaseDefModel.setDescription( + phaseDefinition + .getDescription() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + entry -> entry.getValue() + ) + ) + ); + selectedPhaseDefModel.setLabel( + phaseDefinition + .getLabel() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + entry -> entry.getValue() + ) + ) + ); + return "org/librecms/ui/contentsection/configuration/lifecycle-phase.xhtml"; + } + @POST @Path("/{lifecycleIdentifier}/phases/{phaseIdentifier}/@edit") @AuthorizationRequired @@ -570,9 +646,10 @@ public class ConfigurationLifecyclesController { phaseDefinititionRepo.save(phaseDefinition); return String.format( - "redirect:/%s/configuration/lifecycles/%s", + "redirect:/%s/configuration/lifecycles/%s/phases/%s", sectionIdentifierParam, - lifecycleIdentiferParam + lifecycleIdentiferParam, + phaseIdentifierParam ); } @@ -619,9 +696,10 @@ public class ConfigurationLifecyclesController { phaseDefinititionRepo.delete(phaseDefinition); return String.format( - "redirect:/%s/configuration/lifecycles/%s", + "redirect:/%s/configuration/lifecycles/%s/phases/%s", sectionIdentifierParam, - lifecycleIdentiferParam + lifecycleIdentiferParam, + phaseIdentifierParam ); } @@ -670,9 +748,10 @@ public class ConfigurationLifecyclesController { phaseDefinititionRepo.save(phaseDefinition); return String.format( - "redirect:/%s/configuration/lifecycles/%s", + "redirect:/%s/configuration/lifecycles/%s/phases/%s", sectionIdentifierParam, - lifecycleIdentiferParam + lifecycleIdentiferParam, + phaseIdentifierParam ); } @@ -721,9 +800,10 @@ public class ConfigurationLifecyclesController { phaseDefinititionRepo.save(phaseDefinition); return String.format( - "redirect:/%s/configuration/lifecycles/%s", + "redirect:/%s/configuration/lifecycles/%s/phases/%s", sectionIdentifierParam, - lifecycleIdentiferParam + lifecycleIdentiferParam, + phaseIdentifierParam ); } @@ -772,9 +852,10 @@ public class ConfigurationLifecyclesController { phaseDefinititionRepo.save(phaseDefinition); return String.format( - "redirect:/%s/configuration/lifecycles/%s", + "redirect:/%s/configuration/lifecycles/%s/phases/%s", sectionIdentifierParam, - lifecycleIdentiferParam + lifecycleIdentiferParam, + phaseIdentifierParam ); } @@ -825,9 +906,10 @@ public class ConfigurationLifecyclesController { phaseDefinititionRepo.save(phaseDefinition); return String.format( - "redirect:/%s/configuration/lifecycles/%s", + "redirect:/%s/configuration/lifecycles/%s/phases/%s", sectionIdentifierParam, - lifecycleIdentiferParam + lifecycleIdentiferParam, + phaseIdentifierParam ); } @@ -879,9 +961,10 @@ public class ConfigurationLifecyclesController { phaseDefinititionRepo.save(phaseDefinition); return String.format( - "redirect:/%s/configuration/lifecycles/%s", + "redirect:/%s/configuration/lifecycles/%s/phases/%s", sectionIdentifierParam, - lifecycleIdentiferParam + lifecycleIdentiferParam, + phaseIdentifierParam ); } @@ -930,9 +1013,10 @@ public class ConfigurationLifecyclesController { phaseDefinititionRepo.save(phaseDefinition); return String.format( - "redirect:/%s/configuration/lifecycles/%s", + "redirect:/%s/configuration/lifecycles/%s/phases/%s", sectionIdentifierParam, - lifecycleIdentiferParam + lifecycleIdentiferParam, + phaseIdentifierParam ); } diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/ConfigurationWorkflowController.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/ConfigurationWorkflowController.java index 712ef77bf..5db9c4714 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/ConfigurationWorkflowController.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/ConfigurationWorkflowController.java @@ -5,10 +5,28 @@ */ package org.librecms.ui.contentsections; +import org.libreccm.api.Identifier; +import org.libreccm.api.IdentifierParser; +import org.libreccm.l10n.GlobalizationHelper; import org.libreccm.security.AuthorizationRequired; +import org.libreccm.workflow.CircularTaskDependencyException; +import org.libreccm.workflow.Task; +import org.libreccm.workflow.TaskManager; +import org.libreccm.workflow.TaskRepository; +import org.libreccm.workflow.Workflow; +import org.libreccm.workflow.WorkflowManager; +import org.libreccm.workflow.WorkflowRepository; +import org.librecms.contentsection.ContentSection; +import org.librecms.contentsection.ContentSectionManager; + +import java.util.Locale; +import java.util.Optional; +import java.util.stream.Collectors; import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; import javax.mvc.Controller; +import javax.mvc.Models; import javax.transaction.Transactional; import javax.ws.rs.FormParam; import javax.ws.rs.GET; @@ -25,124 +43,439 @@ import javax.ws.rs.PathParam; @Path("/{sectionIdentifier}/configuration/workflows") public class ConfigurationWorkflowController { + @Inject + private AdminPermissionsChecker adminPermissionsChecker; + + @Inject + private ContentSectionManager sectionManager; + + @Inject + private ContentSectionsUi sectionsUi; + + @Inject + private GlobalizationHelper globalizationHelper; + + @Inject + private IdentifierParser identifierParser; + + @Inject + private Models models; + + @Inject + private WorkflowManager workflowManager; + + @Inject + private WorkflowRepository workflowRepo; + + @Inject + private SelectedWorkflowTemplateModel selectedWorkflowTemplateModel; + + @Inject + private SelectedWorkflowTaskTemplateModel selectedWorkflowTaskTemplateModel; + + @Inject + private TaskManager taskManager; + + @Inject + private TaskRepository taskRepo; + @GET @Path("/") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) - public String listWorkflowDefinitions( + public String listWorkflowTemplates( @PathParam("sectionIdentifier") final String sectionIdentifierParam ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + return sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerWorkflows(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + models.put( + "workflowTemplates", + section + .getWorkflowTemplates() + .stream() + .map(this::buildWorkflowTemplateListModel) + .collect(Collectors.toList()) + ); + return "org/librecms/ui/contentsection/configuration/workflows.xhtml"; } @GET @Path("/{workflowIdentifier}") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) - public String showWorkflowDefinition( + public String showWorkflowTemplate( @PathParam("sectionIdentifier") final String sectionIdentifierParam, @PathParam("workflowIdentifier") final String workflowIdentiferParam ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + return sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerWorkflows(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + selectedWorkflowTemplateModel.setDescription( + workflow + .getDescription() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + entry -> entry.getValue() + ) + ) + ); + selectedWorkflowTemplateModel.setName( + workflow + .getName() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + entry -> entry.getValue() + ) + ) + ); + selectedWorkflowTemplateModel.setTasks( + workflow + .getTasks() + .stream() + .map(this::buildWorkflowTaskTemplateListModel) + .collect(Collectors.toList()) + ); + selectedWorkflowTemplateModel.setUuid(workflow.getUuid()); + selectedWorkflowTemplateModel.setWorkflowId(workflow.getWorkflowId()); + + return "org/librecms/ui/contentsection/configuration/workflow.xhtml"; } @POST @Path("/@add") @AuthorizationRequired - public String addWorkflowDefinition( + public String addWorkflowTemplate( @PathParam("sectionIdentifier") final String sectionIdentifierParam, @FormParam("label") final String label ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Workflow template = new Workflow(); + template.setAbstractWorkflow(true); + template.getName().addValue( + globalizationHelper.getNegotiatedLocale(), label + ); + sectionManager.addWorkflowTemplateToContentSection(template, section); + + return String.format( + "redirect:/%s/configuration/workflows", sectionIdentifierParam + ); } @POST @Path("/{workflowIdentifier}/@delete") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) - public String deleteWorkflowDefinition( + public String deleteWorkflowTemplate( @PathParam("sectionIdentifier") final String sectionIdentifierParam, @PathParam("workflowIdentifier") final String workflowIdentiferParam ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + sectionManager.removeWorkflowTemplateFromContentSection( + workflow, section + ); + workflowRepo.delete(workflow); + + return String.format( + "redirect:/%s/configuration/workflows", sectionIdentifierParam + ); } @POST @Path("/{workflowIdentifier}/label/@add") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) - public String addWorkflowDefinitionLabel( + public String addWorkflowTemplateName( @PathParam("sectionIdentifier") final String sectionIdentifierParam, @PathParam("workflowIdentifier") final String workflowIdentiferParam, @FormParam("locale") final String localeParam, @FormParam("value") final String value ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + workflow.getName().addValue(new Locale(localeParam), value); + workflowRepo.save(workflow); + + return String.format( + "redirect:/%s/configuration/workflows/%s", + sectionIdentifierParam, + workflowIdentiferParam + ); } @POST @Path("/{workflowIdentifier}/label/@edit/{locale}") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) - public String editWorkflowDefinitionLabel( + public String editWorkflowTemplateName( @PathParam("sectionIdentifier") final String sectionIdentifierParam, @PathParam("workflowIdentifier") final String workflowIdentiferParam, @PathParam("locale") final String localeParam, @FormParam("value") final String value ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + workflow.getName().addValue(new Locale(localeParam), value); + workflowRepo.save(workflow); + + return String.format( + "redirect:/%s/configuration/workflows/%s", + sectionIdentifierParam, + workflowIdentiferParam + ); } @POST @Path("/{workflowIdentifier}/label/@remove/{locale}") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) - public String removeWorkflowDefinitionLabel( + public String removeWorkflowTemplateName( @PathParam("sectionIdentifier") final String sectionIdentifierParam, @PathParam("workflowIdentifier") final String workflowIdentiferParam, @PathParam("locale") final String localeParam, @FormParam("value") final String value ) { - throw new UnsupportedOperationException("Not implemented yet."); + + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + workflow.getName().removeValue(new Locale(localeParam)); + workflowRepo.save(workflow); + + return String.format( + "redirect:/%s/configuration/workflows/%s", + sectionIdentifierParam, + workflowIdentiferParam + ); } @POST @Path("/{workflowIdentifier}/description/@add") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) - public String addWorkflowDefinitionDescription( + public String addWorkflowTemplateDescription( @PathParam("sectionIdentifier") final String sectionIdentifierParam, @PathParam("workflowIdentifier") final String workflowIdentiferParam, @FormParam("locale") final String localeParam, @FormParam("value") final String value ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + workflow.getDescription().addValue(new Locale(localeParam), value); + workflowRepo.save(workflow); + + return String.format( + "redirect:/%s/configuration/workflows/%s", + sectionIdentifierParam, + workflowIdentiferParam + ); } @POST @Path("/{workflowIdentifier}/description/@edit/{locale}") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) - public String editWorkflowDefinitionDescription( + public String editWorkflowTemplateDescription( @PathParam("sectionIdentifier") final String sectionIdentifierParam, @PathParam("workflowIdentifier") final String workflowIdentiferParam, @PathParam("locale") final String localeParam, @FormParam("value") final String value ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + workflow.getDescription().addValue(new Locale(localeParam), value); + workflowRepo.save(workflow); + + return String.format( + "redirect:/%s/configuration/workflows/%s", + sectionIdentifierParam, + workflowIdentiferParam + ); } @POST @Path("/{workflowIdentifier}/description/@remove/{locale}") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) - public String removeWorkflowDefinitionDescription( + public String removeWorkflowTemplateDescription( @PathParam("sectionIdentifier") final String sectionIdentifierParam, @PathParam("workflowIdentifier") final String workflowIdentiferParam, @PathParam("locale") final String localeParam, @FormParam("value") final String value ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + workflow.getDescription().removeValue(new Locale(localeParam)); + workflowRepo.save(workflow); + + return String.format( + "redirect:/%s/configuration/workflows/%s", + sectionIdentifierParam, + workflowIdentiferParam + ); } @POST @@ -154,7 +487,36 @@ public class ConfigurationWorkflowController { @PathParam("workflowIdentifier") final String workflowIdentiferParam, @FormParam("label") final String label ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + final Task task = new Task(); + task.getLabel().addValue( + globalizationHelper.getNegotiatedLocale(), label + ); + taskManager.addTask(workflow, task); + + return String.format( + "redirect:/%s/configuration/workflows/%s", + sectionIdentifierParam, + workflowIdentiferParam + ); } @POST @@ -166,7 +528,42 @@ public class ConfigurationWorkflowController { @PathParam("workflowIdentifier") final String workflowIdentiferParam, @PathParam("taskIdentifier") final String taskIdentifierParam ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + final Optional taskResult = findTaskTemplate( + workflow, taskIdentifierParam + ); + if (!taskResult.isPresent()) { + return showWorkflowTaskTemplateNotFound( + section, workflowIdentiferParam, taskIdentifierParam + ); + } + final Task task = taskResult.get(); + taskManager.removeTask(workflow, task); + taskRepo.delete(task); + + return String.format( + "redirect:/%s/configuration/workflows/%s", + sectionIdentifierParam, + workflowIdentiferParam + ); } @POST @@ -180,7 +577,43 @@ public class ConfigurationWorkflowController { @FormParam("locale") final String localeParam, @FormParam("value") final String value ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + final Optional taskResult = findTaskTemplate( + workflow, taskIdentifierParam + ); + if (!taskResult.isPresent()) { + return showWorkflowTaskTemplateNotFound( + section, workflowIdentiferParam, taskIdentifierParam + ); + } + final Task task = taskResult.get(); + task.getLabel().addValue(new Locale(localeParam), value); + taskRepo.save(task); + + return String.format( + "redirect:/%s/configuration/workflows/%s/tasks/%s", + sectionIdentifierParam, + workflowIdentiferParam, + taskIdentifierParam + ); } @POST @@ -194,7 +627,43 @@ public class ConfigurationWorkflowController { @PathParam("locale") final String localeParam, @FormParam("value") final String value ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + final Optional taskResult = findTaskTemplate( + workflow, taskIdentifierParam + ); + if (!taskResult.isPresent()) { + return showWorkflowTaskTemplateNotFound( + section, workflowIdentiferParam, taskIdentifierParam + ); + } + final Task task = taskResult.get(); + task.getLabel().addValue(new Locale(localeParam), value); + taskRepo.save(task); + + return String.format( + "redirect:/%s/configuration/workflows/%s/tasks/%s", + sectionIdentifierParam, + workflowIdentiferParam, + taskIdentifierParam + ); } @POST @@ -208,7 +677,43 @@ public class ConfigurationWorkflowController { @PathParam("taskIdentifier") final String taskIdentifierParam, @PathParam("locale") final String localeParam ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + final Optional taskResult = findTaskTemplate( + workflow, taskIdentifierParam + ); + if (!taskResult.isPresent()) { + return showWorkflowTaskTemplateNotFound( + section, workflowIdentiferParam, taskIdentifierParam + ); + } + final Task task = taskResult.get(); + task.getLabel().removeValue(new Locale(localeParam)); + taskRepo.save(task); + + return String.format( + "redirect:/%s/configuration/workflows/%s/tasks/%s", + sectionIdentifierParam, + workflowIdentiferParam, + taskIdentifierParam + ); } @POST @@ -222,7 +727,43 @@ public class ConfigurationWorkflowController { @FormParam("locale") final String localeParam, @FormParam("value") final String value ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + final Optional taskResult = findTaskTemplate( + workflow, taskIdentifierParam + ); + if (!taskResult.isPresent()) { + return showWorkflowTaskTemplateNotFound( + section, workflowIdentiferParam, taskIdentifierParam + ); + } + final Task task = taskResult.get(); + task.getDescription().addValue(new Locale(localeParam), value); + taskRepo.save(task); + + return String.format( + "redirect:/%s/configuration/workflows/%s/tasks/%s", + sectionIdentifierParam, + workflowIdentiferParam, + taskIdentifierParam + ); } @POST @@ -237,7 +778,43 @@ public class ConfigurationWorkflowController { @PathParam("locale") final String localeParam, @FormParam("value") final String value ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + final Optional taskResult = findTaskTemplate( + workflow, taskIdentifierParam + ); + if (!taskResult.isPresent()) { + return showWorkflowTaskTemplateNotFound( + section, workflowIdentiferParam, taskIdentifierParam + ); + } + final Task task = taskResult.get(); + task.getDescription().addValue(new Locale(localeParam), value); + taskRepo.save(task); + + return String.format( + "redirect:/%s/configuration/workflows/%s/tasks/%s", + sectionIdentifierParam, + workflowIdentiferParam, + taskIdentifierParam + ); } @POST @@ -251,7 +828,43 @@ public class ConfigurationWorkflowController { @PathParam("taskIdentifier") final String taskIdentifierParam, @PathParam("locale") final String localeParam ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + final Optional taskResult = findTaskTemplate( + workflow, taskIdentifierParam + ); + if (!taskResult.isPresent()) { + return showWorkflowTaskTemplateNotFound( + section, workflowIdentiferParam, taskIdentifierParam + ); + } + final Task task = taskResult.get(); + task.getDescription().removeValue(new Locale(localeParam)); + taskRepo.save(task); + + return String.format( + "redirect:/%s/configuration/workflows/%s/tasks/%s", + sectionIdentifierParam, + workflowIdentiferParam, + taskIdentifierParam + ); } @POST @@ -265,7 +878,60 @@ public class ConfigurationWorkflowController { @PathParam("taskIdentifier") final String taskIdentifierParam, @FormParam("blockingTask") final String blockingTaskParam ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + final Optional taskResult = findTaskTemplate( + workflow, taskIdentifierParam + ); + if (!taskResult.isPresent()) { + return showWorkflowTaskTemplateNotFound( + section, workflowIdentiferParam, taskIdentifierParam + ); + } + final Optional blockingTaskResult = findTaskTemplate( + workflow, blockingTaskParam + ); + if (!blockingTaskResult.isPresent()) { + return showWorkflowTaskTemplateNotFound( + section, workflowIdentiferParam, blockingTaskParam + ); + } + + final Task task = taskResult.get(); + final Task blockingTask = blockingTaskResult.get(); + try { + taskManager.addDependentTask(blockingTask, task); + } catch (CircularTaskDependencyException ex) { + models.put("sectionIdentifier", section.getLabel()); + models.put("workflowTemplateIdentifier", workflowIdentiferParam); + models.put("blockedTaskIdentifier", taskIdentifierParam); + models.put("blockingTaskIdentifier", blockingTaskParam); + return "org/librecms/ui/contentsection/configuration/workflowtask-circular-dependency.xhtml"; + } + + return String.format( + "redirect:/%s/configuration/workflows/%s/tasks/%s", + sectionIdentifierParam, + workflowIdentiferParam, + taskIdentifierParam + ); } @POST @@ -279,7 +945,183 @@ public class ConfigurationWorkflowController { @PathParam("taskIdentifier") final String taskIdentifierParam, @PathParam("blockingTaskIdentifier") final String blockingTaskParam ) { - throw new UnsupportedOperationException("Not implemented yet."); + final Optional sectionResult = sectionsUi + .findContentSection(sectionIdentifierParam); + if (!sectionResult.isPresent()) { + sectionsUi.showContentSectionNotFound(sectionIdentifierParam); + } + final ContentSection section = sectionResult.get(); + if (!adminPermissionsChecker.canAdministerLifecycles(section)) { + return sectionsUi.showAccessDenied( + "sectionIdentifier", sectionIdentifierParam + ); + } + + final Optional workflowResult = findWorkflowTemplate( + section, workflowIdentiferParam + ); + if (!workflowResult.isPresent()) { + return showWorkflowTemplateNotFound(section, workflowIdentiferParam); + } + final Workflow workflow = workflowResult.get(); + final Optional taskResult = findTaskTemplate( + workflow, taskIdentifierParam + ); + if (!taskResult.isPresent()) { + return showWorkflowTaskTemplateNotFound( + section, workflowIdentiferParam, taskIdentifierParam + ); + } + final Optional blockingTaskResult = findTaskTemplate( + workflow, blockingTaskParam + ); + if (!blockingTaskResult.isPresent()) { + return showWorkflowTaskTemplateNotFound( + section, workflowIdentiferParam, blockingTaskParam + ); + } + + final Task task = taskResult.get(); + final Task blockingTask = blockingTaskResult.get(); + taskManager.removeDependentTask(blockingTask, task); + + return String.format( + "redirect:/%s/configuration/workflows/%s/tasks/%s", + sectionIdentifierParam, + workflowIdentiferParam, + taskIdentifierParam + ); + } + + private Optional findWorkflowTemplate( + final ContentSection section, final String templateIdentifierParam + ) { + final Identifier identifier = identifierParser.parseIdentifier( + templateIdentifierParam + ); + switch (identifier.getType()) { + case ID: + return section + .getWorkflowTemplates() + .stream() + .filter( + template -> template.isAbstractWorkflow() + ) + .filter( + template -> template.getWorkflowId() == Long.parseLong( + identifier.getIdentifier()) + ).findAny(); + default: + return section + .getWorkflowTemplates() + .stream() + .filter( + template -> template.isAbstractWorkflow() + ) + .filter( + template -> template.getUuid().equals(identifier + .getIdentifier()) + ).findAny(); + } + } + + private String showWorkflowTemplateNotFound( + final ContentSection section, + final String templateIdentifier + ) { + models.put("sectionIdentifier", section.getLabel()); + models.put("workflowTemplateIdentifier", templateIdentifier); + return "org/librecms/ui/contentsection/configuration/workflow-not-found.xhtml"; + } + + private Optional findTaskTemplate( + final Workflow workflow, + final String taskTemplateIdentifierParam + ) { + final Identifier identifier = identifierParser.parseIdentifier( + taskTemplateIdentifierParam + ); + switch (identifier.getType()) { + case ID: + return workflow + .getTasks() + .stream() + .filter( + template -> template.getTaskId() == Long.parseLong( + identifier.getIdentifier() + ) + ).findAny(); + default: + return workflow + .getTasks() + .stream() + .filter( + template -> template.getUuid().equals(identifier + .getIdentifier()) + ).findAny(); + } + } + + private String showWorkflowTaskTemplateNotFound( + final ContentSection section, + final String workflowTemplateIdentifier, + final String taskTemplateIdentifier + ) { + models.put("sectionIdentifier", section.getLabel()); + models.put("workflowTemplateIdentifier", workflowTemplateIdentifier); + models.put("workflowTaskTemplateIdentifier", taskTemplateIdentifier); + return "org/librecms/ui/contentsection/configuration/workflowtask-not-found.xhtml"; + } + + private WorkflowTemplateListModel buildWorkflowTemplateListModel( + final Workflow workflow + ) { + final WorkflowTemplateListModel model = new WorkflowTemplateListModel(); + model.setDescription( + globalizationHelper.getValueFromLocalizedString( + workflow.getDescription() + ) + ); + model.setName( + globalizationHelper.getValueFromLocalizedString(workflow.getName()) + ); + model.setUuid(workflow.getUuid()); + model.setWorkflowId(workflow.getWorkflowId()); + return model; + } + + private WorkflowTaskTemplateListModel buildWorkflowTaskTemplateListModel( + final Task task + ) { + final WorkflowTaskTemplateListModel model + = new WorkflowTaskTemplateListModel(); + model.setBlockedTasks( + task + .getBlockedTasks() + .stream() + .map(this::buildWorkflowTaskTemplateListModel) + .collect(Collectors.toList()) + ); + model.setBlockingTasks( + task + .getBlockingTasks() + .stream() + .map(this::buildWorkflowTaskTemplateListModel) + .collect(Collectors.toList()) + ); + model.setDescription( + globalizationHelper.getValueFromLocalizedString( + task.getDescription() + ) + ); + model.setLabel( + globalizationHelper.getValueFromLocalizedString( + task.getLabel() + ) + ); + model.setTaskId(task.getTaskId()); + model.setUuid(task.getUuid()); + return model; } } diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedLifecycleDefinitionModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedLifecycleDefinitionModel.java index baeaec847..dc4cb3247 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedLifecycleDefinitionModel.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedLifecycleDefinitionModel.java @@ -19,7 +19,7 @@ import javax.inject.Named; * @author Jens Pelzetter */ @RequestScoped -@Named("SelectedLifecycleModel") +@Named("SelectedLifecycleDefinitionModel") public class SelectedLifecycleDefinitionModel { private String uuid; diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedPhaseDefinitionModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedPhaseDefinitionModel.java new file mode 100644 index 000000000..1f2e6dce0 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedPhaseDefinitionModel.java @@ -0,0 +1,73 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.librecms.ui.contentsections; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SelectedPhaseDefinitionModel") +public class SelectedPhaseDefinitionModel { + + private long definitionId; + + private Map label; + + private Map description; + + private long defaultDelay; + + private long defaultDuration; + + public long getDefinitionId() { + return definitionId; + } + + public void setDefinitionId(final long definitionId) { + this.definitionId = definitionId; + } + + public Map getLabel() { + return Collections.unmodifiableMap(label); + } + + public void setLabel(final Map label) { + this.label = new HashMap<>(label); + } + + public Map getDescription() { + return Collections.unmodifiableMap(description); + } + + public void setDescription(final Map description) { + this.description = new HashMap<>(description); + } + + public long getDefaultDelay() { + return defaultDelay; + } + + public void setDefaultDelay(final long defaultDelay) { + this.defaultDelay = defaultDelay; + } + + public long getDefaultDuration() { + return defaultDuration; + } + + public void setDefaultDuration(final long defaultDuration) { + this.defaultDuration = defaultDuration; + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedWorkflowTaskTemplateModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedWorkflowTaskTemplateModel.java new file mode 100644 index 000000000..0d8be3728 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedWorkflowTaskTemplateModel.java @@ -0,0 +1,90 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.librecms.ui.contentsections; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SelectedWorkflowTaskTemplateModel") +public class SelectedWorkflowTaskTemplateModel { + + private long taskId; + + private String uuid; + + private Map label; + + private Map description; + + private List blockedTasks; + + private List blockingTasks; + + public long getTaskId() { + return taskId; + } + + public void setTaskId(final long taskId) { + this.taskId = taskId; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(final String uuid) { + this.uuid = uuid; + } + + public Map getLabel() { + return Collections.unmodifiableMap(label); + } + + public void setLabel(final Map label) { + this.label = new HashMap<>(label); + } + + public Map getDescription() { + return Collections.unmodifiableMap(description); + } + + public void setDescription(final Map description) { + this.description = new HashMap<>(description); + } + + public List getBlockedTasks() { + return Collections.unmodifiableList(blockedTasks); + } + + public void setBlockedTasks( + final List blockedTasks + ) { + this.blockedTasks = new ArrayList<>(blockedTasks); + } + + public List< WorkflowTaskTemplateListModel> getBlockingTasks() { + return Collections.unmodifiableList(blockingTasks); + } + + public void setBlockingTasks( + final List blockingTasks + ) { + this.blockingTasks = new ArrayList<>(blockingTasks); + } + + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedWorkflowTemplateModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedWorkflowTemplateModel.java new file mode 100644 index 000000000..03713519d --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/SelectedWorkflowTemplateModel.java @@ -0,0 +1,77 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.librecms.ui.contentsections; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SelectedWorkflowTemplateModel") +public class SelectedWorkflowTemplateModel { + + private long workflowId; + + private String uuid; + + private Map name; + + private Map description; + + private List tasks; + + public long getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(final long workflowId) { + this.workflowId = workflowId; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(final String uuid) { + this.uuid = uuid; + } + + public Map getName() { + return Collections.unmodifiableMap(name); + } + + public void setName(Map name) { + this.name = new HashMap<>(name); + } + + public Map getDescription() { + return Collections.unmodifiableMap(description); + } + + public void setDescription(final Map description) { + this.description = new HashMap<>(description); + } + + public List getTasks() { + return Collections.unmodifiableList(tasks); + } + + public void setTasks(final List tasks) { + this.tasks = new ArrayList<>(tasks); + } + + + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/WorkflowTaskTemplateListModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/WorkflowTaskTemplateListModel.java new file mode 100644 index 000000000..762dd9251 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/WorkflowTaskTemplateListModel.java @@ -0,0 +1,84 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.librecms.ui.contentsections; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * + * @author Jens Pelzetter + */ +public class WorkflowTaskTemplateListModel { + + private long taskId; + + private String uuid; + + private String label; + + private String description; + + private List blockedTasks; + + private List blockingTasks; + + public long getTaskId() { + return taskId; + } + + public void setTaskId(final long taskId) { + this.taskId = taskId; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(final String uuid) { + this.uuid = uuid; + } + + public List getBlockedTasks() { + return Collections.unmodifiableList(blockedTasks); + } + + public void setBlockedTasks( + final List blockedTasks + ) { + this.blockedTasks = new ArrayList<>(blockedTasks); + } + + public List< WorkflowTaskTemplateListModel> getBlockingTasks() { + return Collections.unmodifiableList(blockingTasks); + } + + public void setBlockingTasks( + final List blockingTasks + ) { + this.blockingTasks = new ArrayList<>(blockingTasks); + } + + public String getLabel() { + return label; + } + + public void setLabel(final String label) { + this.label = label; + } + + public String getDescription() { + return description; + } + + public void setDescription(final String description) { + this.description = description; + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/WorkflowTemplateListModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/WorkflowTemplateListModel.java new file mode 100644 index 000000000..9bda62eb1 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/WorkflowTemplateListModel.java @@ -0,0 +1,54 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.librecms.ui.contentsections; + +/** + * + * @author Jens Pelzetter + */ +public class WorkflowTemplateListModel { + + private long workflowId; + + private String uuid; + + private String name; + + private String description; + + public long getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(final long workflowId) { + this.workflowId = workflowId; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(final String uuid) { + this.uuid = uuid; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(final String description) { + this.description = description; + } + +}