Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
As per this thread - same issue
Hi rkumar,
I too have the similar kind of need, where I need to fetch all the bom structure and get the custom attributes values that or on Usage link.
Is there any way if i can get both the Link and wtpart or wtpart master? Let me know
Thanks
Solved! Go to Solution.
Hi @JM_10276355
the ibah is object that represents WTPart or EPMDocument, or other types.
So put there the object for example WTPart.
IBAHolder ibaHolder = IBAValueHelper.service.refreshAttributeContainer((IBAHolder) ibah, null, null, null);
DefaultAttributeContainer dac = (DefaultAttributeContainer) ibaHolder.getAttributeContainer();
StringBuilder values = new StringBuilder(); // it will be filled with values
if (dac != null)
{
AbstractValueView[] abstrAttrib = dac.getAttributeValues();
// search for atribute name
for (int i = 0; i < abstrAttrib .length; i++)
{
AttributeDefDefaultView attrDef = abstrAttrib [i].getDefinition();
String atrName = attrDef.getName();
if (atrName.equals(ibaParam)) // ibaParam is an internal name of attribute
{
values.append(retValue.length() == 0 ? "" : "@");
values.append(getValueView(avv[i]));// if attribute has more values
}
}
}
PetrH
Hi @JM_10276355
you can use something linke following code.
It gives you UsageLink and child WTPart
WTPart wtp = (WTPart) wtpObject; // source Parent from another search function
ConfigSpec localConfigSpec = ConfigHelper.service.getConfigSpecFor(wtp);
QueryResult qr = WTPartHelper.service.getUsesWTParts(wtp, localConfigSpec);
if (qr.size() != 0)
{
while (qr.hasMoreElements())
{
Persistable persistables[] = (Persistable[]) qr.nextElement();
WTPart subpart = null;
if (persistables[1] instanceof WTPart) // second place in array is WTPart
{
subpart = (WTPart) persistables[1];
}
WTPartUsageLink wtpLink = null;
if (persistables[0] instanceof WTPartUsageLink)
{
wtpLink = (WTPartUsageLink) persistables[0]; // first place in array is WTPartUsageLink
}
}
IBA attributes could be get by
IBAHolder ibaHolder = IBAValueHelper.service.refreshAttributeContainer((IBAHolder) ibah, null, null, null);
DefaultAttributeContainer dac = (DefaultAttributeContainer) ibaHolder.getAttributeContainer();
DefaultAttributeContainer dac contains all IBA attributes of the object so you have to search which IBA attribute name you really want.
Hope this can help
PetrH
Hi @HelesicPetr
That was a quick input, thanks !! I also wanted to know how can we get the IBA from the WTPart we fetched from the above code, I mean to say where to pass the WTPart object so that IBA is defined on the WTPart which is to be retrieved.
Thanks
Hi @JM_10276355
the ibah is object that represents WTPart or EPMDocument, or other types.
So put there the object for example WTPart.
IBAHolder ibaHolder = IBAValueHelper.service.refreshAttributeContainer((IBAHolder) ibah, null, null, null);
DefaultAttributeContainer dac = (DefaultAttributeContainer) ibaHolder.getAttributeContainer();
StringBuilder values = new StringBuilder(); // it will be filled with values
if (dac != null)
{
AbstractValueView[] abstrAttrib = dac.getAttributeValues();
// search for atribute name
for (int i = 0; i < abstrAttrib .length; i++)
{
AttributeDefDefaultView attrDef = abstrAttrib [i].getDefinition();
String atrName = attrDef.getName();
if (atrName.equals(ibaParam)) // ibaParam is an internal name of attribute
{
values.append(retValue.length() == 0 ? "" : "@");
values.append(getValueView(avv[i]));// if attribute has more values
}
}
}
PetrH