Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hello ,
I want to display some data regarding Version History of document (WINDCHILL 11)
version , file name , state , comments ,modified by and last modified
Solved! Go to Solution.
Hi @AB_9905442
btw the VersionControlHelper contains an other method that returns all iterations. allIterationsFrom
try
{
WTDocument document = getDocumentByNumber("0000000142");
QueryResult allVersions = VersionControlHelper.service.allIterationsFrom(document);
while (allVersions.hasMoreElements())
{
Object obj = allVersions.nextElement();
if (obj instanceof RevisionControlled)
{
RevisionControlled iterationObject = (RevisionControlled) obj;
System.out.printf("numer> %s - name> %s - version> %s %n", iterationObject.getDisplayIdentifier(), iterationObject.getName(), iterationObject.getIterationDisplayIdentifier());
}
}
} catch (QueryException e)
{
e.printStackTrace();
} catch (WTException e)
{
e.printStackTrace();
}
PetrH
Hi @AB_9905442
You can try this method that returns all versions so the history is based on all version.
Information can be collected from each object that is returned in a query...
QueryResult allVersions = VersionControlHelper.service.allVersionsOf(document);
while (allVersions.hasMoreElements())
{
Object obj = allVersions.nextElement();
if (obj instanceof RevisionControlled)
{
RevisionControlled iterationObject = (RevisionControlled) obj;
}
}
then you can use following methods to get some info..
iterationObject.getCreateTimestamp();
iterationObject.getCreator();
iterationObject.getModifier();
iterationObject.getVersionDisplayIdentifier();
the document variable can be Mater object or any Versioned one.
example
WTDocument or WTDocumentMaster
EPMDocument or EPMDocumentMaster
PetrH
Hello ,
Thank you for the methode , but it display only 2 iteration
this is our example
Have you used they Query Builder before? You could create a query to display this information
Some info to help you get started: https://www.ptc.com/en/support/wnc-reporting-landing/wnc-reporting-landing-main/querybuilder-intro/qb-intro?overlay=BDDBFF62-6C2F-436C-A38B-BF1BDD6B3F23&source=search
Programmatically as in an external program making REST OData API calls? Or an external program making REST calls for QB data? Or a program integrated in the WC server?
Hi @AB_9905442
And is it wrong? why? you didn't provide real data if there are just versions A.1 and B.1 the result is correct.
PetrH
this is our example
Hi @AB_9905442
Obviously the method returns just latest versions of all revisions.
So you can use another method as a query definition
WTArrayList retValue = new WTArrayList();
QuerySpec queryspec;
try
{
if (revObj instanceof WTDocument)
{
queryspec = new QuerySpec();
int idWTDocObject = queryspec.appendClassList(WTDocument.class, true);
//podmínka vyhledávání
CompositeWhereExpression andCondition = new CompositeWhereExpression(LogicalOperator.AND);
andCondition.append(new SearchCondition(WTDocument.class, WTDocument.NUMBER, SearchCondition.LIKE, ((WTDocument) revObj).getNumber()), new int[]{idWTDocObject});
queryspec.appendWhere(andCondition, new int[]{idWTDocObject, idWTDocObject});
queryspec.appendOrderBy(new OrderBy(new ClassAttribute(WTDocument.class, WTDocument.MODIFY_TIMESTAMP), false), new int[]{0});
QueryResult qResult= PersistenceHelper.manager.find((StatementSpec) queryspec);
retValue.addAll(qResult);
}
} catch (WTException e)
{
e.printStackTrace();
}
PetrH
@HelesicPetr Thank you for the methode , its display all the documents
from this can i get version , file name , state , comments ,modified by and last modified as the picture ?
Yes, go one by one result document version and get all the information what you need.
PetrH
Hi @AB_9905442
btw the VersionControlHelper contains an other method that returns all iterations. allIterationsFrom
try
{
WTDocument document = getDocumentByNumber("0000000142");
QueryResult allVersions = VersionControlHelper.service.allIterationsFrom(document);
while (allVersions.hasMoreElements())
{
Object obj = allVersions.nextElement();
if (obj instanceof RevisionControlled)
{
RevisionControlled iterationObject = (RevisionControlled) obj;
System.out.printf("numer> %s - name> %s - version> %s %n", iterationObject.getDisplayIdentifier(), iterationObject.getName(), iterationObject.getIterationDisplayIdentifier());
}
}
} catch (QueryException e)
{
e.printStackTrace();
} catch (WTException e)
{
e.printStackTrace();
}
PetrH
I implemented this methode it's ok but the first iteration not exist ( A1)
WTDocument refreshedDoc = (WTDocument) PersistenceHelper.manager.refresh(document);
// Get the version history
QueryResult versionHistory = VersionControlHelper.service.allIterationsOf(refreshedDoc.getMaster());
// Display the version history information
int i=1;
while (versionHistory.hasMoreElements()) {
String iteration="";
String version="";
String fileName="";
String state="";
String coments="";
String modifyBy="";
String lastModified="";
Object versioned = versionHistory.nextElement();
if (versioned instanceof Iterated) {
Iterated iterated = (Iterated) versioned;
iteration = getVersion(iterated);
IterationInfo iterationInfo = iterated.getIterationInfo();
coments=iterationInfo.getNote();
modifyBy= iterationInfo.getModifier().getFullName();
// taskLogger.debug("iteration: " + iteration);
// taskLogger.debug("getModifierName: " + iterated.getModifierName());
modifyBy=iterated.getModifierName();
lastModified=iterated.getCreatorName();
if (iterated instanceof LifeCycleManaged) {
LifeCycleManaged lifeCycleManaged = (LifeCycleManaged) iterated;
state= lifeCycleManaged.getLifeCycleState().toString();
//taskLogger.debug("state: " + state);
}
if (iterated instanceof WTDocument) {
WTDocument doc = (WTDocument) iterated;
//taskLogger.debug("doc: " + doc.getNumber());
ContentHolder holder= ContentHelper.service.getContents(doc);
ContentItem ci = ContentHelper.getPrimary((FormatContentHolder) holder);
ApplicationData ad = (ApplicationData) ci;
fileName = ad.getFileName();
//taskLogger.debug(doc.getIterationInfo().getIdentifier().getValue());
// taskLogger.debug(doc.getVersionInfo().getIdentifier().getValue());
version=doc.getVersionInfo().getIdentifier().getValue();
}
}
taskLogger.debug("----------------------"+i+"---------------------------------");
taskLogger.debug(version+iteration+"---"+fileName+"---"+state+"---"+coments+"---"+modifyBy+"---"+lastModified);
i++;
}
how can i display also A1 iteration