diff --git a/ccm-core/src/main/java/org/libreccm/imexport/DependsOn.java b/ccm-core/src/main/java/org/libreccm/imexport/DependsOn.java
new file mode 100644
index 000000000..a3c137bce
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/imexport/DependsOn.java
@@ -0,0 +1,42 @@
+/*
+ * 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 Jens Pelzetter
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE,
+ ElementType.PARAMETER,
+ ElementType.FIELD,
+ ElementType.METHOD})
+public @interface DependsOn {
+
+ Class extends Exportable>[] value();
+
+}
diff --git a/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporter.java b/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporter.java
index 7653cf748..eba225a4a 100644
--- a/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporter.java
+++ b/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporter.java
@@ -35,6 +35,6 @@ public interface EntityImExporter {
T importEntity(JsonObject data);
- JsonObject exportEntity(T entity);
+ JsonObject exportEntity(Exportable entity);
}
diff --git a/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporterTreeManager.java b/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporterTreeManager.java
index 26f6529bc..7d87a75b1 100644
--- a/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporterTreeManager.java
+++ b/ccm-core/src/main/java/org/libreccm/imexport/EntityImExporterTreeManager.java
@@ -77,9 +77,7 @@ final class EntityImExporterTreeManager {
node -> node
.getEntityImExporter()
.getClass()
- .getAnnotation(Processes.class)
- .type()
- .getName(),
+ .getAnnotation(Processes.class).value().getName(),
node -> node));
//Add the dependency relations to the nodes
@@ -199,9 +197,9 @@ final class EntityImExporterTreeManager {
throws DependencyException {
//Get the dependencies of the current EntityImExporter
- final Processes processes = imExporter
+ final DependsOn dependsOn = imExporter
.getClass()
- .getAnnotation(Processes.class);
+ .getAnnotation(DependsOn.class);
//Get the name of the module from the module info.
final String className = imExporter.getClass().getName();
@@ -229,7 +227,7 @@ final class EntityImExporterTreeManager {
className);
//Process the EntityImExporter required by the current module and add
//the dependency relations.
- for (final Class extends Exportable> clazz : processes.dependsOn()) {
+ for (final Class extends Exportable> clazz : dependsOn.value()) {
addDependencyRelation(nodes, node, clazz);
}
@@ -265,8 +263,10 @@ final class EntityImExporterTreeManager {
throw new DependencyException(String.format(
"EntityImExporter for type \"%s\" depends on type \"%s\" "
+ "but no EntityImExporter for type \"%s\" is available.",
- node.getEntityImExporter().getClass().getAnnotation(
- Processes.class).type().getName(),
+ node
+ .getEntityImExporter()
+ .getClass()
+ .getAnnotation(Processes.class).value().getName(),
requiredClass.getName(),
requiredClass.getName()));
}
diff --git a/ccm-core/src/main/java/org/libreccm/imexport/ImportExport.java b/ccm-core/src/main/java/org/libreccm/imexport/ImportExport.java
index 3c81f202e..da8f289a4 100644
--- a/ccm-core/src/main/java/org/libreccm/imexport/ImportExport.java
+++ b/ccm-core/src/main/java/org/libreccm/imexport/ImportExport.java
@@ -22,25 +22,38 @@ import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.files.CcmFiles;
import org.libreccm.files.CcmFilesConfiguration;
import org.libreccm.files.FileAccessException;
+import org.libreccm.files.FileAlreadyExistsException;
import org.libreccm.files.FileDoesNotExistException;
import org.libreccm.files.InsufficientPermissionsException;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Any;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
+
+import javax.enterprise.util.AnnotationLiteral;
import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
import javax.json.JsonReader;
+import javax.json.JsonWriter;
/**
* Central service for importing and exporting entities.
@@ -74,7 +87,121 @@ public class ImportExport {
public void exportEntities(final List entities,
final String exportName) {
- throw new UnsupportedOperationException();
+ final JsonObjectBuilder manifestBuilder = Json.createObjectBuilder();
+ manifestBuilder.add("created",
+ LocalDateTime.now(ZoneId.of("UTC")).toString());
+ try {
+ manifestBuilder.add("onServer",
+ InetAddress.getLocalHost().getHostName());
+ } catch (UnknownHostException ex) {
+ throw new UnexpectedErrorException(ex);
+ }
+
+ final JsonArrayBuilder typesArrayBuilder = Json.createArrayBuilder();
+
+ final Set types = entities
+ .stream()
+ .map(entity -> entity.getClass().getName())
+ .collect(Collectors.toSet());
+
+ final Map> typeEntityMap = new HashMap<>();
+ try {
+ ccmFiles.createDirectory(String.format("exports/%s", exportName));
+
+ for (final String type : types) {
+ ccmFiles.createDirectory(String.format("exports/%s/%s",
+ exportName,
+ type));
+ typesArrayBuilder.add(type);
+
+ final List entitiesOfType = entities
+ .stream()
+ .filter(entity -> entity.getClass().getName().equals(type))
+ .collect(Collectors.toList());
+
+ typeEntityMap.put(type, entitiesOfType);
+ }
+
+ manifestBuilder.add("types", typesArrayBuilder);
+ final OutputStream manifestOutputStream = ccmFiles
+ .createOutputStream(String.format("exports/%s/ccm-export.json",
+ exportName));
+ try (JsonWriter manifestWriter = Json.
+ createWriter(manifestOutputStream)) {
+
+ manifestWriter.writeObject(manifestBuilder.build());
+ }
+
+ } catch (FileAccessException
+ | FileAlreadyExistsException
+ | InsufficientPermissionsException ex) {
+ throw new UnexpectedErrorException(ex);
+ }
+
+ for(final Map.Entry> entry
+ : typeEntityMap.entrySet()) {
+
+ createExportedEntities(exportName,
+ entry.getKey(),
+ entry.getValue());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private JsonArrayBuilder createExportedEntities(
+ final String exportName,
+ final String type,
+ final List entities) {
+
+ final JsonArrayBuilder filesArrayBuilder = Json.createArrayBuilder();
+
+ final Class extends Exportable> clazz;
+ try {
+ clazz = (Class extends Exportable>) Class.forName(type);
+ } catch (ClassNotFoundException ex) {
+ throw new UnexpectedErrorException(ex);
+ }
+
+ final Instance> instance = imExporters
+ .select(new ProcessesLiteral(clazz));
+
+ final EntityImExporter> imExporter;
+ if (instance.isUnsatisfied()) {
+ throw new UnexpectedErrorException(String.format(
+ "No EntityImExporter for entity type \"%s\" available.",
+ type));
+ } else if (instance.isAmbiguous()) {
+ throw new UnexpectedErrorException(String.format(
+ "Instance reference for EntityImExporter for entity "
+ + "type \"%s\" is ambiguous.",
+ type));
+ } else {
+ imExporter = instance.get();
+ }
+
+ for (Exportable entity : entities) {
+
+ final String filename = String.format("%s.json", entity.getUuid());
+ final OutputStream outputStream;
+ try {
+ outputStream = ccmFiles.createOutputStream(String.format(
+ "exports/%s/%s/%s",
+ exportName,
+ type,
+ filename));
+ filesArrayBuilder.add(filename);
+ } catch (FileAccessException
+ | InsufficientPermissionsException ex) {
+ throw new UnexpectedErrorException(ex);
+ }
+
+ final JsonObject exportedEntity = imExporter.exportEntity(entity);
+ try (JsonWriter writer = Json.createWriter(outputStream)) {
+ writer.writeObject(exportedEntity);
+ }
+ }
+
+ return filesArrayBuilder;
}
/**
@@ -122,13 +249,90 @@ public class ImportExport {
final ImportManifest manifest = createImportManifest(importName);
- //ToDo
-
+ final List importers = orderedNodes
+ .stream()
+ .filter(node -> filterImporters(manifest, node))
+ .collect(Collectors.toList());
+
+ importers
+ .stream()
+ .map(EntityImExporterTreeNode::getEntityImExporter)
+ .forEach(imExporter -> importEntitiesOfType(importName,
+ imExporter));
+
+ throw new UnsupportedOperationException();
+
} catch (DependencyException ex) {
throw new UnexpectedErrorException(ex);
}
+ }
- throw new UnsupportedOperationException();
+ private boolean filterImporters(final ImportManifest manifest,
+ final EntityImExporterTreeNode node) {
+
+ final EntityImExporter> imExporter = node.getEntityImExporter();
+ final String type = imExporter
+ .getClass()
+ .getAnnotation(Processes.class).value().getName();
+
+ return manifest.getTypes().contains(type);
+ }
+
+ private void importEntitiesOfType(
+ final String importName,
+ final EntityImExporter> entityImExporter) {
+
+ final String type = entityImExporter
+ .getClass()
+ .getAnnotation(Processes.class).value().getName();
+
+ try (final InputStream tocInputStream = ccmFiles
+ .createInputStream(String.format("imports/%s/%s/%s.json",
+ importName,
+ type,
+ type))) {
+
+ final JsonReader tocReader = Json.createReader(tocInputStream);
+ final JsonObject toc = tocReader.readObject();
+ final JsonArray files = toc.getJsonArray("files");
+
+ files.forEach(value -> importEntity(importName,
+ type,
+ value.toString(),
+ entityImExporter));
+
+ } catch (IOException
+ | FileDoesNotExistException
+ | FileAccessException
+ | InsufficientPermissionsException ex) {
+
+ throw new UnexpectedErrorException(ex);
+ }
+ }
+
+ private void importEntity(final String importName,
+ final String type,
+ final String fileName,
+ final EntityImExporter> imExporter) {
+
+ final String filePath = String.format("imports/%s/%s/%s",
+ importName,
+ type,
+ fileName);
+ try (final InputStream inputStream
+ = ccmFiles.createInputStream(filePath)) {
+
+ final JsonReader reader = Json.createReader(inputStream);
+ final JsonObject data = reader.readObject();
+
+ imExporter.importEntity(data);
+
+ } catch (IOException
+ | FileDoesNotExistException
+ | FileAccessException
+ | InsufficientPermissionsException ex) {
+ throw new UnexpectedErrorException(ex);
+ }
}
@@ -218,6 +422,25 @@ public class ImportExport {
throw new UnexpectedErrorException(ex);
}
+ }
+
+ private static class ProcessesLiteral
+ extends AnnotationLiteral
+ implements Processes {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Class extends Exportable> value;
+
+ private ProcessesLiteral(final Class extends Exportable> value) {
+ this.value = value;
+ }
+
+ @Override
+ public Class extends Exportable> value() {
+
+ return value;
+ }
}
diff --git a/ccm-core/src/main/java/org/libreccm/imexport/Processes.java b/ccm-core/src/main/java/org/libreccm/imexport/Processes.java
index d0dcb5c79..2b9aeab32 100644
--- a/ccm-core/src/main/java/org/libreccm/imexport/Processes.java
+++ b/ccm-core/src/main/java/org/libreccm/imexport/Processes.java
@@ -23,7 +23,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import javax.enterprise.util.Nonbinding;
import javax.inject.Qualifier;
/**
@@ -40,9 +39,6 @@ import javax.inject.Qualifier;
ElementType.METHOD})
public @interface Processes {
- Class extends Exportable> type();
-
- @Nonbinding
- Class extends Exportable>[] dependsOn();
+ Class extends Exportable> value();
}
diff --git a/ccm-core/src/main/java/org/libreccm/security/Party.java b/ccm-core/src/main/java/org/libreccm/security/Party.java
index 3b88763cd..c44444b40 100644
--- a/ccm-core/src/main/java/org/libreccm/security/Party.java
+++ b/ccm-core/src/main/java/org/libreccm/security/Party.java
@@ -95,6 +95,9 @@ public class Party implements Serializable {
@Column(name = "PARTY_ID")
@GeneratedValue(strategy = GenerationType.AUTO)
private long partyId;
+
+ @Column(name = "UUID", unique = true, nullable = false)
+ private String uuid;
/**
* The name of the party. Must only contain the letters a to z and A to Z,
@@ -125,6 +128,14 @@ public class Party implements Serializable {
protected void setPartyId(final long partyId) {
this.partyId = partyId;
}
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ protected void setUuid(final String uuid) {
+ this.uuid = uuid;
+ }
public String getName() {
return name;
diff --git a/ccm-core/src/main/java/org/libreccm/security/PartyRepository.java b/ccm-core/src/main/java/org/libreccm/security/PartyRepository.java
index 33618a992..b0ae59d50 100644
--- a/ccm-core/src/main/java/org/libreccm/security/PartyRepository.java
+++ b/ccm-core/src/main/java/org/libreccm/security/PartyRepository.java
@@ -24,8 +24,10 @@ import org.libreccm.core.CoreConstants;
import javax.enterprise.context.RequestScoped;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
+
import java.util.List;
import java.util.Optional;
+import java.util.UUID;
/**
* Repository class for parties.
@@ -60,6 +62,11 @@ public class PartyRepository extends AbstractEntityRepository {
return entity.getPartyId() == 0;
}
+ @Override
+ public void initNewEntity(final Party party) {
+ party.setUuid(UUID.randomUUID().toString());
+ }
+
/**
* Finds a {@link Party} (which can be a user or group) by its name.
*
diff --git a/ccm-core/src/main/java/org/libreccm/security/User.java b/ccm-core/src/main/java/org/libreccm/security/User.java
index 809ca2354..799903bd3 100644
--- a/ccm-core/src/main/java/org/libreccm/security/User.java
+++ b/ccm-core/src/main/java/org/libreccm/security/User.java
@@ -24,15 +24,46 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.core.EmailAddress;
import org.libreccm.portation.Portable;
-import javax.persistence.*;
import javax.validation.constraints.NotNull;
-import javax.xml.bind.annotation.*;
+
import java.io.Serializable;
-import java.util.*;
import static org.libreccm.core.CoreConstants.CORE_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.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;
+import javax.persistence.ElementCollection;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.NamedAttributeNode;
+import javax.persistence.NamedEntityGraph;
+import javax.persistence.NamedEntityGraphs;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.NamedSubgraph;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
/**
* A user is a person (or a system) accessing CCM. A user authenticates itself
* using a password or other credentials.
@@ -121,7 +152,7 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = UserIdResolver.class,
property = "name")
-public class User extends Party implements Serializable, Portable {
+public class User extends Party implements Serializable, Exportable, Portable {
private static final long serialVersionUID = 4035223413596611393L;
diff --git a/ccm-core/src/main/java/org/libreccm/security/UserImExporter.java b/ccm-core/src/main/java/org/libreccm/security/UserImExporter.java
new file mode 100644
index 000000000..089b78de8
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/security/UserImExporter.java
@@ -0,0 +1,46 @@
+/*
+ * 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.security;
+
+import org.libreccm.imexport.EntityImExporter;
+import org.libreccm.imexport.Exportable;
+import org.libreccm.imexport.Processes;
+
+import javax.enterprise.context.RequestScoped;
+import javax.json.JsonObject;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+@Processes(User.class)
+public class UserImExporter implements EntityImExporter {
+
+ @Override
+ public User importEntity(final JsonObject data) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public JsonObject exportEntity(final Exportable entity) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+}
diff --git a/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_27__add_party_uuid.sql b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_27__add_party_uuid.sql
new file mode 100644
index 000000000..af004e8b2
--- /dev/null
+++ b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_27__add_party_uuid.sql
@@ -0,0 +1,5 @@
+alter table CCM_CORE.PARTIES
+ add column UUID varchar(255) not null;
+
+alter table CCM_CORE.PARTIES
+ add constraint UK_1hv061qace2mn4loroe3fwdel unique (UUID);
\ No newline at end of file
diff --git a/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_27__add_party_uuid.sql b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_27__add_party_uuid.sql
new file mode 100644
index 000000000..af004e8b2
--- /dev/null
+++ b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/pgsql/V7_0_0_27__add_party_uuid.sql
@@ -0,0 +1,5 @@
+alter table CCM_CORE.PARTIES
+ add column UUID varchar(255) not null;
+
+alter table CCM_CORE.PARTIES
+ add constraint UK_1hv061qace2mn4loroe3fwdel unique (UUID);
\ No newline at end of file
diff --git a/ccm-core/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_core_schema.sql b/ccm-core/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_core_schema.sql
index dbe31ce69..2485b44cc 100644
--- a/ccm-core/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_core_schema.sql
+++ b/ccm-core/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_core_schema.sql
@@ -440,6 +440,7 @@ drop sequence if exists HIBERNATE_SEQUENCE;
create table CCM_CORE.PARTIES (
PARTY_ID bigint not null,
NAME varchar(256) not null,
+ UUID varchar(255) not null,
primary key (PARTY_ID)
);
@@ -540,11 +541,11 @@ drop sequence if exists HIBERNATE_SEQUENCE;
SETTING_ID bigint not null,
CONFIGURATION_CLASS varchar(512) not null,
NAME varchar(512) not null,
- SETTING_VALUE_STRING varchar(1024),
- SETTING_VALUE_LONG bigint,
- SETTING_VALUE_BOOLEAN boolean,
- SETTING_VALUE_DOUBLE double,
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
+ SETTING_VALUE_BOOLEAN boolean,
+ SETTING_VALUE_STRING varchar(1024),
+ SETTING_VALUE_DOUBLE double,
+ SETTING_VALUE_LONG bigint,
primary key (SETTING_ID)
);
@@ -776,6 +777,9 @@ drop sequence if exists HIBERNATE_SEQUENCE;
alter table CCM_CORE.INSTALLED_MODULES
add constraint UK_11imwgfojyi4hpr18uw9g3jvx unique (MODULE_CLASS_NAME);
+ alter table CCM_CORE.PARTIES
+ add constraint UK_1hv061qace2mn4loroe3fwdel unique (UUID);
+
alter table CCM_CORE.SETTINGS
add constraint UK5whinfxdaepqs09e5ia9y71uk unique (CONFIGURATION_CLASS, NAME);
diff --git a/ccm-core/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_core_schema.sql b/ccm-core/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_core_schema.sql
index 627cea365..2988482e5 100644
--- a/ccm-core/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_core_schema.sql
+++ b/ccm-core/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_core_schema.sql
@@ -4,7 +4,6 @@ drop sequence if exists HIBERNATE_SEQUENCE;
create schema CCM_CORE;
-
create table CCM_CORE.APPLICATIONS (
APPLICATION_TYPE varchar(1024) not null,
PRIMARY_URL varchar(1024) not null,
@@ -441,6 +440,7 @@ drop sequence if exists HIBERNATE_SEQUENCE;
create table CCM_CORE.PARTIES (
PARTY_ID int8 not null,
NAME varchar(256) not null,
+ UUID varchar(255) not null,
primary key (PARTY_ID)
);
@@ -541,11 +541,11 @@ drop sequence if exists HIBERNATE_SEQUENCE;
SETTING_ID int8 not null,
CONFIGURATION_CLASS varchar(512) not null,
NAME varchar(512) not null,
- SETTING_VALUE_STRING varchar(1024),
- SETTING_VALUE_LONG int8,
- SETTING_VALUE_BOOLEAN boolean,
- SETTING_VALUE_DOUBLE float8,
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
+ SETTING_VALUE_BOOLEAN boolean,
+ SETTING_VALUE_STRING varchar(1024),
+ SETTING_VALUE_DOUBLE float8,
+ SETTING_VALUE_LONG int8,
primary key (SETTING_ID)
);
@@ -777,6 +777,9 @@ drop sequence if exists HIBERNATE_SEQUENCE;
alter table CCM_CORE.INSTALLED_MODULES
add constraint UK_11imwgfojyi4hpr18uw9g3jvx unique (MODULE_CLASS_NAME);
+ alter table CCM_CORE.PARTIES
+ add constraint UK_1hv061qace2mn4loroe3fwdel unique (UUID);
+
alter table CCM_CORE.SETTINGS
add constraint UK5whinfxdaepqs09e5ia9y71uk unique (CONFIGURATION_CLASS, NAME);
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/categorization/CategoryManagerTest/data.yml b/ccm-core/src/test/resources/datasets/org/libreccm/categorization/CategoryManagerTest/data.yml
index 2d7cbf419..41b070f3d 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/categorization/CategoryManagerTest/data.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/categorization/CategoryManagerTest/data.yml
@@ -69,10 +69,13 @@ ccm_core.categorizations:
ccm_core.parties:
- party_id: -3000
+ uuid: 631be113-7e86-453d-9f8b-8cb6cb6df268
name: public-user
- party_id: -3100
+ uuid: 3a61d302-97a5-4e46-bbc9-8d716f7c54c4
name: jdoe
- party_id: -3200
+ uuid: 7d5ad4a7-c2bd-4e49-8716-0bfb40413c75
name: mmuster
ccm_core.users:
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/categorization/CategoryRepositoryTest/after-save-new-category.yml b/ccm-core/src/test/resources/datasets/org/libreccm/categorization/CategoryRepositoryTest/after-save-new-category.yml
index 194a38cfa..b3e97817a 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/categorization/CategoryRepositoryTest/after-save-new-category.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/categorization/CategoryRepositoryTest/after-save-new-category.yml
@@ -56,10 +56,13 @@ ccm_core.category_domains:
ccm_core.parties:
- party_id: -100
+ uuid: 631be113-7e86-453d-9f8b-8cb6cb6df268
name: public-user
- party_id: -200
+ uuid: 3a61d302-97a5-4e46-bbc9-8d716f7c54c4
name: jdoe
- party_id: -300
+ uuid: 7d5ad4a7-c2bd-4e49-8716-0bfb40413c75
name: mmuster
ccm_core.users:
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/categorization/CategoryRepositoryTest/data.yml b/ccm-core/src/test/resources/datasets/org/libreccm/categorization/CategoryRepositoryTest/data.yml
index 3111e67e7..d7309150d 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/categorization/CategoryRepositoryTest/data.yml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/categorization/CategoryRepositoryTest/data.yml
@@ -46,10 +46,13 @@ ccm_core.category_domains:
ccm_core.parties:
- party_id: -100
+ uuid: 631be113-7e86-453d-9f8b-8cb6cb6df268
name: public-user
- party_id: -200
+ uuid: 3a61d302-97a5-4e46-bbc9-8d716f7c54c4
name: jdoe
- party_id: -300
+ uuid: 7d5ad4a7-c2bd-4e49-8716-0bfb40413c75
name: mmuster
ccm_core.users:
diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/ChallengeManagerTest/after-create-account-activation.xml b/ccm-core/src/test/resources/datasets/org/libreccm/security/ChallengeManagerTest/after-create-account-activation.xml
index 5bfeb11d1..daa40bd15 100644
--- a/ccm-core/src/test/resources/datasets/org/libreccm/security/ChallengeManagerTest/after-create-account-activation.xml
+++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/ChallengeManagerTest/after-create-account-activation.xml
@@ -22,8 +22,10 @@
version="1.0"/>