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): 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): commitKey = '' commitNoKey = '' bscChaPrim = '' loadOrder = '' cfieldOrder = [] for column in Colunas.select().join(Entity).where(Entity.table == self.entity.table): loadOrder += ''.rjust(4)+'self:oHashOrder:set("'+ column.dbField +'", "'+ column.name +'")\n' if column.is_indice: cfieldOrder.append(column.dbField) commitKey += ''.rjust(12)+self.alias+'->'+column.dbField+' := _Super:normalizeType('+ self.alias +'->'+ column.dbField +',self:getValue("'+ column.name +'")) /* Column '+ column.dbField +' */\n' bscChaPrim += ''.rjust(4)+'cQuery += " AND ' +column.dbField+ ' = ? "\n' bscChaPrim += ''.rjust(4)+'aAdd(self:aMapBuilder, self:toString(self:getValue("'+column.name+'")))\n' else: commitNoKey += ''.rjust(8)+self.alias+'->'+column.dbField+' := _Super:normalizeType('+ self.alias +'->'+ column.dbField +',self:getValue("'+ column.name +'")) /* Column '+ column.dbField +' */\n' variables = { 'className': self.entity.shortName, 'alias': self.alias, 'entity' : self.entity.name, 'commitKey' : commitKey, 'commitNoKey' : commitNoKey, 'loadOrder' : loadOrder, 'cfieldOrder' : ','.join(cfieldOrder), 'bscChaPrim' : bscChaPrim, '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 getVariables(self): wsDataKeys = '' wsDataNoKeys = '' defaultVarsNoKey = '' defaultVarsKey = '' varskey = [] varsNokey = [] keyVarsNoKeyPath = [] keyPath = '' variables = [] for column in Colunas.select().join(Entity).where(Entity.table == self.entity.table): if not column.name in self.columnsToAdd: self.columnsToAdd.append(column.name) wsDataNoKeys += ''.rjust(4)+'WSDATA '+ column.name +' as STRING OPTIONAL\n' if column.is_indice : defaultVarsKey += ''.rjust(4)+'Default self:'+ column.name +' := ""\n' varskey.append(''.rjust(4)+column.name) keyVarsNoKeyPath.append(''.rjust(4)+column.name) else: defaultVarsNoKey += ''.rjust(4)+'Default self:'+ column.name +' := ""\n' varsNokey.append(''.rjust(4)+column.name) if column.is_keyPathParam : keyPath = column.name if len(keyVarsNoKeyPath) > 0: keyVarsNoKeyPath.remove(' '+keyPath) descriptionPath = self.entity.name.title().replace(" ","").replace("-","").strip() descriptionPath = descriptionPath[0].lower() + descriptionPath[1:] variables = { 'classNameAbreviate': self.entity.shortName, 'description': self.entity.name.title(), 'descriptionPath': descriptionPath, 'className': self.entity.shortName, 'classNameLower' : self.entity.shortName.lower(), 'table' : self.entity.table, 'entityName' : self.entity.name, 'prefix' : self.prefix, 'segment' : self.segment, 'wsDataKeys' : wsDataKeys, 'wsDataNoKeys' : wsDataNoKeys, 'defaultVarsKey' : defaultVarsKey, 'defaultVarsNoKey' : defaultVarsNoKey, 'varskey' : ',;\n'.join(varskey)+ ',;' if len(varsNokey) > 0 else ',;\n'.join(varskey)+ ';' , 'varsNokey' : ',;\n'.join(varsNokey)+';', 'keyPath' : keyPath, 'keyVarsNoKeyPath' : ',;\n'.join(keyVarsNoKeyPath)+';', } return variables
def getVariables(self): properties = '' for column in Colunas.select().join(Entity).where( Entity.table == self.entity.table): canUpdate = "false" if column.is_indice else "true" required = "true" if column.is_keyPathParam else "false" properties += ''.rjust(16) + ( '"' + column.name + '": {\n' ' "description": "' + column.desc + '",\n' ' "type": "string",\n' ' "x-totvs": [\n' ' {\n' ' "product": "' + self.product + '",\n' ' "field": "' + self.alias + '.' + column.dbField + '",\n' ' "required": ' + required + ',\n' ' "type": "' + column.dataType + '",\n' ' "length": "' + str(column.length) + '",\n' ' "note": "' + column.desc + '",\n' ' "available": true,\n' ' "canUpdate": ' + canUpdate + '\n' ' }\n' ' ]\n' ' },\n') classNameTitle = self.entity.name.title().replace(" ", "") descriptionPath = self.entity.name.title().replace(" ", "") descriptionPath = descriptionPath[0].lower() + descriptionPath[1:] variables = { 'className': self.entity.name, 'classNameTitle': classNameTitle, 'descriptionPath': descriptionPath, 'entityName': self.entity.name, 'product': self.product, 'productDescription': self.productDescription, 'contact': self.contact, 'segment': self.segment, 'properties': properties[:-2], 'classNameLower': self.entity.name.lower(), } return variables
def getVariables(self): applyFilterAll = '' applyFilterSingle = '' prepFilter = '' for column in Colunas.select().join(Entity).where(Entity.table == self.entity.table): applyFilterAll += ''.rjust(12)+'self:oCollection:setValue("'+ column.name +'",self:oRest:'+ column.name +')\n' if column.is_indice : applyFilterSingle += ''.rjust(12)+'self:oCollection:setValue("'+ column.name +'",self:oRest:'+ column.name +')\n' prepFilter += ''.rjust(4)+'self:oCollection:setValue("'+ column.name +'", self:oRest:'+ column.name +')\n' variables = { 'className': self.entity.shortName, 'entityName' : self.entity.name, 'prefix' : self.prefix, 'applyFilterAll' : applyFilterAll, 'applyFilterSingle' : applyFilterSingle, 'prepFilter' : prepFilter, } return variables
def getVariables(self): pathParam = '' queryParam = '' parameters = '' keyParameters = '' keyPath = '' abreviate = self.entity.shortName for column in Colunas.select().join(Entity).where(Entity.table == self.entity.table): parameters += ' {\n' parameters += ' "$ref": "#/components/parameters/'+column.name+'Param"\n' parameters += ' },\n' if column.is_indice : keyParameters += ' {\n' keyParameters += ' "$ref": "#/components/parameters/'+column.name+'Param"\n' keyParameters += ' },\n' if column.is_keyPathParam: keyPath = column.name pathParam = ( ' "'+column.name+'Param": {\n' ' "name": "'+column.name+'",\n' ' "in": "path",\n' ' "description": "'+column.desc+'",\n' ' "required": true,\n' ' "schema": {\n' ' "type": "string",\n' ' "format": "string"\n' ' }\n' ' },\n' ) else: queryParam += ( ' "'+column.name+'Param": {\n' ' "name": "'+column.name+'",\n' ' "in": "query",\n' ' "description": "'+column.desc+'",\n' ' "required": ' + 'true' if column.is_indice else 'false' + ',\n' ' "schema": {\n' ' "type": "string",\n' ' "format": "string"\n' ' }\n' ' },\n' ) classNameTitle = self.entity.name.title().replace(" ","") descriptionPath = classNameTitle[0].lower() + classNameTitle[1:] variables = { 'className': self.entity.name, 'classNamePortuguese': self.entity.namePortuguese, 'classNameTitle': classNameTitle, 'descriptionPath': descriptionPath, 'entityName' : self.entity.name, 'product' : self.product, 'productDescription' : self.productDescription, 'contact' : self.contact, 'segment' : self.segment, 'pathParam' : pathParam, 'parameters' : parameters[:-2], 'queryParam' : queryParam[:-3]+"}", 'classNameLower' : self.entity.name.lower(), 'keyParameters' : keyParameters[:-2], 'keyPath' : keyPath, 'abreviate' : abreviate, } 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