Skip to Content
0
Former Member
Mar 02, 2009 at 01:56 PM

how to set values to unniverse prompts through java

42 Views

Hi

I am using JAVA -BOSDK to access reports from infoview. I have a problem when any universe level prompt is present in the report. I am able to retrieve it through java when i say documentInstance.getPrompts() and when i set values to this prompt by Prompt.enterValues(String[] parameters) and then either save the report or saveAs another report , my new values dont get applied to the prompt. Only previous values get applied to the prompt. I checked doing prompt.getPreviousValues and prompt.getCurrentValues but when i save the doc then new values are not set.

here is a part of code iam using: the filterlist contains the ConditionFilterDataItems objects which contain the operands,operator and queryObjectName .I have added multiple prompt.getPrevious and current values for debug purpose.


 private static void applyValuesToUniversePrompt( final DocumentInstance doc, final List filterList )
    {
        final DataProviders dps = doc.getDataProviders() ;
        final DataProvider dataProvider = dps.getItem( 0 ) ;
        final Query query = dataProvider.getQuery() ;
        Prompts newPrompts = doc.getPrompts();
        Prompt newprompt = newPrompts.getItem( 0 );
        newprompt.getPreviousValues();
        newprompt.getCurrentValues();

        final ConditionContainer conditioncont = (OMConditionContainer) query.getCondition() ;
        ConditionFilterDataItem conditionFilterDataItem = null ;
        final Map promptMap = generateInstanceMap( doc ) ;

        //Prompt [] promptArr ;

        for( int i = 0 ; i < filterList.size() ; i++ )
        {
            conditionFilterDataItem = (ConditionFilterDataItem) filterList.get( i ) ;

           
            final String [] operands = conditionFilterDataItem.getFilterOperand() ;
            PromptsImpl univPrompts = (PromptsImpl)doc.getPrompts();
            Prompt [] promptArr = new Prompt[univPrompts.getCount()];
            for(int k= 0;k< univPrompts.getCount();k++)
            {
                 promptArr[k] =(Prompt) univPrompts.getItem( k );
            }
            if(univPrompts.getCount()==0)
                promptArr=null;
            
          if(promptArr!=null)
          {
            for( int j = 0 ; j < promptArr.length ; j++ )
            {
                final Prompt prompt = promptArr [j] ;

                final String promptName = prompt.getName() ;
                final Prompt currentPrompt = (Prompt) promptMap.get( promptName ) ;
                if( operands [j] != null )
                {   
                    currentPrompt.getPreviousValues();
                    currentPrompt.getCurrentValues();
                    currentPrompt.removeValues( currentPrompt.getPreviousValues() );
                    currentPrompt.enterValues( convertStringToArray( operands [j] ) ) ;
                    currentPrompt.getPreviousValues();
                    currentPrompt.getCurrentValues();
                    
                    doc.setPrompts();
                    newPrompts = doc.getPrompts();
                    newprompt = newPrompts.getItem( 0 );
                    newprompt.getPreviousValues();
                    newprompt.getCurrentValues();

                 }
             }
          }
        }
        //doc.setPrompts() ;
        doc.refresh();
        doc.save();
        newPrompts = doc.getPrompts();
        newprompt = newPrompts.getItem( 0 );
        newprompt.getPreviousValues();
        newprompt.getCurrentValues();
     
       // dataProvider.runQuery() ;
        doc.refresh();
        doc.saveAs( "universePrompt2",7148,null,null ) ;
         doc.closeDocument() ;
    }


 private static Map generateInstanceMap( final DocumentInstance document )
    {
        final Map promptMap = new HashMap() ;
        final Prompts prompts = document.getPrompts() ;
        int count ;
        if( prompts != null )
        {
            count = prompts.getCount() ;
            for( int i = 0 ; i < count ; i++ )
            {
                final Prompt prompt = prompts.getItem( i ) ;
                promptMap.put( prompt.getName(), prompt ) ;
            }
        }
        return promptMap ;
    }