How to get IBA values in a HashMap in Windchill

Answered

How to get IBA values in a HashMap in Windchill

Alex Trainee Asked on May 15, 2015 in Windchill PDMLink.
Add Comment
1 Answer(s)
Best answer
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());

logger.info("Testing message");

DefaultAttributeContainer defaultattributecontainer = (DefaultAttributeContainer) ibaHolder.getAttributeContainer();        
        if (defaultattributecontainer != null){
            AbstractValueView aabstractvalueview[] = defaultattributecontainer.getAttributeValues();
            for (int i = 0; i < aabstractvalueview.length; i++) {
                String name = aabstractvalueview[i].getDefinition().getName();
                String value = null;
                if(aabstractvalueview[i] instanceof URLValueDefaultView) {
                   URLValueDefaultView urlv = (URLValueDefaultView) aabstractvalueview[i];
                   value = "" + urlv.getDescription() + "";
                }
                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;
    }
guru@windchillguru.com Guru Answered on May 15, 2015.
Add Comment

Your Answer

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