Examples of ImportResult


Examples of org.jboss.dashboard.workspace.export.structure.ImportResult

                return false;
            }

            // Load the file.
            ExportManager exportManager = UIServices.lookup().getExportManager();
            ImportResult result = exportManager.loadXML(pf.getName(), new FileInputStream(pf));
            if (result == null) {
                log.warn("Error on importation. Nothing to import");
                return false;
            }

            if (result.getException() != null) throw result.getException();
            if (result.getWarnings() != null && result.getWarnings().size() > 0) {
                for (int j = 0; j < result.getWarnings().size(); j++) {
                    log.warn("Problems importing entry " + result.getEntryName() + ": " + result.getWarnings().get(j));
                }
            }

            exportManager.create(new ImportResult[]{result}, null, true);
            return true;
View Full Code Here

Examples of org.jboss.dashboard.workspace.export.structure.ImportResult

        }
        return (ImportResult[]) list.toArray(new ImportResult[list.size()]);
    }

    public ImportResult loadXML(String name, InputStream is) {
        return new ImportResult(name, is);
    }
View Full Code Here

Examples of org.jboss.dashboard.workspace.export.structure.ImportResult

    public CreateResult[] create(ImportResult[] results, int[][] indexes, boolean onStartup) {
        List elementsToCreate = new ArrayList();
        List attributesForCreation = new ArrayList();
        if (indexes == null) {
            for (int i = 0; i < results.length; i++) {
                ImportResult result = results[i];
                elementsToCreate.addAll(result.getRootNode().getChildren());
                while (attributesForCreation.size() < elementsToCreate.size())
                    attributesForCreation.add(result.getAttributes());
            }
        } else {
            for (int i = 0; i < indexes.length; i++) {
                int[] index = indexes[i];
                if (index != null)
                    if (index.length == 1) {
                        ImportResult result = results[index[0]];
                        elementsToCreate.addAll(result.getRootNode().getChildren());
                        while (attributesForCreation.size() < elementsToCreate.size())
                            attributesForCreation.add(result.getAttributes());
                    } else if (index.length > 1) {
                        ImportResult result = results[index[0]];
                        for (int j = 1; j < index.length; j++) {
                            int idx = index[j];
                            elementsToCreate.add(result.getRootNode().getChildren().get(idx));
                            while (attributesForCreation.size() < elementsToCreate.size())
                                attributesForCreation.add(result.getAttributes());
                        }
                    }
            }
        }
        List createResults = new ArrayList();
View Full Code Here

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

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, 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

Examples of org.openbravo.service.db.ImportResult

    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

Examples of org.openbravo.service.db.ImportResult

              + 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

Examples of org.openbravo.service.db.ImportResult

          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

Examples of org.openbravo.service.db.ImportResult

    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

Examples of org.openbravo.service.db.ImportResult

    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
TOP
Copyright © 2018 www.massapi.com. 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.