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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

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

TiboMagnier
1-Newbie

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

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 !

12 REPLIES 12

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

I'm really interested in some sample.

Thank you !

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

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

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

Sorry !

Windchill uses Info*Engine out of the box. You are probably thinking of the the standalone Info*Engine or web services integration where you run a separate Info*Engine server. Not the same thing. For example, if you search for an object in Windchill from the search pages, it uses Info*Engine. If you add a new user to your system, it uses Info*Engine. If you still are not sure, talk to PTC, but I'm fairly certain you may write Info*Engine webject task code without licensing the Info*Engine server.

//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
}

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.

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é

Finally, I managed to get it functionnal, thanks to you.

Thank you very much.

Edit :

The solution I found is not functionnal... indeed, I cannot set directly an IBA into a workflow using Java API.

I am really interested in some help about I*E tasks. Indeed, I managed to find an "update IBA" task, but I have to query. How can I set an argument from the worklow task that will launch the I*E one to describe my current WTDocument ?

Sincerely,

Thibault Magné

This message has been modified by: Thibault Magne

Hi Thibault.

Firstly you need 'WCAdapterGuide.pdf' – there are listed all webjects used in I*E.

Here is example of Update-Objects task that change IBA attribute of object. Also it can checkout/checkin this object.

<?xml version="1.0" standalone="yes"?>

<%@page language="java"%>

<%@page import="wt.util.*"%>

<%@page import="wt.util.*, java.io.*"%>

<%@taglib uri="http://www.ptc.com/infoengine/taglib/core" prefix="ie"%>

<%

System.out.println("Выполняю Task: tasks\\ext\\solver\\mpml\\writePPAttr.xml ...");

WTProperties wtprops = WTProperties.getLocalProperties();

String wtInstance = wtprops.getProperty("wt.federation.ie.VMName");

%>

<ie:authenticate/>
<ie:getService varName="ieObj"/>

<process name="Update-Objects">

<!--
<ie:webject name="CheckOut-Objects" type="OBJ">
<ie:param name="INSTANCE" data="${@FORM[]supporting-adapter[]}" default="<%= wtInstance %>"/>
<ie:param name="OBJECT_REF" data="${@FORM[]object_ref[]}"/>
<ie:param name="GROUP_OUT" data="out"/>
</ie:webject>
-->

<ie:webject name="Update-Objects" type="OBJ">
<ie:param name="AUTHORIZATION" data="${@SERVER[]authorization[0]}"/>
<ie:param name="DBUSER" data="wcadmin"/>

<ie:param name="PASSWD" data="wcadmin"/>

<ie:param name="INSTANCE" data="${@FORM[]supporting-adapter[]}" default="<%= wtInstance %>"/>
<ie:param name="OBJECT_REF" data="${@FORM[]object_ref[]}"/>
<ie:param name="FIELD" data="${@FORM[]attr1[]}"/>
<ie:param name="GROUP_OUT" data="out"/>
</ie:webject>

<!--
<ie:webject name="CheckIn-Objects" type="OBJ">
<ie:param name="INSTANCE" data="${@FORM[]supporting-adapter[]}" default="<%= wtInstance %>"/>
<ie:param name="OBJECT_REF" data="${@FORM[]object_ref[]}"/>
<ie:param name="GROUP_OUT" data="out"/>
</ie:webject>

-->

You can run this task from URL:

http://HOSTNAME/Windchill/servlet/IE/tasks/ext/solver/mpml/writePPAttr.xml?object_ref=VR:com.ptc.windchill.mpml.processplan.MPMProcessPlan:157416&attr1=Massa_detali=111

where Massa_detali=111 is name of IBA and it’s value.

You can run this also from workflow or any java code:

try {

com.infoengine.SAK.Task task = new com.infoengine.SAK.Task("/ext/solver/mpml/writePPAttr.xml");

String object_ref = new String();

object_ref = (new wt.fc.ReferenceFactory()).getReferenceString(part);

task.addParam("object_ref", object_ref);

task.addParam("attr1", "Massa_detali=111");

task.invoke();

}

catch (Exception e)

{

String errormsg = e.toString();

e.printStackTrace();

}

Hope it helps,

Dmitry

I would like to thank you very much : my questions were related to :

- How to use I*E tasks into workflows/pure java code

- How to send parameters to I*E tasks (in java)

- How to set an attribute.

And you answered each of it ! Thank you again for your precision. I will read furthermore the WCAdapterGuide.

That helps a lot.

Thibault Magné

Top Tags