Windchill 对象在持久化后若需要再修改创建者及修改者,采用以下方法:
修改创建者:
public static void setCreator(Iterated obj, WTPrincipalReference uref) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
RemoteMethodServer.getDefault().invoke("setCreator", AutoChangeHelper.class.getName(), null,
new Class[]{Iterated.class, WTPrincipalReference.class}, new Object[]{obj, uref});
} else {
try {
Class[] pp = new Class[]{WTPrincipalReference.class};
Method setCreator = _IterationInfo.class.getDeclaredMethod("setCreator", pp);
setCreator.setAccessible(true);
setCreator.invoke(obj.getIterationInfo(), new Object[]{uref});
PersistenceServerHelper.manager.update(obj);
} catch (Exception e) {
throw e;
}
}
}
修改修改者:
public static void setCreator(Iterated obj, WTPrincipalReference uref) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
RemoteMethodServer.getDefault().invoke("setCreator", AutoChangeHelper.class.getName(), null,
new Class[]{Iterated.class, WTPrincipalReference.class}, new Object[]{obj, uref});
} else {
try {
Class[] pp = new Class[]{WTPrincipalReference.class};
Method setCreator = _IterationInfo.class.getDeclaredMethod("setCreator", pp);
setCreator.setAccessible(true);
setCreator.invoke(obj.getIterationInfo(), new Object[]{uref});
PersistenceServerHelper.manager.update(obj);
} catch (Exception e) {
throw e;
}
}
}