cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Download representation and annotation of a WTDocument in Windchill using java or webject?

Highlighted
Newbie

Download representation and annotation of a WTDocument in Windchill using java or webject?

How can I download representation and annotation of a WTDocument in Windchill using java or a task.xml (webject)?

I need to download these files to create another WTDocument and reference it to the original Document, creating the verification copy.

Thanks in advance

2 REPLIES 2

Re: Download representation and annotation of a WTDocument in Windchill using java or webject?

At firt, your target is 'creating a copy'.

API:wt.enterprise.EnterpriseHelper.service.newCopy((wt.enterprise.RevisionControlled)persistable);

This API dupicate a old Wtoducment and create new one.

The new Wtdocument and old one not only attrbutes , also applicationdata are same.

Re: Download representation and annotation of a WTDocument in Windchill using java or webject?

I can place code to download representation for epmdoc. I am not sure if it's the same for wtdoc


package ext;

import java.io.*;
import java.util.*;
import java.rmi.RemoteException;

import wt.util.*;
import wt.content.*;
import wt.epm.*;
import wt.fc.*;
import wt.query.*;
import wt.content.*;
import wt.representation.*;

import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.httpgw.GatewayAuthenticator;

public class dlRep_main
implements RemoteAccess, Serializable
{
private static void extractContent(EPMDocument EPMDoc, String dlLoc, String conType)
{
try {
Representation defaultRep=RepresentationHelper.service.getDefaultRepresentation(EPMDoc);

if(defaultRep != null)
{
ContentHolder holder=ContentHelper.service.getContents(defaultRep);
Vector contents=ContentHelper.getContentListAll(holder);
ApplicationData data=null;

for (int i=0;i<contents.size();i++)
{
if (contents.get(i) instanceof ApplicationData)
{
data=(ApplicationData)contents.get(i);

if (data!=null && data.getFileName().endsWith(conType))
{
String path = dlLoc+"\\"+data.getFileName();
ContentServerHelper.service.writeContentStream(data, path);
System.out.println("Download Step Executed.\n");
break;
}
}
}
}
}
catch(Exception exception)
{
exception.printStackTrace();
}
}

public static void getEPMDoc(String dlLoc, String drwNo, String conType)
{
try
{
QuerySpec qs = new QuerySpec(EPMDocument.class);
qs.appendWhere(new SearchCondition(EPMDocument.class,EPMDocument.NUMBER,SearchCondition.LIKE, drwNo));
qs.appendAnd();
qs.appendWhere(new SearchCondition(EPMDocument.class, "iterationInfo.latest", "TRUE"));
System.out.println("Now Querying for Doc Using:\n " + qs.toString());

final QueryResult qr = PersistenceHelper.manager.find(qs);

while (qr.hasMoreElements()) {
EPMDocument epmm = (EPMDocument)qr.nextElement();

if (epmm.getNumber().endsWith(".DRW")) {
System.out.println( "\nEPMDoc - Number: " + epmm.getNumber() + " - Name: " + epmm.getName()+ " - CadName: " + epmm.getCADName() );
System.out.println( "Version: " + epmm.getVersionIdentifier().getValue() + " - Iteration:"+epmm.getIterationIdentifier().getValue()+" - Life Cycle State: "+epmm.getLifeCycleState().toString());
extractContent(epmm, dlLoc, conType);
}
}
}
catch(Exception exception)
{
exception.printStackTrace();
}
}

public static void main(String args[])
{
if(args.length < 2)
{
System.out.println("Usage: windchill dlRep_Main <path-where-file-should be saved> <number search string> <content type>");
System.exit(0);
} else
{
try
{
RemoteMethodServer rms = RemoteMethodServer.getDefault();
GatewayAuthenticator auth = new GatewayAuthenticator();
auth.setRemoteUser("wcadmin");
rms.setAuthenticator(auth);

String dlLoc = args[0];
String drwNo = args[1];
String conType = args[2];

Class aclass[] = new Class[3];
aclass[0] = java.lang.String.class;
aclass[1] = java.lang.String.class;
aclass[2] = java.lang.String.class;

Object aobj[] = { dlLoc, drwNo, conType };

rms.invoke("getEPMDoc", "ext.dlRep_main", null, aclass, aobj);
System.exit(0);
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}
}