Skip to content
Snippets Groups Projects
Verified Commit 74c1f3ed authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'f-grpc-main' into f-grpc-f-acm

parents d51fa7d5 28c62562
Branches
Tags
2 merge requests!58REL: prepare release 0.7.2,!45F grpc f acm
Showing
with 574 additions and 823 deletions
......@@ -25,7 +25,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.caosdb</groupId>
<artifactId>caosdb-server</artifactId>
<version>0.5.1-GRPC0.0.20</version>
<version>0.5.1-GRPC0.1.0</version>
<packaging>jar</packaging>
<name>CaosDB Server</name>
<scm>
......
......@@ -25,9 +25,9 @@ copyright = '2020, IndiScale GmbH'
author = 'Daniel Hornung'
# The short X.Y version
version = '0.5'
version = '0.5.1'
# The full version, including alpha/beta/rc tags
release = '0.5.1-SNAPSHOT'
release = '0.5.1-GRPC0.1.0'
# -- General configuration ---------------------------------------------------
......
......@@ -22,13 +22,12 @@
*/
package org.caosdb.server.database.backend.transaction;
import static org.caosdb.server.transaction.Transaction.ERROR_INTEGRITY_VIOLATION;
import org.caosdb.server.database.BackendTransaction;
import org.caosdb.server.database.backend.interfaces.DeleteEntityPropertiesImpl;
import org.caosdb.server.database.exceptions.IntegrityException;
import org.caosdb.server.entity.EntityInterface;
import org.caosdb.server.utils.EntityStatus;
import org.caosdb.server.utils.ServerMessages;
public class DeleteEntityProperties extends BackendTransaction {
......@@ -50,7 +49,7 @@ public class DeleteEntityProperties extends BackendTransaction {
try {
ret.execute(this.entity.getId());
} catch (final IntegrityException exc) {
this.entity.addError(ERROR_INTEGRITY_VIOLATION);
this.entity.addError(ServerMessages.ERROR_INTEGRITY_VIOLATION);
throw exc;
}
}
......
......@@ -24,13 +24,12 @@
*/
package org.caosdb.server.database.backend.transaction;
import static org.caosdb.server.transaction.Transaction.ERROR_INTEGRITY_VIOLATION;
import org.caosdb.server.database.BackendTransaction;
import org.caosdb.server.database.backend.interfaces.DeleteSparseEntityImpl;
import org.caosdb.server.database.exceptions.IntegrityException;
import org.caosdb.server.entity.EntityInterface;
import org.caosdb.server.utils.EntityStatus;
import org.caosdb.server.utils.ServerMessages;
public class DeleteSparseEntity extends BackendTransaction {
......@@ -54,7 +53,7 @@ public class DeleteSparseEntity extends BackendTransaction {
ret.execute(this.entity.getId());
}
} catch (final IntegrityException exc) {
this.entity.addError(ERROR_INTEGRITY_VIOLATION);
this.entity.addError(ServerMessages.ERROR_INTEGRITY_VIOLATION);
throw exc;
}
}
......
package org.caosdb.server.database.backend.transaction;
import static org.caosdb.server.transaction.Transaction.ERROR_INTEGRITY_VIOLATION;
import org.caosdb.server.database.BackendTransaction;
import org.caosdb.server.database.backend.interfaces.InsertEntityDatatypeImpl;
import org.caosdb.server.database.exceptions.IntegrityException;
import org.caosdb.server.database.proto.SparseEntity;
import org.caosdb.server.entity.EntityInterface;
import org.caosdb.server.utils.ServerMessages;
public class InsertEntityDatatype extends BackendTransaction {
......@@ -25,7 +24,7 @@ public class InsertEntityDatatype extends BackendTransaction {
try {
t.execute(e);
} catch (final IntegrityException exc) {
this.entity.addError(ERROR_INTEGRITY_VIOLATION);
this.entity.addError(ServerMessages.ERROR_INTEGRITY_VIOLATION);
throw exc;
}
......
......@@ -22,8 +22,6 @@
*/
package org.caosdb.server.database.backend.transaction;
import static org.caosdb.server.transaction.Transaction.ERROR_INTEGRITY_VIOLATION;
import org.caosdb.server.database.BackendTransaction;
import org.caosdb.server.database.backend.interfaces.InsertSparseEntityImpl;
import org.caosdb.server.database.exceptions.IntegrityException;
......@@ -31,6 +29,7 @@ import org.caosdb.server.database.exceptions.TransactionException;
import org.caosdb.server.database.proto.SparseEntity;
import org.caosdb.server.entity.EntityInterface;
import org.caosdb.server.entity.Version;
import org.caosdb.server.utils.ServerMessages;
import org.caosdb.server.utils.Undoable;
public class InsertSparseEntity extends BackendTransaction {
......@@ -52,7 +51,7 @@ public class InsertSparseEntity extends BackendTransaction {
try {
t.execute(e);
} catch (final IntegrityException exc) {
this.entity.addError(ERROR_INTEGRITY_VIOLATION);
this.entity.addError(ServerMessages.ERROR_INTEGRITY_VIOLATION);
throw exc;
}
......
......@@ -27,9 +27,6 @@ import org.caosdb.server.entity.Message;
@DatatypeDefinition(name = "Reference")
public class ReferenceDatatype extends AbstractDatatype {
public static final Message REFERENCE_ID_NOT_PARSABLE =
new Message(217, "The reference is not parsable. It must be an integer.");
@Override
public ReferenceValue parseValue(final Object value) throws Message {
return ReferenceValue.parseReference(value);
......
......@@ -662,18 +662,6 @@ public class Entity extends AbstractObservable implements EntityInterface {
return ret;
}
@Override
public final Message getMessage(final String type, final Integer code) {
for (final ToElementable m : this.messages) {
if (m instanceof Message
&& ((Message) m).getType().equalsIgnoreCase(type)
&& ((Message) m).getCode() == code) {
return (Message) m;
}
}
return null;
}
@Override
public final void addMessage(final ToElementable m) {
this.messages.add(m);
......@@ -691,7 +679,7 @@ public class Entity extends AbstractObservable implements EntityInterface {
@Override
public void addInfo(final String description) {
final Message m = new Message(MessageType.Info, 0, description);
final Message m = new Message(description);
addMessage(m);
}
......
......@@ -21,17 +21,41 @@
*/
package org.caosdb.server.entity;
import java.util.HashMap;
import java.util.Map;
import org.caosdb.api.entity.v1.MessageCode;
import org.caosdb.server.entity.xml.ToElementable;
import org.caosdb.server.utils.ServerMessages;
import org.jdom2.Element;
public class Message extends Exception implements Comparable<Message>, ToElementable {
protected final String type;
private final Integer code;
private final MessageCode code;
private final String description;
private final String body;
private static final long serialVersionUID = -3005017964769041935L;
@Deprecated private static final Map<String, String> legacy_codes_mapping = new HashMap<>();
static void init() {
legacy_codes_mapping.put(
ServerMessages.ENTITY_HAS_BEEN_DELETED_SUCCESSFULLY.coreToString(), "10");
legacy_codes_mapping.put(ServerMessages.ATOMICITY_ERROR.coreToString(), "12");
legacy_codes_mapping.put(ServerMessages.ENTITY_DOES_NOT_EXIST.coreToString(), "101");
legacy_codes_mapping.put(ServerMessages.PROPERTY_HAS_NO_DATATYPE.coreToString(), "110");
legacy_codes_mapping.put(
ServerMessages.ENTITY_HAS_UNQUALIFIED_PROPERTIES.coreToString(), "114");
legacy_codes_mapping.put(ServerMessages.ENTITY_HAS_UNQUALIFIED_PARENTS.coreToString(), "116");
legacy_codes_mapping.put(ServerMessages.WARNING_OCCURED.coreToString(), "128");
legacy_codes_mapping.put(ServerMessages.ENTITY_NAME_IS_NOT_UNIQUE.coreToString(), "152");
legacy_codes_mapping.put(ServerMessages.REQUIRED_BY_UNQUALIFIED.coreToString(), "192");
legacy_codes_mapping.put(ServerMessages.REFERENCED_ENTITY_DOES_NOT_EXIST.coreToString(), "235");
legacy_codes_mapping.put(ServerMessages.AUTHORIZATION_ERROR.coreToString(), "403");
legacy_codes_mapping.put(ServerMessages.ROLE_DOES_NOT_EXIST.coreToString(), "1104");
legacy_codes_mapping.put(ServerMessages.ENTITY_NAME_DUPLICATES.coreToString(), "0");
}
private static final long serialVersionUID = 1837110172902899264L;
public enum MessageType {
Warning,
......@@ -44,15 +68,18 @@ public class Message extends Exception implements Comparable<Message>, ToElement
return toString().hashCode();
}
@Override
public String toString() {
return this.type.toString()
+ " ("
+ (this.code != null ? Integer.toString(this.code) : "")
private String coreToString() {
return " ("
+ (this.code != null ? this.code.toString() : "0")
+ ") - "
+ (this.description != null ? this.description : "");
}
@Override
public String toString() {
return this.type.toString() + coreToString();
}
@Override
public boolean equals(final Object obj) {
return obj.toString().equals(toString());
......@@ -74,33 +101,33 @@ public class Message extends Exception implements Comparable<Message>, ToElement
this(type, null, description, body);
}
public Message(final String type, final Integer code) {
public Message(final String type, final MessageCode code) {
this(type, code, null, null);
}
public Message(final Integer code, final String description) {
public Message(final MessageCode code, final String description) {
this(MessageType.Info, code, description);
}
public Message(final MessageType type, final Integer code, final String description) {
public Message(final MessageType type, final MessageCode code, final String description) {
this(type.toString(), code, description, null);
}
public Message(
final MessageType type, final Integer code, final String description, final String body) {
final MessageType type, final MessageCode code, final String description, final String body) {
this(type.toString(), code, description, body);
}
public Message(final String type, final Integer code, final String description) {
public Message(final String type, final MessageCode code, final String description) {
this(type, code, description, null);
}
public Message(final MessageType type, final String description) {
this(type.toString(), 0, description);
this(type.toString(), MessageCode.MESSAGE_CODE_UNKNOWN, description);
}
public Message(
final String type, final Integer code, final String description, final String body) {
final String type, final MessageCode code, final String description, final String body) {
this.code = code;
this.description = description;
this.body = body;
......@@ -108,7 +135,7 @@ public class Message extends Exception implements Comparable<Message>, ToElement
}
public Message(
final Integer code, final String description, final String body, final MessageType type) {
final MessageCode code, final String description, final String body, final MessageType type) {
this.code = code;
this.description = description;
this.body = body;
......@@ -116,20 +143,29 @@ public class Message extends Exception implements Comparable<Message>, ToElement
}
public Message(final String string) {
this.code = null;
this.code = MessageCode.MESSAGE_CODE_UNKNOWN;
this.description = string;
this.body = null;
this.type = MessageType.Info.toString();
}
public Integer getCode() {
public MessageCode getCode() {
return this.code;
}
public Element toElement() {
if (legacy_codes_mapping.isEmpty()) {
init();
}
final Element e = new Element(this.type);
if (this.code != null) {
e.setAttribute("code", Integer.toString(this.code));
if (legacy_codes_mapping.containsKey(this.coreToString())) {
e.setAttribute("code", legacy_codes_mapping.get(this.coreToString()));
} else if (this.code == MessageCode.MESSAGE_CODE_UNKNOWN) {
e.setAttribute("code", "0");
} else {
e.setAttribute("code", Integer.toString(this.code.getNumber()));
}
}
if (this.description != null) {
e.setAttribute("description", this.description);
......@@ -153,8 +189,7 @@ public class Message extends Exception implements Comparable<Message>, ToElement
public final void print(final String indent) {
System.out.println(indent + "+---| " + this.type + " |------------------------ ");
System.out.println(
indent + "| Code: " + (this.code != null ? Integer.toString(this.code) : "null"));
System.out.println(indent + "| Code: " + this.code.toString());
System.out.println(indent + "| Description: " + this.description);
System.out.println(indent + "| Body: " + this.body);
System.out.println(indent + "+------------------------------------------------------ ");
......
......@@ -59,8 +59,6 @@ public interface TransactionEntity {
public abstract List<Message> getMessages(String type);
public abstract Message getMessage(String type, Integer code);
public abstract void addMessage(ToElementable m);
public abstract void addError(Message m);
......
......@@ -340,11 +340,6 @@ public class EntityWrapper implements EntityInterface {
return this.entity.getMessages(type);
}
@Override
public Message getMessage(final String type, final Integer code) {
return this.entity.getMessage(type, code);
}
@Override
public void addMessage(final ToElementable m) {
this.entity.addMessage(m);
......
package org.caosdb.server.grpc;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.caosdb.api.entity.v1.AtomicDataType;
import org.caosdb.api.entity.v1.CollectionValues;
import org.caosdb.api.entity.v1.DataType;
import org.caosdb.api.entity.v1.Entity;
import org.caosdb.api.entity.v1.Entity.Builder;
import org.caosdb.api.entity.v1.EntityResponse;
import org.caosdb.api.entity.v1.EntityRole;
import org.caosdb.api.entity.v1.Importance;
import org.caosdb.api.entity.v1.ListDataType;
import org.caosdb.api.entity.v1.MessageCode;
import org.caosdb.api.entity.v1.Parent;
import org.caosdb.api.entity.v1.ReferenceDataType;
import org.caosdb.api.entity.v1.ScalarValue;
import org.caosdb.api.entity.v1.SpecialValue;
import org.caosdb.api.entity.v1.Version;
import org.caosdb.datetime.DateTimeInterface;
import org.caosdb.server.datatype.AbstractCollectionDatatype;
import org.caosdb.server.datatype.AbstractDatatype;
import org.caosdb.server.datatype.BooleanDatatype;
import org.caosdb.server.datatype.BooleanValue;
import org.caosdb.server.datatype.CollectionValue;
import org.caosdb.server.datatype.DateTimeDatatype;
import org.caosdb.server.datatype.DoubleDatatype;
import org.caosdb.server.datatype.FileDatatype;
import org.caosdb.server.datatype.GenericValue;
import org.caosdb.server.datatype.IndexedSingleValue;
import org.caosdb.server.datatype.IntegerDatatype;
import org.caosdb.server.datatype.ReferenceDatatype;
import org.caosdb.server.datatype.ReferenceDatatype2;
import org.caosdb.server.datatype.ReferenceValue;
import org.caosdb.server.datatype.TextDatatype;
import org.caosdb.server.datatype.Value;
import org.caosdb.server.entity.EntityInterface;
import org.caosdb.server.entity.MagicTypes;
import org.caosdb.server.entity.Message;
import org.caosdb.server.entity.Role;
import org.caosdb.server.entity.StatementStatus;
import org.caosdb.server.entity.container.ParentContainer;
import org.caosdb.server.entity.container.PropertyContainer;
import org.caosdb.server.entity.wrapper.Property;
public class CaosDBToGrpcConverters {
/** Get the unit as string. */
public String getStringUnit(final EntityInterface entity) {
final Iterator<Property> iterator = entity.getProperties().iterator();
while (iterator.hasNext()) {
final Property p = iterator.next();
if (MagicTypes.UNIT.getId() == p.getId()) {
iterator.remove();
return p.getValue().toString();
}
}
return null;
}
public EntityResponse.Builder convert(final EntityInterface from) {
final Builder entityBuilder = Entity.newBuilder();
if (from.hasId()) {
entityBuilder.setId(Integer.toString(from.getId()));
}
if (from.getRole() != null) {
entityBuilder.setRole(convert(from.getRole()));
}
if (from.hasName()) {
entityBuilder.setName(from.getName());
}
if (from.hasDescription()) {
entityBuilder.setDescription(from.getDescription());
}
if (from.hasDatatype()) {
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()));
}
final String unit = getStringUnit(from);
if (unit != null) {
entityBuilder.setUnit(unit);
}
if (from.hasProperties()) {
entityBuilder.addAllProperties(convert(from.getProperties()));
}
if (from.hasParents()) {
entityBuilder.addAllParents(convert(from.getParents()));
}
final EntityResponse.Builder responseBuilder = EntityResponse.newBuilder();
responseBuilder.setEntity(entityBuilder);
appendMessages(from, responseBuilder);
return responseBuilder;
}
private EntityRole convert(final Role role) {
switch (role) {
case RecordType:
return EntityRole.ENTITY_ROLE_RECORD_TYPE;
case Record:
return EntityRole.ENTITY_ROLE_RECORD;
case Property:
return EntityRole.ENTITY_ROLE_PROPERTY;
case File:
return EntityRole.ENTITY_ROLE_FILE;
default:
return EntityRole.ENTITY_ROLE_UNSPECIFIED;
}
}
public Iterable<? extends org.caosdb.api.entity.v1.Message> convert(
final List<Message> messages) {
final List<org.caosdb.api.entity.v1.Message> result = new LinkedList<>();
for (final Message m : messages) {
result.add(convert(m));
}
return result;
}
public org.caosdb.api.entity.v1.Message convert(final Message m) {
final org.caosdb.api.entity.v1.Message.Builder builder =
org.caosdb.api.entity.v1.Message.newBuilder();
final MessageCode code = getMessageCode(m);
builder.setCode(code.getNumber());
builder.setDescription(m.getDescription());
return builder.build();
}
public static MessageCode getMessageCode(final Message m) {
return m.getCode();
}
public Version convert(final org.caosdb.server.entity.Version from) {
final org.caosdb.api.entity.v1.Version.Builder builder = Version.newBuilder();
builder.setId(from.getId());
return builder.build();
}
public Parent convert(final org.caosdb.server.entity.wrapper.Parent from) {
final org.caosdb.api.entity.v1.Parent.Builder builder = Parent.newBuilder();
if (from.hasId()) {
builder.setId(from.getId().toString());
}
if (from.hasName()) {
builder.setName(from.getName());
}
if (from.hasDescription()) {
builder.setDescription(from.getDescription());
}
return builder.build();
}
public org.caosdb.api.entity.v1.Property convert(final Property from) {
final org.caosdb.api.entity.v1.Property.Builder builder =
org.caosdb.api.entity.v1.Property.newBuilder();
if (from.hasId()) {
builder.setId(from.getId().toString());
}
if (from.hasName()) {
builder.setName(from.getName());
}
if (from.hasDescription()) {
builder.setDescription(from.getDescription());
}
if (from.hasDatatype()) {
builder.setDataType(convert(from.getDatatype()));
}
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()));
return builder.build();
}
private org.caosdb.api.entity.v1.Value.Builder convert(final Value value) {
if (value instanceof CollectionValue) {
return convertCollectionValue((CollectionValue) value);
}
final org.caosdb.api.entity.v1.Value.Builder builder =
org.caosdb.api.entity.v1.Value.newBuilder();
builder.setScalarValue(convertScalarValue(value));
return builder;
}
private ScalarValue.Builder convertScalarValue(final Value value) {
if (value instanceof BooleanValue) {
return convertBooleanValue((BooleanValue) value);
} else if (value instanceof ReferenceValue) {
return convertReferenceValue((ReferenceValue) value);
} else if (value instanceof DateTimeInterface) {
return convertDateTimeInterface((DateTimeInterface) value);
} else if (value instanceof GenericValue) {
return convertGenericValue((GenericValue) value);
}
return null;
}
private ScalarValue.Builder convertGenericValue(final GenericValue value) {
final Object wrappedValue = value.getValue();
if (wrappedValue instanceof Double) {
return ScalarValue.newBuilder().setDoubleValue((Double) wrappedValue);
} else if (wrappedValue instanceof Integer) {
return ScalarValue.newBuilder().setIntegerValue((Integer) wrappedValue);
} else {
return convertStringValue(value);
}
}
private org.caosdb.api.entity.v1.ScalarValue.Builder convertStringValue(final Value value) {
if (value.toString().isEmpty()) {
return ScalarValue.newBuilder().setSpecialValue(SpecialValue.SPECIAL_VALUE_EMPTY_STRING);
}
return ScalarValue.newBuilder().setStringValue(value.toString());
}
private org.caosdb.api.entity.v1.ScalarValue.Builder convertDateTimeInterface(
final DateTimeInterface value) {
return convertStringValue(value);
}
private org.caosdb.api.entity.v1.ScalarValue.Builder convertBooleanValue(
final BooleanValue value) {
return ScalarValue.newBuilder().setBooleanValue(value.getValue());
}
private ScalarValue.Builder convertReferenceValue(final ReferenceValue value) {
return convertStringValue(value);
}
private org.caosdb.api.entity.v1.Value.Builder convertCollectionValue(
final CollectionValue value) {
final org.caosdb.api.entity.v1.Value.Builder builder =
org.caosdb.api.entity.v1.Value.newBuilder();
final List<ScalarValue> values = new LinkedList<>();
value.forEach(
(v) -> {
values.add(convertScalarValue(v));
});
builder.setListValues(CollectionValues.newBuilder().addAllValues(values));
return builder;
}
private ScalarValue convertScalarValue(final IndexedSingleValue v) {
return convertScalarValue(v.getWrapped()).build();
}
private Importance convert(final StatementStatus statementStatus) {
switch (statementStatus) {
case FIX:
return Importance.IMPORTANCE_FIX;
case OBLIGATORY:
return Importance.IMPORTANCE_OBLIGATORY;
case RECOMMENDED:
return Importance.IMPORTANCE_RECOMMENDED;
case SUGGESTED:
return Importance.IMPORTANCE_SUGGESTED;
default:
return null;
}
}
private org.caosdb.api.entity.v1.DataType.Builder convert(final AbstractDatatype datatype) {
if (datatype instanceof ReferenceDatatype2) {
return DataType.newBuilder()
.setReferenceDataType(convertReferenceDatatype((ReferenceDatatype2) datatype));
} else if (datatype instanceof FileDatatype) {
return DataType.newBuilder()
.setReferenceDataType(convertReferenceDatatype((FileDatatype) datatype));
} else if (datatype instanceof ReferenceDatatype) {
return DataType.newBuilder()
.setReferenceDataType(convertReferenceDatatype((ReferenceDatatype) datatype));
} else if (datatype instanceof AbstractCollectionDatatype) {
return DataType.newBuilder()
.setListDataType(
convertAbstractCollectionDatatype((AbstractCollectionDatatype) datatype));
} else if (datatype instanceof BooleanDatatype) {
return DataType.newBuilder()
.setAtomicDataType(convertBooleanDatatype((BooleanDatatype) datatype));
} else if (datatype instanceof DateTimeDatatype) {
return DataType.newBuilder()
.setAtomicDataType(convertDateTimeDatatype((DateTimeDatatype) datatype));
} else if (datatype instanceof DoubleDatatype) {
return DataType.newBuilder()
.setAtomicDataType(convertDoubleDatatype((DoubleDatatype) datatype));
} else if (datatype instanceof IntegerDatatype) {
return DataType.newBuilder()
.setAtomicDataType(convertIntegerDatatype((IntegerDatatype) datatype));
} else if (datatype instanceof TextDatatype) {
return DataType.newBuilder().setAtomicDataType(convertTextDatatype((TextDatatype) datatype));
}
return null;
}
private AtomicDataType convertTextDatatype(final TextDatatype datatype) {
return AtomicDataType.ATOMIC_DATA_TYPE_TEXT;
}
private AtomicDataType convertIntegerDatatype(final IntegerDatatype datatype) {
return AtomicDataType.ATOMIC_DATA_TYPE_INTEGER;
}
private AtomicDataType convertDoubleDatatype(final DoubleDatatype datatype) {
return AtomicDataType.ATOMIC_DATA_TYPE_DOUBLE;
}
private AtomicDataType convertDateTimeDatatype(final DateTimeDatatype datatype) {
return AtomicDataType.ATOMIC_DATA_TYPE_DATETIME;
}
private AtomicDataType convertBooleanDatatype(final BooleanDatatype datatype) {
return AtomicDataType.ATOMIC_DATA_TYPE_BOOLEAN;
}
private org.caosdb.api.entity.v1.ListDataType.Builder convertAbstractCollectionDatatype(
final AbstractCollectionDatatype collectionDatatype) {
final org.caosdb.api.entity.v1.ListDataType.Builder listBuilder = ListDataType.newBuilder();
final AbstractDatatype datatype = collectionDatatype.getDatatype();
if (datatype instanceof ReferenceDatatype) {
listBuilder.setReferenceDataType(convertReferenceDatatype((ReferenceDatatype) datatype));
} else if (datatype instanceof BooleanDatatype) {
return listBuilder.setAtomicDataType(convertBooleanDatatype((BooleanDatatype) datatype));
} else if (datatype instanceof DateTimeDatatype) {
return listBuilder.setAtomicDataType(convertDateTimeDatatype((DateTimeDatatype) datatype));
} else if (datatype instanceof DoubleDatatype) {
return listBuilder.setAtomicDataType(convertDoubleDatatype((DoubleDatatype) datatype));
} else if (datatype instanceof IntegerDatatype) {
return listBuilder.setAtomicDataType(convertIntegerDatatype((IntegerDatatype) datatype));
} else if (datatype instanceof TextDatatype) {
return listBuilder.setAtomicDataType(convertTextDatatype((TextDatatype) datatype));
}
return listBuilder;
}
private org.caosdb.api.entity.v1.ReferenceDataType.Builder convertReferenceDatatype(
final ReferenceDatatype datatype) {
return ReferenceDataType.newBuilder().setName(datatype.getName());
}
public Iterable<? extends org.caosdb.api.entity.v1.Property> convert(
final PropertyContainer from) {
final Iterator<org.caosdb.server.entity.wrapper.Property> iterator = from.iterator();
return () ->
new Iterator<>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public org.caosdb.api.entity.v1.Property next() {
return convert(iterator.next());
}
};
}
public Iterable<? extends Parent> convert(final ParentContainer from) {
final Iterator<org.caosdb.server.entity.wrapper.Parent> iterator = from.iterator();
return () ->
new Iterator<>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public Parent next() {
return convert(iterator.next());
}
};
}
public void appendMessages(
final EntityInterface from, final org.caosdb.api.entity.v1.EntityResponse.Builder builder) {
if (from.hasMessage(Message.MessageType.Error.toString())) {
builder.addAllErrors(convert(from.getMessages(Message.MessageType.Error.toString())));
}
if (from.hasMessage(Message.MessageType.Warning.toString())) {
builder.addAllWarnings(convert(from.getMessages(Message.MessageType.Warning.toString())));
}
if (from.hasMessage(Message.MessageType.Info.toString())) {
builder.addAllInfos(convert(from.getMessages(Message.MessageType.Info.toString())));
}
}
public void appendMessages(
final EntityInterface from, final org.caosdb.api.entity.v1.IdResponse.Builder builder) {
if (from.hasMessage(Message.MessageType.Error.toString())) {
builder.addAllErrors(convert(from.getMessages(Message.MessageType.Error.toString())));
}
if (from.hasMessage(Message.MessageType.Warning.toString())) {
builder.addAllWarnings(convert(from.getMessages(Message.MessageType.Warning.toString())));
}
if (from.hasMessage(Message.MessageType.Info.toString())) {
builder.addAllInfos(convert(from.getMessages(Message.MessageType.Info.toString())));
}
}
}
......@@ -7,9 +7,9 @@ import java.io.IOException;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
import org.caosdb.api.entity.v1alpha1.FileChunk;
import org.caosdb.api.entity.v1alpha1.FileDownloadResponse;
import org.caosdb.api.entity.v1alpha1.TransmissionStatus;
import org.caosdb.api.entity.v1.FileChunk;
import org.caosdb.api.entity.v1.FileDownloadResponse;
import org.caosdb.api.entity.v1.TransmissionStatus;
import org.caosdb.server.entity.FileProperties;
public class DownloadBuffer {
......
......@@ -4,8 +4,8 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.caosdb.api.entity.v1alpha1.FileDownloadResponse;
import org.caosdb.api.entity.v1alpha1.FileTransmissionSettings;
import org.caosdb.api.entity.v1.FileDownloadResponse;
import org.caosdb.api.entity.v1.FileTransmissionSettings;
import org.caosdb.server.entity.FileProperties;
import org.caosdb.server.utils.Utils;
......
......@@ -7,9 +7,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.caosdb.api.entity.v1alpha1.FileDownloadResponse;
import org.caosdb.api.entity.v1alpha1.FileTransmissionId;
import org.caosdb.api.entity.v1alpha1.FileTransmissionSettings;
import org.caosdb.api.entity.v1.FileDownloadResponse;
import org.caosdb.api.entity.v1.FileTransmissionId;
import org.caosdb.api.entity.v1.FileTransmissionSettings;
import org.caosdb.server.entity.FileProperties;
import org.caosdb.server.utils.Utils;
......
package org.caosdb.server.grpc;
import java.util.concurrent.locks.ReentrantLock;
import org.caosdb.api.entity.v1alpha1.FileTransmissionSettings;
import org.caosdb.api.entity.v1alpha1.RegistrationStatus;
import org.caosdb.api.entity.v1.FileTransmissionSettings;
import org.caosdb.api.entity.v1.RegistrationStatus;
import org.caosdb.server.entity.FileProperties;
public abstract class FileTransmission {
......
......@@ -2,19 +2,19 @@ package org.caosdb.server.grpc;
import io.grpc.stub.StreamObserver;
import java.io.IOException;
import org.caosdb.api.entity.v1alpha1.FileChunk;
import org.caosdb.api.entity.v1alpha1.FileDownloadRequest;
import org.caosdb.api.entity.v1alpha1.FileDownloadResponse;
import org.caosdb.api.entity.v1alpha1.FileTransmissionId;
import org.caosdb.api.entity.v1alpha1.FileTransmissionServiceGrpc.FileTransmissionServiceImplBase;
import org.caosdb.api.entity.v1alpha1.FileTransmissionSettings;
import org.caosdb.api.entity.v1alpha1.FileUploadRequest;
import org.caosdb.api.entity.v1alpha1.FileUploadResponse;
import org.caosdb.api.entity.v1alpha1.RegisterFileUploadRequest;
import org.caosdb.api.entity.v1alpha1.RegisterFileUploadResponse;
import org.caosdb.api.entity.v1alpha1.RegisterFileUploadResponse.Builder;
import org.caosdb.api.entity.v1alpha1.RegistrationStatus;
import org.caosdb.api.entity.v1alpha1.TransmissionStatus;
import org.caosdb.api.entity.v1.FileChunk;
import org.caosdb.api.entity.v1.FileDownloadRequest;
import org.caosdb.api.entity.v1.FileDownloadResponse;
import org.caosdb.api.entity.v1.FileTransmissionId;
import org.caosdb.api.entity.v1.FileTransmissionServiceGrpc.FileTransmissionServiceImplBase;
import org.caosdb.api.entity.v1.FileTransmissionSettings;
import org.caosdb.api.entity.v1.FileUploadRequest;
import org.caosdb.api.entity.v1.FileUploadResponse;
import org.caosdb.api.entity.v1.RegisterFileUploadRequest;
import org.caosdb.api.entity.v1.RegisterFileUploadResponse;
import org.caosdb.api.entity.v1.RegisterFileUploadResponse.Builder;
import org.caosdb.api.entity.v1.RegistrationStatus;
import org.caosdb.api.entity.v1.TransmissionStatus;
import org.caosdb.server.CaosDBServer;
import org.caosdb.server.entity.FileProperties;
import org.caosdb.server.utils.CronJob;
......
......@@ -5,10 +5,10 @@ import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.caosdb.api.entity.v1alpha1.FileChunk;
import org.caosdb.api.entity.v1alpha1.FileTransmissionSettings;
import org.caosdb.api.entity.v1alpha1.FileTransmissionSettings.Builder;
import org.caosdb.api.entity.v1alpha1.TransmissionStatus;
import org.caosdb.api.entity.v1.FileChunk;
import org.caosdb.api.entity.v1.FileTransmissionSettings;
import org.caosdb.api.entity.v1.FileTransmissionSettings.Builder;
import org.caosdb.api.entity.v1.TransmissionStatus;
import org.caosdb.server.FileSystem;
import org.caosdb.server.entity.FileProperties;
......
......@@ -5,7 +5,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.caosdb.api.entity.v1alpha1.FileTransmissionId;
import org.caosdb.api.entity.v1.FileTransmissionId;
import org.caosdb.server.entity.FileProperties;
import org.caosdb.server.utils.Utils;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment