Пример #1
0
 def _generateDataTableHtml(self, fileManData, fileNo, outDir):
     isLargeFile = len(fileManData.dataEntries) > 4500
     tName = normalizePackageName(fileManData.name)
     # Note: We are not normalizing fileNo here
     with open(os.path.join(outDir, "%s.html" % fileNo), 'w') as output:
         output.write("<html>\n")
         if isLargeFile:
             ajexSrc = "%s_array.txt" % fileNo
             outputLargeDataListTableHeader(output, ajexSrc, tName)
         else:
             outputDataListTableHeader(output, tName)
         output.write("<body id=\"dt_example\">")
         output.write("""<div id="container" style="width:80%">""")
         output.write("<h1>File %s(%s) Data List</h1>" % (tName, fileNo))
         writeTableListInfo(output, tName)
         if not isLargeFile:
             output.write("<tbody>\n")
             rows = self._getTableRows(fileManData, fileNo)
             for tableRow in rows:
                 output.write("<tr>\n")
                 for item in tableRow:
                     output.write("<td>%s</td>\n" % item)
                 output.write("</tr>\n")
         output.write("</tbody>\n")
         output.write("</table>\n")
         output.write("</div>\n")
         output.write("</div>\n")
         output.write("</body></html>\n")
     if isLargeFile:
         logger.info("Writing Ajax file: %s" % ajexSrc)
         """ Write out the data file in JSON format """
         outJson = {"aaData": self._getTableRows(fileManData, fileNo)}
         with open(os.path.join(outDir, ajexSrc), 'w') as output:
             json.dump(outJson, output)
Пример #2
0
 def _generateDataListByPackage(self, dataEntryLst, pkgName, list_fields,
                                listName, columnNames, searchColumnNames, fileNo,
                                custom_header=None):
   outDir = os.path.join(self.outDir, fileNo.replace(".","_"))
   with open("%s/%s-%s.html" % (outDir, pkgName, listName), 'w+') as output:
     output.write("<html>\n")
     tName = safeElementId("%s-%s" % (listName, pkgName))
     outputDataListTableHeader(output, tName, columnNames, searchColumnNames)
     output.write("<body id=\"dt_example\">")
     output.write("""<div id="container" style="width:80%">""")
     if pkgName == "All":
       pkgLinkName = pkgName
       output.write("<h1>%s %s List</h1>" % (pkgLinkName, listName))
     else:
       output.write("<h2 align=\"right\"><a href=\"./All-%s.html\">"
                    "All %s</a></h2>" % (listName, listName))
       pkgLinkName = getPackageHRefLink(pkgName)
       output.write("<h1>Package: %s %s List</h1>" % (pkgLinkName, listName))
     if not custom_header:
       outputDataTableHeader(output, columnNames, tName)
       outputDataTableFooter(output, columnNames, tName)
     else:
       outputCustomDataTableHeader(output, custom_header, tName)
       outputDataTableFooter(output, columnNames, tName)
     """ table body """
     output.write("<tbody>\n")
     for dataEntry in dataEntryLst:
       tableRow = [""]*len(list_fields)
       allFields = dataEntry.fields
       output.write("<tr>\n")
       for idx, id in enumerate(list_fields):
         # If value has / in it, we take the first value as usual
         # but assume the information is a "multiple" field and
         # attempt to find the second bit of information within it
         idVal,multval = id[1].split('/') if (len(id[1].split('/')) > 1) else (id[1],None)
         if idVal in allFields:
           value = allFields[idVal].value
           if multval:  # and (multval in value.dataEntries["1"].fields)
             value = self.findSubValue(dataEntry, value,multval,id);
           if type(value) is list:
             tmpValue="<ul>"
             for entry in value:
               if id[-1]:
                 tmpValue += "<li>"+id[-1](dataEntry, entry,sourceField=id[1], targetField=id[-2], glbData=self.dataMap, crossRef=self.crossRef)+"</li>"
               else:
                 tmpValue += "<li>"+ entry +"</li>"
             value = tmpValue+"</ul>"
           else:
             if id[-1]:
               value = id[-1](dataEntry, value,sourceField=id[1], targetField=id[-2], glbData=self.dataMap, crossRef=self.crossRef)
           tableRow[idx] = value
       for item in tableRow:
         #output.write("<td class=\"ellipsis\">%s</td>\n" % item)
         output.write("<td>%s</td>\n" % item)
       output.write("</tr>\n")
     output.write("</tbody>\n")
     output.write("</table>\n")
     output.write("</div>\n")
     output.write("</div>\n")
     output.write ("</body></html>\n")
