Package org.pentaho.platform.api.engine

Examples of org.pentaho.platform.api.engine.IActionSequenceResource


    }

    Set resourceNames = getResourceNames();
    Iterator resourceNamesIterator = resourceNames.iterator();
    String resourceName;
    IActionSequenceResource actionResource;
    while ( resourceNamesIterator.hasNext() ) {
      resourceName = (String) resourceNamesIterator.next();
      actionResource = getResource( resourceName );
      message( Messages
          .getInstance()
          .getString(
            "TestComponent.DEBUG_RESOURCE_DESCRIPTION", resourceName, actionResource.getMimeType(),
            actionResource.getAddress() ) ); //$NON-NLS-1$
      try {
        String content = getResourceAsString( actionResource );
        message( Messages.getInstance().getString(
            "TestComponent.DEBUG_RESOURCE_CONTENTS", ( ( content == null ) ? "null" : content.substring( 0, 100 ) ) ) ); //$NON-NLS-1$ //$NON-NLS-2$
      } catch ( Exception e ) {
View Full Code Here


      TemplateMsgAction actionDefinition = (TemplateMsgAction) getActionDefinition();
      String template = null;

      template = actionDefinition.getTemplate().getStringValue();
      if ( ( null == template ) && isDefinedResource( TemplateComponent.TEMPLATE ) ) {
        IActionSequenceResource resource = getResource( "template" ); //$NON-NLS-1$
        template = getResourceAsString( resource );
      }

      String outputName = (String) getOutputNames().iterator().next();
      IActionParameter outputParam = getOutputItem( outputName );
View Full Code Here

  @SuppressWarnings( "unused" )
  private PentahoTableDataFactory getJarDataFactory() throws Exception {
    PentahoTableDataFactory factory = null;
    if ( isDefinedResource( AbstractJFreeReportComponent.DATACOMPONENT_JARINPUT ) ) {
      final IActionSequenceResource resource = getResource( AbstractJFreeReportComponent.DATACOMPONENT_JARINPUT );
      final InputStream in;
      try {
        in = resource.getInputStream( RepositoryFilePermission.READ, LocaleHelper.getLocale() );
        try {
          // not being able to read a single char is definitly a big boo ..
          if ( in.read() == -1 ) {
            throw new Exception( Messages.getInstance().getErrorString( "JFreeReport.ERROR_0009_REPORT_JAR_UNREADABLE" ) ); //$NON-NLS-1$
          } else {
            final ClassLoader loader = ReportUtils.createJarLoader( getSession(), resource );
            if ( loader == null ) {
              throw new Exception( Messages.getInstance().getString(
                "JFreeReportDataComponent.ERROR_0035_COULD_NOT_CREATE_CLASSLOADER" ) ); //$NON-NLS-1$
            } else if ( !isDefinedInput( AbstractJFreeReportComponent.DATACOMPONENT_CLASSLOCINPUT ) ) {
              throw new Exception( Messages.getInstance().getErrorString(
                "JFreeReport.ERROR_0012_CLASS_LOCATION_MISSING" ) ); //$NON-NLS-1$
            } else {
              final String classLocation =
                  getInputStringValue( AbstractJFreeReportComponent.DATACOMPONENT_CLASSLOCINPUT );
              // Get input parameters, and set them as properties in the report
              // object.
              final ReportParameterValues reportProperties = new ReportParameterValues();
              final Set paramNames = getInputNames();
              final Iterator it = paramNames.iterator();
              while ( it.hasNext() ) {
                final String paramName = (String) it.next();
                final Object paramValue = getInputValue( paramName );
                if ( paramValue instanceof Object[] ) {
                  final Object[] values = (Object[]) paramValue;
                  final StringBuffer valuesBuffer = new StringBuffer();
                  // TODO support non-string items
                  for ( int i = 0; i < values.length; i++ ) {
                    if ( i == 0 ) {
                      valuesBuffer.append( values[i].toString() );
                    } else {
                      valuesBuffer.append( ',' ).append( values[i].toString() );
                    }
                  }
                  reportProperties.put( paramName, valuesBuffer.toString() );
                } else {
                  reportProperties.put( paramName, paramValue );
                }
              }

              final DataFactory dataFactory = new PentahoDataFactory( loader );
              final TableModel model = dataFactory.queryData( classLocation, new ParameterDataRow( reportProperties ) );

              factory = new PentahoTableDataFactory( AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, model );
            }
          }
        } catch ( Exception e ) {
          throw new Exception( Messages.getInstance().getErrorString( "JFreeReport.ERROR_0009_REPORT_JAR_UNREADABLE" ) ); //$NON-NLS-1$
        }
      } catch ( FileNotFoundException e1 ) {
        throw new Exception( Messages.getInstance().getErrorString(
          "JFreeReport.ERROR_0010_REPORT_JAR_MISSING", resource.getAddress() ) ); //$NON-NLS-1$
      }
    }
    return factory;
  }
View Full Code Here

  public InputStream getResourceAsStream( final ResourceManager caller ) throws ResourceLoadingException {
    int resourceType = IActionResource.SOLUTION_FILE_RESOURCE;
    if ( filename.contains( "://" ) ) {
      resourceType = IActionResource.URL_RESOURCE;
    }
    final IActionSequenceResource resource =
        new ActionSequenceResource( "", resourceType, "application/binary", (String) key.getIdentifier() ); //$NON-NLS-1$ //$NON-NLS-2$
    return resource.getInputStream( RepositoryFilePermission.READ, LocaleHelper.getLocale() );
  }
View Full Code Here

      URL url = null;
      if ( srcXml != null ) {
        inputStream = new FileInputStream( new File( createTempXMLFile( srcXml ) ) );
      } else if ( xmlResource != null ) {
        // we have a local document to use as the data source
        IActionSequenceResource resource = getResource( xmlResource.getName() );
        resourceType = resource.getSourceType();
        if ( ( resourceType == IActionSequenceResource.SOLUTION_FILE_RESOURCE )
          || ( resourceType == IActionSequenceResource.FILE_RESOURCE ) ) {
          inputStream = resource.getInputStream( RepositoryFilePermission.READ );
        } else if ( resourceType == IActionSequenceResource.XML ) {
          inputStream = new FileInputStream( new File( createTempXMLFile( resource.getAddress() ) ) );
        } else {
          url = new URL( documentPath );
        }
      }

      // Retrieve the column types
      String[] columnTypes = null;
      if ( retrieveColumnTypes() ) {
        try {
          SAXReader reader = new SAXReader();
          Document document;
          if ( url != null ) {
            document = reader.read( url );
          } else {
            document = reader.read( inputStream );
          }
          Node commentNode = document.selectSingleNode( "/result-set/comment()" ); //$NON-NLS-1$
          if ( commentNode != null ) {
            String commentString = commentNode.getText();
            StringTokenizer st = new StringTokenizer( commentString, "," ); //$NON-NLS-1$
            List columnTypesList = new LinkedList();
            while ( st.hasMoreTokens() ) {
              String token = st.nextToken().trim();
              columnTypesList.add( token );
            }
            columnTypes = (String[]) columnTypesList.toArray( new String[ 0 ] );
          }
        } catch ( Exception e ) {
          getLogger().warn(
            Messages.getInstance().getString( "XQueryBaseComponent.ERROR_0009_ERROR_BUILDING_COLUMN_TYPES" ),
            e ); //$NON-NLS-1$
        }
      }

      if ( rawQuery != null ) {
        if ( rawQuery.indexOf( "{" + XQueryBaseComponent.XML_DOCUMENT_TAG + "}" ) >= 0 ) { //$NON-NLS-1$//$NON-NLS-2$
          rawQuery = TemplateUtil.applyTemplate( rawQuery, XQueryBaseComponent.XML_DOCUMENT_TAG, documentPath );
        } else {
          Calendar now = Calendar.getInstance();
          File temp = File.createTempFile( "tempXQuery" + now.getTimeInMillis(), ".xml" );
          temp.deleteOnExit();

          OutputStream out = new FileOutputStream( temp );
          IActionSequenceResource resource = getResource( xmlResource.getName() );
          inputStream = resource.getInputStream( RepositoryFilePermission.READ );
          byte[] buf = new byte[ 1024 ];
          int len;
          while ( ( len = inputStream.read( buf ) ) > 0 ) {
            out.write( buf, 0, len );
          }
View Full Code Here

   * @return the image
   */
  public static Image getImage( final String imageName, final IPentahoSession session ) {
    Image image = null;
    try {
      IActionSequenceResource resource =
          new ActionSequenceResource( "", IActionSequenceResource.SOLUTION_FILE_RESOURCE, "", //$NON-NLS-1$ //$NON-NLS-2$
              imageName );
      InputStream is = resource.getInputStream( RepositoryFilePermission.READ, LocaleHelper.getLocale() );
      image = ImageIO.read( is );
    } catch ( IOException e ) {
      JFreeChartEngine.log.error( null, e );
    }
    return image;
View Full Code Here

      if ( !isDefinedInput( AbstractJFreeReportComponent.REPORTLOAD_REPORTLOC ) ) {
        error( Messages.getInstance().getErrorString( "JFreeReport.ERROR_0011_REPORT_LOCATION_MISSING" ) ); //$NON-NLS-1$
        return false;
      }

      final IActionSequenceResource resource = getResource( AbstractJFreeReportComponent.DATACOMPONENT_JARINPUT );
      final InputStream in;
      in = resource.getInputStream( RepositoryFilePermission.READ, LocaleHelper.getLocale() );

      try {
        // not being able to read a single char is definitly a big boo ..
        if ( in.read() == -1 ) {
          error( Messages.getInstance().getErrorString( "JFreeReport.ERROR_0009_REPORT_JAR_UNREADABLE" ) ); //$NON-NLS-1$
View Full Code Here

  }

  private MasterReport getReportFromResource() throws ResourceException, IOException {
    MasterReport report = null;
    if ( isDefinedResource( AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTDEFN ) ) {
      final IActionSequenceResource resource = getResource(
        AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTDEFN );

      if ( resource.getSourceType() == IActionResource.XML ) {
        String repDef = resource.getAddress();
        ReportGenerator generator = ReportGenerator.getInstance();

        report =
            generator.parseReport( new InputSource( new ByteArrayInputStream( repDef.getBytes() ) ),
                getDefinedResourceURL( null ) );
      }
      report = parseReport( resource );
    } else if ( isDefinedInput( AbstractJFreeReportComponent.REPORTLOAD_RESOURCENAME ) ) {
      final String resName = getInputStringValue( AbstractJFreeReportComponent.REPORTLOAD_RESOURCENAME );
      if ( isDefinedResource( resName ) ) {
        final IActionSequenceResource resource = getResource( resName );
        report = parseReport( resource );
      }
    }
    return report;
  }
View Full Code Here

    return report;
  }

  private MasterReport getReportFromJar() throws Exception {
    MasterReport report;
    final IActionSequenceResource resource = getResource( AbstractJFreeReportComponent.DATACOMPONENT_JARINPUT );
    final ClassLoader loader = ReportUtils.createJarLoader( getSession(), resource );
    if ( loader == null ) {
      throw new Exception( Messages.getInstance().getString(
        "JFreeReportLoadComponent.ERROR_0035_COULD_NOT_CREATE_CLASSLOADER" ) ); //$NON-NLS-1$
    }

    String reportLocation = getInputStringValue( AbstractJFreeReportComponent.REPORTLOAD_REPORTLOC );
    URL resourceUrl = loader.getResource( reportLocation );
    if ( resourceUrl == null ) {
      throw new Exception( Messages.getInstance().getErrorString( "JFreeReport.ERROR_0016_REPORT_RESOURCE_INVALID", //$NON-NLS-1$
          reportLocation, resource.getAddress() ) );
    }

    try {
      ReportGenerator generator = ReportGenerator.getInstance();
      report = generator.parseReport( resourceUrl, getDefinedResourceURL( resourceUrl ) );
View Full Code Here

    WidgetDefinition widget = null;
    if ( type == DashboardWidgetComponent.TYPE_DIAL ) {

      // load the XML document that defines the dial
      IActionSequenceResource resource =
          new ActionSequenceResource( title, IActionSequenceResource.SOLUTION_FILE_RESOURCE, "text/xml", //$NON-NLS-1$
              definitionPath );
      Document dialDefinition = null;
      try {
        org.dom4j.io.SAXReader reader = new org.dom4j.io.SAXReader();
        reader.setEntityResolver( new SolutionURIResolver() );
        dialDefinition =
            reader.read( resource.getInputStream( RepositoryFilePermission.READ, LocaleHelper.getLocale() ) );
      } catch ( Throwable t ) {
        // XML document can't be read. We'll just return a null document.
      }

      if ( dialDefinition == null ) {
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.engine.IActionSequenceResource

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.