package cn.com.origin.autocode.newitem.generatcode;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCClassificationService;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.ics.ICSAdminAttribute;
import com.teamcenter.rac.kernel.ics.ICSAdminClass;
import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute;
import com.teamcenter.rac.kernel.ics.ICSApplicationObject;
import com.teamcenter.rac.kernel.ics.ICSKeyLov;
import com.teamcenter.rac.kernel.ics.ICSProperty;
import com.teamcenter.rac.kernel.ics.ICSAdminHierarchyObject.InterfaceICSAttribute;

public class CNClassPropBean {
	//ICSFormate
	public int propID;
	public String propDisName;
	public String relValue;
	public String displayValue;
	
	public int attrType;
	public boolean isLov;
	public HashMap<String, String> lovMapping;
	public List<String> keyList ;
	public ICSAdminClassAttribute icsAttr;
	public int intsize = 0;
	public int floatsize = 0;
	public String formate;
	
	
	
	public CNClassPropBean(ICSAdminClassAttribute icsAttr){
		// System.out.println("attr id :"+icsAttr.getAttributeId()+" attr naem :"+icsAttr.getName());
		this.icsAttr = icsAttr;
		this.propID = icsAttr.getAttributeId();
		this.propDisName = icsAttr.getName();
		this.formate = icsAttr.getFormat2().getDisplayString();
		if( icsAttr.getFormat1().isReal()){
			floatsize = icsAttr.getFormat2().getFlagB();
			intsize = icsAttr.getFormat2().getFlagC();
		}
		
		this.attrType = icsAttr.getFormat1().getType();
		ICSKeyLov lov1 = icsAttr.getFormat1().getKeyLov();
		lov1 = (lov1 ==null?icsAttr.getFormat2().getKeyLov():lov1);
		lovMapping = new HashMap<>();
		keyList = new ArrayList<>();
		if(lov1!=null){
			this.isLov = true;
			String[] keys = lov1.getKeys();
			for(String key: keys){
				String value = lov1.getValueOfKey(key);
				lovMapping.put( value,key);
				keyList.add(value);
			}
		}else{
			this.isLov = false;
		}
	}
	
	@Override
	public String toString() {
		return  propDisName +":";
	}
	
	 
	
	

}
