Package it.eng.spagobi.engines.geo

Examples of it.eng.spagobi.engines.geo.GeoEngineInstance


  private static final long serialVersionUID = 1L;
   

  public void service(SourceBean serviceRequest, SourceBean serviceResponse) throws GeoEngineException {
   
    GeoEngineInstance geoEngineInstance;
    Map env;
    byte[] analysisStateRowData;
    GeoEngineAnalysisState analysisState = null;
    String executionContext;
    String executionId;
    String documentLabel;
    String outputType;
   
    Monitor hitsPrimary = null;
        Monitor hitsByDate = null;
        Monitor hitsByUserId = null;
        Monitor hitsByDocumentId = null;
        Monitor hitsByExecutionContext = null;
   
   
    logger.debug("IN");   
   
    try {
      setEngineName(ENGINE_NAME);
      super.service(serviceRequest, serviceResponse);
     
      //if(true) throw new SpagoBIEngineStartupException(getEngineName(), "Test exception");
           
      logger.debug("User Id: " + getUserId());
      logger.debug("Audit Id: " + getAuditId());
      logger.debug("Document Id: " + getDocumentId());
      logger.debug("Template: " + getTemplateAsSourceBean())
     
      hitsPrimary = MonitorFactory.startPrimary("GeoEngine.requestHits");
          hitsByDate = MonitorFactory.start("GeoEngine.requestHits." + DateFormat.getDateInstance(DateFormat.SHORT).format(new Date()));
          hitsByUserId = MonitorFactory.start("GeoEngine.requestHits." + getUserId());
          hitsByDocumentId = MonitorFactory.start("GeoEngine.requestHits." + getDocumentId());
     
     
      executionContext = getAttributeAsString( EXECUTION_CONTEXT );
      logger.debug("Parameter [" + EXECUTION_CONTEXT + "] is equal to [" + executionContext + "]");
     
      executionId = getAttributeAsString( EXECUTION_ID );
      logger.debug("Parameter [" + EXECUTION_ID + "] is equal to [" + executionId + "]");
     
      documentLabel = getAttributeAsString( DOCUMENT_LABEL );
      logger.debug("Parameter [" + DOCUMENT_LABEL + "] is equal to [" + documentLabel + "]");
     
      outputType = getAttributeAsString(OUTPUT_TYPE);
      logger.debug("Parameter [" + OUTPUT_TYPE + "] is equal to [" + outputType + "]");
     
      logger.debug("Execution context: " + executionContext);
      String isDocumentCompositionModeActive = (executionContext != null && executionContext.equalsIgnoreCase("DOCUMENT_COMPOSITION") )? "TRUE": "FALSE";
      logger.debug("Document composition mode active: " + isDocumentCompositionModeActive);
     
      hitsByExecutionContext = MonitorFactory.start("GeoEngine.requestHits." + (isDocumentCompositionModeActive.equalsIgnoreCase("TRUE")?"compositeDocument": "singleDocument"));
     
     
      env = getEnv("TRUE".equalsIgnoreCase(isDocumentCompositionModeActive), documentLabel, executionId);
      if( outputType != null ) {
        env.put(GeoEngineConstants.ENV_OUTPUT_TYPE, outputType);
      }     
     
      geoEngineInstance = GeoEngine.createInstance(getTemplateAsSourceBean(), env);
      geoEngineInstance.setAnalysisMetadata( getAnalysisMetadata() );
     
      analysisStateRowData = getAnalysisStateRowData();
      if(analysisStateRowData != null) {
        logger.debug("AnalysisStateRowData: " + new String(analysisStateRowData));
        analysisState = new GeoEngineAnalysisState( );
        analysisState.load( analysisStateRowData );
        logger.debug("AnalysisState: " + analysisState.toString());
      } else {
        logger.debug("AnalysisStateRowData: NULL");
      }
      if(analysisState != null) {
        geoEngineInstance.setAnalysisState( analysisState );
      }
     
      String selectedMeasureName  = getAttributeAsString("default_kpi");
      logger.debug("Parameter [" + "default_kpi" + "] is equal to [" + selectedMeasureName + "]");
     
      if(!StringUtilities.isEmpty(selectedMeasureName)) {
        geoEngineInstance.getMapRenderer().setSelectedMeasureName(selectedMeasureName);
      }
     
     
      if("TRUE".equalsIgnoreCase(isDocumentCompositionModeActive)){
        setAttribute(DynamicPublisher.PUBLISHER_NAME, "SIMPLE_UI_PUBLISHER");
      } else {
        setAttribute(DynamicPublisher.PUBLISHER_NAME, "AJAX_UI_PUBLISHER");
      }
     
     
      String id = getAttributeAsString("SBI_EXECUTION_ID");
      setAttributeInSession(GEO_ENGINE_INSTANCE, geoEngineInstance);         
    } catch (Exception e) {
      SpagoBIEngineStartupException serviceException = null;
           
      if(e instanceof SpagoBIEngineStartupException) {
        serviceException = (SpagoBIEngineStartupException)e;
      } else {
        Throwable rootException = e;
        while(rootException.getCause() != null) {
          rootException = rootException.getCause();
        }
        String str = rootException.getMessage()!=null? rootException.getMessage(): rootException.getClass().getName();
        String message = "An unpredicted error occurred while executing " + getEngineName() + " service."
                 + "\nThe root cause of the error is: " + str;
       
        serviceException = new SpagoBIEngineStartupException(getEngineName(), message, e);
      }
     
      throw serviceException;
    } finally {
      if(hitsByExecutionContext != null) hitsByExecutionContext.stop();
      if(hitsByDocumentId != null) hitsByDocumentId.stop();
      if(hitsByUserId != null) hitsByUserId.stop();
      if(hitsByDate != null) hitsByDate.stop();
      if(hitsPrimary != null) hitsPrimary.stop();
     
    }
   

    // Put draw Map Action
   
    String outputFormat = null;
    File maptmpfile = null;
    boolean inlineResponse;
    String responseFileName;
    Monitor totalTimeMonitor = null;
    Monitor totalTimePerFormatMonitor = null;
    Monitor flushingResponseTotalTimeMonitor = null;
    Monitor errorHitsMonitor = null;
 
    logger.debug("IN");
   
    try {   
      super.service(serviceRequest, serviceResponse);
     
      totalTimeMonitor = MonitorFactory.start("GeoEngine.drawMapAction.totalTime");
     
      //executionId = getAttributeAsString( "SBI_EXECUTION_ID" );
     
      outputFormat = getAttributeAsString( OUTPUT_FORMAT );   
      logger.debug("Parameter [" + OUTPUT_FORMAT + "] is equal to [" + outputFormat + "]");
     
     
      inlineResponse = getAttributeAsBoolean( INLINE_RESPONSE, true );   
      logger.debug("Parameter [" + INLINE_RESPONSE + "] is equal to [" + inlineResponse + "]");
     
      if(getAuditServiceProxy() != null) getAuditServiceProxy().notifyServiceStartEvent();

      IEngineInstance iEngInst=(IEngineInstance)getAttributeFromSession( EngineConstants.ENGINE_INSTANCE );
      GeoEngineInstance geoInstance=(GeoEngineInstance)iEngInst;

      if(outputFormat == null) {
        logger.info("Parameter [" + outputFormat + "] not specified into request");
       
        //outputFormat = (String)((GeoEngineInstance)).getEnv().get(GeoEngineConstants.ENV_OUTPUT_TYPE);
        outputFormat = (String)geoInstance.getEnv().get(GeoEngineConstants.ENV_OUTPUT_TYPE);
        logger.debug("Env Parameter [" + GeoEngineConstants.ENV_OUTPUT_TYPE + "] is equal to [" + outputFormat + "]");
      }
     
      if(outputFormat == null) {
        logger.info("Parameter [" + GeoEngineConstants.ENV_OUTPUT_TYPE + "] not specified into environment");
        outputFormat = DEFAULT_OUTPUT_TYPE;
      }
     
      totalTimePerFormatMonitor = MonitorFactory.start("GeoEngine.drawMapAction." + outputFormat + "totalTime");
     
     
      try {
        if(outputFormat.equalsIgnoreCase(GeoEngineConstants.PDF)){
          maptmpfile = geoInstance.renderMap( GeoEngineConstants.JPEG );
         
        }else{
          maptmpfile = geoInstance.renderMap( outputFormat );
        }
      } catch (Throwable t) {
         throw new DrawMapServiceException(getActionName(), "Impossible to render map", t);
      }
     
View Full Code Here


    public static final String ENGINE_NAME = "SpagoBIGeoEngine";
 

  public void service(SourceBean serviceRequest, SourceBean serviceResponse) throws GeoEngineException {
   
    GeoEngineInstance geoEngineInstance;
    Map env;
    byte[] analysisStateRowData;
    GeoEngineAnalysisState analysisState = null;
    String executionContext;
    String executionId;
    String documentLabel;
    String outputType;
   
    Monitor hitsPrimary = null;
        Monitor hitsByDate = null;
        Monitor hitsByUserId = null;
        Monitor hitsByDocumentId = null;
        Monitor hitsByExecutionContext = null;
   
   
    logger.debug("IN");   
   
    try {
      setEngineName(ENGINE_NAME);
      super.service(serviceRequest, serviceResponse);
     
      //if(true) throw new SpagoBIEngineStartupException(getEngineName(), "Test exception");
           
      logger.debug("User Id: " + getUserId());
      logger.debug("Audit Id: " + getAuditId());
      logger.debug("Document Id: " + getDocumentId());
      //logger.debug("Template: " + getTemplateAsSourceBean()); 
     
      hitsPrimary = MonitorFactory.startPrimary("GeoEngine.requestHits");
          hitsByDate = MonitorFactory.start("GeoEngine.requestHits." + DateFormat.getDateInstance(DateFormat.SHORT).format(new Date()));
          hitsByUserId = MonitorFactory.start("GeoEngine.requestHits." + getUserId());
          hitsByDocumentId = MonitorFactory.start("GeoEngine.requestHits." + getDocumentId());
     
     
      executionContext = getAttributeAsString( EXECUTION_CONTEXT );
      logger.debug("Parameter [" + EXECUTION_CONTEXT + "] is equal to [" + executionContext + "]");
     
      executionId = getAttributeAsString( EXECUTION_ID );
      logger.debug("Parameter [" + EXECUTION_ID + "] is equal to [" + executionId + "]");
     
      documentLabel = getAttributeAsString( DOCUMENT_LABEL );
      logger.debug("Parameter [" + DOCUMENT_LABEL + "] is equal to [" + documentLabel + "]");
     
      outputType = getAttributeAsString(OUTPUT_TYPE);
      logger.debug("Parameter [" + OUTPUT_TYPE + "] is equal to [" + outputType + "]");
     
      logger.debug("Execution context: " + executionContext);
      String isDocumentCompositionModeActive = (executionContext != null && executionContext.equalsIgnoreCase("DOCUMENT_COMPOSITION") )? "TRUE": "FALSE";
      logger.debug("Document composition mode active: " + isDocumentCompositionModeActive);
     
      hitsByExecutionContext = MonitorFactory.start("GeoEngine.requestHits." + (isDocumentCompositionModeActive.equalsIgnoreCase("TRUE")?"compositeDocument": "singleDocument"));
     
     
      env = getEnv("TRUE".equalsIgnoreCase(isDocumentCompositionModeActive), documentLabel, executionId);
      if( outputType != null ) {
        env.put(GeoEngineConstants.ENV_OUTPUT_TYPE, outputType);
      }     
     
      try {
      geoEngineInstance = GeoEngine.createInstance(getTemplateAsSourceBean(), env);
      } catch (Throwable t) {
        Throwable rootException = t;
        while(rootException.getCause() != null) {
          rootException = rootException.getCause();
        }
        String str = rootException.getMessage()!=null? rootException.getMessage(): rootException.getClass().getName();
       
        SpagoBIEngineStartupException se = new SpagoBIEngineStartupException(getEngineName(), "Impossible to create engine instance. \nThe root cause of the error is: " + str, t);
        throw se;
      }
     
      geoEngineInstance.setAnalysisMetadata( getAnalysisMetadata() );
     
      analysisStateRowData = getAnalysisStateRowData();
      if(analysisStateRowData != null) {
        logger.debug("AnalysisStateRowData: " + new String(analysisStateRowData));
        analysisState = new GeoEngineAnalysisState( );
        analysisState.load( analysisStateRowData );
        logger.debug("AnalysisState: " + analysisState.toString());
      } else {
        logger.debug("AnalysisStateRowData: NULL");
      }
      if(analysisState != null) {
        geoEngineInstance.setAnalysisState( analysisState );
      }
     
      String selectedMeasureName  = getAttributeAsString("default_kpi");
      logger.debug("Parameter [" + "default_kpi" + "] is equal to [" + selectedMeasureName + "]");
     
      if(!StringUtilities.isEmpty(selectedMeasureName)) {
        geoEngineInstance.getMapRenderer().setSelectedMeasureName(selectedMeasureName);
      }
     
     
      if("TRUE".equalsIgnoreCase(isDocumentCompositionModeActive)){
        setAttribute(DynamicPublisher.PUBLISHER_NAME, "SIMPLE_UI_PUBLISHER");
View Full Code Here

TOP

Related Classes of it.eng.spagobi.engines.geo.GeoEngineInstance

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.