[BO XI 3.x] - How to switch a connexion ? (SOLVED)

We have been asked for the following requirement :

Users want to be able to switch universe connexion to avoid people macking queries during corresponding database loading times.

In former v4/5/6, it was possible to use a piece of sql to dynamicaly switch the univers connexion from one to another but it is not longer possible on XI ? have you already met such requirement ? Any ideas ?

Thank you in advance

Bernard


bernard timbal :fr: (BOB member since 2003-05-26)

Depending on the connection type, could you not drop and recreate the actual connection that BO refers to?
I.e. if using ODBC recreate the DSN
E.g http://www.enterpriseitplanet.com/resources/scripts_win/article.php/3089341


MikeD :south_africa: (BOB member since 2002-06-18)

It’s fairly easy to switch universe connection using Designer SDK


jp.golay :switzerland: (BOB member since 2002-06-17)

[quote:796c200c50=“jp.golay”]It’s fairly easy to switch universe connection using Designer SDK
[/quote]

You can also use the enterprise SDK which may be faster since you avoid opening Designer, downloading the universe and exporting to the repository.


BoB LoblaW :us: (BOB member since 2007-10-23)

Have you achieved to change universe connection using enterprise SDK, I am interested in a code sample


jp.golay :switzerland: (BOB member since 2002-06-17)

The basic steps required are:
[list]Query for the universe objects and cast them to IUniverse
Call the getDataConnections() method which returns a set of connection IDs
Delete the contents of the sets and add the new connection ID[/list]
Here is a quick snippet I put together a while back:

// Get ID for the new connection
String query = "SELECT SI_ID, SI_NAME FROM CI_APPOBJECTS WHERE SI_KIND = '" + CeKind.DATACONNECTION + "' AND SI_NAME = '"	 + NEWCONN + "'";

int connID = ((IInfoObject)Utils.getInfoObjects(infoStore, query).get(0)).getID();

// Get universes to change
query = "SELECT SI_ID, SI_NAME, SI_DATACONNECTION FROM CI_APPOBJECTS WHERE SI_KIND = 'universe' AND SI_NAME IN (" + Utils.join(UNVNAMES, ",", "'") + ")";
IInfoObjects unvs = Utils.getInfoObjects(infoStore, query);

for (Object o : unvs) {
	IUniverse unv = (IUniverse)o;
	Set<Integer> conns = unv.getDataConnections();
	
	// Check to see if the universe had a connection
	String oldConn = "[no connection]";
	if (conns.size() != 0)
		oldConn = Utils.getConnectionName(conns.iterator().next(), infoStore);
	
	conns.clear();
	conns.add(connID);
	System.out.println(unv.getTitle() + " connection changed from " + oldConn + " to " + NEWCONN);
}

infoStore.commit(unvs);
System.out.println("Complete");

“Utils” is a custom utility class I put together to handle repetitive tasks.


BoB LoblaW :us: (BOB member since 2007-10-23)

Thanks, nice code, do know if it’s also possible to change Deski universes using such methods?
I am always fighting to do this inside Deski SDK


jp.golay :switzerland: (BOB member since 2002-06-17)

[Moderator Note - Moved to SDK forum]


Nick Daniels :uk: (BOB member since 2002-08-15)

I’ve never tried it for Deski documents, but it does work for Webi docs. I suspect the process to be similar (if not identical) for Deski.


BoB LoblaW :us: (BOB member since 2007-10-23)

Is it possible to change universes if a webi doc have multiples dataproviders with differents universes. Did you tried, is it just the universe order we must keep?


jp.golay :switzerland: (BOB member since 2002-06-17)

Hi,

I post in this topic because i have a similar problem.

I 'm working on VB6 on a projet which we import or export universes between severals clients on different server.

i want to change my connection and have a shared connection because of these clients have to open my universes after import/export of th universe.

As well as i began vb6 and business objects for a few time, i need help.
I saw my bff jill’s code but i didn’t understand it.
I looked at SDK Designer Universe but there are not help or something about Connection property.

