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

WIP: entity-id

parent c4f12649
No related branches found
No related tags found
1 merge request!70Refactory the entity id
...@@ -24,7 +24,7 @@ package org.caosdb.server.database.backend.implementation.MySQL; ...@@ -24,7 +24,7 @@ package org.caosdb.server.database.backend.implementation.MySQL;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.caosdb.server.database.access.Access; import org.caosdb.server.database.access.Access;
import org.caosdb.server.database.backend.interfaces.GetIDByNameImpl; import org.caosdb.server.database.backend.interfaces.GetIDByNameImpl;
...@@ -67,7 +67,7 @@ public class MySQLGetIDByName extends MySQLTransaction implements GetIDByNameImp ...@@ -67,7 +67,7 @@ public class MySQLGetIDByName extends MySQLTransaction implements GetIDByNameImp
stmt.setString(2, role); stmt.setString(2, role);
} }
try (ResultSet rs = stmt.executeQuery()) { try (ResultSet rs = stmt.executeQuery()) {
final ArrayList<EntityID> ret = new ArrayList<>(); final List<EntityID> ret = new LinkedList<>();
while (rs.next()) { while (rs.next()) {
ret.add(new EntityID(rs.getInt("id"))); ret.add(new EntityID(rs.getInt("id")));
} }
......
...@@ -25,5 +25,5 @@ import org.caosdb.server.database.proto.VerySparseEntity; ...@@ -25,5 +25,5 @@ import org.caosdb.server.database.proto.VerySparseEntity;
public interface RetrieveEntityACLImpl extends BackendTransactionImpl { public interface RetrieveEntityACLImpl extends BackendTransactionImpl {
public VerySparseEntity execute(Integer string); public VerySparseEntity execute(Integer id);
} }
...@@ -3,6 +3,15 @@ package org.caosdb.server.entity; ...@@ -3,6 +3,15 @@ package org.caosdb.server.entity;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
/**
* EntityID
*
* <p>This class is an abstraction layer for the entity id.
*
* <p>It also allows to link entities together, e.g. an Entity's Property with the corresponding
* abstract Property, even when the abstract Property does not have a valid ID yet (during bulk
* inserts).
*/
public class EntityID implements Serializable { public class EntityID implements Serializable {
private static final long serialVersionUID = -9092133023135548179L; private static final long serialVersionUID = -9092133023135548179L;
......
...@@ -31,13 +31,11 @@ import org.caosdb.server.transaction.Retrieve; ...@@ -31,13 +31,11 @@ import org.caosdb.server.transaction.Retrieve;
public enum MagicTypes { public enum MagicTypes {
UNIT, UNIT,
NAME, NAME,
DESCRIPTION, DESCRIPTION;
ROOT_DIRECTORY;
private static final EntityID UNIT_ID = new EntityID(21); private static final EntityID UNIT_ID = new EntityID(21);
private static final EntityID DESCRIPTION_ID = new EntityID(24); private static final EntityID DESCRIPTION_ID = new EntityID(24);
private static final EntityID NAME_ID = new EntityID(20); private static final EntityID NAME_ID = new EntityID(20);
private static final EntityID ROOT_DIRECTORY_ID = new EntityID(51);
public EntityID getId() { public EntityID getId() {
switch (this) { switch (this) {
...@@ -47,8 +45,6 @@ public enum MagicTypes { ...@@ -47,8 +45,6 @@ public enum MagicTypes {
return NAME_ID; return NAME_ID;
case DESCRIPTION: case DESCRIPTION:
return DESCRIPTION_ID; return DESCRIPTION_ID;
case ROOT_DIRECTORY:
return ROOT_DIRECTORY_ID;
default: default:
return null; return null;
} }
...@@ -62,8 +58,6 @@ public enum MagicTypes { ...@@ -62,8 +58,6 @@ public enum MagicTypes {
return NAME; return NAME;
case 24: case 24:
return DESCRIPTION; return DESCRIPTION;
case 51:
return ROOT_DIRECTORY;
default: default:
return null; return null;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment