def getVariables(self): expandable = '' expandables = [] serialize = '' fields = '' for column in Colunas.select().join(Entity).where(Entity.table == self.entity.table): serialize += ' oJsonControl:setProp(oJson,"' + column.name + '",self:getValue("'+ column.name+'")) /* Column '+ column.dbField +' */ \n' fields += ' self:oFields:push({"'+column.name+'", self:getValue("'+column.name +'")}) /* Column '+ column.dbField +' */ \n' for relation in Relations.select().where(Relations.table == self.entity.table): for entity in Entity.select().where(Entity.table == relation.tableRelation): expandable = entity.name.title().replace(" ","").replace("-","").strip() expandable = expandable[0].lower() + expandable[1:] expandables.append('"'+ expandable +'"') if len(expandables) > 0: expandable = ' oJson["_expandables"] := {' + ','.join(expandables) + '}\n' variables = { 'className': self.entity.shortName, 'description': self.entity.name, 'expandable' : expandable, 'serialize' : serialize, 'fields' : fields, 'table' : self.entity.table, 'prefix' : self.prefix, } return variables
def getVariables(self): mapper = '' expandables = [] expandable = '' for column in Colunas.select().join(Entity).where(Entity.table == self.entity.table): mapper += ' aAdd(self:aFields,{"'+ column.dbField +'" ,"'+ column.name +'"})\n' for relation in Relations.select().where(Relations.table == self.entity.table): for entity in Entity.select().where(Entity.table == relation.tableRelation): expandable = entity.name.title().replace(" ","").replace("-","").strip() expandable = expandable[0].lower() + expandable[1:] expandables.append('"'+ expandable +'"') if len(expandables) > 0: expandable = ' aAdd(self:aExpand,{' + ','.join(expandables) + '})\n' variables = { 'className': self.entity.shortName, 'entityName' : self.entity.name, 'mapper' : mapper, 'expandable' : expandable, 'prefix' : self.prefix, } return variables
def getVariables(self): optionsVariables = '' fields = '' descriptionPath = '' sufixFileName = '-list.component.ts' componentName = self.entity.namePortuguese.title().replace(" ", "") componentNameLower = componentName.lower() componentCammelLower = componentName[:1].lower() + componentName[1:] self.fileOut = componentNameLower + sufixFileName self.srcPath = os.path.join(settings.PATH_PO_SRC_APP, componentNameLower.lower()) self.srcPath = os.path.join(self.srcPath, componentNameLower.lower() + "-list") for entity in Entity.select(): optionsVariables = '' fields = ''.rjust( 2 ) + "public readonly fields: Array<PoPageDynamicTableField> = [ \n" descriptionPath = self.entity.name.title().replace(" ", "") descriptionPath = descriptionPath[0].lower() + descriptionPath[1:] for column in Colunas.select().join(Entity).where( Entity.table == self.entity.table): fields += ''.rjust( 4 ) + "{ property: '" + column.name + "', label: '" + column.desc + "' " fields += ", key: true" if column.is_keyPathParam else "" #getting field options if column.options != "": fields += ", options: this." + column.name + " " optionsVariables += ''.rjust( 2 ) + "public readonly " + column.name + ": Array<{value: string, label: string}> = [ \n" options = column.options.split(",") for option in options: key = option.split("=")[0] value = option.split("=")[1] optionsVariables += ''.rjust( 4 ) + "{ value: '" + key + "', label: '" + value + "' }, \n" optionsVariables += ''.rjust(2) + "]; \n\n" fields += " },\n" fields += ''.rjust(2) + "]; \n" variables = { 'componentNameLower': componentNameLower, 'componentCammelLower': componentCammelLower, 'optionsVariables': optionsVariables, 'descriptionPath': descriptionPath, 'fields': fields } return variables
def build(self): generators = self.getGenerators() for entity in Entity.select(): new_entity = aliasEntity.AliasEntity(entity.table, entity.name, entity.keyColumn, entity.namePortuguese, entity.shortName) for generator in generators: generator.setEntity(new_entity) generator.build() self.finishApi() return
def getVariables(self): relations = '' column = '' columnRelation = '' relationsKey = [] relationName = '' count = Relations.select().where( Relations.table == self.entity.table).count() index = 1 for relation in Relations.select().where( Relations.table == self.entity.shortName): for entity in Entity.select().where( Entity.shortName == relation.tableRelation): relations += ' oRelation:setCollection(CenClt' + entity.shortName + '():New())\n' relationName = entity.name.title().replace(" ", "").replace( "-", "").strip() relationName = relationName[0].lower() + relationName[1:] relations += ' oRelation:setName("' + relationName + '")\n' relations += ' oRelation:setRelationType(' + relation.relationType + ')\n' relations += ' oRelation:setBehavior(' + relation.behavior + ')\n' for relationKey in RelationKeys.select().where( RelationKeys.relation_id == relation.id): # if relationKey.column.find("_FILIAL") == -1: # column = Colunas.select().where(Colunas.dbField == relationKey.column) # columnRelation = Colunas.select().where(Colunas.dbField == relationKey.columnRelation) relationsKey.append(' {"' + relationKey.column + '","' + relationKey.columnRelation + '"}') if len(relationsKey) > 0: relations += ' oRelation:setRelationKey({;\n' relations += ' ' + ',;\n '.join(relationsKey) + ';\n' relations += ' })\n' relations += ' self:setRelation(oRelation)\n\n' relationsKey = [] #limpa o array from to if index < count: relations += ' oRelation := CenRelation():New()\n\n' #quando h� mais de uma rela��o 'expandable' index = index + 1 variables = { 'relations': relations, 'prefix': self.prefix, 'className': self.entity.shortName } return variables
def getVariables(self): linkName = "" menuName = '' menuList = '' for entity in Entity.select(): menuName = entity.namePortuguese if entity.namePortuguese != '' else 'Home' linkName = menuName.replace(" ", "").lower() menuList += " { label: '" + menuName + "', link: '" + linkName + "'},\n" variables = { 'menuList': menuList, } return variables
def PoBuild(self): generators = self.getPoGenerators() AppRoutingModuleTsGenerator.AppRoutingModuleTsGenerator().build() AppComponentTsGenerator.AppComponentTsGenerator().build() SharedModuleTsGenerator.SharedModuleTsGenerator().build() EnvironmentTsGenerator.EnvironmentTsGenerator().build() for entity in Entity.select(): new_entity = aliasEntity.AliasEntity(entity.table, entity.name, entity.keyColumn, entity.namePortuguese, entity.shortName) for generator in generators: generator.setEntity(new_entity) generator.build() return
def createDir(self): pathDir = '' dirName = '' for entity in Entity.select(): dirName = entity.namePortuguese.replace( " ", "").lower() if len(entity.namePortuguese) > 0 else 'home' pathDir = os.path.join(self.poSrcPath, dirName) if dirName != 'home': if not os.path.isdir(pathDir): os.mkdir(pathDir) if not os.path.isdir(pathDir + "\\" + dirName + "-view"): os.mkdir(pathDir + "\\" + dirName + "-view") if not os.path.isdir(pathDir + "\\" + dirName + "-form"): os.mkdir(pathDir + "\\" + dirName + "-form") if not os.path.isdir(pathDir + "\\" + dirName + "-list"): os.mkdir(pathDir + "\\" + dirName + "-list") self.copyLibs() return
def getVariables(self): routeName = '' componentName = '' imports = '' routes = '' for entity in Entity.select(): menuName = entity.namePortuguese if entity.namePortuguese != '' else 'Home' componentName = entity.namePortuguese.title().replace(" ", "") componentCammelLower = componentName[:1].lower( ) + componentName[1:] routeName = componentName.lower() routes += ''.rjust( 4 ) + "{ path: '" + routeName + "', loadChildren: './" + routeName + "/" + routeName + ".module#" + componentCammelLower + "Module' },\n" routes += ''.rjust( 4 ) + "{ path: '', redirectTo: '/" + routeName + "', pathMatch: 'full'},\n" variables = { 'routes': routes, } return variables
def getVariables(self): keyCollumn = '' compare = '' compareAll = '' dictBodys = {} dictBodys['expandables'] = [] dictBodys['subExpandables'] = [] keyVariables = '' noKeyVariables = '' queryParams = [] order = [] body = [] bodyExpandables = [] bodySubExpandables = [] descriptionPath = '' defaultVar = '' compareValue = '' for column in Colunas.select().join(Entity).where( Entity.table == self.entity.table): #ajusto a declara��o default da vari�vel defaultVar, compareValue = self.getVarName(column) compare += ''.rjust( 8 ) + 'oResult:assertTrue(oJson["' + column.name + '"] == ' + compareValue + ', "Valor comparado na coluna ' + column.dbField + ' de alias ' + column.name + ', nao sao iguais. Retorno:" + cRet) \n' compareAll += ''.rjust( 8 ) + 'oResult:assertTrue(oJson["items"][1]["' + column.name + '"] == ' + compareValue + ', "Valor comparado na coluna ' + column.dbField + ' de alias ' + column.name + ', nao sao iguais. Retorno:" + cRet) \n' order.append(column.name) if column.dataType == 'float': body.append(''.rjust(24) + '\' "' + column.name + '": \'+AllTrim(Str(' + column.variabelName + '))+\'') else: body.append(''.rjust(24) + '\' "' + column.name + '": "\'+' + compareValue + '+\'"') #B3A_CODIGO;obligationCode;string;3;1;1;C�digo da obriga��o;cCode;; if column.is_keyPathParam: keyCollumn = column.variabelName if column.is_indice: keyVariables += ''.rjust( 4 ) + 'Local ' + column.variabelName + ' := ' + defaultVar + ' /*Column ' + column.dbField + '*/\n' if not column.is_keyPathParam: queryParams.append(''.rjust(20) + '"&' + column.name + '="+escape(' + compareValue + ')+;') else: noKeyVariables += ''.rjust( 4 ) + 'Local ' + column.variabelName + ' := ' + defaultVar + ' /*Column ' + column.dbField + '*/\n' dictBodys['body'] = body for relation in Relations.select().where( Relations.table == self.entity.table): for entity in Entity.select().where( Entity.table == relation.tableRelation): compare += '\n' compare += ''.rjust(8) + '//Expandables\n' relationName = entity.name.title().replace(" ", "").replace( "-", "").strip() relationName = relationName[0].lower() + relationName[1:] for coluna in Colunas.select().where( Colunas.entity_id == entity.id): defaultVar, compareValue = self.getVarName(coluna) compare += ''.rjust( 8 ) + 'oResult:assertTrue(oJson["' + relationName + '"]["' + coluna.name + '"] == ' + compareValue + ', "Valor comparado na coluna ' + coluna.dbField + ' de alias ' + coluna.name + ', nao sao iguais. Retorno:" + cRet) \n' if coluna.dataType == 'float': bodyExpandables.append(''.rjust(28) + '\' "' + coluna.name + '": \'+AllTrim(Str(' + coluna.variabelName + '))+\'') else: bodyExpandables.append(''.rjust(28) + '\' "' + coluna.name + '": "\'+' + compareValue + '+\'"') dictBodys['expandables'].append( {relationName: bodyExpandables}) #Sub relacionamento for relation_sub in Relations.select().where( Relations.table == entity.table): for entity_sub in Entity.select().where( Entity.table == relation_sub.tableRelation): compare += '\n' compare += ''.rjust(8) + '//Sub Expandables\n' subRelationName = entity_sub.name.title().replace( " ", "").replace("-", "").strip() subRelationName = subRelationName[0].lower( ) + subRelationName[1:] for coluna_sub in Colunas.select().where( Colunas.entity_id == entity_sub.id): defaultVar, compareValue = self.getVarName( coluna_sub) compare += ''.rjust( 8 ) + 'oResult:assertTrue(oJson["' + relationName + '"]["' + subRelationName + '"]["' + coluna_sub.name + '"] == ' + compareValue + ', "Valor comparado na coluna ' + coluna_sub.dbField + ' de alias ' + coluna_sub.name + ', nao sao iguais. Retorno:" + cRet) \n' if coluna_sub.dataType == 'float': bodySubExpandables.append( ''.rjust(24) + '\' "' + coluna_sub.name + '": \'+AllTrim(Str(' + coluna_sub.variabelName + '))+\'') else: bodySubExpandables.append(''.rjust(24) + '\' "' + coluna_sub.name + '": "\'+' + compareValue + '+\'"') dictBodys['subExpandables'].append({ relationName: { subRelationName: bodySubExpandables } }) descriptionPath = self.entity.name.title().replace(" ", "") descriptionPath = descriptionPath[0].lower() + descriptionPath[1:] queryParams = '\n'.join(queryParams) order = ','.join(order) body = ',\' +;\n'.join(dictBodys['body']) #Pode melhorar =) for dictBody in dictBodys['expandables']: expands = dictBody.keys() for expand in expands: body += ",'+; \n" + ''.rjust( 24) + "'" ' "' + expand + '" : {' + "'+;\n" body += ',\'+;\n'.join(dictBody[expand]) for subDictBody in dictBodys['subExpandables']: subExpands = subDictBody.keys() for subExpand in subExpands: subDicts = subDictBody[subExpand].keys() for subDict in subDicts: if expand == subExpand: body += ",'+; \n" + ''.rjust( 28 ) + "'" ' "' + subDict + '" : {' + "'+;\n " body += ',\'+;\n '.join( subDictBody[subExpand].get(subDict)) body += "'+;\n" + ''.rjust(28) + "'}" body += "'+;\n" + ''.rjust(24) + "'}" variables = { 'descriptionPath': descriptionPath, 'className': self.entity.shortName, 'table': self.entity.table, 'alias': self.alias, 'prefix': self.prefix, 'compare': compare, 'compareAll': compareAll, 'keyVariables': keyVariables, 'noKeyVariables': noKeyVariables, 'queryParams': queryParams, 'keyCollumn': keyCollumn, 'order': order, 'body': body + '\'+;', } return variables
def list(self): for entity in Entity.select(): print('Entity ' + entity.table + ' - Alias Name '+ entity.name) return