Skip to main content
1-Visitor
Mar 24, 2015 6:39 AM UTC
Solved

Change Object type using API

Hi Everyone,

I need help in changing Object type using API.

I want to know if any method exists that can change the object type.

Regards

Sudeep

spai-2Answer
1-Visitor
Apr 6, 2015 10:43 AM UTC

Hi Prabhash,

During Migration, there were some parts migrated with wrong type. Hence i needed the API and i found it.

TypeHelper.setType((Persistable)partObj, TypeHelper.getTypeIdentifier("internal_name"));

PersistenceServerHelper.update(partObj);

partObj = (WTPart)PersistenceHelper.manager.refresh(partObj);

7 replies

1-Visitor
Mar 24, 2015 1:45 PM UTC

Sudeep, I have not come across any API , that can be used to do so. Let's wait what others have to say.

Just curious, what is your business case, that you are looking for such an API.

Kindly share, if you find anything related to this.

Translate
spai-21-VisitorAuthorAnswer
1-Visitor
Apr 6, 2015 10:43 AM UTC

Hi Prabhash,

During Migration, there were some parts migrated with wrong type. Hence i needed the API and i found it.

TypeHelper.setType((Persistable)partObj, TypeHelper.getTypeIdentifier("internal_name"));

PersistenceServerHelper.update(partObj);

partObj = (WTPart)PersistenceHelper.manager.refresh(partObj);

Translate
1-Visitor
Jul 16, 2018 8:59 AM UTC

Hi spai,

 

could you please provide me a import statement this two methods TypeHelper.setType(),  TypeHelper.getTypeIdentifier();

It would me more helpful for me.

Translate
10-Marble
Mar 24, 2015 2:09 PM UTC

Do you need an API or is a utility that PTC has acceptable?

If the utility is acceptable, you can refer to this Knowledgebase Article

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS7287&art_lang=en&posno=2&q=change%20object%20type&source=search‌

We've used this pretty successfully, we've also made some slight tweaks to the output SQL to add additional clauses to filter the objects to be changed.

Translate
spai-21-VisitorAuthor
1-Visitor
Apr 6, 2015 10:52 AM UTC

Hi Stephen,

Good to know that there is a utility for this.

But i had to convert only set of parts whose numbers had to be read from a file and also update many custom attributes on conversion.

So i think using a API is a better option. This is the code i used.

TypeHelper.setType((Persistable)partObj, TypeHelper.getTypeIdentifier("internal_name"));

PersistenceServerHelper.update(partObj);

partObj = (WTPart)PersistenceHelper.manager.refresh(partObj);

Translate
10-Marble
Apr 6, 2015 6:43 PM UTC

Glad you found what you were looking for. We did end up customizing the SQL that the tool outputs to allow us to put in a set of object numbers to convert, but we did not need to touch any attributes.

Translate