Package org.openbravo.dal.xml

Examples of org.openbravo.dal.xml.XMLEntityConverter


    }
  }

  protected String importDataFromXML(Document doc, ChangeAction changeAction) {

    final XMLEntityConverter xec = XMLEntityConverter.newInstance();
    xec.setClient(OBContext.getOBContext().getCurrentClient());
    xec.setOrganization(OBContext.getOBContext().getCurrentOrganization());

    // for a webservice referenced entities should not be created at all!
    xec.getEntityResolver().setOptionCreateReferencedIfNotFound(false);

    // the create action also supports updating
    // an update action should only update
    // and a delete action should be lenient, allowing non existing
    // entities
    // so only update does not allow non-existing entities
    if (changeAction == ChangeAction.UPDATE) {
      xec.getEntityResolver().setResolvingMode(ResolvingMode.MUST_EXIST);
    }
    final List<BaseOBObject> processedObjects = xec.process(doc);

    if (xec.getErrorMessages() != null) {
      throw new InvalidContentException(xec.getErrorMessages());
    }

    // the create action also allows updating
    if (changeAction == ChangeAction.CREATE || changeAction == ChangeAction.UPDATE) {
      return doCreateUpdate(xec);
View Full Code Here


    try {
      // disable the triggers to prevent unexpected extra db actions
      // during import
      TriggerHandler.getInstance().disable();

      final XMLEntityConverter xec = XMLEntityConverter.newInstance();
      xec.setClient(client);
      xec.setOrganization(organization);
      xec.setOptionClientImport(isClientImport);
      xec.setOptionImportAuditInfo(importAuditInfo);
      xec.getEntityResolver().setOptionCreateReferencedIfNotFound(createReferencesIfNotFound);

      listNew = xec.getToInsert();
      listChanged = xec.getToUpdate();
      if (isClientImport) {
        xec.setEntityResolver(ClientImportEntityResolver.getInstance());
      }
      xec.setImportProcessor(importProcessor);
      xec.process(doc);

      ir.setLogMessages(xec.getLogMessages());
      ir.setErrorMessages(xec.getErrorMessages());
      ir.setWarningMessages(xec.getWarningMessages());

      if (ir.hasErrorOccured()) {
        OBDal.getInstance().rollbackAndClose();
        rolledBack = true;
        return ir;
      }

      if (importProcessor != null) {
        try {
          importProcessor.process(xec.getToInsert(), xec.getToUpdate());
        } catch (final Exception e) {
          // note on purpose caught and set in ImportResult
          e.printStackTrace(System.err);
          ir.setException(e);
          ir.setErrorMessages(e.getMessage());
View Full Code Here

TOP

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

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.