Skip to Content

Taking list of structure as input to a CO

Hi All,

My callable object has following input and output struture:-


	IWDMessageManager myMessage = wdComponentAPI.getMessageManager();
	IGPTechnicalDescription technicalDescription;		
	IWDTextAccessor textAccessor = wdComponentAPI.getTextAccessor();
		
	GPWebDynproResourceAccessor resourceAccessor = new GPWebDynproResourceAccessor(textAccessor);
	technicalDescription = GPCallableObjectFactory.createTechnicalDescription("CO_NAME_KEY", "CO_DESCRIPTION_KEY",resourceAccessor,locale);
		
	//Define Input and Output Structure
	IGPStructureInfo input = technicalDescription.getInputStructureInfo();
	IGPStructureInfo output = technicalDescription.getOutputStructureInfo();
		
	try {
		//Define Input Structure
		IGPStructureInfo inputStr = input.addStructure("I_STR","com.testgp2.input");
		inputStr.setMultiplicity(IGPAttributeInfo.MULITIPLICITY_0_N);			
		inputStr.addAttribute("I_STR_FIRSTNAME",IGPAttributeInfo.BASE_STRING);
		inputStr.addAttribute("I_STR_LASTNAME",IGPAttributeInfo.BASE_STRING);
			
		//Define Output Structure
		IGPStructureInfo outputStr = output.addStructure("O_STR","com.testgp2.output");
		outputStr.setMultiplicity(IGPAttributeInfo.MULITIPLICITY_0_N);
		outputStr.addAttribute("O_STR_FIRSTNAME",IGPAttributeInfo.BASE_STRING);
		outputStr.addAttribute("O_STR_LASTNAME",IGPAttributeInfo.BASE_STRING);
		outputStr.addAttribute("O_STR_COMPLETENAME",IGPAttributeInfo.BASE_STRING);
					
		//Define Result State 
		IGPCOResultStateInfo resultStateSuccess = technicalDescription.addResultState("RESULT_NAME_SUCCESS");
		resultStateSuccess.setNameKey("SUCCESS_KEY");
		resultStateSuccess.setDescriptionKey("SUCCESS_DESCRIPTION_KEY");
			
		//Define Exceptions
		IGPExceptionInfo disaster = technicalDescription.addProcessException("EXCEPTION_NAME_DISASTER");
		disaster.setNameKey("DISASTER_KEY");
		disaster.setDescriptionKey("DISASTER_DESCRIPTION_KEY");
		disaster.setFatal(true);
			
	} catch (GPInvocationException e) {
		return null;
	}
	return technicalDescription;    

Now problem is when I am executing this CO standalone, its working fine but when I try to execute it thru GP its not showing any inputs at runtime. That is the collection size is zero in execute method:-


	IWDMessageManager myMessage = wdComponentAPI.getMessageManager();
	wdContext.currentContextElement().setExecutionContext(executionContext);
	//define Input Structure
	IGPStructure input = executionContext.getInputStructure();		
	try {
		
		//Retrieving all the instances of input structure		
		Collection inputStrList = input.getStructures("I_STR","com.testgp2.input");
		
		myMessage.reportWarning("Size of Collection "+inputStrList.size());
		myMessage.reportWarning("Input Structure Info : \n"+input.getStructureInfo().toString());
		
		
		for(Iterator it = inputStrList.iterator(); it.hasNext();){
			
			IGPStructure inputStr = (IGPStructure) it.next();
			
			myMessage.reportWarning("Inside for loop : \n"+inputStr.getStructureInfo().toString());								
			IPublicCCallableObject2Interface.INAMEElement element =  wdContext.nodeNAME().createNAMEElement();
			
			myMessage.reportSuccess(inputStr.getAttributeAsString("I_STR_FIRSTNAME") + "  "+ inputStr.getAttributeAsString("I_STR_LASTNAME"));
				
			element.setFname(inputStr.getAttributeAsString("I_STR_FIRSTNAME"));
			element.setLname(inputStr.getAttributeAsString("I_STR_LASTNAME"));
			element.setCompleteName(inputStr.getAttributeAsString("I_STR_FIRSTNAME")
									 + " - " 
									 +inputStr.getAttributeAsString("I_STR_LASTNAME"));
				
			wdContext.nodeNAME().addElement(element);
		}
		
		wdContext.currentContextElement().setExecutionContext(executionContext);
			
	} catch (GPInvocationException e) {
		//	   TODO Auto-generated catch block
		e.printStackTrace();
		myMessage.reportWarning(e.getMessage());
		myMessage.reportWarning(e.getLocalizedMessage());
		myMessage.reportWarning(e.getStackTraceString());
	}     