I tried this:

        'Import.designerApplication.Universes(univers).Connection = "Shared Connection"
        'Import.designerApplication.Universes(univers).Save

where

Import. ...

is the name of my form

Public designerApplication As New designer.Application 

for designerApplication

and univers as the universe i want to change his connection

So thanks for help

Baris


Benns (BOB member since 2009-05-27)

try something like


Sub Switch_Unv_Cx()
Dim CMSName As String
Dim DesApp As Designer.Application
Dim DesCx As Designer.Connections
Dim DesUnis As Designer.Universes
Dim DesUniAdHoc As Designer.Universe
Dim UnvName As String

UnvName = "TST_SWITCH"
Set DesApp = New Designer.Application
Call DesApp.Logon(bologin, bopwd, CMSName, "secEnterprise")

DesApp.Window.State = dsMinimized
DesApp.Visible = True
DesApp.Interactive = False

Set DesUnis = DesApp.Universes
Call DesUnis.OpenFromEnterprise("ADM", UnvName, 0)
If DesUnis.Item(1).Connection = "CX_BASE_PROD" Then
    DesUnis.Item(1).Connection = "CX_DATAWARE"
    Call DesUnis.Item(1).SaveAsEx(UnvName)
    DesUnis.Item(1).Close
    Call DesApp.Universes.Export("ADM", UnvName, 0)
    DesApp.Quit
    MsgBox "Switched connexion for univers " + "ADM/" + UnvName + " : CX_BASE_PROD > CX_DATAWARE"
    
Exit Sub
End If

If DesUnis.Item(1).Connection = "CX_DATAWARE" Then
    DesUnis.Item(1).Connection = "CX_BASE_PROD"
    Call DesUnis.Item(1).SaveAsEx(UnvName)
    DesUnis.Item(1).Close
    Call DesApp.Universes.Export("ADM", UnvName, 0)
    DesApp.Quit
    MsgBox "Switched connexion for univers " + "ADM/" + UnvName + " : CX_DATAWARE > CX_BASE_PROD"
Exit Sub
End If
End Sub


bernard timbal :fr: (BOB member since 2003-05-26)

[quote:398ba026c4=“jp.golay”]
Is it possible to change universes if a webi doc have multiples dataproviders with differents universes. Did you tried, is it just the universe order we must keep?
[/quote]

Sorry, the reports I changed were very simple with just 1 data provider each so I’m not sure.


BoB LoblaW :us: (BOB member since 2007-10-23)

Sorry, the reports I changed were very simple with just 1 data provider each so I’m not sure.
[/quote]

you should better considere switching univer’s connexion than dataproviders’s univers


bernard timbal :fr: (BOB member since 2003-05-26)

Ok i did tests with ur corde bernard timbal, and it seems working

thanks for that.

but i have questions about it:

Call DesUnis.OpenFromEnterprise("ADM", UnvName, 0) 

With 0, that is notworking, with False yes

this parameters, “0”, what means it?

and how can we verify if the connection has very changed?

If DesUnis.Item(1).Connection = "CX_BASE_PROD" Then 
    DesUnis.Item(1).Connection = "CX_DATAWARE" 

CX_BASE_PROD and CX_DATAWARE, what are they?

Best Regards

Baris


Benns (BOB member since 2009-05-27)

With 0, that is notworking, with False yes

lock or not the univers (here : not locked)

and how can we verify if the connection has very changed?

importing the univers and check his connexion

CX_BASE_PROD and CX_DATAWARE, what are they?

the connexions names


bernard timbal :fr: (BOB member since 2003-05-26)

About CX_BASE_PROD and CX_DATAWARE:

So ur example allows changing the name of the connection for the universe. this connection will be always “securized”

But if i want to keep my connection but just change is "type of connection, is it the same reasoning?

Actually we can choose our type of connection between:

-securized connection
-personnal connection
-shared connection

is Shared connection allowing another person to open my universe?

In fact, my universe will be copied in a folder on server, then since this folder, it will be exporting on client repository. So i could open universe in my designer, and same thing for the client. For that i have two service developed with VB6.


Benns (BOB member since 2009-05-27)