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; }
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; }
public SDKEngine[] getEngines() throws NotAllowedOperationException { SDKEngine[] toReturn = null; logger.debug("IN"); this.setTenant(); try { super.checkUserPermissionForFunctionality( SpagoBIConstants.ENGINES_MANAGEMENT, "User cannot see engines congifuration."); List enginesList = DAOFactory.getEngineDAO().loadAllEngines(); List sdkEnginesList = new ArrayList(); if (enginesList != null && enginesList.size() > 0) { for (Iterator it = enginesList.iterator(); it.hasNext(); ) { Engine engine = (Engine) it.next(); SDKEngine sdkEngine = new SDKObjectsConverter().fromEngineToSDKEngine(engine); sdkEnginesList.add(sdkEngine); } } toReturn = new SDKEngine[sdkEnginesList.size()]; toReturn = (SDKEngine[]) sdkEnginesList.toArray(toReturn); } catch (NotAllowedOperationException e) { throw e; } catch (Exception e) { logger.error("Error while retrieving SDKEngine list", e); logger.debug("Returning null"); return null; } finally { this.unsetTenant(); logger.debug("OUT"); } return toReturn; }
public SDKEngine getEngine(Integer engineId) throws NotAllowedOperationException { SDKEngine toReturn = null; logger.debug("IN: engineId in input = " + engineId); this.setTenant(); try { super.checkUserPermissionForFunctionality( SpagoBIConstants.ENGINES_MANAGEMENT, "User cannot see engines congifuration."); if (engineId == null) { logger.warn("Engine identifier in input is null!"); return null; } Engine engine = DAOFactory.getEngineDAO().loadEngineByID(engineId); if (engine == null) { logger.warn("Engine with identifier [" + engineId + "] not existing."); return null; } toReturn = new SDKObjectsConverter().fromEngineToSDKEngine(engine); } catch (NotAllowedOperationException e) { throw e; } catch (Exception e) { logger.error("Error while retrieving SDKEngine", e); logger.debug("Returning null"); return null; } finally { this.unsetTenant(); logger.debug("OUT"); } return toReturn; }
public static Engine getEngineByDriver(String driver) { Engine engine; engine = null; try { Assert.assertNotNull(DAOFactory.getEngineDAO(), "EngineDao cannot be null"); engine = DAOFactory.getEngineDAO().loadEngineByDriver(driver); if (engine == null) { throw new SpagoBIRuntimeException( "There are no engines with driver equal to [" + driver + "] available"); } } catch (Throwable t) { throw new SpagoBIRuntimeException( "Impossible to load a valid engine whose drover is equal to [" + driver + "]", t); } finally { logger.debug("OUT"); } return engine; }
/** * Method called by document composition publisher , that returns alla available exporters for a * single document contained in the composed one. * * @param objLabel * @param sessionContainer * @param requestSB * @return */ public static List getAvailableExporters( String objLabel, SessionContainer sessionContainer, SourceBean requestSB) { logger.debug("IN"); List<Exporters> exporters = null; List<String> exportersTypes = null; if (objLabel == null || objLabel.equals("")) { logger.error("Object Label is null: cannot get engine's url."); return null; } try { // get the user profile from session SessionContainer permSession = sessionContainer.getPermanentContainer(); IEngUserProfile profile = (IEngUserProfile) permSession.getAttribute(IEngUserProfile.ENG_USER_PROFILE); BIObject obj = DAOFactory.getBIObjectDAO().loadBIObjectByLabel(objLabel); if (obj == null) { logger.error( "Cannot obtain engine url. Document with label " + objLabel + " doesn't exist into database."); List l = new ArrayList(); l.add(objLabel); throw new EMFUserError(EMFErrorSeverity.ERROR, "1005", l, messageBundle); } Engine engine = obj.getEngine(); exporters = DAOFactory.getEngineDAO().getAssociatedExporters(engine); if (exporters != null) { exportersTypes = new ArrayList<String>(); for (int i = 0; i < exporters.size(); i++) { Domain domain = DAOFactory.getDomainDAO().loadDomainById(exporters.get(i).getDomainId()); String cd = domain.getValueCd(); exportersTypes.add(cd); } } } catch (Exception e) { logger.error("Error while getting document's exporters for label :" + objLabel + ": " + e); return null; } finally { logger.debug("OUT"); } return exportersTypes; }