Skip to main content
1-Visitor
March 24, 2015
Solved

Change Object type using API

  • March 24, 2015
  • 2 replies
  • 5394 views

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

Best answer by spai-2

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);

2 replies

1-Visitor
March 24, 2015

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.

spai-21-VisitorAuthorAnswer
1-Visitor
April 6, 2015

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);

1-Visitor
July 16, 2018

Hi spai,

 

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

It would me more helpful for me.

10-Marble
March 24, 2015

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.

spai-21-VisitorAuthor
1-Visitor
April 6, 2015

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);

10-Marble
April 6, 2015

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.