private static WTDocument createDocument(Persistable persistable, String directory, String filesname, String partnumber) throws WTException, PropertyVetoException, IOException {
boolean flag = false;
WTPart part = (WTPart) persistable;
WTDocument document = getDocument(partnumber, part.getVersionIdentifier().getValue(), "1");
if (document == null) {
document = WTDocument.newWTDocument();
//int j = IXBVersionHelper.getVersionIndex(part.getVersionIdentifier().getValue());
Hashtable table = new Hashtable();
table.put("name", part.getName() + "´òÓ¡Îĵµ");
table.put("number", partnumber);
table.put("type", "Document");
table.put("version", part.getVersionIdentifier().getValue());
table.put("iteration", "1");
table.put("title", part.getName() + "´òÓ¡Îĵµ");
table.put("department", "DESIGN");
table.put("lifecycletemplate", "Default");
table.put("lifecyclestate", "RELEASED");
//table.put("domain","/Administrator");
String partPath = part.getFolderPath();
partPath = partPath.substring(0,partPath.lastIndexOf("/"));
table.put("saveIn", partPath);
Hashtable table1 = new Hashtable();
Vector vector = new Vector();
document = createDocumentObject(table, table1, vector, true);
//document = (WTDocument) VersionControlHelper.service.newVersion(document, VersionIdentifier.newVersionIdentifier(IXBVersionHelper.getVersionSeries(j)), IterationIdentifier.newIterationIdentifier("1"));
document = (WTDocument) PersistenceHelper.manager.save(document);
}
ApplicationData appData = ApplicationData.newApplicationData(document);
//System.out.println("filesname---------"+filesname);
appData.setFileName(filesname);
FileInputStream in = new FileInputStream(directory + "/" + filesname);
appData.setRole(ContentRoleType.PRIMARY);
appData = ContentServerHelper.service.updateContent(document, appData, directory + "/" + filesname);
return document;
} |