CCM NG: Added references from Workflow to the WorkflowTemplate used to create the workflow.

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4293 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2016-09-12 15:44:45 +00:00
parent fd6de757f0
commit cb0a19410e
6 changed files with 54 additions and 2 deletions

View File

@ -39,6 +39,7 @@ import javax.persistence.Inheritance;
import javax.persistence.InheritanceType; import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinTable; import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
@ -58,6 +59,10 @@ public class Workflow implements Serializable {
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
private long workflowId; private long workflowId;
@ManyToOne
@JoinColumn(name = "TEMPLATE_ID")
private WorkflowTemplate template;
@Embedded @Embedded
@AssociationOverride( @AssociationOverride(
name = "values", name = "values",
@ -96,6 +101,14 @@ public class Workflow implements Serializable {
this.workflowId = workflowId; this.workflowId = workflowId;
} }
public WorkflowTemplate getTemplate() {
return template;
}
protected void setTemplate(final WorkflowTemplate template) {
this.template = template;
}
public LocalizedString getName() { public LocalizedString getName() {
return name; return name;
} }

View File

@ -0,0 +1,10 @@
-- Adds a foreign key column which references the workflow template used
-- to create a workflow
alter table CCM_CORE.WORKFLOWS
add column TEMPLATE_ID int8;
alter table CCM_CORE.WORKFLOWS
add constraint FKol71r1t83h0qe65gglq43far2
foreign key (template_id)
references CCM_CORE.WORKFLOW_TEMPLATES;

View File

@ -0,0 +1,10 @@
-- Adds a foreign key column which references the workflow template used
-- to create a workflow
alter table CCM_CORE.WORKFLOWS
add column TEMPLATE_ID bigint;
alter table CCM_CORE.WORKFLOWS
add constraint FKol71r1t83h0qe65gglq43far2
foreign key (template_id)
references CCM_CORE.WORKFLOW_TEMPLATES;

View File

@ -29,6 +29,7 @@ import org.libreccm.testutils.EqualsVerifier;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Locale;
/** /**
* *
@ -89,12 +90,19 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
final User user2 = new TestUser(); final User user2 = new TestUser();
user2.setName("user2"); user2.setName("user2");
final WorkflowTemplate template1 = new WorkflowTemplate();
template1.getName().addValue(Locale.ENGLISH, "Template 1");
final WorkflowTemplate template2 = new WorkflowTemplate();
template1.getName().addValue(Locale.ENGLISH, "Template 2");
verifier verifier
.withPrefabValues(UserTask.class, userTask1, userTask2) .withPrefabValues(UserTask.class, userTask1, userTask2)
.withPrefabValues(Role.class, role1, role2) .withPrefabValues(Role.class, role1, role2)
.withPrefabValues(Task.class, task1, task2) .withPrefabValues(Task.class, task1, task2)
.withPrefabValues(Group.class, group1, group2) .withPrefabValues(Group.class, group1, group2)
.withPrefabValues(User.class, user1, user2); .withPrefabValues(User.class, user1, user2)
.withPrefabValues(WorkflowTemplate.class, template1, template2);
} }
/** /**

View File

@ -580,6 +580,7 @@ CREATE SCHEMA ccm_core;
create table ccm_core.workflows ( create table ccm_core.workflows (
workflow_id bigint not null, workflow_id bigint not null,
template_id bigint,
primary key (workflow_id) primary key (workflow_id)
); );
@ -1080,4 +1081,9 @@ CREATE SCHEMA ccm_core;
foreign key (workflow_id) foreign key (workflow_id)
references ccm_core.workflows; references ccm_core.workflows;
alter table CCM_CORE.WORKFLOWS
add constraint FKol71r1t83h0qe65gglq43far2
foreign key (template_id)
references CCM_CORE.WORKFLOW_TEMPLATES;
create sequence hibernate_sequence start with 1 increment by 1; create sequence hibernate_sequence start with 1 increment by 1;

View File

@ -1124,3 +1124,8 @@ create sequence hibernate_sequence start 1 increment 1;
add constraint FKefpdf9ojplu7loo31hfm0wl2h add constraint FKefpdf9ojplu7loo31hfm0wl2h
foreign key (TASK_ID) foreign key (TASK_ID)
references CCM_CORE.WORKFLOW_TASKS; references CCM_CORE.WORKFLOW_TASKS;
alter table CCM_CORE.WORKFLOWS
add constraint FKol71r1t83h0qe65gglq43far2
foreign key (template_id)
references CCM_CORE.WORKFLOW_TEMPLATES;