Inputs will be the IT Resource Name and the IT Resource Parameter Name
Define the following:
private tcITResourceDefinitionOperationsIntf itResDefOp=null;
private tcITResourceInstanceOperationsIntf itResInstOp=null;
private long itResourceKey = 0L;
Next, in some module pull the Ops:
itResDefOp=Platform.getService(tcITResourceDefinitionOperationsIntf.class);
itResInstOp=Platform.getService(tcITResourceInstanceOperationsIntf.class);
Define a search and get the itResourceKey
Map searchFor = new HashMap();
searchFor.put("IT Resources.Name", itResourceName);
try {
tcResultSet results =
itResInstOp.findITResourceInstances(searchFor);
if (results.getRowCount() == 1) {
results.goToRow(0);
itResourceKey =
results.getLongValue("IT Resources.Key");
} else {
searchFor.clear();
results =
itResInstOp.findITResourceInstances(searchFor);
for (int i = 0; i < results.getRowCount(); i++) {
results.goToRow(i);
if (results.getStringValue("IT Resources.Name")
.equalsIgnoreCase(itResourceName)) {
itResourceKey =
results.getLongValue("IT Resources.Key");
break;
}
}
}
}
catch (Exception ex) {
;
}
Finally, pull the parameter value:
try {
tcResultSet paramSet= itResInstOp
.getITResourceInstanceParameters(itResourceKey);
int numParams=paramSet.getRowCount();
if (numParams < 1) {
; // Do something here it's not found
}
for (int iparam=0; iparam < numParams; ++iparam) {
paramSet.goToRow(iparam);
String paramName=paramSet
.getStringValue("IT Resources Type Parameter.Name");
if(paramName
.equalsIgnoreCase("WhatYouAreSearchingFor")) {
ResultValue=paramSet
.getStringValue("IT Resource.Parameter.Value");
}
}
}
catch (Exception e) {
;
}
No comments:
Post a Comment