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

How to turn an identifier ie wt.epm.EPMDocument:42864420 into an EPMDocument object?

Level 12

How to turn an identifier ie wt.epm.EPMDocument:42864420 into an EPMDocument object?

I am working on a jsp page that asks the user to select some specific EPMDocument
versions in a form. When submitted the form is returning the identifiers of the
object(s) selected. The identifiers are what you get from:
PersistenceHelper.getObjectIdentifier(epmDoc)

The jsp page is outputting the form checkbox as follows:
out.println("\t\t<td><input type="checkbox" name="checkbox" value="\"" +=" persistencehelper.getobjectidentifier(epmdoc)=" +=" &quot;\&quot;="></input></td>");

So upon submission I have an array of string values like this:
"wt.epm.EPMDocument:42864420", "wt.epm.EPMDocument:43075131", etc

So how do I turn take this string value and turn it into an EPMDocument object?

String epmID = "wt.epm.EPMDocument:42864420";

EPMDocument epmDoc = ?????(epmID);


Thanks
--
4 REPLIES 4

How to turn an identifier ie wt.epm.EPMDocument:42864420 into an EPMDocument object?

Hi Randy,
Try the following code and see if it works.

import wt.fc.*;
import wt.epm.*;

reference="OR:wt.epm.EPMDocument:42864420";
ReferenceFactory factory = new ReferenceFactory();
Persistable persistable = factory.getReference(reference).getObject();
if(persistable!=null && persistable instanceof EPMDocument) {
EPMDocument doc = (EPMDocument)persistable;
System.out.println("EPMDocument Name :"+doc.getName());
}


Regards,
Prathap <">http://goo.gl/LuT5>



RE: How to turn an identifier ie wt.epm.EPMDocument:42864420 into an EPMDocument object?

Really all you need to do is


ReferenceFactory ref = new ReferenceFactory();

EPMDocument epdmDoc = ( EPMDocument )ref.getReference( epmID ).getObject;

How to turn an identifier ie wt.epm.EPMDocument:42864420 into an EPMDocument object?

This also works:

Persistable obj = BasicWebjectDelegate.getObjectByUfid(obid);

Then the persistable obj can be cast to its corresponding windchill object type:

EPMDocument epm = null;
If(obj instanceof EPMDocument) {
epm = (EPMDocument) obj;
}

-Thomas R. Busch
Sr. Software Developer
Stryker Corporation
(269) 389 - 4014
tom.busch@stryker.com<">mailto:tom.busch@stryker.com>

RE: How to turn an identifier ie wt.epm.EPMDocument:42864420 into an EPMDocument object? (Summary)


This is a summary of the responses to my question. Some of these were sent to the list and some were sent only to me.
Original question:


I am working on a jsp page that asks the user to select some specific EPMDocument
versions in a form. When submitted the form is returning the identifiers of the
object(s) selected. The identifiers are what you get from:
PersistenceHelper.getObjectIdentifier(epmDoc)

The jsp page is outputting the form checkbox as follows:
out.println("\t\t<td><input type="checkbox" name="checkbox" value="" +=" persistencehelper.getobjectidentifier(epmdoc)=" +=" &quot;&quot;="></input></td>");

So upon submission I have an array of string values like this:
"wt.epm.EPMDocument:42864420", "wt.epm.EPMDocument:43075131", etc

So how do I turn take this string value and turn it into an EPMDocument object?

String epmID = "wt.epm.EPMDocument:42864420";

EPMDocument epmDoc = ?????(epmID);



Basically there were 3 approaches given to turn the string identifier back into an EPMDocument.


Given we have this:


String epmID = "wt.epm.EPMDocument:42864420";


===================================================================


1st approach is using the ReferenceFactory like this:


ReferenceFactory rf = new ReferenceFactory();


EPMDocument epmDoc = (EPMDocument)rf.getReference(epmID).getObject();


===================================================================


2nd approach is ObjectIdentifer and ObjectReference like this:


ObjectIdentifier oid = ObjectIdentifier.newObjectIdentifier(epmID);


EPMDocument epmDoc = (EPMDocument) wt.fc.ObjectReference.newObjectReference(oid).getObject();


===================================================================


3rd approach is to use BasicWebjectDelegate:


EPMDocument epmDoc = (EPMDocument) wt.adapter.BasicWebjectDelegate.getObjectByUfid(epmID);


===================================================================


I haven't yet decided which approach to use yet. I have tried all 3 and they work.


I want to thank all of you that responded. Per usual the users on this list are a fantastic resource.