And I have checked the parameter mappings at GP level. They are correct.

Can anybody please suggest?

Regards,

Amey Mogare

Edited by: Amey Mogare on Oct 20, 2008 6:19 AM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Oct 20, 2008 at 05:48 AM

    how you are setting the input parameters

    through CO ?

    please check that part detailly...

    with regards

    shanto aloor

    Add comment
    10|10000 characters needed characters exceeded

    • Inside a block, I have two actions :-

      Action-1 takes user input thru a form (web dynpro view) and passes it as output

      parameter (list)

      getDescription() method in CO-1

      		IWDMessageManager myMessage = wdComponentAPI.getMessageManager();		
      		IGPTechnicalDescription technicalDescription;
      		
      		IWDTextAccessor textAccessor = wdComponentAPI.getTextAccessor();
      		
      		GPWebDynproResourceAccessor resourceAccessor = new GPWebDynproResourceAccessor(textAccessor);
      		technicalDescription = GPCallableObjectFactory.createTechnicalDescription("CO_NAME_KEY", "CO_DESCRIPTION_KEY",resourceAccessor,locale);
      		
      		//Define Input and Output Structure
      		IGPStructureInfo output = technicalDescription.getOutputStructureInfo();
      		
      		try {
      		
      			//Define Output Structure
      			IGPStructureInfo outputStr = output.addStructure("O_STR","com.testgp.output");
      			outputStr.setMultiplicity(IGPAttributeInfo.MULITIPLICITY_0_N);
      			outputStr.addAttribute("O_STR_FIRSTNAME",IGPAttributeInfo.BASE_STRING);
      			outputStr.addAttribute("O_STR_LASTNAME",IGPAttributeInfo.BASE_STRING);
      			
      			//Define Result State 
      			IGPCOResultStateInfo resultStateSuccess = technicalDescription.addResultState("RESULT_NAME_SUCCESS");
      			resultStateSuccess.setNameKey("SUCCESS_KEY");
      			resultStateSuccess.setDescriptionKey("SUCCESS_DESCRIPTION_KEY");
      			
      			//Define Exceptions
      			IGPExceptionInfo disaster = technicalDescription.addProcessException("EXCEPTION_NAME_DISASTER");
      			disaster.setNameKey("DISASTER_KEY");
      			disaster.setDescriptionKey("DISASTER_DESCRIPTION_KEY");
      			disaster.setFatal(true);
      			
      		} catch (GPInvocationException e) {
      			return null;
      		}
      		return technicalDescription;
      
      
      

      And here is the complete() method of CO-1 :---

      
          	IWDMessageManager myMessage = wdComponentAPI.getMessageManager();
      		IGPExecutionContext executionContext = wdContext.currentContextElement().getExecutionContext();
      		//define Output Structure
      		IGPStructure output = executionContext.getOutputStructure();
      		
      		try {
      
      			//Setting final output list
      			String o_fname, o_lastname;
      			myMessage.reportWarning("This is outside for-loop of complete() method of CO-1");
      			for(int i = 0; i < wdContext.nodeSTR().size(); i++){
      
      				o_fname = wdContext.nodeSTR().getSTRElementAt(i).getValue1();
      				o_lastname = wdContext.nodeSTR().getSTRElementAt(i).getValue2();				
      				
      				IGPStructure outputStr = output.addStructure("O_STR","com.testgp.output");
      				outputStr.setAttributeValue("O_STR_FIRSTNAME", o_fname);
      				outputStr.setAttributeValue("O_STR_LASTNAME", o_lastname);
      			
      				myMessage.reportWarning("Inside loop["+i+"] outputStr.getStructureInfo().toString():- \n"+outputStr.getStructureInfo().toString());
      				myMessage.reportWarning("Firstname :- "+outputStr.getAttributeAsString("O_STR_FIRSTNAME"));
      				myMessage.reportWarning("Lastname :- "+outputStr.getAttributeAsString("O_STR_LASTNAME"));
      			}
      			
      			//success
      			executionContext.setResultState("RESULT_NAME_SUCCESS");
      			executionContext.processingComplete();
      			
      		} catch (GPInvocationException e) {
      			//	   TODO Auto-generated catch block
      			e.printStackTrace();
      			
      		} catch (GPEngineException e) {
      			//	   TODO Auto-generated catch block
      			e.printStackTrace();
      		}
      

      And inside a process, I am passing this output list to another action. (whose code I have already put up in my question)

      I hope I made my problem clear. Pls help.

      Thanks n regards,

      Amey Mogare