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

How to set primary classification attribute while creating part

jselvaraj
Regular Member

How to set primary classification attribute while creating part

Hi All,

 

I am trying to create  a WTPart from java. In my set up the classification is set as a mandatory attribute.

 

Could you please help me on how to set  the value of the primary classification? I tried to set the default value for the classfication, however it does not work. Here is the code I am using to create WTPart.

 


   WTPart wtpart=WTPart.newWTPart();
   try {
    /
    TypeIdentifier typeidentifier = TypeHelper.getTypeIdentifier("WCTYPE|wt.part.WTPart");
    WCTypeIdentifier wctypeidentifier = (WCTypeIdentifier) typeidentifier;
    TypeDefinitionReference typeDefinitionReference = TypedUtilityServiceHelper.service.getTypeDefinitionReference(wctypeidentifier.getTypename());
    wtpart.setTypeDefinitionReference(typeDefinitionReference);
  
    wtpart.setName("Test part007");
    String container_path = "/wt.inf.container.OrgContainer=yyyy/wt.pdmlink.PDMLinkProduct=xxxx";
    WTContainerRef containerRef = WTContainerHelper.service .getByPath(container_path);
    wtpart.setContainerReference(containerRef);
    
    String folder_path = "/Default";
    Folder folder = FolderHelper.service .getFolder(folder_path,containerRef);
    FolderHelper. assignLocation(wtpart, folder);
    
    wtpart=(WTPart) wt.fc.PersistenceHelper.manager .store(wtpart);
    
    }

 

 

Thanks in advance.

Tags (2)
3 REPLIES 3

Re: How to set primary classification attribute while creating part

Hi @jselvaraj,

Have you tried "How to set classification node or classification attributes value (available for 10.2 M030 and 11.0)" section of KB article CS217792?

 

WTPart part_work = (WTPart)WorkInProgressHelper.service.checkout(part, WorkInProgressHelper.service.getCheckoutFolder(), null).getWorkingCopy();
PersistableAdapter obj = new PersistableAdapter(part_work,null,SessionHelper.getLocale(), new UpdateOperationIdentifier());
obj.load(bindingAttributeName);
obj.set(bindingAttributeName,classificationNode);
obj.apply();
PersistenceHelper.manager.modify(part_work);
return (WTPart)WorkInProgressHelper.service.checkin(part_work, null);

 

Are you having some trouble doing it?

 

Thanks,

Shirish

Re: How to set primary classification attribute while creating part

I agree to use PersistableAdapter class to set the classification attribute value.

Re: How to set primary classification attribute while creating part

Hi selvaraj,

 

could you please provide me a import statement for  TypeHelper.getTypeIdentifier();

It would me more helpful for me.

Announcements