# --------------------------------------------------------------------------------------------------------- # 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 import tools.file_type 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" 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): 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 = "" reference = "" project = "" application = "" attributes = "" 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: """ 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) @staticmethod def rebuild_data(job, data: dict) -> dict: """ gets the subtable-tag from filecsv and sets the subtables in order to workable entity-elements :param job: :param data: :return: """ data = tools.file_type.popSubjectsNode(job, data) # data = tools.file_type.popNameNode(job, data) return data def check_data(self, job, data: dict) -> dict: """ it checks the data for the specific form :param job: :param tdata: :param ttype: :return: """ 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 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