BaseReportAndParameters.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. * BaseReportAndParameters.java
  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. */
  15. import java.rmi.RemoteException;
  16. import java.util.Hashtable;
  17. import java.util.Set;
  18. import com.cognos.developer.schemas.bibus._3.BaseClass;
  19. import com.cognos.developer.schemas.bibus._3.BaseParameter;
  20. import com.cognos.developer.schemas.bibus._3.OrderEnum;
  21. import com.cognos.developer.schemas.bibus._3.PropEnum;
  22. import com.cognos.developer.schemas.bibus._3.QueryOptions;
  23. import com.cognos.developer.schemas.bibus._3.SearchPathMultipleObject;
  24. import com.cognos.developer.schemas.bibus._3.Sort;
  25. public class BaseReportAndParameters {
  26. ReportParameters myReportParameters = new ReportParameters();
  27. DrillThrough myDrillThrough = new DrillThrough();
  28. // Default constructor
  29. public BaseReportAndParameters() {
  30. }
  31. /**
  32. * Hash report name and its parameters
  33. */
  34. public Hashtable hashReportNameAndPara(CRNConnect conn, String mySearchPath) {
  35. Hashtable myHashTable = null;
  36. BaseClassWrapper[] myReport = null;
  37. // retrieve objects from the content store
  38. BaseClass[] reportList = getCSObject(conn, mySearchPath);
  39. myReport = new BaseClassWrapper[reportList.length];
  40. if (reportList != null && reportList.length > 0) {
  41. myHashTable = new Hashtable();
  42. for (int num = 0; num < reportList.length; num++) {
  43. BaseParameter[] myBasePara = null;
  44. myReport[num] = new BaseClassWrapper(reportList[num]);
  45. String aReportName = myReport[num].toString();
  46. try {
  47. // get report's parameters
  48. myBasePara = myReportParameters.getReportParameters(
  49. myReport[num], conn);
  50. } catch (RemoteException reEx) {
  51. System.out.println("Error getting '"
  52. + myReport[num].getBaseClassObject()
  53. .getSearchPath().getValue() + aReportName
  54. + "' parameters: "
  55. + reEx.getMessage());
  56. return null;
  57. }
  58. if (myBasePara.length > 0) {
  59. myHashTable.put(myReport[num], myBasePara);
  60. }
  61. }
  62. }
  63. return myHashTable;
  64. }
  65. /**
  66. * Use to get all the packages from content store
  67. */
  68. public BaseClassWrapper[] getListOfPackages(CRNConnect myCon) {
  69. BaseClassWrapper[] listOfPackages = null;
  70. // package search path
  71. String mySearchPath = "/content//package";
  72. BaseClass[] packageList = getCSObject(myCon, mySearchPath);
  73. if (packageList != null && packageList.length > 0) {
  74. int numOfPackage = packageList.length;
  75. listOfPackages = new BaseClassWrapper[numOfPackage];
  76. for (int i = 0; i < numOfPackage; i++) {
  77. listOfPackages[i] = new BaseClassWrapper(packageList[i]);
  78. }
  79. }
  80. return listOfPackages;
  81. }
  82. /**
  83. * Use this method to retrieve objects from the content store
  84. */
  85. public BaseClass[] getCSObject(CRNConnect con, String myPathStr) {
  86. SearchPathMultipleObject cmSearchPath = new SearchPathMultipleObject(
  87. myPathStr);
  88. BaseClass[] myCMObject = null;
  89. PropEnum props[] = new PropEnum[] { PropEnum.searchPath,
  90. PropEnum.defaultName };
  91. Sort sortOptions[] = { new Sort() };
  92. sortOptions[0].setOrder(OrderEnum.ascending);
  93. sortOptions[0].setPropName(PropEnum.defaultName);
  94. try {
  95. myCMObject = con.getCMService().query(cmSearchPath, props,
  96. sortOptions, new QueryOptions());
  97. } catch (RemoteException remoteEx) {
  98. System.out
  99. .println("Error retrieving object from Content Store according to specified search path: "
  100. + remoteEx.getMessage());
  101. }
  102. return myCMObject;
  103. }
  104. /**
  105. * Use this method to retrieve report from a hash table
  106. */
  107. public BaseClassWrapper[] getReports(Hashtable myHash) {
  108. BaseClassWrapper[] listOfReport = null;
  109. Set setOfReport = myHash.keySet();
  110. Object[] myReports = setOfReport.toArray();
  111. if (myReports.length > 0) {
  112. listOfReport = new BaseClassWrapper[myReports.length];
  113. for (int n = 0; n < myReports.length; n++) {
  114. listOfReport[n] = (BaseClassWrapper) myReports[n];
  115. }
  116. }
  117. return listOfReport;
  118. }
  119. }