WC 10.1 Retrieving values from a multi-valued IBA?
‎Apr 23, 2013
06:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
‎Apr 23, 2013
06:42 PM
WC 10.1 Retrieving values from a multi-valued IBA?
I'm trying to grab the value from some IBAs using the newcom.ptc.core.lwc.server.LWCNormalizedObjectclass.
For values that are single valued, i'm having no problems, but when i have mult-valued IBAs I'm stuck. The get method says it's supported, but for the life of me I can't figure out how to access them. It sounds like an array of Objects will be returned.
If anybody has used this class for retrieving a multi-valued IBA and would share the code snippet, I would appreciate it.
getpublic Object get(Stringattribute)
throws WTException<dd>
Supported API: true
Returns the value(s) of the attribute with the given name from the object. If the attribute is multi-valued, an Object[] will be returned. Throws an exception if the attribute has not been previously loaded into the object.</dd>
Labels:
- Labels:
-
Other
2 REPLIES 2
‎Apr 23, 2013
07:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
‎Apr 23, 2013
07:21 PM
Steve,
Here's a snippet that works and may get what you need:
LWCNormalizedObject lno = new LWCNormalizedObject(pdpPart, null, null, null);
lno.load(designFunc);
Object designFuncValue = lno.get(designFunc);
if (designFuncValue instanceof Object[]) {
logger.debug(CLASSNAME + ".getSupplementalRoles(): instanceof Object[]");
Object[] designFuncValues = (Object[])designFuncValue;
for (int i = 0; i < designFuncValues.length; i++) {
if (((String)designFuncValues[i]).equals(mech)) {
roles.add(Role.toRole(mechRole));
} else if (((String)designFuncValues[i]).equals(elec)) {
roles.add(Role.toRole(elecRole));
} else if (((String)designFuncValues[i]).equals(opt)) {
roles.add(Role.toRole(optRole));
} else if (((String)designFuncValues[i]).equals(sw)) {
roles.add(Role.toRole(swRole));
}
}
} else {
logger.debug(CLASSNAME + ".getSupplementalRoles(): not instanceof Object[]");
if (((String)designFuncValue).equals(mech)) {
roles.add(Role.toRole(mechRole));
} else if (((String)designFuncValue).equals(elec)) {
roles.add(Role.toRole(elecRole));
} else if (((String)designFuncValue).equals(opt)) {
roles.add(Role.toRole(optRole));
} else if (((String)designFuncValue).equals(sw)) {
roles.add(Role.toRole(swRole));
}
}
Thanks,
Jason Schrader
Here's a snippet that works and may get what you need:
LWCNormalizedObject lno = new LWCNormalizedObject(pdpPart, null, null, null);
lno.load(designFunc);
Object designFuncValue = lno.get(designFunc);
if (designFuncValue instanceof Object[]) {
logger.debug(CLASSNAME + ".getSupplementalRoles(): instanceof Object[]");
Object[] designFuncValues = (Object[])designFuncValue;
for (int i = 0; i < designFuncValues.length; i++) {
if (((String)designFuncValues[i]).equals(mech)) {
roles.add(Role.toRole(mechRole));
} else if (((String)designFuncValues[i]).equals(elec)) {
roles.add(Role.toRole(elecRole));
} else if (((String)designFuncValues[i]).equals(opt)) {
roles.add(Role.toRole(optRole));
} else if (((String)designFuncValues[i]).equals(sw)) {
roles.add(Role.toRole(swRole));
}
}
} else {
logger.debug(CLASSNAME + ".getSupplementalRoles(): not instanceof Object[]");
if (((String)designFuncValue).equals(mech)) {
roles.add(Role.toRole(mechRole));
} else if (((String)designFuncValue).equals(elec)) {
roles.add(Role.toRole(elecRole));
} else if (((String)designFuncValue).equals(opt)) {
roles.add(Role.toRole(optRole));
} else if (((String)designFuncValue).equals(sw)) {
roles.add(Role.toRole(swRole));
}
}
Thanks,
Jason Schrader
‎Apr 23, 2013
11:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
‎Apr 23, 2013
11:21 PM
Thanks that was just what I needed! I wasn't casting the object to an array of objects correctly.
Steve D.
Steve D.