[NG][UPDATE]
- minor modifications in core classes for import - adds new batch of files with exported objects git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5089 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
dfd2eaa5d1
commit
cbcc621eba
|
|
@ -30,6 +30,7 @@ import org.libreccm.portation.Portable;
|
|||
import org.libreccm.security.RecursivePermissions;
|
||||
import org.libreccm.web.CcmApplication;
|
||||
|
||||
import javax.persistence.FetchType;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
|
|
@ -210,7 +211,7 @@ public class Domain extends CcmObject implements Serializable, Portable {
|
|||
/**
|
||||
* The owners of the domain.
|
||||
*/
|
||||
@OneToMany(mappedBy = "domain")
|
||||
@OneToMany(mappedBy = "domain", fetch = FetchType.LAZY)
|
||||
@XmlElementWrapper(name = "owners", namespace = CAT_XML_NS)
|
||||
@JsonIgnore
|
||||
private List<DomainOwnership> owners;
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public class CcmObject implements Identifiable, Serializable {
|
|||
/**
|
||||
* Permissions granted on this object.
|
||||
*/
|
||||
@OneToMany(mappedBy = "object")
|
||||
@OneToMany(mappedBy = "object", fetch = FetchType.LAZY)
|
||||
@IndexedEmbedded(includePaths = {"grantedPrivilege", "grantee.name"})
|
||||
@XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "permission", namespace = CORE_XML_NS)
|
||||
|
|
@ -122,7 +122,7 @@ public class CcmObject implements Identifiable, Serializable {
|
|||
/**
|
||||
* Categories which have been assigned to this {@code CcmObject}.
|
||||
*/
|
||||
@OneToMany(mappedBy = "categorizedObject")
|
||||
@OneToMany(mappedBy = "categorizedObject", fetch = FetchType.LAZY)
|
||||
@XmlElementWrapper(name = "categories", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "category", namespace = CORE_XML_NS)
|
||||
@JsonIgnore
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import javax.persistence.AssociationOverride;
|
|||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
|
@ -114,7 +115,7 @@ public class Resource extends CcmObject implements Serializable {
|
|||
/**
|
||||
* The child resources of this resource.
|
||||
*/
|
||||
@OneToMany(mappedBy = "parent")
|
||||
@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
|
||||
@JsonIgnore
|
||||
private List<Resource> childs;
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ public class LocalizedString implements Serializable {
|
|||
@Lob
|
||||
@Type(type = "org.hibernate.type.TextType")
|
||||
@Field
|
||||
// @XmlElementWrapper(name = "values", namespace = L10N_XML_NS)
|
||||
@XmlElement(name = "values", namespace = L10N_XML_NS)
|
||||
@XmlJavaTypeAdapter(LocalizedStringValuesAdapter.class)
|
||||
private Map<Locale, String> values;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.libreccm.portation;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class Group extends Party implements Serializable, Portable {
|
|||
* The memberships of the group. For adding or removing memberships the
|
||||
* methods provided by the {@link GroupManager} should be used.
|
||||
*/
|
||||
@OneToMany(mappedBy = "group")
|
||||
@OneToMany(mappedBy = "group", fetch = FetchType.LAZY)
|
||||
@XmlElementWrapper(name = "group-memberships", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "group-membership", namespace = CORE_XML_NS)
|
||||
@JsonIgnore
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
|
||||
import javax.persistence.FetchType;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
|
|
@ -107,7 +108,7 @@ public class Party implements Serializable {
|
|||
/**
|
||||
* The role memberships the party.
|
||||
*/
|
||||
@OneToMany(mappedBy = "member")
|
||||
@OneToMany(mappedBy = "member", fetch = FetchType.LAZY)
|
||||
@XmlElementWrapper(name = "role-memberships", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "role-membership", namespace = CORE_XML_NS)
|
||||
@JsonIgnore
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ public class Role implements Serializable, Portable {
|
|||
/**
|
||||
* All memberships of the roles.
|
||||
*/
|
||||
@OneToMany(mappedBy = "role")
|
||||
@OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
|
||||
@XmlElementWrapper(name = "role-memberships", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "role-membership", namespace = CORE_XML_NS)
|
||||
@JsonIgnore
|
||||
|
|
@ -177,7 +177,7 @@ public class Role implements Serializable, Portable {
|
|||
@JsonIgnore
|
||||
private List<Permission> permissions = new ArrayList<>();
|
||||
|
||||
@OneToMany(mappedBy = "role")
|
||||
@OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
|
||||
@JsonIgnore
|
||||
private List<TaskAssignment> assignedTasks = new ArrayList<>();
|
||||
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ public class User extends Party implements Serializable, Portable {
|
|||
/**
|
||||
* The groups of which the user is a member.
|
||||
*/
|
||||
@OneToMany(mappedBy = "member")
|
||||
@OneToMany(mappedBy = "member", fetch = FetchType.LAZY)
|
||||
@XmlElementWrapper(name = "group-memberships", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "group-membership", namespace = CORE_XML_NS)
|
||||
@JsonIgnore
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import org.libreccm.categorization.DomainOwnership;
|
|||
import org.libreccm.core.Resource;
|
||||
import org.libreccm.portation.Portable;
|
||||
|
||||
import javax.persistence.FetchType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
|
@ -97,7 +98,7 @@ public class CcmApplication extends Resource implements Serializable, Portable {
|
|||
/**
|
||||
* Category Domains owned by this {@code CcmObject}.
|
||||
*/
|
||||
@OneToMany(mappedBy = "owner")
|
||||
@OneToMany(mappedBy = "owner", fetch = FetchType.LAZY)
|
||||
@XmlElementWrapper(name = "domains", namespace = WEB_XML_NS)
|
||||
@XmlElement(name = "domain", namespace = WEB_XML_NS)
|
||||
@JsonIgnore
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ public class AssignableTask extends Task implements Serializable, Portable {
|
|||
/**
|
||||
* The roles to which task is assigned.
|
||||
*/
|
||||
@OneToMany(mappedBy = "task")
|
||||
@OneToMany(mappedBy = "task", fetch = FetchType.LAZY)
|
||||
@JsonIgnore
|
||||
private List<TaskAssignment> assignments;
|
||||
|
||||
|
|
|
|||
|
|
@ -153,16 +153,16 @@ public class Task implements Identifiable, Serializable {
|
|||
private Workflow workflow;
|
||||
|
||||
/**
|
||||
* Tasks which the depends of this task.
|
||||
* Tasks which depend on this task.
|
||||
*/
|
||||
@ManyToMany(mappedBy = "dependsOn")
|
||||
@ManyToMany(mappedBy = "dependsOn", fetch = FetchType.LAZY)
|
||||
@JsonIgnore
|
||||
private List<Task> dependentTasks;
|
||||
|
||||
/**
|
||||
* The task of this task depends.
|
||||
* The dependencies of this task.
|
||||
*/
|
||||
@ManyToMany
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "WORKFLOW_TASK_DEPENDENCIES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
|
|
@ -175,8 +175,9 @@ public class Task implements Identifiable, Serializable {
|
|||
/**
|
||||
* Comments for the task.
|
||||
*/
|
||||
@OneToMany
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "TASK_ID")
|
||||
@JsonIdentityReference(alwaysAsId = true)
|
||||
private List<TaskComment> comments;
|
||||
|
||||
public Task() {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package org.libreccm.workflow;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.libreccm.core.CoreConstants;
|
||||
|
|
@ -80,6 +81,7 @@ public class TaskComment implements Identifiable, Serializable, Portable {
|
|||
*/
|
||||
@OneToOne
|
||||
@JoinColumn(name = "AUTHOR_ID")
|
||||
@JsonIdentityReference(alwaysAsId = true)
|
||||
private User author;
|
||||
|
||||
public long getCommentId() {
|
||||
|
|
|
|||
|
|
@ -27,9 +27,27 @@ import org.libreccm.core.Identifiable;
|
|||
import org.libreccm.l10n.LocalizedString;
|
||||
import org.libreccm.portation.Portable;
|
||||
|
||||
import javax.persistence.*;
|
||||
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.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
@ -38,8 +56,6 @@ 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.
|
||||
|
|
@ -92,6 +108,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
|
|||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "TEMPLATE_ID")
|
||||
@JsonIdentityReference(alwaysAsId = true)
|
||||
private Workflow template;
|
||||
|
||||
/**
|
||||
|
|
@ -152,7 +169,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
|
|||
/**
|
||||
* The tasks belonging to this workflow.
|
||||
*/
|
||||
@OneToMany(mappedBy = "workflow")
|
||||
@OneToMany(mappedBy = "workflow", fetch = FetchType.LAZY)
|
||||
@JsonIgnore
|
||||
private List<Task> tasks;
|
||||
|
||||
|
|
@ -244,9 +261,9 @@ public class Workflow implements Identifiable, Serializable, Portable {
|
|||
}
|
||||
|
||||
protected void setObject(final CcmObject object) {
|
||||
if (abstractWorkflow) {
|
||||
if (abstractWorkflow && object != null) {
|
||||
throw new AbstractWorkflowException(String.format(
|
||||
"Workflow %s is abstrct and can not assigned to an object.",
|
||||
"Workflow %s is abstract and can not assigned to an object.",
|
||||
uuid));
|
||||
}
|
||||
this.object = object;
|
||||
|
|
|
|||
|
|
@ -60,13 +60,13 @@ public class WorkflowRepository extends AbstractEntityRepository<Long, Workflow>
|
|||
* the provided UUID.
|
||||
*/
|
||||
public Optional<Workflow> findByUuid(final String uuid) {
|
||||
if (uuid == null || uuid.trim().isEmpty()) {
|
||||
if (uuid == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"The UUID of the Workflow to retrieve can't be null or empty.");
|
||||
}
|
||||
|
||||
final TypedQuery<Workflow> query = getEntityManager().createNamedQuery(
|
||||
"Workflow.findByUuid", Workflow.class);
|
||||
final TypedQuery<Workflow> query = getEntityManager()
|
||||
.createNamedQuery("Workflow.findByUuid", Workflow.class);
|
||||
query.setParameter("uuid", uuid);
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -144,7 +144,6 @@ public class CoreDataImportTest {
|
|||
|
||||
Assert.assertFalse(importHelper.importPermissions());
|
||||
|
||||
// Assert.assertFalse(importHelper.importWorkflowTemplates());
|
||||
Assert.assertFalse(importHelper.importWorkflows());
|
||||
Assert.assertFalse(importHelper.importTaskComments());
|
||||
//Assert.assertFalse(importHelper.importAssignableTasks());
|
||||
|
|
|
|||
Loading…
Reference in New Issue