Package org.eclipse.birt.report.model.api

Examples of org.eclipse.birt.report.model.api.ScalarParameterHandle


  }
 
  public LabelValueBean[] getReportParameterOptions(IParameterDefnBase parameter) throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    LabelValueBean options[] = null;
    ScalarParameterHandle handle = (ScalarParameterHandle) parameter.getHandle();
   
    Vector<LabelValueBean> v = new Vector<LabelValueBean>();
    if (handle.getDataSetName() != null) {
      String columnName = extractSqlColumn(handle.getValueExpr());
     
      List<?> list = runnable.getDesignInstance().getDataSet(handle.getDataSetName()).getCachedResultSetColumns();
      Iterator<?> columnIterator = list.iterator();
      int position = 0;
      while (columnIterator.hasNext()) {
        IResultSetColumn column = (IResultSetColumn) columnIterator.next();
        String name = column.getName();
        if (name.equals(columnName)) {
          break;
        }
        position++;
      }
     
      IDataSet dataSet = runnable.getDesignInstance().getDataSet(handle.getDataSetName());
      String queryText = dataSet.getQueryText();
      String sortByColumn = extractSqlColumn(handle.getSortByColumn());
      queryText += " order by " + sortByColumn;
      queryText += " " + handle.getSortDirection();
      Query query = em.createNativeQuery(queryText);
      Iterator<?> iterator = query.getResultList().iterator();
      while (iterator.hasNext()) {
        Object object[] = (Object[]) iterator.next();
        LabelValueBean bean = new LabelValueBean((String) object[position], (String) object[position]);
        v.add(bean);
      }
    }
    else {
      Iterator<?> iterator = handle.getListProperty("selectionList").iterator();
      while (iterator.hasNext()) {
        SelectionChoice selectionChoice = (SelectionChoice) iterator.next();
        LabelValueBean bean = new LabelValueBean(selectionChoice.getLabel(), selectionChoice.getValue());
        v.add(bean);
      }
View Full Code Here


        Collection<?> collection = engine.getReportParameters();
        Iterator<?> iterator = collection.iterator();
        Vector<ReportParamDisplayForm> vector = new Vector<ReportParamDisplayForm>();
        while (iterator.hasNext()) {
          IParameterDefnBase definition = (IParameterDefnBase) iterator.next();
          ScalarParameterHandle handle = (ScalarParameterHandle) definition.getHandle();
          if (definition.getName().equals("siteId")) {
            continue;
          }
          ReportParamDisplayForm reportParamDisplayForm = new ReportParamDisplayForm();
          reportParamDisplayForm.setName(definition.getName());
          reportParamDisplayForm.setDisplayName(definition.getPromptText());
          reportParamDisplayForm.setType(handle.getDataType());
          reportParamDisplayForm.setRequired("Y");
         
          if (handle.getControlType().equals(DesignChoiceConstants.PARAM_CONTROL_LIST_BOX)) {
            LabelValueBean values[] = engine.getReportParameterOptions(definition);
            if (handle.distinct()) {
              Vector<LabelValueBean> valueVector = new Vector<LabelValueBean>();
              for (LabelValueBean value : values) {
                boolean found = false;
                Enumeration<LabelValueBean> enumeration = valueVector.elements();
                while (enumeration.hasMoreElements()) {
View Full Code Here

    private void generateOptions(ReportGeneratorActionForm form, ReportEngine engine, String siteId) throws NumberFormatException, Exception {
    Collection<?> collection = engine.getReportParameters();
    Iterator<?> iterator = collection.iterator();
    while (iterator.hasNext()) {
      IParameterDefnBase definition = (IParameterDefnBase) iterator.next();
      ScalarParameterHandle handle = (ScalarParameterHandle) definition.getHandle();
      if (definition.getName().equals("siteId")) {
        continue;
      }
      if (handle.getControlType().equals(DesignChoiceConstants.PARAM_CONTROL_LIST_BOX)) {
        LabelValueBean values[] = engine.getReportParameterOptions(definition);
        ReportParamDisplayForm reportParamDisplayForm = null;
        for (ReportParamDisplayForm f : form.getReportParameters()) {
          if (f.getName().equals(definition.getName())) {
            reportParamDisplayForm = f;
View Full Code Here

    }


    //Get report design and find default value, prompt text and data set expression using the DE API
    ReportDesignHandle reportHandle = ( ReportDesignHandle ) report.getDesignHandle( );
    ScalarParameterHandle parameterHandle = (ScalarParameterHandle) reportHandle.findParameter( scalar.getName() );
    parameter.put("Default Value", parameterHandle.getDefaultValue());
    parameter.put("Prompt Text", parameterHandle.getPromptText());
    parameter.put("Data Set Expression", parameterHandle.getValueExpr());

    if(scalar.getControlType() !=  IScalarParameterDefn.TEXT_BOX)
    {
      //retrieve selection list for cascaded parameter
      if ( parameterHandle.getContainer( ) instanceof CascadingParameterGroupHandle){
        Collection sList = Collections.EMPTY_LIST;
        if ( parameterHandle.getContainer( ) instanceof CascadingParameterGroupHandle )
        {
          int index = parameterHandle.getContainerSlotHandle( )
              .findPosn( parameterHandle );
          Object[] keyValue = new Object[index];
          for ( int i = 0; i < index; i++ )
          {
            ScalarParameterHandle handle = (ScalarParameterHandle) ( (CascadingParameterGroupHandle) parameterHandle.getContainer( ) ).getParameters( )
                .get( i );
            //Use parameter default values
            keyValue[i] = handle.getDefaultValue();
          }
          String groupName = parameterHandle.getContainer( ).getName( );
          task.evaluateQuery( groupName );

          sList = task.getSelectionListForCascadingGroup( groupName, keyValue );
View Full Code Here

TOP

Related Classes of org.eclipse.birt.report.model.api.ScalarParameterHandle

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.