- Removed class WorkflowTemplate, replaced by property abstractWorkflow in class workflow
- Fixed several test failures



git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5015 8810af33-2d31-482b-a856-94f89814c4df

Former-commit-id: e4bbfc3e41
pull/2/head
jensp 2017-09-27 19:45:02 +00:00
parent 6ba2869181
commit b6c1253bfe
54 changed files with 5950 additions and 2360 deletions

View File

@ -23,8 +23,7 @@ import org.libreccm.workflow.AssignableTask;
import org.libreccm.workflow.AssignableTaskManager;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowManager;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.libreccm.workflow.WorkflowRepository;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentSectionRepository;
@ -56,7 +55,7 @@ class ApplyWorkflowController {
private ContentSectionRepository sectionRepo;
@Inject
private WorkflowTemplateRepository templateRepo;
private WorkflowRepository templateRepo;
@Inject
private WorkflowManager workflowManager;
@ -68,7 +67,7 @@ class ApplyWorkflowController {
private PermissionChecker permissionChecker;
@Transactional(Transactional.TxType.REQUIRED)
protected WorkflowTemplate getDefaultWorkflow(final ContentType contentType) {
protected Workflow getDefaultWorkflow(final ContentType contentType) {
Objects.requireNonNull(contentType);
@ -83,7 +82,7 @@ class ApplyWorkflowController {
@Transactional(Transactional.TxType.REQUIRED)
Long getDefaultWorkflowId(final ContentType contentType) {
final WorkflowTemplate workflowTemplate
final Workflow workflowTemplate
= getDefaultWorkflow(contentType);
if (workflowTemplate == null) {
return null;
@ -93,7 +92,7 @@ class ApplyWorkflowController {
}
@Transactional(Transactional.TxType.REQUIRED)
protected List<WorkflowTemplate> getWorkflowTemplates(
protected List<Workflow> getWorkflowTemplates(
final ContentSection section) {
final ContentSection contentSection = sectionRepo
@ -115,7 +114,7 @@ class ApplyWorkflowController {
Objects.requireNonNull(folder);
Objects.requireNonNull(workflowTemplateId);
final WorkflowTemplate workflowTemplate;
final Workflow workflowTemplate;
if (workflowTemplateId == null
&& permissionChecker
.isPermitted(ItemPrivileges.APPLY_ALTERNATE_WORKFLOW, folder)) {

View File

@ -43,7 +43,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.PermissionChecker;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.CmsConstants;
import org.librecms.contentsection.privileges.ItemPrivileges;
@ -111,7 +111,7 @@ public class ApplyWorkflowFormSection
LOGGER.error("Too many listeners", ex);
}
add(new Label(new GlobalizedMessage("cms.ui.authoring.workflow",
super.add(new Label(new GlobalizedMessage("cms.ui.authoring.workflow",
CmsConstants.CMS_BUNDLE)));
radioGroup.addValidationListener(new NotNullValidationListener() {
@ -125,8 +125,8 @@ public class ApplyWorkflowFormSection
}
});
add(radioGroup);
addInitListener(this);
super.add(radioGroup);
super.addInitListener(this);
}
/**
@ -280,7 +280,7 @@ public class ApplyWorkflowFormSection
}
@Override
protected List<WorkflowTemplate> getCollection(final PageState state) {
protected List<Workflow> getCollection(final PageState state) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ApplyWorkflowController controller = cdiUtil
.findBean(ApplyWorkflowController.class);

View File

@ -21,7 +21,6 @@ package com.arsdigita.cms.ui.authoring;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.FormSection;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent;
@ -38,16 +37,13 @@ import org.librecms.contentsection.Folder;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.util.Assert;
import org.arsdigita.cms.CMSConfig;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItemInitializer;
import org.librecms.contentsection.ContentItemManager;
import org.librecms.contentsection.ContentType;
import java.util.Date;
@ -293,7 +289,7 @@ public abstract class BasicPageForm extends BasicItemForm {
final String name,
final ContentSection section,
final Folder folder,
final WorkflowTemplate workflowTemplate,
final Workflow workflowTemplate,
final ContentItemInitializer<T> initializer,
final Locale locale) throws FormProcessException {

View File

@ -18,8 +18,8 @@
*/
package com.arsdigita.cms.ui.authoring;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemInitializer;
import org.librecms.contentsection.ContentItemManager;
@ -56,7 +56,7 @@ class BasicPageFormController {
private FolderRepository folderRepo;
@Inject
private WorkflowTemplateRepository workflowTemplateRepo;
private WorkflowRepository workflowRepo;
@Transactional(Transactional.TxType.REQUIRED)
protected <T extends ContentItem> T createContentItem(
@ -81,7 +81,7 @@ class BasicPageFormController {
final String name,
final ContentSection section,
final Folder folder,
final WorkflowTemplate workflowTemplate,
final Workflow workflowTemplate,
final Class<T> clazz,
final ContentItemInitializer<T> initializer,
final Locale locale) {
@ -109,7 +109,7 @@ class BasicPageFormController {
locale);
} else {
final WorkflowTemplate itemWorkflowTemplate = workflowTemplateRepo
final Workflow itemWorkflowTemplate = workflowRepo
.findById(workflowTemplate.getWorkflowId())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No WorkflowTemplate with ID %d in the database.",

View File

@ -39,8 +39,8 @@ import com.arsdigita.util.Assert;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemInitializer;
@ -100,9 +100,9 @@ public class PageCreateForm
this.selectedLanguageParam = selectedLanguageParam;
workflowSection.setCreationSelector(creationSelector);
addSubmissionListener(this);
super.addSubmissionListener(this);
getSaveCancelSection().getSaveButton()
super.getSaveCancelSection().getSaveButton()
.setButtonLabel(new GlobalizedMessage("cms.ui.create",
CmsConstants.CMS_BUNDLE));
}
@ -239,9 +239,9 @@ public class PageCreateForm
getItemInitializer(data, state),
locale);
} else {
final WorkflowTemplateRepository workflowTemplateRepo = cdiUtil
.findBean(WorkflowTemplateRepository.class);
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
final WorkflowRepository workflowRepo = cdiUtil
.findBean(WorkflowRepository.class);
final Workflow workflowTemplate = workflowRepo
.findById(selectedWorkflowTemplateId)
.orElseThrow(() -> new IllegalArgumentException(String.format(
"No WorkflowTemplate with ID %d in the database.",

View File

@ -64,7 +64,6 @@ import org.libreccm.workflow.TaskManager;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowManager;
import org.libreccm.workflow.WorkflowRepository;
import org.libreccm.workflow.WorkflowTemplate;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemManager;
@ -823,7 +822,7 @@ class ItemLifecycleSelectForm extends BaseForm {
} else {
// restart the workflow by recreating it
// from the same workflow template
final WorkflowTemplate template = workflow.getTemplate();
final Workflow template = workflow.getTemplate();
workflowRepo.delete(workflow);
final Workflow restarted = workflowManager.createWorkflow(
template, item);

View File

@ -18,7 +18,7 @@
*/
package com.arsdigita.cms.ui.type;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentSectionRepository;
import org.librecms.contentsection.ContentType;
@ -130,7 +130,7 @@ class ContentTypeAdminPaneController {
}
@Transactional(Transactional.TxType.REQUIRED)
public WorkflowTemplate getWorkflowTemplate(final ContentType type) {
public Workflow getWorkflowTemplate(final ContentType type) {
final ContentType contentType = typeRepo
.findById(type.getObjectId())
@ -146,7 +146,7 @@ class ContentTypeAdminPaneController {
public Optional<String> getWorkflowTemplateName(final ContentType type,
final Locale locale) {
final WorkflowTemplate workflowTemplate = getWorkflowTemplate(type);
final Workflow workflowTemplate = getWorkflowTemplate(type);
if (workflowTemplate == null) {
return Optional.empty();
@ -170,7 +170,7 @@ class ContentTypeAdminPaneController {
}
@Transactional(Transactional.TxType.REQUIRED)
public List<WorkflowTemplate> getWorkflowTemplates(
public List<Workflow> getWorkflowTemplates(
final ContentSection section) {
final ContentSection contentSection = sectionRepo

View File

@ -23,7 +23,6 @@ import com.arsdigita.cms.CMS;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentType;
import org.librecms.lifecycle.LifecycleDefinition;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.kernel.KernelConfig;
@ -34,7 +33,6 @@ import org.libreccm.cdi.utils.CdiUtil;
import java.util.Locale;
import org.libreccm.workflow.WorkflowTemplate;
import org.librecms.CmsConstants;
import org.librecms.contenttypes.ContentTypeInfo;
import org.librecms.contenttypes.ContentTypesManager;

View File

@ -42,10 +42,8 @@ import com.arsdigita.cms.CMS;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentType;
import org.librecms.lifecycle.LifecycleDefinition;
import org.libreccm.workflow.WorkflowTemplate;
import com.arsdigita.cms.ui.CMSForm;
import com.arsdigita.cms.ui.GlobalNavigation;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.util.UncheckedWrapperException;
@ -53,7 +51,8 @@ import com.arsdigita.util.UncheckedWrapperException;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentTypeManager;
import org.librecms.contentsection.ContentTypeRepository;
@ -204,7 +203,7 @@ public class EditType extends CMSForm
data.put(m_lcSelect.getName(), cycle.getDefinitionId());
}
WorkflowTemplate template = type.getDefaultWorkflow();
Workflow template = type.getDefaultWorkflow();
if (template != null) {
data.put(m_wfSelect.getName(), template.getWorkflowId());
}
@ -215,7 +214,7 @@ public class EditType extends CMSForm
* model.
*/
private ContentType getContentType(final PageState state) {
final String key = (String) m_types.getSelectedKey(state);
final String key = m_types.getSelectedKey(state);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ContentTypeRepository typeRepo = cdiUtil.findBean(
@ -226,7 +225,7 @@ public class EditType extends CMSForm
result = typeRepo.findById(Long.parseLong(key));
} catch (NumberFormatException ex) {
throw new UncheckedWrapperException(String.format(
"The provided key \"%d\" is not a long.", key),
"The provided key \"%s\" is not a long.", key),
ex);
}
@ -265,8 +264,8 @@ public class EditType extends CMSForm
ContentTypeRepository.class);
final LifecycleDefinitionRepository lifecycleDefRepo = cdiUtil.findBean(
LifecycleDefinitionRepository.class);
final WorkflowTemplateRepository workflowTemplateRepo = cdiUtil
.findBean(WorkflowTemplateRepository.class);
final WorkflowRepository workflowRepo = cdiUtil
.findBean(WorkflowRepository.class);
final ContentTypeManager typeManager = cdiUtil.findBean(
ContentTypeManager.class);
@ -292,11 +291,11 @@ public class EditType extends CMSForm
} else {
defaultLifecycle = lifecycleDefRepo.findById(lifecycleId).get();
}
final WorkflowTemplate defaultWorkflow;
final Workflow defaultWorkflow;
if (workflowId == 0) {
defaultWorkflow = null;
} else {
defaultWorkflow = workflowTemplateRepo.findById(workflowId).get();
defaultWorkflow = workflowRepo.findById(workflowId).get();
}
@ -367,7 +366,7 @@ public class EditType extends CMSForm
final ContentTypeAdminPaneController controller = cdiUtil
.findBean(ContentTypeAdminPaneController.class);
final List<WorkflowTemplate> templates = controller
final List<Workflow> templates = controller
.getWorkflowTemplates(section);
final Locale defaultLocale = KernelConfig.getConfig()
.getDefaultLocale();

View File

@ -30,16 +30,19 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ui.CMSForm;
import com.arsdigita.web.Web;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowTemplate;
import org.apache.logging.log4j.Logger;
import java.math.BigDecimal;
import java.util.TooManyListenersException;
import org.apache.logging.log4j.LogManager;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.workflow.WorkflowManager;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.libreccm.workflow.WorkflowRepository;
import org.librecms.contentsection.ContentItem;
/**
@ -97,12 +100,13 @@ class ItemWorkflowSelectForm extends CMSForm {
if (item.getWorkflow() == null) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowTemplateRepository templateRepo = cdiUtil.
findBean(WorkflowTemplateRepository.class);
final WorkflowRepository templateRepo = cdiUtil.
findBean(WorkflowRepository.class);
final WorkflowManager workflowManager = cdiUtil.findBean(
WorkflowManager.class);
final WorkflowTemplate template = templateRepo.findById(flowId)
final Workflow template = templateRepo
.findById(flowId)
.get();
workflowManager.createWorkflow(template, item);
}

View File

@ -25,8 +25,8 @@ import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.cms.CMS;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.workflow.Workflow;
/**
* @author Uday Mathur
@ -60,28 +60,8 @@ class WorkflowAddForm extends BaseWorkflowForm {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowAdminPaneController controller = cdiUtil.findBean(
WorkflowAdminPaneController.class);
// final WorkflowTemplateRepository workflowTemplateRepository
// = cdiUtil.findBean(
// WorkflowTemplateRepository.class);
// final ContentSectionManager sectionManager = cdiUtil.findBean(
// ContentSectionManager.class);
// final ConfigurationManager confManager = cdiUtil.findBean(
// ConfigurationManager.class);
// final KernelConfig kernelConfig = confManager.findConfiguration(
// KernelConfig.class);
// final Locale defaultLocale = kernelConfig.getDefaultLocale();
//
// final WorkflowTemplate workflow = new WorkflowTemplate();
// workflow.getName().addValue(defaultLocale, label);
// workflow.getDescription().addValue(defaultLocale, description);
//
// workflowTemplateRepository.save(workflow);
//
// final ContentSection section = CMS.getContext().getContentSection();
// sectionManager
// .addWorkflowTemplateToContentSection(workflow, section);
final WorkflowTemplate workflow = controller.createWorkflow(
final Workflow workflow = controller.createWorkflow(
CMS.getContext().getContentSection(),
label,
description);

View File

@ -29,7 +29,6 @@ import com.arsdigita.cms.ui.VisibilityComponent;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.librecms.contentsection.privileges.AdminPrivileges;
@ -92,8 +91,8 @@ public final class WorkflowAdminPane extends BaseAdminPane {
.toString();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowTemplateRepository templateRepo = cdiUtil.findBean(
WorkflowTemplateRepository.class);
final WorkflowRepository templateRepo = cdiUtil.findBean(
WorkflowRepository.class);
return templateRepo.findById(Long.parseLong(id));
}

View File

@ -35,8 +35,6 @@ import org.libreccm.workflow.TaskManager;
import org.libreccm.workflow.TaskRepository;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentSectionManager;
import org.librecms.contentsection.ContentSectionRepository;
@ -54,7 +52,6 @@ import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.management.relation.RoleInfo;
import javax.transaction.Transactional;
/**
@ -79,9 +76,6 @@ public class WorkflowAdminPaneController {
@Inject
private WorkflowRepository workflowRepo;
@Inject
private WorkflowTemplateRepository workflowTemplateRepo;
@Inject
private TaskRepository taskRepo;
@ -95,7 +89,7 @@ public class WorkflowAdminPaneController {
private RoleRepository roleRepo;
@Transactional(Transactional.TxType.REQUIRED)
public List<WorkflowTemplate> retrieveWorkflows(final ContentSection section) {
public List<Workflow> retrieveWorkflows(final ContentSection section) {
final ContentSection contentSection = sectionRepo
.findById(section.getObjectId())
@ -108,7 +102,7 @@ public class WorkflowAdminPaneController {
}
@Transactional(Transactional.TxType.REQUIRED)
public WorkflowTemplate createWorkflow(final ContentSection section,
public Workflow createWorkflow(final ContentSection section,
final String name,
final String desc) {
@ -123,11 +117,12 @@ public class WorkflowAdminPaneController {
+ "Where did that ID come from?",
section.getObjectId())));
final WorkflowTemplate workflowTemplate = new WorkflowTemplate();
final Workflow workflowTemplate = new Workflow();
workflowTemplate.setAbstractWorkflow(true);
workflowTemplate.getName().addValue(defaultLocale, name);
workflowTemplate.getDescription().addValue(defaultLocale, desc);
workflowTemplateRepo.save(workflowTemplate);
workflowRepo.save(workflowTemplate);
sectionManager.addWorkflowTemplateToContentSection(workflowTemplate,
contentSection);
@ -371,7 +366,7 @@ public class WorkflowAdminPaneController {
}
@Transactional(Transactional.TxType.REQUIRED)
public void removeAssignment(final Task task, final String roleId ) {
public void removeAssignment(final Task task, final String roleId) {
final Role role = roleRepo
.findById(Long.parseLong(roleId))

View File

@ -26,8 +26,7 @@ import com.arsdigita.cms.CMS;
import com.arsdigita.kernel.KernelConfig;
import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.contentsection.ContentSection;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import java.util.Iterator;
import java.util.Locale;
@ -49,8 +48,8 @@ class WorkflowListModelBuilder extends AbstractListModelBuilder {
private class Model implements ListModel {
private final Iterator<WorkflowTemplate> templates;
private WorkflowTemplate currentTemplate;
private final Iterator<Workflow> templates;
private Workflow currentTemplate;
public Model() {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();

View File

@ -29,8 +29,8 @@ import com.arsdigita.kernel.KernelConfig;
import java.util.List;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.workflow.Workflow;
import org.librecms.contentsection.ContentSection;
import org.libreccm.workflow.WorkflowTemplate;
/**
* Builds a list of workflow templates registered to the current content
@ -41,7 +41,7 @@ import org.libreccm.workflow.WorkflowTemplate;
*/
public class WorkflowsOptionPrintListener implements PrintListener {
protected List<WorkflowTemplate> getCollection(final PageState state) {
protected List<Workflow> getCollection(final PageState state) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowsOptionPrintListenerController controller = cdiUtil
@ -62,9 +62,9 @@ public class WorkflowsOptionPrintListener implements PrintListener {
final OptionGroup target = (OptionGroup) event.getTarget();
target.clearOptions();
final List<WorkflowTemplate> templates = getCollection(state);
final List<Workflow> templates = getCollection(state);
for (final WorkflowTemplate template : templates) {
for (final Workflow template : templates) {
target.addOption(new Option(
Long.toString(template.getWorkflowId()),
template.getName().getValue(KernelConfig

View File

@ -19,7 +19,7 @@
package com.arsdigita.cms.ui.workflow;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentSectionRepository;
@ -41,7 +41,7 @@ class WorkflowsOptionPrintListenerController {
private ContentSectionRepository sectionRepo;
@Transactional(Transactional.TxType.REQUIRED)
protected List<WorkflowTemplate> getWorkflowTemplates(
protected List<Workflow> getWorkflowTemplates(
final ContentSection section) {
Objects.requireNonNull(section);

View File

@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.Collections;
import org.libreccm.categorization.Category;
import org.libreccm.workflow.WorkflowTemplate;
import org.librecms.lifecycle.LifecycleDefinition;
import java.util.List;
@ -38,7 +37,6 @@ import javax.inject.Inject;
import org.libreccm.categorization.Categorization;
import org.libreccm.categorization.CategoryManager;
import org.libreccm.categorization.ObjectNotAssignedToCategoryException;
import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.security.AuthorizationRequired;
@ -212,7 +210,7 @@ public class ContentItemManager {
* {@link ContentSection#rootDocumentsFolder} of the provided content
* section. Otherwise an {@link IllegalArgumentException} is thrown.
*
* Likewise the provided {@link WorkflowTemplate} must be defined in the
* Likewise the provided abstract {@link Workflow} must be defined in the
* provided content section. Otherwise an {@link IllegalArgumentException}
* is thrown.
*
@ -235,7 +233,7 @@ public class ContentItemManager {
final ContentSection section,
@RequiresPrivilege(ItemPrivileges.CREATE_NEW)
final Folder folder,
final WorkflowTemplate workflowTemplate,
final Workflow workflowTemplate,
final Class<T> type,
final Locale locale) {
@ -258,7 +256,7 @@ public class ContentItemManager {
* {@link ContentSection#rootDocumentsFolder} of the provided content
* section. Otherwise an {@link IllegalArgumentException} is thrown.
*
* Likewise the provided {@link WorkflowTemplate} must be defined in the
* Likewise the provided abstract {@link Workflow} must be defined in the
* provided content section. Otherwise an {@link IllegalArgumentException}
* is thrown.
*
@ -283,7 +281,7 @@ public class ContentItemManager {
final ContentSection section,
@RequiresPrivilege(ItemPrivileges.CREATE_NEW)
final Folder folder,
final WorkflowTemplate workflowTemplate,
final Workflow workflowTemplate,
final Class<T> type,
final ContentItemInitializer<T> initializer,
final Locale locale) {
@ -490,13 +488,10 @@ public class ContentItemManager {
throw new RuntimeException(ex);
}
// final String uuid = UUID.randomUUID().toString();
// copy.setUuid(uuid);
// copy.setItemUuid(uuid);
copy.setContentType(contentType.get());
if (draftItem.getWorkflow() != null) {
final WorkflowTemplate template = draftItem.getWorkflow()
final Workflow template = draftItem.getWorkflow()
.getTemplate();
final Workflow copyWorkflow = workflowManager.createWorkflow(
template, item);

View File

@ -21,6 +21,7 @@ package org.librecms.contentsection;
import org.libreccm.security.RecursivePermissions;
import org.libreccm.security.Role;
import org.libreccm.web.CcmApplication;
import org.libreccm.workflow.Workflow;
import java.io.Serializable;
import java.util.Collections;
@ -42,7 +43,6 @@ import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import org.libreccm.workflow.WorkflowTemplate;
import org.librecms.contentsection.privileges.AssetPrivileges;
import org.librecms.contentsection.privileges.ItemPrivileges;
import org.librecms.contentsection.privileges.TypePrivileges;
@ -206,7 +206,7 @@ public class ContentSection extends CcmApplication implements Serializable {
@JoinColumn(name = "WORKFLOW_TEMPLATE_ID")
}
)
private List<WorkflowTemplate> workflowTemplates = new ArrayList<>();
private List<Workflow> workflowTemplates = new ArrayList<>();
public ContentSection() {
roles = new ArrayList<>();
@ -339,20 +339,24 @@ public class ContentSection extends CcmApplication implements Serializable {
lifecycleDefinitions.remove(definition);
}
public List<WorkflowTemplate> getWorkflowTemplates() {
public List<Workflow> getWorkflowTemplates() {
return Collections.unmodifiableList(workflowTemplates);
}
protected void setWorkflowTemplates(
final List<WorkflowTemplate> workflowTemplates) {
final List<Workflow> workflowTemplates) {
this.workflowTemplates = workflowTemplates;
}
protected void addWorkflowTemplate(final WorkflowTemplate template) {
protected void addWorkflowTemplate(final Workflow template) {
if (!template.isAbstractWorkflow()) {
throw new IllegalArgumentException(
"The provided workflow is not an abstract workflow.");
}
workflowTemplates.add(template);
}
protected void removeWorkflowTemplate(final WorkflowTemplate template) {
protected void removeWorkflowTemplate(final Workflow template) {
workflowTemplates.remove(template);
}

View File

@ -30,7 +30,7 @@ import org.libreccm.security.PermissionManager;
import org.libreccm.security.RequiresPrivilege;
import org.libreccm.security.Role;
import org.libreccm.security.RoleRepository;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import java.util.List;
import java.util.Locale;
@ -54,6 +54,8 @@ import java.util.Optional;
import org.librecms.contentsection.privileges.TypePrivileges;
import org.librecms.dispatcher.ItemResolver;
import java.util.Objects;
import javax.enterprise.inject.Instance;
import static org.librecms.contentsection.ContentSection.*;
@ -413,10 +415,18 @@ public class ContentSectionManager {
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public void addWorkflowTemplateToContentSection(
final WorkflowTemplate template,
final Workflow template,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_WORKFLOW)
final ContentSection section) {
Objects.requireNonNull(template);
Objects.requireNonNull(section);
if (!template.isAbstractWorkflow()) {
throw new IllegalArgumentException(
"The provided workflow is not abstract workflow.");
}
section.addWorkflowTemplate(template);
sectionRepo.save(section);
}
@ -432,7 +442,7 @@ public class ContentSectionManager {
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public void removeWorkflowTemplateFromContentSection(
final WorkflowTemplate template,
final Workflow template,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_WORKFLOW)
final ContentSection section) {
@ -476,15 +486,18 @@ public class ContentSectionManager {
* {@link CmsConstants#AdminPrivileges.ADMINISTER_CONTENT_TYPES} for the
* provided content section.
*
* @param type The type to add (a subclass of {@link ContentItem}.
* @param type The type to add (a subclass of
* {@link ContentItem}.
* @param section The section to which the type is added.
* @param defaultLifecycle The default lifecycle for items of the provided
* type in the provided content section. The lifecycle must be part of the
* provided section. Otherwise an {@link IllegalArgumentException} is
* type in the provided content section. The
* lifecycle must be part of the provided section.
* Otherwise an {@link IllegalArgumentException} is
* thrown.
* @param defaultWorkflow The default workflow for items of the provided
* type in the provided content section. The workflow must be part of the
* provided section. Otherwise an {@link IllegalArgumentException} is
* type in the provided content section. The
* workflow must be part of the provided section.
* Otherwise an {@link IllegalArgumentException} is
* thrown.
*
* @return The new {@link ContentType} instance.
@ -496,7 +509,7 @@ public class ContentSectionManager {
@RequiresPrivilege(AdminPrivileges.ADMINISTER_CONTENT_TYPES)
final ContentSection section,
final LifecycleDefinition defaultLifecycle,
final WorkflowTemplate defaultWorkflow) {
final Workflow defaultWorkflow) {
if (type == null) {
throw new IllegalArgumentException("Can't add null as content type "
@ -518,6 +531,11 @@ public class ContentSectionManager {
+ "without a default workflow.");
}
if (!defaultWorkflow.isAbstractWorkflow()) {
throw new IllegalArgumentException(
"The provided workflow is not an abstract workflow.");
}
if (!section.getLifecycleDefinitions().contains(defaultLifecycle)) {
final KernelConfig kernelConfig = confManager.findConfiguration(
KernelConfig.class);
@ -605,7 +623,8 @@ public class ContentSectionManager {
* @param section The section from which the type is removed.
*
* @throws IllegalArgumentException if the provided {@link ContentType} is
* in use or the parameters or otherwise illegal.
* in use or the parameters or otherwise
* illegal.
* @see
* ContentTypeRepository#delete(org.librecms.contentsection.ContentType)
*/

View File

@ -25,7 +25,7 @@ import static org.librecms.CmsConstants.*;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.lifecycle.LifecycleDefinition;
import java.io.Serializable;
@ -117,7 +117,7 @@ public class ContentType extends CcmObject implements Serializable {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "DEFAULT_WORKFLOW")
private WorkflowTemplate defaultWorkflow;
private Workflow defaultWorkflow;
public ContentType() {
super();
@ -192,11 +192,15 @@ public class ContentType extends CcmObject implements Serializable {
this.defaultLifecycle = defaultLifecycle;
}
public WorkflowTemplate getDefaultWorkflow() {
public Workflow getDefaultWorkflow() {
return defaultWorkflow;
}
protected void setDefaultWorkflow(final WorkflowTemplate defaultWorkflow) {
protected void setDefaultWorkflow(final Workflow defaultWorkflow) {
if (!defaultWorkflow.isAbstractWorkflow()) {
throw new IllegalArgumentException(
"The provided workflow is not an abstract workflow.");
}
this.defaultWorkflow = defaultWorkflow;
}

View File

@ -24,10 +24,12 @@ import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.PermissionManager;
import org.libreccm.security.RequiresPrivilege;
import org.libreccm.security.Role;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.contentsection.privileges.AdminPrivileges;
import org.librecms.lifecycle.LifecycleDefinition;
import java.util.Objects;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
@ -98,7 +100,7 @@ public class ContentTypeManager {
* Sets the default workflow to use for new items of a content type.
*
* @param type
* @param template The {@link WorkflowTemplate} for the workflow to use for
* @param template The abstract {@link Workflow} for the workflow to use for
* new items of the provided {@code type}.
*/
@Transactional(Transactional.TxType.REQUIRED)
@ -106,7 +108,15 @@ public class ContentTypeManager {
public void setDefaultWorkflow(
@RequiresPrivilege(AdminPrivileges.ADMINISTER_CONTENT_TYPES)
final ContentType type,
final WorkflowTemplate template) {
final Workflow template) {
Objects.requireNonNull(type);
Objects.requireNonNull(template);
if (!template.isAbstractWorkflow()) {
throw new IllegalArgumentException(
"The provided workflow is not an abstract workflow.");
}
type.setDefaultWorkflow(template);

View File

@ -22,7 +22,7 @@ import org.libreccm.categorization.Category;
import org.libreccm.categorization.Domain;
import org.libreccm.security.Role;
import org.libreccm.web.CcmApplication;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentType;
import org.librecms.lifecycle.LifecycleDefinition;
@ -66,7 +66,7 @@ public final class AdminPrivileges {
*/
public static final String ADMINISTER_ROLES = "administer_roles";
/**
* Allows manipulation of the {@link WorkflowTemplate}s assigned to a
* Allows manipulation of the (abstract) {@link Workflow}s assigned to a
* {@link ContentSection}.
*
* @see ContentSection#workflowTemplates

View File

@ -0,0 +1,17 @@
drop constraint FKrx08cdjm9tutrp5lvfhgslw48;
alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES
add constraint FK1t85m4jehnhd6tyx5dtpavr15
foreign key (WORKFLOW_TEMPLATE_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CMS.CONTENT_TYPES
drop constraint if exists FKhnu9oikw8rpf22lt5fmk41t7k;
alter table CCM_CMS.CONTENT_TYPES
add constraint FKpgeccqsr50xwb268ypmfx0r66
foreign key (DEFAULT_WORKFLOW)
references CCM_CORE.WORKFLOWS;
alter table if exists FKeixdxau4jebw682gd49tdbsjy
drop constraint FKeixdxau4jebw682gd49tdbsjy;

View File

@ -0,0 +1,17 @@
drop constraint FKrx08cdjm9tutrp5lvfhgslw48;
alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES
add constraint FK1t85m4jehnhd6tyx5dtpavr15
foreign key (WORKFLOW_TEMPLATE_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CMS.CONTENT_TYPES
drop constraint if exists FKhnu9oikw8rpf22lt5fmk41t7k;
alter table CCM_CMS.CONTENT_TYPES
add constraint FKpgeccqsr50xwb268ypmfx0r66
foreign key (DEFAULT_WORKFLOW)
references CCM_CORE.WORKFLOWS;
alter table if exists FKeixdxau4jebw682gd49tdbsjy
drop constraint FKeixdxau4jebw682gd49tdbsjy;

View File

@ -23,6 +23,7 @@ import java.util.Optional;
import static org.libreccm.testutils.DependenciesHelpers.*;
import org.apache.shiro.subject.ExecutionException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.arquillian.junit.Arquillian;
@ -51,10 +52,13 @@ import java.util.Locale;
import javax.activation.MimeType;
import javax.activation.MimeTypeParseException;
import org.jboss.arquillian.persistence.CleanupUsingScript;
import org.librecms.assets.FileAsset;
import java.util.concurrent.Callable;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
@ -212,6 +216,8 @@ public class AssetManagerTest {
"timestamp",
"uuid"})
public void shareAsset() throws MimeTypeParseException {
shiro.getSystemUser().execute(() -> {
final Folder folder = folderRepo.findById(-420L).get();
assertThat(folder, is(not(nullValue())));
@ -223,8 +229,11 @@ public class AssetManagerTest {
assetRepo.save(file);
assetManager.shareAsset(file, folder);
assertThat(file.getDisplayName(), is(equalTo("datasheet.pdf")));
return null;
});
}
/**
@ -241,9 +250,12 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void shareAssetNull() {
shiro.getSystemUser().execute(() -> {
final Folder folder = folderRepo.findById(-420L).get();
assetManager.shareAsset(null, folder);
});
}
/**
@ -261,13 +273,22 @@ public class AssetManagerTest {
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void shareAssetFolderIsNull() throws MimeTypeParseException {
public void shareAssetFolderIsNull() throws Throwable {
try {
shiro.getSystemUser().execute(() -> {
final FileAsset file = new FileAsset();
file.setDisplayName("datasheet.pdf");
file.setFileName("datasheet.pdf");
file.setMimeType(new MimeType("application/pdf"));
assetManager.shareAsset(file, null);
return null;
});
} catch (ExecutionException ex) {
//We need the original exception
throw ex.getCause();
}
}
/**
@ -284,11 +305,14 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void shareAlreadySharedAsset() {
shiro.getSystemUser().execute(() -> {
final Folder folder = folderRepo.findById(-420L).get();
final Asset asset = assetRepo.findById(-700L).get();
assetManager.shareAsset(asset, folder);
});
}
/**
@ -304,7 +328,9 @@ public class AssetManagerTest {
+ "after-clean-orphaned.xml",
excludeColumns = {"timestamp", "object_order"})
public void cleanOrphanedAssets() {
shiro.getSystemUser().execute(() -> {
assetManager.cleanOrphanedAssets();
});
}
/**
@ -324,11 +350,17 @@ public class AssetManagerTest {
"object_order",
"uuid"})
public void moveAssetToOtherFolder() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-900L).get();
shiro.getSystemUser().execute(() -> {
final Folder folder = folderRepo.findById(-410L).get();
assetManager.move(asset, folder);
});
return null;
});
}
/**
@ -348,11 +380,14 @@ public class AssetManagerTest {
"object_order",
"uuid"})
public void moveAssetToFolderInOtherContentSection() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-900L).get();
final Folder folder = folderRepo.findById(-1600L).get();
assetManager.move(asset, folder);
});
}
/**
@ -371,9 +406,11 @@ public class AssetManagerTest {
public void moveAssetNull() {
final Asset asset = null;
shiro.getSystemUser().execute(() -> {
final Folder folder = folderRepo.findById(-410L).get();
assetManager.move(asset, folder);
});
}
/**
@ -390,11 +427,14 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void moveAssetTargetFolderIsNull() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-900L).get();
final Folder targetFolder = null;
assetManager.move(asset, targetFolder);
});
}
/**
@ -411,11 +451,14 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void moveAssetTargetFolderIsNotAssetFolder() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-900L).get();
final Folder folder = folderRepo.findById(-200L).get();
assetManager.move(asset, folder);
});
}
/**
@ -438,11 +481,14 @@ public class AssetManagerTest {
"categorization_id",
"object_order"})
public void copyAssetToOtherFolder() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-1100L).get();
final Folder targetFolder = folderRepo.findById(-400L).get();
assetManager.copy(asset, targetFolder);
});
}
/**
@ -496,11 +542,14 @@ public class AssetManagerTest {
"categorization_id",
"object_order"})
public void copyAssetToOtherContentSection() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-1100L).get();
final Folder targetFolder = folderRepo.findById(-1600L).get();
assetManager.copy(asset, targetFolder);
});
}
/**
@ -517,11 +566,14 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void copyAssetNull() {
shiro.getSystemUser().execute(() -> {
final Asset asset = null;
final Folder targetFolder = folderRepo.findById(-420L).get();
assetManager.copy(asset, targetFolder);
});
}
/**
@ -538,11 +590,14 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void copyAssetTargetFolderIsNull() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-1100L).get();
final Folder targetFolder = null;
assetManager.copy(asset, targetFolder);
});
}
/**
@ -559,11 +614,14 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void copyAssetTargetFolderIsNotAssetFolder() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-1100L).get();
final Folder targetFolder = folderRepo.findById(-200L).get();
assetManager.copy(asset, targetFolder);
});
}
/**
@ -578,6 +636,8 @@ public class AssetManagerTest {
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyIsAssetInUse() {
shiro.getSystemUser().execute(() -> {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
@ -589,6 +649,9 @@ public class AssetManagerTest {
assertThat(assetManager.isAssetInUse(servicesHeader), is(true));
assertThat(assetManager.isAssetInUse(product1Datasheet), is(true));
assertThat(assetManager.isAssetInUse(catalog), is(true));
return null;
});
}
/**
@ -603,6 +666,8 @@ public class AssetManagerTest {
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetPathWithoutContentSection() {
shiro.getSystemUser().execute(() -> {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
@ -619,6 +684,7 @@ public class AssetManagerTest {
is(equalTo("")));
assertThat(assetManager.getAssetPath(catalog),
is(equalTo("/media/downloads/catalog.pdf")));
});
}
/**
@ -633,6 +699,8 @@ public class AssetManagerTest {
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetPathWithContentSection() {
shiro.getSystemUser().execute(() -> {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
@ -649,6 +717,7 @@ public class AssetManagerTest {
is(equalTo("")));
assertThat(assetManager.getAssetPath(catalog, true),
is(equalTo("info:/media/downloads/catalog.pdf")));
});
}
/**
@ -663,6 +732,8 @@ public class AssetManagerTest {
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetFolder() {
shiro.getSystemUser().execute(() -> {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
@ -694,6 +765,7 @@ public class AssetManagerTest {
assertThat(phbFolder.get(), is(equalTo(images)));
assertThat(servicesHeaderFolder.get(), is(equalTo(media)));
assertThat(catalogFolder.get(), is(equalTo(downloads)));
});
}
/**
@ -708,6 +780,8 @@ public class AssetManagerTest {
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetFolders() {
shiro.getSystemUser().execute(() -> {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
@ -719,9 +793,11 @@ public class AssetManagerTest {
final Folder images = folderRepo.findById(-410L).get();
final Folder downloads = folderRepo.findById(-420L).get();
final List<Folder> headerFolders = assetManager.getAssetFolders(header);
final List<Folder> headerFolders = assetManager.getAssetFolders(
header);
final List<Folder> phbFolders = assetManager.getAssetFolders(phb);
final List<Folder> servicesHeaderFolders = assetManager.getAssetFolders(
final List<Folder> servicesHeaderFolders = assetManager
.getAssetFolders(
servicesHeader);
final List<Folder> product1DatasheetFolders = assetManager.
getAssetFolders(product1Datasheet);
@ -760,6 +836,7 @@ public class AssetManagerTest {
assertThat(catalogFolders.get(0), is(equalTo(infoAssets)));
assertThat(catalogFolders.get(1), is(equalTo(media)));
assertThat(catalogFolders.get(2), is(equalTo(downloads)));
});
}

View File

@ -20,6 +20,7 @@ package org.librecms.contentsection;
import static org.libreccm.testutils.DependenciesHelpers.*;
import org.apache.shiro.subject.ExecutionException;
import org.apache.shiro.subject.Subject;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
@ -56,6 +57,8 @@ import org.librecms.assets.Image;
import org.librecms.assets.VideoAsset;
import org.librecms.contentsection.rs.Assets;
import java.util.concurrent.Callable;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
@ -202,15 +205,19 @@ public class AssetRepositoryTest {
excludeColumns = {"timestamp", "object_order"}
)
public void deleteUnusedAsset() {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-800L).get();
assetRepo.delete(asset);
});
}
/**
* Verifies that an {@link Asset} which is associated to at least one
* {@link ContentItem} can't be deleted by using
* {@link AssetRepository#delete(org.librecms.assets.Asset)}.
* @throws java.lang.Throwable
*/
@Test(expected = AssetInUseException.class)
@InSequence(110)
@ -220,10 +227,18 @@ public class AssetRepositoryTest {
"datasets/org/librecms/contentsection/AssetRepositoryTest/"
+ "data.xml")
@ShouldThrowException(AssetInUseException.class)
public void deleteUsedAsset() {
final Asset asset = assetRepo.findById(-700L).get();
public void deleteUsedAsset() throws Throwable {
try {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-700L).get();
assetRepo.delete(asset);
return null;
});
} catch (ExecutionException ex) {
throw ex.getCause();
}
}
/**
@ -234,6 +249,7 @@ public class AssetRepositoryTest {
@InSequence(200)
@UsingDataSet(
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
public void findAssetByUuid() {
final Optional<Asset> header = shiro
@ -342,7 +358,6 @@ public class AssetRepositoryTest {
is(equalTo("services-header.png")));
assertThat(images.get(2).getDisplayName(), is(equalTo("the-phb.png")));
assertThat(files.get(0).getDisplayName(), is(equalTo("catalog.pdf")));
assertThat(files.get(1).getDisplayName(),
is(equalTo("product1-datasheet.pdf")));

View File

@ -39,8 +39,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.libreccm.security.Shiro;
import org.libreccm.tests.categories.IntegrationTest;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.librecms.contenttypes.Article;
import org.librecms.contenttypes.Event;
import org.librecms.lifecycle.LifecycleDefinition;
@ -52,6 +50,7 @@ import java.util.Optional;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import org.jboss.arquillian.persistence.CleanupUsingScript;
import org.jboss.arquillian.persistence.TestExecutionPhase;
@ -60,6 +59,9 @@ import static org.junit.Assert.*;
import static org.libreccm.testutils.DependenciesHelpers.*;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
/**
* Tests for the {@link ContentItemManager}.
*
@ -90,7 +92,7 @@ public class ContentItemManagerTest {
private Shiro shiro;
@Inject
private WorkflowTemplateRepository workflowTemplateRepo;
private WorkflowRepository workflowRepo;
@Inject
private LifecycleDefinitionRepository lifecycleDefinitionRepo;
@ -194,7 +196,7 @@ public class ContentItemManagerTest {
assertThat(itemManager, is(not(nullValue())));
assertThat(folderRepo, is(not(nullValue())));
assertThat(shiro, is(not(nullValue())));
assertThat(workflowTemplateRepo, is(not(nullValue())));
assertThat(workflowRepo, is(not(nullValue())));
assertThat(lifecycleDefinitionRepo, is(not(nullValue())));
assertThat(entityManager, is(not(nullValue())));
}
@ -418,8 +420,9 @@ public class ContentItemManagerTest {
.get();
final Folder folder = section.getRootDocumentsFolder();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L).get();
final Workflow workflowTemplate = workflowRepo
.findById(-110L)
.get();
final Article article = itemManager.createContentItem(
"new-article",
@ -466,8 +469,9 @@ public class ContentItemManagerTest {
.get();
final Folder folder = section.getRootDocumentsFolder();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L).get();
final Workflow workflowTemplate = workflowRepo
.findById(-110L)
.get();
itemManager.createContentItem("Test",
section,
@ -499,8 +503,9 @@ public class ContentItemManagerTest {
.get();
final Folder folder = section.getRootDocumentsFolder();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L).get();
final Workflow workflowTemplate = workflowRepo
.findById(-110L)
.get();
itemManager.createContentItem(null,
section,
@ -561,8 +566,9 @@ public class ContentItemManagerTest {
.findByLabel("info")
.get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L).get();
final Workflow workflowTemplate = workflowRepo
.findById(-110L)
.get();
itemManager.createContentItem("Test",
section,

View File

@ -152,11 +152,11 @@ public class ContentItemPermissionTest {
.addClass(org.libreccm.workflow.TaskComment.class)
.addClass(org.libreccm.workflow.TaskState.class)
.addClass(org.libreccm.workflow.Workflow.class)
.addClass(org.libreccm.workflow.AbstractWorkflowException.class)
//Classes required by org.libreccm.categorization.Category
.addClass(org.libreccm.security.RecursivePermissions.class)
//Classes required by org.libreccm.workflow.Workflow.class
.addClass(org.libreccm.workflow.WorkflowState.class)
.addClass(org.libreccm.workflow.WorkflowTemplate.class)
//Classes required by org.librecms.contentsection.ContentItem
.addClass(org.librecms.contentsection.AttachmentList.class)
.addClass(org.librecms.contentsection.ContentItemVersion.class)

View File

@ -57,8 +57,8 @@ import static org.libreccm.testutils.DependenciesHelpers.*;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.arquillian.persistence.CleanupUsingScript;
import org.jboss.arquillian.persistence.TestExecutionPhase;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
import org.librecms.contentsection.privileges.ItemPrivileges;
import org.librecms.contenttypes.Article;
import org.librecms.contenttypes.Event;
@ -102,7 +102,7 @@ public class ContentSectionManagerTest {
private LifecycleDefinitionRepository lifecycleDefRepo;
@Inject
private WorkflowTemplateRepository workflowTemplateRepo;
private WorkflowRepository workflowRepo;
public ContentSectionManagerTest() {
}
@ -198,7 +198,7 @@ public class ContentSectionManagerTest {
assertThat(categoryRepo, is(not(nullValue())));
assertThat(typeRepo, is(not(nullValue())));
assertThat(lifecycleDefRepo, is(not(nullValue())));
assertThat(workflowTemplateRepo, is(not(nullValue())));
assertThat(workflowRepo, is(not(nullValue())));
}
/**
@ -449,9 +449,11 @@ public class ContentSectionManagerTest {
public void addContentTypeToSection() {
final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-14001L).get();
.findById(-13002L)
.get();
final Workflow workflowTemplate = workflowRepo
.findById(-14001L)
.get();
manager.addContentTypeToSection(Event.class,
section,
@ -474,9 +476,11 @@ public class ContentSectionManagerTest {
public void addAlreadyAddedContentTypeToSection() {
final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-14002L).get();
.findById(-13002L)
.get();
final Workflow workflowTemplate = workflowRepo
.findById(-14002L)
.get();
manager.addContentTypeToSection(News.class,
section,
@ -501,7 +505,7 @@ public class ContentSectionManagerTest {
final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
final Workflow workflowTemplate = workflowRepo
.findById(-14002L).get();
manager.addContentTypeToSection(null,
@ -527,7 +531,7 @@ public class ContentSectionManagerTest {
public void addContentTypeToSectionSectionIsNull() {
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
final Workflow workflowTemplate = workflowRepo
.findById(-14002L).get();
manager.addContentTypeToSection(Event.class,
@ -551,7 +555,7 @@ public class ContentSectionManagerTest {
@InSequence(800)
public void addContentTypeToSectionLifecycleIsNull() {
final ContentSection section = repository.findById(-1100L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
final Workflow workflowTemplate = workflowRepo
.findById(-14001L).get();
manager.addContentTypeToSection(Event.class,
@ -602,7 +606,7 @@ public class ContentSectionManagerTest {
final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13003L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
final Workflow workflowTemplate = workflowRepo
.findById(-14001L).get();
manager.addContentTypeToSection(Event.class,
@ -628,7 +632,7 @@ public class ContentSectionManagerTest {
final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
final Workflow workflowTemplate = workflowRepo
.findById(-14003L).get();
manager.addContentTypeToSection(Event.class,

View File

@ -388,7 +388,7 @@ public class ContentTypeRepositoryTest {
.addClass(org.libreccm.workflow.TaskState.class)
.addClass(org.libreccm.workflow.Workflow.class)
.addClass(org.libreccm.workflow.WorkflowState.class)
.addClass(org.libreccm.workflow.WorkflowTemplate.class)
.addClass(org.libreccm.workflow.AbstractWorkflowException.class)
.addClass(org.librecms.CmsConstants.class)
.addClass(org.librecms.contentsection.Asset.class)
.addClass(org.librecms.contentsection.AttachmentList.class)

View File

@ -30,12 +30,11 @@ import org.libreccm.security.User;
import org.libreccm.tests.categories.UnitTest;
import org.libreccm.testutils.EqualsVerifier;
import org.libreccm.web.CcmApplication;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.lifecycle.LifecycleDefinition;
import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
/**
*
@ -144,13 +143,11 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
final LifecycleDefinition lifecycleDef2 = new LifecycleDefinition();
lifecycleDef2.setDefinitionId(-110);
final WorkflowTemplate workflowTemplate1 = new WorkflowTemplate();
workflowTemplate1.getName().addValue(Locale.ENGLISH,
"Workflow Template 1");
final Workflow workflow1 = new Workflow();
workflow1.setAbstractWorkflow(true);
final WorkflowTemplate workflowTemplate2 = new WorkflowTemplate();
workflowTemplate2.getName().addValue(Locale.ENGLISH,
"Workflow Template 2");
final Workflow workflow2 = new Workflow();
workflow2.setAbstractWorkflow(false);
verifier
.withPrefabValues(ContentItem.class, item1, item2)
@ -167,9 +164,7 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
.withPrefabValues(LifecycleDefinition.class,
lifecycleDef1,
lifecycleDef2)
.withPrefabValues(WorkflowTemplate.class,
workflowTemplate1,
workflowTemplate2);
.withPrefabValues(Workflow.class, workflow1, workflow2);
}
/**

View File

@ -82,8 +82,6 @@ DELETE FROM ccm_core.workflow_task_descriptions;
DELETE FROM ccm_cms.content_section_workflow_templates;
DELETE FROM ccm_core.workflow_templates;
DELETE FROM ccm_core.workflows;
DELETE FROM ccm_cms.lifecycle_phase_definition_labels;

View File

@ -82,8 +82,6 @@ DELETE FROM ccm_core.workflow_task_descriptions;
DELETE FROM ccm_cms.content_section_workflow_templates;
DELETE FROM ccm_core.workflow_templates;
DELETE FROM ccm_core.workflows;
DELETE FROM ccm_cms.lifecycle_phase_definition_labels;

View File

@ -0,0 +1,67 @@
/*
* Copyright (C) 2017 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class AbstractWorkflowException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
* Creates a new instance of <code>AbstractWorkflowException</code> without detail message.
*/
public AbstractWorkflowException() {
super();
}
/**
* Constructs an instance of <code>AbstractWorkflowException</code> with the specified detail message.
*
* @param msg The detail message.
*/
public AbstractWorkflowException(final String msg) {
super(msg);
}
/**
* Constructs an instance of <code>AbstractWorkflowException</code> which wraps the
* specified exception.
*
* @param exception The exception to wrap.
*/
public AbstractWorkflowException(final Exception exception) {
super(exception);
}
/**
* Constructs an instance of <code>AbstractWorkflowException</code> with the specified message which also wraps the
* specified exception.
*
* @param msg The detail message.
* @param exception The exception to wrap.
*/
public AbstractWorkflowException(final String msg, final Exception exception) {
super(msg, exception);
}
}

View File

@ -29,6 +29,7 @@ import org.libreccm.portation.Portable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
@ -37,6 +38,8 @@ import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import java.util.Locale;
/**
* A workflow is a collection of tasks which are performed on an object. Tasks
* can depend on each other.
@ -78,13 +81,18 @@ public class Workflow implements Identifiable, Serializable, Portable {
@NotNull
private String uuid;
/**
* Indicates that this {@code Workflow} can be assigned to an object.
*/
@Column(name = "abstract_workflow")
private boolean abstractWorkflow;
/**
* The template which was used to generate the workflow.
*/
@ManyToOne
@JoinColumn(name = "TEMPLATE_ID")
@JsonIdentityReference(alwaysAsId = true)
private WorkflowTemplate template;
private Workflow template;
/**
* Human readable name of the workflow.
@ -173,11 +181,19 @@ public class Workflow implements Identifiable, Serializable, Portable {
this.uuid = uuid;
}
public WorkflowTemplate getTemplate() {
public boolean isAbstractWorkflow() {
return abstractWorkflow;
}
public void setAbstractWorkflow(boolean abstractWorkflow) {
this.abstractWorkflow = abstractWorkflow;
}
public Workflow getTemplate() {
return template;
}
protected void setTemplate(final WorkflowTemplate template) {
protected void setTemplate(final Workflow template) {
this.template = template;
}
@ -228,6 +244,11 @@ public class Workflow implements Identifiable, Serializable, Portable {
}
protected void setObject(final CcmObject object) {
if (abstractWorkflow) {
throw new AbstractWorkflowException(String.format(
"Workflow %s is abstrct and can not assigned to an object.",
uuid));
}
this.object = object;
}
@ -257,6 +278,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
hash = 79 * hash + (int) (workflowId ^ (workflowId >>> 32));
hash = 79 * hash + Objects.hashCode(uuid);
hash = 79 * hash + Objects.hashCode(name);
hash = 79 * hash + (abstractWorkflow ? 1 : 0);
hash = 79 * hash + Objects.hashCode(description);
hash = 79 * hash + Objects.hashCode(state);
hash = 79 * hash + (active ? 1 : 0);
@ -289,6 +311,10 @@ public class Workflow implements Identifiable, Serializable, Portable {
return false;
}
if (abstractWorkflow != other.isAbstractWorkflow()) {
return false;
}
if (!Objects.equals(description, other.getDescription())) {
return false;
}
@ -319,6 +345,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
+ "uuid = \"%s\", "
+ "name = \"%s\", "
+ "description = \"%s\", "
+ "abstractWorkflow = %b, "
+ "state = \"%s\", "
+ "active = %b%s"
+ " }",
@ -327,6 +354,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
uuid,
Objects.toString(name),
Objects.toString(description),
abstractWorkflow,
Objects.toString(state),
active,
data);

View File

@ -19,6 +19,7 @@
package org.libreccm.workflow;
import com.arsdigita.kernel.KernelConfig;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.shiro.subject.Subject;
@ -37,13 +38,22 @@ import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
/**
* Manager for {@link Workflow}s. The logic of some of these classes has been
@ -109,17 +119,17 @@ public class WorkflowManager {
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)
public Workflow createWorkflow(final WorkflowTemplate template,
public Workflow createWorkflow(final Workflow template,
final CcmObject object) {
if (template == null) {
throw new IllegalArgumentException(
Objects.requireNonNull(template,
"Can't create a workflow without a template.");
if (!template.isAbstractWorkflow()) {
throw new IllegalArgumentException(
"The provided template is not an abstract workflow");
}
if (object == null) {
throw new IllegalArgumentException(
Objects.requireNonNull(object,
"Can't create a workflow without an object.");
}
final Workflow workflow = new Workflow();

View File

@ -1,98 +0,0 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.core.CcmObject;
import org.libreccm.portation.Portable;
import org.libreccm.security.GroupIdResolver;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import java.io.Serializable;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
/**
* Objects of these class are used as templates for new workflows. The tasks
* in the template are copied when a new workflow is generated.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "WORKFLOW_TEMPLATES", schema = DB_SCHEMA)
@NamedQueries({
@NamedQuery(
name = "WorkflowTemplate.findByUuid",
query = "SELECT t FROM WorkflowTemplate t " +
"WHERE t.uuid = :uuid")
})
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = WorkflowTemplateIdResolver.class,
property = "uuid")
public class WorkflowTemplate extends Workflow implements Serializable,
Portable {
private static final long serialVersionUID = 5770519379144947171L;
/**
* A workflow template has no object. Therefore the {@code setObject
* (CcmObject)} method has been overwritten to throw an
* {@link UnsupportedOperationException} when called on the workflow
* template.
*
* @param object
*/
@Override
protected void setObject(final CcmObject object) {
//throw new UnsupportedOperationException(
// "A WorkflowTemplate has no object.");
}
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof WorkflowTemplate)) {
return false;
}
final WorkflowTemplate other = (WorkflowTemplate) obj;
return other.canEqual(obj);
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof WorkflowTemplate;
}
}

View File

@ -1,62 +0,0 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
import org.libreccm.cdi.utils.CdiUtil;
import javax.enterprise.context.RequestScoped;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 9/6/17
*/
@RequestScoped
public class WorkflowTemplateIdResolver implements ObjectIdResolver {
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowTemplateRepository workflowTemplateRepository = cdiUtil
.findBean(WorkflowTemplateRepository.class);
return workflowTemplateRepository
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No workflow templates with uuid %s in the " +
"database.", id.key.toString())));
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
return new WorkflowTemplateIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
return resolverType instanceof WorkflowTemplateIdResolver;
}
}

View File

@ -1,50 +0,0 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
import org.libreccm.portation.AbstractMarshaller;
import org.libreccm.portation.Marshals;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 11/21/16
*/
@RequestScoped
@Marshals(WorkflowTemplate.class)
public class WorkflowTemplateMarshaller extends
AbstractMarshaller<WorkflowTemplate> {
@Inject
private WorkflowTemplateRepository workflowTemplateRepository;
@Override
protected Class<WorkflowTemplate> getObjectClass() {
return WorkflowTemplate.class;
}
@Override
@Transactional(Transactional.TxType.REQUIRED)
protected void insertIntoDb(WorkflowTemplate portableObject) {
workflowTemplateRepository.save(portableObject);
}
}

View File

@ -1,80 +0,0 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
import org.libreccm.core.AbstractEntityRepository;
import javax.enterprise.context.RequestScoped;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import java.util.Optional;
import java.util.UUID;
/**
* A repository for {@link WorkflowTemplate}s.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class WorkflowTemplateRepository
extends AbstractEntityRepository<Long, WorkflowTemplate> {
@Override
public Class<WorkflowTemplate> getEntityClass() {
return WorkflowTemplate.class;
}
@Override
public boolean isNew(final WorkflowTemplate template) {
return template.getWorkflowId() == 0;
}
@Override
public void initNewEntity(final WorkflowTemplate workflowTemplate) {
super.initNewEntity(workflowTemplate);
workflowTemplate.setUuid(UUID.randomUUID().toString());
}
/**
* Find a {@link WorkflowTemplate} by its UUID.
*
* @param uuid The UUID of the {@link WorkflowTemplate} to find.
*
* @return An {@link Optional} containing the {@link WorkflowTemplate}
* identified by the provided UUID.
*/
public Optional<WorkflowTemplate> findByUuid(final String uuid) {
if (uuid == null || uuid.trim().isEmpty()) {
throw new IllegalArgumentException(
"The UUID of the WorkflowTemplate to retrieve can't be " +
"null or empty.");
}
final TypedQuery<WorkflowTemplate> query = getEntityManager()
.createNamedQuery("WorkflowTemplate.findByUuid",
WorkflowTemplate.class);
query.setParameter("uuid", uuid);
try {
return Optional.of(query.getSingleResult());
} catch(NoResultException ex) {
return Optional.empty();
}
}
}

View File

@ -0,0 +1,13 @@
alter table CCM_CORE.WORKFLOWS add column ABSTRACT_WORKFLOW boolean;
update CCM_CORE.WORKFLOWS set ABSTRACT_WORKFLOW = true
where WORKFLOW_ID in (select WORKFLOW_ID from CCM_CORE.WORKFLOW_TEMPLATES);
alter table CCM_CORE.WORKFLOW_TEMPLATES
drop constraint if exists FK8692vdme4yxnkj1m0k1dw74pk;
alter table CCM_CORE.WORKFLOWS
drop constraint if exists FKeixdxau4jebw682gd49tdbsjy;
drop table CCM_CORE.WORKFLOW_TEMPLATES cascade;

View File

@ -0,0 +1,13 @@
alter table CCM_CORE.WORKFLOWS add column ABSTRACT_WORKFLOW boolean;
update CCM_CORE.WORKFLOWS set ABSTRACT_WORKFLOW = true
where WORKFLOW_ID in (select WORKFLOW_ID from CCM_CORE.WORKFLOW_TEMPLATES);
alter table CCM_CORE.WORKFLOW_TEMPLATES
drop constraint if exists FK8692vdme4yxnkj1m0k1dw74pk;
alter table CCM_CORE.WORKFLOWS
drop constraint if exists FKeixdxau4jebw682gd49tdbsjy;
drop table CCM_CORE.WORKFLOW_TEMPLATES cascade;

View File

@ -144,7 +144,7 @@ public class CoreDataImportTest {
Assert.assertFalse(importHelper.importPermissions());
Assert.assertFalse(importHelper.importWorkflowTemplates());
// Assert.assertFalse(importHelper.importWorkflowTemplates());
Assert.assertFalse(importHelper.importWorkflows());
Assert.assertFalse(importHelper.importTaskComments());
//Assert.assertFalse(importHelper.importAssignableTasks());

View File

@ -79,13 +79,6 @@ class ImportHelper {
@Marshals(DomainOwnership.class)
private DomainOwnershipMarshaller domainOwnershipMarshaller;
@Inject
@Marshals(Permission.class)
private PermissionMarshaller permissionMarshaller;
@Inject
@Marshals(WorkflowTemplate.class)
private WorkflowTemplateMarshaller workflowTemplateMarshaller;
@Inject
@Marshals(Workflow.class)
private WorkflowMarshaller workflowMarshaller;
@ -209,14 +202,6 @@ class ImportHelper {
return permissionMarshaller.importFile();
}
boolean importWorkflowTemplates() {
workflowTemplateMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"workflowTemplates.xml",
indentation);
return workflowTemplateMarshaller.importFile();
}
boolean importWorkflows() {
workflowMarshaller.prepare(

View File

@ -579,13 +579,12 @@ public class PermissionManagerTest {
/**
* Verifies that
* {@link PermissionManager#revokePrivilege(java.lang.String, org.libreccm.security.Role, org.libreccm.core.CcmObject)}
* throws an {@link IllegalArgumentException} if called with {@code null}
* for the privilege to revoke.
* throws an {@link NullPointerException} if called with {@code null} for
* the privilege to revoke.
*
* @throws Throwable
*/
@Test(expected
= IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@ -605,15 +604,14 @@ public class PermissionManagerTest {
/**
* Verifies that
* {@link PermissionManager#revokePrivilege(java.lang.String, org.libreccm.security.Role)}
* throws an {@link IllegalArgumentException} if called with {@code null}
* for the role to revoke the permission from.
* throws an {@link NullPointerException} if called with {@code null} for
* the role to revoke the permission from.
*
* @throws Throwable
*/
@Test(expected
= IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@Test(expected = IllegalArgumentException.class)
@UsingDataSet("datasets/org/libreccm/security/PermissionManagerTest/"
+ "data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(340)
public void revokePermissionFromRoleNull() throws Throwable {
@ -628,15 +626,15 @@ public class PermissionManagerTest {
/**
* Verifies that
* {@link PermissionManager#revokePrivilege(java.lang.String, org.libreccm.security.Role, org.libreccm.core.CcmObject)}
* throws an {@link IllegalArgumentException} if called with {@code null}
* for the role to revoke the permission from.
* throws an {@link NullPointerException} if called with {@code null} for
* the role to revoke the permission from.
*
* @throws Throwable
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = NullPointerException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@ShouldThrowException(NullPointerException.class)
@InSequence(345)
public void revokePermissionOnObjectFromRoleNull() throws Throwable {
final CcmObject object1 = ccmObjectRepository.findById(-20001L).get();
@ -659,10 +657,10 @@ public class PermissionManagerTest {
*
* @throws Throwable
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = NullPointerException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@ShouldThrowException(NullPointerException.class)
@InSequence(350)
public void revokePermissionNullObject() throws Throwable {
final Role role1 = roleRepository.findByName("role1").get();

View File

@ -47,8 +47,7 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
TaskComment.class,
TaskAssignment.class,
AssignableTask.class,
Workflow.class,
WorkflowTemplate.class
Workflow.class
});
}
@ -98,12 +97,6 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
final Workflow workflow2 = new Workflow();
workflow2.getName().addValue(Locale.ENGLISH, "Workflow 2");
final WorkflowTemplate template1 = new WorkflowTemplate();
template1.getName().addValue(Locale.ENGLISH, "Template 1");
final WorkflowTemplate template2 = new WorkflowTemplate();
template1.getName().addValue(Locale.ENGLISH, "Template 2");
final CcmObject object1 = new CcmObject();
object1.setDisplayName("Object 1");
@ -117,7 +110,6 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
.withPrefabValues(Group.class, group1, group2)
.withPrefabValues(User.class, user1, user2)
.withPrefabValues(Workflow.class, workflow1, workflow2)
.withPrefabValues(WorkflowTemplate.class, template1, template2)
.withPrefabValues(CcmObject.class, object1, object2);
}

View File

@ -46,7 +46,7 @@ create schema CCM_CORE;
create table CCM_CORE.CATEGORY_DESCRIPTIONS (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
@ -63,7 +63,7 @@ create schema CCM_CORE;
create table CCM_CORE.CATEGORY_TITLES (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
@ -111,7 +111,7 @@ create schema CCM_CORE;
create table CCM_CORE.DOMAIN_DESCRIPTIONS (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
@ -128,14 +128,14 @@ create schema CCM_CORE;
create table CCM_CORE.DOMAIN_TITLES (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
create table CCM_CORE.FORMBUILDER_COMPONENT_DESCRIPTIONS (
COMPONENT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (COMPONENT_ID, LOCALE)
);
@ -180,14 +180,14 @@ create schema CCM_CORE;
create table CCM_CORE.FORMBUILDER_DATA_QUERY_DESCRIPTIONS (
DATA_QUERY_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (DATA_QUERY_ID, LOCALE)
);
create table CCM_CORE.FORMBUILDER_DATA_QUERY_NAMES (
DATA_QUERY_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (DATA_QUERY_ID, LOCALE)
);
@ -224,7 +224,7 @@ create schema CCM_CORE;
create table CCM_CORE.FORMBUILDER_OPTION_LABELS (
OPTION_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OPTION_ID, LOCALE)
);
@ -237,14 +237,14 @@ create schema CCM_CORE;
create table CCM_CORE.FORMBUILDER_PROCESS_LISTENER_DESCRIPTIONS (
PROCESS_LISTENER_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PROCESS_LISTENER_ID, LOCALE)
);
create table CCM_CORE.FORMBUILDER_PROCESS_LISTENER_NAMES (
PROCESS_LISTENER_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PROCESS_LISTENER_ID, LOCALE)
);
@ -403,14 +403,14 @@ create schema CCM_CORE;
create table CCM_CORE.PAGE_MODEL_DESCRIPTIONS (
PAGE_MODEL_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PAGE_MODEL_ID, LOCALE)
);
create table CCM_CORE.PAGE_MODEL_TITLES (
PAGE_MODEL_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PAGE_MODEL_ID, LOCALE)
);
@ -436,7 +436,7 @@ create schema CCM_CORE;
PERMISSION_ID bigint not null,
CREATION_DATE timestamp,
CREATION_IP varchar(255),
granted_privilege varchar(255),
GRANTED_PRIVILEGE varchar(255),
INHERITED boolean,
CREATION_USER_ID bigint,
GRANTEE_ID bigint,
@ -473,21 +473,21 @@ create schema CCM_CORE;
create table CCM_CORE.RESOURCE_DESCRIPTIONS (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
create table CCM_CORE.RESOURCE_TITLES (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
create table CCM_CORE.RESOURCE_TYPE_DESCRIPTIONS (
RESOURCE_TYPE_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (RESOURCE_TYPE_ID, LOCALE)
);
@ -512,7 +512,7 @@ create schema CCM_CORE;
create table CCM_CORE.ROLE_DESCRIPTIONS (
ROLE_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (ROLE_ID, LOCALE)
);
@ -529,11 +529,11 @@ create schema CCM_CORE;
SETTING_ID bigint not null,
CONFIGURATION_CLASS varchar(512) not null,
NAME varchar(512) not null,
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
SETTING_VALUE_BOOLEAN boolean,
SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_DOUBLE double,
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
SETTING_VALUE_LONG bigint,
SETTING_VALUE_DOUBLE double,
SETTING_VALUE_STRING varchar(1024),
primary key (SETTING_ID)
);
@ -544,7 +544,7 @@ create schema CCM_CORE;
create table CCM_CORE.SETTINGS_L10N_STR_VALUES (
ENTRY_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (ENTRY_ID, LOCALE)
);
@ -593,14 +593,14 @@ create schema CCM_CORE;
create table CCM_CORE.WORKFLOW_DESCRIPTIONS (
WORKFLOW_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (WORKFLOW_ID, LOCALE)
);
create table CCM_CORE.WORKFLOW_NAMES (
WORKFLOW_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (WORKFLOW_ID, LOCALE)
);
@ -614,7 +614,7 @@ create schema CCM_CORE;
create table CCM_CORE.WORKFLOW_TASK_COMMENTS (
COMMENT_ID bigint not null,
COMMENT longvarchar,
COMMENT varchar(2147483647),
UUID varchar(255) not null,
AUTHOR_ID bigint,
TASK_ID bigint,
@ -628,14 +628,14 @@ create schema CCM_CORE;
create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS (
TASK_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (TASK_ID, LOCALE)
);
create table CCM_CORE.WORKFLOW_TASK_LABELS (
TASK_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (TASK_ID, LOCALE)
);
@ -649,13 +649,9 @@ create schema CCM_CORE;
primary key (TASK_ID)
);
create table CCM_CORE.WORKFLOW_TEMPLATES (
WORKFLOW_ID bigint not null,
primary key (WORKFLOW_ID)
);
create table CCM_CORE.WORKFLOWS (
WORKFLOW_ID bigint not null,
abstract_workflow boolean,
ACTIVE boolean,
WORKFLOW_STATE varchar(255),
TASKS_STATE varchar(255),
@ -691,7 +687,8 @@ create schema CCM_CORE;
alter table CCM_CORE.WORKFLOWS
add constraint UK_o113id7d1cxql0edsrohlnn9x unique (UUID);
create sequence hibernate_sequence start with 1 increment by 1;
create sequence hibernate_sequence start with 1 increment by 1;
alter table CCM_CORE.APPLICATIONS
add constraint FKatcp9ij6mbkx0nfeig1o6n3lm
@ -1014,7 +1011,7 @@ create sequence hibernate_sequence start with 1 increment by 1;
references CCM_CORE.CCM_ROLES;
alter table CCM_CORE.PERMISSIONS
add constraint FKc1x3h1p3o20qiwmonpmva7t5i
add constraint FKg56ujjoe0j30pq579rf0l5yc6
foreign key (INHERITED_FROM_ID)
references CCM_CORE.CCM_OBJECTS;
@ -1198,17 +1195,12 @@ create sequence hibernate_sequence start with 1 increment by 1;
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOW_TEMPLATES
add constraint FK8692vdme4yxnkj1m0k1dw74pk
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOWS
add constraint FKrm2yfrs6veoxoy304upq2wc64
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.WORKFLOWS
add constraint FKeixdxau4jebw682gd49tdbsjy
add constraint FK9ray5beiny6wm2mi0uwyecay2
foreign key (TEMPLATE_ID)
references CCM_CORE.WORKFLOW_TEMPLATES;
references CCM_CORE.WORKFLOWS;

View File

@ -2,7 +2,7 @@ drop schema if exists CCM_CORE cascade;
drop sequence if exists HIBERNATE_SEQUENCE;
create schema CCM_CORE;
create schema CCM_CORE;
create table CCM_CORE.APPLICATIONS (
APPLICATION_TYPE varchar(1024) not null,
@ -436,7 +436,7 @@ create schema CCM_CORE;
PERMISSION_ID int8 not null,
CREATION_DATE timestamp,
CREATION_IP varchar(255),
granted_privilege varchar(255),
GRANTED_PRIVILEGE varchar(255),
INHERITED boolean,
CREATION_USER_ID int8,
GRANTEE_ID int8,
@ -529,11 +529,11 @@ create schema CCM_CORE;
SETTING_ID int8 not null,
CONFIGURATION_CLASS varchar(512) not null,
NAME varchar(512) not null,
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
SETTING_VALUE_BOOLEAN boolean,
SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_DOUBLE float8,
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
SETTING_VALUE_LONG int8,
SETTING_VALUE_DOUBLE float8,
SETTING_VALUE_STRING varchar(1024),
primary key (SETTING_ID)
);
@ -649,13 +649,9 @@ create schema CCM_CORE;
primary key (TASK_ID)
);
create table CCM_CORE.WORKFLOW_TEMPLATES (
WORKFLOW_ID int8 not null,
primary key (WORKFLOW_ID)
);
create table CCM_CORE.WORKFLOWS (
WORKFLOW_ID int8 not null,
abstract_workflow boolean,
ACTIVE boolean,
WORKFLOW_STATE varchar(255),
TASKS_STATE varchar(255),
@ -691,7 +687,8 @@ create schema CCM_CORE;
alter table CCM_CORE.WORKFLOWS
add constraint UK_o113id7d1cxql0edsrohlnn9x unique (UUID);
create sequence hibernate_sequence start 1 increment 1;
create sequence hibernate_sequence start 1 increment 1;
alter table CCM_CORE.APPLICATIONS
add constraint FKatcp9ij6mbkx0nfeig1o6n3lm
@ -1014,7 +1011,7 @@ create sequence hibernate_sequence start 1 increment 1;
references CCM_CORE.CCM_ROLES;
alter table CCM_CORE.PERMISSIONS
add constraint FKc1x3h1p3o20qiwmonpmva7t5i
add constraint FKg56ujjoe0j30pq579rf0l5yc6
foreign key (INHERITED_FROM_ID)
references CCM_CORE.CCM_OBJECTS;
@ -1198,17 +1195,12 @@ create sequence hibernate_sequence start 1 increment 1;
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOW_TEMPLATES
add constraint FK8692vdme4yxnkj1m0k1dw74pk
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOWS
add constraint FKrm2yfrs6veoxoy304upq2wc64
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.WORKFLOWS
add constraint FKeixdxau4jebw682gd49tdbsjy
add constraint FK9ray5beiny6wm2mi0uwyecay2
foreign key (TEMPLATE_ID)
references CCM_CORE.WORKFLOW_TEMPLATES;
references CCM_CORE.WORKFLOWS;

View File

@ -48,7 +48,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.CATEGORY_DESCRIPTIONS (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
@ -65,7 +65,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.CATEGORY_TITLES (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
@ -81,7 +81,6 @@ CREATE SCHEMA ccm_shortcuts;
OBJECT_ID bigint not null,
REV integer not null,
REVTYPE tinyint,
REVEND integer,
DISPLAY_NAME varchar(255),
primary key (OBJECT_ID, REV)
);
@ -113,7 +112,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.DOMAIN_DESCRIPTIONS (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
@ -130,14 +129,14 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.DOMAIN_TITLES (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
create table CCM_CORE.FORMBUILDER_COMPONENT_DESCRIPTIONS (
COMPONENT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (COMPONENT_ID, LOCALE)
);
@ -182,14 +181,14 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.FORMBUILDER_DATA_QUERY_DESCRIPTIONS (
DATA_QUERY_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (DATA_QUERY_ID, LOCALE)
);
create table CCM_CORE.FORMBUILDER_DATA_QUERY_NAMES (
DATA_QUERY_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (DATA_QUERY_ID, LOCALE)
);
@ -226,7 +225,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.FORMBUILDER_OPTION_LABELS (
OPTION_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OPTION_ID, LOCALE)
);
@ -239,14 +238,14 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.FORMBUILDER_PROCESS_LISTENER_DESCRIPTIONS (
PROCESS_LISTENER_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PROCESS_LISTENER_ID, LOCALE)
);
create table CCM_CORE.FORMBUILDER_PROCESS_LISTENER_NAMES (
PROCESS_LISTENER_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PROCESS_LISTENER_ID, LOCALE)
);
@ -405,14 +404,14 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.PAGE_MODEL_DESCRIPTIONS (
PAGE_MODEL_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PAGE_MODEL_ID, LOCALE)
);
create table CCM_CORE.PAGE_MODEL_TITLES (
PAGE_MODEL_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PAGE_MODEL_ID, LOCALE)
);
@ -438,7 +437,7 @@ CREATE SCHEMA ccm_shortcuts;
PERMISSION_ID bigint not null,
CREATION_DATE timestamp,
CREATION_IP varchar(255),
granted_privilege varchar(255),
GRANTED_PRIVILEGE varchar(255),
INHERITED boolean,
CREATION_USER_ID bigint,
GRANTEE_ID bigint,
@ -475,21 +474,21 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.RESOURCE_DESCRIPTIONS (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
create table CCM_CORE.RESOURCE_TITLES (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
create table CCM_CORE.RESOURCE_TYPE_DESCRIPTIONS (
RESOURCE_TYPE_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (RESOURCE_TYPE_ID, LOCALE)
);
@ -514,7 +513,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.ROLE_DESCRIPTIONS (
ROLE_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (ROLE_ID, LOCALE)
);
@ -531,11 +530,11 @@ CREATE SCHEMA ccm_shortcuts;
SETTING_ID bigint not null,
CONFIGURATION_CLASS varchar(512) not null,
NAME varchar(512) not null,
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
SETTING_VALUE_BOOLEAN boolean,
SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_DOUBLE double,
SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_BOOLEAN boolean,
SETTING_VALUE_LONG bigint,
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
primary key (SETTING_ID)
);
@ -546,7 +545,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.SETTINGS_L10N_STR_VALUES (
ENTRY_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (ENTRY_ID, LOCALE)
);
@ -595,14 +594,14 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.WORKFLOW_DESCRIPTIONS (
WORKFLOW_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (WORKFLOW_ID, LOCALE)
);
create table CCM_CORE.WORKFLOW_NAMES (
WORKFLOW_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (WORKFLOW_ID, LOCALE)
);
@ -616,7 +615,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.WORKFLOW_TASK_COMMENTS (
COMMENT_ID bigint not null,
COMMENT longvarchar,
COMMENT varchar(2147483647),
UUID varchar(255) not null,
AUTHOR_ID bigint,
TASK_ID bigint,
@ -630,14 +629,14 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS (
TASK_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (TASK_ID, LOCALE)
);
create table CCM_CORE.WORKFLOW_TASK_LABELS (
TASK_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (TASK_ID, LOCALE)
);
@ -651,13 +650,9 @@ CREATE SCHEMA ccm_shortcuts;
primary key (TASK_ID)
);
create table CCM_CORE.WORKFLOW_TEMPLATES (
WORKFLOW_ID bigint not null,
primary key (WORKFLOW_ID)
);
create table CCM_CORE.WORKFLOWS (
WORKFLOW_ID bigint not null,
abstract_workflow boolean,
ACTIVE boolean,
WORKFLOW_STATE varchar(255),
TASKS_STATE varchar(255),
@ -693,7 +688,18 @@ CREATE SCHEMA ccm_shortcuts;
alter table CCM_CORE.WORKFLOWS
add constraint UK_o113id7d1cxql0edsrohlnn9x unique (UUID);
create sequence hibernate_sequence start with 1 increment by 1;
create table CCM_SHORTCUTS.SHORTCUTS (
SHORTCUT_ID bigint not null,
REDIRECT varchar(1024),
URL_KEY varchar(1024),
primary key (SHORTCUT_ID)
);
alter table CCM_SHORTCUTS.SHORTCUTS
add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY);
create sequence hibernate_sequence start with 1 increment by 1;
alter table CCM_CORE.APPLICATIONS
add constraint FKatcp9ij6mbkx0nfeig1o6n3lm
@ -750,11 +756,6 @@ create sequence hibernate_sequence start with 1 increment by 1;
foreign key (REV)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CORE.CCM_OBJECTS_AUD
add constraint FKo5s37ctcdny7tmewjwv7705h5
foreign key (REVEND)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CORE.DIGESTS
add constraint FKc53g09agnye3w1v4euy3e0gsi
foreign key (FROM_PARTY_ID)
@ -1016,7 +1017,7 @@ create sequence hibernate_sequence start with 1 increment by 1;
references CCM_CORE.CCM_ROLES;
alter table CCM_CORE.PERMISSIONS
add constraint FKc1x3h1p3o20qiwmonpmva7t5i
add constraint FKg56ujjoe0j30pq579rf0l5yc6
foreign key (INHERITED_FROM_ID)
references CCM_CORE.CCM_OBJECTS;
@ -1200,27 +1201,12 @@ create sequence hibernate_sequence start with 1 increment by 1;
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOW_TEMPLATES
add constraint FK8692vdme4yxnkj1m0k1dw74pk
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOWS
add constraint FKrm2yfrs6veoxoy304upq2wc64
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.WORKFLOWS
add constraint FKeixdxau4jebw682gd49tdbsjy
add constraint FK9ray5beiny6wm2mi0uwyecay2
foreign key (TEMPLATE_ID)
references CCM_CORE.WORKFLOW_TEMPLATES;
create table CCM_SHORTCUTS.SHORTCUTS (
SHORTCUT_ID bigint not null,
REDIRECT varchar(1024),
URL_KEY varchar(1024),
primary key (SHORTCUT_ID)
);
alter table CCM_SHORTCUTS.SHORTCUTS
add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY);
references CCM_CORE.WORKFLOWS;

View File

@ -81,7 +81,6 @@ create table CCM_CORE.APPLICATIONS (
OBJECT_ID int8 not null,
REV int4 not null,
REVTYPE int2,
REVEND int4,
DISPLAY_NAME varchar(255),
primary key (OBJECT_ID, REV)
);
@ -438,7 +437,7 @@ create table CCM_CORE.APPLICATIONS (
PERMISSION_ID int8 not null,
CREATION_DATE timestamp,
CREATION_IP varchar(255),
granted_privilege varchar(255),
GRANTED_PRIVILEGE varchar(255),
INHERITED boolean,
CREATION_USER_ID int8,
GRANTEE_ID int8,
@ -531,11 +530,11 @@ create table CCM_CORE.APPLICATIONS (
SETTING_ID int8 not null,
CONFIGURATION_CLASS varchar(512) not null,
NAME varchar(512) not null,
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
SETTING_VALUE_BOOLEAN boolean,
SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_DOUBLE float8,
SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_BOOLEAN boolean,
SETTING_VALUE_LONG int8,
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
primary key (SETTING_ID)
);
@ -651,13 +650,9 @@ create table CCM_CORE.APPLICATIONS (
primary key (TASK_ID)
);
create table CCM_CORE.WORKFLOW_TEMPLATES (
WORKFLOW_ID int8 not null,
primary key (WORKFLOW_ID)
);
create table CCM_CORE.WORKFLOWS (
WORKFLOW_ID int8 not null,
abstract_workflow boolean,
ACTIVE boolean,
WORKFLOW_STATE varchar(255),
TASKS_STATE varchar(255),
@ -693,7 +688,18 @@ create table CCM_CORE.APPLICATIONS (
alter table CCM_CORE.WORKFLOWS
add constraint UK_o113id7d1cxql0edsrohlnn9x unique (UUID);
create sequence hibernate_sequence start 1 increment 1;
create table CCM_SHORTCUTS.SHORTCUTS (
SHORTCUT_ID int8 not null,
REDIRECT varchar(1024),
URL_KEY varchar(1024),
primary key (SHORTCUT_ID)
);
alter table CCM_SHORTCUTS.SHORTCUTS
add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY);
create sequence hibernate_sequence start 1 increment 1;
alter table CCM_CORE.APPLICATIONS
add constraint FKatcp9ij6mbkx0nfeig1o6n3lm
@ -750,11 +756,6 @@ create sequence hibernate_sequence start 1 increment 1;
foreign key (REV)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CORE.CCM_OBJECTS_AUD
add constraint FKo5s37ctcdny7tmewjwv7705h5
foreign key (REVEND)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CORE.DIGESTS
add constraint FKc53g09agnye3w1v4euy3e0gsi
foreign key (FROM_PARTY_ID)
@ -1016,7 +1017,7 @@ create sequence hibernate_sequence start 1 increment 1;
references CCM_CORE.CCM_ROLES;
alter table CCM_CORE.PERMISSIONS
add constraint FKc1x3h1p3o20qiwmonpmva7t5i
add constraint FKg56ujjoe0j30pq579rf0l5yc6
foreign key (INHERITED_FROM_ID)
references CCM_CORE.CCM_OBJECTS;
@ -1200,28 +1201,12 @@ create sequence hibernate_sequence start 1 increment 1;
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOW_TEMPLATES
add constraint FK8692vdme4yxnkj1m0k1dw74pk
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOWS
add constraint FKrm2yfrs6veoxoy304upq2wc64
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.WORKFLOWS
add constraint FKeixdxau4jebw682gd49tdbsjy
add constraint FK9ray5beiny6wm2mi0uwyecay2
foreign key (TEMPLATE_ID)
references CCM_CORE.WORKFLOW_TEMPLATES;
create table CCM_SHORTCUTS.SHORTCUTS (
SHORTCUT_ID int8 not null,
REDIRECT varchar(1024),
URL_KEY varchar(1024),
primary key (SHORTCUT_ID)
);
alter table CCM_SHORTCUTS.SHORTCUTS
add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY);
references CCM_CORE.WORKFLOWS;