示例#1
0
 def _finalize(self):
     text_dlg = etree.SubElement(self.responsexml, "TEXT")
     text_dlg.attrib['type'] = six.text_type(self.msgtype)
     text_dlg.text = six.text_type(self.msgtext)
     if len(self.actions) != 0:
         self.responsexml.append(get_actions_xml(self.actions))
     XferContainerAbstract._finalize(self)
示例#2
0
 def _finalize(self):
     self.responsejson['print'] = {
         'mode': self.report_mode,
         'title': self.get_print_name(),
         'content': self.report_content.decode()
     }
     XferContainerAbstract._finalize(self)
示例#3
0
 def _finalize(self):
     self.responsejson['data'] = {
         'text': six.text_type(self.msgtext),
         'type': self.msgtype
     }
     self.responsejson['actions'] = get_actions_json(self.actions)
     XferContainerAbstract._finalize(self)
示例#4
0
 def _finalize(self):
     if self.redirect_act is not None:
         if self.format == 'JSON':
             self.responsejson['action'] = self.redirect_act[0].get_action_json(modal=self.redirect_act[1], close=self.redirect_act[2], params=self.redirect_act[3])
         else:
             self.responsexml.append(self.redirect_act[0].get_action_xml(modal=self.redirect_act[1], close=self.redirect_act[2], params=self.redirect_act[3]))
     XferContainerAbstract._finalize(self)
示例#5
0
 def _finalize(self):
     printxml = etree.SubElement(self.responsexml, "PRINT")
     printxml.attrib['mode'] = six.text_type(
         self.report_mode)  # 3=PDF - 4=CSV
     printxml.text = self.report_content
     etree.SubElement(printxml, "TITLE").text = self.get_print_name()
     XferContainerAbstract._finalize(self)
示例#6
0
 def _finalize(self):
     self.responsejson['data'] = {}
     self.responsejson['comp'] = []
     for comp in self.get_sort_components():
         self.responsejson['comp'].append(comp.get_json())
         self.responsejson['data'][comp.name] = comp.get_json_value()
     self.responsejson['actions'] = get_actions_json(self.actions)
     XferContainerAbstract._finalize(self)
示例#7
0
 def _finalize(self):
     sortedkey_components, final_components = self.get_sort_components()
     self.responsejson['data'] = {}
     self.responsejson['comp'] = []
     for key in sortedkey_components:
         comp = final_components[key]
         self.responsejson['comp'].append(comp.get_json())
         self.responsejson['data'][comp.name] = comp.get_json_value()
     self.responsejson['actions'] = get_actions_json(self.actions)
     XferContainerAbstract._finalize(self)
示例#8
0
 def _finalize(self):
     sortedkey_components, final_components = self.get_sort_components()
     self.responsejson['data'] = {}
     self.responsejson['comp'] = []
     for key in sortedkey_components:
         comp = final_components[key]
         self.responsejson['comp'].append(comp.get_json())
         self.responsejson['data'][comp.name] = comp.get_json_value()
     self.responsejson['actions'] = get_actions_json(self.actions)
     XferContainerAbstract._finalize(self)
示例#9
0
 def __init__(self, **kwargs):
     XferContainerAbstract.__init__(self, **kwargs)
     self.title = ""
     self.msg = ""
     self.traitment_data = None
     self.typemsg = 1
     self.redirect_act = None
     self.except_msg = ""
     self.except_classact = None
     self.custom = None
示例#10
0
 def __init__(self, **kwargs):
     XferContainerAbstract.__init__(self, **kwargs)
     self.title = ""
     self.msg = ""
     self.traitment_data = None
     self.typemsg = 1
     self.redirect_act = None
     self.except_msg = ""
     self.except_classact = None
     self.custom = None
示例#11
0
 def _finalize(self):
     if len(self.components) != 0:
         sortedkey_components, final_components = self.get_sort_components()
         xml_comps = etree.SubElement(self.responsexml, "COMPONENTS")
         for key in sortedkey_components:
             comp = final_components[key]
             xml_comp = comp.get_reponse_xml()
             xml_comps.append(xml_comp)
     if len(self.actions) != 0:
         self.responsexml.append(get_actions_xml(self.actions))
     XferContainerAbstract._finalize(self)
示例#12
0
 def _finalize(self):
     if self.redirect_act is not None:
         if self.format == 'JSON':
             self.responsejson['action'] = self.redirect_act[
                 0].get_action_json(modal=self.redirect_act[1],
                                    close=self.redirect_act[2],
                                    params=self.redirect_act[3])
         else:
             self.responsexml.append(self.redirect_act[0].get_action_xml(
                 modal=self.redirect_act[1],
                 close=self.redirect_act[2],
                 params=self.redirect_act[3]))
     XferContainerAbstract._finalize(self)
示例#13
0
 def __init__(self):
     self.title = ''
     self.modelxml = etree.Element('model')
     self.page_width = 210
     self.page_height = 297
     self.horizontal_marge = 10
     self.vertical_marge = 10
     self.header_height = 0
     self.bottom_height = 0
     self.header = None
     self.bottom = None
     self.body = None
     self.content_width = 0
     self.mode = 0
     self.xfer = XferContainerAbstract()
示例#14
0
 def __init__(self):
     self.title = ''
     self.modelxml = etree.Element('model')
     self.page_width = 210
     self.page_height = 297
     self.horizontal_marge = 10
     self.vertical_marge = 10
     self.header_height = 0
     self.bottom_height = 0
     self.header = None
     self.bottom = None
     self.body = None
     self.content_width = 0
     self.mode = 0
     self.xfer = XferContainerAbstract()
示例#15
0
 def __init__(self, **kwargs):
     XferContainerAbstract.__init__(self, **kwargs)
     self.actions = []
     self.components = {}
     self.tab = 0
示例#16
0
 def __init__(self):
     XferContainerAbstract.__init__(self)
     self.report_content = ""
     self.report_mode = PRINT_PDF_FILE
     self.print_selector = []
     self.selector = None
示例#17
0
 def __init__(self, **kwargs):
     XferContainerAbstract.__init__(self, **kwargs)
     self.actions = []
     self.components = {}
     self.tab = 0
示例#18
0
 def _finalize(self):
     self.responsejson['data'] = {'text': six.text_type(self.msgtext), 'type': self.msgtype}
     self.responsejson['actions'] = get_actions_json(self.actions)
     XferContainerAbstract._finalize(self)
示例#19
0
 def __init__(self, **kwargs):
     XferContainerAbstract.__init__(self, **kwargs)
     self.msgtype = XFER_DBOX_INFORMATION
     self.msgtext = ""
     self.actions = []
示例#20
0
class ReportGenerator(object):

    def __init__(self):
        self.title = ''
        self.modelxml = etree.Element('model')
        self.page_width = 210
        self.page_height = 297
        self.horizontal_marge = 10
        self.vertical_marge = 10
        self.header_height = 0
        self.bottom_height = 0
        self.header = None
        self.bottom = None
        self.body = None
        self.content_width = 0
        self.mode = 0
        self.xfer = XferContainerAbstract()

    def fill_attrib_headerfooter(self):
        if self.header is not None:
            self.header.attrib['extent'] = "%d.0" % self.header_height
        if self.bottom is not None:
            self.bottom.attrib['extent'] = "%d.0" % self.bottom_height

    def get_num_page(self):
        return len(self.modelxml.xpath("page"))

    def add_page(self):
        self.content_width = self.page_width - 2 * self.horizontal_marge
        page = etree.SubElement(self.modelxml, "page")
        self.header = etree.SubElement(page, "header")
        self.bottom = etree.SubElement(page, "bottom")
        self.body = etree.SubElement(page, "body")
        self.fill_attrib_headerfooter()

    def get_text_from_title(self):
        xml_text = convert_to_html(
            'text', "{[b]}{[u]}%s{[/u]}{[/b]}" % self.title, text_align='center')
        xml_text.attrib['height'] = "%d.0" % 12
        xml_text.attrib['width'] = "%d.0" % self.content_width
        xml_text.attrib['top'] = "0.0"
        xml_text.attrib['left'] = "0.0"
        return xml_text

    def fill_attrib(self):
        self.modelxml.attrib['page_width'] = "%d.0" % self.page_width
        self.modelxml.attrib['page_height'] = "%d.0" % self.page_height
        self.modelxml.attrib['margin_right'] = "%d.0" % self.horizontal_marge
        self.modelxml.attrib['margin_left'] = "%d.0" % self.horizontal_marge
        self.modelxml.attrib['margin_bottom'] = "%d.0" % self.vertical_marge
        self.modelxml.attrib['margin_top'] = "%d.0" % self.vertical_marge
        self.fill_attrib_headerfooter()

    def fill_content(self, request):
        if request is not None:
            self.xfer._initialize(request)

    def generate(self, request):
        self.modelxml = etree.Element('model')
        self.add_page()
        self.fill_content(request)
        self.fill_attrib()
        xml_generated = etree.tostring(
            self.modelxml, xml_declaration=True, pretty_print=True, encoding='utf-8')
        logging.getLogger("lucterios.core.print").debug(
            xml_generated.decode("utf-8"))
        return xml_generated

    def generate_report(self, request, is_csv):
        report_content = self.generate(request)
        if is_csv:
            xsl_file = join(dirname(__file__), "ConvertxlpToCSV.xsl")
            if not isfile(xsl_file):
                raise LucteriosException(GRAVE, "Error:no csv xsl file!")
            with open(xsl_file, 'rb') as xsl_file:
                csv_transform = etree.XSLT(etree.XML(xsl_file.read()))
            xml_rep_content = etree.XML(report_content)
            for xml_br in xml_rep_content.xpath("//br"):
                xml_br.text = ' '
            content = six.text_type(
                csv_transform(xml_rep_content)).encode('utf-8')
        else:
            content = transforme_xml2pdf(report_content)
        if len(content) > 0:
            return content
        else:
            return ""
