The example provided in this document is provided “as-is” to the user and assumes that the user:
PREREQUISITES:
For the sample to work, the Strategy Web JAR files must be accessible by the Java Runtime
Environment. The Strategy Web JAR files can be found under:
Note:
More elaborate programs will require additional library files and are out of the scope of this document.
Users may want to access or change the tooltip on a grid in a Report Services Document programmatically. Below is a sample on how this can be done:
package com.Strategy.sdk.standalone;
import com.Strategy.web.beans.FolderBean;
import com.Strategy.web.beans.RWBean;
import com.Strategy.web.beans.WebBeanException;
import com.Strategy.web.beans.WebBeanFactory;
import com.Strategy.web.objects.WebFolder;
import com.Strategy.web.objects.WebFormat;
import com.Strategy.web.objects.WebIServerSession;
import com.Strategy.web.objects.WebObjectSource;
import com.Strategy.web.objects.WebObjectsException;
import com.Strategy.web.objects.WebObjectsFactory;
import com.Strategy.web.objects.rw.EnumRWUnitTypes;
import com.Strategy.web.objects.rw.RWGridGraphDef;
import com.Strategy.web.objects.rw.RWInstance;
import com.Strategy.web.objects.rw.RWUnitDef;
import com.Strategy.webapi.EnumDSSXMLApplicationType;
import com.Strategy.webapi.EnumDSSXMLDocSaveAsFlags;
import com.Strategy.webapi.EnumDSSXMLObjectFlags;
public class run {
private static WebObjectsFactory factory = null;
private static WebIServerSession serverSession = null;
public static void main(String[] args) throws WebObjectsException, IllegalArgumentException, WebBeanException{
if (serverSession == null) {
// create factory object
factory = WebObjectsFactory.getInstance();
serverSession = factory.getIServerSession();
// Set up session properties
serverSession.setServerName("servername"); // Should be replaced with the name of an Intelligence Server
serverSession.setServerPort(0);
serverSession.setProjectName("project"); // Project where the session should be created
serverSession.setLogin("user"); // User ID
serverSession.setPassword("password"); // Password
serverSession.setApplicationType(EnumDSSXMLApplicationType.DssXmlApplicationCustomApp);
}
WebObjectSource wos = factory.getObjectSource();
wos.setFlags(wos.getFlags()|EnumDSSXMLObjectFlags.DssXmlObjectProperties);
String docID = "docID";
WebBeanFactory factory = WebBeanFactory.getInstance();
RWBean rwb = (RWBean) factory.newBean("RWBean");
rwb.setSessionInfo(serverSession);
rwb.setObjectID(docID);
RWInstance rwi = rwb.getRWInstance();
// Getting parent folder to use when saving later
FolderBean fb = rwb.getParentFolderBean("fb");
WebFolder parentFolder = fb.getFolderObject();
System.out.println("Parent Folder: "+ parentFolder.getName() + "\n");
// Getting Grid and Properties
RWUnitDef[] rwUnits = rwi.getDefinition().findUnitsByType(EnumRWUnitTypes.RWUNIT_GRIDGRAPH);
RWUnitDef rwUnit;
rwUnit = rwUnits[0];
RWGridGraphDef gridDef;
for (int i=0; i<rwUnits.length; i++){
gridDef = (RWGridGraphDef)rwUnit;
WebFormat format=gridDef.getFormat();
System.out.println("Tooltip: " + format.getValue("FormattingAppearance", "TooltipText"));
// Setting new Tooltip value
format.setValue("FormattingAppearance", "TooltipText", "testingggg");
System.out.println("new :" + format.getValue("FormattingAppearance", "TooltipText"));
}
// Apply the changes
RWInstance newInst = rwi.getRWManipulator().applyChanges();
// Get status of the Document
int status = newInst.getStatus();
// Poll the status of the Document until it is ready
while (status!=1){
status = newInst.pollStatus();
}
// Saving the document as a NEW document
// This is recommended in the case the save is interrupted, then the original file is retained.
rwi.setSaveAsFlags(EnumDSSXMLDocSaveAsFlags.DssXmlDocSaveAsOverwrite);
String docNameVersion2 = rwb.getDisplayName() + "2";
newInst.saveAs(parentFolder,docNameVersion2);
}
}