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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Using Infoengine for retrieving workflow task information

PreetiGupta
15-Moonstone

Using Infoengine for retrieving workflow task information

I am curious if someone has done this. It does not look like it is straight forward using infoengine. So wondering, if anyone has used infoengine to get workflow intruction, variables, and voting options of an open task.

thanks.

ACCEPTED SOLUTION

Accepted Solutions

I don’t know your exact requirement to use info engine to get workflow activity information.

I had similar requiring for one cognos report, where I have to use info engine to get workflow related information using info Engine.  It’s tedious to write webjects to retrieve all workflow related information when you have API’s easily available. I wrote one helper class to retrieve all require information using API. Call helper class from task/xml file, which with return result in infoengine group.

So you can use the xml/task for cognos reports, web service or for any other purpose.

Below is example

<ie:webject name="Create-Group" type="GRP">

    <ie:param name="GROUP_OUT" data="out"/>

</ie:webject>

<%

System.out.println("***************IN TASK ********************");

Group out = getGroup( "out" );

String oID=getParam("objectID").toString();

Group group=ext.report.SummaryReport.getDescription(oID);

Element[] elements = group.getElementArray();

for (int i = 0; i < elements.length; i++) {

    Element e= (Element) elements[i];

    out.addElement ( e );

}

System.out.println("*************** out summary Header********************");

%>

<ie:webject name="Return-Groups" type="GRP">

<ie:param name="GROUP_IN" data="out"/>

</ie:webject>

public static Group getRoutingHistory(String objectID) {

  System.out.println("WithoutRepeter");

  Group grp = new Group();

  try {

  ReferenceFactory rf = new ReferenceFactory();

  WTReference ref = rf.getReference(objectID);

  WTChangeRequest2 wtChangeRequest2 = (WTChangeRequest2) ref.getObject();

  Enumeration processes = WfEngineHelper.service.getAssociatedProcesses(wtChangeRequest2, null);

  while (processes.hasMoreElements()) {

  WfProcess process = (WfProcess) processes.nextElement();

  NmOid nmOid = new NmOid(process);

  QueryResult status = WorkflowCommands.getRouteStatus(nmOid);

  while (status.hasMoreElements()) {

  Object obj = status.nextElement();

  String activityName = "N/A";

  String assigne = "N/A";

  String role = "N/A";

  String comments = "N/A";

  String vote = "N/A";

  String actStatus = "N/A";

  String completed = "N/A";

  String start = "N/A";

  String signature = "N/A";

  String completedBy = "N/A";

  if (obj.getClass().isAssignableFrom(WorkItem.class)) {

  WorkItem workitem = (WorkItem) obj;

  activityName = ((WfAssignedActivity) workitem.getSource().getObject()).getName();

  assigne = workitem.getOwnership().getOwner().getFullName();

  role = workitem.getRole().getDisplay();

  if (workitem.getStatus().toString().equalsIgnoreCase(WfAssignmentState.COMPLETED.toString())) {

  actStatus = new URLFactory().getHREF("/netmarkets/images/checked.gif");

  } else {

  actStatus = new URLFactory().getHREF("/netmarkets/images/unchecked.gif");

  }

  WfVotingEventAudit wfVotingEventAudit = getAuditEvent(workitem);

  if (wfVotingEventAudit != null) {

  comments = wfVotingEventAudit.getUserComment();

  vote = wfVotingEventAudit.getEventList().toString();

  DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyy");

  completed = ((wfVotingEventAudit.getTimestamp()) == null) ? "" : dateFormat.format(wfVotingEventAudit.getTimestamp());

  start = ((wfVotingEventAudit.getCreateTimestamp()) == null) ? "" : dateFormat.format(wfVotingEventAudit.getCreateTimestamp());

  signature = getSignature((WTUser) wfVotingEventAudit.getUserRef().getObject());

  completedBy = wfVotingEventAudit.getUserRef().getFullName();

  }

  } else if (obj.getClass().isAssignableFrom(Element.class)) {

  continue;

  } else if (obj.getClass().isAssignableFrom(WfVotingEventAudit.class)) {

  WfVotingEventAudit wfVotingEventAudit = (WfVotingEventAudit) obj;

  activityName = wfVotingEventAudit.getActivityName();

  assigne = wfVotingEventAudit.getAssigneeRef().getFullName();

  role = ((wfVotingEventAudit.getRole() == null) ? "" : wfVotingEventAudit.getRole().getDisplay());

  comments = wfVotingEventAudit.getUserComment();

  vote = wfVotingEventAudit.getEventList().toString();

  actStatus = new URLFactory().getHREF("/netmarkets/images/checked.gif");

  DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyy");

  completed = ((wfVotingEventAudit.getTimestamp()) == null) ? "N/A" : dateFormat.format(wfVotingEventAudit.getTimestamp());

  start = ((wfVotingEventAudit.getCreateTimestamp()) == null) ? "N/A" : dateFormat.format(wfVotingEventAudit.getCreateTimestamp());

  signature = getSignature((WTUser) wfVotingEventAudit.getUserRef().getObject());

  completedBy = wfVotingEventAudit.getUserRef().getFullName();

  }

  Element element = new Element();

  element.addAtt(new Att("Assigne", assigne));

  element.addAtt(new Att("Role", role));

  comments = ((comments.trim().length() == 0 ? "N/A" : comments));

  System.out.println("Comments-->" + comments);

  element.addAtt(new Att("Comments", comments));

  vote = vote.replace("[", "");

  vote = vote.replace("]", "");

  vote = ((vote.length() == 0 ? "N/A" : vote));

  if (!completed.equalsIgnoreCase("N/A")){

  vote = "Task Completed";

  }

  element.addAtt(new Att("vote", vote));

  element.addAtt(new Att("Status", actStatus));

  element.addAtt(new Att("Completed", completed.replace("-", "")));

  element.addAtt(new Att("start", start.replace("-", "")));

  element.addAtt(new Att("WorkItemName", activityName));

  element.addAtt(new Att("Signature", signature));

  element.addAtt(new Att("completedBy", completedBy));

  System.out.println("Completed by " + completedBy);

  // System.out.println("adding element "+element);

  grp.addElement(element);

  }

  }

  } catch (WTException e) {

  e.printStackTrace();

  } catch (WTRuntimeException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  } catch (PropertyVetoException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  } catch (IOException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  }

  return grp;

  }

Hope it helps !!!

Thanks

Shreyas

View solution in original post

3 REPLIES 3

I don’t know your exact requirement to use info engine to get workflow activity information.

I had similar requiring for one cognos report, where I have to use info engine to get workflow related information using info Engine.  It’s tedious to write webjects to retrieve all workflow related information when you have API’s easily available. I wrote one helper class to retrieve all require information using API. Call helper class from task/xml file, which with return result in infoengine group.

So you can use the xml/task for cognos reports, web service or for any other purpose.

Below is example

<ie:webject name="Create-Group" type="GRP">

    <ie:param name="GROUP_OUT" data="out"/>

</ie:webject>

<%

System.out.println("***************IN TASK ********************");

Group out = getGroup( "out" );

String oID=getParam("objectID").toString();

Group group=ext.report.SummaryReport.getDescription(oID);

Element[] elements = group.getElementArray();

for (int i = 0; i < elements.length; i++) {

    Element e= (Element) elements[i];

    out.addElement ( e );

}

System.out.println("*************** out summary Header********************");

%>

<ie:webject name="Return-Groups" type="GRP">

<ie:param name="GROUP_IN" data="out"/>

</ie:webject>

public static Group getRoutingHistory(String objectID) {

  System.out.println("WithoutRepeter");

  Group grp = new Group();

  try {

  ReferenceFactory rf = new ReferenceFactory();

  WTReference ref = rf.getReference(objectID);

  WTChangeRequest2 wtChangeRequest2 = (WTChangeRequest2) ref.getObject();

  Enumeration processes = WfEngineHelper.service.getAssociatedProcesses(wtChangeRequest2, null);

  while (processes.hasMoreElements()) {

  WfProcess process = (WfProcess) processes.nextElement();

  NmOid nmOid = new NmOid(process);

  QueryResult status = WorkflowCommands.getRouteStatus(nmOid);

  while (status.hasMoreElements()) {

  Object obj = status.nextElement();

  String activityName = "N/A";

  String assigne = "N/A";

  String role = "N/A";

  String comments = "N/A";

  String vote = "N/A";

  String actStatus = "N/A";

  String completed = "N/A";

  String start = "N/A";

  String signature = "N/A";

  String completedBy = "N/A";

  if (obj.getClass().isAssignableFrom(WorkItem.class)) {

  WorkItem workitem = (WorkItem) obj;

  activityName = ((WfAssignedActivity) workitem.getSource().getObject()).getName();

  assigne = workitem.getOwnership().getOwner().getFullName();

  role = workitem.getRole().getDisplay();

  if (workitem.getStatus().toString().equalsIgnoreCase(WfAssignmentState.COMPLETED.toString())) {

  actStatus = new URLFactory().getHREF("/netmarkets/images/checked.gif");

  } else {

  actStatus = new URLFactory().getHREF("/netmarkets/images/unchecked.gif");

  }

  WfVotingEventAudit wfVotingEventAudit = getAuditEvent(workitem);

  if (wfVotingEventAudit != null) {

  comments = wfVotingEventAudit.getUserComment();

  vote = wfVotingEventAudit.getEventList().toString();

  DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyy");

  completed = ((wfVotingEventAudit.getTimestamp()) == null) ? "" : dateFormat.format(wfVotingEventAudit.getTimestamp());

  start = ((wfVotingEventAudit.getCreateTimestamp()) == null) ? "" : dateFormat.format(wfVotingEventAudit.getCreateTimestamp());

  signature = getSignature((WTUser) wfVotingEventAudit.getUserRef().getObject());

  completedBy = wfVotingEventAudit.getUserRef().getFullName();

  }

  } else if (obj.getClass().isAssignableFrom(Element.class)) {

  continue;

  } else if (obj.getClass().isAssignableFrom(WfVotingEventAudit.class)) {

  WfVotingEventAudit wfVotingEventAudit = (WfVotingEventAudit) obj;

  activityName = wfVotingEventAudit.getActivityName();

  assigne = wfVotingEventAudit.getAssigneeRef().getFullName();

  role = ((wfVotingEventAudit.getRole() == null) ? "" : wfVotingEventAudit.getRole().getDisplay());

  comments = wfVotingEventAudit.getUserComment();

  vote = wfVotingEventAudit.getEventList().toString();

  actStatus = new URLFactory().getHREF("/netmarkets/images/checked.gif");

  DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyy");

  completed = ((wfVotingEventAudit.getTimestamp()) == null) ? "N/A" : dateFormat.format(wfVotingEventAudit.getTimestamp());

  start = ((wfVotingEventAudit.getCreateTimestamp()) == null) ? "N/A" : dateFormat.format(wfVotingEventAudit.getCreateTimestamp());

  signature = getSignature((WTUser) wfVotingEventAudit.getUserRef().getObject());

  completedBy = wfVotingEventAudit.getUserRef().getFullName();

  }

  Element element = new Element();

  element.addAtt(new Att("Assigne", assigne));

  element.addAtt(new Att("Role", role));

  comments = ((comments.trim().length() == 0 ? "N/A" : comments));

  System.out.println("Comments-->" + comments);

  element.addAtt(new Att("Comments", comments));

  vote = vote.replace("[", "");

  vote = vote.replace("]", "");

  vote = ((vote.length() == 0 ? "N/A" : vote));

  if (!completed.equalsIgnoreCase("N/A")){

  vote = "Task Completed";

  }

  element.addAtt(new Att("vote", vote));

  element.addAtt(new Att("Status", actStatus));

  element.addAtt(new Att("Completed", completed.replace("-", "")));

  element.addAtt(new Att("start", start.replace("-", "")));

  element.addAtt(new Att("WorkItemName", activityName));

  element.addAtt(new Att("Signature", signature));

  element.addAtt(new Att("completedBy", completedBy));

  System.out.println("Completed by " + completedBy);

  // System.out.println("adding element "+element);

  grp.addElement(element);

  }

  }

  } catch (WTException e) {

  e.printStackTrace();

  } catch (WTRuntimeException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  } catch (PropertyVetoException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  } catch (IOException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  }

  return grp;

  }

Hope it helps !!!

Thanks

Shreyas

PreetiGupta
15-Moonstone
(To:satre-2)

Thanks Shreyas for your quick response. I dig into it.

@_1647
13-Aquamarine
(To:satre-2)

Hi,
Could please add the getAuditEvent() method in reply with workitem parameter

It will be very helpfull to get all the details for different objects of change management.

Announcements


Top Tags