Export Container Templates with code Windchill 12.1
I wanted to know, if there is a way to export Container Templates with code, or a windchill shell command.
I couldn't find anything in the knowledge base, that's why I wanted to ask in a post.
I wanted to know, if there is a way to export Container Templates with code, or a windchill shell command.
I couldn't find anything in the knowledge base, that's why I wanted to ask in a post.
Hi
Templates are clastic objects that have content and the content is XML. The content is an ApplicationData so you can use standard api to search the template and download it.
here is a code that gives you the content URL and download URL
QuerySpec queryspec;
String templateName="Product Design";
try
{
queryspec = new QuerySpec();
int idClassIssue = queryspec.appendClassList(DefaultWTContainerTemplate.class, true);
CompositeWhereExpression andCondition = new CompositeWhereExpression(LogicalOperator.AND);
andCondition.append(new SearchCondition(DefaultWTContainerTemplate.class, DefaultWTContainerTemplate.LATEST_ITERATION, SearchCondition.IS_TRUE), new int[]{idClassIssue});
andCondition.append(new SearchCondition(DefaultWTContainerTemplate.class, DefaultWTContainerTemplate.NAME, SearchCondition.LIKE, templateName), new int[]{idClassIssue});
queryspec.appendWhere(andCondition, new int[]{idClassIssue, idClassIssue});
queryspec.appendOrderBy(new OrderBy(new ClassAttribute(DefaultWTContainerTemplate.class, DefaultWTContainerTemplate.MODIFY_TIMESTAMP), false), new int[]{0});
QueryResult queryresult = PersistenceHelper.manager.find((StatementSpec) queryspec);
while (queryresult.hasMoreElements())
{
Object object = queryresult.nextElement();
if (object instanceof Persistable[])
{
DefaultWTContainerTemplate cam = (DefaultWTContainerTemplate) ((Persistable[])object)[0];
ContentHolder syHold = ContentHelper.service.getContents(cam);
Vector<ApplicationData> vectorOfAppData = ContentHelper.getContentListAll(syHold);
Iterator<ApplicationData> appIter = vectorOfAppData.iterator();
while (appIter.hasNext())
{
ApplicationData syAppData = appIter.next();
ContentHolder holder = ContentHelper.service.getContents(cam);
final URL viewContentURL = WVSContentHelper.getViewContentURL(syAppData, holder);
final URL downloadURL = WVSContentHelper.getDownloadURL(syAppData, holder);
}
}
}
} catch (QueryException e)
{
e.printStackTrace();
} catch (WTException e)
{
e.printStackTrace();
} catch (PropertyVetoException e)
{
throw new RuntimeException(e);
}
PS: how to get inputStream
InputStream stream = ContentServerHelper.service.findContentStream(syAppData);
PetrH
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.