Пример #3
0
 def _generateDataTableHtml(self, fileManData, fileNo):
   outDir = self.outDir
   isLargeFile = len(fileManData.dataEntries) > 4500
   tName = normalizePackageName(fileManData.name)
   outDir = os.path.join(self.outDir, fileNo.replace(".","_"))
   if not os.path.exists(outDir):
     os.mkdir(outDir)
   with open("%s/%s.html" % (outDir, fileNo), 'w') as output:
     output.write("<html>\n")
     if isLargeFile:
       ajexSrc = "%s_array.txt" % fileNo
       outputLargeDataListTableHeader(output, ajexSrc, tName)
     else:
       outputDataListTableHeader(output, tName)
     output.write("<body id=\"dt_example\">")
     output.write("""<div id="container" style="width:80%">""")
     output.write("<h1>File %s(%s) Data List</h1>" % (tName, fileNo))
     writeTableListInfo(output, tName)
     if not isLargeFile:
       output.write("<tbody>\n")
       for ien in getKeys(fileManData.dataEntries.keys(), float):
         dataEntry = fileManData.dataEntries[ien]
         if not dataEntry.name:
           logging.warn("no name for %s" % dataEntry)
           continue
         name = dataEntry.name
         if isFilePointerType(dataEntry):
           link, name = convertFilePointerToHtml(dataEntry.name)
         dataHtmlLink = "<a href=\"../%s/%s\">%s</a>" % (fileNo.replace(".","_"),getDataEntryHtmlFile(dataEntry, ien, fileNo),
                                                   name)
         tableRow = [dataHtmlLink, dataEntry.ien]
         output.write("<tr>\n")
         """ table body """
         for item in tableRow:
           output.write("<td>%s</td>\n" % item)
         output.write("</tr>\n")
     output.write("</tbody>\n")
     output.write("</table>\n")
     output.write("</div>\n")
     output.write("</div>\n")
     output.write ("</body></html>\n")
   if isLargeFile:
     logging.info("Ajex source file: %s" % ajexSrc)
     """ Write out the data file in JSON format """
     outJson = {"aaData": []}
     with open(os.path.join(outDir, ajexSrc), 'w') as output:
       outArray =  outJson["aaData"]
       for ien in getKeys(fileManData.dataEntries.keys(), float):
         dataEntry = fileManData.dataEntries[ien]
         if not dataEntry.name:
           logging.warn("no name for %s" % dataEntry)
           continue
         name = dataEntry.name
         if isFilePointerType(dataEntry):
           link, name = convertFilePointerToHtml(dataEntry.name)
         dataHtmlLink = "<a href=\"../%s/%s\">%s</a>" % (fileNo.replace(".","_"),getDataEntryHtmlFile(dataEntry, ien, fileNo),
                                                   name)
         outArray.append([dataHtmlLink, ien])
       json.dump(outJson, output)
Пример #4
0
    def _generateICRSummaryPageImpl(self, inputJson, listName, pkgName, isForAll=False):
        outDir = self._outDir
        pkgHtmlName = pkgName
        outFilename = "%s/%s-%s.html" % (outDir, pkgName, listName)
        if not isForAll:
            if pkgName in pkgMap:
                pkgName = pkgMap[pkgName]
            pkgHtmlName = pkgName + '-ICR.html'
            outFilename = "%s/%s" % (outDir, pkgHtmlName)
        with open(outFilename, 'w+') as output:
            output.write("<html>\n")
            tName = safeElementId("%s-%s" % (listName, pkgName))
            useAjax = useAjaxDataTable(len(inputJson))
            columnNames = [x[0] for x in summary_list_fields]
            searchColumns = ['IA #', 'Name', 'Custodial Package',
                             'Date Created', 'File #', 'Remote Procedure',
                             'Routine', 'Date Activated']
            if useAjax:
                ajaxSrc = '%s_array.txt' % pkgName
                outputLargeDataListTableHeader(output, ajaxSrc, tName,
                                                columnNames, searchColumns)
            else:
                outputDataListTableHeader(output, tName, columnNames, searchColumns)
            output.write("<body id=\"dt_example\">")
            output.write("""<div id="container" style="width:80%">""")

            if isForAll:
                output.write("<h1>%s %s</h1>" % (pkgName, listName))
            else:
                output.write("<h2 align=\"right\"><a href=\"./All-%s.html\">"
                             "All %s</a></h2>" % (listName, listName))
                output.write("<h1>Package: %s %s</h1>" % (pkgName, listName))
            # pkgLinkName = getPackageHRefLink(pkgName)
            outputDataTableHeader(output, columnNames, tName)
            outputDataTableFooter(output, columnNames, tName)
            """ table body """
            output.write("<tbody>\n")
            if not useAjax:
                """ Now convert the ICR Data to Table data """
                for icrSummary in inputJson:
                    output.write("<tr>\n")
                    for item in icrSummary:
                        #output.write("<td class=\"ellipsis\">%s</td>\n" % item)
                        output.write("<td>%s</td>\n" % item)
                    output.write("</tr>\n")
            else:
                logging.info("Ajax source file: %s" % ajaxSrc)
                """ Write out the data file in JSON format """
                outJson = {"aaData": []}
                with open(os.path.join(outDir, ajaxSrc), 'w') as ajaxOut:
                    outArray =  outJson["aaData"]
                    for icrSummary in inputJson:
                        outArray.append(icrSummary)
                    json.dump(outJson, ajaxOut)
            output.write("</tbody>\n")
            output.write("</table>\n")
            output.write("</div>\n")
            output.write("</div>\n")
            output.write ("</body></html>\n")
