From 12f072263c05208464b80c0124bde0396b100d86 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Thu, 8 Jul 2021 10:58:16 +0200
Subject: [PATCH] WIP: retrieve simple entity

---
 proto/caosdb/entity/v1alpha1/main.proto | 102 ++++++++++++++----------
 1 file changed, 61 insertions(+), 41 deletions(-)

diff --git a/proto/caosdb/entity/v1alpha1/main.proto b/proto/caosdb/entity/v1alpha1/main.proto
index 9001e4f..54336e7 100644
--- a/proto/caosdb/entity/v1alpha1/main.proto
+++ b/proto/caosdb/entity/v1alpha1/main.proto
@@ -24,68 +24,88 @@ option  java_multiple_files = true;
 option  java_package        = "org.caosdb.api.entity.v1alpha1";
 package caosdb.entity.v1alpha1;
 
-// Entity version
+// Version of an entity.
 message Version {
   // Version id
   string id = 1;
 }
 
-// Unit of a value or default unit of a Property
-message Unit {
-  // The string representation of the unit
-  string str = 1;
-}
-
-
-// Basic datatype. To be used as the datatype of a value or as the default datatype of a Property
-message BasicDatatype {
-  // Name of the basic datatype (e.g. integer, double, boolean)
-  string name = 1;
-}
-
-// Reference datatype. To be used as the datatype of a value or as the default datatype of a Property
-message ReferenceDatatype {
-  // The referenced record type
-  string reference = 1;
-}
-
-// Entity
+// This is the main class for CaosDB's entities.
 message Entity {
   // Entity ID
-  string eid = 1;
-  // Entity Name
+  string id = 1;
+  // Entity name
   string name = 2;
-  // Entity Description
+  // Entity description
   string description = 3;
-  // Entity Version
+  // Entity version
   Version version = 4;
-  // Entity Role
+  // Entity role (e.g. RecordType, Property, Record)
   string role = 5;
-  // Default unit (only used by Properties)
-  Unit unit = 6;
-  // Default datatype (only used by Properties)
-  oneof datatype {
-    // Basic datatype (e.g. integer, double)
-    BasicDatatype basic = 7;
-    // Reference datatype
-    ReferenceDatatype reference = 8;
-  };
+  // Default unit of this entity (only used by properties).
+  string unit = 6;
+  // Default datatype of this entity (only used by properties).
+  string datatype = 7;
+  // Properties of this entity.
+  repeated Property properties = 8;
+  // Parents of this entity.
+  repeated Parent parents = 9;
 }
 
-// RetrieveRequest message
-message RetrieveRequest {
-  // requested entity
-  Entity entity = 1;
+// Property of an entity. Don't confuse with an Entity with role="Property"
+message Property {
+  // ID of the implemented Entity
+  string id = 1;
+  // Property name
+  string name = 2;
+  // Property description
+  string description = 3;
+  // Property value
+  string value = 4;
+  // Property importance
+  string importance = 5;
+  // Property unit
+  string unit = 6;
+  // Property datatype
+  string datatype = 7;
+}
+
+// Parent of an entity.
+message Parent {
+  // ID of the parernt entity.
+  string id = 1;
+  // Name of the parernt entity.
+  string name = 2;
+  // Description of the parent entity.
+  string description = 3;
 }
 
-// RetrieveResponse message
+// Request a transaction of an entity by its ID. This can be used to implement
+// a retrieval or deletion.
+message ByIdRequest {
+  // ID of requested entity
+  string id = 1;
+}
+
+// Response to a retrieve request
 message RetrieveResponse {
   // payload of the retrieval
   Entity entity = 1;
 }
 
+// Wrapper for different kinds of retrievals (currently, only by ID). We need
+// this in order to make a repeated field of these different kinds of
+// retrievals.
+message RetrieveRequest {
+  // Wrapped special kind of request.
+  oneof wrapped_request {
+    // A single retrieve 
+    ByIdRequest by_id = 1;
+  }
+}
+
 // Entity Transaction Service
 service EntityTransactionService {
-  // Retrieve a single entity
+  // Issue a single retrieve request
   rpc Retrieve(RetrieveRequest) returns (RetrieveResponse);
 }
-- 
GitLab