Skip to main content
1-Visitor
September 23, 2010
Question

Set an IBA value to a soft-type into a workflow

  • September 23, 2010
  • 3 replies
  • 9981 views

Hi,


This is my first question, so please apologize if it's not precise enough.

I'm working on a workflow and I'm wondering how can I define an IBA value of a soft type.

I tried to do with an "Expression" robot, but I lack knowledge about programmatically setting an attribute in Java.


Here is the code I used to get an attribute value.

<code>

if (primaryBusinessObject instanceof wt.doc.WTDocument) {
wt.doc.WTDocument doc=(wt.doc.WTDocument)primaryBusinessObject;
wt.iba.definition.litedefinition.StringDefView def;
def= (wt.iba.definition.litedefinition.StringDefView)wt.iba.definition.service.IBADefinitionHelper.service.getAttributeDefDefaultViewByPath("ATTRIBUTE_NAME");
doc = (wt.doc.WTDocument)wt.iba.value.service.IBAValueHelper.service.refreshAttributeContainer(doc, null, null, null);
wt.iba.value.DefaultAttributeContainer dac = (wt.iba.value.DefaultAttributeContainer)doc.getAttributeContainer();
wt.iba.value.litevalue.AbstractValueView[] avv = dac.getAttributeValues(def);
if(avv != null && avv.length == 1) {
wt.iba.value.litevalue.StringValueDefaultView svdv = (wt.iba.value.litevalue.StringValueDefaultView)avv[0];
String atr=svdv.getValue();
if (atr != null && atr.trim().equals("check_value")){
result="Forward";
}
}
}

</code>


I've read Windchill's API JavaDoc, but there is no mention about "getAttributeDefDefaultViewByPath" for example. Si I'm completely lost.


Please help me understand this part.


Thanks in advance !

3 replies

1-Visitor
September 27, 2010

Most simple way for work with IBA attributes using Task ( Update or Change-Identity). If you Interesting I can post sample.

1-Visitor
September 27, 2010

I'm really interested in some sample.

Thank you !

1-Visitor
September 29, 2010

Info*Engine is the PTC supported way to update an object's IBA value.

That said, you can do it fairly easily through the java API with the persistence framework.

Let's say your IBA is of type string, you can use your primary business object's wttypedefinition to query for the iba value object known as a stringvalue.

Then, you can update it. This will work without doing a checkout of the object. If you do want to checkout the object, you can use the work in progress API to handle that requirement.

To handle it the supported way, please look at example in the Windchill Adapter Guide to see the I*E webjects that are used to take care of this: Query-Object, Checkout/Checkin webjects, and Update-Object.

You can invoke an Info*Engine task using java code in your workflow. Examples are floating around out there.

Please reply back if you want more help, though my time is limited right now.

I hope to create a freebie to handle this sort of task in pure Java code very soon.

Dave

1-Visitor
September 29, 2010

Thank you for your explanations : they clarifies all this stuff.

My issue with I*E is that we havent got any licences (we are a small business and won't take I*E until ERP integration in 1-2 years). That's why I'd rather prefer Pure Java, even if it's unsupported by PTC.

I found a .java file that contains code to update attributes, but my point is : how do I "install" it to use it into a workflow (do I have to put it in "codebase", compile it, declare it in site.xconf ?).

I currently am testing everything into a VM, so I can't make tests (even destructives).

1-Visitor
September 29, 2010

Same person... I've got an account for me and an account "PTC contract related".

Sorry !

1-Visitor
October 1, 2010

//Assuming you are trying to (create and)SET(not get) an IBA value

private AttributeDefDefaultView getAttributeDefinition( String ibaPath ) {
AttributeDefDefaultView ibaDef = null;
try {
ibaDef = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath( ibaPath );
if ( ibaDef == null ) {
AbstractAttributeDefinizerView ibaNodeView = DefinitionLoader.getAttributeDefinition( ibaPath );
if ( ibaNodeView != null ) {
ibaDef = IBADefinitionHelper.service.getAttributeDefDefaultView( ( AttributeDefNodeView ) ibaNodeView );
}
}
}
catch ( Exception e) {
//have fun
}
return ibaDef;
//enjoy
}
1-Visitor
October 1, 2010

The above piece of code is in reponse to - 'I've read Windchill's API JavaDoc, but there is no mention about "getAttributeDefDefaultViewByPath" for example. Si I'm completely lost.' , only. Let me know if you would need help with the actual updateIBA part.

Also, you could use

AttributeDefDefaultView[] theAtts = theContainer.getAttributeDefinitions();

but, given the fact that you are "setting" an ibaValue, the definition for your ibaPath may not even exist during your method call.

1-Visitor
October 1, 2010

First, I would like to thank you both for your answers that lighten my vision of Windchill. Then, I'm completely overbusy for the moment (ISO audit) so I apalogize not to search and test your advices (for the moement though).

@Hari Mathevan : Thank you for this piece of code, butI can't see where the primaryBusinessObject is mentionned, neither where I can set (not create, just set) the attribute value.So I will ask you further help, not for the moment though.

@David DeMay : I'll contact my PTC reseller concerning I*E, but now you told me, I'm pretty sure that he told me that I*E where compulsory (and costly) for our ERP integration.

Thanks again for your answer, I'll have the time to dig further in 2 weeks !

Sincerely,

Thibault Magné