Package org.openbravo.model.ad.utility

Examples of org.openbravo.model.ad.utility.DataSet


   *          the xml is written to this writer
   * @see #CLIENT_DATA_SET_NAME
   * @see #CLIENT_ID_PARAMETER_NAME
   */
  public void exportClientToXML(Map<String, Object> parameters, boolean exportAuditInfo, Writer out) {
    DataSet dataSet = null;
    final boolean prevMode = OBContext.getOBContext().setInAdministratorMode(true);
    try {
      final OBCriteria<DataSet> obc = OBDal.getInstance().createCriteria(DataSet.class);
      obc.add(Expression.eq("name", CLIENT_DATA_SET_NAME));
      if (obc.list().size() == 0) {
        throw new OBException("No dataset found with name " + CLIENT_DATA_SET_NAME);
      }
      dataSet = obc.list().get(0);

      // read the client
      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,
View Full Code Here


  }

  private OBError processButton(VariablesSecureApp vars, String strKey) {
    OBError myError = null;
    try {
      DataSet myDataset = (DataSet) OBDal.getInstance().get(DataSet.class, strKey);
      ExportReferenceDataData[] data = ExportReferenceDataData.selectDataset(this, strKey);
      if (data == null || data.length == 0)
        return Utility.translateError(this, vars, vars.getLanguage(), "ProcessRunError");
      ExportReferenceDataData[] module = ExportReferenceDataData.selectModule(this,
          data[0].adModuleId);
View Full Code Here

   * @see DataSetTable#setExcludeAuditInfo(Boolean)
   * @see DataSetTable#setIncludeAllColumns(Boolean)
   */
  public void testIncludeAllExcludeAudit() {
    setSystemAdministratorContext();
    final DataSet ds = createDataSet();
    for (DataSetTable dst : ds.getDataSetTableList()) {
      dst.setExcludeAuditInfo(true);
      dst.setIncludeAllColumns(true);
    }
    final String xml = DataExportService.getInstance().exportDataSetToXML(ds);
    checkPropsPresent(ds, xml, false, false, new String[] {});
View Full Code Here

   * @see DataSetTable#setExcludeAuditInfo(Boolean)
   * @see DataSetTable#setIncludeAllColumns(Boolean)
   */
  public void testIncludeAll() {
    setSystemAdministratorContext();
    final DataSet ds = createDataSet();
    for (DataSetTable dst : ds.getDataSetTableList()) {
      dst.setExcludeAuditInfo(false);
      dst.setIncludeAllColumns(true);
    }
    final String xml = DataExportService.getInstance().exportDataSetToXML(ds);
    checkPropsPresent(ds, xml, true, false, new String[] {});
View Full Code Here

   * @see DataSetTable#setIncludeAllColumns(Boolean)
   * @see DataSetTable#isBusinessObject()
   */
  public void testIncludeAllPlusChildren() {
    setSystemAdministratorContext();
    final DataSet ds = createDataSet();
    for (DataSetTable dst : ds.getDataSetTableList()) {
      dst.setExcludeAuditInfo(false);
      dst.setIncludeAllColumns(true);
      dst.setBusinessObject(true);
    }
    final String xml = DataExportService.getInstance().exportDataSetToXML(ds);
View Full Code Here

   * @see DataSetTable#getDataSetColumnList()
   * @see DataSetColumn#isExcluded()
   */
  public void testIncludeAllExcludeSpecificColumn() {
    setSystemAdministratorContext();
    final DataSet ds = createDataSet();
    for (DataSetTable dst : ds.getDataSetTableList()) {
      dst.setExcludeAuditInfo(true);
      dst.setIncludeAllColumns(true);
      dst.setBusinessObject(false);
    }

    // exclude the Order.project and Order.selfService
    final DataSetTable dst = ds.getDataSetTableList().get(0);
    assertTrue(dst.getTable().getDBTableName().toLowerCase().equals("c_order"));
    dst.getDataSetColumnList().add(
        createDataSetColumn(dst, getProperty(Order.ENTITY_NAME, Order.PROPERTY_PROJECT), true));
    dst.getDataSetColumnList().add(
        createDataSetColumn(dst, getProperty(Order.ENTITY_NAME, Order.PROPERTY_SELFSERVICE), true));
View Full Code Here

   * @see DataSetTable#getDataSetColumnList()
   * @see DataSetColumn#isExcluded()
   */
  public void testExcludeAllIncludeSpecificColumn() {
    setSystemAdministratorContext();
    final DataSet ds = createDataSet();
    for (DataSetTable dst : ds.getDataSetTableList()) {
      dst.setExcludeAuditInfo(true);
      dst.setIncludeAllColumns(false);
      dst.setBusinessObject(false);
    }

    // exclude the Order.project and Order.selfService
    final DataSetTable dst = ds.getDataSetTableList().get(0);
    assertTrue(dst.getTable().getDBTableName().toLowerCase().equals("c_order"));
    dst.getDataSetColumnList().add(
        createDataSetColumn(dst, getProperty(Order.ENTITY_NAME, Order.PROPERTY_PROJECT), false));
    dst.getDataSetColumnList()
        .add(
View Full Code Here

      }
    }
  }

  private DataSet createDataSet() {
    final DataSet ds = OBProvider.getInstance().get(DataSet.class);
    ds.setId("" + System.currentTimeMillis());
    ds.setClient(OBContext.getOBContext().getCurrentClient());
    ds.setOrganization(OBContext.getOBContext().getCurrentOrganization());
    ds.setDescription("test");
    ds.setExport(true);
    ds.setExportAllowed(true);
    ds.setActive(true);
    ds.getDataSetTableList().add(createDataSetTable(ds, Order.TABLE_NAME));
    ds.getDataSetTableList().add(createDataSetTable(ds, Organization.TABLE_NAME));
    return ds;
  }
View Full Code Here

TOP

Related Classes of org.openbravo.model.ad.utility.DataSet

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.