[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-94f89814c4df
ccm-docs
tosmers 2017-10-27 15:51:21 +00:00
parent dfd2eaa5d1
commit cbcc621eba
16 changed files with 51 additions and 28 deletions

View File

@ -30,6 +30,7 @@ import org.libreccm.portation.Portable;
import org.libreccm.security.RecursivePermissions; import org.libreccm.security.RecursivePermissions;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
import javax.persistence.FetchType;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
@ -210,7 +211,7 @@ public class Domain extends CcmObject implements Serializable, Portable {
/** /**
* The owners of the domain. * The owners of the domain.
*/ */
@OneToMany(mappedBy = "domain") @OneToMany(mappedBy = "domain", fetch = FetchType.LAZY)
@XmlElementWrapper(name = "owners", namespace = CAT_XML_NS) @XmlElementWrapper(name = "owners", namespace = CAT_XML_NS)
@JsonIgnore @JsonIgnore
private List<DomainOwnership> owners; private List<DomainOwnership> owners;

View File

@ -112,7 +112,7 @@ public class CcmObject implements Identifiable, Serializable {
/** /**
* Permissions granted on this object. * Permissions granted on this object.
*/ */
@OneToMany(mappedBy = "object") @OneToMany(mappedBy = "object", fetch = FetchType.LAZY)
@IndexedEmbedded(includePaths = {"grantedPrivilege", "grantee.name"}) @IndexedEmbedded(includePaths = {"grantedPrivilege", "grantee.name"})
@XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS) @XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS)
@XmlElement(name = "permission", 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}. * 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) @XmlElementWrapper(name = "categories", namespace = CORE_XML_NS)
@XmlElement(name = "category", namespace = CORE_XML_NS) @XmlElement(name = "category", namespace = CORE_XML_NS)
@JsonIgnore @JsonIgnore

View File

@ -39,6 +39,7 @@ import javax.persistence.AssociationOverride;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embedded; import javax.persistence.Embedded;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinTable; import javax.persistence.JoinTable;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
@ -114,7 +115,7 @@ public class Resource extends CcmObject implements Serializable {
/** /**
* The child resources of this resource. * The child resources of this resource.
*/ */
@OneToMany(mappedBy = "parent") @OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
@JsonIgnore @JsonIgnore
private List<Resource> childs; private List<Resource> childs;

View File

@ -73,7 +73,6 @@ public class LocalizedString implements Serializable {
@Lob @Lob
@Type(type = "org.hibernate.type.TextType") @Type(type = "org.hibernate.type.TextType")
@Field @Field
// @XmlElementWrapper(name = "values", namespace = L10N_XML_NS)
@XmlElement(name = "values", namespace = L10N_XML_NS) @XmlElement(name = "values", namespace = L10N_XML_NS)
@XmlJavaTypeAdapter(LocalizedStringValuesAdapter.class) @XmlJavaTypeAdapter(LocalizedStringValuesAdapter.class)
private Map<Locale, String> values; private Map<Locale, String> values;

View File

@ -18,6 +18,7 @@
*/ */
package org.libreccm.portation; package org.libreccm.portation;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;

View File

@ -104,7 +104,7 @@ public class Group extends Party implements Serializable, Portable {
* The memberships of the group. For adding or removing memberships the * The memberships of the group. For adding or removing memberships the
* methods provided by the {@link GroupManager} should be used. * 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) @XmlElementWrapper(name = "group-memberships", namespace = CORE_XML_NS)
@XmlElement(name = "group-membership", namespace = CORE_XML_NS) @XmlElement(name = "group-membership", namespace = CORE_XML_NS)
@JsonIgnore @JsonIgnore

View File

@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators; import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import javax.persistence.FetchType;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
@ -107,7 +108,7 @@ public class Party implements Serializable {
/** /**
* The role memberships the party. * The role memberships the party.
*/ */
@OneToMany(mappedBy = "member") @OneToMany(mappedBy = "member", fetch = FetchType.LAZY)
@XmlElementWrapper(name = "role-memberships", namespace = CORE_XML_NS) @XmlElementWrapper(name = "role-memberships", namespace = CORE_XML_NS)
@XmlElement(name = "role-membership", namespace = CORE_XML_NS) @XmlElement(name = "role-membership", namespace = CORE_XML_NS)
@JsonIgnore @JsonIgnore

View File

@ -162,7 +162,7 @@ public class Role implements Serializable, Portable {
/** /**
* All memberships of the roles. * All memberships of the roles.
*/ */
@OneToMany(mappedBy = "role") @OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
@XmlElementWrapper(name = "role-memberships", namespace = CORE_XML_NS) @XmlElementWrapper(name = "role-memberships", namespace = CORE_XML_NS)
@XmlElement(name = "role-membership", namespace = CORE_XML_NS) @XmlElement(name = "role-membership", namespace = CORE_XML_NS)
@JsonIgnore @JsonIgnore
@ -177,7 +177,7 @@ public class Role implements Serializable, Portable {
@JsonIgnore @JsonIgnore
private List<Permission> permissions = new ArrayList<>(); private List<Permission> permissions = new ArrayList<>();
@OneToMany(mappedBy = "role") @OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
@JsonIgnore @JsonIgnore
private List<TaskAssignment> assignedTasks = new ArrayList<>(); private List<TaskAssignment> assignedTasks = new ArrayList<>();

View File

@ -195,7 +195,7 @@ public class User extends Party implements Serializable, Portable {
/** /**
* The groups of which the user is a member. * 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) @XmlElementWrapper(name = "group-memberships", namespace = CORE_XML_NS)
@XmlElement(name = "group-membership", namespace = CORE_XML_NS) @XmlElement(name = "group-membership", namespace = CORE_XML_NS)
@JsonIgnore @JsonIgnore

View File

@ -27,6 +27,7 @@ import org.libreccm.categorization.DomainOwnership;
import org.libreccm.core.Resource; import org.libreccm.core.Resource;
import org.libreccm.portation.Portable; import org.libreccm.portation.Portable;
import javax.persistence.FetchType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; 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}. * Category Domains owned by this {@code CcmObject}.
*/ */
@OneToMany(mappedBy = "owner") @OneToMany(mappedBy = "owner", fetch = FetchType.LAZY)
@XmlElementWrapper(name = "domains", namespace = WEB_XML_NS) @XmlElementWrapper(name = "domains", namespace = WEB_XML_NS)
@XmlElement(name = "domain", namespace = WEB_XML_NS) @XmlElement(name = "domain", namespace = WEB_XML_NS)
@JsonIgnore @JsonIgnore

View File

@ -136,7 +136,7 @@ public class AssignableTask extends Task implements Serializable, Portable {
/** /**
* The roles to which task is assigned. * The roles to which task is assigned.
*/ */
@OneToMany(mappedBy = "task") @OneToMany(mappedBy = "task", fetch = FetchType.LAZY)
@JsonIgnore @JsonIgnore
private List<TaskAssignment> assignments; private List<TaskAssignment> assignments;

View File

@ -153,16 +153,16 @@ public class Task implements Identifiable, Serializable {
private Workflow workflow; 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 @JsonIgnore
private List<Task> dependentTasks; 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", @JoinTable(name = "WORKFLOW_TASK_DEPENDENCIES",
schema = DB_SCHEMA, schema = DB_SCHEMA,
joinColumns = { joinColumns = {
@ -175,8 +175,9 @@ public class Task implements Identifiable, Serializable {
/** /**
* Comments for the task. * Comments for the task.
*/ */
@OneToMany @OneToMany(fetch = FetchType.EAGER)
@JoinColumn(name = "TASK_ID") @JoinColumn(name = "TASK_ID")
@JsonIdentityReference(alwaysAsId = true)
private List<TaskComment> comments; private List<TaskComment> comments;
public Task() { public Task() {

View File

@ -19,6 +19,7 @@
package org.libreccm.workflow; package org.libreccm.workflow;
import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.ObjectIdGenerators; import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.libreccm.core.CoreConstants; import org.libreccm.core.CoreConstants;
@ -80,6 +81,7 @@ public class TaskComment implements Identifiable, Serializable, Portable {
*/ */
@OneToOne @OneToOne
@JoinColumn(name = "AUTHOR_ID") @JoinColumn(name = "AUTHOR_ID")
@JsonIdentityReference(alwaysAsId = true)
private User author; private User author;
public long getCommentId() { public long getCommentId() {

View File

@ -27,9 +27,27 @@ import org.libreccm.core.Identifiable;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
import org.libreccm.portation.Portable; 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 javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -38,8 +56,6 @@ import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA; 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 * A workflow is a collection of tasks which are performed on an object. Tasks
* can depend on each other. * can depend on each other.
@ -92,6 +108,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
*/ */
@ManyToOne @ManyToOne
@JoinColumn(name = "TEMPLATE_ID") @JoinColumn(name = "TEMPLATE_ID")
@JsonIdentityReference(alwaysAsId = true)
private Workflow template; private Workflow template;
/** /**
@ -152,7 +169,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
/** /**
* The tasks belonging to this workflow. * The tasks belonging to this workflow.
*/ */
@OneToMany(mappedBy = "workflow") @OneToMany(mappedBy = "workflow", fetch = FetchType.LAZY)
@JsonIgnore @JsonIgnore
private List<Task> tasks; private List<Task> tasks;
@ -244,9 +261,9 @@ public class Workflow implements Identifiable, Serializable, Portable {
} }
protected void setObject(final CcmObject object) { protected void setObject(final CcmObject object) {
if (abstractWorkflow) { if (abstractWorkflow && object != null) {
throw new AbstractWorkflowException(String.format( 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)); uuid));
} }
this.object = object; this.object = object;

View File

@ -60,13 +60,13 @@ public class WorkflowRepository extends AbstractEntityRepository<Long, Workflow>
* the provided UUID. * the provided UUID.
*/ */
public Optional<Workflow> findByUuid(final String uuid) { public Optional<Workflow> findByUuid(final String uuid) {
if (uuid == null || uuid.trim().isEmpty()) { if (uuid == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"The UUID of the Workflow to retrieve can't be null or empty."); "The UUID of the Workflow to retrieve can't be null or empty.");
} }
final TypedQuery<Workflow> query = getEntityManager().createNamedQuery( final TypedQuery<Workflow> query = getEntityManager()
"Workflow.findByUuid", Workflow.class); .createNamedQuery("Workflow.findByUuid", Workflow.class);
query.setParameter("uuid", uuid); query.setParameter("uuid", uuid);
try { try {

View File

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