123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- import com.cognos.developer.schemas.bibus._3.AsynchOptionEnum;
- import com.cognos.developer.schemas.bibus._3.AsynchOptionInt;
- import com.cognos.developer.schemas.bibus._3.AsynchReply;
- import com.cognos.developer.schemas.bibus._3.AsynchReplyStatusEnum;
- import com.cognos.developer.schemas.bibus._3.BaseParameter;
- import com.cognos.developer.schemas.bibus._3.Option;
- import com.cognos.developer.schemas.bibus._3.ParameterValue;
- import com.cognos.developer.schemas.bibus._3.RunOptionBoolean;
- import com.cognos.developer.schemas.bibus._3.RunOptionEnum;
- import com.cognos.developer.schemas.bibus._3.RunOptionStringArray;
- import com.cognos.developer.schemas.bibus._3.SearchPathSingleObject;
- public class Cancel
- {
-
- public String runAndCancelReport(
- CRNConnect connect,
- BaseClassWrapper report)
- {
- String output = new String();
- if ((connect != null)
- && (report != null)
- && (connect.getDefaultSavePath() != null))
- {
- ParameterValue reportParameters[] = new ParameterValue[] {};
- ReportParameters repParms = new ReportParameters();
- BaseParameter[] prm = null;
- try
- {
- prm = repParms.getReportParameters(report, connect);
- }
- catch (java.rmi.RemoteException remoteEx)
- {
- System.out.println("Caught Remote Exception:\n");
- remoteEx.printStackTrace();
- }
- if (prm != null && prm.length > 0)
- {
- reportParameters = ReportParameters.setReportParameters(prm);
- }
- if ((reportParameters == null) || (reportParameters.length <= 0))
- {
- reportParameters = new ParameterValue[] {};
- }
- output += execAndCancel(report, connect, reportParameters);
- }
- else
- {
- output += "Invalid parameter(s) passed to runReport."
- + System.getProperty("line.separator");
- }
- return output;
- }
-
- public String execAndCancel(
- BaseClassWrapper report,
- CRNConnect connect,
- ParameterValue pv[])
- {
- Option execReportRunOptions[] = new Option[5];
- RunOptionBoolean saveOutputRunOption = new RunOptionBoolean();
- RunOptionStringArray outputFormat = new RunOptionStringArray();
- RunOptionBoolean promptFlag = new RunOptionBoolean();
- AsynchOptionInt primaryWaitThreshold = new AsynchOptionInt();
- AsynchOptionInt secondaryWaitThreshold = new AsynchOptionInt();
- AsynchReply rsr = null;
-
- saveOutputRunOption.setName(RunOptionEnum.saveOutput);
- saveOutputRunOption.setValue(false);
-
- String[] reportFormat = new String[] { "HTML" };
- outputFormat.setName(RunOptionEnum.outputFormat);
- outputFormat.setValue(reportFormat);
-
- promptFlag.setName(RunOptionEnum.prompt);
- promptFlag.setValue(false);
-
- primaryWaitThreshold.setName(AsynchOptionEnum.primaryWaitThreshold);
- primaryWaitThreshold.setValue(1);
- secondaryWaitThreshold.setName(AsynchOptionEnum.secondaryWaitThreshold);
- secondaryWaitThreshold.setValue(1);
-
- execReportRunOptions[0] = saveOutputRunOption;
- execReportRunOptions[1] = outputFormat;
- execReportRunOptions[2] = promptFlag;
- execReportRunOptions[3] = primaryWaitThreshold;
- execReportRunOptions[4] = secondaryWaitThreshold;
- SearchPathSingleObject reportSearchPath = new SearchPathSingleObject();
- reportSearchPath.set_value(
- report.getBaseClassObject().getSearchPath().getValue());
- try
- {
- rsr =
- connect.getReportService().run(
- reportSearchPath,
- pv,
- execReportRunOptions);
-
- if (!rsr.getStatus().equals(AsynchReplyStatusEnum.complete))
- {
-
- if (!RunReport.hasSecondaryRequest(rsr, "cancel"))
- {
- return "The conversation didn't lead to a valid state to call cancel()";
- }
-
- connect.getReportService().cancel(rsr.getPrimaryRequest());
-
- return "Call to cancel() succeeded.";
- }
- System.out.println("Secondary requests at complete:");
- for (int i = 0; i < rsr.getSecondaryRequests().length; i++)
- {
- System.out.println(rsr.getSecondaryRequests()[i].getName());
- }
- return "The conversation didn't lead to a valid state to call cancel().";
- }
- catch (java.rmi.RemoteException remoteEx)
- {
- return ("Caught Remote Exception:\n" + remoteEx.toString());
- }
- }
- }
|