EditReportSpec.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: DOCS
  4. (C) Copyright IBM Corp. 2005, 2008
  5. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  6. IBM Corp.
  7. */
  8. /**
  9. * EditReportSpec
  10. *
  11. * Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  12. * Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  13. *
  14. * EditReportSpec class contains methods for modifying a simple list
  15. * report
  16. *
  17. */
  18. import com.cognos.developer.schemas.bibus._3.AsynchDetailReportObject;
  19. import com.cognos.developer.schemas.bibus._3.AsynchReply;
  20. import com.cognos.developer.schemas.bibus._3.AsynchReplyStatusEnum;
  21. import com.cognos.developer.schemas.bibus._3.Option;
  22. import com.cognos.developer.schemas.bibus._3.ParameterValue;
  23. import com.cognos.developer.schemas.bibus._3.ReportServiceQueryOptionBoolean;
  24. import com.cognos.developer.schemas.bibus._3.ReportServiceQueryOptionEnum;
  25. import com.cognos.developer.schemas.bibus._3.ReportServiceQueryOptionSpecificationFormat;
  26. import com.cognos.developer.schemas.bibus._3.SearchPathSingleObject;
  27. import com.cognos.developer.schemas.bibus._3.SpecificationFormatEnum;
  28. public class EditReportSpec
  29. {
  30. // get the Report Spec
  31. public String getReportSpec(CRNConnect connect, BaseClassWrapper report)
  32. {
  33. String reportSpec = "";
  34. if ((connect.getReportService() != null)
  35. && (report != null)
  36. && (connect.getDefaultSavePath() != null))
  37. {
  38. // sn_dg_prm_smpl_modifyreport_P1_start_0
  39. try
  40. {
  41. String reportPath = report.getBaseClassObject().getSearchPath().getValue();
  42. Option[] qOpts = new Option[2];
  43. ReportServiceQueryOptionBoolean upgradeSpecFlag = new ReportServiceQueryOptionBoolean();
  44. upgradeSpecFlag.setName(ReportServiceQueryOptionEnum.upgrade);
  45. upgradeSpecFlag.setValue(true);
  46. ReportServiceQueryOptionSpecificationFormat specFormat = new ReportServiceQueryOptionSpecificationFormat();
  47. specFormat.setName(ReportServiceQueryOptionEnum.specificationFormat);
  48. specFormat.setValue(SpecificationFormatEnum.report);
  49. qOpts[0] = upgradeSpecFlag;
  50. qOpts[1] = specFormat;
  51. // sn_dg_sdk_method_reportService_query_start_1
  52. AsynchReply qResult =
  53. connect.getReportService().query(
  54. new SearchPathSingleObject(reportPath),
  55. new ParameterValue[] {},
  56. qOpts);
  57. // sn_dg_sdk_method_reportService_query_end_1
  58. if ( (qResult.getStatus() == AsynchReplyStatusEnum.working)
  59. || (qResult.getStatus() == AsynchReplyStatusEnum.stillWorking) )
  60. {
  61. while ( (qResult.getStatus() == AsynchReplyStatusEnum.working)
  62. || (qResult.getStatus() == AsynchReplyStatusEnum.stillWorking) )
  63. {
  64. qResult = connect.getReportService().wait(qResult.getPrimaryRequest(),
  65. new ParameterValue[] {},
  66. new Option[] {});
  67. }
  68. }
  69. // sn_dg_sdk_method_reportService_query_start_2
  70. // extract the report spec
  71. if (qResult.getDetails() != null)
  72. {
  73. for (int i = 0; i < qResult.getDetails().length; i++)
  74. {
  75. if (qResult.getDetails()[i] instanceof AsynchDetailReportObject)
  76. {
  77. reportSpec = ( (AsynchDetailReportObject)qResult.getDetails()[i]).getReport().getSpecification().getValue();
  78. }
  79. }
  80. }
  81. // sn_dg_sdk_method_reportService_query_end_2
  82. }
  83. // sn_dg_prm_smpl_modifyreport_P1_end_0
  84. catch (java.rmi.RemoteException remoteEx)
  85. {
  86. System.out.println(remoteEx.getMessage());
  87. remoteEx.printStackTrace();
  88. }
  89. }
  90. return reportSpec;
  91. }
  92. }