CCM NG: Refactored dependencies between tasks from an n:m relation to two 1:n relations using an relation entity (TaskDependency). Also renamed some attributes to make the dependency relations more readable.
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5162 8810af33-2d31-482b-a856-94f89814c4df
Former-commit-id: 2d900794f9
pull/2/head
parent
7c23d97bc2
commit
02c4f07aa2
|
|
@ -363,9 +363,9 @@
|
|||
<groupId>com.github.spotbugs</groupId>
|
||||
<artifactId>spotbugs-maven-plugin</artifactId>
|
||||
<version>3.1.0-RC8</version>
|
||||
<configuration>
|
||||
<!--<configuration>
|
||||
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
|
||||
</configuration>
|
||||
</configuration>-->
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ import org.libreccm.categorization.CategoryManager;
|
|||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
import org.libreccm.security.Shiro;
|
||||
import org.libreccm.workflow.TaskDependency;
|
||||
import org.librecms.contentsection.ContentItemRepository;
|
||||
import org.librecms.contentsection.ContentSectionManager;
|
||||
import org.librecms.dispatcher.ItemResolver;
|
||||
|
|
@ -171,11 +172,15 @@ public class Summary extends CMSContainer {
|
|||
final GraphSet graph = new GraphSet();
|
||||
|
||||
for (final Task task : tasks) {
|
||||
final List<Task> dependsOn = task.getDependsOn();
|
||||
final List<TaskDependency> blockingTasks = task
|
||||
.getBlockingTasks();
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
for (final Task dep : dependsOn) {
|
||||
graph.addEdge(task, dep, null);
|
||||
builder.append(dep.getLabel().getValue(language));
|
||||
for (final TaskDependency blocking : blockingTasks) {
|
||||
graph.addEdge(task, blocking, null);
|
||||
builder.append(blocking
|
||||
.getBlockingTask()
|
||||
.getLabel()
|
||||
.getValue(language));
|
||||
}
|
||||
|
||||
final int len = builder.length();
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import com.arsdigita.util.UncheckedWrapperException;
|
|||
import org.libreccm.workflow.Task;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.workflow.CircularTaskDependencyException;
|
||||
import org.libreccm.workflow.TaskDependency;
|
||||
import org.libreccm.workflow.TaskManager;
|
||||
import org.libreccm.workflow.TaskRepository;
|
||||
import org.librecms.CmsConstants;
|
||||
|
|
@ -187,10 +188,12 @@ class BaseTaskForm extends BaseForm {
|
|||
*/
|
||||
final void processDependencies(final Task task,
|
||||
final String[] selectedDependencies) {
|
||||
final List<Task> dependencies = task.getDependentTasks();
|
||||
final List<TaskDependency> blockedTasks = task.getBlockedTasks();
|
||||
final Map<Long, Task> toAdd = new HashMap<>();
|
||||
// Everything is to be removed unless it is in the array.
|
||||
final Map<Long, Task> toRemove = dependencies.stream()
|
||||
final Map<Long, Task> toRemove = blockedTasks
|
||||
.stream()
|
||||
.map(TaskDependency::getBlockedTask)
|
||||
.collect(Collectors.toMap(Task::getTaskId,
|
||||
dependency -> dependency));
|
||||
|
||||
|
|
|
|||
|
|
@ -34,9 +34,8 @@ import org.librecms.workflow.CmsTask;
|
|||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.workflow.Task;
|
||||
import org.libreccm.workflow.TaskRepository;
|
||||
import org.libreccm.workflow.TaskDependency;
|
||||
import org.libreccm.workflow.Workflow;
|
||||
import org.librecms.workflow.CmsTaskType;
|
||||
|
||||
|
|
@ -125,9 +124,11 @@ class TaskEditForm extends BaseTaskForm {
|
|||
final WorkflowAdminPaneController controller = cdiUtil.findBean(
|
||||
WorkflowAdminPaneController.class);
|
||||
|
||||
final List<Task> dependencies = controller.getDependencies(task);
|
||||
final List<String> depIdList = dependencies.stream()
|
||||
.map(dependency -> Long.toString(dependency.getTaskId()))
|
||||
final List<TaskDependency> blockedTasks = controller.getBlockedTasks(task);
|
||||
final List<String> depIdList = blockedTasks
|
||||
.stream()
|
||||
.map(TaskDependency::getBlockedTask)
|
||||
.map(blockedTask -> Long.toString(blockedTask.getTaskId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
getDependenciesOptionGroup().setValue(state, depIdList.toArray());
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import com.arsdigita.bebop.form.Option;
|
|||
import com.arsdigita.bebop.form.RadioGroup;
|
||||
import com.arsdigita.bebop.parameters.BooleanParameter;
|
||||
|
||||
import com.arsdigita.cms.ui.ContentItemPage;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.kernel.KernelConfig;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
|
@ -50,6 +49,7 @@ import org.libreccm.cdi.utils.CdiUtil;
|
|||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
import org.libreccm.workflow.AssignableTask;
|
||||
import org.libreccm.workflow.TaskDependency;
|
||||
import org.libreccm.workflow.Workflow;
|
||||
import org.librecms.CmsConstants;
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
|
|
@ -192,12 +192,16 @@ public final class TaskFinishForm extends CommentAddForm {
|
|||
+ "tasks");
|
||||
|
||||
// Reenable the previous tasks.
|
||||
for (final Task dependent : task.getDependentTasks()) {
|
||||
for (final TaskDependency blockedTask : task
|
||||
.getBlockedTasks()) {
|
||||
LOGGER.debug("Reenabling task {}",
|
||||
dependent.getLabel().getValue(
|
||||
kernelConfig.getDefaultLocale()));
|
||||
blockedTask
|
||||
.getBlockedTask()
|
||||
.getLabel()
|
||||
.getValue(kernelConfig
|
||||
.getDefaultLocale()));
|
||||
|
||||
controller.enable(dependent);
|
||||
controller.enable(blockedTask.getBlockedTask());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ import org.libreccm.security.Shiro;
|
|||
import org.libreccm.workflow.Task;
|
||||
import org.libreccm.workflow.AssignableTask;
|
||||
import org.libreccm.workflow.AssignableTaskManager;
|
||||
import org.libreccm.workflow.TaskDependency;
|
||||
import org.librecms.contentsection.privileges.AdminPrivileges;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -340,12 +341,15 @@ final class TaskItemPane extends BaseItemPane {
|
|||
final WorkflowAdminPaneController controller = cdiUtil
|
||||
.findBean(WorkflowAdminPaneController.class);
|
||||
|
||||
final List<Task> dependencies = controller.getDependencies(task);
|
||||
final List<TaskDependency> blockedTasks = controller
|
||||
.getBlockedTasks(task);
|
||||
final KernelConfig kernelConfig = KernelConfig.getConfig();
|
||||
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||
|
||||
return dependencies.stream()
|
||||
.map(dependency -> dependency.getLabel().getValue(
|
||||
return blockedTasks
|
||||
.stream()
|
||||
.map(TaskDependency::getBlockedTask)
|
||||
.map(blockedTask -> blockedTask.getLabel().getValue(
|
||||
defaultLocale))
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.libreccm.security.RoleRepository;
|
|||
import org.libreccm.workflow.AssignableTaskManager;
|
||||
import org.libreccm.workflow.CircularTaskDependencyException;
|
||||
import org.libreccm.workflow.Task;
|
||||
import org.libreccm.workflow.TaskDependency;
|
||||
import org.libreccm.workflow.TaskManager;
|
||||
import org.libreccm.workflow.TaskRepository;
|
||||
import org.libreccm.workflow.Workflow;
|
||||
|
|
@ -208,10 +209,12 @@ public class WorkflowAdminPaneController {
|
|||
*/
|
||||
private void processDependencies(final Task task,
|
||||
final String[] selectedDependencies) {
|
||||
final List<Task> dependencies = task.getDependentTasks();
|
||||
final List<TaskDependency> blockedTasks = task.getBlockedTasks();
|
||||
final Map<Long, Task> toAdd = new HashMap<>();
|
||||
// Everything is to be removed unless it is in the array.
|
||||
final Map<Long, Task> toRemove = dependencies.stream()
|
||||
final Map<Long, Task> toRemove = blockedTasks
|
||||
.stream()
|
||||
.map(TaskDependency::getBlockedTask)
|
||||
.collect(Collectors.toMap(Task::getTaskId,
|
||||
dependency -> dependency));
|
||||
|
||||
|
|
@ -241,7 +244,7 @@ public class WorkflowAdminPaneController {
|
|||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<Task> getDependencies(final Task task) {
|
||||
public List<TaskDependency> getBlockedTasks(final Task task) {
|
||||
|
||||
final Task theTask = taskRepo
|
||||
.findById(task.getTaskId())
|
||||
|
|
@ -249,7 +252,7 @@ public class WorkflowAdminPaneController {
|
|||
"No Task with ID %d in the database. Where did that ID come from?",
|
||||
task.getTaskId())));
|
||||
|
||||
return new ArrayList<>(theTask.getDependsOn());
|
||||
return new ArrayList<>(theTask.getBlockedTasks());
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
|
|
@ -266,10 +269,12 @@ public class WorkflowAdminPaneController {
|
|||
|
||||
while (tasksIter.hasNext()) {
|
||||
Task task = tasksIter.next();
|
||||
final Iterator<Task> deps = task.getDependsOn().iterator();
|
||||
final Iterator<TaskDependency> deps = task
|
||||
.getBlockingTasks()
|
||||
.iterator();
|
||||
final StringBuffer buffer = new StringBuffer();
|
||||
while (deps.hasNext()) {
|
||||
Task dep = deps.next();
|
||||
Task dep = deps.next().getBlockingTask();
|
||||
graphSet.addEdge(task, dep, null);
|
||||
buffer
|
||||
.append(dep.getLabel().getValue(defaultLocale))
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ import org.libreccm.security.Shiro;
|
|||
import org.libreccm.security.User;
|
||||
import org.libreccm.tests.categories.IntegrationTest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
|
@ -150,6 +149,7 @@ public class ContentItemPermissionTest {
|
|||
.addClass(org.libreccm.security.Relation.class)
|
||||
//Classes required by org.libreccm.workflow.Task.class
|
||||
.addClass(org.libreccm.workflow.TaskComment.class)
|
||||
.addClass(org.libreccm.workflow.TaskDependency.class)
|
||||
.addClass(org.libreccm.workflow.TaskState.class)
|
||||
.addClass(org.libreccm.workflow.Workflow.class)
|
||||
.addClass(org.libreccm.workflow.AbstractWorkflowException.class)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ import javax.inject.Inject;
|
|||
|
||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
|
@ -387,6 +386,7 @@ public class ContentTypeRepositoryTest {
|
|||
.addClass(org.libreccm.workflow.Task.class)
|
||||
.addClass(org.libreccm.workflow.TaskAssignment.class)
|
||||
.addClass(org.libreccm.workflow.TaskComment.class)
|
||||
.addClass(org.libreccm.workflow.TaskDependency.class)
|
||||
.addClass(org.libreccm.workflow.TaskState.class)
|
||||
.addClass(org.libreccm.workflow.Workflow.class)
|
||||
.addClass(org.libreccm.workflow.WorkflowState.class)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ drop schema if exists CCM_CORE;
|
|||
|
||||
drop sequence if exists HIBERNATE_SEQUENCE;
|
||||
|
||||
|
||||
create schema CCM_CMS;
|
||||
|
||||
create schema CCM_CORE;
|
||||
|
|
@ -1432,11 +1433,11 @@ drop sequence if exists HIBERNATE_SEQUENCE;
|
|||
SETTING_ID bigint not null,
|
||||
CONFIGURATION_CLASS varchar(512) not null,
|
||||
NAME varchar(512) not null,
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
SETTING_VALUE_DOUBLE double,
|
||||
SETTING_VALUE_LONG bigint,
|
||||
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
|
||||
SETTING_VALUE_STRING varchar(1024),
|
||||
SETTING_VALUE_LONG bigint,
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
primary key (SETTING_ID)
|
||||
);
|
||||
|
||||
|
|
@ -1539,8 +1540,10 @@ drop sequence if exists HIBERNATE_SEQUENCE;
|
|||
);
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES (
|
||||
DEPENDS_ON_TASK_ID bigint not null,
|
||||
DEPENDENT_TASK_ID bigint not null
|
||||
TASK_DEPENDENCY_ID bigint not null,
|
||||
BLOCKED_TASK_ID bigint,
|
||||
BLOCKING_TASK_ID bigint,
|
||||
primary key (TASK_DEPENDENCY_ID)
|
||||
);
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS (
|
||||
|
|
@ -2921,13 +2924,13 @@ drop sequence if exists HIBERNATE_SEQUENCE;
|
|||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FK1htp420ki24jaswtcum56iawe
|
||||
foreign key (DEPENDENT_TASK_ID)
|
||||
add constraint FKy88tppv7ihx0lsn6g64f5lfq
|
||||
foreign key (BLOCKED_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FK8rbggnp4yjpab8quvvx800ymy
|
||||
foreign key (DEPENDS_ON_TASK_ID)
|
||||
add constraint FKrj80uilojn73u9a4xgk3vt0cj
|
||||
foreign key (BLOCKING_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ drop schema if exists CCM_CORE cascade;
|
|||
|
||||
drop sequence if exists HIBERNATE_SEQUENCE;
|
||||
|
||||
|
||||
create schema CCM_CMS;
|
||||
|
||||
create schema CCM_CORE;
|
||||
|
|
@ -1432,11 +1433,11 @@ drop sequence if exists HIBERNATE_SEQUENCE;
|
|||
SETTING_ID int8 not null,
|
||||
CONFIGURATION_CLASS varchar(512) not null,
|
||||
NAME varchar(512) not null,
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
SETTING_VALUE_DOUBLE float8,
|
||||
SETTING_VALUE_LONG int8,
|
||||
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
|
||||
SETTING_VALUE_STRING varchar(1024),
|
||||
SETTING_VALUE_LONG int8,
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
primary key (SETTING_ID)
|
||||
);
|
||||
|
||||
|
|
@ -1539,8 +1540,10 @@ drop sequence if exists HIBERNATE_SEQUENCE;
|
|||
);
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES (
|
||||
DEPENDS_ON_TASK_ID int8 not null,
|
||||
DEPENDENT_TASK_ID int8 not null
|
||||
TASK_DEPENDENCY_ID int8 not null,
|
||||
BLOCKED_TASK_ID int8,
|
||||
BLOCKING_TASK_ID int8,
|
||||
primary key (TASK_DEPENDENCY_ID)
|
||||
);
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS (
|
||||
|
|
@ -2921,13 +2924,13 @@ drop sequence if exists HIBERNATE_SEQUENCE;
|
|||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FK1htp420ki24jaswtcum56iawe
|
||||
foreign key (DEPENDENT_TASK_ID)
|
||||
add constraint FKy88tppv7ihx0lsn6g64f5lfq
|
||||
foreign key (BLOCKED_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FK8rbggnp4yjpab8quvvx800ymy
|
||||
foreign key (DEPENDS_ON_TASK_ID)
|
||||
add constraint FKrj80uilojn73u9a4xgk3vt0cj
|
||||
foreign key (BLOCKING_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ import java.util.Objects;
|
|||
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
|
@ -38,7 +36,6 @@ import javax.persistence.GenerationType;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.Table;
|
||||
|
|
|
|||
|
|
@ -20,14 +20,13 @@ package org.libreccm.workflow;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.core.Identifiable;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
@ -36,6 +35,28 @@ import java.util.Objects;
|
|||
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
|
||||
/**
|
||||
* A task is part of a workflow and represents a specific step in the creation
|
||||
* process of an {@link CcmObject}.
|
||||
|
|
@ -84,6 +105,21 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
|||
query = "SELECT t FROM Task t "
|
||||
+ "WHERE t.workflow = :workflow "
|
||||
+ "AND t.taskState = org.libreccm.workflow.TaskState.FINISHED")
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "Task.existsDependency",
|
||||
query = "SELECT (CASE WHEN COUNT(d) > 0 THEN true ELSE false END) "
|
||||
+ "FROM TaskDependency d "
|
||||
+ "WHERE d.blockedTask = :blockedTask "
|
||||
+ "AND d.blockingTask = :blockingTask"
|
||||
)
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "Task.findDependency",
|
||||
query = "SELECT d FROM TaskDependency d "
|
||||
+ "WHERE d.blockedTask = :blockedTask "
|
||||
+ "AND d.blockingTask = :blockingTask"
|
||||
)
|
||||
})
|
||||
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||
resolver = TaskIdResolver.class,
|
||||
|
|
@ -152,26 +188,34 @@ public class Task implements Identifiable, Serializable {
|
|||
@JsonIdentityReference(alwaysAsId = true)
|
||||
private Workflow workflow;
|
||||
|
||||
/**
|
||||
* Tasks which depend on this task.
|
||||
*/
|
||||
@ManyToMany(mappedBy = "dependsOn", fetch = FetchType.LAZY)
|
||||
@JsonIgnore
|
||||
private List<Task> dependentTasks;
|
||||
// /**
|
||||
// * Tasks which depend on this task.
|
||||
// */
|
||||
// @ManyToMany(mappedBy = "dependsOn", fetch = FetchType.LAZY)
|
||||
// @JsonIgnore
|
||||
// private List<Task> dependentTasks;
|
||||
@OneToMany(mappedBy = "blockingTask", fetch = FetchType.LAZY)
|
||||
@XmlElementWrapper(name = "blocked-tasks")
|
||||
@XmlElement(name = "task-dependency")
|
||||
private List<TaskDependency> blockedTasks;
|
||||
|
||||
/**
|
||||
* The dependencies of this task.
|
||||
*/
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "WORKFLOW_TASK_DEPENDENCIES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "DEPENDS_ON_TASK_ID")},
|
||||
inverseJoinColumns = {
|
||||
@JoinColumn(name = "DEPENDENT_TASK_ID")})
|
||||
@JsonIdentityReference(alwaysAsId = true)
|
||||
private List<Task> dependsOn;
|
||||
@OneToMany(mappedBy = "blockedTask", fetch = FetchType.LAZY)
|
||||
@XmlElementWrapper(name = "blocking-tasks")
|
||||
@XmlElement(name = "task-dependency")
|
||||
private List<TaskDependency> blockingTasks;
|
||||
|
||||
// /**
|
||||
// * The dependencies of this task.
|
||||
// */
|
||||
// @ManyToMany(fetch = FetchType.LAZY)
|
||||
// @JoinTable(name = "WORKFLOW_TASK_DEPENDENCIES",
|
||||
// schema = DB_SCHEMA,
|
||||
// joinColumns = {
|
||||
// @JoinColumn(name = "DEPENDS_ON_TASK_ID")},
|
||||
// inverseJoinColumns = {
|
||||
// @JoinColumn(name = "DEPENDENT_TASK_ID")})
|
||||
// @JsonIdentityReference(alwaysAsId = true)
|
||||
// private List<Task> dependsOn;
|
||||
/**
|
||||
* Comments for the task.
|
||||
*/
|
||||
|
|
@ -185,8 +229,10 @@ public class Task implements Identifiable, Serializable {
|
|||
|
||||
label = new LocalizedString();
|
||||
description = new LocalizedString();
|
||||
dependentTasks = new ArrayList<>();
|
||||
dependsOn = new ArrayList<>();
|
||||
// dependentTasks = new ArrayList<>();
|
||||
// dependsOn = new ArrayList<>();
|
||||
blockedTasks = new ArrayList<>();
|
||||
blockingTasks = new ArrayList<>();
|
||||
comments = new ArrayList<>();
|
||||
active = false;
|
||||
}
|
||||
|
|
@ -250,44 +296,83 @@ public class Task implements Identifiable, Serializable {
|
|||
this.workflow = workflow;
|
||||
}
|
||||
|
||||
public List<Task> getDependentTasks() {
|
||||
if (dependentTasks == null) {
|
||||
// public List<Task> getDependentTasks() {
|
||||
// if (dependentTasks == null) {
|
||||
// return null;
|
||||
// } else {
|
||||
// return Collections.unmodifiableList(dependentTasks);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected void setDependentTasks(final List<Task> dependentTasks) {
|
||||
// this.dependentTasks = dependentTasks;
|
||||
// }
|
||||
//
|
||||
// protected void addDependentTask(final Task task) {
|
||||
// dependentTasks.add(task);
|
||||
// }
|
||||
//
|
||||
// protected void removeDependentTask(final Task task) {
|
||||
// dependentTasks.remove(task);
|
||||
// }
|
||||
//
|
||||
// public List<Task> getDependsOn() {
|
||||
// if (dependsOn == null) {
|
||||
// return null;
|
||||
// } else {
|
||||
// return Collections.unmodifiableList(dependsOn);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected void setDependsOn(final List<Task> dependsOn) {
|
||||
// this.dependsOn = dependsOn;
|
||||
// }
|
||||
//
|
||||
// protected void addDependsOn(final Task task) {
|
||||
// dependsOn.add(task);
|
||||
// }
|
||||
//
|
||||
// protected void removeDependsOn(final Task task) {
|
||||
// dependsOn.remove(task);
|
||||
// }
|
||||
public List<TaskDependency> getBlockingTasks() {
|
||||
if (blockingTasks == null) {
|
||||
return null;
|
||||
} else {
|
||||
return Collections.unmodifiableList(dependentTasks);
|
||||
return Collections.unmodifiableList(blockingTasks);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setDependentTasks(final List<Task> dependentTasks) {
|
||||
this.dependentTasks = dependentTasks;
|
||||
protected void setBlockingTasks(final List<TaskDependency> blockingTasks) {
|
||||
this.blockingTasks = blockingTasks;
|
||||
}
|
||||
|
||||
protected void addDependentTask(final Task task) {
|
||||
dependentTasks.add(task);
|
||||
protected void addBlockingTask(final TaskDependency taskDependency) {
|
||||
blockingTasks.add(taskDependency);
|
||||
}
|
||||
|
||||
protected void removeDependentTask(final Task task) {
|
||||
dependentTasks.remove(task);
|
||||
protected void removeBlockingTask(final TaskDependency taskDependency) {
|
||||
blockingTasks.remove(taskDependency);
|
||||
}
|
||||
|
||||
public List<Task> getDependsOn() {
|
||||
if (dependsOn == null) {
|
||||
public List<TaskDependency> getBlockedTasks() {
|
||||
if (blockedTasks == null) {
|
||||
return null;
|
||||
} else {
|
||||
return Collections.unmodifiableList(dependsOn);
|
||||
return Collections.unmodifiableList(blockedTasks);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setDependsOn(final List<Task> dependsOn) {
|
||||
this.dependsOn = dependsOn;
|
||||
protected void setBlockedTasks(final List<TaskDependency> blockedTasks) {
|
||||
this.blockedTasks = blockedTasks;
|
||||
}
|
||||
|
||||
protected void addDependsOn(final Task task) {
|
||||
dependsOn.add(task);
|
||||
protected void addBlockedTask(final TaskDependency taskDependency) {
|
||||
blockedTasks.add(taskDependency);
|
||||
}
|
||||
|
||||
protected void removeDependsOn(final Task task) {
|
||||
dependsOn.remove(task);
|
||||
protected void removeBlockedTask(final TaskDependency taskDependency) {
|
||||
blockedTasks.remove(taskDependency);
|
||||
}
|
||||
|
||||
public List<TaskComment> getComments() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||
import org.libreccm.core.CoreConstants;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "WORKFLOW_TASK_DEPENDENCIES", schema = CoreConstants.DB_SCHEMA)
|
||||
public class TaskDependency implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4383255770131633943L;
|
||||
|
||||
@Id
|
||||
@Column(name = "TASK_DEPENDENCY_ID")
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long taskDependencyId;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "BLOCKED_TASK_ID")
|
||||
@JsonIdentityReference(alwaysAsId = true)
|
||||
private Task blockedTask;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "BLOCKING_TASK_ID")
|
||||
@JsonIdentityReference(alwaysAsId = true)
|
||||
private Task blockingTask;
|
||||
|
||||
public long getTaskDependencyId() {
|
||||
return taskDependencyId;
|
||||
}
|
||||
|
||||
public void setTaskDependencyId(final long taskDependencyId) {
|
||||
this.taskDependencyId = taskDependencyId;
|
||||
}
|
||||
|
||||
public Task getBlockedTask() {
|
||||
return blockedTask;
|
||||
}
|
||||
|
||||
protected void setBlockedTask(final Task blockedTask) {
|
||||
this.blockedTask = blockedTask;
|
||||
}
|
||||
|
||||
public Task getBlockingTask() {
|
||||
return blockingTask;
|
||||
}
|
||||
|
||||
protected void setBlockingTask(final Task blockingTask) {
|
||||
this.blockingTask = blockingTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash
|
||||
= 89 * hash + (int) (taskDependencyId ^ (taskDependencyId >>> 32));
|
||||
hash = 89 * hash + Objects.hashCode(blockedTask);
|
||||
hash = 89 * hash + Objects.hashCode(blockingTask);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof TaskDependency)) {
|
||||
return false;
|
||||
}
|
||||
final TaskDependency other = (TaskDependency) obj;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (taskDependencyId != other.getTaskDependencyId()) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(blockedTask, other.getBlockedTask())) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(blockingTask, other.getBlockingTask());
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object obj) {
|
||||
return obj instanceof TaskDependency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return toString("");
|
||||
}
|
||||
|
||||
public String toString(final String data) {
|
||||
|
||||
return String.format("%s{ "
|
||||
+ "taskDependencyId = %d, "
|
||||
+ "blockedTask = %s, "
|
||||
+ "blockingTask = %s%s"
|
||||
+ " }",
|
||||
super.toString(),
|
||||
taskDependencyId,
|
||||
Objects.toString(blockedTask),
|
||||
Objects.toString(blockingTask),
|
||||
data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -26,14 +26,19 @@ import org.libreccm.security.RequiresPrivilege;
|
|||
import org.libreccm.security.Shiro;
|
||||
import org.libreccm.security.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
/**
|
||||
* Manager for {@link Task}s. The logic of some of this methods has been taken
|
||||
* from the old implementation without changes.
|
||||
|
|
@ -94,8 +99,8 @@ public class TaskManager {
|
|||
/**
|
||||
* Adds a dependent {@link Task} to another {@code Task}.
|
||||
*
|
||||
* @param parent The task to which the dependent task is added.
|
||||
* @param task The dependent task.
|
||||
* @param blockingTask The task which blocks the blocked task.
|
||||
* @param blockedTask The task blocked by the blocking task.
|
||||
*
|
||||
* @throws CircularTaskDependencyException If a circular dependency is
|
||||
* detected.
|
||||
|
|
@ -103,33 +108,81 @@ public class TaskManager {
|
|||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void addDependentTask(final Task parent, final Task task)
|
||||
public void addDependentTask(final Task blockingTask,
|
||||
final Task blockedTask)
|
||||
throws CircularTaskDependencyException {
|
||||
|
||||
checkForCircularDependencies(parent, task);
|
||||
Objects.requireNonNull(blockedTask);
|
||||
Objects.requireNonNull(blockingTask);
|
||||
|
||||
parent.addDependentTask(task);
|
||||
task.addDependsOn(parent);
|
||||
LOGGER.debug("Adding a dependency between task {} (blocking task) "
|
||||
+ "and task {} (blocked task)...",
|
||||
Objects.toString(blockingTask),
|
||||
Objects.toString(blockedTask));
|
||||
|
||||
taskRepo.save(task);
|
||||
taskRepo.save(parent);
|
||||
LOGGER.debug("Checking for circular dependencies...");
|
||||
checkForCircularDependencies(blockingTask, blockedTask);
|
||||
|
||||
LOGGER.debug("Checking if dependency already exists...");
|
||||
final TypedQuery<Boolean> query = entityManager
|
||||
.createNamedQuery("Task.existsDependency", Boolean.class);
|
||||
query.setParameter("blockingTask", blockingTask);
|
||||
query.setParameter("blockedTask", blockedTask);
|
||||
final Boolean dependencyExists = query.getSingleResult();
|
||||
|
||||
if (dependencyExists) {
|
||||
LOGGER.info("Dependency between task {} (blocking task) "
|
||||
+ "and task {} (blocked task) already exists.",
|
||||
Objects.toString(blockingTask),
|
||||
Objects.toString(blockedTask));
|
||||
return;
|
||||
}
|
||||
|
||||
final TaskDependency dependency = new TaskDependency();
|
||||
dependency.setBlockedTask(blockedTask);
|
||||
dependency.setBlockingTask(blockingTask);
|
||||
|
||||
blockingTask.addBlockedTask(dependency);
|
||||
blockedTask.addBlockingTask(dependency);
|
||||
|
||||
// blockingTask.addDependentTask(blockedTask);
|
||||
// blockedTask.addDependsOn(blockingTask);
|
||||
|
||||
entityManager.persist(dependency);
|
||||
taskRepo.save(blockedTask);
|
||||
taskRepo.save(blockingTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a dependent task.
|
||||
*
|
||||
* @param parent The task from which the dependent task is removed.
|
||||
* @param task The dependent task to remove.
|
||||
* @param blockingTask The task which blocks the other task.
|
||||
* @param blockedTask The task which is blocked by the other task.
|
||||
*/
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void removeDependentTask(final Task parent, final Task task) {
|
||||
parent.removeDependentTask(task);
|
||||
task.removeDependsOn(parent);
|
||||
public void removeDependentTask(final Task blockingTask,
|
||||
final Task blockedTask) {
|
||||
|
||||
taskRepo.save(task);
|
||||
taskRepo.save(parent);
|
||||
final TypedQuery<TaskDependency> query = entityManager
|
||||
.createNamedQuery("Task.findDependency", TaskDependency.class);
|
||||
query.setParameter("blockedTask", blockedTask);
|
||||
query.setParameter("blockingTask", blockingTask);
|
||||
final List<TaskDependency> dependencies = query.getResultList();
|
||||
|
||||
for(final TaskDependency dependency : dependencies) {
|
||||
|
||||
entityManager.remove(dependency);
|
||||
blockingTask.removeBlockedTask(dependency);
|
||||
blockedTask.removeBlockingTask(dependency);
|
||||
}
|
||||
|
||||
// blockingTask.removeDependentTask(blockedTask);
|
||||
// blockedTask.removeDependsOn(blockingTask);
|
||||
|
||||
taskRepo.save(blockedTask);
|
||||
taskRepo.save(blockingTask);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -149,19 +202,27 @@ public class TaskManager {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean dependsOn(final Task task, final Task dependsOn) {
|
||||
for (final Task current : task.getDependsOn()) {
|
||||
if (current.equals(dependsOn)) {
|
||||
return true;
|
||||
}
|
||||
private boolean dependsOn(final Task blockingTask, final Task blockedTask) {
|
||||
|
||||
if (current.getDependsOn() != null
|
||||
&& !current.getDependsOn().isEmpty()) {
|
||||
return dependsOn(current, dependsOn);
|
||||
}
|
||||
}
|
||||
final TypedQuery<Boolean> query = entityManager
|
||||
.createNamedQuery("Task.existsDependency", Boolean.class);
|
||||
query.setParameter("blockingTask", blockingTask);
|
||||
query.setParameter("blockedTask", blockedTask);
|
||||
|
||||
return false;
|
||||
return query.getSingleResult();
|
||||
|
||||
// for (final Task current : blockingTask.getDependsOn()) {
|
||||
// if (current.equals(blockedTask)) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// if (current.getDependsOn() != null
|
||||
// && !current.getDependsOn().isEmpty()) {
|
||||
// return dependsOn(current, blockedTask);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -252,9 +313,8 @@ public class TaskManager {
|
|||
* @param task The task to finish.
|
||||
*/
|
||||
public void finish(final Task task) {
|
||||
if (task == null) {
|
||||
throw new IllegalArgumentException("Can't finished null...");
|
||||
}
|
||||
|
||||
Objects.requireNonNull(task, "Can't finished null...");
|
||||
|
||||
if (task.getTaskState() != TaskState.ENABLED) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
|
|
@ -265,7 +325,11 @@ public class TaskManager {
|
|||
task.setTaskState(TaskState.FINISHED);
|
||||
taskRepo.save(task);
|
||||
|
||||
task.getDependentTasks().forEach(dependent -> updateState(dependent));
|
||||
task
|
||||
.getBlockedTasks()
|
||||
.stream()
|
||||
.map(TaskDependency::getBlockedTask)
|
||||
.forEach(this::updateState);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -276,6 +340,9 @@ public class TaskManager {
|
|||
* @param task
|
||||
*/
|
||||
protected void updateState(final Task task) {
|
||||
|
||||
Objects.requireNonNull(task);
|
||||
|
||||
LOGGER.debug("Updating state for task {}...",
|
||||
Objects.toString(task));
|
||||
|
||||
|
|
@ -285,11 +352,13 @@ public class TaskManager {
|
|||
return;
|
||||
}
|
||||
|
||||
for (final Task dependsOnTask : task.getDependsOn()) {
|
||||
for (final TaskDependency blockingTaskDependency : task.getBlockingTasks()) {
|
||||
|
||||
final Task blockingTask = blockingTaskDependency.getBlockingTask();
|
||||
LOGGER.debug("Checking dependency {}...",
|
||||
Objects.toString(dependsOnTask));
|
||||
if (dependsOnTask.getTaskState() != TaskState.FINISHED
|
||||
&& dependsOnTask.isActive()) {
|
||||
Objects.toString(blockingTask));
|
||||
if (blockingTask.getTaskState() != TaskState.FINISHED
|
||||
&& blockingTask.isActive()) {
|
||||
|
||||
LOGGER.debug("Dependency is not yet satisfied.");
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import org.apache.shiro.subject.Subject;
|
|||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.core.CoreConstants;
|
||||
import org.libreccm.core.UnexpectedErrorException;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
import org.libreccm.security.AuthorizationRequired;
|
||||
import org.libreccm.security.RequiresPrivilege;
|
||||
|
|
@ -54,7 +55,6 @@ 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
|
||||
* ported from the workflow implementation. The methods have only been edited to
|
||||
|
|
@ -267,17 +267,48 @@ public class WorkflowManager {
|
|||
private void fixTaskDependencies(final Task template,
|
||||
final Task task,
|
||||
final Map<Long, Task> tasks) {
|
||||
if (template.getDependentTasks() != null
|
||||
&& !template.getDependentTasks().isEmpty()) {
|
||||
template.getDependentTasks().forEach(dependent
|
||||
-> task.addDependentTask(tasks.get(dependent.getTaskId())));
|
||||
|
||||
if (template.getBlockedTasks() != null
|
||||
&& !template.getBlockedTasks().isEmpty()) {
|
||||
|
||||
for (final TaskDependency blocked : template.getBlockedTasks()) {
|
||||
|
||||
final Task blockingTask = tasks
|
||||
.get(blocked.getBlockingTask().getTaskId());
|
||||
final Task blockedTask = tasks
|
||||
.get(blocked.getBlockedTask().getTaskId());
|
||||
try {
|
||||
taskManager.addDependentTask(blockingTask, blockedTask);
|
||||
} catch (CircularTaskDependencyException ex) {
|
||||
throw new UnexpectedErrorException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (template.getDependsOn() != null
|
||||
&& !template.getDependsOn().isEmpty()) {
|
||||
template.getDependsOn().forEach(dependsOn
|
||||
-> task.addDependsOn(tasks.get(dependsOn.getTaskId())));
|
||||
// if (template.getDependentTasks() != null
|
||||
// && !template.getDependentTasks().isEmpty()) {
|
||||
// template.getDependentTasks().forEach(dependent
|
||||
// -> task.addDependentTask(tasks.get(dependent.getTaskId())));
|
||||
// }
|
||||
for (final TaskDependency blocking : template.getBlockingTasks()) {
|
||||
|
||||
final Task blockingTask = tasks
|
||||
.get(blocking.getBlockingTask().getTaskId());
|
||||
final Task blockedTask = tasks
|
||||
.get(blocking.getBlockedTask().getTaskId());
|
||||
try {
|
||||
taskManager.addDependentTask(blockingTask, blockedTask);
|
||||
} catch(CircularTaskDependencyException ex) {
|
||||
throw new UnexpectedErrorException(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if (template.getDependsOn() != null
|
||||
// && !template.getDependsOn().isEmpty()) {
|
||||
// template.getDependsOn().forEach(dependsOn
|
||||
// -> task.addDependsOn(tasks.get(dependsOn.getTaskId())));
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
drop constraint if exists FK1htp420ki24jaswtcum56iawe;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
drop constraint if exists FK8rbggnp4yjpab8quvvx800ymy;
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES_ (
|
||||
TASK_DEPENDENCY_ID bigint,
|
||||
BLOCKED_TASK_ID bigint,
|
||||
BLOCKING_TASK_ID bigint
|
||||
);
|
||||
|
||||
insert into CCM_CORE.WORKFLOW_TASK_DEPENDENCIES_ (BLOCKED_TASK_ID, BLOCKING_TASK_ID)
|
||||
(select DEPENDENT_TASK_ID, DEPENDS_ON_TASK_ID
|
||||
from CCM_CORE.WORKFLOW_TASK_DEPENDENCIES);
|
||||
|
||||
update CCM_CORE.WORKFLOW_TASK_DEPENDENCIES_
|
||||
set TASK_DEPENDENCY_ID = nextval('hibernate_sequence');
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES_
|
||||
alter column TASK_DEPENDENCY_ID set not null;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES_
|
||||
add primary key(TASK_DEPENDENCY_ID);
|
||||
|
||||
drop table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES_
|
||||
rename to CCM_CORE.WORKFLOW_TASK_DEPENDENCIES;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FKci4hwj0evq82m4nyvux1bwc73
|
||||
foreign key (BLOCKED_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FKkmrbcm2fbbrb43l5j7supp7eg
|
||||
foreign key (BLOCKING_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
drop constraint if exists FK1htp420ki24jaswtcum56iawe;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
drop constraint if exists FK8rbggnp4yjpab8quvvx800ymy;
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES_ (
|
||||
TASK_DEPENDENCY_ID bigint,
|
||||
BLOCKED_TASK_ID bigint,
|
||||
BLOCKING_TASK_ID bigint
|
||||
);
|
||||
|
||||
insert into CCM_CORE.WORKFLOW_TASK_DEPENDENCIES_ (BLOCKED_TASK_ID, BLOCKING_TASK_ID)
|
||||
(select DEPENDENT_TASK_ID, DEPENDS_ON_TASK_ID
|
||||
from CCM_CORE.WORKFLOW_TASK_DEPENDENCIES);
|
||||
|
||||
update CCM_CORE.WORKFLOW_TASK_DEPENDENCIES_
|
||||
set TASK_DEPENDENCY_ID = nextval('hibernate_sequence');
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES_
|
||||
alter column TASK_DEPENDENCY_ID set not null;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES_
|
||||
add primary key(TASK_DEPENDENCY_ID);
|
||||
|
||||
drop table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES_
|
||||
rename to WORKFLOW_TASK_DEPENDENCIES;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FKci4hwj0evq82m4nyvux1bwc73
|
||||
foreign key (BLOCKED_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FKkmrbcm2fbbrb43l5j7supp7eg
|
||||
foreign key (BLOCKING_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
|
@ -2,6 +2,7 @@ drop schema if exists CCM_CORE;
|
|||
|
||||
drop sequence if exists HIBERNATE_SEQUENCE;
|
||||
|
||||
|
||||
create schema CCM_CORE;
|
||||
|
||||
create table CCM_CORE.APPLICATIONS (
|
||||
|
|
@ -530,10 +531,10 @@ drop sequence if exists HIBERNATE_SEQUENCE;
|
|||
CONFIGURATION_CLASS varchar(512) not null,
|
||||
NAME varchar(512) not null,
|
||||
SETTING_VALUE_STRING varchar(1024),
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
SETTING_VALUE_DOUBLE double,
|
||||
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
|
||||
SETTING_VALUE_LONG bigint,
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
|
||||
primary key (SETTING_ID)
|
||||
);
|
||||
|
||||
|
|
@ -636,8 +637,10 @@ drop sequence if exists HIBERNATE_SEQUENCE;
|
|||
);
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES (
|
||||
DEPENDS_ON_TASK_ID bigint not null,
|
||||
DEPENDENT_TASK_ID bigint not null
|
||||
TASK_DEPENDENCY_ID bigint not null,
|
||||
BLOCKED_TASK_ID bigint,
|
||||
BLOCKING_TASK_ID bigint,
|
||||
primary key (TASK_DEPENDENCY_ID)
|
||||
);
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS (
|
||||
|
|
@ -1203,13 +1206,13 @@ drop sequence if exists HIBERNATE_SEQUENCE;
|
|||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FK1htp420ki24jaswtcum56iawe
|
||||
foreign key (DEPENDENT_TASK_ID)
|
||||
add constraint FKy88tppv7ihx0lsn6g64f5lfq
|
||||
foreign key (BLOCKED_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FK8rbggnp4yjpab8quvvx800ymy
|
||||
foreign key (DEPENDS_ON_TASK_ID)
|
||||
add constraint FKrj80uilojn73u9a4xgk3vt0cj
|
||||
foreign key (BLOCKING_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ drop schema if exists CCM_CORE cascade;
|
|||
|
||||
drop sequence if exists HIBERNATE_SEQUENCE;
|
||||
|
||||
|
||||
|
||||
create schema CCM_CORE;
|
||||
|
||||
create table CCM_CORE.APPLICATIONS (
|
||||
|
|
@ -530,10 +532,10 @@ drop sequence if exists HIBERNATE_SEQUENCE;
|
|||
CONFIGURATION_CLASS varchar(512) not null,
|
||||
NAME varchar(512) not null,
|
||||
SETTING_VALUE_STRING varchar(1024),
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
SETTING_VALUE_DOUBLE float8,
|
||||
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
|
||||
SETTING_VALUE_LONG int8,
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
|
||||
primary key (SETTING_ID)
|
||||
);
|
||||
|
||||
|
|
@ -636,8 +638,10 @@ drop sequence if exists HIBERNATE_SEQUENCE;
|
|||
);
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES (
|
||||
DEPENDS_ON_TASK_ID int8 not null,
|
||||
DEPENDENT_TASK_ID int8 not null
|
||||
TASK_DEPENDENCY_ID int8 not null,
|
||||
BLOCKED_TASK_ID int8,
|
||||
BLOCKING_TASK_ID int8,
|
||||
primary key (TASK_DEPENDENCY_ID)
|
||||
);
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS (
|
||||
|
|
@ -1203,13 +1207,13 @@ drop sequence if exists HIBERNATE_SEQUENCE;
|
|||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FK1htp420ki24jaswtcum56iawe
|
||||
foreign key (DEPENDENT_TASK_ID)
|
||||
add constraint FKy88tppv7ihx0lsn6g64f5lfq
|
||||
foreign key (BLOCKED_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FK8rbggnp4yjpab8quvvx800ymy
|
||||
foreign key (DEPENDS_ON_TASK_ID)
|
||||
add constraint FKrj80uilojn73u9a4xgk3vt0cj
|
||||
foreign key (BLOCKING_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS
|
||||
|
|
|
|||
|
|
@ -312,9 +312,9 @@
|
|||
<groupId>com.github.spotbugs</groupId>
|
||||
<artifactId>spotbugs-maven-plugin</artifactId>
|
||||
<version>3.1.0-RC8</version>
|
||||
<configuration>
|
||||
<!--<configuration>
|
||||
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
|
||||
</configuration>
|
||||
</configuration>-->
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ DROP SCHEMA IF EXISTS ccm_core;
|
|||
|
||||
DROP SEQUENCE IF EXISTS hibernate_sequence;
|
||||
|
||||
CREATE SCHEMA ccm_core;
|
||||
CREATE SCHEMA ccm_shortcuts;
|
||||
|
||||
create schema CCM_CORE;
|
||||
|
||||
create schema CCM_SHORTCUTS;
|
||||
|
||||
create table CCM_CORE.APPLICATIONS (
|
||||
APPLICATION_TYPE varchar(1024) not null,
|
||||
|
|
@ -530,10 +532,10 @@ CREATE SCHEMA ccm_shortcuts;
|
|||
SETTING_ID bigint not null,
|
||||
CONFIGURATION_CLASS varchar(512) not null,
|
||||
NAME varchar(512) not null,
|
||||
SETTING_VALUE_DOUBLE double,
|
||||
SETTING_VALUE_STRING varchar(1024),
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
SETTING_VALUE_DOUBLE double,
|
||||
SETTING_VALUE_LONG bigint,
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
|
||||
primary key (SETTING_ID)
|
||||
);
|
||||
|
|
@ -555,6 +557,20 @@ CREATE SCHEMA ccm_shortcuts;
|
|||
value varchar(255)
|
||||
);
|
||||
|
||||
create table CCM_CORE.SITE_AWARE_APPLICATIONS (
|
||||
OBJECT_ID bigint not null,
|
||||
SITE_ID bigint,
|
||||
primary key (OBJECT_ID)
|
||||
);
|
||||
|
||||
create table CCM_CORE.SITES (
|
||||
DEFAULT_SITE boolean,
|
||||
DEFAULT_THEME varchar(255),
|
||||
DOMAIN_OF_SITE varchar(255),
|
||||
OBJECT_ID bigint not null,
|
||||
primary key (OBJECT_ID)
|
||||
);
|
||||
|
||||
create table CCM_CORE.THREADS (
|
||||
OBJECT_ID bigint not null,
|
||||
ROOT_ID bigint,
|
||||
|
|
@ -623,8 +639,10 @@ CREATE SCHEMA ccm_shortcuts;
|
|||
);
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES (
|
||||
DEPENDS_ON_TASK_ID bigint not null,
|
||||
DEPENDENT_TASK_ID bigint not null
|
||||
TASK_DEPENDENCY_ID bigint not null,
|
||||
BLOCKED_TASK_ID bigint,
|
||||
BLOCKING_TASK_ID bigint,
|
||||
primary key (TASK_DEPENDENCY_ID)
|
||||
);
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS (
|
||||
|
|
@ -680,6 +698,9 @@ CREATE SCHEMA ccm_shortcuts;
|
|||
alter table CCM_CORE.SETTINGS
|
||||
add constraint UK5whinfxdaepqs09e5ia9y71uk unique (CONFIGURATION_CLASS, NAME);
|
||||
|
||||
alter table CCM_CORE.SITES
|
||||
add constraint UK_kou1h4y4st2m173he44yy8grx unique (DOMAIN_OF_SITE);
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_COMMENTS
|
||||
add constraint UK_4nnedf08odyjxalfkg16fmjoi unique (UUID);
|
||||
|
||||
|
|
@ -1111,6 +1132,21 @@ CREATE SCHEMA ccm_shortcuts;
|
|||
foreign key (LIST_ID)
|
||||
references CCM_CORE.SETTINGS;
|
||||
|
||||
alter table CCM_CORE.SITE_AWARE_APPLICATIONS
|
||||
add constraint FKopo91c29jaunpcusjwlphhxkd
|
||||
foreign key (SITE_ID)
|
||||
references CCM_CORE.SITES;
|
||||
|
||||
alter table CCM_CORE.SITE_AWARE_APPLICATIONS
|
||||
add constraint FKslbu2qagg23dmdu01lun7oh7x
|
||||
foreign key (OBJECT_ID)
|
||||
references CCM_CORE.APPLICATIONS;
|
||||
|
||||
alter table CCM_CORE.SITES
|
||||
add constraint FKrca95c6p023men53b8ayu26kp
|
||||
foreign key (OBJECT_ID)
|
||||
references CCM_CORE.CCM_OBJECTS;
|
||||
|
||||
alter table CCM_CORE.THREADS
|
||||
add constraint FKsx08mpwvwnw97uwdgjs76q39g
|
||||
foreign key (ROOT_ID)
|
||||
|
|
@ -1177,13 +1213,13 @@ CREATE SCHEMA ccm_shortcuts;
|
|||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FK1htp420ki24jaswtcum56iawe
|
||||
foreign key (DEPENDENT_TASK_ID)
|
||||
add constraint FKy88tppv7ihx0lsn6g64f5lfq
|
||||
foreign key (BLOCKED_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FK8rbggnp4yjpab8quvvx800ymy
|
||||
foreign key (DEPENDS_ON_TASK_ID)
|
||||
add constraint FKrj80uilojn73u9a4xgk3vt0cj
|
||||
foreign key (BLOCKING_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ DROP SCHEMA IF EXISTS ccm_core CASCADE;
|
|||
|
||||
DROP SEQUENCE IF EXISTS hibernate_sequence;
|
||||
|
||||
CREATE SCHEMA ccm_core;
|
||||
CREATE SCHEMA ccm_shortcuts;
|
||||
|
||||
create table CCM_CORE.APPLICATIONS (
|
||||
create schema CCM_CORE;
|
||||
|
||||
create schema CCM_SHORTCUTS;
|
||||
|
||||
create table CCM_CORE.APPLICATIONS (
|
||||
APPLICATION_TYPE varchar(1024) not null,
|
||||
PRIMARY_URL varchar(1024) not null,
|
||||
OBJECT_ID int8 not null,
|
||||
|
|
@ -530,10 +532,10 @@ create table CCM_CORE.APPLICATIONS (
|
|||
SETTING_ID int8 not null,
|
||||
CONFIGURATION_CLASS varchar(512) not null,
|
||||
NAME varchar(512) not null,
|
||||
SETTING_VALUE_DOUBLE float8,
|
||||
SETTING_VALUE_STRING varchar(1024),
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
SETTING_VALUE_DOUBLE float8,
|
||||
SETTING_VALUE_LONG int8,
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
|
||||
primary key (SETTING_ID)
|
||||
);
|
||||
|
|
@ -555,6 +557,20 @@ create table CCM_CORE.APPLICATIONS (
|
|||
value varchar(255)
|
||||
);
|
||||
|
||||
create table CCM_CORE.SITE_AWARE_APPLICATIONS (
|
||||
OBJECT_ID int8 not null,
|
||||
SITE_ID int8,
|
||||
primary key (OBJECT_ID)
|
||||
);
|
||||
|
||||
create table CCM_CORE.SITES (
|
||||
DEFAULT_SITE boolean,
|
||||
DEFAULT_THEME varchar(255),
|
||||
DOMAIN_OF_SITE varchar(255),
|
||||
OBJECT_ID int8 not null,
|
||||
primary key (OBJECT_ID)
|
||||
);
|
||||
|
||||
create table CCM_CORE.THREADS (
|
||||
OBJECT_ID int8 not null,
|
||||
ROOT_ID int8,
|
||||
|
|
@ -623,8 +639,10 @@ create table CCM_CORE.APPLICATIONS (
|
|||
);
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES (
|
||||
DEPENDS_ON_TASK_ID int8 not null,
|
||||
DEPENDENT_TASK_ID int8 not null
|
||||
TASK_DEPENDENCY_ID int8 not null,
|
||||
BLOCKED_TASK_ID int8,
|
||||
BLOCKING_TASK_ID int8,
|
||||
primary key (TASK_DEPENDENCY_ID)
|
||||
);
|
||||
|
||||
create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS (
|
||||
|
|
@ -680,6 +698,9 @@ create table CCM_CORE.APPLICATIONS (
|
|||
alter table CCM_CORE.SETTINGS
|
||||
add constraint UK5whinfxdaepqs09e5ia9y71uk unique (CONFIGURATION_CLASS, NAME);
|
||||
|
||||
alter table CCM_CORE.SITES
|
||||
add constraint UK_kou1h4y4st2m173he44yy8grx unique (DOMAIN_OF_SITE);
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_COMMENTS
|
||||
add constraint UK_4nnedf08odyjxalfkg16fmjoi unique (UUID);
|
||||
|
||||
|
|
@ -1111,6 +1132,21 @@ create table CCM_CORE.APPLICATIONS (
|
|||
foreign key (LIST_ID)
|
||||
references CCM_CORE.SETTINGS;
|
||||
|
||||
alter table CCM_CORE.SITE_AWARE_APPLICATIONS
|
||||
add constraint FKopo91c29jaunpcusjwlphhxkd
|
||||
foreign key (SITE_ID)
|
||||
references CCM_CORE.SITES;
|
||||
|
||||
alter table CCM_CORE.SITE_AWARE_APPLICATIONS
|
||||
add constraint FKslbu2qagg23dmdu01lun7oh7x
|
||||
foreign key (OBJECT_ID)
|
||||
references CCM_CORE.APPLICATIONS;
|
||||
|
||||
alter table CCM_CORE.SITES
|
||||
add constraint FKrca95c6p023men53b8ayu26kp
|
||||
foreign key (OBJECT_ID)
|
||||
references CCM_CORE.CCM_OBJECTS;
|
||||
|
||||
alter table CCM_CORE.THREADS
|
||||
add constraint FKsx08mpwvwnw97uwdgjs76q39g
|
||||
foreign key (ROOT_ID)
|
||||
|
|
@ -1177,13 +1213,13 @@ create table CCM_CORE.APPLICATIONS (
|
|||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FK1htp420ki24jaswtcum56iawe
|
||||
foreign key (DEPENDENT_TASK_ID)
|
||||
add constraint FKy88tppv7ihx0lsn6g64f5lfq
|
||||
foreign key (BLOCKED_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES
|
||||
add constraint FK8rbggnp4yjpab8quvvx800ymy
|
||||
foreign key (DEPENDS_ON_TASK_ID)
|
||||
add constraint FKrj80uilojn73u9a4xgk3vt0cj
|
||||
foreign key (BLOCKING_TASK_ID)
|
||||
references CCM_CORE.WORKFLOW_TASKS;
|
||||
|
||||
alter table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS
|
||||
|
|
|
|||
Loading…
Reference in New Issue