Package org.openbravo.dal.xml

Examples of org.openbravo.dal.xml.EntityXMLConverter


                    entityName, where);
            obq.setFilterOnReadableClients(false);
            obq.setFilterOnReadableOrganization(false);

            // Get xml
            final EntityXMLConverter exc = EntityXMLConverter.newInstance();
            exc.setOptionEmbedChildren(true);
            exc.setOptionIncludeChildren(true);
            exc.setOptionIncludeReferenced(false);
            exc.setOptionExportClientOrganizationReferences(true);
            StringWriter sw = new StringWriter();
            exc.setOutput(sw);
            exc.process(obq.list());
            final String xml = sw.toString();
            doc = DocumentHelper.parseText(xml);

            // PRODUCTS
            if (entityName.equals("ExternalPOS") && erp_pos != null) {
                final Map<String, String> lData = processExternalPOS(doc,
                        erp_pos);
                String whereClauseProduct = lData.get("whereProduct");
                if (whereClauseProduct == null) {
                    whereClauseProduct = "client.id=" + erp_id
                            + " and organization.id in ('0', " + erp_org + ")";
                }
                final OBQuery<BaseOBObject> obq2 = OBDal.getInstance()
                        .createQuery("Product", whereClauseProduct);
                obq2.setFilterOnReadableClients(false);
                obq2.setFilterOnReadableOrganization(false);
                sw = new StringWriter();
                exc.setOutput(sw);
                exc.process(obq2.list());
                final String xml2 = sw.toString();
                doc = DocumentHelper.parseText(xml2);

                final Map<String, String> pBuy = priceBuyProductByPriceList(obq2);
                final Map<String, String> pSell = priceSellProductByPriceList(
View Full Code Here


        final String whereClause = " in (" + aux + ")";
        final OBQuery<BaseOBObject> obq3 = OBDal.getInstance().createQuery(
                entityLocation, "id" + whereClause);
        obq3.setFilterOnReadableClients(false);
        obq3.setFilterOnReadableOrganization(false);
        final EntityXMLConverter exc = EntityXMLConverter.newInstance();
        exc.setOptionEmbedChildren(true);
        exc.setOptionIncludeChildren(true);
        exc.setOptionIncludeReferenced(false);
        exc.setOptionExportClientOrganizationReferences(true);
        final StringWriter sw = new StringWriter();
        exc.setOutput(sw);
        exc.process(obq3.list());

        final String xml = sw.toString();
        Document doc2 = null;
        try {
            doc2 = DocumentHelper.parseText(xml);
View Full Code Here

          w.write(xmlResult);
          w.close();
          return;
        } else {
          final StringWriter sw = new StringWriter();
          final EntityXMLConverter exc = EntityXMLConverter.newInstance();
          exc.setOptionEmbedChildren(true);
          exc.setOptionIncludeChildren(true);
          exc.setOptionIncludeReferenced(false);
          exc.setOptionExportClientOrganizationReferences(true);
          exc.setOutput(sw);
          exc.process(obq.list());
          xml = sw.toString();
        }
      } else {
        final BaseOBObject result = OBDal.getInstance().get(entityName, id);
        if (result == null) {
          throw new ResourceNotFoundException("No resource found for entity " + entityName
              + " using id " + id);
        }
        final StringWriter sw = new StringWriter();
        final EntityXMLConverter exc = EntityXMLConverter.newInstance();
        exc.setOptionEmbedChildren(true);
        exc.setOptionIncludeChildren(true);
        exc.setOptionIncludeReferenced(false);
        exc.setOptionExportClientOrganizationReferences(true);
        exc.setOutput(sw);
        exc.process(result);
        xml = sw.toString();
      }
    }
    if (request.getParameter("template") != null) {
      final String url = request.getRequestURL().toString();
View Full Code Here

      final Client client = OBDal.getInstance().get(Client.class,
          parameters.get(CLIENT_ID_PARAMETER_NAME));

      // the export part may not be run as superuser
      log.debug("Exporting dataset " + dataSet.getName());
      final EntityXMLConverter exc = EntityXMLConverter.newInstance();
      exc.setOptionExportClientOrganizationReferences(true);
      exc.setOptionMinimizeXMLSize(true);
      exc.setOptionIncludeChildren(false);
      exc.setOptionIncludeReferenced(true);
      exc.setOptionExportTransientInfo(false);
      exc.setOptionExportAuditInfo(exportAuditInfo);
      exc.setAddSystemAttributes(false);
      exc.setOutput(out);
      exc.setClient(client);

      final List<DataSetTable> dts = dataSet.getDataSetTableList();
      Collections.sort(dts, new DatasetTableComparator());

      final Set<BaseOBObject> toExport = new LinkedHashSet<BaseOBObject>();
      for (final DataSetTable dt : dts) {
        final List<BaseOBObject> list = DataSetService.getInstance().getExportableObjects(dt, null,
            parameters);
        toExport.addAll(list);
      }

      if (toExport.size() > 0) {
        exc.process(toExport);
      }

    } finally {
      OBContext.getOBContext().setInAdministratorMode(prevMode);
    }
