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

DOC: comments for sql statements

parent 9fc93905
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,7 @@ public class MySQLGetAllNames extends MySQLTransaction implements GetAllNamesImp ...@@ -18,6 +18,7 @@ public class MySQLGetAllNames extends MySQLTransaction implements GetAllNamesImp
super(access); super(access);
} }
/** Retrieve tuples (EntityName, EntityRole, ACL) for all entities which have a name. */
public static final String STMT_GET_ALL_NAMES = public static final String STMT_GET_ALL_NAMES =
"SELECT d.value as EntityName, e.role AS EntityRole, a.acl AS ACL " "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 " + "FROM name_data AS d JOIN entities AS e JOIN entity_acl AS a "
......
...@@ -36,11 +36,17 @@ public class MySQLGetIDByName extends MySQLTransaction implements GetIDByNameImp ...@@ -36,11 +36,17 @@ public class MySQLGetIDByName extends MySQLTransaction implements GetIDByNameImp
super(access); 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 = public static final String STMT_GET_ID_BY_NAME =
"Select n.entity_id AS id " "Select n.entity_id AS id "
+ "FROM name_data AS n JOIN entities AS e " + "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)" + "ON (n.domain_id=0 AND n.property_id=20 AND e.id = n.entity_id)"
+ "WHERE n.value=?"; + "WHERE n.value=?";
public static final String STMT_AND_ROLE = " AND e.role=?"; 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_NOT_ROLE = " AND e.role!='ROLE'";
public static final String STMT_LIMIT = " LIMIT "; public static final String STMT_LIMIT = " LIMIT ";
......
...@@ -15,10 +15,19 @@ public class MySQLInsertEntityDatatype extends MySQLTransaction ...@@ -15,10 +15,19 @@ public class MySQLInsertEntityDatatype extends MySQLTransaction
super(access); 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 = public static final String STMT_INSERT_ENTITY_DATATYPE =
"INSERT INTO data_type (domain_id, entity_id, property_id, datatype) " "INSERT INTO data_type (domain_id, entity_id, property_id, datatype) "
+ "SELECT 0, 0, ?, " + "SELECT 0, 0, ?, "
+ "( SELECT entity_id FROM name_data WHERE domain_id = 0 AND property_id = 20 AND value = ? LIMIT 1);"; + "( 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 = public static final String STMT_INSERT_ENTITY_COLLECTION =
"INSERT INTO collection_type (domain_id, entity_id, property_id, collection) " "INSERT INTO collection_type (domain_id, entity_id, property_id, collection) "
+ "SELECT 0, 0, ?, ?;"; + "SELECT 0, 0, ?, ?;";
......
...@@ -38,6 +38,12 @@ public class MySQLRetrieveDatatypes extends MySQLTransaction implements Retrieve ...@@ -38,6 +38,12 @@ public class MySQLRetrieveDatatypes extends MySQLTransaction implements Retrieve
super(access); 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 = private static final String STMT_GET_DATATYPE =
"SELECT id AS ParentID, " "SELECT id AS ParentID, "
+ "(SELECT value FROM name_data WHERE domain_id = 0 AND entity_ID = e.id AND property_id = 20) AS ParentName, " + "(SELECT value FROM name_data WHERE domain_id = 0 AND entity_ID = e.id AND property_id = 20) AS ParentName, "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment