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 standalone java class will connect to a Project in Strategy 9.4.1 and create a search object that will return all attributes and metrics.
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.WebSearch;
import com.Strategy.webapi.EnumDSSXMLAuthModes;
import com.Strategy.webapi.EnumDSSXMLObjectTypes;
import com.Strategy.webapi.EnumDSSXMLSearchDomain;
import com.Strategy.webapi.EnumDSSXMLSearchFlags;
public class SearchComponents {
public static void main(String[] args) throws WebObjectsException {
//Create IS session
WebObjectsFactory objectFactory = WebObjectsFactory.getInstance();
//Session parameters
WebIServerSession serverSession = objectFactory.getIServerSession();
serverSession.setServerPort(0);
serverSession.setAuthMode(EnumDSSXMLAuthModes.DssXmlAuthStandard);
serverSession.setProjectName("XXXXXXXX");
serverSession.setLogin("administrator");
serverSession.setPassword("");
serverSession.setServerName("XXXXXXXXXX");
WebObjectsFactory woFact = serverSession.getFactory();
WebObjectSource wos = woFact.getObjectSource();
WebSearch search = wos.getNewSearchObject();
System.out.println("Session created");
//Set search parameters
//Using wildcard * to return all
search.setDisplayName("*");
search.setSearchFlags(search.getSearchFlags()
+ EnumDSSXMLSearchFlags.DssXmlSearchNameWildCard);
search.setAsync(false);
//Set type of objects we want returned, here att and metrics only
search.types().add(new Integer(EnumDSSXMLObjectTypes.DssXmlTypeAttribute));
search.types().add(new Integer(EnumDSSXMLObjectTypes.DssXmlTypeMetric));
search.setDomain(EnumDSSXMLSearchDomain.DssXmlSearchDomainProject);
search.submit();
WebFolder f = search.getResults();
System.out.println("After search: " + f.size());
WebObjectInfo objectInfo = null;
if(f.size()>0){
for(int i=0;i<f.size();i++){
objectInfo = f.get(i);
System.out.println(objectInfo.getDisplayName());
}
}
}//End main
}//end class