View Full Code Here

   */
  public String exportDataSetToXML(DataSet dataSet, String moduleId, Map<String, Object> parameters) {

    log.debug("Exporting dataset " + dataSet.getName());

    final EntityXMLConverter exc = EntityXMLConverter.newInstance();
    exc.setOptionIncludeReferenced(false);
    exc.setOptionExportTransientInfo(true);
    exc.setOptionExportAuditInfo(true);
    exc.setAddSystemAttributes(true);
    if (dataSet != null) {
      exc.setDataSet(dataSet);
    }
    final StringWriter out = new StringWriter();
    exc.setOutput(out);

    final List<DataSetTable> dts = dataSet.getDataSetTableList();
    Collections.sort(dts, new DatasetTableComparator());

    // set the Client ID if not set
    if (parameters.get(CLIENT_ID_PARAMETER_NAME) == null) {
      parameters.put(CLIENT_ID_PARAMETER_NAME, OBContext.getOBContext().getCurrentClient().getId());
    }

    final Set<BaseOBObject> toExport = new LinkedHashSet<BaseOBObject>();
    for (final DataSetTable dt : dts) {
      final Boolean isbo = dt.isBusinessObject();
      exc.setOptionIncludeChildren(isbo != null && isbo.booleanValue());
      final List<BaseOBObject> list = DataSetService.getInstance().getExportableObjects(dt,
          moduleId, parameters);
      toExport.addAll(list);
    }

    if (toExport.size() > 0) {
      exc.process(toExport);
    }
    return out.toString();
  }
View Full Code Here

  }

  private String exportTax() {
    final OBCriteria<?> obc = OBDal.getInstance().createCriteria(TaxRate.class);

    final EntityXMLConverter exc = EntityXMLConverter.newInstance();
    exc.setOptionIncludeChildren(true);
    exc.setOptionIncludeReferenced(true);
    exc.setAddSystemAttributes(false);

    @SuppressWarnings("unchecked")
    final List<BaseOBObject> list = (List<BaseOBObject>) obc.list();
    final String xml = exc.toXML(list);
    log.debug(xml);
    return xml;
  }
View Full Code Here

    final OBCriteria<T> obc = OBDal.getInstance().createCriteria(clz);
    return obc.list();
  }

  protected <T extends BaseOBObject> String getXML(List<T> objs) {
    final EntityXMLConverter exc = EntityXMLConverter.newInstance();
    exc.setOptionIncludeReferenced(true);
    // exc.setOptionEmbedChildren(true);
    // exc.setOptionIncludeChildren(true);
    exc.setAddSystemAttributes(false);
    return exc.toXML(new ArrayList<BaseOBObject>(objs));
  }
View Full Code Here

    return exc.toXML(new ArrayList<BaseOBObject>(objs));
  }

  protected <T extends BaseOBObject> String getXML(Class<T> clz) {
    final OBCriteria<T> obc = OBDal.getInstance().createCriteria(clz);
    final EntityXMLConverter exc = EntityXMLConverter.newInstance();
    exc.setOptionIncludeReferenced(true);
    // exc.setOptionEmbedChildren(true);
    // exc.setOptionIncludeChildren(true);
    exc.setAddSystemAttributes(false);
    return exc.toXML(new ArrayList<BaseOBObject>(obc.list()));
  }
View Full Code Here

  }

  // overridden because also children are exported
  @SuppressWarnings("unchecked")
  protected <T extends BaseOBObject> String getXML(List<T> pts) {
    final EntityXMLConverter exc = EntityXMLConverter.newInstance();
    exc.setOptionIncludeReferenced(true);
    exc.setOptionEmbedChildren(true);
    exc.setOptionIncludeChildren(true);
    exc.setAddSystemAttributes(false);
    return exc.toXML((List<BaseOBObject>) pts);
  }
View Full Code Here

    final OBCriteria<?> obc = OBDal.getInstance().createCriteria(clz);
    if (field != null) {
      obc.add(Expression.eq(field, value));
    }

    final EntityXMLConverter exc = EntityXMLConverter.newInstance();
    exc.setOptionIncludeChildren(true);
    exc.setOptionIncludeReferenced(true);
    exc.setAddSystemAttributes(false);

    @SuppressWarnings("unchecked")
    final List<BaseOBObject> list = (List<BaseOBObject>) obc.list();
    final String xml = exc.toXML(list);
    log.debug(xml);
    return xml;
  }
View Full Code Here

TOP

Related Classes of org.openbravo.dal.xml.EntityXMLConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.