eu.agrosense.spi.agent.AgentQuery Maven / Gradle / Ivy
/**
* Copyright (C) 2008-2013 LimeTri. All rights reserved.
*
* AgroSense is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* There are special exceptions to the terms and conditions of the GPLv3 as it
* is applied to this software, see the FLOSS License Exception
* .
*
* AgroSense is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* AgroSense. If not, see .
*/
package eu.agrosense.spi.agent;
import eu.agrosense.api.agent.AgentConstants;
import eu.agrosense.api.farm.FarmConstants;
import eu.agrosense.shared.model.Farm;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.opendolphin.core.PresentationModel;
import org.opendolphin.core.client.ClientAttribute;
import org.opendolphin.core.client.ClientDolphin;
import org.opendolphin.core.client.comm.OnFinishedHandler;
import org.opendolphin.core.client.comm.OnFinishedHandlerAdapter;
/**
* Support class to query for agents
*
* @since 14.02-beta
* @author johan
*/
public class AgentQuery {
private final ClientDolphin client;
private String farmId;
public AgentQuery(ClientDolphin client) {
this.client = client;
}
/**
* Restrict query output to farm.
* Use as fluent api
* @param farmId
* @return
*/
public AgentQuery forFarm(String farmId) {
this.farmId = farmId;
return this;
}
/**
* Asynchronous call to retrieve all agents
*
* To filter on a farm please use {@link AgentQuery#forFarm(java.lang.String) } in addition to this method
*
* {@link OnFinishedHandler#onFinishedData(java.util.List) } of the provided handler will be called with
* the data result. For columns see {@link AgentConstants#CMD_PULL_AGENT_LIST}
* If not on the gui thread, the synchronous version {@link AgentQuery#agents() can also be used as alternative
*
* @since 14.01-beta
* @see AgentConstants#CMD_PULL_AGENT_LIST
* @param handler
*/
public void agents(OnFinishedHandler handler) {
checkFarm();
client.send(AgentConstants.CMD_PULL_AGENT_LIST, handler);
}
/**
* Synchronized call to retrieve all agents.
*
* To filter on a farm please use {@link AgentQuery#forFarm(java.lang.String) } in addition to this method
*
* Do not use this method on a gui thread, in that case use {@link AgentQuery#agents(org.opendolphin.core.client.comm.OnFinishedHandler) }
*
* @since 14.01-beta
* @see AgentConstants#CMD_PULL_AGENT_LIST
* @return
* @throws InterruptedException
*/
public List © 2015 - 2025 Weber Informatics LLC | Privacy Policy