Version Differences for Agent Filter

(AHPSCRIPTS-43)
(AHPSCRIPTS-79)
Line 160:
  Variable.equals("sys/os.name", "Linux") });    Variable.equals("sys/os.name", "Linux") }); 
  });</pre>    });</pre> 
       
    + = Select Agents from Multi-Select Property =  
       
    + *This script (mostly the last line) assumes that you have a multi-select that is populated with the names of agents (as the appear in the Current Activity screen) named "agents". The script basically returns any agents that are both part of the environment and selected in the drop-down.  
       
    + ==== AHPSCRIPTS-80 ====  
    + <pre>import com.urbancode.anthill3.domain.agent.Agent;  
    + import com.urbancode.anthill3.runtime.scripting.helpers.*;  
    + import java.util.*;  
       
    + public class PropertyIncludesAgentNames extends Criteria {  
       
    + private String propertyName;  
       
    + public PropertyIncludesAgentNames(String propertyName) {  
    + this.propertyName = propertyName;  
    + }  
       
    + public Agent[] filter(Agent[] agents){  
    + list = new ArrayList();  
       
    + for (int i = 0; i < agents.length; i++) {  
    + System.out.println(PropertyLookup.get(propertyName) + " : " + agents[i].getName());  
    + if (PropertyLookup.contains(propertyName, agents[i].getName())) {  
    + list.add(agents[i]);  
    + }  
    + }  
    +  
    + Agent[] result = new Agent[list.size()];  
    + list.toArray(result);  
    + return result;  
    + }  
    + }  
       
    + return Where.is(new PropertyIncludesAgentNames("agents"));</pre>