If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Automating New Secured Custom View in Transformer 8.x

Started by socalsrk, 16 Jul 2010 05:52:35 AM

Previous topic - Next topic

socalsrk

Has anyone automatically created custom views and applied a new security object via SDK or MDL in Transformer 8.x? I have models where a new drilldown item is added in the database and I want to create a new custom view and apex for it within the model. At the same time I need to assign a NEW security group to the custom view.

I'm able to apply security groups that already exist in the model, but I am having trouble trying to bring new security objects in from the Content Store.

In Transformer 7.x, I wasn't able to add the new UserClass via SDK, but I was able to use MDL to just add the new UserClasses to the model. When I opened the model via SDK, the new UserClass was then available.

ex. "UserClassAdd <USERCLASSNAME>"

In Transformer 8.x, the MDL seems a little more complicated. It requires more information. I do have the name and the expected CN, but I'm not sure what I'm doing wrong.

I'm new to Cognos Development so any help would be greatly appreciated. Also, let me know if I'm not making sense or using wrong terminology.

Thanks in advance

nybble

A number of people have asked for an example of how to use the SDK to apply security in Transformer 8.
This code is in VB.NET. You can download Express editions from Microsoft for free.

Sub SecurityExample()
    Dim objTransApp As Object
    Dim model As Model
    Dim nspace As TransformerSDKLib.Namespace
    Dim objectCAMID As String
    Dim customView As CustomView
    Dim secObj As SecurityObject

    objTransApp = CreateObject("IBMCognosTransformer.ApplicationCtrl.1")

    model = objTransApp.OpenModel("MyModel.mdl")
    If model Is Nothing Then
        Throw New System.Exception("Failed to open the model.")
    End If

    'Populate the model
    Dim dataSource As TransformerSDKLib.DataSource
    dataSource = model.DataSources.Item("MySource")
    dataSource.GenerateCategories = True
    model.GenerateCategories()

    'Log onto the server
    Dim err As xtrCommError
    err = objTransApp.Logon("MyNamespaceID", "user", "password")
    If err <> 0 Then
        Throw New System.Exception("Failed to log on: " & err)
    End If

    'Create the Namespace object for the authentication provider
    nspace = model.Namespaces.Add()
    With nspace
        .ID = "MyNamespaceID" 'Specify the authentication provider ID
        .Update()
    End With

    'Now you would loop here for all users/groups/roles to be secured

    'Look up the CAMID; look at the docs to get the right properties for
    'users versus groups/roles
    With nspace
        .ObjectName = "MyRole"
        .Update()
        objectCAMID = .ObjectCAMID
    End With

    'Create a custom view
    customView = model.CustomViews.Add()
    With customView
        .Name = "MyView"
        'Set the dimension to be customized
        Dim myDim As Dimension = model.Dimensions.Item("MyDim")
        .DimensionInclude(myDim) = xtrViewType.trViewTypeCustom
        .Update()
        'Find the category to apex
        Dim category As Category
        category = myDim.FindCategoryByCatCode("MyCategory")
        'Fetch the dimension view
        Dim view As TransformerSDKLib.View
        view = .DimensionView(myDim)
        'Apex on the category
        view.Apex = category
        view.Update()
    End With

    'Create a security object
    secObj = nspace.SecurityObjects.Add()
    With secObj
        .Name = objectCAMID
        .DisplayName = "MyRole"
        .Type = xtrSecurityType.trSecurityType_Role 'type could be extracted from the CAMID if necessary
        'Attach the security object to the custom view
        .AddToCustomView(customView)
        .Update()
    End With

    'Attach the custom view to the cube
    Dim cube As TransformerSDKLib.Cube
    cube = model.Cubes.Item("MyCube")
    cube.CubeCustomViews.Add(customView)
    cube.Update()

    With model
        .SaveAs("MyModel.mdl")
        .Close()
    End With

    objTransApp.Logoff()
    objTransApp = Nothing
End Sub