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

WIP: entity-id

parent f1b03a16
No related branches found
No related tags found
1 merge request!70Refactory the entity id
Pipeline #27291 failed
......@@ -37,8 +37,10 @@ import org.caosdb.server.datatype.CollectionValue;
import org.caosdb.server.datatype.IndexedSingleValue;
import org.caosdb.server.datatype.ReferenceValue;
import org.caosdb.server.datatype.SingleValue;
import org.caosdb.server.entity.EntityID;
import org.caosdb.server.entity.EntityInterface;
import org.caosdb.server.entity.Message;
import org.caosdb.server.entity.RetrieveEntity;
import org.caosdb.server.entity.Role;
import org.caosdb.server.entity.StatementStatus;
import org.caosdb.server.entity.wrapper.Domain;
......@@ -72,8 +74,7 @@ public class DatabaseUtils {
final List<EntityInterface> stage1Inserts, final EntityInterface e) {
// entity value
if (e.hasValue()) {
final Property p = new Property();
p.setId(e.getId());
final Property p = new Property(e);
p.setStatementStatus(StatementStatus.FIX);
p.setPIdx(0);
p.setDatatype(e.getDatatype());
......@@ -116,7 +117,7 @@ public class DatabaseUtils {
}
private static boolean hasUniquePropertyId(final EntityInterface p, final EntityInterface e) {
final Integer id = p.getId();
final EntityID id = p.getId();
for (final EntityInterface p2 : e.getProperties()) {
if (Objects.equal(p2.getId(), id) && p2 != p) {
return false;
......@@ -189,7 +190,7 @@ public class DatabaseUtils {
*
* <p>Never returns null.
*/
public static SparseEntity parseNameRoleACL(ResultSet rs) throws SQLException {
public static SparseEntity parseNameRoleACL(final ResultSet rs) throws SQLException {
final SparseEntity ret = new SparseEntity();
ret.role = bytes2UTF8(rs.getBytes("EntityRole"));
ret.name = bytes2UTF8(rs.getBytes("EntityName"));
......@@ -206,7 +207,7 @@ public class DatabaseUtils {
* <p>Never returns null.
*/
public static SparseEntity parseEntityResultSet(final ResultSet rs) throws SQLException {
SparseEntity ret = parseNameRoleACL(rs);
final SparseEntity ret = parseNameRoleACL(rs);
ret.id = rs.getInt("EntityID");
ret.description = bytes2UTF8(rs.getBytes("EntityDesc"));
ret.datatype = bytes2UTF8(rs.getBytes("Datatype"));
......@@ -247,8 +248,7 @@ public class DatabaseUtils {
public static void parseParentsFromVerySparseEntity(
final EntityInterface entity, final List<VerySparseEntity> pars) {
for (final VerySparseEntity vsp : pars) {
final Parent p = new Parent();
p.setId(vsp.id);
final Parent p = new Parent(new RetrieveEntity(new EntityID(vsp.id)));
p.setName(vsp.name);
p.setDescription(vsp.description);
entity.addParent(p);
......@@ -256,7 +256,7 @@ public class DatabaseUtils {
}
private static void replace(
final Property p, final HashMap<Integer, Property> domainMap, boolean isHead) {
final Property p, final Map<EntityID, Property> domainMap, final boolean isHead) {
// ... find the corresponding domain and replace it
ReferenceValue ref;
try {
......@@ -264,7 +264,7 @@ public class DatabaseUtils {
} catch (final Message e) {
throw new RuntimeException("This should never happen.");
}
final EntityInterface replacement = domainMap.get((ref.getId()));
final EntityInterface replacement = domainMap.get(ref.getId());
if (replacement == null) {
if (isHead) {
throw new NullPointerException("Replacement was null");
......@@ -297,7 +297,7 @@ public class DatabaseUtils {
final EntityInterface e, final List<Property> protoProperties) {
// here we will store every domain we can find and we will index it by
// its id.
final HashMap<Integer, Property> domainMap = new HashMap<Integer, Property>();
final Map<EntityID, Property> domainMap = new HashMap<>();
// loop over all properties and collect the domains
for (final Property p : protoProperties) {
......@@ -323,7 +323,7 @@ public class DatabaseUtils {
}
// loop over all properties
boolean isHead =
final boolean isHead =
e.getVersion().getSuccessors() == null || e.getVersion().getSuccessors().isEmpty();
for (final Property p : protoProperties) {
......@@ -368,7 +368,7 @@ public class DatabaseUtils {
}
private static Property parseFlatProperty(final FlatProperty fp) {
final Property property = new Property();
final Property property = new Property(new RetrieveEntity());
property.parseFlatProperty(fp);
return property;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment