package cn.com.origin.autocode.xmlutil;

/** 
 * @copyRight 浙江康勒科技有限公司
 * @author    作者 E-mail:hub@connor.net.cn 
 * @date      创建时间：2017-7-2 下午7:59:01 
 * @version   v1.0 
 * @parameter  
 * @since  
 * @return  
 */

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

import javax.xml.bind.annotation.XmlAttribute;

import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentListOfValuesType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.soa.client.model.LovValue;

public class CNProperty {
	// <prop lovName="" isLov="false" isMust="false"
	// propertyType="string" displayName="名称" realName="object_name"/>
	 String lovName; // lov属性名称
	 Boolean isLov; // 是否是lov
	 Boolean isMust; // 是否必须
	 String propertyType;// 属性类型
	 String displayName;// 显示名称
	 String realName;// 属性真实名称
	 String defaultValue;
	 public List<String> lovValueList;
	 public List<String> lovDisplayValueList;
	 public int selectIndex = -1;
	 public Object value;
	 public TCComponentListOfValues lov;

	public void initProperty() {
		try {
			this.lovValueList = new ArrayList<>();
			this.lovDisplayValueList = new ArrayList<>();
			if (this.isLov) {
				 lov = TCComponentListOfValuesType
						.findLOVByName(lovName);
				if (lov != null) {
					ListOfValuesInfo info = lov.getListOfValues();
					info.getLOVDisplayValues();
					List<LovValue> lovValueList = info.getValues();
					for (LovValue lovV : lovValueList) {
						this.lovDisplayValueList.add(lovV.getDisplayValue());
						this.lovValueList.add(lovV.getStringValue());
					}
				}
			}
		} catch (TCException e) {
			e.printStackTrace();
		}

	}

	public CNProperty() {
	}

	public CNProperty(String realName, String displayName, String propertyType,
			Boolean isMust, Boolean isLov, String lovName) {
		this.realName = realName;
		this.displayName = displayName;
		this.propertyType = propertyType;
		this.isMust = isMust;
		this.isLov = isLov;
		this.lovName = lovName;
	}

	
	
	@XmlAttribute(name = "defaultValue")
	public String getDefaultValue() {
		return defaultValue;
	}

	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}

	@XmlAttribute(name = "lovName")
	public String getLovName() {
		return lovName;
	}

	public void setLovName(String lovName) {
		this.lovName = lovName;
	}

	@XmlAttribute(name = "isLov")
	public Boolean getIsLov() {
		return isLov;
	}

	public void setIsLov(Boolean isLov) {
		this.isLov = isLov;
	}

	@XmlAttribute(name = "isMust")
	public Boolean getIsMust() {
		return isMust;
	}

	public void setIsMust(Boolean isMust) {
		this.isMust = isMust;
	}

	@XmlAttribute(name = "propertyType")
	public String getPropertyType() {
		return propertyType;
	}

	public void setPropertyType(String propertyType) {
		this.propertyType = propertyType;
	}

	@XmlAttribute(name = "displayName")
	public String getDisplayName() {
		return displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	@XmlAttribute(name = "realName")
	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

}