/* bcwti
 *
 * Copyright (c) 2010 Parametric Technology Corporation (PTC). All Rights Reserved.
 *
 * This software is the confidential and proprietary information of PTC
 * and is subject to the terms of a software license agreement. You shall
 * not disclose such confidential information and shall use it only in accordance
 * with the terms of the license agreement.
 *
 * ecwti
 */
package com.ptc.windchill.esi.examples;

import com.infoengine.object.factory.Att;
import com.infoengine.object.factory.Element;
import com.ptc.windchill.esi.esipart.ESIWTPartRenderer;
import com.ptc.windchill.esi.rnd.ESIRendererException;
import java.util.Collection;
import wt.eff.Eff;
import wt.part.WTPart;


public class Example2MyRenderer extends ESIWTPartRenderer {

  // This example method will adjust the mapper to return a value for the attribute "Team". If the attribute "Team" is found
  // and the value is null or empty, then this method will update the value.

  protected Element adjustPartElement( Element elem, String group, WTPart part, Eff eff, Collection targets )
            throws ESIRendererException {
    Att att = elem.getAtt("Team"); // get the attribute "Team" from the mapper output

    if ( att != null )   // verify that the attribute exists in the mapper.
    {
       // Check to see if the value of "Team" is null or is empty.
       if ( att.getValue() == null || att.getValue().toString().trim().equals(""))
        {
            //	Get the value for "Team" from the part object and use it to set
            //	the value for the "Team" attribute in the mapper output.
            att.setValue(part.getTeamName());
        }
    }

    return elem;
  }
}
