CCM NG: Some fixes for the Im/Export system
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5744 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
dc49dded4b
commit
792acde2a8
|
|
@ -19,8 +19,12 @@
|
|||
package org.libreccm.categorization;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
|
@ -47,6 +51,12 @@ public class DomainImExporter extends AbstractEntityImExporter<Domain> {
|
|||
domainRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends Exportable>> getRequiredEntities() {
|
||||
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,13 @@
|
|||
package org.libreccm.categorization;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.DependsOn;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
import org.libreccm.web.CcmApplication;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
|
|
@ -34,7 +37,6 @@ import javax.transaction.Transactional;
|
|||
*/
|
||||
@RequestScoped
|
||||
@Processes(DomainOwnership.class)
|
||||
@DependsOn({CcmApplication.class, Domain.class})
|
||||
public class DomainOwnershipImExporter
|
||||
extends AbstractEntityImExporter<DomainOwnership> {
|
||||
|
||||
|
|
@ -54,4 +56,14 @@ public class DomainOwnershipImExporter
|
|||
entityManager.persist(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends Exportable>> getRequiredEntities() {
|
||||
|
||||
final Set<Class<? extends Exportable>> classes = new HashSet<>();
|
||||
classes.add(CcmApplication.class);
|
||||
classes.add(Domain.class);
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,12 @@
|
|||
package org.libreccm.core;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
|
|
@ -46,6 +50,12 @@ public class ResourceTypeImExporter
|
|||
repository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends Exportable>> getRequiredEntities() {
|
||||
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2018 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.imexport;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Used to describe dependencies of an {@link EntityImExporter} when importing
|
||||
* entities. Used by {@link EntityImExporterTreeManager} to
|
||||
* create a dependency tree and do topological sorting.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE,
|
||||
ElementType.PARAMETER,
|
||||
ElementType.FIELD,
|
||||
ElementType.METHOD})
|
||||
public @interface DependsOn {
|
||||
|
||||
Class<? extends Exportable>[] value();
|
||||
|
||||
}
|
||||
|
|
@ -196,11 +196,6 @@ final class EntityImExporterTreeManager {
|
|||
final Map<String, EntityImExporterTreeNode> nodes)
|
||||
throws DependencyException {
|
||||
|
||||
//Get the dependencies of the current EntityImExporter
|
||||
final DependsOn dependsOn = imExporter
|
||||
.getClass()
|
||||
.getAnnotation(DependsOn.class);
|
||||
|
||||
//Get the name of the module from the module info.
|
||||
final String className = imExporter.getClass().getName();
|
||||
LOGGER
|
||||
|
|
@ -227,7 +222,8 @@ final class EntityImExporterTreeManager {
|
|||
className);
|
||||
//Process the EntityImExporter required by the current module and add
|
||||
//the dependency relations.
|
||||
for (final Class<? extends Exportable> clazz : dependsOn.value()) {
|
||||
for (final Class<? extends Exportable> clazz
|
||||
: imExporter.getRequiredEntities()) {
|
||||
|
||||
addDependencyRelation(nodes, node, clazz);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,12 @@
|
|||
package org.libreccm.security;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
|
@ -48,4 +52,10 @@ public class GroupImExporter extends AbstractEntityImExporter<Group>{
|
|||
groupRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends Exportable>> getRequiredEntities() {
|
||||
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@
|
|||
package org.libreccm.security;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.DependsOn;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
|
@ -31,7 +34,6 @@ import javax.inject.Inject;
|
|||
*/
|
||||
@RequestScoped
|
||||
@Processes(Permission.class)
|
||||
@DependsOn({Role.class})
|
||||
public class PermissionImExporter extends AbstractEntityImExporter<Permission>{
|
||||
|
||||
@Inject
|
||||
|
|
@ -48,6 +50,15 @@ public class PermissionImExporter extends AbstractEntityImExporter<Permission>{
|
|||
permissionRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends Exportable>> getRequiredEntities() {
|
||||
|
||||
final Set<Class<? extends Exportable>> classes = new HashSet<>();
|
||||
classes.add(Role.class);
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,12 @@
|
|||
package org.libreccm.security;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
|
|
@ -45,4 +49,10 @@ public class RoleImExporter extends AbstractEntityImExporter<Role> {
|
|||
roleRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends Exportable>> getRequiredEntities() {
|
||||
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@
|
|||
package org.libreccm.security;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.DependsOn;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.transaction.Transactional;
|
||||
|
|
@ -31,7 +34,6 @@ import javax.transaction.Transactional;
|
|||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Processes(RoleMembership.class)
|
||||
@DependsOn({User.class, Group.class, Role.class})
|
||||
public class RoleMembershipImExporter
|
||||
extends AbstractEntityImExporter<RoleMembership> {
|
||||
|
||||
|
|
@ -51,4 +53,15 @@ public class RoleMembershipImExporter
|
|||
entityManager.persist(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends Exportable>> getRequiredEntities() {
|
||||
|
||||
final Set<Class<? extends Exportable>> classes = new HashSet<>();
|
||||
classes.add(User.class);
|
||||
classes.add(Group.class);
|
||||
classes.add(Role.class);
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,12 @@
|
|||
package org.libreccm.security;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
|
@ -48,4 +52,10 @@ public class UserImExporter extends AbstractEntityImExporter<User> {
|
|||
userRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends Exportable>> getRequiredEntities() {
|
||||
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,12 @@
|
|||
package org.libreccm.web;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
|
@ -50,6 +54,12 @@ public class ApplicationImExporter
|
|||
applicationRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends Exportable>> getRequiredEntities() {
|
||||
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@
|
|||
package org.libreccm.workflow;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.DependsOn;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
|
|
@ -33,7 +36,6 @@ import javax.transaction.Transactional;
|
|||
*/
|
||||
@RequestScoped
|
||||
@Processes(TaskAssignment.class)
|
||||
@DependsOn({AssignableTask.class})
|
||||
public class TaskAssignmentMarshaller
|
||||
extends AbstractEntityImExporter<TaskAssignment> {
|
||||
|
||||
|
|
@ -53,4 +55,13 @@ public class TaskAssignmentMarshaller
|
|||
entityManager.persist(entity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends Exportable>> getRequiredEntities() {
|
||||
|
||||
final Set<Class<? extends Exportable>> classes = new HashSet<>();
|
||||
classes.add(AssignableTask.class);
|
||||
|
||||
return classes;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@
|
|||
package org.libreccm.workflow;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.DependsOn;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
|
@ -32,7 +35,6 @@ import javax.transaction.Transactional;
|
|||
*/
|
||||
@RequestScoped
|
||||
@Processes(TaskComment.class)
|
||||
@DependsOn(AssignableTask.class)
|
||||
public class TaskCommentImExporter extends AbstractEntityImExporter<TaskComment> {
|
||||
|
||||
@Inject
|
||||
|
|
@ -48,4 +50,15 @@ public class TaskCommentImExporter extends AbstractEntityImExporter<TaskComment>
|
|||
protected void saveImportedEntity(TaskComment entity) {
|
||||
taskCommentRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends Exportable>> getRequiredEntities() {
|
||||
|
||||
final Set<Class<? extends Exportable>> classes = new HashSet<>();
|
||||
classes.add(AssignableTask.class);
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@
|
|||
package org.libreccm.workflow;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.DependsOn;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
|
|
@ -33,7 +36,6 @@ import javax.transaction.Transactional;
|
|||
*/
|
||||
@RequestScoped
|
||||
@Processes(TaskDependency.class)
|
||||
@DependsOn({AssignableTask.class})
|
||||
public class TaskDependencyMarshaller
|
||||
extends AbstractEntityImExporter<TaskDependency> {
|
||||
|
||||
|
|
@ -52,4 +54,15 @@ public class TaskDependencyMarshaller
|
|||
entityManager.persist(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends Exportable>> getRequiredEntities() {
|
||||
|
||||
final Set<Class<? extends Exportable>> classes = new HashSet<>();
|
||||
classes.add(AssignableTask.class);
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,12 @@
|
|||
package org.libreccm.workflow;
|
||||
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
|
@ -49,4 +53,10 @@ public class WorkflowImExporter extends AbstractEntityImExporter<Workflow> {
|
|||
workflowRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Class<? extends Exportable>> getRequiredEntities() {
|
||||
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue