[UPDATE]
- modifies managed/back references - adds updated export data for import git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4472 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
eab9004678
commit
c762750b6d
|
|
@ -19,6 +19,7 @@
|
|||
package org.libreccm.categorization;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.portation.Portable;
|
||||
|
||||
|
|
@ -84,7 +85,7 @@ public class Categorization implements Serializable, Portable {
|
|||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "CATEGORY_ID")
|
||||
@JsonBackReference
|
||||
@JsonManagedReference(value = "categorization-category")
|
||||
private Category category;
|
||||
|
||||
/**
|
||||
|
|
@ -92,7 +93,7 @@ public class Categorization implements Serializable, Portable {
|
|||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
@JsonBackReference
|
||||
@JsonManagedReference(value = "categorization-object")
|
||||
private CcmObject categorizedObject;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ public class Category extends CcmObject implements InheritsPermissions,
|
|||
*/
|
||||
@OneToMany(mappedBy = "category")
|
||||
@XmlElementWrapper(name = "objects", namespace = CAT_XML_NS)
|
||||
@JsonManagedReference
|
||||
@JsonBackReference(value = "categorization-category")
|
||||
private List<Categorization> objects;
|
||||
|
||||
/**
|
||||
|
|
@ -191,7 +191,7 @@ public class Category extends CcmObject implements InheritsPermissions,
|
|||
@OneToMany(mappedBy = "parentCategory")
|
||||
@XmlElementWrapper(name = "subcategories", namespace = CAT_XML_NS)
|
||||
@XmlElement(name = "category")
|
||||
@JsonManagedReference
|
||||
@JsonBackReference(value = "parentcategory-subcategory")
|
||||
private List<Category> subCategories;
|
||||
|
||||
/**
|
||||
|
|
@ -200,7 +200,7 @@ public class Category extends CcmObject implements InheritsPermissions,
|
|||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "PARENT_CATEGORY_ID")
|
||||
@JsonBackReference
|
||||
@JsonManagedReference(value = "parentcategory-subcategory")
|
||||
private Category parentCategory;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
package org.libreccm.core;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.libreccm.categorization.Categorization;
|
||||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.categorization.CategoryManager;
|
||||
import org.libreccm.portation.Portable;
|
||||
import org.libreccm.security.Permission;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
|
@ -117,7 +117,7 @@ public class CcmObject implements Identifiable, Serializable {
|
|||
@OneToMany(mappedBy = "object")
|
||||
@XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "permission", namespace = CORE_XML_NS)
|
||||
@JsonManagedReference
|
||||
@JsonBackReference(value = "permission-object")
|
||||
private List<Permission> permissions;
|
||||
|
||||
/**
|
||||
|
|
@ -126,7 +126,7 @@ public class CcmObject implements Identifiable, Serializable {
|
|||
@OneToMany(mappedBy = "categorizedObject")
|
||||
@XmlElementWrapper(name = "categories", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "category", namespace = CORE_XML_NS)
|
||||
@JsonManagedReference
|
||||
@JsonBackReference(value = "categorization-object")
|
||||
private List<Categorization> categories;
|
||||
|
||||
public CcmObject() {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
|
||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
|
@ -43,7 +44,8 @@ import java.util.List;
|
|||
*/
|
||||
public abstract class AbstractMarshaller<P extends Portable> {
|
||||
|
||||
private static final Logger log = Logger.getLogger(AbstractMarshaller.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger(AbstractMarshaller
|
||||
.class);
|
||||
|
||||
private Format format;
|
||||
private String filename;
|
||||
|
|
@ -73,11 +75,14 @@ public abstract class AbstractMarshaller<P extends Portable> {
|
|||
JacksonXmlModule module = new JacksonXmlModule();
|
||||
module.setDefaultUseWrapper(false);
|
||||
xmlMapper = new XmlMapper(module);
|
||||
|
||||
if (indentation) {
|
||||
xmlMapper.enable(SerializationFeature.INDENT_OUTPUT);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -117,8 +122,9 @@ public abstract class AbstractMarshaller<P extends Portable> {
|
|||
try {
|
||||
fileWriter = new FileWriter(file);
|
||||
} catch (IOException e) {
|
||||
log.error(String.format("Unable to open a fileWriter for the file" +
|
||||
" with the name %s.", file.getName()));
|
||||
LOGGER.error("Unable to open a fileWriter for the file" +
|
||||
" with the name {}.", file.getName());
|
||||
LOGGER.error(e);
|
||||
}
|
||||
if (fileWriter != null) {
|
||||
for (P object : exportList) {
|
||||
|
|
@ -128,11 +134,12 @@ public abstract class AbstractMarshaller<P extends Portable> {
|
|||
case XML:
|
||||
try {
|
||||
line = xmlMapper.writeValueAsString(object);
|
||||
//log.info(line);
|
||||
//LOGGER.info(line);
|
||||
} catch (IOException e) {
|
||||
log.error(String.format("Unable to write objetct " +
|
||||
"of class %s as XML string with name %s.",
|
||||
object.getClass(), file.getName()), e);
|
||||
LOGGER.error("Unable to write objetct " +
|
||||
"of class {} as XML string with name {}.",
|
||||
object.getClass(), file.getName());
|
||||
LOGGER.error(e);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -144,16 +151,18 @@ public abstract class AbstractMarshaller<P extends Portable> {
|
|||
fileWriter.write(line);
|
||||
fileWriter.write(System.getProperty("line.separator"));
|
||||
} catch (IOException e) {
|
||||
log.error(String.format("Unable to write to file with" +
|
||||
" the name %s.", file.getName()));
|
||||
LOGGER.error("Unable to write to file with" +
|
||||
" the name {}.", file.getName());
|
||||
LOGGER.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
fileWriter.close();
|
||||
} catch (IOException e) {
|
||||
log.error(String.format("Unable to close a fileWriter for the" +
|
||||
" file with the name %s.", file.getName()));
|
||||
LOGGER.error("Unable to close a fileWriter for the" +
|
||||
" file with the name {}.", file.getName());
|
||||
LOGGER.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -173,8 +182,9 @@ public abstract class AbstractMarshaller<P extends Portable> {
|
|||
try {
|
||||
lines = Files.readAllLines(file.toPath());
|
||||
} catch (IOException e) {
|
||||
log.error(String.format("Unable to read lines of the file with " +
|
||||
"name %s.", file.getName()));
|
||||
LOGGER.error("Unable to read lines of the file with " +
|
||||
"name {}.", file.getName());
|
||||
LOGGER.error(e);
|
||||
}
|
||||
|
||||
List<P> objects = new ArrayList<>();
|
||||
|
|
@ -186,8 +196,9 @@ public abstract class AbstractMarshaller<P extends Portable> {
|
|||
try {
|
||||
object = xmlMapper.readValue(line, getObjectClass());
|
||||
} catch (IOException e) {
|
||||
log.error(String.format("Unable to read objects " +
|
||||
"from XML line:\n \"%s\"", line), e);
|
||||
LOGGER.error("Unable to read objects " +
|
||||
"from XML line:\n \"{}\"", line);
|
||||
LOGGER.error(e);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,9 @@ public class Marshaller {
|
|||
private <P extends Portable> void exportList(List<P> list,
|
||||
Class<? extends P> type,
|
||||
Format format,
|
||||
String filename) {
|
||||
String filename)
|
||||
throws IllegalArgumentException {
|
||||
|
||||
final Instance<AbstractMarshaller<? extends Portable>>
|
||||
marshallerInstance = marshallerInstances.select(new
|
||||
MarshalsLiteral(type));
|
||||
|
|
@ -153,8 +155,10 @@ public class Marshaller {
|
|||
* @param format The import style
|
||||
* @param <P> The type of the current marshaller
|
||||
*/
|
||||
public <P extends Portable> void importFiles(
|
||||
List<String> filenames, Format format) {
|
||||
public <P extends Portable> void importFiles(List<String> filenames,
|
||||
Format format)
|
||||
throws IllegalArgumentException {
|
||||
|
||||
for (String filename : filenames) {
|
||||
String[] splitFilename = filename.split("__");
|
||||
String className =
|
||||
|
|
|
|||
|
|
@ -18,18 +18,10 @@
|
|||
*/
|
||||
package org.libreccm.security;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.*;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import org.libreccm.core.DefaultEntityGraph;
|
||||
import org.libreccm.portation.Portable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.NamedAttributeNode;
|
||||
import javax.persistence.NamedEntityGraph;
|
||||
|
|
@ -42,6 +34,14 @@ import javax.persistence.Table;
|
|||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.CORE_XML_NS;
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
/**
|
||||
* A group is basically a collection of users.
|
||||
|
|
@ -101,7 +101,7 @@ public class Group extends Party implements Serializable, Portable {
|
|||
@OneToMany(mappedBy = "group")
|
||||
@XmlElementWrapper(name = "group-memberships", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "group-membership", namespace = CORE_XML_NS)
|
||||
@JsonManagedReference
|
||||
@JsonBackReference(value = "groupmembership-group")
|
||||
private Set<GroupMembership> memberships = new HashSet<>();
|
||||
|
||||
public Group() {
|
||||
|
|
|
|||
|
|
@ -19,13 +19,9 @@
|
|||
package org.libreccm.security;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import org.libreccm.portation.Portable;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
|
@ -39,6 +35,11 @@ import javax.persistence.Table;
|
|||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.CORE_XML_NS;
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
/**
|
||||
* A association class representing the assoication between a {@link User} and
|
||||
|
|
@ -66,13 +67,13 @@ public class GroupMembership implements Serializable, Portable {
|
|||
@ManyToOne
|
||||
@JoinColumn(name = "GROUP_ID")
|
||||
@XmlTransient
|
||||
@JsonBackReference
|
||||
@JsonManagedReference(value = "groupmembership-group")
|
||||
private Group group;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "MEMBER_ID")
|
||||
@XmlTransient
|
||||
@JsonBackReference
|
||||
@JsonManagedReference(value = "groupmembership-user")
|
||||
private User member;
|
||||
|
||||
public long getMembershipId() {
|
||||
|
|
|
|||
|
|
@ -18,17 +18,8 @@
|
|||
*/
|
||||
package org.libreccm.security;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.*;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import org.libreccm.core.DefaultEntityGraph;
|
||||
import org.libreccm.portation.Portable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
|
@ -48,6 +39,14 @@ import javax.validation.constraints.NotNull;
|
|||
import javax.validation.constraints.Pattern;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.CORE_XML_NS;
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
/**
|
||||
* Party is a base class for {@link User} and {@link Group} defining some common
|
||||
|
|
@ -99,7 +98,7 @@ public class Party implements Serializable {
|
|||
@OneToMany(mappedBy = "member")
|
||||
@XmlElementWrapper(name = "role-memberships", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "role-membership", namespace = CORE_XML_NS)
|
||||
@JsonManagedReference
|
||||
@JsonBackReference(value = "rolemembership-party")
|
||||
private Set<RoleMembership> roleMemberships = new HashSet<>();
|
||||
|
||||
protected Party() {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package org.libreccm.security;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.portation.Portable;
|
||||
|
||||
|
|
@ -97,7 +98,7 @@ public class Permission implements Serializable, Portable {
|
|||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
@JsonBackReference
|
||||
@JsonManagedReference(value = "permission-object")
|
||||
private CcmObject object;
|
||||
|
||||
/**
|
||||
|
|
@ -105,7 +106,7 @@ public class Permission implements Serializable, Portable {
|
|||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "GRANTEE_ID")
|
||||
@JsonBackReference
|
||||
@JsonManagedReference(value = "permission-role")
|
||||
private Role grantee;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.libreccm.security;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import org.libreccm.core.DefaultEntityGraph;
|
||||
|
|
@ -150,7 +151,7 @@ public class Role implements Serializable, Portable {
|
|||
@OneToMany(mappedBy = "role")
|
||||
@XmlElementWrapper(name = "role-memberships", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "role-membership", namespace = CORE_XML_NS)
|
||||
@JsonManagedReference
|
||||
@JsonBackReference(value = "rolemembership-role")
|
||||
private Set<RoleMembership> memberships = new HashSet<>();
|
||||
|
||||
/**
|
||||
|
|
@ -159,11 +160,11 @@ public class Role implements Serializable, Portable {
|
|||
@OneToMany(mappedBy = "grantee")
|
||||
@XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "permission", namespace = CORE_XML_NS)
|
||||
@JsonManagedReference
|
||||
@JsonBackReference(value = "permission-role")
|
||||
private List<Permission> permissions = new ArrayList<>();
|
||||
|
||||
@OneToMany(mappedBy = "role")
|
||||
@JsonManagedReference
|
||||
@JsonBackReference(value = "taskassignment-role")
|
||||
private List<TaskAssignment> assignedTasks;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,13 +19,9 @@
|
|||
package org.libreccm.security;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import org.libreccm.portation.Portable;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
|
@ -39,6 +35,11 @@ import javax.persistence.Table;
|
|||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.CORE_XML_NS;
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
/**
|
||||
* Association class representing the association between a {@link Role} and a
|
||||
|
|
@ -67,13 +68,13 @@ public class RoleMembership implements Serializable, Portable {
|
|||
@ManyToOne
|
||||
@JoinColumn(name = "ROLE_ID")
|
||||
@XmlTransient
|
||||
@JsonBackReference
|
||||
@JsonManagedReference(value = "rolemembership-role")
|
||||
private Role role;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "MEMBER_ID")
|
||||
@XmlTransient
|
||||
@JsonBackReference
|
||||
@JsonManagedReference(value = "rolemembership-party")
|
||||
private Party member;
|
||||
|
||||
public long getMembershipId() {
|
||||
|
|
|
|||
|
|
@ -18,21 +18,11 @@
|
|||
*/
|
||||
package org.libreccm.security;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.*;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import org.libreccm.core.DefaultEntityGraph;
|
||||
import org.libreccm.core.EmailAddress;
|
||||
import org.libreccm.portation.Portable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.CollectionTable;
|
||||
import javax.persistence.Column;
|
||||
|
|
@ -57,6 +47,16 @@ import javax.xml.bind.annotation.XmlElement;
|
|||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.CORE_XML_NS;
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
/**
|
||||
* A user is a person (or a system) accessing CCM. A user authenticates itself
|
||||
|
|
@ -204,7 +204,7 @@ public class User extends Party implements Serializable, Portable {
|
|||
@OneToMany(mappedBy = "member")
|
||||
@XmlElementWrapper(name = "group-memberships", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "group-membership", namespace = CORE_XML_NS)
|
||||
@JsonManagedReference
|
||||
@JsonBackReference(value = "groupmembership-user")
|
||||
private Set<GroupMembership> groupMemberships = new HashSet<>();
|
||||
|
||||
protected User() {
|
||||
|
|
|
|||
|
|
@ -18,19 +18,10 @@
|
|||
*/
|
||||
package org.libreccm.workflow;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.*;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import org.libreccm.portation.Portable;
|
||||
import org.libreccm.security.User;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
|
|
@ -41,6 +32,14 @@ import javax.persistence.OneToOne;
|
|||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
/**
|
||||
* A task which can be assigned to a user. Also a {@code AssignableTask} can be
|
||||
|
|
@ -130,7 +129,7 @@ public class AssignableTask extends Task implements Serializable, Portable {
|
|||
* The roles to which task is assigned.
|
||||
*/
|
||||
@OneToMany(mappedBy = "task")
|
||||
@JsonManagedReference
|
||||
@JsonBackReference(value = "taskassignment-assignabletask")
|
||||
private List<TaskAssignment> assignments;
|
||||
|
||||
public AssignableTask() {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ package org.libreccm.workflow;
|
|||
|
||||
import static org.libreccm.core.CoreConstants.*;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.core.Identifiable;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
|
@ -157,12 +159,14 @@ public class Task implements Identifiable, Serializable {
|
|||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "WORKFLOW_ID")
|
||||
@JsonManagedReference(value = "task-workflow")
|
||||
private Workflow workflow;
|
||||
|
||||
/**
|
||||
* Tasks which the depends of this task.
|
||||
*/
|
||||
@ManyToMany(mappedBy = "dependsOn")
|
||||
@JsonBackReference(value = "dependson-dependent")
|
||||
private List<Task> dependentTasks;
|
||||
|
||||
/**
|
||||
|
|
@ -175,6 +179,7 @@ public class Task implements Identifiable, Serializable {
|
|||
@JoinColumn(name = "DEPENDS_ON_TASK_ID")},
|
||||
inverseJoinColumns = {
|
||||
@JoinColumn(name = "DEPENDENT_TASK_ID")})
|
||||
@JsonManagedReference(value = "dependson-dependent")
|
||||
private List<Task> dependsOn;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,15 +18,11 @@
|
|||
*/
|
||||
package org.libreccm.workflow;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.*;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import org.libreccm.portation.Portable;
|
||||
import org.libreccm.security.Role;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
|
@ -35,6 +31,10 @@ import javax.persistence.Id;
|
|||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
/**
|
||||
* Represents the assignment of a {@link AssignableTask} to a {@link Role}.
|
||||
|
|
@ -60,7 +60,7 @@ public class TaskAssignment implements Serializable, Portable {
|
|||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "TASK_ID")
|
||||
@JsonBackReference
|
||||
@JsonManagedReference(value = "taskassignment-assignabletask")
|
||||
private AssignableTask task;
|
||||
|
||||
/**
|
||||
|
|
@ -68,7 +68,7 @@ public class TaskAssignment implements Serializable, Portable {
|
|||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "ROLE_ID")
|
||||
@JsonBackReference
|
||||
@JsonManagedReference(value = "taskassignment-role")
|
||||
private Role role;
|
||||
|
||||
public long getTaskAssignmentId() {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.libreccm.workflow;
|
|||
|
||||
import static org.libreccm.core.CoreConstants.*;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
||||
|
|
@ -151,6 +152,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
|
|||
* The tasks belonging to this workflow.
|
||||
*/
|
||||
@OneToMany(mappedBy = "workflow")
|
||||
@JsonBackReference(value = "task-workflow")
|
||||
private List<Task> tasks;
|
||||
|
||||
public Workflow() {
|
||||
|
|
|
|||
|
|
@ -77,12 +77,14 @@ public class CoreDataImportTest {
|
|||
"CoreDataImportTest.war")
|
||||
.addPackage(org.libreccm.categorization.Category
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.core.CcmObject.class.getPackage())
|
||||
.addPackage(org.libreccm.core.CcmObject
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.l10n.LocalizedString
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.portation.AbstractMarshaller
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.security.Group.class.getPackage())
|
||||
.addPackage(org.libreccm.security.Group
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.workflow.AssignableTask
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.configuration.ConfigurationManager
|
||||
|
|
@ -91,6 +93,10 @@ public class CoreDataImportTest {
|
|||
.class.getPackage())
|
||||
.addPackage(org.libreccm.testutils.EqualsVerifier
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.web.CcmApplication
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.jpa.EntityManagerProducer
|
||||
.class.getPackage())
|
||||
.addAsLibraries(getModuleDependencies())
|
||||
.addAsResource("test-persistence.xml",
|
||||
"META-INF/persistence.xml")
|
||||
|
|
@ -113,72 +119,72 @@ public class CoreDataImportTest {
|
|||
public void categoriesShouldBeImported() {
|
||||
ImportHelper.importCategories();
|
||||
}
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(110)
|
||||
// public void categorizationsShouldBeImported() {
|
||||
// ImportHelper.importCategorizations();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(115)
|
||||
// public void usersShouldBeImported() {
|
||||
// ImportHelper.importUsers();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(120)
|
||||
// public void groupsShouldBeImported() {
|
||||
// ImportHelper.importGroups();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(125)
|
||||
// public void groupMembershipsShouldBeImported() {
|
||||
// ImportHelper.importGroupMemberships();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(130)
|
||||
// public void rolesShouldBeImported() {
|
||||
// ImportHelper.importRoles();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(135)
|
||||
// public void roleMembershipsShouldBeImported() {
|
||||
// ImportHelper.importRoleMemberships();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(140)
|
||||
// public void workflowTemplatesShouldBeImported() {
|
||||
// ImportHelper.importWorkflowTemplates();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(145)
|
||||
// public void workflowsShouldBeImported() {
|
||||
// ImportHelper.importWorkflows();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(150)
|
||||
// public void assignableTasksShouldBeImported() {
|
||||
// ImportHelper.importAssignableTasks();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(155)
|
||||
// public void taskAssignmentsShouldBeImported() {
|
||||
// ImportHelper.importTaskAssignments();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(160)
|
||||
// public void permissionsShouldBeImported() {
|
||||
// ImportHelper.importPermissions();
|
||||
// }
|
||||
|
||||
@Test
|
||||
@InSequence(110)
|
||||
public void categorizationsShouldBeImported() {
|
||||
ImportHelper.importCategorizations();
|
||||
}
|
||||
|
||||
@Test
|
||||
@InSequence(115)
|
||||
public void usersShouldBeImported() {
|
||||
ImportHelper.importUsers();
|
||||
}
|
||||
|
||||
@Test
|
||||
@InSequence(120)
|
||||
public void groupsShouldBeImported() {
|
||||
ImportHelper.importGroups();
|
||||
}
|
||||
|
||||
@Test
|
||||
@InSequence(125)
|
||||
public void groupMembershipsShouldBeImported() {
|
||||
ImportHelper.importGroupMemberships();
|
||||
}
|
||||
|
||||
@Test
|
||||
@InSequence(130)
|
||||
public void rolesShouldBeImported() {
|
||||
ImportHelper.importRoles();
|
||||
}
|
||||
|
||||
@Test
|
||||
@InSequence(135)
|
||||
public void roleMembershipsShouldBeImported() {
|
||||
ImportHelper.importRoleMemberships();
|
||||
}
|
||||
|
||||
@Test
|
||||
@InSequence(140)
|
||||
public void workflowTemplatesShouldBeImported() {
|
||||
ImportHelper.importWorkflowTemplates();
|
||||
}
|
||||
|
||||
@Test
|
||||
@InSequence(145)
|
||||
public void workflowsShouldBeImported() {
|
||||
ImportHelper.importWorkflows();
|
||||
}
|
||||
|
||||
@Test
|
||||
@InSequence(150)
|
||||
public void assignableTasksShouldBeImported() {
|
||||
ImportHelper.importAssignableTasks();
|
||||
}
|
||||
|
||||
@Test
|
||||
@InSequence(155)
|
||||
public void taskAssignmentsShouldBeImported() {
|
||||
ImportHelper.importTaskAssignments();
|
||||
}
|
||||
|
||||
@Test
|
||||
@InSequence(160)
|
||||
public void permissionsShouldBeImported() {
|
||||
ImportHelper.importPermissions();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,17 +43,16 @@ import java.util.List;
|
|||
*/
|
||||
class ImportHelper {
|
||||
private static String pathName =
|
||||
"/home/tosmers/Svn/libreccm/ccm-ng/ccm-core/src/test/resource" +
|
||||
"/portation/trunk-iaw-export";
|
||||
"/home/tosmers/Svn/libreccm/ccm_ng/ccm-core/src/test/resources/" +
|
||||
"portation/trunk-iaw-exports";
|
||||
private static boolean indentation = false;
|
||||
|
||||
private static String blub = "Hallo";
|
||||
|
||||
static void importCategories() {
|
||||
CategoryMarshaller categoryMarshaller = new
|
||||
CategoryMarshaller();
|
||||
categoryMarshaller.prepare(Format.XML, pathName,
|
||||
"categories", indentation);
|
||||
"categories.xml", indentation);
|
||||
List<Category> categories = categoryMarshaller.importFile();
|
||||
}
|
||||
|
||||
|
|
@ -61,21 +60,21 @@ class ImportHelper {
|
|||
CategorizationMarshaller categorizationMarshaller = new
|
||||
CategorizationMarshaller();
|
||||
categorizationMarshaller.prepare(Format.XML, pathName,
|
||||
"categorizations", indentation);
|
||||
"categorizations.xml", indentation);
|
||||
categorizationMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importUsers() {
|
||||
UserMarshaller userMarshaller = new UserMarshaller();
|
||||
userMarshaller.prepare(Format.XML, pathName,
|
||||
"users", indentation);
|
||||
"users.xml", indentation);
|
||||
userMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importGroups() {
|
||||
GroupMarshaller groupMarshaller = new GroupMarshaller();
|
||||
groupMarshaller.prepare(Format.XML, pathName,
|
||||
"groups", indentation);
|
||||
"groups.xml", indentation);
|
||||
groupMarshaller.importFile();
|
||||
}
|
||||
|
||||
|
|
@ -83,14 +82,14 @@ class ImportHelper {
|
|||
GroupMembershipMarshaller groupMembershipMarshaller = new
|
||||
GroupMembershipMarshaller();
|
||||
groupMembershipMarshaller.prepare(Format.XML, pathName,
|
||||
"groupMemberships", indentation);
|
||||
"groupMemberships.xml", indentation);
|
||||
groupMembershipMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importRoles() {
|
||||
RoleMarshaller roleMarshaller = new RoleMarshaller();
|
||||
roleMarshaller.prepare(Format.XML, pathName,
|
||||
"roles", indentation);
|
||||
"roles.xml", indentation);
|
||||
roleMarshaller.importFile();
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +97,7 @@ class ImportHelper {
|
|||
RoleMembershipMarshaller roleMembershipMarshaller = new
|
||||
RoleMembershipMarshaller();
|
||||
roleMembershipMarshaller.prepare(Format.XML, pathName,
|
||||
"roleMemberships", indentation);
|
||||
"roleMemberships.xml", indentation);
|
||||
roleMembershipMarshaller.importFile();
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +105,7 @@ class ImportHelper {
|
|||
WorkflowTemplateMarshaller workflowTemplateMarshaller = new
|
||||
WorkflowTemplateMarshaller();
|
||||
workflowTemplateMarshaller.prepare(Format.XML, pathName,
|
||||
"workflowTemplates", indentation);
|
||||
"workflowTemplates.xml", indentation);
|
||||
workflowTemplateMarshaller.importFile();
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +113,7 @@ class ImportHelper {
|
|||
WorkflowMarshaller workflowMarshaller = new
|
||||
WorkflowMarshaller();
|
||||
workflowMarshaller.prepare(Format.XML, pathName,
|
||||
"workflows", indentation);
|
||||
"workflows.xml", indentation);
|
||||
workflowMarshaller.importFile();
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +121,7 @@ class ImportHelper {
|
|||
AssignableTaskMarshaller assignableTaskMarshaller = new
|
||||
AssignableTaskMarshaller();
|
||||
assignableTaskMarshaller.prepare(Format.XML, pathName,
|
||||
"assignableTasks", indentation);
|
||||
"assignableTasks.xml", indentation);
|
||||
assignableTaskMarshaller.importFile();
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +129,7 @@ class ImportHelper {
|
|||
TaskAssignmentMarshaller taskAssignmentMarshaller = new
|
||||
TaskAssignmentMarshaller();
|
||||
taskAssignmentMarshaller.prepare(Format.XML, pathName,
|
||||
"taskAssignments", indentation);
|
||||
"taskAssignments.xml", indentation);
|
||||
taskAssignmentMarshaller.importFile();
|
||||
}
|
||||
|
||||
|
|
@ -138,7 +137,7 @@ class ImportHelper {
|
|||
PermissionMarshaller permissionMarshaller = new
|
||||
PermissionMarshaller();
|
||||
permissionMarshaller.prepare(Format.XML, pathName,
|
||||
"permissions", indentation);
|
||||
"permissions.xml", indentation);
|
||||
permissionMarshaller.importFile();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue