|
|
@ -15,17 +15,6 @@ import tools.git_tool |
|
|
|
TABLE_NAME = "table" |
|
|
|
""" system-name for this entity """ |
|
|
|
FIELD_ID = "tbid" |
|
|
|
FIELD_NAME = D.FIELD_NAME |
|
|
|
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION |
|
|
|
FIELD_REFERENCE = B.SUBJECT_REFERENCE |
|
|
|
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES |
|
|
|
FIELD_PROJECT = B.SUBJECT_PROJECT |
|
|
|
FIELD_APPLICATION = B.SUBJECT_APP |
|
|
|
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE] |
|
|
|
""" list of object-attributes """ |
|
|
|
LIST_NODES = [B.DATA_NODE_HEADER, B.DATA_NODE_DATA, B.DATA_NODE_FIELDS, B.DATA_NODE_KEYS] |
|
|
|
|
|
|
|
LIST_SUBTABLES = {} |
|
|
|
|
|
|
|
DEFAULT_FIELD = "" |
|
|
|
DEFAULT_TYPE = "string" |
|
|
@ -69,6 +58,12 @@ class Table(model.entity.Entity): |
|
|
|
nor a concrete table in the system-model |
|
|
|
it is an abstract super-class in order to relation to the database-management-system |
|
|
|
""" |
|
|
|
FIELD_ID = "tbid" |
|
|
|
LIST_FIELDS = [FIELD_ID, D.FIELD_NAME, B.SUBJECT_DESCRIPTION, B.SUBJECT_REFERENCE, B.SUBJECT_PROJECT] |
|
|
|
""" list of object-attributes """ |
|
|
|
LIST_NODES = [B.NODE_ATTRIBUTES, "fielddef", "fieldnames"] |
|
|
|
|
|
|
|
LIST_SUBTABLES = [] |
|
|
|
tbid = 0 |
|
|
|
name = "" |
|
|
|
project = "" |
|
|
@ -121,70 +116,38 @@ class Table(model.entity.Entity): |
|
|
|
""" |
|
|
|
return sql |
|
|
|
|
|
|
|
# def read_unique_names(self, job, project, application, gran, args): |
|
|
|
def read_unique_names(self, job, project="", application="", gran= "", args={}) -> list: |
|
|
|
return [] |
|
|
|
# table is not an real entity |
|
|
|
|
|
|
|
# def read_entity(self, job, name, project=""): |
|
|
|
def read_entity(self, job, name: str, args: dict={}): |
|
|
|
return self.read_ddl(job, name, args=args) |
|
|
|
# table is not an real entity |
|
|
|
|
|
|
|
def getFieldList(self): |
|
|
|
""" |
|
|
|
returns a list of scalar attributes |
|
|
|
:return: LIST_FIELDS |
|
|
|
""" |
|
|
|
return LIST_FIELDS |
|
|
|
|
|
|
|
def getNodeList(self): |
|
|
|
""" |
|
|
|
returns a list of sub-nodes - which can be persisted in a clob-field |
|
|
|
:return: LIST_NODES |
|
|
|
""" |
|
|
|
return LIST_NODES |
|
|
|
|
|
|
|
def getSubtableList(self): |
|
|
|
""" |
|
|
|
returns a list of sub-tables |
|
|
|
:return: LIST_SUBTABLES |
|
|
|
""" |
|
|
|
return LIST_SUBTABLES |
|
|
|
|
|
|
|
def getName(self): |
|
|
|
""" |
|
|
|
returns the name - maybe build from other attributes |
|
|
|
:return: |
|
|
|
""" |
|
|
|
return self.name |
|
|
|
|
|
|
|
def getIDName(self): |
|
|
|
def read_ddl(self, job, name, args: dict={}): |
|
|
|
""" |
|
|
|
it returns the name as unique-id - maybe build from few attributes |
|
|
|
reads the ddl of the table depending on context |
|
|
|
a) component: the ddl is read from specific or general component-folder |
|
|
|
b) testcase: the ddl is read from general component-folder |
|
|
|
c) testserver: the ddl is read from model-folder |
|
|
|
:param job: |
|
|
|
:param name: |
|
|
|
:param context: |
|
|
|
:return: |
|
|
|
""" |
|
|
|
return self.name |
|
|
|
|
|
|
|
def read_ddl(self, job, name): |
|
|
|
ddl = tools.config_tool.getConfig(job, D.DDL_FILENAME, self.component, name) |
|
|
|
self.fieldnames = [] |
|
|
|
fielddef = {} |
|
|
|
if B.DATA_NODE_TABLES in ddl and name in ddl[B.DATA_NODE_TABLES]: |
|
|
|
ddl = ddl[B.DATA_NODE_TABLES][name] |
|
|
|
for k in ddl[B.DATA_NODE_DATA]: |
|
|
|
if not isinstance(k, dict) \ |
|
|
|
or D.DDL_FIELD not in k: |
|
|
|
continue |
|
|
|
ddl[k[D.DDL_FIELD]] = k |
|
|
|
for f in ddl: |
|
|
|
if f in [B.DATA_NODE_HEADER, B.DATA_NODE_FIELDS, B.DATA_NODE_DATA]: |
|
|
|
continue |
|
|
|
field = {} |
|
|
|
self.fieldnames.append(f) |
|
|
|
for k in D.LIST_DDL_ATTR: |
|
|
|
if k in ddl[f]: |
|
|
|
field[k] = ddl[f][k] |
|
|
|
else: |
|
|
|
field[k] = DEFAULTS[k] |
|
|
|
fielddef[f] = field |
|
|
|
self.fielddef = fielddef |
|
|
|
if "context" in args: |
|
|
|
if args["context"] == "component": |
|
|
|
ddl = tools.config_tool.getConfig(job, D.DDL_FILENAME, self.component.name, name, ttype=D.CSV_SPECTYPE_DDL) |
|
|
|
elif args["context"] == "testdata": |
|
|
|
ddl = tools.config_tool.getConfig(job, D.DDL_FILENAME, args["context"], name, ttype=D.CSV_SPECTYPE_DDL) |
|
|
|
elif args["context"] == B.ATTR_INST_TESTSERVER: |
|
|
|
ddl = tools.config_tool.getConfig(job, D.DDL_FILENAME, B.ATTR_INST_TESTSERVER, name, ttype=D.CSV_SPECTYPE_DDL) |
|
|
|
config = {} |
|
|
|
if "_name" in ddl: |
|
|
|
config[ddl["_name"]] = ddl |
|
|
|
else: |
|
|
|
config = ddl |
|
|
|
return self.setAttributes(job, config, name, self.LIST_FIELDS, self.LIST_NODES, self.LIST_SUBTABLES) |
|
|
|
|
|
|
|
def select_entity(self, job, name): |
|
|
|
""" |
|
|
|