|
|
@ -5,6 +5,7 @@ |
|
|
|
print("is importing module.app") |
|
|
|
|
|
|
|
import os |
|
|
|
import basic.program |
|
|
|
import basic.toolHandling |
|
|
|
import basic.constants as B |
|
|
|
import model.entity |
|
|
@ -232,14 +233,16 @@ def insertEntities(job,applData, dbTime, dbi): |
|
|
|
|
|
|
|
|
|
|
|
class Application(model.entity.Entity): |
|
|
|
table = "application" |
|
|
|
""" table = "application" |
|
|
|
job = None |
|
|
|
name = "" |
|
|
|
description = "" |
|
|
|
reference = "" |
|
|
|
components = {} |
|
|
|
project = {} |
|
|
|
""" |
|
|
|
|
|
|
|
def __int__(self, job, project=""): |
|
|
|
def __init__(self, job): |
|
|
|
self.job = job |
|
|
|
|
|
|
|
def read_unique_names(self, job, project, application, gran, args): |
|
|
@ -300,137 +303,3 @@ class Application(model.entity.Entity): |
|
|
|
:return: |
|
|
|
""" |
|
|
|
return self.name |
|
|
|
|
|
|
|
class Application_old(model.entity.Entity): |
|
|
|
table = "application" |
|
|
|
name = "" |
|
|
|
description = "" |
|
|
|
reference = "" |
|
|
|
component = [] |
|
|
|
project = {} |
|
|
|
|
|
|
|
def __init__(self, job, name=""): |
|
|
|
""" |
|
|
|
to be initialized by readSpec |
|
|
|
:param job: |
|
|
|
""" |
|
|
|
self.job = job |
|
|
|
if len(name) > 1: |
|
|
|
self.getEntity(job, name) |
|
|
|
|
|
|
|
def getEntity(self, job, name): |
|
|
|
if B.TOPIC_NODE_DB in job.conf: |
|
|
|
self.select_entity(job, name) |
|
|
|
#self.read_entity(job, name) |
|
|
|
else: |
|
|
|
self.read_entity(job, name) |
|
|
|
|
|
|
|
def read_entity(self, job, app): |
|
|
|
apppath = tools.config_tool.select_config_path(job, P.KEY_BASIC, B.SUBJECT_APPS, "") |
|
|
|
repopath = apppath[len(job.conf[B.TOPIC_PATH][B.ATTR_PATH_COMPS]) + 1:] |
|
|
|
gitresult = tools.git_tool.gitLog(job, B.ATTR_PATH_COMPS, repopath, 1) |
|
|
|
applData = tools.config_tool.getConfig(job, P.KEY_BASIC, B.SUBJECT_APPS) |
|
|
|
# main object |
|
|
|
for f in job.testserver.conf[B.DATA_NODE_DDL][TABLE_NAMES[0]][B.DATA_NODE_HEADER]: |
|
|
|
if f == model.entity.ENTITY_NAME: |
|
|
|
setattr(self, f, app) |
|
|
|
elif f == model.entity.ENTITY_ATTRIBUTES: |
|
|
|
setattr(self, f, {}) |
|
|
|
elif f in applData[B.SUBJECT_APPS][app]: |
|
|
|
setattr(self, f, applData[B.SUBJECT_APPS][app][f]) |
|
|
|
elif f in model.entity.ENTITY_FIELDS: |
|
|
|
setattr(self, f, model.entity.getEntityValue(job, f, gitresult[0])) |
|
|
|
else: |
|
|
|
setattr(self, f, "xx") |
|
|
|
project = {} |
|
|
|
if applData[B.SUBJECT_APPS][app][B.SUBJECT_PROJECTS] is not None: |
|
|
|
for proj in applData[B.SUBJECT_APPS][app][B.SUBJECT_PROJECTS]: |
|
|
|
project[proj] = {} |
|
|
|
for f in job.testserver.conf[B.DATA_NODE_DDL][TABLE_NAMES[1]][B.DATA_NODE_HEADER]: |
|
|
|
if f == model.entity.ENTITY_NAME: |
|
|
|
project[proj][f] = proj |
|
|
|
elif f == "project": |
|
|
|
project[proj][f] = proj |
|
|
|
elif f == model.entity.ENTITY_ATTRIBUTES: |
|
|
|
project[proj][f] = {} |
|
|
|
elif f in applData[B.SUBJECT_PROJECTS][proj]: |
|
|
|
project[proj][f] = applData[B.SUBJECT_PROJECTS][proj][f] |
|
|
|
elif f in model.entity.ENTITY_FIELDS: |
|
|
|
project[proj][f] = model.entity.getEntityValue(job, f, gitresult[0]) |
|
|
|
else: |
|
|
|
project[proj][f] = "xx" |
|
|
|
setattr(self, "project", project) |
|
|
|
component = [] |
|
|
|
if applData[B.SUBJECT_APPS][app][B.SUBJECT_COMPS] is not None: |
|
|
|
for comp in applData[B.SUBJECT_APPS][app][B.SUBJECT_COMPS]: |
|
|
|
component.append(comp) |
|
|
|
setattr(self, "component", component) |
|
|
|
|
|
|
|
def getApplicationRows(self, job): |
|
|
|
rows = [] |
|
|
|
row = {} |
|
|
|
for f in job.testserver.conf[B.DATA_NODE_DDL][TABLE_NAMES[0]][B.DATA_NODE_HEADER]: |
|
|
|
row[f] = getattr(self, f) |
|
|
|
rows.append(row) |
|
|
|
return rows |
|
|
|
|
|
|
|
def getAppProjectRows(self, job, apid): |
|
|
|
rows = [] |
|
|
|
for proj in self.project: |
|
|
|
row = {} |
|
|
|
for f in job.testserver.conf[B.DATA_NODE_DDL][TABLE_NAMES[1]][B.DATA_NODE_HEADER]: |
|
|
|
if f == "apid": |
|
|
|
row[f] = apid |
|
|
|
elif f in self.project[proj]: |
|
|
|
row[f] = self.project[proj][f] |
|
|
|
rows.append(row) |
|
|
|
return rows |
|
|
|
|
|
|
|
def getAppComponentRows(self, job, apid): |
|
|
|
rows = [] |
|
|
|
for comp in self.component: |
|
|
|
row = {} |
|
|
|
row["apid"] = apid |
|
|
|
row["component"] = comp |
|
|
|
rows.append(row) |
|
|
|
return rows |
|
|
|
|
|
|
|
def select_entity(self, job, app): |
|
|
|
dbi = basic.toolHandling.getDbTool(job, job.testserver, job.conf[B.TOPIC_NODE_DB][B.ATTR_TYPE]) |
|
|
|
data = dbi.selectRows(TABLE_NAMES[0], job, "WHERE name = \'" + app +"\' AND actual = " + model.entity.ENTITY_ACTUAL) |
|
|
|
# main object |
|
|
|
self.setAppRow(data[B.DATA_NODE_DATA][0], app) |
|
|
|
apid = getattr(self, "apid") |
|
|
|
data = dbi.selectRows(TABLE_NAMES[1], job, "WHERE apid = "+str(apid)) |
|
|
|
self.setProjRow(data[B.DATA_NODE_DATA]) |
|
|
|
data = dbi.selectRows(TABLE_NAMES[2], job, "WHERE apid = " + str(apid)) |
|
|
|
self.setCompRow(data[B.DATA_NODE_DATA]) |
|
|
|
|
|
|
|
def setAppRow(self, row, app): |
|
|
|
for f in self.job.testserver.conf[B.DATA_NODE_DDL][TABLE_NAMES[0]][B.DATA_NODE_HEADER]: |
|
|
|
if f not in row and f == model.entity.ENTITY_NAME: |
|
|
|
setattr(self, f, app) |
|
|
|
else: |
|
|
|
setattr(self, f, str(row[f])) |
|
|
|
def setProjRow(self, rows): |
|
|
|
project = {} |
|
|
|
for row in rows: |
|
|
|
project[row["project"]] = row |
|
|
|
setattr(self, "project", project) |
|
|
|
def setCompRow(self, rows): |
|
|
|
component = [] |
|
|
|
for row in rows: |
|
|
|
component.append(row["component"]) |
|
|
|
setattr(self, "component", component) |
|
|
|
|
|
|
|
def insertEntity(self, dbi=None): |
|
|
|
job = self.job |
|
|
|
rows = self.getApplicationRows(job) |
|
|
|
apid = dbi.insertRows(job, TABLE_NAMES[0], rows) |
|
|
|
rows = self.getAppProjectRows(job, apid) |
|
|
|
dbi.insertRows(job, TABLE_NAMES[1], rows) |
|
|
|
rows = self.getAppComponentRows(job, apid) |
|
|
|
dbi.insertRows(job, TABLE_NAMES[2], rows) |
|
|
|
|
|
|
|
def writeEntity(self): |
|
|
|
pass |
|
|
|