CCM NG: Revised Im/Export system for entities in org.libreccm.categorization
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5707 8810af33-2d31-482b-a856-94f89814c4df
parent
2d6e92ea43
commit
e92e055630
|
|
@ -29,6 +29,9 @@ import java.util.Objects;
|
|||
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
|
@ -52,6 +55,10 @@ import javax.persistence.Table;
|
|||
@Entity
|
||||
@Table(name = "CATEGORIZATIONS", schema = DB_SCHEMA)
|
||||
@NamedQueries({
|
||||
@NamedQuery(
|
||||
name = "Categorization.findByUuid",
|
||||
query = "SELECT c FROM Categorization c WHERE c.uuid = :uuid"
|
||||
),
|
||||
@NamedQuery(
|
||||
name = "Categorization.find",
|
||||
query = "SELECT c FROM Categorization c "
|
||||
|
|
@ -94,9 +101,9 @@ import javax.persistence.Table;
|
|||
+ "WHERE c.category = :category "
|
||||
+ "AND c.indexObject = TRUE")
|
||||
})
|
||||
@JsonIdentityInfo(generator = CategorizationIdGenerator.class,
|
||||
property = "customCatId")
|
||||
public class Categorization implements Serializable, Relation, Portable {
|
||||
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||
property = "uuid")
|
||||
public class Categorization implements Serializable, Relation, Exportable {
|
||||
|
||||
private static final long serialVersionUID = 201504301320L;
|
||||
|
||||
|
|
@ -108,6 +115,9 @@ public class Categorization implements Serializable, Relation, Portable {
|
|||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long categorizationId;
|
||||
|
||||
@Column(name = "UUID", unique = true, nullable = false)
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* The category to which this {@code Categorization} object belongs.
|
||||
*/
|
||||
|
|
@ -126,7 +136,7 @@ public class Categorization implements Serializable, Relation, Portable {
|
|||
|
||||
/**
|
||||
* If the categorised object is the indexObject object of the category this
|
||||
property is set to {@code true}.
|
||||
* property is set to {@code true}.
|
||||
*/
|
||||
@Column(name = "CATEGORY_INDEX")
|
||||
private boolean indexObject;
|
||||
|
|
@ -166,6 +176,15 @@ public class Categorization implements Serializable, Relation, Portable {
|
|||
this.categorizationId = categorizationId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
protected void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
|
@ -195,7 +214,6 @@ public class Categorization implements Serializable, Relation, Portable {
|
|||
// public boolean getIndex() {
|
||||
// return indexObject;
|
||||
// }
|
||||
|
||||
public boolean isIndexObject() {
|
||||
return indexObject;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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.categorization;
|
||||
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
|
||||
* @version created on 3/23/17
|
||||
*/
|
||||
public class CategorizationIdGenerator extends ObjectIdGenerator<String> {
|
||||
private static final long serialVersionUID = 3013739402534056286L;
|
||||
|
||||
@Override
|
||||
public Class<?> getScope() {
|
||||
return Categorization.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUseFor(ObjectIdGenerator<?> gen) {
|
||||
return gen instanceof CategorizationIdGenerator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectIdGenerator<String> forScope(Class<?> scope) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectIdGenerator<String> newForSerialization(Object context) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdKey key(Object key) {
|
||||
if (key == null)
|
||||
return null;
|
||||
return new IdKey(Categorization.class, Categorization.class, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateId(Object forPojo) {
|
||||
if (!(forPojo instanceof Categorization)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Only Categorization instances are supported.");
|
||||
}
|
||||
|
||||
final Categorization categorization = (Categorization) forPojo;
|
||||
|
||||
return String.format("{%s}{%s}",
|
||||
categorization.getCategory().getUuid(),
|
||||
categorization.getCategorizedObject().getUuid());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015 LibreCCM Foundation.
|
||||
* 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
|
||||
|
|
@ -18,37 +18,37 @@
|
|||
*/
|
||||
package org.libreccm.categorization;
|
||||
|
||||
import org.libreccm.portation.AbstractMarshaller;
|
||||
import org.libreccm.portation.Marshals;
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.DependsOn;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
|
||||
* @version created the 8/23/17
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Marshals(DomainOwnership.class)
|
||||
public class DomainOwnershipMarshaller extends AbstractMarshaller<DomainOwnership> {
|
||||
|
||||
private static final long serialVersionUID = 6743023023790517330L;
|
||||
@Processes(Categorization.class)
|
||||
@DependsOn({Category.class})
|
||||
public class CategorizationImExporter
|
||||
extends AbstractEntityImExporter<Categorization> {
|
||||
|
||||
@Inject
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Override
|
||||
protected Class<DomainOwnership> getObjectClass() {
|
||||
return DomainOwnership.class;
|
||||
protected Class<Categorization> getEntityClass() {
|
||||
|
||||
return Categorization.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void insertIntoDb(DomainOwnership portableObject) {
|
||||
if (portableObject.getOwnershipId() == 0) {
|
||||
entityManager.persist(portableObject);
|
||||
} else {
|
||||
entityManager.merge(portableObject);
|
||||
}
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
protected void saveImportedEntity(final Categorization entity) {
|
||||
|
||||
entityManager.persist(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -41,6 +41,8 @@ import java.util.Objects;
|
|||
import static org.libreccm.categorization.CategorizationConstants.CAT_XML_NS;
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
import org.libreccm.imexport.Exportable;
|
||||
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
|
|
@ -148,7 +150,7 @@ import javax.persistence.Table;
|
|||
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||
resolver = CategoryIdResolver.class,
|
||||
property = "uuid")
|
||||
public class Category extends CcmObject implements Serializable, Portable {
|
||||
public class Category extends CcmObject implements Serializable, Exportable {
|
||||
|
||||
private static final long serialVersionUID = -7250208963391878547L;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015 LibreCCM Foundation.
|
||||
* 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
|
||||
|
|
@ -18,35 +18,37 @@
|
|||
*/
|
||||
package org.libreccm.categorization;
|
||||
|
||||
import org.libreccm.portation.AbstractMarshaller;
|
||||
import org.libreccm.portation.Marshals;
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.DependsOn;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
|
||||
* @version created on 11/7/16
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Marshals(Category.class)
|
||||
public class CategoryMarshaller extends AbstractMarshaller<Category> {
|
||||
|
||||
private static final long serialVersionUID = -9089135773302229477L;
|
||||
@Processes(Category.class)
|
||||
@DependsOn({Domain.class})
|
||||
public class CategoryImExporter extends AbstractEntityImExporter<Category> {
|
||||
|
||||
@Inject
|
||||
private CategoryRepository categoryRepository;
|
||||
|
||||
@Override
|
||||
protected Class<Category> getObjectClass() {
|
||||
protected Class<Category> getEntityClass() {
|
||||
|
||||
return Category.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
protected void insertIntoDb(Category portableObject) {
|
||||
categoryRepository.save(portableObject);
|
||||
protected void saveImportedEntity(final Category entity) {
|
||||
|
||||
categoryRepository.save(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -44,6 +44,7 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The {@code CategoryManager} provides several helper methods for managing
|
||||
|
|
@ -138,6 +139,7 @@ public class CategoryManager implements Serializable {
|
|||
category.getObjectId())));
|
||||
|
||||
final Categorization categorization = new Categorization();
|
||||
categorization.setUuid(UUID.randomUUID().toString());
|
||||
categorization.setCategorizedObject(object);
|
||||
categorization.setCategory(assignedCategory);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ import java.io.Serializable;
|
|||
import static org.libreccm.categorization.CategorizationConstants.CAT_XML_NS;
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
import org.libreccm.imexport.Exportable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
|
@ -123,7 +125,7 @@ import javax.persistence.TemporalType;
|
|||
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||
resolver = DomainIdResolver.class,
|
||||
property = "uuid")
|
||||
public class Domain extends CcmObject implements Serializable, Portable {
|
||||
public class Domain extends CcmObject implements Serializable, Exportable {
|
||||
|
||||
private static final long serialVersionUID = 4012590760598188732L;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015 LibreCCM Foundation.
|
||||
* 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
|
||||
|
|
@ -18,33 +18,35 @@
|
|||
*/
|
||||
package org.libreccm.categorization;
|
||||
|
||||
import org.libreccm.portation.AbstractMarshaller;
|
||||
import org.libreccm.portation.Marshals;
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
|
||||
* @version created the 8/22/17
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Marshals(Domain.class)
|
||||
public class DomainMarshaller extends AbstractMarshaller<Domain> {
|
||||
|
||||
private static final long serialVersionUID = -2435714410695539890L;
|
||||
@Processes(Domain.class)
|
||||
public class DomainImExporter extends AbstractEntityImExporter<Domain> {
|
||||
|
||||
@Inject
|
||||
private DomainRepository domainRepository;
|
||||
|
||||
@Override
|
||||
protected Class<Domain> getObjectClass() {
|
||||
protected Class<Domain> getEntityClass() {
|
||||
|
||||
return Domain.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void insertIntoDb(Domain portableObject) {
|
||||
domainRepository.save(portableObject);
|
||||
protected void saveImportedEntity(final Domain entity) {
|
||||
|
||||
domainRepository.save(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -28,9 +28,11 @@ import javax.inject.Inject;
|
|||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Provides several methods when managing the relations between {@link Domain}s
|
||||
|
|
@ -103,6 +105,7 @@ public class DomainManager implements Serializable {
|
|||
public void addDomainOwner(final CcmApplication application,
|
||||
final Domain domain) {
|
||||
final DomainOwnership ownership = new DomainOwnership();
|
||||
ownership.setUuid(UUID.randomUUID().toString());
|
||||
ownership.setDomain(domain);
|
||||
ownership.setOwner(application);
|
||||
ownership.setOwnerOrder(domain.getOwners().size() + 1);
|
||||
|
|
|
|||
|
|
@ -21,15 +21,28 @@ package org.libreccm.categorization;
|
|||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.portation.Portable;
|
||||
import org.libreccm.web.CcmApplication;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import org.libreccm.core.CoreConstants;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
/**
|
||||
* Association class for the association between a {@link Domain} and a
|
||||
* {@link CcmObject}. Instances of this class should not be created manually.
|
||||
|
|
@ -41,14 +54,19 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
|||
@Entity
|
||||
@Table(name = "DOMAIN_OWNERSHIPS", schema = DB_SCHEMA)
|
||||
@NamedQueries({
|
||||
@NamedQuery(
|
||||
name = "DomainOwnership.findByUuid",
|
||||
query = "SELECT o FROM DomainOwnership o WHERE o.uuid = :uuid"
|
||||
)
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "DomainOwnership.findByOwnerAndDomain",
|
||||
query = "SELECT o FROM DomainOwnership o "
|
||||
+ "WHERE o.owner = :owner AND o.domain = :domain")
|
||||
})
|
||||
@JsonIdentityInfo(generator = DomainOwnershipIdGenerator.class,
|
||||
property = "customOwnId")
|
||||
public class DomainOwnership implements Serializable, Portable {
|
||||
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||
property = "uuid")
|
||||
public class DomainOwnership implements Serializable, Exportable {
|
||||
|
||||
private static final long serialVersionUID = 201504301305L;
|
||||
|
||||
|
|
@ -60,6 +78,10 @@ public class DomainOwnership implements Serializable, Portable {
|
|||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long ownershipId;
|
||||
|
||||
@Column(name = "UUID", unique = true, nullable = false)
|
||||
@XmlElement(name = "uuid", namespace = CoreConstants.CORE_XML_NS)
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* The {@link Domain} owned by the {@link CcmObject}.
|
||||
*/
|
||||
|
|
@ -102,6 +124,15 @@ public class DomainOwnership implements Serializable, Portable {
|
|||
this.ownershipId = ownershipId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
protected void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public CcmApplication getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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.categorization;
|
||||
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
|
||||
* @version created the 8/10/17
|
||||
*/
|
||||
public class DomainOwnershipIdGenerator extends ObjectIdGenerator<String> {
|
||||
private static final long serialVersionUID = -5651368736214980681L;
|
||||
|
||||
@Override
|
||||
public Class<?> getScope() {
|
||||
return DomainOwnership.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUseFor(ObjectIdGenerator<?> objectIdGenerator) {
|
||||
return objectIdGenerator instanceof DomainOwnershipIdGenerator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectIdGenerator<String> forScope(Class<?> aClass) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectIdGenerator<String> newForSerialization(Object o) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdKey key(Object key) {
|
||||
if (key == null)
|
||||
return null;
|
||||
return new IdKey(DomainOwnership.class, DomainOwnership.class, key);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateId(Object forPojo) {
|
||||
if (!(forPojo instanceof DomainOwnership)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Only DomainOwnerships instances are supported.");
|
||||
}
|
||||
|
||||
final DomainOwnership domainOwnership = (DomainOwnership) forPojo;
|
||||
|
||||
return String.format("{%s}{%s}",
|
||||
domainOwnership.getDomain().getDomainKey(),
|
||||
domainOwnership.getOwner().getPrimaryUrl());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015 LibreCCM Foundation.
|
||||
* 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
|
||||
|
|
@ -18,40 +18,40 @@
|
|||
*/
|
||||
package org.libreccm.categorization;
|
||||
|
||||
import org.libreccm.portation.AbstractMarshaller;
|
||||
import org.libreccm.portation.Marshals;
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.DependsOn;
|
||||
import org.libreccm.imexport.Processes;
|
||||
import org.libreccm.web.CcmApplication;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.transaction.Transactional;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
|
||||
* @version created on 11/7/16
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Marshals(Categorization.class)
|
||||
public class CategorizationMarshaller extends AbstractMarshaller<Categorization> {
|
||||
|
||||
private static final long serialVersionUID = -4388218720510005447L;
|
||||
@Processes(DomainOwnership.class)
|
||||
@DependsOn({CcmApplication.class, Domain.class})
|
||||
public class DomainOwnershipImExporter
|
||||
extends AbstractEntityImExporter<DomainOwnership>{
|
||||
|
||||
@Inject
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Override
|
||||
protected Class<Categorization> getObjectClass() {
|
||||
return Categorization.class;
|
||||
protected Class<DomainOwnership> getEntityClass() {
|
||||
|
||||
return DomainOwnership.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
protected void insertIntoDb(Categorization portableObject) {
|
||||
if (portableObject.getCategorizationId() == 0) {
|
||||
entityManager.persist(portableObject);
|
||||
} else {
|
||||
entityManager.merge(portableObject);
|
||||
}
|
||||
protected void saveImportedEntity(final DomainOwnership entity) {
|
||||
|
||||
entityManager.persist(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -29,6 +29,8 @@ import java.io.Serializable;
|
|||
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
import org.libreccm.imexport.Exportable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
|
@ -73,7 +75,7 @@ import javax.persistence.TemporalType;
|
|||
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||
resolver = ResourceIdResolver.class,
|
||||
property = "uuid")
|
||||
public class Resource extends CcmObject implements Serializable {
|
||||
public class Resource extends CcmObject implements Serializable, Exportable {
|
||||
|
||||
private static final long serialVersionUID = 7345482620613842781L;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ import java.util.Objects;
|
|||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
import static org.libreccm.web.WebConstants.WEB_XML_NS;
|
||||
|
||||
import org.libreccm.imexport.Exportable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.NamedAttributeNode;
|
||||
|
|
@ -79,7 +81,7 @@ import javax.persistence.Table;
|
|||
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||
resolver = ApplicationIdResolver.class,
|
||||
property = "uuid")
|
||||
public class CcmApplication extends Resource implements Serializable, Portable {
|
||||
public class CcmApplication extends Resource implements Serializable, Portable, Exportable {
|
||||
|
||||
private static final long serialVersionUID = 9205226362368890784L;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
alter table CCM_CORE.DOMAIN_OWNERSHIPS
|
||||
add column UUID varchar(255) not null;
|
||||
|
||||
alter table CCM_CORE.DOMAIN_OWNERSHIPS
|
||||
add constraint UK_j86gai9740v9hshascbsboudb unique (UUID);
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
alter table CCM_CORE.CATEGORIZATIONS
|
||||
add column UUID varchar(255) not null;
|
||||
|
||||
alter table CCM_CORE.CATEGORIZATIONS
|
||||
add constraint UK_da7jus3wn1tr8poyaw9btxbrc unique (UUID);
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
alter table CCM_CORE.DOMAIN_OWNERSHIPS
|
||||
add column UUID varchar(255) not null;
|
||||
|
||||
alter table CCM_CORE.DOMAIN_OWNERSHIPS
|
||||
add constraint UK_j86gai9740v9hshascbsboudb unique (UUID);
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
alter table CCM_CORE.CATEGORIZATIONS
|
||||
add column UUID varchar(255) not null;
|
||||
|
||||
alter table CCM_CORE.CATEGORIZATIONS
|
||||
add constraint UK_da7jus3wn1tr8poyaw9btxbrc unique (UUID);
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -55,18 +55,21 @@ ccm_core.category_domains:
|
|||
|
||||
ccm_core.categorizations:
|
||||
- categorization_id: -10000
|
||||
uuid: 5ace8dbb-2e8a-4bf6-932a-22591be326bf
|
||||
category_id: -2100
|
||||
object_id: -3100
|
||||
object_order: 1
|
||||
category_order: 1
|
||||
category_index: false
|
||||
- categorization_id: -10100
|
||||
uuid: 50780558-5851-4eb2-8398-460173507a1b
|
||||
category_id: -2200
|
||||
object_id: -3300
|
||||
category_order: 1
|
||||
object_order: 1
|
||||
category_index: true
|
||||
- categorization_id: -10200
|
||||
uuid: 05014503-0763-41e3-883c-461721beee6f
|
||||
object_id: -3200
|
||||
category_id: -2100
|
||||
category_order: 1
|
||||
|
|
|
|||
|
|
@ -66,12 +66,14 @@ ccm_core.category_domains:
|
|||
|
||||
ccm_core.categorizations:
|
||||
- categorization_id: -10000
|
||||
uuid: 5ace8dbb-2e8a-4bf6-932a-22591be326bf
|
||||
category_id: -2100
|
||||
object_id: -3100
|
||||
object_order: 1
|
||||
category_order: 1
|
||||
category_index: false
|
||||
- categorization_id: -10100
|
||||
uuid: 50780558-5851-4eb2-8398-460173507a1b
|
||||
category_id: -2200
|
||||
object_id: -3300
|
||||
category_order: 1
|
||||
|
|
|
|||
|
|
@ -99,12 +99,14 @@ ccm_core.category_domains:
|
|||
|
||||
ccm_core.categorizations:
|
||||
- categorization_id: -10000
|
||||
uuid: 5ace8dbb-2e8a-4bf6-932a-22591be326bf
|
||||
category_id: -2100
|
||||
object_id: -3100
|
||||
object_order: 1
|
||||
category_order: 1
|
||||
category_index: false
|
||||
- categorization_id: -10100
|
||||
uuid: 50780558-5851-4eb2-8398-460173507a1b
|
||||
category_id: -2200
|
||||
object_id: -3300
|
||||
category_order: 1
|
||||
|
|
|
|||
|
|
@ -54,9 +54,10 @@ ccm_core.category_domains:
|
|||
version: 1.0
|
||||
|
||||
ccm_core.categorizations:
|
||||
- categorization_id: -10100
|
||||
category_id: -2200
|
||||
object_id: -3300
|
||||
category_order: 1
|
||||
- categorization_id: -10000
|
||||
uuid: 5ace8dbb-2e8a-4bf6-932a-22591be326bf
|
||||
category_id: -2100
|
||||
object_id: -3100
|
||||
object_order: 1
|
||||
category_index: true
|
||||
category_order: 1
|
||||
category_index: false
|
||||
|
|
|
|||
|
|
@ -54,12 +54,14 @@ ccm_core.category_domains:
|
|||
|
||||
ccm_core.categorizations:
|
||||
- categorization_id: -10000
|
||||
uuid: 5ace8dbb-2e8a-4bf6-932a-22591be326bf
|
||||
category_id: -2100
|
||||
object_id: -3100
|
||||
object_order: 1
|
||||
category_order: 1
|
||||
category_index: false
|
||||
- categorization_id: -10100
|
||||
uuid: 50780558-5851-4eb2-8398-460173507a1b
|
||||
category_id: -2200
|
||||
object_id: -3300
|
||||
category_order: 1
|
||||
|
|
|
|||
|
|
@ -55,12 +55,14 @@ ccm_core.category_domains:
|
|||
|
||||
ccm_core.categorizations:
|
||||
- categorization_id: -10000
|
||||
uuid: 5ace8dbb-2e8a-4bf6-932a-22591be326bf
|
||||
category_id: -2100
|
||||
object_id: -3100
|
||||
object_order: 1
|
||||
category_order: 1
|
||||
category_index: false
|
||||
- categorization_id: -10100
|
||||
uuid: 50780558-5851-4eb2-8398-460173507a1b
|
||||
category_id: -2200
|
||||
object_id: -3300
|
||||
category_order: 1
|
||||
|
|
@ -110,70 +112,84 @@ ccm_core.users:
|
|||
|
||||
ccm_core.ccm_roles:
|
||||
- role_id: -4000
|
||||
uuid: cb07e4f7-9a77-41e8-af1a-eed318aed596
|
||||
name: domain_test_category_manager
|
||||
- role_id: -4100
|
||||
uuid: e9d4bb0a-7218-4ecb-a759-d1623b2d5c00
|
||||
name: category_foo_manager
|
||||
|
||||
ccm_core.role_memberships:
|
||||
- membership_id: -5000
|
||||
uuid: a62fab65-94e0-463b-8d51-6f7585e2417c
|
||||
role_id: -4000
|
||||
member_id: -3100
|
||||
- membership_id: 5100
|
||||
uuid: 8fb7b7cc-fe04-4986-93de-73132b94e2fa
|
||||
role_id: -4100
|
||||
member_id: -3200
|
||||
|
||||
ccm_core.permissions:
|
||||
- permission_id: -6000
|
||||
uuid: 1f9cd01d-b04f-4cb8-83b7-502a53b442c9
|
||||
granted_privilege: manage_category
|
||||
grantee_id: -4000
|
||||
object_id: -2000
|
||||
inherited: false
|
||||
- permission_id: -6010
|
||||
uuid: 964ab653-eadf-4c69-b4cb-d90e9834bb81
|
||||
granted_privilege: manage_category
|
||||
grantee_id: -4000
|
||||
object_id: -2100
|
||||
inherited: true
|
||||
inherited_from_id: -2000
|
||||
- permission_id: -6020
|
||||
uuid: c44261af-6522-418d-b7c5-ae3b3dcb02a3
|
||||
granted_privilege: manage_category
|
||||
grantee_id: -4000
|
||||
object_id: -2200
|
||||
inherited: true
|
||||
inherited_from_id: -2000
|
||||
- permission_id: -6100
|
||||
uuid: 8aa98e4d-6fa9-411b-bcb0-3e51bba63a5b
|
||||
granted_privilege: manage_category_objects
|
||||
grantee_id: -4000
|
||||
object_id: -2000
|
||||
inherited: false
|
||||
- permission_id: -6110
|
||||
uuid: 89fe50b0-6f59-4dfd-8520-f9059ad9d629
|
||||
granted_privilege: manage_category_objects
|
||||
grantee_id: -4000
|
||||
object_id: -2100
|
||||
inherited: true
|
||||
inherited_from_id: -2000
|
||||
- permission_id: -6120
|
||||
uuid: 052ea99f-a0de-4d8b-aebd-69ad9680f921
|
||||
granted_privilege: manage_category_objects
|
||||
grantee_id: -4000
|
||||
object_id: -2200
|
||||
inherited: true
|
||||
inherited_from_id: -2000
|
||||
- permission_id: -6200
|
||||
uuid: daf465e7-bfb3-4847-a5f8-2c985f20cbb8
|
||||
granted_privilege: manage_category
|
||||
grantee_id: -4100
|
||||
object_id: -2100
|
||||
inherited: false
|
||||
- permission_id: -6210
|
||||
uuid: 23424b24-fa6f-4e2c-86f6-6c10c4342dd7
|
||||
granted_privilege: manage_category
|
||||
grantee_id: -4100
|
||||
object_id: -2200
|
||||
inherited: true
|
||||
inherited_from_id: -2100
|
||||
- permission_id: -6300
|
||||
uuid: 1b58b9ab-7c8a-402f-9fe5-d5f4af8dfa00
|
||||
granted_privilege: manage_category_objects
|
||||
grantee_id: -4100
|
||||
object_id: -2100
|
||||
inherited: false
|
||||
- permission_id: -6310
|
||||
uuid: 9aafe40c-ce25-4344-bc3f-144a0457191a
|
||||
granted_privilege: manage_category_objects
|
||||
grantee_id: -4100
|
||||
object_id: -2200
|
||||
|
|
|
|||
|
|
@ -95,24 +95,30 @@ ccm_core.users:
|
|||
|
||||
ccm_core.ccm_roles:
|
||||
- role_id: -500
|
||||
uuid: 420f5f60-18a6-4dbe-9160-c730bbe18f45
|
||||
name: category_manager
|
||||
- role_id: -510
|
||||
uuid: 0aeea94d-3d8e-4a50-807b-e3c857038e22
|
||||
name: category_manager_domain_test
|
||||
|
||||
ccm_core.role_memberships:
|
||||
- membership_id: -600
|
||||
uuid: 59bfad40-2bd1-4ddd-91cf-60c51724e29c
|
||||
role_id: -500
|
||||
member_id: -200
|
||||
- membership_id: -610
|
||||
uuid: 192024a9-0489-44a0-940f-725b5579a52d
|
||||
role_id: -510
|
||||
member_id: -300
|
||||
|
||||
ccm_core.permissions:
|
||||
- permission_id: -700
|
||||
uuid: 70e8b64c-505d-48bd-b196-36c10ed2321a
|
||||
granted_privilege: manage_category
|
||||
grantee_id: -500
|
||||
inherited: false
|
||||
- permission_id: -710
|
||||
uuid: 1a798119-a4a4-477b-8092-4423d7185e1b
|
||||
granted_privilege: manage_category
|
||||
grantee_id: -510
|
||||
object_id: -1000
|
||||
|
|
|
|||
|
|
@ -85,24 +85,30 @@ ccm_core.users:
|
|||
|
||||
ccm_core.ccm_roles:
|
||||
- role_id: -500
|
||||
uuid: 420f5f60-18a6-4dbe-9160-c730bbe18f45
|
||||
name: category_manager
|
||||
- role_id: -510
|
||||
uuid: 0aeea94d-3d8e-4a50-807b-e3c857038e22
|
||||
name: category_manager_domain_test
|
||||
|
||||
ccm_core.role_memberships:
|
||||
- membership_id: -600
|
||||
uuid: 59bfad40-2bd1-4ddd-91cf-60c51724e29c
|
||||
role_id: -500
|
||||
member_id: -200
|
||||
- membership_id: -610
|
||||
uuid: 192024a9-0489-44a0-940f-725b5579a52d
|
||||
role_id: -510
|
||||
member_id: -300
|
||||
|
||||
ccm_core.permissions:
|
||||
- permission_id: -700
|
||||
uuid: 70e8b64c-505d-48bd-b196-36c10ed2321a
|
||||
granted_privilege: manage_category
|
||||
grantee_id: -500
|
||||
inherited: false
|
||||
- permission_id: -710
|
||||
uuid: 1a798119-a4a4-477b-8092-4423d7185e1b
|
||||
granted_privilege: manage_category
|
||||
grantee_id: -510
|
||||
object_id: -1000
|
||||
|
|
|
|||
Loading…
Reference in New Issue