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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

How to get all the representations from WTPart

syalagudri
12-Amethyst

How to get all the representations from WTPart

I have a WTPart object handle and I want to get the representations from it. With the following code I am facing an error from code Representation representation = (Representation) reps.nextElement();

Failed. class wt.viewmarkup.DerivedImage cannot be cast to class wt.representation.Representation (wt.viewmarkup.DerivedImage and wt.representation.Representation are in unnamed module of loader 'app')

 

    public ArrayList getDefaultRep(WTPart part) throws ApplicationException {
ArrayList repsList = new ArrayList();
EPMDocument epmDoc = null;
//WTPart part = null;
WTDocument document = null;
Representable representable = null;
ReferenceFactory factory = new ReferenceFactory();
Representation newReturnRepresentation = null;
com.ptc.wvs.common.ui.VisualizationHelper vizHelper = new com.ptc.wvs.common.ui.VisualizationHelper();

try {
representable = vizHelper.findRepresentable(part);
if (representable != null) {
QueryResult reps = vizHelper.getRepresentations(representable);
System.out.println("Representations size: " + reps.size());
while (reps.hasMoreElements()) {
Representation representation = (Representation) reps.nextElement();

System.out.println("Representation Name: " + representation.getName());
System.out.println("Representation InfoPageURL: " + representation.getInfoPageURL());
System.out.println("Representation Type: " + representation.getType());

repsList.add( representation.getName() + ": "+ representation.getInfoPageURL());

// try {
// representation = (Representation) ContentHelper.service.getContents((ContentHolder)representation);
// if (representation != null) {
// Enumeration e = ContentHelper.getApplicationData((ContentHolder)representation).elements();
// while (e.hasMoreElements()) {
// Object app_object = e.nextElement();
// if (app_object instanceof ApplicationData) {
// ApplicationData appData = (ApplicationData) app_object;
// String ol_url = appData.getViewContentURL((ContentHolder)representation).toString();
// System.out.println(" rep ol_url== " + ol_url);
// repsList.add(" rep ol_url== " + ol_url);
// }
// }
// }
// }catch(Exception ex){
// //ex.printStackTrace();
// }
}
}
} catch (Exception e) {
throw new ApplicationException(APPLICATION_ERROR, "getDefaultRep Failed.", e);
}
return repsList;
}

 

Does anyone know the better way to get all the representations

0 REPLIES 0
Top Tags