@@ -68,16 +68,21 @@ def validateSearchParam(paramName, searchName, searchParamNames):
6868 elif paramName != searchParamNames [0 ]:
6969 utils .error (msgPrefix + " does not have a paramter with name " + paramName )
7070
71- def getSearchUrlName (recordType , recordTypeName , paramName ):
71+ # return the search url segment and list of dynamic attributes (if any)
72+ def getSearchInfo (recordType , recordTypeName , paramName ):
7273 filteredQuestions = list (filter (lambda search : 'InternalQuestions' not in search ['fullName' ], recordType ['searches' ]))
7374 if not len (filteredQuestions ) == 1 :
7475 utils .error ("RecordType " + recordTypeName + " has more than a single search" )
7576 search = filteredQuestions [0 ]
77+ dynAttrs = []
78+ for dynAttr in search ['dynamicAttributes' ]:
79+ if dynAttr ['name' ] != 'weight' :
80+ dynAttrs .append (dynAttr ['name' ])
7681 paramNames = search ['paramNames' ]
7782 validateSearchParam (paramName , search ['urlSegment' ], paramNames )
78- return search ['urlSegment' ]
83+ return { 'urlSegment' : search ['urlSegment' ], 'dynAttrs' : dynAttrs }
7984
80- def composeUrlParams (paramName , paramValue , recordType , batchType , batchName , batchTimestamp , batchId ):
85+ def composeUrlParams (paramName , paramValue , recordType , dynAttrs , batchType , batchName , batchTimestamp , batchId ):
8186 urlParams = {}
8287 if paramName is not None :
8388 urlParams [paramName ] = paramValue
@@ -87,15 +92,15 @@ def composeUrlParams(paramName, paramValue, recordType, batchType, batchName, ba
8792 reportConfig ['batch-name' ] = batchName
8893 reportConfig ['batch-timestamp' ] = batchTimestamp
8994 reportConfig ['batch-id' ] = batchId
90- attributeNames = list (map (lambda attribute : attribute ['name' ], recordType ['attributes' ]))
95+ attributeNames = dynAttrs + list (map (lambda attribute : attribute ['name' ], recordType ['attributes' ]))
9196 reportConfig ['attributes' ] = [attr for attr in attributeNames if attr not in recordType ['primaryKeyColumnRefs' ]]
9297 reportConfig ['tables' ] = list (map (lambda table : table ['name' ], recordType ['tables' ]))
9398 urlParams ['reportConfig' ] = json .dumps (reportConfig )
9499 return urlParams
95100
96- def runReportToFile (wdkServiceUrl , workingDir , recordTypeName , searchName , paramName , paramValue , recordType , batchType , batchName , batchTimestamp , batchId ):
101+ def runReportToFile (wdkServiceUrl , workingDir , recordTypeName , searchName , dynAttrs , paramName , paramValue , recordType , batchType , batchName , batchTimestamp , batchId ):
97102 reportUrl = wdkServiceUrl + '/record-types/' + recordTypeName + '/searches/' + searchName + '/reports/' + REPORTNAME + '?'
98- urlParams = composeUrlParams (paramName , paramValue , recordType , batchType , batchName , batchTimestamp , batchId )
103+ urlParams = composeUrlParams (paramName , paramValue , recordType , dynAttrs , batchType , batchName , batchTimestamp , batchId )
99104 targetFilename = workingDir + "/" + recordTypeName + ".json"
100105 with requests .get (url = reportUrl , params = urlParams , stream = True ) as response :
101106 if (response .status_code != 200 ):
@@ -125,8 +130,8 @@ for recordTypeName in utils.getRecordTypeNames(wdkServiceUrl):
125130 recordType = utils .getRecordType (wdkServiceUrl , recordTypeName )
126131 if (checkRecordTypeBatch (recordType , batchType )):
127132 print (str (datetime .datetime .now ()) + " Processing record type: " + recordType ['nativeDisplayName' ], flush = True )
128- searchUrlName = getSearchUrlName (recordType , recordTypeName , paramName )
129- runReportToFile (wdkServiceUrl , outputDir , recordTypeName , searchUrlName , paramName , paramValue , recordType , batchType , batchName , batchTimestamp , batchId )
133+ searchInfo = getSearchInfo (recordType , recordTypeName , paramName )
134+ runReportToFile (wdkServiceUrl , outputDir , recordTypeName , searchInfo [ 'urlSegment' ], searchInfo [ 'dynAttrs' ] , paramName , paramValue , recordType , batchType , batchName , batchTimestamp , batchId )
130135
131136# write meta file about this batch
132137print (str (datetime .datetime .now ()) + " writing batch.json" , flush = True )
0 commit comments