Browse Source

refactoring: basic-model - comp

refactor
Ulrich 1 year ago
parent
commit
c35202180a
  1. 25
      model/application.py
  2. 82
      model/component.py
  3. 2
      model/entity.py
  4. 68
      model/environment.py

25
model/application.py

@ -2,8 +2,6 @@
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
print("is importing module.app")
import os
import basic.program
import basic.toolHandling
@ -15,10 +13,9 @@ import tools.path_const as P
import tools.config_tool
import tools.file_tool
import tools.git_tool
import tools.file_type
TABLE_NAMES = ["application", "ap_project", "ap_component"]
STORAGES = [ M.STORAGE_FILE, M.STORAGE_DB ]
""" used storage in priority sortage, so: if file then read_fcts / if db then select-fcts """
DEFAULT_SYNC = M.SYNC_FULL_GIT2DB
TABLE_NAME = B.SUBJECT_APP
@ -30,7 +27,6 @@ UNIQUE_FIELDS = [D.FIELD_NAME]
""" unique business field as human identifer """
IDENTIFYER_FIELDS = [FIELD_ID]
""" unique technical field as technical identifer """
print("has imported module.app")
def searchProjects(job, appl):
"""
@ -202,7 +198,11 @@ class Application(model.entity.Entity):
"""
config = self.getConfig(job, P.KEY_BASIC, B.SUBJECT_APPS,
tools.config_tool.get_plain_filename(job, ""), ttype=B.SUBJECT_APP)
outList = list(config[B.SUBJECT_APPS].keys())
conf = list(config[B.SUBJECT_APPS].keys())
outList = []
for k in conf:
if k[:1] != "_":
outList.append(k)
return outList
def read_entity(self, job, name):
@ -225,7 +225,7 @@ class Application(model.entity.Entity):
:return:
"""
data = tools.file_type.popSubjectsNode(job, data)
data = tools.file_type.popNameNode(job, data)
# data = tools.file_type.popNameNode(job, data)
return data
def check_data(self, job, data: dict) -> dict:
@ -236,10 +236,11 @@ class Application(model.entity.Entity):
:param ttype:
:return:
"""
import tools.file_type
checkNodes = {}
checkNodes[tools.file_type.MUST_NODES] = []
checkNodes[tools.file_type.MUSTNT_NODES] = [B.DATA_NODE_DATA, B.DATA_NODE_HEADER, B.DATA_NODE_FIELDS, B.DATA_NODE_KEYS] + B.LIST_SUBJECTS
checkNodes[tools.file_type.OPT_NODES] = []
return tools.file_type.check_nodes(job, data, checkNodes)
checkNodes[tools.file_type.MUST_NODES] = [B.SUBJECT_COMPS]
checkNodes[tools.file_type.MUSTNT_NODES] = [B.DATA_NODE_DATA, B.DATA_NODE_HEADER, B.DATA_NODE_FIELDS, B.DATA_NODE_KEYS]
checkNodes[tools.file_type.OPT_NODES] = [B.SUBJECT_APPS, B.SUBJECT_VARIANTS, B.SUBJECT_USECASES]
for conf in data:
tools.file_type.check_nodes(job, data[conf], checkNodes)
return data

82
model/component.py

