38 lines
986 B
Java
38 lines
986 B
Java
/**
|
|
*
|
|
*/
|
|
package org.gcube.vremanagement.executor.client.plugins.query.filter;
|
|
|
|
import java.util.List;
|
|
|
|
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
|
|
|
/**
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
*/
|
|
@Deprecated
|
|
public class ListEndpointDiscoveryFilter implements EndpointDiscoveryFilter {
|
|
|
|
protected static final String containsFormat = "contains($entry/string(),'%1s')";
|
|
|
|
@Override
|
|
public void filter(SimpleQuery simpleQuery, List<ServiceEndpoint> serviceEndpoints) {
|
|
|
|
String expression = "";
|
|
int size = serviceEndpoints.size();
|
|
for(int i=0; i<size; i++){
|
|
String hostedOn = serviceEndpoints.get(i).profile().runtime().hostedOn();
|
|
String condition = String.format(containsFormat, hostedOn);
|
|
expression = String.format("%s %s", expression, condition);
|
|
if(i<(size-1)){
|
|
expression = String.format("%s or ", expression);
|
|
}
|
|
}
|
|
|
|
simpleQuery.addCondition(expression);
|
|
|
|
}
|
|
|
|
}
|