Пример #5
0
 def _generateDataTableHtml(self, fileManData, fileNo):
     outDir = self.outDir
     isLargeFile = len(fileManData.dataEntries) > 4500
     tName = normalizePackageName(fileManData.name)
     with open("%s/%s.html" % (outDir, fileNo), "w") as output:
         output.write("<html>\n")
         if isLargeFile:
             ajexSrc = "%s_array.txt" % fileNo
             outputLargeDataListTableHeader(output, ajexSrc, tName)
         else:
             outputDataListTableHeader(output, tName)
         output.write('<body id="dt_example">')
         output.write("""<div id="container" style="width:80%">""")
         output.write("<h1>File %s(%s) Data List</h1>" % (tName, fileNo))
         writeTableListInfo(output, tName)
         if not isLargeFile:
             output.write("<tbody>\n")
             for ien in getKeys(fileManData.dataEntries.keys(), float):
                 dataEntry = fileManData.dataEntries[ien]
                 if not dataEntry.name:
                     logging.warn("no name for %s" % dataEntry)
                     continue
                 name = dataEntry.name
                 if isFilePointerType(dataEntry):
                     link, name = convertFilePointerToHtml(dataEntry.name)
                 dataHtmlLink = '<a href="%s">%s</a>' % (getDataEntryHtmlFile(dataEntry, ien, fileNo), name)
                 tableRow = [dataHtmlLink, dataEntry.ien]
                 output.write("<tr>\n")
                 """ table body """
                 for item in tableRow:
                     output.write("<td>%s</td>\n" % item)
                 output.write("</tr>\n")
         output.write("</tbody>\n")
         output.write("</table>\n")
         output.write("</div>\n")
         output.write("</div>\n")
         output.write("</body></html>\n")
     if isLargeFile:
         logging.info("Ajex source file: %s" % ajexSrc)
         """ Write out the data file in JSON format """
         outJson = {"aaData": []}
         with open(os.path.join(outDir, ajexSrc), "w") as output:
             outArray = outJson["aaData"]
             for ien in getKeys(fileManData.dataEntries.keys(), float):
                 dataEntry = fileManData.dataEntries[ien]
                 if not dataEntry.name:
                     logging.warn("no name for %s" % dataEntry)
                     continue
                 name = dataEntry.name
                 if isFilePointerType(dataEntry):
                     link, name = convertFilePointerToHtml(dataEntry.name)
                 dataHtmlLink = '<a href="%s">%s</a>' % (getDataEntryHtmlFile(dataEntry, ien, fileNo), name)
                 outArray.append([dataHtmlLink, ien])
             json.dump(outJson, output)
Пример #6
0
def generateListingPage(outDir, pageData, dataType):
    outDir = os.path.join(outDir, dataType.replace(".","_"))
    if not os.path.exists(outDir):
      os.mkdir(outDir)
    with open("%s/%s.html" % (outDir, dataType), 'w') as output:
      output.write("<html>\n")
      outputDataListTableHeader(output, dataType,pageData["headers"],pageData["headers"],[])
      output.write("<body id=\"dt_example\">")
      output.write("""<div id="container" style="width:80%">""")
      output.write("<h1> %s Data List</h1>" % (dataType))
      outputCustomDataTableHeader(output, pageData["headers"],dataType)
      output.write("<tbody>\n")
      for object in pageData["records"]:
        object.pop(0)
        output.write("<tr>\n")
        # """ table body """
        for idx, item in enumerate(object):
          pageObject = item
          if idx in [0, 5]:  # Col 0 in Namespace table is namespace, Col 5 in Numberspace table is namespace
            pageObject=""
            allnmsp = item.split(",")
            for nmsp in allnmsp:
              result = crossRef.__categorizeVariableNameByNamespace__(nmsp.strip())
              if result[0] != None:
                pageObject += """<a href='../dox/%s'>%s</a></br> """ % (getPackageHtmlFileName(result[1].getName()),nmsp)
              else:
                pageObject += nmsp + "</br>"
            output.write("<td>%s</td>\n" % pageObject)
          else:
                output.write("<td>%s</td>\n" % item)
        output.write("</tr>\n")
      output.write("</tbody>\n")
      output.write("</table>\n")
      output.write("</div>\n")
      output.write("</div>\n")
      output.write ("</body></html>\n")
Пример #7
0
 def _generatePkgDepSummaryPage(self, inputJson, date):
     outDep = {}
     for icrItem in inputJson:
         curIaNum = icrItem['IA #']
         # ignore the non-active icrs
         if 'STATUS' not in icrItem or icrItem['STATUS'] != 'Active':
             continue
         if 'CUSTODIAL PACKAGE' in icrItem:
             curPkg = icrItem['CUSTODIAL PACKAGE']
             outDep.setdefault(curPkg,{})
             if 'SUBSCRIBING PACKAGE' in icrItem:
                 for subPkg in icrItem['SUBSCRIBING PACKAGE']:
                     if 'SUBSCRIBING PACKAGE' in subPkg:
                         subPkgName = subPkg['SUBSCRIBING PACKAGE']
                         if isinstance(subPkgName,list):
                           for subPkgNameEntry in subPkgName:
                             subDep = outDep.setdefault(subPkgNameEntry, {}).setdefault('dependencies',{})
                             subDep.setdefault(curPkg, []).append(curIaNum)
                             curDep = outDep.setdefault(curPkg, {}).setdefault('dependents', {})
                             curDep.setdefault(subPkgNameEntry, []).append(curIaNum)
                         else:
                           subDep = outDep.setdefault(subPkgName, {}).setdefault('dependencies',{})
                           subDep.setdefault(curPkg, []).append(curIaNum)
                           curDep = outDep.setdefault(curPkg, {}).setdefault('dependents', {})
                           curDep.setdefault(subPkgName, []).append(curIaNum)
     """ Convert outDep to html page """
     outDir = self._outDir
     outFilename = "%s/ICR-PackageDep.html" % outDir
     with open(outFilename, 'w+') as output:
         output.write("<html>\n")
         tName = safeElementId("%s-%s" % ('ICR', 'PackageDep'))
         outputDataListTableHeader(output, tName)
         output.write("<body id=\"dt_example\">")
         output.write("""<div id="container" style="width:80%">""")
         outputDataTableHeader(output, ['Package Name', 'Dependencies Information'], tName)
         """ table body """
         output.write("<tbody>\n")
         """ Now convert the ICR Data to Table data """
         for pkgName in sorted(outDep.iterkeys()):
             output.write("<tr>\n")
             output.write("<td>%s</td>\n" % getPackageHRefLink(pkgName, {'CUSTODIAL PACKAGE': pkgName}, crossRef=self._crossRef))
             """ Convert the dependencies and dependent information """
             output.write("<td>\n")
             output.write ("<ol>\n")
             for pkgDepType in sorted(outDep[pkgName].iterkeys()):
                 output.write ("<li>\n")
                 output.write ("<dt>%s:</dt>\n" % pkgDepType.upper())
                 depPkgInfo = outDep[pkgName][pkgDepType]
                 for depPkgName in sorted(depPkgInfo.iterkeys()):
                     outputInfo = getPackageHRefLink(depPkgName, {'CUSTODIAl PACKAGE': depPkgName}, crossRef=self._crossRef)
                     outputInfo += ': &nbsp;&nbsp Total # of ICRs %s : [' % len(depPkgInfo[depPkgName])
                     for icrNo in depPkgInfo[depPkgName]:
                         outputInfo += getICRIndividualHtmlFileLinkByIen(icrNo, {'NUMBER': icrNo}, crossRef=self._crossRef) + '&nbsp;&nbsp'
                     outputInfo += ']'
                     output.write ("<dt>%s:</dt>\n" % outputInfo)
                 output.write ("</li>\n")
             output.write ("</ol>\n")
             output.write("</td>\n")
             output.write ("</tr>\n")
         output.write("</tbody>\n")
         output.write("</table>\n")
         if date is not None:
             link = "http://foia-vista.osehra.org/VistA_Integration_Agreement/"
             output.write("<a href=\"%s\">Generated from %s IA Listing Descriptions</a>" % (link, date))
         output.write("</div>\n")
         output.write("</div>\n")
         output.write ("</body></html>\n")
Пример #8
0
    def _generateRequirementsSummaryPageImpl(self,
                                             inputJson,
                                             listName,
                                             pkgName,
                                             isForAll=False):
        outDir = self._outDir
        listName = listName.strip()
        pkgName = pkgName.strip()
        # TODO: Use Utility functions to generate filename name
        pkgHtmlName = pkgName.replace('/', '_')
        outFilename = "%s/%s-%s.html" % (outDir, pkgName.replace(
            '/', '_'), listName)
        if not isForAll:
            outFilename = "%s/%s-Req.html" % (outDir, pkgHtmlName)
        with open(outFilename, 'w+') as output:
            output.write("<html>\n")
            tName = "%s-%s" % (listName.replace(
                ' ', '_'), pkgName.replace(' ', '_'))
            useAjax = False  #useAjaxDataTable(len(inputJson))
            columnNames = fieldList
            searchColumns = searchColumnList
            if useAjax:
                ajaxSrc = '%s_array.txt' % pkgName
                outputLargeDataListTableHeader(output, ajaxSrc, tName,
                                               columnNames, searchColumns)
            else:
                outputDataListTableHeader(output,
                                          tName,
                                          columnNames,
                                          searchColumns,
                                          hideColumnNames=['Recently Updated'])
            output.write("<body id=\"dt_example\">")
            output.write("""<div id="container" style="width:80%">""")

            if isForAll:
                output.write("<h1>%s %s</h1>" % (pkgName, listName))
                reqData = inputJson
            else:
                reqData = inputJson[pkgName]
                output.write("<h2 align=\"right\"><a href=\"./All-%s.html\">"
                             "All %s</a></h2>" % (listName, listName))
                output.write("<h1>BFF Entry: %s %s</h1>" % (pkgName, listName))
            outputDataTableHeader(output, columnNames, tName)
            outputDataTableFooter(output, columnNames, tName)
            """ table body """
            output.write("<tbody>\n")
            if not useAjax:
                """ Now convert the requirements Data to Table data """
                for reqEntry in reqData:
                    output.write("<tr>\n")
                    if not isForAll:
                        reqSummary = self._convertReqEntryToSummaryInfo(
                            reqEntry)
                        if not reqSummary in allReqs:
                            allReqs.append(reqSummary)
                    else:
                        reqSummary = reqEntry
                    for idx, item in enumerate(fieldList):
                        # List of objects should be displayed as a UL object
                        if isinstance(reqSummary[idx], list):
                            output.write("<td><ul>")
                            for entry in reqSummary[idx]:
                                if pkgName in entry:
                                    output.write(
                                        "<li class='disabled'>%s</li>\n" %
                                        entry)
                                else:
                                    output.write("<li>%s</li>\n" % entry)
                            output.write("</ul></td>")
                        # Otherwise, write it out as is
                        else:
                            if pkgName in str(reqSummary[idx]):
                                output.write("<td class='disabled'>%s</td>\n" %
                                             reqSummary[idx])
                            else:
                                output.write("<td>%s</td>\n" % reqSummary[idx])
                    output.write("</tr>\n")
            else:
                logger.info("Ajax source file: %s" % ajaxSrc)
                """ Write out the data file in JSON format """
                outJson = {"aaData": []}
                with open(os.path.join(outDir, ajaxSrc), 'w') as ajaxOut:
                    outArray = outJson["aaData"]
                    for reqSummary in inputJson:
                        outArray.append(reqSummary)
                    json.dump(outJson, ajaxOut)
            output.write("</tbody>\n")
            output.write("</table>\n")
            output.write("</div>\n")
            output.write("</div>\n")
            output.write("</body></html>\n")
Пример #9
0
def _generateICRSummaryPageImpl(inputJson, listName, pkgName, date, outDir,
                                isForAll=False):
    listName = listName.strip()
    pkgName = pkgName.strip()
    pkgHtmlName = pkgName
    outFilename = os.path.join(outDir, "%s-%s.html" % (pkgName, listName))
    if not isForAll:
        if pkgName in PACKAGE_MAP:
            pkgName = PACKAGE_MAP[pkgName]
        pkgHtmlName = pkgName + '-ICR.html'
        outFilename = "%s/%s" % (outDir, pkgHtmlName)
    with open(outFilename, 'w+') as output:
        output.write("<html>\n")
        tName = "%s-%s" % (listName.replace(' ', '_'), pkgName.replace(' ', '_'))
        useAjax = _useAjaxDataTable(len(inputJson))
        columnNames = [x[0] for x in SUMMARY_LIST_FIELDS]
        searchColumns = ['IA #', 'Name', 'Custodial Package',
                         'Date Created', 'File #', 'Remote Procedure',
                         'Routine', 'Date Activated', 'General Description']
        hideColumns = ['General Description']
        if useAjax:
            ajaxSrc = '%s_array.txt' % pkgName
            outputLargeDataListTableHeader(output, ajaxSrc, tName,
                                           columnNames, searchColumns,
                                           hideColumns)
        else:
            outputDataListTableHeader(output, tName, columnNames,
                                      searchColumns, hideColumns)
        output.write("<body id=\"dt_example\">")
        output.write("""<div id="container" style="width:80%">""")

        if isForAll:
            output.write("<h1>%s %s</h1>" % (pkgName, listName))
        else:
            output.write("<h2 align=\"right\"><a href=\"./All-%s.html\">"
                         "All %s</a></h2>" % (listName, listName))
            output.write("<h1>Package: %s %s</h1>" % (pkgName, listName))
        # pkgLinkName = _getPackageHRefLink(pkgName)
        outputDataTableHeader(output, columnNames, tName)
        outputDataTableFooter(output, columnNames, tName)
        """ table body """
        output.write("<tbody>\n")
        if not useAjax:
            """ Now convert the ICR Data to Table data """
            for icrSummary in inputJson:
                output.write("<tr>\n")
                for item in icrSummary:
                    #output.write("<td class=\"ellipsis\">%s</td>\n" % item)
                    output.write("<td>%s</td>\n" % item)
                output.write("</tr>\n")
        else:
            logger.debug("Ajax source file: %s" % ajaxSrc)
            """ Write out the data file in JSON format """
            outJson = {"aaData": []}
            with open(os.path.join(outDir, ajaxSrc), 'w') as ajaxOut:
                outArray =  outJson["aaData"]
                for icrSummary in inputJson:
                    outArray.append(icrSummary)
                json.dump(outJson, ajaxOut)
        output.write("</tbody>\n")
        output.write("</table>\n")
        if date is not None:
            link = "https://foia-vista.osehra.org/VistA_Integration_Agreement/"
            output.write("<a href=\"%s\">Generated from %s IA Listing Descriptions</a>" % (link, date))
        output.write("</div>\n")
        output.write("</div>\n")
        output.write ("</body></html>\n")
Пример #10
0
    def _generateICRSummaryPageImpl(self, inputJson, listName, pkgName, date, isForAll=False):
        outDir = self._outDir
        listName = listName.strip()
        pkgName = pkgName.strip()
        pkgHtmlName = pkgName
        outFilename = "%s/%s-%s.html" % (outDir, pkgName, listName)
        if not isForAll:
            if pkgName in pkgMap:
                pkgName = pkgMap[pkgName]
            pkgHtmlName = pkgName + '-ICR.html'
            outFilename = "%s/%s" % (outDir, pkgHtmlName)
        with open(outFilename, 'w+') as output:
            output.write("<html>\n")
            tName = "%s-%s" % (listName.replace(' ', '_'), pkgName.replace(' ', '_'))
            useAjax = useAjaxDataTable(len(inputJson))
            columnNames = [x[0] for x in summary_list_fields]
            searchColumns = ['IA #', 'Name', 'Custodial Package',
                             'Date Created', 'File #', 'Remote Procedure',
                             'Routine', 'Date Activated', 'General Description']
            hideColumns = ['General Description']
            if useAjax:
                ajaxSrc = '%s_array.txt' % pkgName
                outputLargeDataListTableHeader(output, ajaxSrc, tName,
                                               columnNames, searchColumns,
                                               hideColumns)
            else:
                outputDataListTableHeader(output, tName, columnNames,
                                          searchColumns, hideColumns)
            output.write("<body id=\"dt_example\">")
            output.write("""<div id="container" style="width:80%">""")

            if isForAll:
                output.write("<h1>%s %s</h1>" % (pkgName, listName))
            else:
                output.write("<h2 align=\"right\"><a href=\"./All-%s.html\">"
                             "All %s</a></h2>" % (listName, listName))
                output.write("<h1>Package: %s %s</h1>" % (pkgName, listName))
            # pkgLinkName = getPackageHRefLink(pkgName)
            outputDataTableHeader(output, columnNames, tName)
            outputDataTableFooter(output, columnNames, tName)
            """ table body """
            output.write("<tbody>\n")
            if not useAjax:
                """ Now convert the ICR Data to Table data """
                for icrSummary in inputJson:
                    output.write("<tr>\n")
                    for item in icrSummary:
                        #output.write("<td class=\"ellipsis\">%s</td>\n" % item)
                        output.write("<td>%s</td>\n" % item)
                    output.write("</tr>\n")
            else:
                logging.info("Ajax source file: %s" % ajaxSrc)
                """ Write out the data file in JSON format """
                outJson = {"aaData": []}
                with open(os.path.join(outDir, ajaxSrc), 'w') as ajaxOut:
                    outArray =  outJson["aaData"]
                    for icrSummary in inputJson:
                        outArray.append(icrSummary)
                    json.dump(outJson, ajaxOut)
            output.write("</tbody>\n")
            output.write("</table>\n")
            if date is not None:
                link = "https://foia-vista.osehra.org/VistA_Integration_Agreement/"
                output.write("<a href=\"%s\">Generated from %s IA Listing Descriptions</a>" % (link, date))
            output.write("</div>\n")
            output.write("</div>\n")
            output.write ("</body></html>\n")
Пример #11
0
 def _generatePkgDepSummaryPage(self, inputJson, date):
     outDep = {}
     for icrItem in inputJson:
         curIaNum = icrItem['IA #']
         # ignore the non-active icrs
         if 'STATUS' not in icrItem or icrItem['STATUS'] != 'Active':
             continue
         if 'CUSTODIAL PACKAGE' in icrItem:
             curPkg = icrItem['CUSTODIAL PACKAGE']
             outDep.setdefault(curPkg,{})
             if 'SUBSCRIBING PACKAGE' in icrItem:
                 for subPkg in icrItem['SUBSCRIBING PACKAGE']:
                     if 'SUBSCRIBING PACKAGE' in subPkg:
                         subPkgName = subPkg['SUBSCRIBING PACKAGE']
                         if isinstance(subPkgName,list):
                           for subPkgNameEntry in subPkgName:
                             subDep = outDep.setdefault(subPkgNameEntry, {}).setdefault('dependencies',{})
                             subDep.setdefault(curPkg, []).append(curIaNum)
                             curDep = outDep.setdefault(curPkg, {}).setdefault('dependents', {})
                             curDep.setdefault(subPkgNameEntry, []).append(curIaNum)
                         else:
                           subDep = outDep.setdefault(subPkgName, {}).setdefault('dependencies',{})
                           subDep.setdefault(curPkg, []).append(curIaNum)
                           curDep = outDep.setdefault(curPkg, {}).setdefault('dependents', {})
                           curDep.setdefault(subPkgName, []).append(curIaNum)
     """ Convert outDep to html page """
     outFilename = "%s/ICR-PackageDep.html" % self._outDir
     with open(outFilename, 'w+') as output:
         output.write("<html>\n")
         tName = safeElementId("%s-%s" % ('ICR', 'PackageDep'))
         outputDataListTableHeader(output, tName)
         output.write("<body id=\"dt_example\">")
         output.write("""<div id="container" style="width:80%">""")
         outputDataTableHeader(output, ['Package Name', 'Dependencies Information'], tName)
         """ table body """
         output.write("<tbody>\n")
         """ Now convert the ICR Data to Table data """
         for pkgName in sorted(outDep.iterkeys()):
             output.write("<tr>\n")
             output.write("<td>%s</td>\n" % getPackageHRefLink(pkgName, {'CUSTODIAL PACKAGE': pkgName}, crossRef=self._crossRef))
             """ Convert the dependencies and dependent information """
             output.write("<td>\n")
             output.write ("<ol>\n")
             for pkgDepType in sorted(outDep[pkgName].iterkeys()):
                 output.write ("<li>\n")
                 output.write ("<dt>%s:</dt>\n" % pkgDepType.upper())
                 depPkgInfo = outDep[pkgName][pkgDepType]
                 for depPkgName in sorted(depPkgInfo.iterkeys()):
                     outputInfo = getPackageHRefLink(depPkgName, {'CUSTODIAl PACKAGE': depPkgName}, crossRef=self._crossRef)
                     outputInfo += ': &nbsp;&nbsp Total # of ICRs %s : [' % len(depPkgInfo[depPkgName])
                     for icrNo in depPkgInfo[depPkgName]:
                         outputInfo += getICRIndividualHtmlFileLinkByIen(icrNo, {'NUMBER': icrNo}, crossRef=self._crossRef) + '&nbsp;&nbsp'
                     outputInfo += ']'
                     output.write ("<dt>%s:</dt>\n" % outputInfo)
                 output.write ("</li>\n")
             output.write ("</ol>\n")
             output.write("</td>\n")
             output.write ("</tr>\n")
         output.write("</tbody>\n")
         output.write("</table>\n")
         if date is not None:
             link = "https://foia-vista.osehra.org/VistA_Integration_Agreement/"
             output.write("<a href=\"%s\">Generated from %s IA Listing Descriptions</a>" % (link, date))
         output.write("</div>\n")
         output.write("</div>\n")
         output.write ("</body></html>\n")
