diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7980f90eb16a03370acc07a940f801911c1ddef8..5ad5f1304f0a6d15e935c7ad4378f55366673891 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -120,7 +120,7 @@ pages_prepare: &pages_prepare script: - echo "Deploying..." - make doc - - cp -r build/doc/html public + - rm -r public || true ; cp -r build/doc/html public artifacts: paths: - public diff --git a/pom.xml b/pom.xml index d677280b94a9610275b5cd3236c86f6d48a8de94..83345a86cc2135633f606ed12bb5550e6de1303a 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.caosdb</groupId> <artifactId>caosdb-server</artifactId> - <version>0.5.0-GRPC0.0.13</version> + <version>0.5.0-GRPC0.0.14</version> <packaging>jar</packaging> <name>CaosDB Server</name> <scm> diff --git a/src/main/java/org/caosdb/server/datatype/BooleanValue.java b/src/main/java/org/caosdb/server/datatype/BooleanValue.java index 8fbe6bcb5e47126a349bee84d21c4f2025f727b3..2bcbb48bcaf52ec0ef9a83a6d81d51190d1249ef 100644 --- a/src/main/java/org/caosdb/server/datatype/BooleanValue.java +++ b/src/main/java/org/caosdb/server/datatype/BooleanValue.java @@ -39,6 +39,6 @@ public class BooleanValue extends AbstractEnumValue { } public boolean getValue() { - return toString().equals("TRUE"); + return toDatabaseString().equals("TRUE"); } } diff --git a/src/main/java/org/caosdb/server/entity/MagicTypes.java b/src/main/java/org/caosdb/server/entity/MagicTypes.java index cffdb0723588d3aaec31e24a39895e304aa2e18b..f17d448ca934901dc491f1d737f9122e2a67862a 100644 --- a/src/main/java/org/caosdb/server/entity/MagicTypes.java +++ b/src/main/java/org/caosdb/server/entity/MagicTypes.java @@ -26,6 +26,7 @@ import java.util.HashMap; import org.caosdb.server.entity.container.RetrieveContainer; import org.caosdb.server.transaction.Retrieve; +/** Some types correspond to entities in the database with magic IDs. */ public enum MagicTypes { UNIT, NAME, diff --git a/src/main/java/org/caosdb/server/grpc/EntityTransactionServiceImpl.java b/src/main/java/org/caosdb/server/grpc/EntityTransactionServiceImpl.java index 32cb1e27e76a469151508ab56c17d207e1ef06f9..0b5dd7e102e3b6f374ccfe28ddde2c73dbdd5cfb 100644 --- a/src/main/java/org/caosdb/server/grpc/EntityTransactionServiceImpl.java +++ b/src/main/java/org/caosdb/server/grpc/EntityTransactionServiceImpl.java @@ -7,6 +7,8 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.UUID; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.shiro.SecurityUtils; import org.caosdb.api.entity.v1alpha1.AtomicDataType; import org.caosdb.api.entity.v1alpha1.CollectionValues; @@ -85,10 +87,13 @@ public class EntityTransactionServiceImpl extends EntityTransactionServiceImplBa private final FileTransmissionServiceImpl fileTransmissionService; + /** Get the unit as string. */ public String getStringUnit(final EntityInterface entity) { - for (final Property p : entity.getProperties()) { + final Iterator<Property> iterator = entity.getProperties().iterator(); + while (iterator.hasNext()) { + final Property p = iterator.next(); if (MagicTypes.UNIT.getId() == p.getId()) { - p.setEntityStatus(EntityStatus.IGNORE); + iterator.remove(); return p.getValue().toString(); } } @@ -115,10 +120,18 @@ public class EntityTransactionServiceImpl extends EntityTransactionServiceImplBa entityBuilder.setDataType(convert(from.getDatatype())); } if (from.hasValue()) { + try { + from.parseValue(); + } catch (final Message e) { + // ignore. This problem should be handled elsewhere because this is + // only for the serialization of the data and not for the validation. + // In any case, the string representation can be used. + } entityBuilder.setValue(convert(from.getValue())); } - if (from.hasUnit()) { - entityBuilder.setUnit(getStringUnit(from)); + final String unit = getStringUnit(from); + if (unit != null) { + entityBuilder.setUnit(unit); } if (from.hasProperties()) { entityBuilder.addAllProperties(convert(from.getProperties())); @@ -218,10 +231,18 @@ public class EntityTransactionServiceImpl extends EntityTransactionServiceImplBa if (from.hasDatatype()) { builder.setDataType(convert(from.getDatatype())); } - if (from.hasUnit()) { - builder.setUnit(getStringUnit(from)); + final String unit = getStringUnit(from); + if (unit != null) { + builder.setUnit(unit); } if (from.hasValue()) { + try { + from.parseValue(); + } catch (final Message e) { + // ignore. This problem should be handled elsewhere because this is + // only for the serialization of the data and not for the validation. + // In any case, the string representation can be used. + } builder.setValue(convert(from.getValue())); } builder.setImportance(convert(from.getStatementStatus())); @@ -763,7 +784,9 @@ public class EntityTransactionServiceImpl extends EntityTransactionServiceImplBa } if (from.getPropertiesCount() > 0) { - entity.getProperties().addAll(convertProperties(from.getPropertiesList())); + final StatementStatus defaultImportance = + entity.getRole() == Role.RecordType ? StatementStatus.RECOMMENDED : StatementStatus.FIX; + entity.getProperties().addAll(convertProperties(from.getPropertiesList(), defaultImportance)); } if (from.getParentsCount() > 0) { entity.getParents().addAll(convertParents(from.getParentsList())); @@ -882,16 +905,18 @@ public class EntityTransactionServiceImpl extends EntityTransactionServiceImplBa } private Collection<Property> convertProperties( - final List<org.caosdb.api.entity.v1alpha1.Property> propertiesList) { + final List<org.caosdb.api.entity.v1alpha1.Property> propertiesList, + final StatementStatus defaultImportance) { final Collection<Property> result = new LinkedList<>(); propertiesList.forEach( e -> { - result.add(convert(e)); + result.add(convert(e, defaultImportance)); }); return result; } - private Property convert(final org.caosdb.api.entity.v1alpha1.Property e) { + private Property convert( + final org.caosdb.api.entity.v1alpha1.Property e, final StatementStatus defaultImportance) { final Property result = new Property(); try { @@ -912,6 +937,12 @@ public class EntityTransactionServiceImpl extends EntityTransactionServiceImplBa } if (e.getImportance() != Importance.IMPORTANCE_UNSPECIFIED) { result.setStatementStatus(convert(e.getImportance())); + } else { + result.setStatementStatus(defaultImportance); + } + // TODO remove this hard-coded setting when the API supports flags + if (result.getFlag("inheritance") == null) { + result.setFlag("inheritance", "fix"); } return result;