Skip to content
Snippets Groups Projects
Commit 68e1c25c authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

deprication warning

parent ca8f7d9b
Branches
Tags
1 merge request!19ENH: add resolve_value to Property
This commit is part of merge request !19. Comments created here will be created in the context of that merge request.
...@@ -31,6 +31,7 @@ Some simplified functions for generation of records etc. ...@@ -31,6 +31,7 @@ Some simplified functions for generation of records etc.
import sys import sys
import tempfile import tempfile
from collections.abc import Iterable from collections.abc import Iterable
import warnings
from subprocess import call from subprocess import call
from caosdb.common.datatype import (BOOLEAN, DATETIME, DOUBLE, FILE, INTEGER, from caosdb.common.datatype import (BOOLEAN, DATETIME, DOUBLE, FILE, INTEGER,
...@@ -85,6 +86,34 @@ def new_record(record_type, name=None, description=None, ...@@ -85,6 +86,34 @@ def new_record(record_type, name=None, description=None,
return r return r
def id_query(ids):
warnings.warn("Please use 'create_id_query', which only creates"
"the string.", DeprecationWarning)
return execute_query(create_id_query(ids))
def create_id_query(ids):
return "FIND ENTITY WITH " + " OR ".join(
["ID={}".format(id) for id in ids])
def retrieve_entity_with_id(eid):
return execute_query("FIND ENTITY WITH ID={}".format(eid), unique=True)
def retrieve_entities_with_ids(entities):
collection = Container()
step = 20
for i in range(len(entities)//step+1):
collection.extend(
execute_query(
create_id_query(entities[i*step:(i+1)*step])))
return collection
def get_type_of_entity_with(id_): def get_type_of_entity_with(id_):
objs = retrieve_entities_with_ids([id_]) objs = retrieve_entities_with_ids([id_])
...@@ -693,27 +722,6 @@ def _apply_to_ids_of_entity(entity, func): ...@@ -693,27 +722,6 @@ def _apply_to_ids_of_entity(entity, func):
prop.value = func(prop.value) prop.value = func(prop.value)
def create_id_query(ids):
return "FIND ENTITY WITH " + " OR ".join(
["ID={}".format(id) for id in ids])
def retrieve_entity_with_id(eid):
return execute_query("FIND ENTITY WITH ID={}".format(eid), unique=True)
def retrieve_entities_with_ids(entities):
collection = Container()
step = 20
for i in range(len(entities)//step+1):
collection.extend(
execute_query(
create_id_query(entities[i*step:(i+1)*step])))
return collection
def resolve_reference(prop): def resolve_reference(prop):
"""resolves the value of a reference property """resolves the value of a reference property
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment