Added FilterOperator
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/workspace-task-executor-library@169050 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c72d1ac0ba
commit
b60eb2dd50
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.common.workspacetaskexecutor.dataminer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
@ -449,7 +450,6 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskConfig
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
public List<TaskOperator> getListOperators(String[] filterForParameterTypes, FilterOperator operator) throws Exception{
|
||||
logger.info("Getting list operators applying filters: "+filterForParameterTypes+", operator: "+operator);
|
||||
|
||||
DataMinerAccessPoint dap = getDataMinerAccessPoint();
|
||||
|
||||
|
@ -458,6 +458,11 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskConfig
|
|||
return dap.getListOperators();
|
||||
}
|
||||
|
||||
List<String> listFilterParameterTypes = new ArrayList<String>();
|
||||
listFilterParameterTypes.addAll(Arrays.asList(filterForParameterTypes));
|
||||
listFilterParameterTypes.removeAll(Arrays.asList("", null));
|
||||
logger.info("Getting list operators applying filters: "+listFilterParameterTypes+", operator: "+operator);
|
||||
|
||||
List<TaskOperator> filteredListOperators = new ArrayList<TaskOperator>(dap.getListOperators().size());
|
||||
|
||||
if(operator==null){
|
||||
|
@ -471,25 +476,39 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskConfig
|
|||
List<TaskParameter> io = taskOperator.getInputOperators();
|
||||
int filterPassed = 0;
|
||||
|
||||
List<String> matchedFilter = new ArrayList<String>();
|
||||
for (TaskParameter taskParameter : io) {
|
||||
logger.trace("key: "+taskParameter.getKey() + ", value: "+taskParameter.getValue() +", defaultValue: "+taskParameter.getDefaultValue());
|
||||
for (String filterParameterName : filterForParameterTypes) {
|
||||
if(taskParameter.getType().getType().compareToIgnoreCase(filterParameterName)==0){
|
||||
filterPassed++;
|
||||
logger.trace("has type: "+taskParameter.getType());
|
||||
for (String filterParameterName : listFilterParameterTypes) {
|
||||
if(taskParameter.getType()!=null){
|
||||
if(taskParameter.getType().getType().compareToIgnoreCase(filterParameterName)==0){
|
||||
//IGNORING FILTER ALREADY MATCHED
|
||||
if(!matchedFilter.contains(filterParameterName)){
|
||||
matchedFilter.add(filterParameterName);
|
||||
filterPassed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(operator.equals(FilterOperator.LOGICAL_OR) && filterPassed>=1){
|
||||
filteredListOperators.add(taskOperator);
|
||||
logger.debug("Added operator: "+taskOperator + " It is matching "+FilterOperator.LOGICAL_OR +" and filterPassed>=1");
|
||||
logger.info("Added operator: "+taskOperator.getName() + " It is matching "+FilterOperator.LOGICAL_OR +" with filters: "+listFilterParameterTypes);
|
||||
logger.trace("Operators are: "+taskOperator.getInputOperators());
|
||||
//IN AND ALL FILTERS MUST BE MATCHED
|
||||
}else if(operator.equals(FilterOperator.LOGICAL_AND) && filterPassed==filterForParameterTypes.length){
|
||||
}else if(operator.equals(FilterOperator.LOGICAL_AND) && filterPassed==listFilterParameterTypes.size()){
|
||||
filteredListOperators.add(taskOperator);
|
||||
logger.debug("Added operator: "+taskOperator + " It is matching "+FilterOperator.LOGICAL_AND +" and filterPassed==filterForParameterNames.length");
|
||||
logger.info("Added operator: "+taskOperator.getName()+ " It is matching "+FilterOperator.LOGICAL_AND +" with filters: "+listFilterParameterTypes);
|
||||
logger.trace("Operators are: "+taskOperator.getInputOperators());
|
||||
}
|
||||
else{
|
||||
logger.info("Removed operator: "+taskOperator + " It does not match the filters: "+filterForParameterTypes);
|
||||
else if(operator.equals(FilterOperator.LOGICAL_NOT) && filterPassed==0){
|
||||
filteredListOperators.add(taskOperator);
|
||||
logger.info("Added operator: "+taskOperator.getName() + " It is matching "+FilterOperator.LOGICAL_NOT +" with filters: "+listFilterParameterTypes);
|
||||
logger.trace("Operators are: "+taskOperator.getInputOperators());
|
||||
}else{
|
||||
logger.info("Removed operator: "+taskOperator.getName() + " It is not matching the operator: "+operator+" with filters: "+listFilterParameterTypes);
|
||||
logger.trace("Operators are: "+taskOperator.getInputOperators());
|
||||
filteredListOperators.remove(taskOperator);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,5 +15,6 @@ import java.io.Serializable;
|
|||
public enum FilterOperator implements Serializable{
|
||||
|
||||
LOGICAL_OR,
|
||||
LOGICAL_AND;
|
||||
LOGICAL_AND,
|
||||
LOGICAL_NOT;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue