Package org.openbravo.service.db

Examples of org.openbravo.service.db.ImportResult


          if (!datasetFile.exists()) {
            continue;
          }

          String strXml = Utility.fileToString(datasetFile.getPath());
          ImportResult myResult = myData.importDataFromXML((Client) OBDal.getInstance().get(
              Client.class, strClient), (Organization) OBDal.getInstance().get(Organization.class,
              "0"), strXml, (Module) OBDal.getInstance().get(Module.class, data[j].adModuleId));
          m_info.append(SALTO_LINEA).append("File: ").append(datasetFile.getName()).append(":")
              .append(SALTO_LINEA);
          if (myResult.getLogMessages() != null && !myResult.getLogMessages().equals("")
              && !myResult.getLogMessages().equals("null")) {
            m_info.append(SALTO_LINEA).append("LOG:").append(SALTO_LINEA);
            m_info.append(SALTO_LINEA).append(myResult.getLogMessages()).append(SALTO_LINEA);
          }
          if (myResult.getWarningMessages() != null && !myResult.getWarningMessages().equals("")
              && !myResult.getWarningMessages().equals("null")) {
            m_info.append(SALTO_LINEA).append("WARNINGS:").append(SALTO_LINEA);
            m_info.append(SALTO_LINEA).append(myResult.getWarningMessages()).append(SALTO_LINEA);
          }
          if (myResult.getErrorMessages() != null && !myResult.getErrorMessages().equals("")
              && !myResult.getErrorMessages().equals("null")) {
            m_info.append(SALTO_LINEA).append("ERRORS:").append(SALTO_LINEA);
            if (myResult.getErrorMessages().startsWith("isBatchUpdateException:")) {
              String messageKey = myResult.getErrorMessages().substring(
                  "isBatchUpdateException:".length()).trim();
              m_info.append(SALTO_LINEA).append(
                  Utility.translateError(this, vars, vars.getLanguage(), messageKey).getMessage())
                  .append(SALTO_LINEA);
              strError = strError.append(Utility.translateError(this, vars, vars.getLanguage(),
                  messageKey).getMessage());
            } else {
              m_info.append(SALTO_LINEA).append(myResult.getErrorMessages()).append(SALTO_LINEA);
              strError = strError.append(myResult.getErrorMessages());
            }
          }

          if (!strError.toString().equals(""))
            return strError.toString();
View Full Code Here


          if (!datasetFile.exists()) {
            continue;
          }

          String strXml = Utility.fileToString(datasetFile.getPath());
          ImportResult myResult = myData.importDataFromXML((Client) OBDal.getInstance().get(
              Client.class, vars.getClient()), (Organization) OBDal.getInstance().get(
              Organization.class, strOrganization), strXml, (Module) OBDal.getInstance().get(
              Module.class, data[j].adModuleId));
          m_info.append(SALTO_LINEA).append("File: ").append(datasetFile.getName()).append(":")
              .append(SALTO_LINEA);
          if (myResult.getLogMessages() != null && !myResult.getLogMessages().equals("")
              && !myResult.getLogMessages().equals("null")) {
            m_info.append(SALTO_LINEA).append("LOG:").append(SALTO_LINEA);
            m_info.append(SALTO_LINEA).append(replaceNL(myResult.getLogMessages())).append(
                SALTO_LINEA);
          }
          if (myResult.getWarningMessages() != null && !myResult.getWarningMessages().equals("")
              && !myResult.getWarningMessages().equals("null")) {
            m_info.append(SALTO_LINEA).append("WARNINGS:").append(SALTO_LINEA);
            m_info.append(SALTO_LINEA).append(replaceNL(myResult.getWarningMessages())).append(
                SALTO_LINEA);
          }
          if (myResult.getErrorMessages() != null && !myResult.getErrorMessages().equals("")
              && !myResult.getErrorMessages().equals("null")) {
            m_info.append(SALTO_LINEA).append("ERRORS:").append(SALTO_LINEA);
            m_info.append(SALTO_LINEA).append(replaceNL(myResult.getErrorMessages())).append(
                SALTO_LINEA);
          }
          if (myResult.getErrorMessages() != null && !myResult.getErrorMessages().equals("")
              && !myResult.getErrorMessages().equals("null"))
            strError = strError.append(myResult.getErrorMessages());
          if (!strError.toString().equals(""))
            return strError.toString();
          else {
            if (UpdateReferenceDataData.selectRegister(this, data[j].adModuleId, strOrganization)
                .equals("0"))
View Full Code Here

    return WebServiceUtil.getInstance().createResultXMLWithObjectsAndWarning(
        "Action performed successfully", sb.toString(), null, null, null, deletedList);
  }

  protected String doCreateUpdate(XMLEntityConverter xec) {
    final ImportResult ir = new ImportResult();

    DataImportService.getInstance().saveUpdateConvertedObjects(xec, ir, false, null);
    if (ir.getErrorMessages() != null) {
      throw new InvalidContentException(ir.getErrorMessages());
    }
    final String log = (xec.getLogMessages() != null ? xec.getLogMessages() : "")
        + (xec.getLogMessages() != null ? "\n" : "") + "Updated " + xec.getToUpdate().size()
        + " business objects, Inserted " + xec.getToInsert().size() + " business objects ";
View Full Code Here

              + Utility.wikifiedName(amd.dsName) + ".xml");

          // Import data from the xml file
          final String strXml = Utility.fileToString(datasetFile.getPath());
          final DataImportService importService = DataImportService.getInstance();
          final ImportResult result = importService.importDataFromXML(OBDal.getInstance().get(
              Client.class, "0"), OBDal.getInstance().get(Organization.class, "0"), strXml, OBDal
              .getInstance().get(Module.class, amd.adModuleId));
          if (result.hasErrorOccured()) {
            log4j.error(result.getErrorMessages());
            if (result.getException() != null) {
              throw new OBException(result.getException());
            } else {
              throw new OBException(result.getErrorMessages());
            }
          }

          String msg = result.getWarningMessages();
          if (msg != null && msg.length() > 0)
            log4j.warn(msg);

          msg = result.getLogMessages();
          if (msg != null && msg.length() > 0)
            log4j.debug(msg);
        }
        OBDal.getInstance().commitAndClose();
      }
View Full Code Here

          if (!datasetFile.exists()) {
            continue;
          }

          final String strXml = Utility.fileToString(datasetFile.getPath());
          final ImportResult myResult = myData.importDataFromXML(OBDal.getInstance().get(
              Client.class, strClient), OBDal.getInstance().get(Organization.class, AD_Org_ID),
              strXml, OBDal.getInstance().get(Module.class, data[j].adModuleId));
          m_info.append(SALTO_LINEA).append("File: ").append(datasetFile.getName()).append(":")
              .append(SALTO_LINEA);
          if (myResult.getLogMessages() != null && !myResult.getLogMessages().equals("")
              && !myResult.getLogMessages().equals("null")) {
            m_info.append(SALTO_LINEA).append("LOG:").append(SALTO_LINEA);
            m_info.append(SALTO_LINEA).append(
                myResult.getLogMessages().replaceAll("\\\n", SALTO_LINEA)).append(SALTO_LINEA);
          }
          if (myResult.getWarningMessages() != null && !myResult.getWarningMessages().equals("")
              && !myResult.getWarningMessages().equals("null")) {
            m_info.append(SALTO_LINEA).append("WARNINGS:").append(SALTO_LINEA);
            m_info.append(SALTO_LINEA).append(
                myResult.getWarningMessages().replaceAll("\\\n", SALTO_LINEA)).append(SALTO_LINEA);
          }
          if (myResult.getErrorMessages() != null && !myResult.getErrorMessages().equals("")
              && !myResult.getErrorMessages().equals("null")) {
            m_info.append(SALTO_LINEA).append("ERRORS:").append(SALTO_LINEA);
            m_info.append(SALTO_LINEA).append(
                myResult.getErrorMessages().replaceAll("\\\n", SALTO_LINEA)).append(SALTO_LINEA);
          }
          if (myResult.getErrorMessages() != null && !myResult.getErrorMessages().equals("")
              && !myResult.getErrorMessages().equals("null"))
            strError = strError.append(myResult.getErrorMessages());

          if (!strError.toString().equals(""))
            return strError.toString();
          else {
            if (!InitialOrgSetupData
View Full Code Here

    String xml = exportClass(CountryTrl.class, "country", getCountry("Norway"));

    // change the id
    xml = xml.replaceAll("<CountryTrl id=\"..", "<CountryTrl id=\"1k");

    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
        OBDal.getInstance().get(Client.class, "1000001"),
        OBDal.getInstance().get(Organization.class, "1000001"), xml,
        OBDal.getInstance().get(Module.class, "0"));

    log.debug("WARNING>>>>");
    log.debug(ir.getWarningMessages());
    assertTrue(ir.getWarningMessages() != null
        && ir.getWarningMessages().trim().length() != 0
        && ir.getWarningMessages().indexOf(
            "eventhough it does not belong to the target organization") != -1);

    for (final BaseOBObject bob : ir.getUpdatedObjects()) {
      assertEquals(CountryTrl.class.getName(), bob.getClass().getName());
      // and clean up
      OBDal.getInstance().remove(bob);
    }
  }