示例#21
0
class ReportGenerator(object):
    def __init__(self):
        self.title = ''
        self.modelxml = etree.Element('model')
        self.page_width = 210
        self.page_height = 297
        self.horizontal_marge = 10
        self.vertical_marge = 10
        self.header_height = 0
        self.bottom_height = 0
        self.header = None
        self.bottom = None
        self.body = None
        self.content_width = 0
        self.mode = 0
        self.xfer = XferContainerAbstract()
        self.watermark = ""

    def fill_attrib_headerfooter(self):
        if self.header is not None:
            self.header.attrib['extent'] = "%d.0" % self.header_height
        if self.bottom is not None:
            self.bottom.attrib['extent'] = "%d.0" % self.bottom_height

    def get_num_page(self):
        return len(self.modelxml.xpath("page"))

    def add_page(self):
        self.content_width = self.page_width - 2 * self.horizontal_marge
        page = etree.SubElement(self.modelxml, "page")
        self.header = etree.SubElement(page, "header")
        self.bottom = etree.SubElement(page, "bottom")
        self.body = etree.SubElement(page, "body")
        self.fill_attrib_headerfooter()

    def get_text_from_title(self):
        xml_text = convert_to_html('text',
                                   "{[b]}{[u]}%s{[/u]}{[/b]}" % self.title,
                                   text_align='center')
        xml_text.attrib['height'] = "%d.0" % 12
        xml_text.attrib['width'] = "%d.0" % self.content_width
        xml_text.attrib['top'] = "0.0"
        xml_text.attrib['left'] = "0.0"
        return xml_text

    def fill_attrib(self):
        self.modelxml.attrib['page_width'] = "%d.0" % self.page_width
        self.modelxml.attrib['page_height'] = "%d.0" % self.page_height
        self.modelxml.attrib['margin_right'] = "%d.0" % self.horizontal_marge
        self.modelxml.attrib['margin_left'] = "%d.0" % self.horizontal_marge
        self.modelxml.attrib['margin_bottom'] = "%d.0" % self.vertical_marge
        self.modelxml.attrib['margin_top'] = "%d.0" % self.vertical_marge
        self.fill_attrib_headerfooter()

    def fill_content(self, request):
        if request is not None:
            self.xfer._initialize(request)

    def generate(self, request):
        self.modelxml = etree.Element('model')
        self.add_page()
        self.fill_content(request)
        self.fill_attrib()
        xml_generated = etree.tostring(self.modelxml,
                                       xml_declaration=True,
                                       pretty_print=True,
                                       encoding='utf-8')
        getLogger("lucterios.core.print").debug(xml_generated.decode("utf-8"))
        return xml_generated

    def generate_report(self, request, is_csv):
        report_content = self.generate(request)
        if is_csv:
            xsl_file = join(dirname(__file__), "ConvertxlpToCSV.xsl")
            if not isfile(xsl_file):
                raise LucteriosException(GRAVE, "Error:no csv xsl file!")
            with open(xsl_file, 'rb') as xsl_file:
                csv_transform = etree.XSLT(etree.XML(xsl_file.read()))
            xml_rep_content = etree.XML(report_content)
            for xml_br in xml_rep_content.xpath("//br"):
                xml_br.text = ','
            content = six.text_type(
                csv_transform(xml_rep_content)).encode('utf-8')
        else:
            try:
                content = transforme_xml2pdf(report_content, self.watermark)
            except ValueError:
                getLogger("lucterios.core.print").exception(
                    'transforme_xml2pdf')
                raise LucteriosException(IMPORTANT,
                                         _('This impression failed !'))
        if len(content) > 0:
            return content
        else:
            return ""
示例#22
0
 def __init__(self):
     XferContainerAbstract.__init__(self)
     self.report_content = ""
     self.report_mode = PRINT_PDF_FILE
     self.print_selector = []
     self.selector = None
示例#23
0
 def _finalize(self):
     if self.redirect_act is not None:
         act_xml = self.redirect_act[0].get_action_xml(self.redirect_act[1])
         if act_xml is not None:
             self.responsexml.append(act_xml)
     XferContainerAbstract._finalize(self)
示例#24
0
 def __init__(self, **kwargs):
     XferContainerAbstract.__init__(self, **kwargs)
     self.msgtype = XFER_DBOX_INFORMATION
     self.msgtext = ""
     self.actions = []
示例#25
0
 def __init__(self, **kwargs):
     XferContainerAbstract.__init__(self, **kwargs)
     self.success = False