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.
In Strategy, shortcut objects represent links to other objects such as reports, documents, or filters for example. These shortcut objects simplify navigation by providing quick links to objects that may otherwise be deeply embedded in the folder structure.
Using the Strategy Java Web SDK 9.4.x, it is possible to programatically create these shortcut objects. To accomplish this, implement the following code:
package customclasses.misc;
import com.Strategy.web.objects.WebFolder;
import com.Strategy.web.objects.WebIServerSession;
import com.Strategy.web.objects.WebObjectInfo;
import com.Strategy.web.objects.WebObjectSource;
import com.Strategy.web.objects.WebObjectsException;
import com.Strategy.web.objects.WebObjectsFactory;
import com.Strategy.web.objects.WebShortcut;
import com.Strategy.webapi.EnumDSSXMLApplicationType;
import com.Strategy.webapi.EnumDSSXMLAuthModes;
import com.Strategy.webapi.EnumDSSXMLObjectTypes;
/**
*
*
* This example shows how to programmatically create a shortcut that points to a report.
*
*
*/
public class CreateWebShortcut {
public static void main(String[] args) {
String SessionID = "";
//Create factory object.
WebObjectsFactory factory = WebObjectsFactory.getInstance();
WebIServerSession serverSession = factory.getIServerSession();
serverSession.setServerName("ISERVERNAME");
serverSession.setServerPort(0);
serverSession.setProjectName("PROJECTNAME");
serverSession.setLogin("administrator");
serverSession.setPassword("");
serverSession.setApplicationType(EnumDSSXMLApplicationType.DssXmlApplicationCustomApp);
serverSession.setAuthMode(EnumDSSXMLAuthModes.DssXmlAuthStandard);
try {
SessionID = serverSession.getSessionID();
System.out.println("Welcome " + serverSession.getLogin());
System.out.println("SessionID: " + SessionID);
//Object IDs for both the report and
String strReportID = "E638377511D5C49EC0000C881FDA1A4F";
String strParentFolderID = "8D67909211D3E4981000E787EC6DE8A4";
//Initialize the WebObjectSource Object and get target report (this could also be document) and parent folder where shortcut will reside
WebObjectSource wos = factory.getObjectSource();
WebObjectInfo oReportInfo = wos.getObject(strReportID, EnumDSSXMLObjectTypes.DssXmlTypeReportDefinition);
WebFolder oParentFolder = (WebFolder) wos.getObject(strParentFolderID, EnumDSSXMLObjectTypes.DssXmlTypeFolder);
//Create a new shortcut object and set its target to the report object
WebShortcut oShortcut = (WebShortcut) wos.getNewObject(EnumDSSXMLObjectTypes.DssXmlTypeShortcut);
oShortcut.setTarget(oReportInfo);
//save the object back to the MD, specifying the parent folder as the 'My Reports' folder
wos.save(oShortcut, oParentFolder);
//clean up and close the session
System.out.println("Closing session");
serverSession.closeSession();
} catch (WebObjectsException ex) {
ex.printStackTrace();
}
}
}