Ejemplo n.º 1
0
 def service_logs(self):
     from sagas.ofbiz.entities import OfEntity as e, oc
     oc.import_package('org.apache.ofbiz.service.ServiceDispatcher')
     log = oc.j.ServiceDispatcher.getServiceLogMap()
     for rs, value in log.items():
         print(oc.get(rs.getModelService(), 'name'), rs.getLocalName(),
               rs.getMode(), rs.getStartStamp(), rs.getEndStamp())
Ejemplo n.º 2
0
    def test_form(self):
        oc.import_package('org.apache.ofbiz.base.util.UtilMisc')

        forms = oc.component('form_mgr')
        locale = oc.j.UtilMisc.ensureLocale('zh_CN')
        loc = 'component://product/widget/catalog/ProductForms.xml'
        # form_name='FindProduct'
        form_name = 'EditProduct'
        form = forms.getModelForm(form_name, loc)
        forms.renderForm(form, locale)
Ejemplo n.º 3
0
    def test_render(self):
        from sagas.ofbiz.entities import OfEntity as e

        oc.import_package('org.apache.ofbiz.base.util.UtilMisc')
        oc.import_package('com.sagas.meta.PropertiesManager')
        oc.import_package('org.apache.ofbiz.widget.renderer.fo.FoFormRenderer')
        oc.import_package('org.apache.ofbiz.widget.renderer.FormRenderer')
        ffr = oc.j.FoFormRenderer()

        forms = oc.component('form_mgr')
        loc = 'component://product/widget/catalog/ProductForms.xml'
        # form_name='FindProduct'
        form_name = 'EditProduct'
        form = forms.getModelForm(form_name, loc)
        fr = oc.j.FormRenderer(form, ffr)
        writer = oc.j.StringBuilder()

        locale = oc.j.UtilMisc.ensureLocale(None)
        ctx = oc.jmap(locale=locale)
        ctx.put('product', e().refProduct('GZ-2002'))
        oc.j.PropertiesManager.execPropertyMap(ctx, "ContentUiLabels",
                                               "uiLabelMap", True)

        fr.render(writer, ctx)
        print(writer.toString())
Ejemplo n.º 4
0
    def process(self):
        from sagas.ofbiz.services import OfService as s, oc, track
        oc.import_package('org.apache.ofbiz.base.component.ComponentConfig')
        allComponents = oc.j.ComponentConfig.getAllComponents()
        properties = {}
        for c in allComponents:
            conf_dir = c.getRootLocation() + 'config'
            if os.path.isdir(conf_dir):
                files = io_utils.list_files(conf_dir)
                for f in files:
                    if f.endswith('.xml'):
                        self.parse_resource_file(f, properties)

        resource = RsResource(properties=properties)
        return resource
Ejemplo n.º 5
0
 def collect_component_data_files(self):
     oc.import_package('org.apache.ofbiz.base.component.ComponentConfig')
     allComponents = oc.j.ComponentConfig.getAllComponents()
     index = 1
     self.comp_files = {}
     for c in allComponents:
         self.comp_files[c.getGlobalName()] = []
     for c in allComponents:
         # print(index, c.getComponentName(), c.getRootLocation())
         # print(index, c.getGlobalName(), c.getRootLocation())
         index = index + 1
         ts = c.getTestSuiteInfos()
         # print('\t', 'contains test suites', len(ts))
         ent_res = c.getEntityResourceInfos()
         for es in ent_res:
             data_type = get_field(es, 'type')
             if data_type == 'data':
                 # print('\t', data_type, get_field(es, 'readerName'),
                 #      es.getLocation())
                 self.comp_files[c.getGlobalName()].append(c.getRootLocation() + es.getLocation())
     return self.comp_files
Ejemplo n.º 6
0
 def remove_model(self, entity_name):
     oc.import_package('org.apache.ofbiz.entity.jdbc.*')
     delete_table(entity_name)
     print('done.')