Examples of SDKExecutedDocumentContent


Examples of it.eng.spagobi.sdk.documents.bo.SDKExecutedDocumentContent

     
      SDKDocumentParameter[] array={par};
           
     
      SDKExecutedDocumentContent cont=  proxy.executeDocument(doc, array, "/spagobi/admin","PDF");

      DataHandler dh=cont.getContent();
      InputStream is=dh.getInputStream();

     
     
      File file=new File("C:/ciaociao.pdf");
View Full Code Here

Examples of it.eng.spagobi.sdk.documents.bo.SDKExecutedDocumentContent

  }


  private SDKExecutedDocumentContent executeKpi(SDKDocument document, BIObject biobj, String userId,String ouputType){
    logger.debug("IN");
    SDKExecutedDocumentContent toReturn=null;
    SourceBean request = null;
    SourceBean resp = null;
    EMFErrorHandler errorHandler = null;

    try {
      request = new SourceBean("");
      resp = new SourceBean("");
    } catch (SourceBeanException e1) {
      logger.error("Source Bean Exception");
      return null;
    }
    RequestContainer reqContainer = new RequestContainer();
    ResponseContainer resContainer = new ResponseContainer();
    reqContainer.setServiceRequest(request);
    resContainer.setServiceResponse(resp);
    DefaultRequestContext defaultRequestContext = new DefaultRequestContext(
        reqContainer, resContainer);
    resContainer.setErrorHandler(new EMFErrorHandler());
    RequestContainer.setRequestContainer(reqContainer);
    ResponseContainer.setResponseContainer(resContainer);
    SessionContainer session = new SessionContainer(true);
    reqContainer.setSessionContainer(session);
    errorHandler = defaultRequestContext.getErrorHandler();

    Engine engine;
    try {
      engine = DAOFactory.getEngineDAO().loadEngineByID(document.getEngineId());
    } catch (EMFUserError e1) {
      logger.error("Error while retrieving engine", e1);
      return null;
    }
    if(engine==null){
      logger.error("No engine found");
      return null;
    }
    String className = engine.getClassName();
    logger.debug("Try instantiating class " + className
        + " for internal engine " + engine.getName() + "...");
    InternalEngineIFace internalEngine = null;
    // tries to instantiate the class for the internal engine
    try {
      if (className == null && className.trim().equals("")) throw new ClassNotFoundException();
      internalEngine = (InternalEngineIFace) Class.forName(className).newInstance();
    } catch (ClassNotFoundException cnfe) {
      logger.error("The class ['" + className
          + "'] for internal engine " + engine.getName()
          + " was not found.", cnfe);
      return null;
    } catch (Exception e) {
      logger.error("Error while instantiating class " + className, e);
      return null;
    }

    // result of the Kpi
    List<KpiResourceBlock> blocksList=null;
    try {
      blocksList=((SpagoBIKpiInternalEngine)internalEngine).executeCode(reqContainer, biobj, resp, userId);
      if(blocksList==null){
        logger.error("No result returned by kpi execution");
        return null;
      }
      else{
        logger.debug("Kpi executed and result returned");
      }
    } catch (EMFUserError e) {
      logger.error("Error during engine execution", e);
      return null;   
    } catch (Exception e) {
      logger.error("Error while engine execution", e);
      return null;
    }

    File tmpFile=null;
    String mimeType = "application/pdf";
    logger.debug("setting object to return of type SDKExecuteDocumentContent");
    toReturn=new SDKExecutedDocumentContent();
    // call exporter!
    try{
      KpiExporter exporter=new KpiExporter();
      if(ouputType.equals("PDF")){
        logger.debug("call PDF Exporter");
        tmpFile=exporter.getKpiReportPDF(blocksList, biobj, userId);
        toReturn.setFileName(biobj.getLabel()+".pdf");
      }else if (ouputType.equals("XML")){
        mimeType = "text/xml";
        logger.debug("call XML Exporter");
        tmpFile=exporter.getKpiExportXML(blocksList, biobj, userId);
        toReturn.setFileName(biobj.getLabel()+".xml");
      }
    }
    catch (Exception e) {
      logger.error("error while exporting",e);
      return null;
    }
    if(tmpFile==null){
      logger.error("file not created");
      return null;
    }
    else{
      logger.debug("file created");
    }

    try{
      FileDataSource mods = new FileDataSource(tmpFile);   
      toReturn.setFileType(mimeType);
      DataHandler dhSource = new DataHandler(mods);
      toReturn.setContent(dhSource);
    }

    finally{
      logger.debug("deleting file Tmp");
      logger.debug("file Tmp deleted");
View Full Code Here

Examples of it.eng.spagobi.sdk.documents.bo.SDKExecutedDocumentContent


  private SDKExecutedDocumentContent executeReport(SDKDocument document, BIObject biobj, IEngUserProfile profile, String output){

    logger.debug("IN");
    SDKExecutedDocumentContent toReturn = null;

    try {

      ReportExporter jse = new ReportExporter();
      File tmpFile = jse.getReport(biobj, profile, output);
      if (tmpFile == null) {
        logger.error("File returned from exporter is NULL!");
        return null;
      }

      logger.debug("setting object to return of type SDKExecuteDocumentContent");
      toReturn = new SDKExecutedDocumentContent();
      FileDataSource mods = new FileDataSource(tmpFile);
      DataHandler dataHandler = new DataHandler(mods);
      toReturn.setContent(dataHandler);
      String fileExtension = FileUtils.getFileExtension(tmpFile);
      String fileName = null;
      if (fileExtension != null && !fileExtension.trim().equals("")) {
        fileName = biobj.getLabel() + "." + fileExtension;
      } else {
        fileName = biobj.getLabel();
      }
      String mimeType = MimeUtils.getMimeType(tmpFile);
      logger.debug("Produced file name is " + fileName);
      logger.debug("Produced file mimetype is " + mimeType);
      toReturn.setFileName(fileName);
      toReturn.setFileType(mimeType);
      DataHandler dhSource = new DataHandler(mods);
      toReturn.setContent(dhSource);

    } finally {
      logger.debug("OUT");
    }
    return toReturn;
View Full Code Here

Examples of it.eng.spagobi.sdk.documents.bo.SDKExecutedDocumentContent

  public SDKExecutedDocumentContent executeDocument(SDKDocument document, SDKDocumentParameter[] parameters, String roleName, String outputType)
  throws NonExecutableDocumentException, NotAllowedOperationException,MissingParameterValue,InvalidParameterValue {
    logger.debug("IN");
    String output = (outputType != null && !outputType.equals("")) ? outputType : "PDF";
    SDKExecutedDocumentContent toReturn = null;

    IEngUserProfile profile = null;

    Integer idDocument=document.getId();
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.