How to get IBA values in a HashMap in Windchill

Answered

How to get IBA values in a HashMap in Windchill

Add Comment
1 Answer(s)
Best answer
<pre>public static HashMap getIBAValueMap(IBAHolder ibaHolder) throws Exception { 
        HashMap ibaValueMap = new HashMap();
        ibaHolder = IBAValueHelper.service.refreshAttributeContainer(ibaHolder, null, WTContext.getContext().getLocale(), null);
        //Logger logger = LogR.getLogger(Util.class.getName());

<a href="http://logger.info/">logger.info</a>("Testing message");

DefaultAttributeContainer defaultattributecontainer = (DefaultAttributeContainer) ibaHolder.getAttributeContainer();        
        if (defaultattributecontainer != null){
            AbstractValueView aabstractvalueview[] = defaultattributecontainer.getAttributeValues();
            for (int i = 0; i &lt; aabstractvalueview.length; i++) {
                String name = aabstractvalueview[i].getDefinition().getName();
                String value = null;
                if(aabstractvalueview[i] instanceof URLValueDefaultView) {
                   URLValueDefaultView urlv = (URLValueDefaultView) aabstractvalueview[i];
                   value = "<a href="http://www.ezcollab.com/%22%22">" + urlv.getDescription() + "</a>";
                }
                else {
                    value = IBAValueUtility.getLocalizedIBAValueDisplayString(aabstractvalueview[i], WTContext.getContext().getLocale());
                }

Object eValue = (Object) ibaValueMap.get(name);
                if(eValue == null){
                    ibaValueMap.put(name, value);
                } else {
                    ArrayList al = new ArrayList();
                    if(eValue instanceof ArrayList){
                        al = (ArrayList)eValue;
                        al.add(value);
                    } else {
                        al.add(eValue);
                        al.add(value);
                    }     
                    ibaValueMap.put(name, al);
                }
            }           
        }
        return ibaValueMap;
    }</pre>
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.