i'm customizing plm windchill workflow, provides mechanism execute java code snippets. unfortunately, 'inserted' prepared service's method, means there no way import classes, have include full package names use it. don't try understand snippet below, how looks like:
wt.fc.queryresult activities = wt.fc.persistencehelper.manager.find((wt.pds.statementspec) activitiesquery); while (activities.hasmoreelements()) { wt.workflow.work.wfassignedactivity activity = (wt.workflow.work.wfassignedactivity) activities.nextelement(); if(activity.getdisplayidentifier().tostring().equals("analyze image request")){ java.util.list<wt.workflow.work.workitem> workitems = wt.workflow.status.wfworkflowstatushelper.service.getworkitems(activity); (wt.workflow.work.workitem workitem : workitems){ string action = workitem.getactionperformed(); if(action != null && action.equals("accepted")){ wt.org.wtprincipalreference approver = workitem.getownership().getowner(); n_approver = approver.getfullname() + " ("+approver.getdisplayname()+")"; wt.fc.collections.wthashset approverset = new wt.fc.collections.wthashset(java.util.arrays.aslist(approver)); wt.project.role role = wt.project.role.torole("approver"); com.ptc.windchill.pdmlink.change.server.impl.workflowprocesshelper.setchangeitemparticipants(report, role, approverset); break; } } break; } }
and question - how make code more readable? of course there no way import classes inside method, there no way divide snippet separate methods (as 'pasted' one) i'm looking other ideas.
one option make code more readable separate chained method/property calls across multiple lines.
for example, line:
wt.project.role role = wt.project.role.torole("approver");
could rewritten as:
wt.project.role role = wt .project .role .torole("approver");
Comments
Post a Comment