View Full Code Here

    setUserContext("1000000");
    addReadWriteAccess(Warehouse.class);
    final String xml = getXML(Warehouse.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);
    if (ir.getException() != null) {
      ir.getException().printStackTrace(System.err);
      fail(ir.getException().getMessage());
    } else if (ir.getErrorMessages() != null) {
      fail(ir.getErrorMessages());
    } else {
      // 2 warehouses, 2 locations
      assertEquals(4, ir.getInsertedObjects().size());
      assertEquals(0, ir.getUpdatedObjects().size());
    }
    if (ir.hasErrorOccured()) {
      fail(ir.getErrorMessages());
    }
  }
View Full Code Here

  public void test3Warehouse() {
    setUserContext("1000000");
    addReadWriteAccess(Warehouse.class);
    final String xml = getXML(Warehouse.class);
    setUserContext("1000019");
    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(2, ir.getInsertedObjects().size());
    for (final BaseOBObject bob : ir.getInsertedObjects()) {
      assertTrue(bob instanceof Warehouse);
    }
    assertEquals(0, ir.getUpdatedObjects().size());
    if (ir.hasErrorOccured()) {
      fail(ir.getErrorMessages());
    }
  }
View Full Code Here

    // remove the entity to force a not-write situation
    final Entity entity = ModelProvider.getInstance().getEntity(Greeting.class);
    OBContext.getOBContext().getEntityAccessChecker().getWritableEntities().remove(entity);
    OBContext.getOBContext().getEntityAccessChecker().getReadableEntities().add(entity);

    final ImportResult ir = DataImportService.getInstance().importDataFromXML(c, o, xml);
    if (ir.getException() != null) {
      ir.getException().printStackTrace(System.err);
      fail(ir.getException().getMessage());
    } else if (ir.getErrorMessages() != null) {
      fail(ir.getErrorMessages());
    } else {
      // assertEquals(0, ir.getUpdatedObjects().size());
      // assertEquals(0, ir.getUpdatedObjects().size());
      assertTrue(ir.getWarningMessages() != null);
      assertTrue(ir.getWarningMessages().indexOf("updating") != -1);
      assertTrue(ir.getWarningMessages().indexOf(" because it is not writable") != -1);
    }
    // force a rollback, so that the db is not changed
    rollback();
  }
View Full Code Here

    // remove the entity from the writable entities to force an access error
    final Entity entity = ModelProvider.getInstance().getEntity(Warehouse.class);
    OBContext.getOBContext().getEntityAccessChecker().getWritableEntities().remove(entity);

    final ImportResult ir = DataImportService.getInstance().importDataFromXML(c, o, xml);
    assertTrue("No error messages, error messages expected", ir.getErrorMessages() != null);
    assertTrue("Incorrect error", ir.getErrorMessages().indexOf("Object Warehouse") != -1);
    assertTrue("Incorrect error", ir.getErrorMessages().indexOf("is new but not writable") != -1);
    assertTrue("There should not be warnings", ir.getWarningMessages() == null);
    // force a rollback, so that the db is not changed
    rollback();
  }
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.