Added FilterOperator
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/workspace-task-executor-library@169043 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3accf33882
commit
88f7465af3
|
@ -8,6 +8,7 @@ import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
|||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.ExecutableItem;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.ExecutableTask;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.FilterOperator;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.TaskOperator;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.TaskOutput;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.TaskParameter;
|
||||
|
@ -443,10 +444,13 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskConfig
|
|||
* Gets the list operators.
|
||||
*
|
||||
* @param filterForParameterNames the filter for parameter names. It returns only {@link TaskOperator} matching the input filters
|
||||
* @param operator the operator applied to the filters. It must be of type {@link FilterOperator}
|
||||
* @return the list operators
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<TaskOperator> getListOperators(String[] filterForParameterNames) throws Exception{
|
||||
public List<TaskOperator> getListOperators(String[] filterForParameterNames, FilterOperator operator) throws Exception{
|
||||
|
||||
Validate.notNull(operator, "The "+FilterOperator.class.getSimpleName()+" passed is null");
|
||||
|
||||
DataMinerAccessPoint dap = getDataMinerAccessPoint();
|
||||
|
||||
|
@ -455,29 +459,35 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskConfig
|
|||
return dap.getListOperators();
|
||||
}
|
||||
|
||||
List<TaskOperator> filteredListOperators = new ArrayList<TaskOperator>(dap.getListOperators().size());
|
||||
|
||||
//APPLYING FILTERS ON PARAMETER NAME/TYPE
|
||||
for (TaskOperator taskOperator : dap.getListOperators()) {
|
||||
logger.trace("***Algor: "+taskOperator.getName());
|
||||
List<TaskParameter> io = taskOperator.getInputOperators();
|
||||
boolean filterPassed = false;
|
||||
int filterPassed = 0;
|
||||
|
||||
for (TaskParameter taskParameter : io) {
|
||||
logger.trace("key: "+taskParameter.getKey() + ", value: "+taskParameter.getValue() +", defaultValue: "+taskParameter.getDefaultValue());
|
||||
for (String filterParameterName : filterForParameterNames) {
|
||||
if(taskParameter.getKey().compareToIgnoreCase(filterParameterName)==0){
|
||||
filterPassed = true;
|
||||
break;
|
||||
filterPassed++;
|
||||
}
|
||||
}
|
||||
|
||||
if(!filterPassed){
|
||||
logger.info("Removed key: "+taskParameter.getKey() + " It does not match filters: "+filterForParameterNames);
|
||||
io.remove(taskParameter);
|
||||
}
|
||||
}
|
||||
|
||||
if(operator.equals(FilterOperator.LOGICAL_OR) && filterPassed>=1){
|
||||
filteredListOperators.add(taskOperator);
|
||||
//IN AND ALL FILTERS MUST BE MATCHED
|
||||
}else if(operator.equals(FilterOperator.LOGICAL_AND) && filterPassed==filterForParameterNames.length){
|
||||
filteredListOperators.add(taskOperator);
|
||||
}
|
||||
else
|
||||
logger.info("Removed operator: "+taskOperator + " It does not match filters: "+filterForParameterNames);
|
||||
|
||||
}
|
||||
|
||||
return dap.getListOperators();
|
||||
return filteredListOperators;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.common.workspacetaskexecutor.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* The Enum FilterOperator.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Jun 12, 2018
|
||||
*/
|
||||
public enum FilterOperator implements Serializable{
|
||||
|
||||
LOGICAL_OR,
|
||||
LOGICAL_AND;
|
||||
}
|
Loading…
Reference in New Issue