您的位置:首页 > 其它

查询对象的自定义类型WTTypeDefinition

2009-12-12 12:24 453 查看
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import com.ptc.core.meta.type.mgmt.common.TypeDefinitionDefaultView;
import com.ptc.core.meta.type.mgmt.server.impl.WTTypeDefinition;
import wt.clients.prodmgmt.WTPartHelper;
import wt.epm.util.EPMSoftTypeServerUtilities;
import wt.fc.PersistenceHelper;
import wt.part.WTPart;
import wt.type.TypeDefinitionReference;
import wt.type.Typed;
import wt.util.WTException;

/**
*
* @author 云淡天晴
* @version 1.0
* 此例显示了如何获取一个对象的自定义类型
* 在这里我们以部件为例,当然方法有很多种,此方法只是在众多方法中较为简洁。
*
*/

public class TypeDemo implements wt.method.RemoteAccess{

/**
* 获取部件的自定义类型
* @param args
* @throws WTException
* @throws InvocationTargetException
* @throws RemoteException
*/
public static void main(String[] args) throws WTException, RemoteException, InvocationTargetException {
// TODO Auto-generated method stub
WTPart[] part=WTPartHelper.findPartByNumber("0000000021");
System.out.println(part[0]);
WTTypeDefinition definition=geTypeDefinition(part[0]);
System.out.println(definition.getDisplayNameKey());
}

/**
* 获取部件的自定义类型并且返回类型对象
* @param type 此type为WTPart,WTDocument等接口
* @return WTTypeDefinition
* @throws WTException
*/
public static WTTypeDefinition geTypeDefinition(Typed type) throws WTException
{
TypeDefinitionReference ref=type.getTypeDefinitionReference();
TypeDefinitionDefaultView view = EPMSoftTypeServerUtilities.getTypeDefinition(ref);
WTTypeDefinition definition = (WTTypeDefinition) PersistenceHelper.manager.refresh(view.getObjectID());
return definition;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: