protected Engine getEngineByDocumentType(String type) {
    Engine engine;
    List<Engine> engines;

    engine = null;
    try {
      Assert.assertNotNull(DAOFactory.getEngineDAO(), "EngineDao cannot be null");
      engines = DAOFactory.getEngineDAO().loadAllEnginesForBIObjectType(type);
      if (engines == null || engines.size() == 0) {
        throw new SpagoBIServiceException(
            SERVICE_NAME, "There are no engines for documents of type [" + type + "] available");
      } else {
        engine = engines.get(0);
        if (engines.size() > 1) {
          LogMF.warn(
              logger,
              "There are more than one engine for document of type [WORKSHEET]. We will use the one whose label is equal to [{0}]",
              engine.getLabel());
        } else {
          LogMF.debug(logger, "Using worksheet engine with label [{0}]", engine.getLabel());
        }
      }
    } catch (Throwable t) {
      throw new SpagoBIServiceException(
          SERVICE_NAME, "Impossible to load a valid engine for document of type [WORKSHEET]", t);
    } finally {
      logger.debug("OUT");
    }

    return engine;
  }
예제 #2
0
  public static Engine getEngineByDocumentType(String type) {
    Engine engine;
    List<Engine> engines;

    engine = null;
    try {
      Assert.assertNotNull(DAOFactory.getEngineDAO(), "EngineDao cannot be null");
      engines = DAOFactory.getEngineDAO().loadAllEnginesForBIObjectType(type);
      if (engines == null || engines.size() == 0) {
        throw new SpagoBIRuntimeException(
            "There are no engines for documents of type [" + type + "] available");
      } else {
        engine = (Engine) engines.get(0);
        LogMF.warn(
            logger,
            "There are more than one engine for document of type ["
                + type
                + "]. We will use the one whose label is equal to [{0}]",
            engine.getLabel());
      }
    } catch (Throwable t) {
      throw new SpagoBIRuntimeException(
          "Impossible to load a valid engine for document of type [" + type + "]", t);
    } finally {
      logger.debug("OUT");
    }

    return engine;
  }