migration changes
This commit is contained in:
parent
8536d8d03a
commit
08ea46f79b
|
@ -1,31 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>eu.eudat</groupId>
|
|
||||||
<artifactId>dmp-backend</artifactId>
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<source>17</source>
|
|
||||||
<target>17</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,43 +0,0 @@
|
||||||
package eu.old.eudat.commons.enums;
|
|
||||||
|
|
||||||
public enum DescriptionTemplateTypeStatus {
|
|
||||||
|
|
||||||
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
|
|
||||||
|
|
||||||
private final short value;
|
|
||||||
|
|
||||||
DescriptionTemplateTypeStatus(short value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DescriptionTemplateTypeStatus fromInteger(int value) {
|
|
||||||
switch (value) {
|
|
||||||
case 0:
|
|
||||||
return SAVED;
|
|
||||||
case 1:
|
|
||||||
return FINALIZED;
|
|
||||||
case 99:
|
|
||||||
return DELETED;
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Unsupported Description Template Type Status");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DescriptionTemplateTypeStatus fromLabel(String value) {
|
|
||||||
switch (value) {
|
|
||||||
case "SAVED":
|
|
||||||
return SAVED;
|
|
||||||
case "FINALISED":
|
|
||||||
return FINALIZED;
|
|
||||||
case "DELETED":
|
|
||||||
return DELETED;
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Unsupported Description Template Type Status");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package eu.old.eudat.configurations.typedefinition;
|
|
||||||
|
|
||||||
public enum DataType {
|
|
||||||
TINY,
|
|
||||||
SHORT,
|
|
||||||
INTEGER,
|
|
||||||
LONG,
|
|
||||||
DOUBLE,
|
|
||||||
FLOAT,
|
|
||||||
DATE,
|
|
||||||
STRING,
|
|
||||||
TEXT
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package eu.old.eudat.configurations.typedefinition;
|
|
||||||
|
|
||||||
public interface DatabaseColumnType {
|
|
||||||
public String getType(DataType dt);
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package eu.old.eudat.configurations.typedefinition;
|
|
||||||
|
|
||||||
public class PostgreSQLDatabaseColumnType implements DatabaseColumnType {
|
|
||||||
|
|
||||||
public String getType(DataType dt) {
|
|
||||||
switch (dt) {
|
|
||||||
case TINY:
|
|
||||||
case SHORT:
|
|
||||||
case INTEGER:
|
|
||||||
return "integer";
|
|
||||||
case LONG:
|
|
||||||
return "bigint";
|
|
||||||
case FLOAT:
|
|
||||||
case DOUBLE:
|
|
||||||
return "numeric";
|
|
||||||
case DATE:
|
|
||||||
return "timestamp";
|
|
||||||
case STRING:
|
|
||||||
return "character varying(250)";
|
|
||||||
case TEXT:
|
|
||||||
return "text";
|
|
||||||
}
|
|
||||||
return "character varying(250)";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package eu.old.eudat.configurations.typedefinition;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Types;
|
|
||||||
|
|
||||||
public class PostgreSQLEnumType extends org.hibernate.type.EnumType {
|
|
||||||
|
|
||||||
public void nullSafeSet(
|
|
||||||
PreparedStatement st,
|
|
||||||
Object value,
|
|
||||||
int index,
|
|
||||||
SharedSessionContractImplementor session)
|
|
||||||
throws HibernateException, SQLException {
|
|
||||||
st.setObject(
|
|
||||||
index,
|
|
||||||
value != null ?
|
|
||||||
((Enum) value).name() :
|
|
||||||
null,
|
|
||||||
Types.OTHER
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,113 +0,0 @@
|
||||||
package eu.old.eudat.configurations.typedefinition;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|
||||||
import org.hibernate.usertype.UserType;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Types;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Currently not used
|
|
||||||
*/
|
|
||||||
public class UUIDType implements UserType<UUID> {
|
|
||||||
private final int[] sqlTypesSupported = new int[]{Types.NUMERIC};
|
|
||||||
private final String CAST_EXCEPTION_TEXT = " cannot be cast to a java.util.UUID";
|
|
||||||
|
|
||||||
public int[] sqlTypes() {
|
|
||||||
return sqlTypesSupported;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSqlType() {
|
|
||||||
return sqlTypesSupported[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<UUID> returnedClass() {
|
|
||||||
return UUID.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(UUID x, UUID y) throws HibernateException {
|
|
||||||
if (x == null) return y == null;
|
|
||||||
else return x.equals(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode(UUID x) throws HibernateException {
|
|
||||||
return x == null ? -1 : x.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
|
||||||
assert (names.length == 1);
|
|
||||||
Object value = rs.getObject(names[0]);
|
|
||||||
if (value == null) return null;
|
|
||||||
|
|
||||||
UUID uuid = UUID.fromString(rs.getString(names[0]));
|
|
||||||
return rs.wasNull() ? null : uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
|
||||||
if (value == null) {
|
|
||||||
st.setNull(index, Types.NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!UUID.class.isAssignableFrom(value.getClass()))
|
|
||||||
throw new HibernateException(value.getClass().toString() + CAST_EXCEPTION_TEXT);
|
|
||||||
|
|
||||||
UUID uuid = (UUID) value;
|
|
||||||
st.setObject(index, uuid, Types.OTHER);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID deepCopy(UUID value) throws HibernateException {
|
|
||||||
if (value == null) return null;
|
|
||||||
return new UUID(value.getMostSignificantBits(), value.getLeastSignificantBits());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMutable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Serializable disassemble(UUID value) throws HibernateException {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID assemble(Serializable cached, Object owner) throws HibernateException {
|
|
||||||
return (UUID) cached;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID replace(UUID original, Object target, Object owner) throws HibernateException {
|
|
||||||
return original;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
|
||||||
// throws HibernateException, SQLException
|
|
||||||
// {
|
|
||||||
// return nullSafeGet(rs, names, owner);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
|
|
||||||
// throws HibernateException, SQLException
|
|
||||||
// {
|
|
||||||
// nullSafeSet(st, value, index);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
|
|
||||||
throws HibernateException, SQLException {
|
|
||||||
return nullSafeGet(rs, names, owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, UUID value, int index, SharedSessionContractImplementor session)
|
|
||||||
throws HibernateException, SQLException {
|
|
||||||
nullSafeSet(st, value, index);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,93 +0,0 @@
|
||||||
package eu.old.eudat.configurations.typedefinition;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|
||||||
import org.hibernate.usertype.UserType;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Types;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store and retrieve a PostgreSQL "xml" column as a Java string.
|
|
||||||
*/
|
|
||||||
public class XMLType implements UserType<String> {
|
|
||||||
|
|
||||||
private final int[] sqlTypesSupported = new int[]{Types.VARCHAR};
|
|
||||||
|
|
||||||
public int[] sqlTypes() {
|
|
||||||
return sqlTypesSupported;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSqlType() {
|
|
||||||
return sqlTypesSupported[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<String> returnedClass() {
|
|
||||||
return String.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(String x, String y) throws HibernateException {
|
|
||||||
if (x == null) {
|
|
||||||
return y == null;
|
|
||||||
} else {
|
|
||||||
return x.equals(y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode(String x) throws HibernateException {
|
|
||||||
return x == null ? -1 : x.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String nullSafeGet(ResultSet resultSet, int i, SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws SQLException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
|
||||||
assert (names.length == 1);
|
|
||||||
String xmldoc = rs.getString(names[0]);
|
|
||||||
return rs.wasNull() ? null : xmldoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
|
||||||
if (value == null) {
|
|
||||||
st.setNull(index, Types.OTHER);
|
|
||||||
} else {
|
|
||||||
st.setObject(index, value, Types.OTHER);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String deepCopy(String value) throws HibernateException {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMutable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Serializable disassemble(String value) throws HibernateException {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String assemble(Serializable cached, Object owner) throws HibernateException {
|
|
||||||
return (String) cached;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String replace(String original, String target, Object owner) throws HibernateException {
|
|
||||||
return original;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
|
|
||||||
throws HibernateException, SQLException {
|
|
||||||
return nullSafeGet(rs, names, owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, String value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
|
|
||||||
nullSafeSet(st, value, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package eu.old.eudat.convention;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public interface ConventionService {
|
|
||||||
|
|
||||||
Boolean isValidId(Integer id);
|
|
||||||
|
|
||||||
Boolean isValidGuid(UUID guid);
|
|
||||||
|
|
||||||
Boolean isValidUUID(String str);
|
|
||||||
UUID parseUUIDSafe(String str);
|
|
||||||
|
|
||||||
Boolean isValidHash(String hash);
|
|
||||||
|
|
||||||
String hashValue(Object value);
|
|
||||||
|
|
||||||
String limit(String text, int maxLength);
|
|
||||||
|
|
||||||
String truncate(String text, int maxLength);
|
|
||||||
|
|
||||||
UUID getEmptyUUID();
|
|
||||||
|
|
||||||
boolean isNullOrEmpty(String value);
|
|
||||||
|
|
||||||
boolean isListNullOrEmpty(List<?> value);
|
|
||||||
|
|
||||||
String stringEmpty();
|
|
||||||
|
|
||||||
String asPrefix(String name);
|
|
||||||
|
|
||||||
String asIndexerPrefix(String part);
|
|
||||||
|
|
||||||
String asIndexer(String... names);
|
|
||||||
|
|
||||||
<K, V> Map<K, List<V>> toDictionaryOfList(List<V> items, Function<V, K> keySelector);
|
|
||||||
}
|
|
|
@ -1,150 +0,0 @@
|
||||||
package eu.old.eudat.convention;
|
|
||||||
|
|
||||||
import eu.old.eudat.errorcode.ErrorThesaurusProperties;
|
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
|
||||||
import gr.cite.tools.logging.LoggerService;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
|
|
||||||
public class ConventionServiceImpl implements ConventionService {
|
|
||||||
private final static Pattern UUID_REGEX_PATTERN = Pattern.compile("^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$");
|
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ConventionServiceImpl.class));
|
|
||||||
private final ErrorThesaurusProperties errors;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public ConventionServiceImpl(ErrorThesaurusProperties errors) {
|
|
||||||
this.errors = errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Boolean isValidId(Integer id) {
|
|
||||||
return id != null && id > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Boolean isValidGuid(UUID guid) {
|
|
||||||
return guid != null && !guid.equals(this.getEmptyUUID());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Boolean isValidUUID(String str) {
|
|
||||||
if (this.isNullOrEmpty(str)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return UUID_REGEX_PATTERN.matcher(str).matches();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID parseUUIDSafe(String str) {
|
|
||||||
if (!this.isValidUUID(str)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return UUID.fromString(str);
|
|
||||||
} catch (Exception ex){
|
|
||||||
logger.warn("invalid uuid" + str, ex);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Boolean isValidHash(String hash) {
|
|
||||||
return !this.isNullOrEmpty(hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String hashValue(Object value) throws MyApplicationException {
|
|
||||||
if (value == null) return this.stringEmpty();
|
|
||||||
if (value instanceof Instant) return String.format("%ts", (Instant) value);
|
|
||||||
throw new MyApplicationException(this.errors.getSystemError().getCode(), this.errors.getSystemError().getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String limit(String text, int maxLength) {
|
|
||||||
if (this.isNullOrEmpty(text)) return text;
|
|
||||||
if (text.length() > maxLength) return String.format("%s...", text.substring(0, maxLength));
|
|
||||||
else return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String truncate(String text, int maxLength) {
|
|
||||||
String truncated = text;
|
|
||||||
if (text.length() < maxLength) return text;
|
|
||||||
|
|
||||||
truncated = truncated.trim();
|
|
||||||
truncated = truncated.replaceAll("\\s+", " ");//remove multiple spaces
|
|
||||||
if (truncated.length() < maxLength) return truncated;
|
|
||||||
truncated = truncated.replaceAll("([.!@#$%^&-=':;,<>?*\"/|])+", "");//remove multiple spaces
|
|
||||||
if (truncated.length() < maxLength) return truncated;
|
|
||||||
truncated = truncated.replaceAll("([aeiou])+", "");//remove multiple spaces
|
|
||||||
if (truncated.length() < maxLength) return truncated;
|
|
||||||
truncated = truncated.replaceAll("([AEIOU])+", "");//remove multiple spaces
|
|
||||||
if (truncated.length() < maxLength) return truncated;
|
|
||||||
|
|
||||||
if (text.length() > maxLength) return String.format("%s...", text.substring(0, maxLength));
|
|
||||||
return text;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getEmptyUUID() {
|
|
||||||
return new UUID(0L, 0L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isNullOrEmpty(String value) {
|
|
||||||
return value == null || value.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isListNullOrEmpty(List<?> value) {
|
|
||||||
if(value == null) return true;
|
|
||||||
return value.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String stringEmpty() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String asPrefix(String name) {
|
|
||||||
if (name == null) return null;
|
|
||||||
return name + ".";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String asIndexer(String... names) {
|
|
||||||
if (names == null) return null;
|
|
||||||
return String.join(".", Arrays.stream(names).filter(x -> !this.isNullOrEmpty(x)).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String asIndexerPrefix(String part) {
|
|
||||||
if (part == null) return null;
|
|
||||||
return part + ".";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <K, V> Map<K, List<V>> toDictionaryOfList(List<V> items, Function<V, K> keySelector) {
|
|
||||||
Map<K, List<V>> map = new HashMap<>();
|
|
||||||
for (V model : items) {
|
|
||||||
K key = keySelector.apply(model);
|
|
||||||
if (!map.containsKey(key)) map.put(key, new ArrayList<V>());
|
|
||||||
map.get(key).add(model);
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package eu.old.eudat.data;
|
|
||||||
|
|
||||||
public interface BaseEntity {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package eu.old.eudat.data;
|
|
||||||
|
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "DescriptionTemplateType")
|
|
||||||
public class DescriptionTemplateTypeEntity implements BaseEntity {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
|
||||||
@Column(name = "ID", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
public static final String _id = "ID";
|
|
||||||
|
|
||||||
@Column(name = "Name", nullable = false)
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public static final String _name = "Name";
|
|
||||||
|
|
||||||
@Column(name = "Status", nullable = false)
|
|
||||||
private Short status;
|
|
||||||
|
|
||||||
public static final String _status = "Status";
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Short getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(Short status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package eu.old.eudat.errorcode;
|
|
||||||
|
|
||||||
public class ErrorDescription {
|
|
||||||
|
|
||||||
private int code;
|
|
||||||
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
public int getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(int code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package eu.old.eudat.errorcode;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableConfigurationProperties(ErrorThesaurusProperties.class)
|
|
||||||
public class ErrorThesaurusConfiguration {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
package eu.old.eudat.errorcode;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
@ConfigurationProperties(prefix = "error-thesaurus")
|
|
||||||
public class ErrorThesaurusProperties {
|
|
||||||
|
|
||||||
private ErrorDescription systemError;
|
|
||||||
|
|
||||||
public ErrorDescription getSystemError() {
|
|
||||||
return systemError;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSystemError(ErrorDescription systemError) {
|
|
||||||
this.systemError = systemError;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ErrorDescription forbidden;
|
|
||||||
|
|
||||||
public ErrorDescription getForbidden() {
|
|
||||||
return forbidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setForbidden(ErrorDescription forbidden) {
|
|
||||||
this.forbidden = forbidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ErrorDescription hashConflict;
|
|
||||||
|
|
||||||
public ErrorDescription getHashConflict() {
|
|
||||||
return hashConflict;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHashConflict(ErrorDescription hashConflict) {
|
|
||||||
this.hashConflict = hashConflict;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ErrorDescription modelValidation;
|
|
||||||
|
|
||||||
public ErrorDescription getModelValidation() {
|
|
||||||
return modelValidation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModelValidation(ErrorDescription modelValidation) {
|
|
||||||
this.modelValidation = modelValidation;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package eu.old.eudat.model;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class DescriptionTemplateType {
|
|
||||||
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
private short status;
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(short status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,96 +0,0 @@
|
||||||
package eu.old.eudat.model.builder;
|
|
||||||
|
|
||||||
import eu.old.eudat.convention.ConventionService;
|
|
||||||
import gr.cite.tools.data.builder.Builder;
|
|
||||||
import gr.cite.tools.data.query.QueryBase;
|
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
|
||||||
import gr.cite.tools.logging.LoggerService;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public abstract class BaseBuilder<M, D> implements Builder {
|
|
||||||
|
|
||||||
protected final LoggerService logger;
|
|
||||||
|
|
||||||
protected final ConventionService conventionService;
|
|
||||||
|
|
||||||
public BaseBuilder(
|
|
||||||
ConventionService conventionService,
|
|
||||||
LoggerService logger
|
|
||||||
) {
|
|
||||||
this.conventionService = conventionService;
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public M build(FieldSet directives, D data) {
|
|
||||||
if (data == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
List<M> models = this.build(directives == null ? getFullFieldSet() : directives, List.of(data));
|
|
||||||
return models.stream().findFirst().orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract List<M> build(FieldSet directives, List<D> data);
|
|
||||||
|
|
||||||
public abstract FieldSet getFullFieldSet();
|
|
||||||
|
|
||||||
public <K> Map<K, M> asForeignKey(QueryBase<D> query, FieldSet directives, Function<M, K> keySelector) {
|
|
||||||
this.logger.trace("Building references from query");
|
|
||||||
List<D> data = query.collectAs(directives);
|
|
||||||
this.logger.trace("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
|
|
||||||
return this.asForeignKey(data, directives, keySelector);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <K> Map<K, M> asForeignKey(List<D> data, FieldSet directives, Function<M, K> keySelector) {
|
|
||||||
this.logger.trace("building references");
|
|
||||||
List<M> models = this.build(directives, data);
|
|
||||||
this.logger.trace("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
|
||||||
assert models != null;
|
|
||||||
return models.stream().collect(Collectors.toMap(keySelector, o -> o));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <K> Map<K, List<M>> asMasterKey(QueryBase<D> query, FieldSet directives, Function<M, K> keySelector) {
|
|
||||||
this.logger.trace("Building details from query");
|
|
||||||
List<D> data = query.collectAs(directives);
|
|
||||||
this.logger.trace("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
|
|
||||||
return this.asMasterKey(data, directives, keySelector);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <K> Map<K, List<M>> asMasterKey(List<D> data, FieldSet directives, Function<M, K> keySelector) {
|
|
||||||
this.logger.trace("building details");
|
|
||||||
List<M> models = this.build(directives, data);
|
|
||||||
this.logger.trace("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
|
||||||
Map<K, List<M>> map = new HashMap<>();
|
|
||||||
assert models != null;
|
|
||||||
for (M model : models) {
|
|
||||||
K key = keySelector.apply(model);
|
|
||||||
if (!map.containsKey(key))
|
|
||||||
map.put(key, new ArrayList<M>());
|
|
||||||
map.get(key).add(model);
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <FK, FM> Map<FK, FM> asEmpty(List<FK> keys, Function<FK, FM> mapper, Function<FM, FK> keySelector) {
|
|
||||||
this.logger.trace("building static references");
|
|
||||||
List<FM> models = keys.stream().map(mapper).collect(Collectors.toList());
|
|
||||||
this.logger.trace("mapping {} build items from {} requested", Optional.of(models).map(List::size).orElse(0), Optional.of(keys).map(List::size));
|
|
||||||
return models.stream().collect(Collectors.toMap(keySelector, o -> o));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String hashValue(Instant value) {
|
|
||||||
return this.conventionService.hashValue(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String asPrefix(String name) {
|
|
||||||
return this.conventionService.asPrefix(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String asIndexer(String... names) {
|
|
||||||
return this.conventionService.asIndexer(names);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
package eu.old.eudat.model.builder;
|
|
||||||
|
|
||||||
import eu.old.eudat.convention.ConventionService;
|
|
||||||
import eu.old.eudat.data.DescriptionTemplateTypeEntity;
|
|
||||||
import eu.old.eudat.model.DescriptionTemplateType;
|
|
||||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
|
||||||
import gr.cite.tools.logging.LoggerService;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class DescriptionTemplateTypeBuilder extends BaseBuilder<DescriptionTemplateType, DescriptionTemplateTypeEntity> {
|
|
||||||
|
|
||||||
public DescriptionTemplateTypeBuilder(ConventionService conventionService) {
|
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeBuilder.class)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<DescriptionTemplateType> build(FieldSet directives, List<DescriptionTemplateTypeEntity> data) {
|
|
||||||
if (directives == null || directives.isEmpty())
|
|
||||||
return new ArrayList<>();
|
|
||||||
|
|
||||||
List<DescriptionTemplateType> models = new ArrayList<>(100);
|
|
||||||
|
|
||||||
if (data == null)
|
|
||||||
return models;
|
|
||||||
for (DescriptionTemplateTypeEntity d : data) {
|
|
||||||
DescriptionTemplateType m = new DescriptionTemplateType();
|
|
||||||
if (directives.hasField(this.asIndexer(DescriptionTemplateTypeEntity._id)))
|
|
||||||
m.setId(d.getId());
|
|
||||||
if (directives.hasField(this.asIndexer(DescriptionTemplateTypeEntity._name)))
|
|
||||||
m.setName(d.getName());
|
|
||||||
if (directives.hasField(this.asIndexer(DescriptionTemplateTypeEntity._status)))
|
|
||||||
m.setStatus(d.getStatus());
|
|
||||||
models.add(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
return models;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldSet getFullFieldSet() {
|
|
||||||
BaseFieldSet fieldSet = new BaseFieldSet();
|
|
||||||
fieldSet.setFields(Set.of(
|
|
||||||
DescriptionTemplateTypeEntity._id,
|
|
||||||
DescriptionTemplateTypeEntity._name,
|
|
||||||
DescriptionTemplateTypeEntity._status
|
|
||||||
));
|
|
||||||
return fieldSet;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
package eu.old.eudat.model.result;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class QueryResult<M> {
|
|
||||||
|
|
||||||
public QueryResult() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueryResult(List<M> items, long count, long countOverride) {
|
|
||||||
this.items = items;
|
|
||||||
this.count = count;
|
|
||||||
this.countOverride = countOverride;
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueryResult(List<M> items, long count) {
|
|
||||||
this.items = items;
|
|
||||||
this.count = count;
|
|
||||||
this.countOverride = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueryResult(M item) {
|
|
||||||
this.items = List.of(item);
|
|
||||||
this.count = 1;
|
|
||||||
this.countOverride = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueryResult(List<M> items) {
|
|
||||||
this.items = items;
|
|
||||||
if (items != null)
|
|
||||||
this.count = items.size();
|
|
||||||
else
|
|
||||||
this.count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<M> items;
|
|
||||||
|
|
||||||
private long count;
|
|
||||||
|
|
||||||
private long countOverride;
|
|
||||||
|
|
||||||
public List<M> getItems() {
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItems(List<M> items) {
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCount() {
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCount(long count) {
|
|
||||||
this.count = count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCountOverride() {
|
|
||||||
return countOverride;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCountOverride(long countOverride) {
|
|
||||||
this.countOverride = countOverride;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static QueryResult<?> empty() {
|
|
||||||
return new QueryResult<>(new ArrayList<>(), 0L);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,132 +0,0 @@
|
||||||
package eu.old.eudat.query;
|
|
||||||
|
|
||||||
import eu.old.eudat.commons.enums.DescriptionTemplateTypeStatus;
|
|
||||||
import eu.old.eudat.data.DescriptionTemplateTypeEntity;
|
|
||||||
import eu.old.eudat.query.lookup.DescriptionTemplateTypeLookup;
|
|
||||||
import eu.old.eudat.query.lookup.LookupAware;
|
|
||||||
import gr.cite.tools.data.query.FieldResolver;
|
|
||||||
import gr.cite.tools.data.query.QueryBase;
|
|
||||||
import gr.cite.tools.data.query.QueryContext;
|
|
||||||
import jakarta.persistence.Tuple;
|
|
||||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
|
||||||
import jakarta.persistence.criteria.Predicate;
|
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
||||||
public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateTypeEntity> implements LookupAware<DescriptionTemplateTypeQuery, DescriptionTemplateTypeLookup> {
|
|
||||||
|
|
||||||
private Collection<UUID> ids;
|
|
||||||
|
|
||||||
private Collection<String> names;
|
|
||||||
|
|
||||||
private Collection<Short> statuses;
|
|
||||||
|
|
||||||
public DescriptionTemplateTypeQuery ids(UUID value) {
|
|
||||||
this.ids = List.of(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionTemplateTypeQuery ids(UUID... value) {
|
|
||||||
this.ids = Arrays.asList(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionTemplateTypeQuery ids(List<UUID> value) {
|
|
||||||
this.ids = value;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionTemplateTypeQuery names(String value) {
|
|
||||||
this.names = List.of(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionTemplateTypeQuery names(String... value) {
|
|
||||||
this.names = Arrays.asList(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionTemplateTypeQuery names(List<String> value) {
|
|
||||||
this.names = value;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionTemplateTypeQuery statuses(Short value) {
|
|
||||||
this.statuses = List.of(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionTemplateTypeQuery statuses(Short... value) {
|
|
||||||
this.statuses = Arrays.asList(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionTemplateTypeQuery statuses(List<Short> value) {
|
|
||||||
this.statuses = value;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DescriptionTemplateTypeQuery fromLookup(DescriptionTemplateTypeLookup lookup) {
|
|
||||||
if (lookup == null) return this;
|
|
||||||
if (lookup.getName() != null) names(lookup.getName());
|
|
||||||
if (lookup.getStatus() != null) statuses(DescriptionTemplateTypeStatus.fromLabel(lookup.getStatus()).getValue());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Boolean isFalseQuery() {
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Class<DescriptionTemplateTypeEntity> entityClass() {
|
|
||||||
return DescriptionTemplateTypeEntity.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
|
||||||
List<Predicate> predicates = new ArrayList<>();
|
|
||||||
|
|
||||||
if (this.ids != null) {
|
|
||||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._id));
|
|
||||||
for (UUID item : this.ids) inClause.value(item);
|
|
||||||
predicates.add(inClause);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.names != null) {
|
|
||||||
CriteriaBuilder.In<String> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._name));
|
|
||||||
for (String item : this.names) inClause.value(item);
|
|
||||||
predicates.add(inClause);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.statuses != null) {
|
|
||||||
CriteriaBuilder.In<Short> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._status));
|
|
||||||
for (Short item : this.statuses) inClause.value(item);
|
|
||||||
predicates.add(inClause);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!predicates.isEmpty()) {
|
|
||||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
|
||||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
|
||||||
} else {
|
|
||||||
return queryContext.CriteriaBuilder.and();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String fieldNameOf(FieldResolver item) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected DescriptionTemplateTypeEntity convert(Tuple tuple, Set<String> columns) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package eu.old.eudat.query.lookup;
|
|
||||||
|
|
||||||
import gr.cite.tools.data.query.Lookup;
|
|
||||||
|
|
||||||
public class DescriptionTemplateTypeLookup extends Lookup {
|
|
||||||
|
|
||||||
private String name, status;
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(String status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package eu.old.eudat.query.lookup;
|
|
||||||
|
|
||||||
public interface LookupAware<Q, L> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Every query that supports building from a lookup object should implement this interface
|
|
||||||
* @param lookup The object containing all the lookup options
|
|
||||||
* @return The query built from all the set options
|
|
||||||
*/
|
|
||||||
Q fromLookup(L lookup);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,101 +0,0 @@
|
||||||
package eu.old.eudat.service;
|
|
||||||
|
|
||||||
import eu.old.eudat.commons.enums.DescriptionTemplateTypeStatus;
|
|
||||||
import eu.old.eudat.data.DescriptionTemplateTypeEntity;
|
|
||||||
import eu.old.eudat.model.DescriptionTemplateType;
|
|
||||||
import eu.old.eudat.model.builder.DescriptionTemplateTypeBuilder;
|
|
||||||
import eu.old.eudat.query.DescriptionTemplateTypeQuery;
|
|
||||||
import eu.old.eudat.query.lookup.DescriptionTemplateTypeLookup;
|
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
|
||||||
import org.springframework.transaction.TransactionDefinition;
|
|
||||||
import org.springframework.transaction.TransactionStatus;
|
|
||||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
||||||
|
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
import jakarta.persistence.PersistenceContext;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class DescriptionTemplateTypeService {
|
|
||||||
|
|
||||||
private final ApplicationContext applicationContext;
|
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
|
||||||
|
|
||||||
private final PlatformTransactionManager transactionManager;
|
|
||||||
|
|
||||||
@PersistenceContext
|
|
||||||
private EntityManager entityManager;
|
|
||||||
|
|
||||||
public DescriptionTemplateTypeService(ApplicationContext applicationContext, BuilderFactory builderFactory, PlatformTransactionManager platformTransactionManager) {
|
|
||||||
this.applicationContext = applicationContext;
|
|
||||||
this.builderFactory = builderFactory;
|
|
||||||
this.transactionManager = platformTransactionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DescriptionTemplateType> getAll(DescriptionTemplateTypeLookup lookup) {
|
|
||||||
DescriptionTemplateTypeQuery query = applicationContext.getBean(DescriptionTemplateTypeQuery.class);
|
|
||||||
return builderFactory
|
|
||||||
.builder(DescriptionTemplateTypeBuilder.class)
|
|
||||||
.build(lookup.getProject(), query.fromLookup(lookup).collect());
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionTemplateType getById(UUID id) {
|
|
||||||
DescriptionTemplateTypeQuery query = applicationContext.getBean(DescriptionTemplateTypeQuery.class);
|
|
||||||
return builderFactory
|
|
||||||
.builder(DescriptionTemplateTypeBuilder.class)
|
|
||||||
.build(null, query.ids(id).first());
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionTemplateType create(DescriptionTemplateType payload) {
|
|
||||||
DescriptionTemplateTypeEntity created = new DescriptionTemplateTypeEntity();
|
|
||||||
created.setId(UUID.randomUUID());
|
|
||||||
created.setName(payload.getName());
|
|
||||||
created.setStatus(DescriptionTemplateTypeStatus.SAVED.getValue());
|
|
||||||
|
|
||||||
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
|
|
||||||
definition.setName(UUID.randomUUID().toString());
|
|
||||||
definition.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
|
|
||||||
definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
|
||||||
TransactionStatus status = null;
|
|
||||||
try {
|
|
||||||
status = transactionManager.getTransaction(definition);
|
|
||||||
entityManager.persist(created);
|
|
||||||
|
|
||||||
entityManager.flush();
|
|
||||||
transactionManager.commit(status);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
if (status != null)
|
|
||||||
transactionManager.rollback(status);
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
|
|
||||||
DescriptionTemplateTypeQuery query = applicationContext.getBean(DescriptionTemplateTypeQuery.class);
|
|
||||||
return builderFactory
|
|
||||||
.builder(DescriptionTemplateTypeBuilder.class)
|
|
||||||
.build(null, query.ids(created.getId()).first());
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionTemplateType update(DescriptionTemplateType payload) {
|
|
||||||
DescriptionTemplateTypeEntity entity = entityManager.find(DescriptionTemplateTypeEntity.class, payload.getId());
|
|
||||||
entity.setName(payload.getName());
|
|
||||||
entity.setStatus(payload.getStatus());
|
|
||||||
entityManager.merge(entity);
|
|
||||||
entityManager.flush();
|
|
||||||
return builderFactory.builder(DescriptionTemplateTypeBuilder.class).build(null, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean delete (UUID id) {
|
|
||||||
DescriptionTemplateTypeEntity entity = entityManager.find(DescriptionTemplateTypeEntity.class, id);
|
|
||||||
if (entity == null) return false;
|
|
||||||
entity.setStatus(DescriptionTemplateTypeStatus.DELETED.getValue());
|
|
||||||
entityManager.merge(entity);
|
|
||||||
entityManager.flush();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +1,15 @@
|
||||||
package eu.old.eudat.query;
|
package eu.old.eudat.query;
|
||||||
|
|
||||||
import eu.eudat.query.UserQuery;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class DatasetProfileQuery {
|
public class DatasetProfileQuery {
|
||||||
|
|
||||||
private UserQuery userQuery;
|
private OldUserQuery userQuery;
|
||||||
|
|
||||||
public UserQuery getUserQuery() {
|
public OldUserQuery getUserQuery() {
|
||||||
return userQuery;
|
return userQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserQuery(UserQuery userQuery) {
|
public void setUserQuery(OldUserQuery userQuery) {
|
||||||
this.userQuery = userQuery;
|
this.userQuery = userQuery;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,13 @@
|
||||||
<module>web</module>
|
<module>web</module>
|
||||||
<module>data</module>
|
<module>data</module>
|
||||||
<module>elastic</module>
|
<module>elastic</module>
|
||||||
<module>core</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.http.version>1.19.0</project.http.version>
|
<project.http.version>1.19.0</project.http.version>
|
||||||
<project.oauth.version>1.19.0</project.oauth.version>
|
<project.oauth.version>1.19.0</project.oauth.version>
|
||||||
<project.version>0.2.0</project.version>
|
<project.version>0.2.0</project.version>
|
||||||
<java.version>17</java.version>
|
<java.version>21</java.version>
|
||||||
|
|
||||||
<dmp-backend-commons.version>0.0.1-SNAPSHOT</dmp-backend-commons.version>
|
<dmp-backend-commons.version>0.0.1-SNAPSHOT</dmp-backend-commons.version>
|
||||||
|
|
||||||
|
|
|
@ -229,8 +229,8 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>17</source>
|
<source>21</source>
|
||||||
<target>17</target>
|
<target>21</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -276,7 +276,7 @@
|
||||||
<properties>
|
<properties>
|
||||||
<start-class>eu.old.eudat.EuDatApplication</start-class>
|
<start-class>eu.old.eudat.EuDatApplication</start-class>
|
||||||
<opensaml.version>4.0.1</opensaml.version>
|
<opensaml.version>4.0.1</opensaml.version>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>21</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
Loading…
Reference in New Issue