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

Changing document type

Highlighted
Aquamarine

Changing document type

Tech support says no way but I am sure it can be done. I have created a
new soft type both a document and a part. There are no workflows or
additional attributes added for the new soft type so they are identical
in nature to the basic WTPart and WTDocument. All I need to do is, for a
few specific objects, change their type in the system for all iterations
(there aren't many) to the new soft type. That's all. Has anyone done
this before?

6 REPLIES 6

Changing document type

hi,

try
wt ext.tools.UpdateIBAs -t <new-type-name> obid

hth, martin

Villanueva, Antonio wrote:
>
> Tech support says no way but I am sure it can be done. I have created
> a new soft type both a document and a part. There are no workflows or
> additional attributes added for the new soft type so they are
> identical in nature to the basic WTPart and WTDocument. All I need to
> do is, for a few specific objects, change their type in the system for
> all iterations (there aren’t many) to the new soft type. That’s all.
> Has anyone done this before?
>
>
>
> -----End Original Message-----

RE: Changing document type

I have done this for changeRequest object. U can aswell do it for WTDocument

public Persistable saveCR(wt.change2.WTChangeRequest2 cr) throws WTException
{
Persistable persistable = null;
if(RemoteMethodServer.ServerFlag)
{
TypeIdentifier typeidentifier = TypeHelper.getTypeIdentifier("WCTYPE|wt.change2.WTChangeRequest2|in.co.tafe.DCR");
persistable = CoreMetaUtility.setType((Persistable)cr,typeidentifier);
persistable = (Persistable)wt.fc.PersistenceHelper.manager.save(persistable);
return persistable;
}
Class aclass[];
Object aobj[];
try
{
aclass = (new Class[] {wt.change2.WTChangeRequest2.class});
aobj = (new Object[] {cr});
persistable = (Persistable)RemoteMethodServer.getDefault().invoke("saveCR", null, this, aclass, aobj);
}
catch(Exception ex)
{

}
return persistable;



}

RE: Changing document type

Did you ever find a solution to change the types of existing Parts or Documents?

In Reply to Antonio Villanueva:
Tech support says no way but I am sure it can be done. I have created a
new soft type both a document and a part. There are no workflows or
additional attributes added for the new soft type so they are identical
in nature to the basic WTPart and WTDocument. All I need to do is, for a
few specific objects, change their type in the system for all iterations
(there aren't many) to the new soft type. That's all. Has anyone done
this before?

Changing document type

You can use SQL to update the wttypedefiniton instance. It's not supported
which is why they say it can't be done. I had posted a long time ago SQL
that showed how to delete a soft type. It showed the relationships between
everything.







_____

Changing document type

Stephen and Antonio,
I solved this issue by creating a JSP page with Item Picker (using the
JCA architecture) on for users to choose a type (when certain conditions
are met). On the server side, I wrote a Command, and updated the type as
mentioned below. In our case, this page shown similar to a Set State or
Reteam pages.

SQL code would have worked for us too, but it would involve Windchill
team as every time as opposed to the users doing it. Other alternative
is to use the LoadFromFile utility with the required Doc Type in it.
BTW, these two approaches update the type of the last iteration of the
latest version. When the item is revised it uses the new type.

PS: It probably does not hurt to have this kind of functionality OOTB.

Hope this helps.


public class RetypeCommand implements RemoteAccess, Serializable{

private static final long serialVersionUID = 1L;
static final boolean SERVER;
static {
SERVER = RemoteMethodServer.ServerFlag;
}
public static NmChangeModel[] reType(NmCommandBean commandBean)throws
WTException {

//If not running on server, execute remotely
if(!SERVER){
try{
Class aclass[] = {NmCommandBean.class };
Object aobj[] = {commandBean};
return
(NmChangeModel[])RemoteMethodServer.getDefault().invoke("reType",
"ext.xxx.util.commands.RetypeCommand", null, aclass, aobj);
}
catch(Exception ex){
throw new WTException(ex);
}
}
HashMap comboBox = commandBean.getComboBox();
String newType = null;
if (comboBox != null) {
ArrayList list = (ArrayList) comboBox.get("type_picker");
if (list != null){
newType = (String) list.get(0);
}
}
try {
if (newType != null){
//Get the Object
NmOid nmOid = commandBean.getElementOid();
if(nmOid == null){
nmOid = commandBean.getPrimaryOid();
}

Typed typed = (Typed)nmOid.getRefObject();
//Retype.
TypeDefinitionReference typeDefRef =
TypedUtility.getTypeDefinitionReference(newType);
//Checkout if it's not already checked out
boolean isCheckedOut =
WorkInProgressHelper.isCheckedOut((Workable)typed);
if( !isCheckedOut){
typed = (Typed)
WorkInProgressHelper.service.checkout((Workable)typed,
WorkInProgressHelper.service.getCheckoutFolder(), "Setting new Type to:"
+ newType).getWorkingCopy();
}
//Get the original type
String oldType =
wt.type.TypedUtilityServiceHelper.service.getExternalTypeIdentifier(type
d);
//Save the Typed Object.
typed.setTypeDefinitionReference(typeDefRef);
PersistenceHelper.manager.save((Persistable)typed);
//Check in if checked out here
if( !isCheckedOut){


int len = oldType.lastIndexOf("|");
if( len > 0){
oldType = oldType.substring(len+1, oldType.length());
}
WorkInProgressHelper.service.checkin((Workable)typed, "Updated
the type from:" + oldType);
}
}
} catch (WTException ex) {
Throwable throwable = ex.getNestedThrowable();
if (throwable != null) {
String errorMessage = throwable.getMessage();
errorMessage = errorMessage.replaceFirst("wt.util.WTException:",
").trim();
throw new NmException(errorMessage);
} else {
throw ex;
}
}catch (WTPropertyVetoException ex1) {
Throwable throwable = ex1.getNestedThrowable();
if (throwable != null) {
String errorMessage = throwable.getMessage();
errorMessage = errorMessage.replaceFirst("wt.util.WTException:",
").trim();
throw new NmException(errorMessage);
} else {
throw new WTException(ex1);
}
}catch (RemoteException ex2) {
throw new WTException(ex2);
}
return null;
}
}


Raju Pulavarthi
Sr. Systems Analyst
Cardiovascular Division


St. Jude Medical
14901 DeVeau Place
Minnetonka, MN 55435 USA
Tel +1 952 351 1469
Fax +1 952 351 1271
-
sjm.com

RE: Changing document type

Hi Antonio,

We have done this at Psion Teklogix Inc. We made behaviour to "reclassify" the documents. With the help of Sudeep Bhattarai from Najanaja. We have a tool to reset the type based on the Name of the document. We have mappings for wild card strings to types and it resets them to the appropriate type. We could never trust the user creating the documents because it is left up to the users discretion.

"Auto Document Classification"

· Created customizations to reset document type and category based on a generic name

o This does not change the iteration of documents

o This is only performed by site administrators

o A listener added or used in a workflow expression to change the type prior to review

· Certain contexts can be ignored where they store external documents

Thus, global discrete searches are created and shared to the organization can be trusted and used. We found out that the users hate the search index because it gives them everything rather than a discrete result.

In the future, the same will be done but reverse for WTPart. We plan to have the name auto populate based on the "Classification" hierarchy in PartsLink with mappings to abbriviations. Thus, the user doesn't have to enter the title/name to any part and will be derived from the classification.

I've attached a list to show you what we've done at Psion with the help of Sudeep Bhattarai from Najanaja.

Announcements
LiveWorx Call For Papers Happening Now!