Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Solved! Go to Solution.
This would work but another option for less effort could be to extend the already existing ObjectWebject class that already has that function. In the example below you can use getUfidsAsGroup then loop through the group and perform actions on each element, like get the context just for an example, then add to the group_out.
Task:
<%@page language="java" session="boolean" access="http|soap|internal"%>
<%@taglib uri="http://www.ptc.com/infoengine/taglib/core" prefix="ie"%>
<!--
deploy: WT_HOME\tasks\Query-ExampleWebject.xml
usage http://host/Windchill/servlet/IE/tasks/Query-ExampleWebject.xml
-->
<%
String wcAdapter = wt.util.WTProperties.getLocalProperties().getProperty("wt.federation.ie.VMName");
%>
<ie:webject name="Query-Objects" type="OBJ">
<ie:param name="INSTANCE" data="<%=wcAdapter%>"/>
<ie:param name="WHERE" data="number=GC00000*"/>
<ie:param name="attribute" data="number" delim="," />
<ie:param name="type" data="wt.part.WTPart" />
<ie:param name="group_out" data="parts" />
</ie:webject>
<ie:webject name="EXAMPLE" type="OBJ">
<ie:param name="group_in" data="parts" />
<ie:param name="INSTANCE" data="<%=wcAdapter%>"/>
<ie:param name="group_out" data="partsWithContext" />
</ie:webject>
Webject:
public class Example_QueryWebject extends ObjectWebject {
public Task invoke(Task task) throws WTException {
Webject webject = task.getWebject();
Task response = new Task();
String groupOutName = null;
try {
groupOutName = webject.paramValue("GROUP_OUT");
if (StringUtils.isBlank(groupOutName)) {
throw new WTException("Error: GROUP_OUT is null");
}
Group group = new Group(groupOutName);
Group g = getUfidsAsGroup(task);
List<Element> strings = g.getElementList();
group.setClassName("String");
ReferenceFactory rf = new ReferenceFactory();
for (Element element : strings) {
// Retrieve ufid for element
String obidAttribute = element.getUfid();
// Check if the "obid" attribute exists
if (obidAttribute != null) {
// Print the content of the "obid" attribute
obidAttribute = obidAttribute.substring(0,obidAttribute.lastIndexOf(':'));
WTReference ref = rf.getReference(obidAttribute);
WTPart part = (WTPart)ref.getObject();
if (part == null) {
throw new WTException("could not be retrieved for OBID=" + obidAttribute);
}
this.setAttributes(part, group);
} else {
System.out.println("obid attribute not found in element.");
}
}
response.addVdb(group);
} catch (Exception var10) {
var10.printStackTrace();
Group errorGroup = new Group(groupOutName);
errorGroup.setClassName(this.groupOutClass);
Element errorElement = new Element();
errorElement.addAtt(new Att("wiState", "Error: " + var10.getLocalizedMessage()));
errorGroup.addElement(errorElement);
response.addVdb(errorGroup);
System.out.println("\n" + response.getVdb().toXML());
}
return response;
}
private void setAttributes(WTPart part, Group group) throws WfException, WTException {
Element ele = new Element();
ele.addAtt(new Att("Name", part.getName()));
ele.addAtt(new Att("Number", part.getNumber()));
ele.addAtt(new Att("Context", part.getContainerName()));
group.addElement(ele);
}
}
site.xconf:
<Property name="EXAMPLE.WCTYPE|java.lang.Object" overridable="true"
targetFile="codebase/wt.adapter.delegates.properties"
value="ext.Example_QueryWebject"/>
From Search-Objects webject im getting the parts details, and Context-Name Webject is the custom webject which we have created. Using Return-Group webject im combining both webject data. But the data is not combining. The custom data is showing for only the last object.
<%@page language="java"%>
<%@taglib uri="http://www.ptc.com/infoengine/taglib/core" prefix="ie"%>
<ie:webject name="Search-Objects" type="OBJ">
<ie:param name="INSTANCE" data="$(@FORM[]supporting-adapter[*])" delim="!" valueSeparator="!" default="<%=com.infoengine.au.NamingService.getVMName()%>"/>
<ie:param name="TYPE" data="wt.part.WTPart"/>
<ie:param name="attribute" data="obid,number,name,version,lifeCycleState,containerReference" delim=","/>
<ie:param name="GROUP_OUT" data="objectSearched"/>
</ie:webject>
<ie:forEach groupIn="objectSearched" groupOut="Obj">
<ie:webject name="Context-Name" type="EXT" use="ext.customWebject.ExampleCustomWebject">
<ie:param name="COLUMN" data="obid"/>
<ie:param name="GROUP_IN" data="Obj"/>
<ie:param name="GROUP_OUT" data="ActualResult"/>
</ie:webject>
</ie:forEach>
<ie:webject name="Return-Groups" type="GRP">
<ie:param name="GROUP_IN" data="objectSearched"/>
<ie:param name="GROUP_IN" data="ActualResult"/>
</ie:webject>
Hi @RG_10893406,
I wanted to see if you got the help you needed.
If so, please mark the appropriate reply as the Accepted Solution. It will help other members who may have the same question.
Please note that industry experts also review the replies and may eventually accept one of them as solution on your behalf.
Of course, if you have more to share on your issue, please pursue the conversation.
Thanks,
I did not get any solution. I am still searching for the solution.
Please let me know if anybody aware of it. It will be helpful for me.
If it helps you solve it, they asked to see the webject but what you sent is the code which implements an info engine task to call the webject. You need to show java code the webjects
This would work but another option for less effort could be to extend the already existing ObjectWebject class that already has that function. In the example below you can use getUfidsAsGroup then loop through the group and perform actions on each element, like get the context just for an example, then add to the group_out.
Task:
<%@page language="java" session="boolean" access="http|soap|internal"%>
<%@taglib uri="http://www.ptc.com/infoengine/taglib/core" prefix="ie"%>
<!--
deploy: WT_HOME\tasks\Query-ExampleWebject.xml
usage http://host/Windchill/servlet/IE/tasks/Query-ExampleWebject.xml
-->
<%
String wcAdapter = wt.util.WTProperties.getLocalProperties().getProperty("wt.federation.ie.VMName");
%>
<ie:webject name="Query-Objects" type="OBJ">
<ie:param name="INSTANCE" data="<%=wcAdapter%>"/>
<ie:param name="WHERE" data="number=GC00000*"/>
<ie:param name="attribute" data="number" delim="," />
<ie:param name="type" data="wt.part.WTPart" />
<ie:param name="group_out" data="parts" />
</ie:webject>
<ie:webject name="EXAMPLE" type="OBJ">
<ie:param name="group_in" data="parts" />
<ie:param name="INSTANCE" data="<%=wcAdapter%>"/>
<ie:param name="group_out" data="partsWithContext" />
</ie:webject>
Webject:
public class Example_QueryWebject extends ObjectWebject {
public Task invoke(Task task) throws WTException {
Webject webject = task.getWebject();
Task response = new Task();
String groupOutName = null;
try {
groupOutName = webject.paramValue("GROUP_OUT");
if (StringUtils.isBlank(groupOutName)) {
throw new WTException("Error: GROUP_OUT is null");
}
Group group = new Group(groupOutName);
Group g = getUfidsAsGroup(task);
List<Element> strings = g.getElementList();
group.setClassName("String");
ReferenceFactory rf = new ReferenceFactory();
for (Element element : strings) {
// Retrieve ufid for element
String obidAttribute = element.getUfid();
// Check if the "obid" attribute exists
if (obidAttribute != null) {
// Print the content of the "obid" attribute
obidAttribute = obidAttribute.substring(0,obidAttribute.lastIndexOf(':'));
WTReference ref = rf.getReference(obidAttribute);
WTPart part = (WTPart)ref.getObject();
if (part == null) {
throw new WTException("could not be retrieved for OBID=" + obidAttribute);
}
this.setAttributes(part, group);
} else {
System.out.println("obid attribute not found in element.");
}
}
response.addVdb(group);
} catch (Exception var10) {
var10.printStackTrace();
Group errorGroup = new Group(groupOutName);
errorGroup.setClassName(this.groupOutClass);
Element errorElement = new Element();
errorElement.addAtt(new Att("wiState", "Error: " + var10.getLocalizedMessage()));
errorGroup.addElement(errorElement);
response.addVdb(errorGroup);
System.out.println("\n" + response.getVdb().toXML());
}
return response;
}
private void setAttributes(WTPart part, Group group) throws WfException, WTException {
Element ele = new Element();
ele.addAtt(new Att("Name", part.getName()));
ele.addAtt(new Att("Number", part.getNumber()));
ele.addAtt(new Att("Context", part.getContainerName()));
group.addElement(ele);
}
}
site.xconf:
<Property name="EXAMPLE.WCTYPE|java.lang.Object" overridable="true"
targetFile="codebase/wt.adapter.delegates.properties"
value="ext.Example_QueryWebject"/>