# --------------------------------------------------------------------------------------------------------- # Author : Ulrich Carmesin # Source : gitea.ucarmesin.de # --------------------------------------------------------------------------------------------------------- import os import basic.toolHandling import basic.constants as B import model.entity import model.factory import tools.data_const as D import tools.path_const as P import tools.config_tool as config_tool import tools.file_tool as file_tool import tools.git_tool TABLE_NAMES = ["component", "co_step", "co_table", "co_artifact", "co_comps"] 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" CP_SUBJECT_TABLES = "tables" CP_SUBJECT_ARTS = B.SUBJECT_ARTIFACTS LIST_CP_SUBJECTS = [CP_SUBJECT_COMPS, CP_SUBJECT_STEPS, CP_SUBJECT_TABLES, CP_SUBJECT_ARTS] REL_ATTR_TYPE = "relationtyp" REL_ATTR_FILE = "conffile" REL_ATTR_FTYPE = "filetyp" REL_ATTR_IP_PATTERN = "ippattern" REL_ATTR_HOST_PATTERN = "hostpattern" REL_ATTR_PORT_PATTERN = "portpattern" REL_ATTR_URL_PATTERN = "urlpattern" LIST_REL_ATTR = [REL_ATTR_TYPE, REL_ATTR_FILE, REL_ATTR_FTYPE, REL_ATTR_IP_PATTERN, REL_ATTR_HOST_PATTERN, REL_ATTR_PORT_PATTERN, REL_ATTR_URL_PATTERN] def select_components(job, project, application): """ get all project which are configured for the workspace with all environments where the application of the project are installed :param job: :return: """ outList = [] appl = tools.config_tool.getConfig(job, P.KEY_BASIC, B.SUBJECT_APPS) path = job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS] for p in os.listdir(path): if p in ["catalog", "config", "test", "tools"]: continue if p[0:1] in [".", "_"]: continue if not os.path.isdir(os.path.join(path, p)): continue outList.append(p) return outList class Component(model.entity.Entity): coid = 0 name = "" description = "" reference = "" project = "" 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 :param job: :param opt. project: select-criteria if used and defined :param opt. application: select-criteria if used and defined :param opt. gran: granularity values testcase / testsuite / testplan :param opt. args additional args :return: list of entity-names """ # suche weiterleiten if application != "": app = model.factory.getApplication() return list(app.components.keys()) path = os.path.join(job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS]) outList = self.getDirlist(job, path, "csv") return outList def read_entity(self, job, name): """ reads the entity from the file-system :param job: :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 def getName(self): """ returns the name - maybe build from other attributes :return: """ return self.name def getIDName(self): """ it returns the name as unique-id - maybe build from few attributes :return: """ return self.name def write_entity(self, job, name): return def remove_entity(self, job, name): return def select_entity(self, job, name): return def update_entity(self, job, name): return def delete_entity(self, job, name): return def get_schema(self, tableName="", tableObject=None): return