Windchill API's to create the new Representation by using the local PVZ file for an EPMDocument and WTPart
Hello All,
I'm having a secanrio that, the PVZ file of the specific assembly was saved in my local drive, I want to upload that PVZ file to the specific EPMDocument under Representations\annations using the utility (using java program). On top of that we will create Interference Definitiion Detection to that Representation to identify the Interference between the parts.
By using the program I could able to create the representaion i.e., Derived image, but PVZ content upload in not happening that means representation is creating without the PVZ file.
Following is the program that I'm trying . PLease suggest me what I'm missing in the program.
Representation newRep = null;
String localFile = "C:\\Users\\59381047_1.pvz";
File contentFile = new File(localFile);
System.out.println(Dumobj.getName());
try{
DerivedImage newDerImage = DerivedImage.newDerivedImage("default");
//System.out.println ("#######Derived image111 :" + newDerImage );
newDerImage.setRepresentable((Representable)wtDocObject);
newDerImage.setDefaultRepresentation(new Boolean(true));
newDerImage.setDerivationType((DerivationType)DerivationType.PART);
newDerImage.setRepresentationType((RepresentationType)RepresentationType.PRODUCT_VIEW);
//newDerImage.setDerivedFromReference(ObjectReference.newObjectReference((Persistable)wtDocObject));
newDerImage.setDomainRef(DomainAdministeredHelper.getAdminDomainRef((DomainAdministered)wtDocObject));
newDerImage.setDescription("description");
Ownership newOwnership = Ownership.newOwnership(SessionHelper.getPrincipal());
newDerImage.setOwnership(newOwnership);
newDerImage.setDerivedFrom(wtDocObject);
newDerImage.setCADPartName("vvvv");
newRep = (Representation)PersistenceHelper.manager.save ((Representation)newDerImage);
// ContentServerHelper.service.writeContentStream(null, localFile);
newRep = (Representation)newDerImage;
System.out.println("**** Derived image :" + newRep.toString() );
wt.pom.Transaction trx = new wt.pom.Transaction();
java.io.FileInputStream is = new java.io.FileInputStream(contentFile);
trx.start();
ApplicationData newAppData = ApplicationData.newApplicationData(wtDocObject);
newAppData.setFileName( contentFile.getName() );
System.out.println("*** " + newAppData.getFileName() + " " + newAppData.getFileSize());
// newAppData.set
ReferenceFactory rf = new ReferenceFactory();
WTReference wtref = rf.getReference(wtDocObject);
String Obid = rf.getReferenceString(wtref);
newAppData.setRole(ContentRoleType.toContentRoleType("SECONDARY"));
newAppData = wt.content.ContentServerHelper.service.updateContent( newRep, newAppData, (java.io.InputStream) is);
PublishUtils.createThumbnailPropertiesFile(localFile, null);
PublishHelper.storeRepresentation(newAppData, wtDocObject, contentFile, true, true, null, null, true, Obid, null, 0, null);
// newRep = (Representation) ContentServerHelper.service.updateHolderFormat((FormatContentHolder) newRep);
System.out.println("*** New content file uploaded " );
System.out.println("*** " + newAppData.getFileName() + " " + newAppData.getFileSize());
PersistenceHelper.manager.save(newAppData);
newRep = (Representation)PersistenceHelper.manager.save ((Representation)newRep);
Publisher pub = new Publisher();
boolean result = pub.doPublish(true, true, Obid,PublishUtils.getConfigSpecFor(wtDocObject),true, "name", "description" , Publisher.PART);
// PublishHelper.storeWTPartRepresentation(PublishJob.doPublishJob(.);, wtDocObject, contentFile);
// PublishHelper.storeWTPartRepresentation(paramPublishJob, paramWTPart, paramFile)
System.out.println("********"+result);
trx.commit();
is.close();
}catch(Exception exp){
exp.printStackTrace();

