package cn.net.connor.std.processedit.newmeop;

import java.util.HashMap;
import java.util.Map;

import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;

import cn.net.connor.std.aifrcp.util.KUtil;
import cn.net.connor.std.aifrcp.util.PropLocation;

public class MeopNoRow {
	
	private TCComponentBOMLine bomline;

	public MeopNoRow(TCComponentBOMLine cLine) {
		this.bomline = cLine;
	}


	public Object[] getRowData(String[] tableProps) throws Exception{
		int len = KUtil.getLen(tableProps);
		Object[] data = new Object[len];
		Map<String, TCComponent> markedComponents = new HashMap<String, TCComponent>();
		PropLocation.initLocationMap(markedComponents , bomline);
		for(int i=0; i<len; i++) {
			String[] config = tableProps[i].split("\\.");
			if(KUtil.getLen(config)!=2) {
				data[i] = tableProps[i];
				continue;
			}
			String propLoc = config[0].toUpperCase();
			if(markedComponents.containsKey(propLoc)) {
				data[i] = markedComponents.get(propLoc).getProperty(config[1]);
			}else {
				data[i] = tableProps[i];
			}
		}
		return data;
	}
}
