diff --git a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLGetAllNames.java b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLGetAllNames.java index be7ff11543547a87e1fef03a0c0ae67dd5621702..060cf9b8a77ad15e430b34f06e2b17737dd27cc2 100644 --- a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLGetAllNames.java +++ b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLGetAllNames.java @@ -18,6 +18,7 @@ public class MySQLGetAllNames extends MySQLTransaction implements GetAllNamesImp super(access); } + /** Retrieve tuples (EntityName, EntityRole, ACL) for all entities which have a name. */ public static final String STMT_GET_ALL_NAMES = "SELECT d.value as EntityName, e.role AS EntityRole, a.acl AS ACL " + "FROM name_data AS d JOIN entities AS e JOIN entity_acl AS a " diff --git a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLGetIDByName.java b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLGetIDByName.java index a113020c93415798fd9734f5fb0cbe232a0865d8..e9797640d98b6e9f2afb2b95ff3ea5103b623070 100644 --- a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLGetIDByName.java +++ b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLGetIDByName.java @@ -36,11 +36,17 @@ public class MySQLGetIDByName extends MySQLTransaction implements GetIDByNameImp super(access); } + /** + * Resolves the (primary) name of an entity to an id. This query is not necessarily unique. + * Therefore {@link #STMT_AND_ROLE}, {@link #STMT_NOT_ROLE}, and {@link #STMT_LIMIT} can as + * additional conditions. + */ public static final String STMT_GET_ID_BY_NAME = "Select n.entity_id AS id " + "FROM name_data AS n JOIN entities AS e " + "ON (n.domain_id=0 AND n.property_id=20 AND e.id = n.entity_id)" + "WHERE n.value=?"; + public static final String STMT_AND_ROLE = " AND e.role=?"; public static final String STMT_NOT_ROLE = " AND e.role!='ROLE'"; public static final String STMT_LIMIT = " LIMIT "; diff --git a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLInsertEntityDatatype.java b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLInsertEntityDatatype.java index dbc8b95773c6a02f705c7bb71e9ed3d8a7d410c3..47671864570c1a041b8b164a0f045fbf70b47987 100644 --- a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLInsertEntityDatatype.java +++ b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLInsertEntityDatatype.java @@ -15,10 +15,19 @@ public class MySQLInsertEntityDatatype extends MySQLTransaction super(access); } + /** + * Inserts atomic data types of properties into the data_type table. Has two parameters, the + * property_id and the data type name. + */ public static final String STMT_INSERT_ENTITY_DATATYPE = "INSERT INTO data_type (domain_id, entity_id, property_id, datatype) " + "SELECT 0, 0, ?, " + "( SELECT entity_id FROM name_data WHERE domain_id = 0 AND property_id = 20 AND value = ? LIMIT 1);"; + + /** + * Inserts collection data types of properties into the data_type table. Has two parameters, the + * property_id and the type of collection (e.g. 'LIST'). + */ public static final String STMT_INSERT_ENTITY_COLLECTION = "INSERT INTO collection_type (domain_id, entity_id, property_id, collection) " + "SELECT 0, 0, ?, ?;"; diff --git a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveDatatypes.java b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveDatatypes.java index 91d1e97a1eae70904d61acbd0da70c3a1af921d7..a8e12672cf21592c23d8cea0aa22629b4b68855c 100644 --- a/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveDatatypes.java +++ b/src/main/java/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveDatatypes.java @@ -38,6 +38,12 @@ public class MySQLRetrieveDatatypes extends MySQLTransaction implements Retrieve super(access); } + /** + * Retrieve (ParentID, ParentName, ParentDescription, ParentRole, ACL) tuple which actually + * contains the ID, name, description, role and ACL of the datatype. The misleading names should + * be fixed sometimes (TODO) but this also requires to adjust the code below, which uses {@link + * DatabaseUtils#parseParentResultSet(ResultSet)}. + */ private static final String STMT_GET_DATATYPE = "SELECT id AS ParentID, " + "(SELECT value FROM name_data WHERE domain_id = 0 AND entity_ID = e.id AND property_id = 20) AS ParentName, "