git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application/perform-service@176947 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ab561d96a4
commit
33173ead11
|
@ -172,7 +172,7 @@ public class ExportCSVQuery extends Query {
|
|||
String field=actualField(filterLabel);
|
||||
StringBuilder toReturn=new StringBuilder();
|
||||
for(String p:filterValues)
|
||||
toReturn.append(String.format("%1%s = '%2$s' OR",field,p));
|
||||
toReturn.append(String.format("%1$s = '%2$s' OR",field,p));
|
||||
toReturn.setLength(toReturn.lastIndexOf("OR"));
|
||||
return toReturn.toString();
|
||||
}
|
||||
|
|
|
@ -7,14 +7,20 @@ import javax.ws.rs.WebApplicationException;
|
|||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class InterfaceCommons {
|
||||
|
||||
private static final Logger log= LoggerFactory.getLogger(InterfaceCommons.class);
|
||||
|
||||
public static final void checkMandatory(Object toCheck, String name) throws WebApplicationException{
|
||||
if(toCheck==null)
|
||||
throw new WebApplicationException(String.format("Parameter %1$s is mandatory",name),Response.Status.BAD_REQUEST);
|
||||
}
|
||||
|
||||
public static final List<String> getParameter(MultivaluedMap<String,String> map,String paramName, boolean mandatory){
|
||||
// log.debug()
|
||||
if(map.containsKey(paramName)) {
|
||||
return map.get(paramName);
|
||||
}else if(mandatory) throw new WebApplicationException(String.format("Parameter %1$s is mandatory",paramName),Response.Status.BAD_REQUEST);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.application.perform.service.rest;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -57,8 +58,12 @@ public class Performance {
|
|||
|
||||
request.addAreas(InterfaceCommons.getParameter(parameters, ServiceConstants.Performance.AREA_PARAMETER, false));
|
||||
request.addQuarters(InterfaceCommons.getParameter(parameters, ServiceConstants.Performance.QUARTER_PARAMETER, false));
|
||||
for(String s:InterfaceCommons.getParameter(parameters, ServiceConstants.Performance.FARM_ID_PARAMETER, true))
|
||||
List<String> farmidsString=InterfaceCommons.getParameter(parameters, ServiceConstants.Performance.FARM_ID_PARAMETER, true);
|
||||
log.debug("FARMIDS : ",farmidsString);
|
||||
for(String s:farmidsString) {
|
||||
log.debug("Parsing {} ",s);
|
||||
request.addFarmId(Long.parseLong(s));
|
||||
}
|
||||
|
||||
request.addSpecies(InterfaceCommons.getParameter(parameters, ServiceConstants.Performance.SPECIES_ID_PARAMETER, false));
|
||||
request.addPeriods(InterfaceCommons.getParameter(parameters, ServiceConstants.Performance.PERIOD_PARAMETER, false));
|
||||
|
|
|
@ -14,10 +14,10 @@ public class PerformanceTest extends CommonTest{
|
|||
public void getPerformance() {
|
||||
WebTarget target=
|
||||
target(ServiceConstants.Performance.PATH).
|
||||
// queryParam(ServiceConstants.Performance.AREA_PARAMETER, "A1","A2").
|
||||
// queryParam(ServiceConstants.Performance.QUARTER_PARAMETER, "Q1","Q2").
|
||||
// queryParam(ServiceConstants.Performance.SPECIES_ID_PARAMETER, "Gadilidae","Tonno").
|
||||
// queryParam(ServiceConstants.Performance.PERIOD_PARAMETER, "First","Spring").
|
||||
queryParam(ServiceConstants.Performance.AREA_PARAMETER, "A1","A2").
|
||||
queryParam(ServiceConstants.Performance.QUARTER_PARAMETER, "Q1","Q2").
|
||||
queryParam(ServiceConstants.Performance.SPECIES_ID_PARAMETER, "Gadilidae","Tonno").
|
||||
queryParam(ServiceConstants.Performance.PERIOD_PARAMETER, "First","Spring").
|
||||
queryParam(ServiceConstants.Performance.FARM_ID_PARAMETER, "13625424","1233556","12346").
|
||||
queryParam(ServiceConstants.Performance.BATCH_TYPE_PARAMETER, "GROW_OUT_AGGREGATED");
|
||||
|
||||
|
|
Loading…
Reference in New Issue