Skip to content
Snippets Groups Projects
Commit 7ff39fa3 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

FIX: Fix typos and datamodel problems

parent 9e59dc9f
Branches
Tags
1 merge request!1F awi sams
...@@ -65,10 +65,10 @@ Container: ...@@ -65,10 +65,10 @@ Container:
obligatory_properties: obligatory_properties:
Responsible: Responsible:
ContainerType: ContainerType:
suggested_properties:
container_label: container_label:
description: A standardized label for a container description: A standardized label for a container
datatype: TEXT datatype: TEXT
suggested_properties:
Child container: Child container:
datatype: LIST<Container> datatype: LIST<Container>
Container size: Container size:
......
...@@ -28,7 +28,7 @@ import json ...@@ -28,7 +28,7 @@ import json
import logging import logging
import sys import sys
import caosdb as db import linkahead as db
from caosadvancedtools.serverside import helper from caosadvancedtools.serverside import helper
from caosadvancedtools.serverside.logging import configure_server_side_logging from caosadvancedtools.serverside.logging import configure_server_side_logging
...@@ -126,16 +126,18 @@ def create_container_entities(responsible_id, container_type_id, container_size, ...@@ -126,16 +126,18 @@ def create_container_entities(responsible_id, container_type_id, container_size,
# Post process child containers # Post process child containers
batch = post_process_containers(batch) batch = post_process_containers(batch)
try: try:
logger.info(batch)
batch.insert() batch.insert()
except: except Exception as e:
logger.error("{} The registered containers could not be imported to the system. {}".format( logger.error("{} The registered containers could not be imported to the system. {}".format(
ERROR_PREFIX, ERROR_SUFFIX)) ERROR_PREFIX, ERROR_SUFFIX))
logger.error(e)
return None return None
# TODO: Reset the internal_container_label_counter of person to its previous value if nothing has be inserted # TODO: Reset the internal_container_label_counter of person to its previous value if nothing has be inserted
# Add to parent container # Add to parent container
if parent_container is not None: if parent_container is not None:
child_cont_prop = db.Property(name=get_entity_name("child_container_prop").retrieve() child_cont_prop = db.Property(name=get_entity_name("child_container_prop")).retrieve()
new_childs=[] new_childs=[]
for entity in batch: for entity in batch:
new_childs += [entity.id] new_childs += [entity.id]
...@@ -148,7 +150,7 @@ def create_container_entities(responsible_id, container_type_id, container_size, ...@@ -148,7 +150,7 @@ def create_container_entities(responsible_id, container_type_id, container_size,
parent_container.get_property(child_cont_prop.name).value=new_childs parent_container.get_property(child_cont_prop.name).value=new_childs
else: else:
parent_container.get_property(child_cont_prop.name).value += new_childs parent_container.get_property(child_cont_prop.name).value += new_childs
parent_container=post_process_parent_container(parent) parent_container=post_process_parent_container(parent_container)
parent_container.update() parent_container.update()
set_label_counter(container_type_id=container_type_id, set_label_counter(container_type_id=container_type_id,
......
...@@ -55,8 +55,8 @@ def get_container_name_prefix(responsible_id: int, container_type_id: int) -> st ...@@ -55,8 +55,8 @@ def get_container_name_prefix(responsible_id: int, container_type_id: int) -> st
Name in the format `<responsible>_<container_type_name>` Name in the format `<responsible>_<container_type_name>`
""" """
resp = db.cached_get_entity_by(eid=responsible_id) resp = db.cached.cached_get_entity_by(eid=responsible_id)
ct = db.cached_get_entity_by(eid=container_type_id) ct = db.cached.cached_get_entity_by(eid=container_type_id)
resp_str = get_record_string(resp) resp_str = get_record_string(resp)
ct_str = get_record_string(ct) ct_str = get_record_string(ct)
......
...@@ -3,10 +3,12 @@ import yaml ...@@ -3,10 +3,12 @@ import yaml
from pathlib import Path from pathlib import Path
CONSTANTS = yaml.load(os.path.join(Path(__file__).parent, "default_constants.yml")) with open(os.path.join(Path(__file__).parent, "default_constants.yml")) as yaml_file:
CONSTANTS = yaml.safe_load(yaml_file)
if os.path.isfile(os.path.join(Path(__file__).parent, "constants.yml")): if os.path.isfile(os.path.join(Path(__file__).parent, "constants.yml")):
CONSTANTS.update(yaml.load(os.path.join(Path(__file__).parent, "constants.yml"))) with open(os.path.join(Path(__file__).parent, "constants.yml")) as custom_yaml_file:
CONSTANTS.update(yaml.safe_load(custom_yaml_file))
def get_entity_name(name: str): def get_entity_name(name: str):
...@@ -21,6 +23,6 @@ def get_entity_name(name: str): ...@@ -21,6 +23,6 @@ def get_entity_name(name: str):
def get_column_header_name(name: str): def get_column_header_name(name: str):
if name in CONSTANTS["csv_column_names"]: if name in CONSTANTS["csv_column_names"]:
return CONSTANTS["csv_column_names"] return CONSTANTS["csv_column_names"][name]
return get_entity_name(name) return get_entity_name(name)
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment