def createGenericreportobject(self):
     #ReportModule=CustomObject()
     with open(self.filename, "rb") as binary_file:
         self.file_ref = bytearray(binary_file.read())
         index = self.filename.rfind('\\')
         self.name = self.filename[index + 1:]
         if self.filename.endswith(".csv"):
             with open(self.filename) as csvfile:
                 readCSV = csv.reader(csvfile)
                 for row in readCSV:
                     ReportModule = CustomObject()
                     self.saveObject(ReportModule, row[0] + "." + row[1],
                                     "GenericReport", self.file,
                                     self.filename,
                                     "GenericReport_" + row[0] + row[1])
                     ReportModule.save()
         #self.saveObject(ReportModule,self.name,"GenericReport",self.file,self.filename,"GenericReport_"+self.filename)
         #ReportModule.save()
         else:
             ReportModule = CustomObject()
             #Print.debug("Other than CSV file-----------")
             self.saveObject(ReportModule, self.name, "GenericReport",
                             self.file, self.filename,
                             "GenericReport_" + self.filename)
             ReportModule.save()
         checksum = self.getcrc(self.file_ref)
         Print.debug("checksum == " + str(checksum))
         ReportModule.save_property('checksum.CodeOnlyChecksum', checksum)
         Print.debug("End of Analysis!!!")
    def add_sqlnamedquery(sqltable, sql_queries, resultMaps, typeAliases, file,
                          namespace):
        for sqlid, node in sqltable.items():
            log.info('NEW Named Query - %s' % sqlid)

            sqlquery = CustomObject()
            sqlquery.set_name(sqlid)
            sqlquery.set_type('CAST_SQL_NamedQuery')
            sqlquery.set_parent(file)
            sqlquery.save()

            #Get SQL from node
            sql = node.text
            for sub_node in node:
                if 'refid' in sub_node.attrib and sub_node.attrib[
                        'refid'] in sql_queries:
                    sql += sql_queries[sub_node.attrib['refid']].text.strip()
                if sub_node.tail:
                    sql += sub_node.tail

            #log.info('SQL: %s' % sql)
            sqlquery.save_property('CAST_SQL_MetricableQuery.sqlQuery', sql)

            log.info(' - creating links...')
            for embedded in external_link.analyse_embedded(sql):
                for t in embedded.types:
                    #log.info(' - link to : %s' % embedded.callee.get_name())
                    link = create_link(t, sqlquery, embedded.callee)
                    link.mark_as_not_sure()

            #Save all potential properties for later use
            CommonParsing.add_property(sqlquery, node, 'parameterClass',
                                       typeAliases)
            CommonParsing.add_property(sqlquery, node, 'parameterType',
                                       typeAliases)
            CommonParsing.add_property(sqlquery, node, 'resultClass',
                                       typeAliases)
            CommonParsing.add_property(sqlquery, node, 'listClass',
                                       typeAliases)
            CommonParsing.add_property(sqlquery, node, 'resultMap',
                                       typeAliases)
            CommonParsing.add_property(sqlquery, node, 'resultType',
                                       typeAliases)
            CommonParsing.add_property(sqlquery, node, 'parameterMap',
                                       typeAliases)

            if (namespace != ''):
                log.debug('Habemus namespacus!')
                sqlquery.save_property('iBatisProperties.namespace', namespace)

            for mapId, mapClass in resultMaps.items():
                if 'resultMap' in node.attrib and node.attrib[
                        'resultMap'] == mapId:
                    log.debug(' - class: %s' % mapClass)
                    sqlquery.save_property('iBatisProperties.class', mapClass)