Windchill常见开发API
持久化管理
-
wt.fc.Persistable接口:所有持续化的对象都实现这个接口。
-
lwt.fc.PersistenceHelper :有一个PersistenceManager属性:manager 。
-
lwt.fc.PersistenceManager接口 :提供一系列的方法,对持续化对象进行操作;如:delete(),find()等。
-
wt.fc .StandardPersistenceManager :实现PersistenceManager接口。
示例
l查询对象示例:
l更新一个对象示例:
说明:QuerySpec定义查询对象;SearchCondition定义查询条件;QueryResult是查询结果
文档相关对象
wt.doc.WTDocument
wt.epm.EPMDocument
wt.doc.WTDocumentMaster
wt.epm.EPMDocumentMaster
创建文档
HashMap<String, String> inputdata = new HashMap<String, String>();
inputdata.put("name", doc_name);
inputdata.put("folderRef", folderRef);
inputdata.put("container", containerRef);
TypeIdentifier typeidentifier = FdnWTContainerHelper.toTypeIdentifier("wt.doc.WTDocument");
WTDocument document = ApplicationIntegrationFactory.createDocument(typeidentifier,inputdata,false,SessionHelper.manager.getLocale(), "html");
ontentHolder ch = (ContentHolder) document;
ApplicationData ap = ApplicationData.newApplicationData(ch);
ap.setRole(ContentRoleType.PRIMARY);
StringfilePath = doc_path;
ap= ContentServerHelper.service.updateContent(ch, ap, filePath);
ap= (ApplicationData) PersistenceHelper.manager.save(ap);
查询文档
QuerySpec querySpec = new QuerySpec(WTDocument.class);
WhereExpression where = new SearchCondition(WTDocument.class,
WTDocument.NAME,SearchCondition.EQUAL,name);
QueryResult result = PersistenceHelper.manager.find((StatementSpec) querySpec);
更新文档
WTDocumentMaster docmaster = (WTDocumentMaster) doc.getMaster();
WTDocumentMasterIdentity docmasteridentity = (WTDocumentMasterIdentity) docmaster
.getIdentificationObject();
docmasteridentity.setName(newDocName);
docmasteridentity.setNumber();
docmaster = (WTDocumentMaster) IdentityHelper.service.changeIdentity(docmaster, docmasteridentity);