(→AHPSCRIPTS-79)
|
(→Select Agents from Multi-Select Property)
|
Line 195: | |||
return Where.is(new PropertyIncludesAgentNames("agents"));</pre> | return Where.is(new PropertyIncludesAgentNames("agents"));</pre> | ||
+ | = Select Agent of First Job in Current Workflow = | ||
+ | ==== AHPSCRIPTS-30 ==== | ||
+ | <pre>import com.urbancode.anthill3.domain.agent.Agent; | ||
+ | import com.urbancode.anthill3.runtime.scripting.helpers.*; | ||
+ | return new Where() { | ||
+ | public Agent[] filter(Agent[] agents) { | ||
+ | // assumes that the build job was the first job in orig-workflow | ||
+ | Agent targetAgent = WorkflowLookup.getCurrentCase().getJobTraceArray()[0].getAgent(); | ||
+ | boolean found = false; | ||
+ | for (int i = 0; i < agents.length; i++) { | ||
+ | if (agents[i].equals(targetAgent)) { | ||
+ | found = true; | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | if (found) { | ||
+ | return new Agent[]{targetAgent}; | ||
+ | } | ||
+ | else { | ||
+ | return new Agent[0]; | ||
+ | } | ||
+ | } | ||
+ | };</pre> |