How to change universe of a webi document using BO RE Java SDK

Web Intelligence documents use one or many universes. Sometimes it is necessary to change universes for a bunch of reports. Changing universe might be very difficult if you need to modify dozens of documents. Luckily it is possible to utilize BusinessObjects Report Engine Java SDK.

There is a number of Webi documents in a folder which use a number of universes. The task is to make a copy of these on the same BOE server.

It is easy to copy documents (in CMC) and universes (using Universe Designer. The complex problem is to change a copied document to use the copied universes.

The manual procedure of changing universe for a document is the following:

  • Open Webi document in Web Intelligence in edit mode.
  • Click Edit query.
  • For each query, change universe in the query properties.
  • Changing universe you have to confirm mapping. If you change a universe to its copy, you do not need to do anything in this mapping. But just confirming it takes few seconds.

The automated procedure for all documents will do the following:

  • Get list of universe IDs that used by the copied documents.
  • Get list of all available universes.
  • Create a mapping of IDs.
  • Map all reports from the original universes to their copies using the mapping.

If you have to modify 5 documents, the writing code might take even more time then do it manually, but anyway coding is more fun then clicking 🙂

If you have to modify 50  documents, think twice before starting manual work.

Java Function

public static boolean changeUniverses(DocumentInstance widoc,
                                      HashMap<String, String> mapping)
{
   boolean failed = false;
   DataProviders dps = widoc.getDataProviders();
   HashSet<DataSource> dataSources = new HashSet<DataSource>();
   for (int i = 0; i < dps.getCount(); ++i) {
      DataProvider dp = (DataProvider) dps.getItem(i);
      dataSources.add(dp.getDataSource());
   }
   for (DataSource ds: dataSources) {
      String universeId = ds.getUniverseID();
      String oldID = universeId;
      String newID = mapping.get(oldID);
      System.out.println(oldID + "->" + newID);
      dps.changeUniverse(oldID, newID, true);
      if (dps.mustFillChangeUniverseMapping()) {
         ChangeUniverseMapping unvMapping = dps.getChangeUniverseMapping();
         ChangeDataSourceMapping[] dsMappings = unvMapping.getDataSourceMappings();
         for (ChangeDataSourceMapping dsMapping : dsMappings) {
            ChangeDataSourceObjectMapping[] objMappings = dsMapping.getAllMappings();
            for (ChangeDataSourceObjectMapping objMapping : objMappings) {
               if (objMapping.getToObject() == null) {
                  failed = true;
               }
            }
         }
         dps.setChangeUniverseMapping();
         if (widoc.getMustFillContexts()) {
            failed = true;
         }
         widoc.applyFormat();
         widoc.refresh();
      }
      if (failed) {
         return false;
      }
   }
   return true;
}

BTW, the universe id is something like:

UnivCUID=ASiM_T4jxmJIj0aKWpbeXro;UnivID=41709;ShortName=Finance;UnivName=Finance

Complete code

https://bukhantsov.org/tools/WidRemapping.zip

20 thoughts on “How to change universe of a webi document using BO RE Java SDK

  1. Gary

    Hi, what lib do I import to use DataProviders?
    I’m new to Java and any help is greatly appreciated!
    I have circa 500 WebIs that need to be re-pointed to the correct Universes.

    Like

    Reply
  2. Kevin

    Hi,

    Thanks for the app its just what I’ve been looking for.

    I’m not a developer and struggle with code, so was wondering if you could give me instructions on how to run the app as I’m currently getting the error:

    Exception in thread “main” java.land.NoClassDefFoundError

    I understand that this is saying that it cannot find the class definitions, .classpath file, but how do I make the app see this file or better said the Class it requires?

    Like

    Reply
  3. Kevin

    Sorry, I got further by compiling it using javac. However, now it’s complaining about not being able to find any of the import classes…

    All errors are similar to:

    C:\Share\Customers\Z (Greenstone)\JavaTool\src\org\bukhantsov\javatool\Program.java:134: cannot
    symbol : class DataSource
    location: class org.bukhantsov.javatool.Program
    for (DataSource ds: dataSources) {

    I changed the path in the .classpath file to reflect the path to the jar files on my machine, but that hasn’t helped unfortunately.

    I’m using BOE XI 3.1 BTW.

    Like

    Reply
  4. Juda

    Hi,

    Thanks for the code posted. I’m using it.

    But I have problems with some of my reports. (#DATATYPE, #SYNTAX, #FORMAT)

    Looks like they all have merge dimensions.

    Using the UI I didn’t get the same problems.

    I’m using BOE XI 3.1 SP5 BTW

    Can you please help

    Thanks

    Jud

    Like

    Reply
  5. Balaji

    Hi,
    we recently migrated to BI 4.0 SP5
    we have the same issue 3 of our unv has corrupted and we have around 100-120 reports based on each report. I’m really struggling to get this fixed and users are eating my head.
    we renamed the org UNV to XXX1.UNV and now the unv is responding. The issue is how I repoint all my reports to xxx1.unv ??
    ————————————————-

    Is there a way if you can give me a compiled JSP file that I just rename the CUID and run on my Env to fix all these reports ??

    if that is possiable you will be the saver of my life… can you plzzz

    Thanks for your great help in advance

    Thanks
    Balaji Karunakaran

    Like

    Reply
    1. dmytro Post author

      BI 4.0 ReportEngine SDK does not allow to change universe. There is no replacement for that SDK at the moment.
      Do you have 3.1 system?
      Do you have BIAR with the universes and reports?

      Like

      Reply
  6. Mike

    Hi,

    I have started looking at the challenge of remapping a report from a UNV type universe to a UNX universe this week and have seen many posts, including yours, saying that this is not possible in BI 4.0.

    However, APOS have released a tool to do just this, although from their marketing it would appear to be for BI 4.0 SP6 only.

    So, my guess is that the SDK finally got updated in SP6 with methods to remap a report to a different universe? Are you able to shed any light on this?

    Many thanks

    Mike

    Like

    Reply
    1. dmytro Post author

      I am not actively working with SDK lately so I do not have the latest information about this. SAP has definitely been working on the development of their SDK and everything that was not possible will finally be possible soon. I heard that most of the needed functionality will be available in 4.1, and probably in the corresponding SP of 4.0 as well.

      Like

      Reply
  7. Doug

    Thank you very much for this code and others on your blog. It has been very helpful. I was able to modify it to remap all reports in our repository (10,000+ reports).

    If anyone is using this code to remap a large repository, you will have to break up your queries. There is a 1000 object limit on the query. We ran one query that retrieved all user’s personal folders, then looped through each one running a second query to get all of each user’s folder.

    Also, avoid any folders that are read only. The “~webintelligence” folder will cause errors if it is included in the remapping. Explicitly exclude it if you are doing user personal folders.

    Like

    Reply
  8. Suraj Bhosle

    Hi Dmytro,

    Is it possible to copy a webi report from one folder to another using BO SDK?
    Can you please help me understand the approach?

    Regards,
    Suraj

    Like

    Reply
  9. Gurbachan

    Hi ,

    Thanks for the code posted. I’m using it.

    But I have problems with some of my reports. (#DATATYPE, #SYNTAX, #FORMAT)

    Looks like they all have manually created merge dimensions

    Using the UI I didn’t get the same problems.

    I’m using BOE XI 3.1 SP5 FP3

    Can you please help

    Thanks
    Gurbachan

    Like

    Reply
  10. Doug

    I am remapping reports in our repository based on your code. I would recommend changing this line in your code:

    widoc = wiRepEngine.openDocument(infoObject.getID());

    to

    widoc = wiRepEngine.openDocument(infoObject.getID(),true, false);

    Using that version of openDocument with the additional parameters will ignore refresh on open. I found that a lot of my users created documents with refresh on open set. This significantly increased the amount of time it took to remap all of the reports.

    Like

    Reply
    1. Doug

      Sorry, I got the syntax incorrect going from memory. It should be:

      OpenDocumentParameters docParam = new OpenDocumentParameters(infoObject.getID(),true,false) ;
      widoc = wiRepEngine.openDocument(infoObject.getID(),docParam);

      Like

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s