Package org.openbravo.service.db

Examples of org.openbravo.service.db.ImportResult


    // change the xml to force an update
    xml = xml.replaceAll("</name>", "t</name>");
    xml = xml.replaceAll("</id>", "new</id>");
    setUserContext("0");
    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
        OBDal.getInstance().get(Client.class, "1000000"),
        OBDal.getInstance().get(Organization.class, "1000002"), xml);
    if (ir.getException() != null) {
      ir.getException().printStackTrace(System.err);
      fail(ir.getException().getMessage());
    } else if (ir.getErrorMessages() != null) {
      fail(ir.getErrorMessages());
    } else {
      assertTrue(ir.getWarningMessages() != null);
      assertTrue(ir.getWarningMessages().indexOf("Updating entity") != -1);
      assertTrue(ir.getWarningMessages().indexOf(
          "eventhough it does not belong to the target organization ") != -1);
    }
    // force a rollback, so that the db is not changed
    rollback();
  }
View Full Code Here


    }

    final ClientImportProcessor importProcessor = new ClientImportProcessor();
    importProcessor.setNewName("" + System.currentTimeMillis());
    try {
      final ImportResult ir = DataImportService.getInstance().importClientData(importProcessor,
          false, new StringReader(xml));
      xml = null;
      if (ir.getException() != null) {
        throw new OBException(ir.getException());
      }
      if (ir.getErrorMessages() != null) {
        fail(ir.getErrorMessages());
      }
      // none should be updated!
      assertEquals(0, ir.getUpdatedObjects().size());

      String newClientId = null;

      // and never insert anything in client 0
      for (final BaseOBObject bob : ir.getInsertedObjects()) {
        if (bob instanceof ClientEnabled) {
          final ClientEnabled ce = (ClientEnabled) bob;
          assertNotNull(ce.getClient());
          assertTrue(!ce.getClient().getId().equals("0"));
          newClientId = ce.getClient().getId();
View Full Code Here

      // final URL url = this.getClass().getResource("testdata/" + fileName);
      // final File f = new File(new URI(url.toString()));

      final File f = new File(fileName); // "/home/mtaal/mytmp/" +

      final ImportResult ir = DataImportService.getInstance().importClientData(importProcessor,
          false, new FileReader(f));
      if (ir.getException() != null) {
        throw new OBException(ir.getException());
      }
      if (ir.getErrorMessages() != null && ir.getErrorMessages().trim().length() > 0) {
        fail(ir.getErrorMessages());
      }
    } catch (final Exception e) {
      throw new OBException(e);
    }
  }
View Full Code Here

    setUserContext("100");

    final String xml = exportTax();
    final Client c = OBDal.getInstance().get(Client.class, "1000000");
    final Organization o = OBDal.getInstance().get(Organization.class, "1000000");
    final ImportResult ir = DataImportService.getInstance().importDataFromXML(c, o, xml);

    log.debug("WARNING>>>>");
    assertTrue(ir.getWarningMessages(), ir.getWarningMessages() == null);
    assertEquals(0, ir.getUpdatedObjects().size());
    assertEquals(0, ir.getInsertedObjects().size());
    if (ir.hasErrorOccured()) {
      fail(ir.getErrorMessages());
    }
  }
View Full Code Here

    final int cnt = count(Greeting.class);
    addReadWriteAccess(Greeting.class);
    final String xml = getXML(Greeting.class);
    // insert in org 1000001
    setUserContext("1000019");
    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
        OBDal.getInstance().get(Client.class, "1000001"),
        OBDal.getInstance().get(Organization.class, "1000001"), xml);
    assertEquals(cnt, ir.getInsertedObjects().size());
    assertEquals(0, ir.getUpdatedObjects().size());
    if (ir.hasErrorOccured()) {
      fail(ir.getErrorMessages());
    }
  }
View Full Code Here

    setUserContext("1000000");
    addReadWriteAccess(Greeting.class);
    final String xml = getXML(Greeting.class);
    setUserContext("1000019");
    // insert in org 1000002
    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
        OBDal.getInstance().get(Client.class, "1000001"),
        OBDal.getInstance().get(Organization.class, "1000001"), xml);
    assertEquals(0, ir.getInsertedObjects().size());
    assertEquals(0, ir.getUpdatedObjects().size());
    if (ir.hasErrorOccured()) {
      fail(ir.getErrorMessages());
    }
  }
View Full Code Here

    setUserContext("1000019");
    String xml = getXML(Greeting.class);
    xml = xml.replaceAll("Mrs", "Mrsses");
    xml = xml.replaceAll("Herr", "Heer");
    xml = xml.replaceAll("Heer", "Her");
    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
        OBDal.getInstance().get(Client.class, "1000001"),
        OBDal.getInstance().get(Organization.class, "1000001"), xml);
    assertEquals(0, ir.getInsertedObjects().size());
    assertEquals(2, ir.getUpdatedObjects().size());
    if (ir.hasErrorOccured()) {
      fail(ir.getErrorMessages());
    }
  }
View Full Code Here

  // do it again, no change!
  private <T extends BaseOBObject> void doTestNoChange(Class<T> clz) {
    setUserContext("1000000");
    addReadWriteAccess(Greeting.class);
    final String xml = getXML(clz);
    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
        OBContext.getOBContext().getCurrentClient(),
        OBContext.getOBContext().getCurrentOrganization(), xml);
    assertTrue(ir.getInsertedObjects().size() == 0);
    assertTrue(ir.getUpdatedObjects().size() == 0);
  }
View Full Code Here

    // export to client 1000001
    setUserContext("1000019");
    // don't be bothered by access checks...
    setAccess();
    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
        OBDal.getInstance().get(Client.class, "1000001"),
        OBDal.getInstance().get(Organization.class, "1000001"), xml);
    if (ir.getException() != null) {
      ir.getException().printStackTrace(System.err);
      fail(ir.getException().getMessage());
    } else if (ir.getErrorMessages() != null) {
      fail(ir.getErrorMessages());
    }

    assertEquals(TOTAL_PT_PTL, ir.getInsertedObjects().size());
    assertEquals(0, ir.getUpdatedObjects().size());
  }
View Full Code Here

    xml = xml.replaceAll("</name>", "t</name>");

    // export to client 1000001
    setUserContext("1000019");
    setAccess();
    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
        OBDal.getInstance().get(Client.class, "1000001"),
        OBDal.getInstance().get(Organization.class, "1000001"), xml);
    if (ir.getException() != null) {
      ir.getException().printStackTrace(System.err);
      fail(ir.getException().getMessage());
    }

    assertEquals(0, ir.getInsertedObjects().size());
    assertEquals(0, ir.getUpdatedObjects().size());
  }
View Full Code Here

TOP

Related Classes of org.openbravo.service.db.ImportResult

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.