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.
The following sample code illustrates how to obtain raw values for a metric within a dataset of a Report Services document using Strategy Web SDK 9.3.x-9.4.x.
public class GetRawData {
public static void main(String[] args) {
String SessionID = "";
ViewBean vb = null;
WebObjectsFactory objectFactory = WebObjectsFactory.getInstance();
WebIServerSession serverSession = objectFactory.getIServerSession();
serverSession.setApplicationType(EnumDSSXMLApplicationType.DssXmlApplicationCustomApp);
serverSession.setAuthMode(EnumDSSXMLAuthModes.DssXmlAuthStandard);
serverSession.setProjectName("Strategy Tutorial");
serverSession.setLogin("administrator");
serverSession.setPassword("");
serverSession.setServerName("localhost");
try {
SessionID = serverSession.getSessionID();
System.out.println("Welcome " + serverSession.getLogin());
System.out.println("SessionID: " + SessionID);
String strRWID = "D630C7D543E732C929026589CB87498A";
WebBeanFactory beanfactory = WebBeanFactory.getInstance();
RWBean rwb = (RWBean) beanfactory.newBean("RWBean");
rwb.setSessionInfo(serverSession);
rwb.setObjectID(strRWID);
RWInstance rwi = rwb.getRWInstance();
RWGridGraphSettings settings = rwi.getDefaultGridGraphSettings();
settings.setEnabled(true);
settings.setResultFlags(EnumDSSXMLResultFlags.DssXmlResultGrid |EnumDSSXMLResultFlags.DssXmlResultRawData);
rwi.setAsync(false);
rwb.collectData();
String gridKey = "";
RWDefinition oDef = rwi.getDefinition();
RWUnitDef[] rwUnits = oDef.findUnitsByType(EnumRWUnitTypes.RWUNIT_GRIDGRAPH);
RWUnitDef rwUnit;
for (int i=0;i<rwUnits.length; i++){
rwUnit = rwUnits;
RWGridGraphDef griddef = (RWGridGraphDef)rwUnit;
if (griddef.getName().equalsIgnoreCase("GridGraph19")){gridKey = griddef.getKey();}
}
RWData data = rwi.getData();
List grids = data.findUnits(gridKey);
int iGrid = 0;
int iGridSize = grids.size();
if (iGrid < iGridSize) {vb = (ViewBean) rwb.getDataWebBeans(gridKey).get(iGrid);}
WebViewInstance newVInst = vb.getViewInstance();
WebGridData newGridData = newVInst.getGridData();
WebGridRows newGridRows = newGridData.getWebReportGrid().getGridRows();
WebRow newWebRow = null;
for (int x=0;x < newGridRows.size(); x++){
newWebRow = newGridRows.get(x);
for (int j=0;j < newWebRow.size(); j++){
WebRowValue value=newWebRow.get(j);
value.getRawValue();
System.out.print(value.getRawValue()+ "\n");
}
}
} catch(Exception e){e.printStackTrace();}
}
}