@ -12,6 +12,7 @@ import tools.path_const as P
import tools.config_tool as config_tool
import tools.file_tool as file_tool
import tools.git_tool
import tools.file_type
TABLE_NAMES = ["component", "co_step", "co_table", "co_artifact", "co_comps"]
DEFAULT_SYNC = model.entity.SYNC_FULL_GIT2DB
@ -19,15 +20,6 @@ DEFAULT_SYNC = model.entity.SYNC_FULL_GIT2DB
TABLE_NAME = "component"
""" system-name for this entity """
FIELD_ID = "coid"
FIELD_NAME = D.FIELD_NAME
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE]
""" list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES, B.DATA_NODE_TOPICS]
LIST_SUBTABLES = [B.SUBJECT_ARTIFACTS, B.SUBJECT_COMPS, B.SUBJECT_STEPS, B.SUBJECT_DATATABLES]
PREFIX_SUBTABLE = ""
CP_SUBJECT_COMPS = "components"
CP_SUBJECT_STEPS = "steps"
@ -67,6 +59,12 @@ def select_components(job, project, application):
return outList
class Component(model.entity.Entity):
FIELD_ID = "coid"
LIST_FIELDS = [FIELD_ID, D.FIELD_NAME, B.SUBJECT_DESCRIPTION, B.SUBJECT_REFERENCE]
""" list of object-attributes """
LIST_NODES = [B.NODE_ATTRIBUTES, B.DATA_NODE_TOPICS]
LIST_SUBTABLES = [B.SUBJECT_ARTIFACTS, B.SUBJECT_COMPS, B.SUBJECT_STEPS, B.SUBJECT_DATATABLES]
PREFIX_SUBTABLE = "co"
coid = 0
name = ""
description = ""
@ -75,9 +73,6 @@ class Component(model.entity.Entity):
application = ""
attributes = ""
def __init__(self, job="", name=""):
pass
def read_unique_names(self, job, project, application, gran, args):
"""
reads the entity-names from file-storage
@ -103,54 +98,37 @@ class Component(model.entity.Entity):
:param name:
:return:
"""
configPath = tools.config_tool.select_config_path(job, P.KEY_COMP, name, "")
#repoPath = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS], name)
#gitresult = tools.git_tool.gitLog(job, B.ATTR_PATH_COMPS, repoPath, 1)
config = file_tool.read_file_dict(job, configPath, job.m)
print("ok")
for k in LIST_FIELDS:
if k not in config[TABLE_NAME]:
continue
setattr(self, k, config[TABLE_NAME][k])
for k in LIST_CP_SUBJECTS:
if k not in config[TABLE_NAME]:
continue
setattr(self, k, config[TABLE_NAME][k])
return self
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
config = self.getConfig(job, P.KEY_COMP, tools.config_tool.get_plain_filename(job, name), "", ttype=B.SUBJECT_COMP)
return self.setAttributes(job, config, name, self.LIST_FIELDS, self.LIST_NODES, self.LIST_SUBTABLES)
def getName(self):
@staticmethod
def rebuild_data(job, data: dict) -> dict:
"""
returns the name - maybe build from other attributes
gets the subtable-tag from filecsv and sets the subtables in order to workable entity-elements
:param job:
:param data:
:return:
"""
return self.name
data = tools.file_type.popSubjectsNode(job, data)
# data = tools.file_type.popNameNode(job, data)
return data
def getIDName(self):
def check_data(self, job, data: dict) -> dict:
"""
it returns the name as unique-id - maybe build from few attributes
it checks the data for the specific form
:param job:
:param tdata:
:param ttype:
:return:
"""
return self.name
checkNodes = {}
checkNodes[tools.file_type.MUST_NODES] = [B.SUBJECT_COMPS]
checkNodes[tools.file_type.MUSTNT_NODES] = [B.DATA_NODE_DATA, B.DATA_NODE_HEADER, B.DATA_NODE_FIELDS, B.DATA_NODE_KEYS]
checkNodes[tools.file_type.OPT_NODES] = [B.SUBJECT_APPS, B.SUBJECT_VARIANTS, B.SUBJECT_USECASES]
for conf in data:
tools.file_type.check_nodes(job, data[conf], checkNodes)
return data
def write_entity(self, job, name):
return

2
model/entity.py

@ -378,6 +378,8 @@ class Entity:
key = tools.data_tool.getExistKeyword(k, config[rootname])
if key == "":
continue
if not isinstance(config[rootname][key], dict):
continue
for o in config[rootname][key]:
if o in [B.DATA_NODE_DATA, B.DATA_NODE_HEADER, B.DATA_NODE_FIELDS, B.DATA_NODE_ROW, B.DATA_NODE_PATH]:
continue

68
model/environment.py

@ -10,22 +10,14 @@ import tools.config_tool
import tools.file_tool
import tools.git_tool
import tools.data_const as D
import tools.file_type
TABLE_NAME = "environment"
""" system-name for this entity """
FIELD_ID = "enid"
FIELD_NAME = "name"
FIELD_DESCRIPTION = B.SUBJECT_DESCRIPTION
FIELD_REFERENCE = B.SUBJECT_REFERENCE
FIELD_PROJECT = B.SUBJECT_PROJECT
FIELD_ATTRIBUTES = B.NODE_ATTRIBUTES
LIST_FIELDS = [FIELD_ID, FIELD_NAME, FIELD_DESCRIPTION, FIELD_REFERENCE, FIELD_PROJECT, FIELD_ATTRIBUTES]
""" list of object-attributes """
LIST_SUBTABLES = [B.SUBJECT_COMPS, B.SUBJECT_PROJECTS]
LIST_NODES = [B.NODE_ATTRIBUTES]
FILE_EXTENSION = D.DFILE_TYPE_YML
UNIQUE_FIELDS = [FIELD_NAME]
UNIQUE_FIELDS = [D.FIELD_NAME]
""" unique business field as human identifer """
IDENTIFYER_FIELDS = [FIELD_ID]
""" unique technical field as technical identifer """
@ -63,6 +55,12 @@ def select_environments(job, projectList):
class Environment(model.entity.Entity):
FIELD_ID = "enid"
LIST_FIELDS = [FIELD_ID, D.FIELD_NAME, B.SUBJECT_DESCRIPTION, B.SUBJECT_REFERENCE]
""" list of object-attributes """
LIST_SUBTABLES = [B.SUBJECT_COMPS, B.SUBJECT_PROJECTS]
LIST_NODES = [B.NODE_ATTRIBUTES]
name = ""
description = ""
reference = ""
@ -104,40 +102,32 @@ class Environment(model.entity.Entity):
:param name:
:return:
"""
config = self.getConfig(job, P.KEY_ENV, name, tools.config_tool.get_plain_filename(job, name))
return self.setAttributes(job, config, name, LIST_FIELDS, LIST_NODES, LIST_SUBTABLES)
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
config = self.getConfig(job, P.KEY_ENV, name,
tools.config_tool.get_plain_filename(job, name), ttype=B.SUBJECT_ENVIRONMENT)
return self.setAttributes(job, config, name, self.LIST_FIELDS, self.LIST_NODES, self.LIST_SUBTABLES)
def getName(self):
@staticmethod
def rebuild_data(job, data: dict) -> dict:
"""
returns the name - maybe build from other attributes
gets the subtable-tag from filecsv and sets the subtables in order to workable entity-elements
:param job:
:param data:
:return:
"""
return self.name
data = tools.file_type.popSubjectsNode(job, data)
data = tools.file_type.popNameNode(job, data)
return data
def getIDName(self):
def check_data(self, job, data: dict) -> dict:
"""
it returns the name as unique-id - maybe build from few attributes
it checks the data for the specific form
:param job:
:param tdata:
:param ttype:
:return:
"""
return self.name
checkNodes = {}
checkNodes[tools.file_type.MUST_NODES] = [B.SUBJECT_COMPS]
checkNodes[tools.file_type.MUSTNT_NODES] = [B.DATA_NODE_DATA, B.DATA_NODE_HEADER, B.DATA_NODE_FIELDS, B.DATA_NODE_KEYS]
checkNodes[tools.file_type.OPT_NODES] = [B.SUBJECT_PROJECTS]
return tools.file_type.check_nodes(job, data, checkNodes)

Loading…
Cancel
Save