Пример #12
0
 def _generateDataListByPackage(self,
                                dataEntryLst,
                                pkgName,
                                list_fields,
                                listName,
                                columnNames,
                                searchColumnNames,
                                fileNoOutDir,
                                custom_header=None):
     filename = os.path.join(fileNoOutDir,
                             "%s-%s.html" % (pkgName, listName))
     with open(filename, 'w') as output:
         output.write("<html>\n")
         if pkgName == "All":
             tName = "%s %s List" % (normalizePackageName(pkgName),
                                     listName)
         else:
             tName = normalizePackageName(pkgName)
         outputDataListTableHeader(output, tName, columnNames,
                                   searchColumnNames)
         output.write("<body id=\"dt_example\">")
         output.write(
             "<a class=\"brand\" href=\"%s\" style=\"height:50px; padding: 0px;\"> \
               <img src=\"https://osehra.org/sites/default/files/vivian.png\" width=\"137\" height=\"50\"/></a>"
             % VIV_URL)
         output.write("""<div id="container" style="width:80%">""")
         if pkgName == "All":
             pkgLinkName = pkgName
             output.write("<h1>%s %s List</h1>" % (pkgLinkName, listName))
         else:
             output.write("<h2 align=\"right\"><a href=\"./All-%s.html\">"
                          "All %s</a></h2>" % (listName, listName))
             pkgLinkName = getPackageHRefLink(pkgName)
             output.write("<h1>Package: %s %s List</h1>" %
                          (pkgLinkName, listName))
         if not custom_header:
             outputDataTableHeader(output, columnNames, tName)
             outputDataTableFooter(output, columnNames, tName)
         else:
             outputCustomDataTableHeaderRows(output, custom_header, tName)
             outputDataTableFooter(output, columnNames, tName)
         # table body
         output.write("<tbody>\n")
         for dataEntry in dataEntryLst:
             tableRow = [""] * len(list_fields)
             allFields = dataEntry.fields
             output.write("<tr>\n")
             for idx, id in enumerate(list_fields):
                 # If value has / in it, we take the first value as usual
                 # but assume the information is a "multiple" field and
                 # attempt to find the second bit of information within it
                 idVal, multval = id[1].split('/') if (
                     len(id[1].split('/')) > 1) else (id[1], None)
                 if idVal in allFields:
                     value = allFields[idVal].value
                     if multval:  # and (multval in value.dataEntries["1"].fields)
                         value = self.findSubValue(dataEntry, value,
                                                   multval, id)
                     if isinstance(value, list) and id[0] != "Description":
                         # Don't write out descriptions as lists
                         tmpValue = "<ul>"
                         for entry in value:
                             if id[-1]:
                                 tmpValue += "<li>" + id[-1](
                                     dataEntry,
                                     entry,
                                     sourceField=id[1],
                                     targetField=id[-2],
                                     glbData=self.dataMap,
                                     crossRef=self.crossRef) + "</li>"
                             else:
                                 tmpValue += "<li>" + entry + "</li>"
                         value = tmpValue + "</ul>"
                     else:
                         if id[-1]:
                             value = id[-1](dataEntry,
                                            value,
                                            sourceField=id[1],
                                            targetField=id[-2],
                                            glbData=self.dataMap,
                                            crossRef=self.crossRef)
                     tableRow[idx] = value
             for item in tableRow:
                 output.write("<td>%s</td>\n" % item)
             output.write("</tr>\n")
         output.write("</tbody>\n")
         output.write("</table>\n")
         output.write("</div>\n")
         output.write("</div>\n")
         output.write("</body></html>\n")
Пример #13
0
    def _generateRequirementsSummaryPageImpl(self, inputJson, listName, pkgName, isForAll=False):
        outDir = self._outDir
        listName = listName.strip()
        pkgName = pkgName.strip()
        pkgHtmlName = pkgName.replace('/','_')
        outFilename = "%s/%s-%s.html" % (outDir, pkgName.replace('/','_'), listName)
        if not isForAll:
            outFilename = "%s/%s-Req.html" % (outDir, pkgHtmlName)
        with open(outFilename, 'w+') as output:
            output.write("<html>\n")
            tName = "%s-%s" % (listName.replace(' ', '_'), pkgName.replace(' ', '_'))
            useAjax = False #useAjaxDataTable(len(inputJson))
            columnNames = fieldList
            searchColumns = searchColumnList
            if useAjax:
                ajaxSrc = '%s_array.txt' % pkgName
                outputLargeDataListTableHeader(output, ajaxSrc, tName,
                                                columnNames, searchColumns)
            else:
                outputDataListTableHeader(output, tName, columnNames, searchColumns, hideColumnNames=['Recently Updated'])
            output.write("<body id=\"dt_example\">")
            output.write("""<div id="container" style="width:80%">""")

            if isForAll:
                output.write("<h1>%s %s</h1>" % (pkgName, listName))
                reqData= inputJson
            else:
                reqData=inputJson[pkgName]
                output.write("<h2 align=\"right\"><a href=\"./All-%s.html\">"
                             "All %s</a></h2>" % (listName, listName))
                output.write("<h1>BFF Entry: %s %s</h1>" % (pkgName, listName))
            outputDataTableHeader(output, columnNames, tName)
            outputDataTableFooter(output, columnNames, tName)
            """ table body """
            output.write("<tbody>\n")
            if not useAjax:
                """ Now convert the requirements Data to Table data """
                for reqEntry in reqData:
                    output.write("<tr>\n")
                    if not isForAll:
                      reqSummary = self._convertReqEntryToSummaryInfo(reqEntry);
                      if not reqSummary in allReqs:
                        allReqs.append(reqSummary)
                    else:
                      reqSummary = reqEntry
                    for idx,item in enumerate(fieldList):
                        # List of objects should be displayed as a UL object
                        if type(reqSummary[idx]) is list:
                          output.write("<td><ul>")
                          for entry in reqSummary[idx]:
                            if pkgName in entry:
                              output.write("<li class='disabled'>%s</li>\n" %  entry)
                            else:
                              output.write("<li>%s</li>\n" %  entry)
                          output.write("</ul></td>")
                        # Otherwise, write it out as is
                        else:
                          if pkgName in str(reqSummary[idx]):
                            output.write("<td class='disabled'>%s</td>\n" %  reqSummary[idx])
                          else:
                            output.write("<td>%s</td>\n" %  reqSummary[idx])
                    output.write("</tr>\n")
            else:
                logging.info("Ajax source file: %s" % ajaxSrc)
                """ Write out the data file in JSON format """
                outJson = {"aaData": []}
                with open(os.path.join(outDir, ajaxSrc), 'w') as ajaxOut:
                    outArray =  outJson["aaData"]
                    for reqSummary in inputJson:
                        outArray.append(reqSummary)
                    json.dump(outJson, ajaxOut)
            output.write("</tbody>\n")
            output.write("</table>\n")
            output.write("</div>\n")
            output.write("</div>\n")
            output.write ("</body></html>\n")
Пример #14
0
 def _generateDataListByPackage(self, dataEntryLst, pkgName, list_fields,
                                listName, columnNames, searchColumnNames,
                                fileNoOutDir, custom_header=None):
   filename = os.path.join(fileNoOutDir, "%s-%s.html" % (pkgName, listName))
   with open(filename, 'w') as output:
     output.write("<html>\n")
     if pkgName == "All":
       tName = "%s %s List" % (normalizePackageName(pkgName), listName)
     else:
       tName = normalizePackageName(pkgName)
     outputDataListTableHeader(output, tName, columnNames, searchColumnNames)
     output.write("<body id=\"dt_example\">")
     output.write("""<div id="container" style="width:80%">""")
     if pkgName == "All":
       pkgLinkName = pkgName
       output.write("<h1>%s %s List</h1>" % (pkgLinkName, listName))
     else:
       output.write("<h2 align=\"right\"><a href=\"./All-%s.html\">"
                    "All %s</a></h2>" % (listName, listName))
       pkgLinkName = getPackageHRefLink(pkgName)
       output.write("<h1>Package: %s %s List</h1>" % (pkgLinkName, listName))
     if not custom_header:
       outputDataTableHeader(output, columnNames, tName)
       outputDataTableFooter(output, columnNames, tName)
     else:
       outputCustomDataTableHeaderRows(output, custom_header, tName)
       outputDataTableFooter(output, columnNames, tName)
     """ table body """
     output.write("<tbody>\n")
     for dataEntry in dataEntryLst:
       tableRow = [""]*len(list_fields)
       allFields = dataEntry.fields
       output.write("<tr>\n")
       for idx, id in enumerate(list_fields):
         # If value has / in it, we take the first value as usual
         # but assume the information is a "multiple" field and
         # attempt to find the second bit of information within it
         idVal, multval = id[1].split('/') if (len(id[1].split('/')) > 1) else (id[1],None)
         if idVal in allFields:
           value = allFields[idVal].value
           if multval:  # and (multval in value.dataEntries["1"].fields)
             value = self.findSubValue(dataEntry, value,multval,id)
           if type(value) is list and id[0] != "Description":
             # Don't write out descriptions as lists
             tmpValue="<ul>"
             for entry in value:
               if id[-1]:
                 tmpValue += "<li>"+id[-1](dataEntry, entry,sourceField=id[1], targetField=id[-2], glbData=self.dataMap, crossRef=self.crossRef)+"</li>"
               else:
                 tmpValue += "<li>"+ entry +"</li>"
             value = tmpValue+"</ul>"
           else:
             if id[-1]:
               value = id[-1](dataEntry, value,sourceField=id[1], targetField=id[-2], glbData=self.dataMap, crossRef=self.crossRef)
           tableRow[idx] = value
       for item in tableRow:
         #output.write("<td class=\"ellipsis\">%s</td>\n" % item)
         output.write("<td>%s</td>\n" % item)
       output.write("</tr>\n")
     output.write("</tbody>\n")
     output.write("</table>\n")
     output.write("</div>\n")
     output.write("</div>\n")
     output.write ("</body></html>\n")