List of usage examples for org.apache.commons.lang3 StringUtils upperCase
public static String upperCase(final String str)
Converts a String to upper case as per String#toUpperCase() .
A null input String returns null .
StringUtils.upperCase(null) = null StringUtils.upperCase("") = "" StringUtils.upperCase("aBc") = "ABC"
Note: As described in the documentation for String#toUpperCase() , the result of this method is affected by the current locale.
From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java
/** Adds a pipeline. This will return false if the pipeline could not be added. */ public boolean addPipeline(PipelineDefinition pipeline) { if (isValidPipeline(pipeline)) { log.debug("{}: Adding pipeline", StringUtils.upperCase(pipeline.getName())); pipelines.put(StringUtils.upperCase(pipeline.getName()), pipeline); return true; } else {//from w w w . j a v a 2 s.com log.warn("{}: This pipeline was not added.", pipeline); return false; } }
From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java
/** Check that the algorithm is not null, is valid, and has a name which has not already been added to the PipelineManager instance. Returns false if the algorithm is not valid.*/ private boolean isValidAlgorithm(AlgorithmDefinition algorithm) { if (algorithm == null) { log.warn("algorithm cannot be null"); return false; } else if (!algorithm.isValid()) { log.error("{}: algorithm is not valid", algorithm); return false; } else if (getAlgorithm(algorithm.getName()) != null) { log.error("{}: algorithm name is already in use", StringUtils.upperCase(algorithm.getName())); return false; } else {/*from w w w .j a v a 2 s .c o m*/ return true; } }
From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java
/** Check that the task is not null, is valid, references an algorithm which already exists in the PipelineManager, has a name which has not already been added to the PipelineManager instance, and has properties associated with it which are valid for the referenced algorithm. Returns false if the action is invalid. */ private boolean isValidAction(ActionDefinition actionDefinition) { if (actionDefinition == null) { log.warn("action was null"); return false; } else if (!actionDefinition.isValid()) { log.error("{}: action is not valid", actionDefinition); return false; } else if (getAlgorithm(actionDefinition) == null) { log.error("{}: referenced algorithm {} does not exist", actionDefinition.getName(), StringUtils.upperCase(actionDefinition.getAlgorithmRef())); return false; } else if (getAction(actionDefinition.getName()) != null) { log.error("{}: action name is already in use", actionDefinition.getName()); return false; } else {// w w w . j a v a 2 s . c o m // If this action provided any properties... if (actionDefinition.getProperties() != null) { AlgorithmDefinition algorithm = getAlgorithm(actionDefinition); // For each property (we've already verified the completeness of this set)... for (PropertyDefinitionRef propertyValue : actionDefinition.getProperties()) { if (!algorithm.getProvidesCollection().getAlgorithmProperties().contains(propertyValue)) { // If the referenced property in the action doesn't exist in the algorithm's definition... log.error("{}: The referenced algorithm ({}) does not expose the property {}.", actionDefinition.getName(), actionDefinition.getAlgorithmRef(), propertyValue.getName()); return false; } else if (!isValidValueForType(propertyValue.getValue(), algorithm.getProvidesCollection() .getAlgorithmProperty(propertyValue.getName()).getType())) { // Otherwise, if the provided value for the property is not acceptable given the property's defined type... log.error("{}.{}: The provided value of '{}' cannot be converted to type {}.", actionDefinition.getName(), propertyValue.getName(), propertyValue.getValue(), algorithm.getProvidesCollection().getAlgorithmProperty(propertyValue.getName()) .getType()); return false; } } } else { log.debug("{}: no properties were provided", actionDefinition.getName()); } } return true; }
From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java
/** Check that the task is not null, is valid, has a name which has not already been added to the PipelineManager, references only actions which have already been added to the PipelineManager, and if more than one action is specified, check that all referenced actions are of the same Operation. Returns false if the task is invalid. */ private boolean isValidTask(TaskDefinition task) { if (task == null) { log.warn("task must not be null"); return false; } else if (!task.isValid()) { log.error("{}: task is not valid", task); return false; } else if (getTask(task.getName()) != null) { log.error("{}: task name is already in use", StringUtils.upperCase(task.getName())); return false; } else {//from w ww . j av a2s. c o m ActionType actionType = null; for (ActionDefinitionRef actionRef : task.getActions()) { if (getAction(actionRef) == null) { log.error("{}: The referenced action ({}) does not exist", StringUtils.upperCase(task.getName()), StringUtils.upperCase(actionRef.getName())); return false; } else if (actionType == null) { // First time through - set the action type. Remember, algorithms MUST have an ActionType associated with them, so this is okay. actionType = getAlgorithm(actionRef).getActionType(); } else { // Not first time through - check that the current action uses the same action type as the first action in the task. ActionType otherActionType = null; if (actionType != (otherActionType = getAlgorithm(actionRef).getActionType())) { log.error( "{}: task cannot contain actions which have different ActionTypes. The first ActionType for this task was {}, but {} has an ActionType of {}.", task.getName(), actionType, actionRef.getName(), otherActionType); return false; } } } return true; } }
From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java
/** Check that the pipeline is not null, is valid, has a name which is unique in the PipelineManager, references valid tasks, and that the states (using provides/requires) are valid for the proposed sequence of tasks. Returns false if the pipeline. */ private boolean isValidPipeline(PipelineDefinition pipeline) { if (pipeline == null) { log.warn("pipeline must not be null"); return false; } else if (!pipeline.isValid()) { log.error("{}: pipeline is not valid"); return false; } else if (getPipeline(pipeline.getName()) != null) { log.error("{}: pipeline name is already in use", StringUtils.upperCase(pipeline.getName())); return false; }//from ww w . ja v a 2s . co m return areTasksValid(StringUtils.upperCase(pipeline.getName()), pipeline.getTaskRefs()); }
From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java
private boolean isValidDetectionPipeline(String pipelineName, List<TaskDefinitionRef> taskDefinitions, Set<StateDefinition> currentStates) { if (taskDefinitions.size() == 1) { // There's only one task in the pipeline, and we know it to be detection. boolean rValue = true; Set<StateDefinitionRef> requiredStates = requiredTaskStates .get(StringUtils.upperCase(taskDefinitions.get(0).getName())); if (!currentStates.containsAll(requiredStates)) { log.error("{}: The states for {} are not satisfied. Current: {}. Required: {}.", pipelineName, taskDefinitions.get(0).getName(), currentStates, requiredStates); rValue = false;//from w w w.ja v a2 s . c o m } return rValue; } else if (getTask(taskDefinitions.get(0)).getActions().size() > 1) { // There's more than one task, and the number of actions in the first task exceeds 1. log.error("{}: No tasks may follow the multi-detection task of {}.", pipelineName, taskDefinitions.get(0).getName()); return false; } else if (getTask(taskDefinitions.get(1)) == null) { // At this point, we've determined there's at least one more task. The next task name must exist. log.error("{}: Task with name {} does not exist.", pipelineName, taskDefinitions.get(1).getName()); return false; } else { currentStates.addAll(providedTaskStates.get(StringUtils.upperCase(taskDefinitions.get(0).getName()))); ActionType nextTaskType = getTaskType(taskDefinitions.get(1)); switch (nextTaskType) { case DETECTION: currentStates.clear(); // If the next task is detection-based, we should disregard the current states as we're downselecting. return isValidDetectionPipeline(pipelineName, taskDefinitions.subList(1, taskDefinitions.size()), currentStates); case MARKUP: return isValidMarkupPipeline(pipelineName, taskDefinitions.subList(1, taskDefinitions.size()), currentStates); default: log.error("{}: {} is a detection task and may not be followed by {}.", pipelineName, taskDefinitions.get(0).getName(), taskDefinitions.get(1).getName()); return false; } } }
From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java
private boolean isValidMarkupPipeline(String pipelineName, List<TaskDefinitionRef> taskDefinitions, Set<StateDefinition> currentStates) { if (taskDefinitions.size() == 1) { // There's only one task in the pipeline, and we know it to be markup. boolean rValue = true; Set<StateDefinitionRef> requiredStates = requiredTaskStates .get(StringUtils.upperCase(taskDefinitions.get(0).getName())); if (!currentStates.containsAll(requiredStates)) { log.error("{}: The states for {} are not satisfied. Current: {}. Required: {}.", pipelineName, taskDefinitions.get(0).getName(), currentStates, requiredStates); rValue = false;//from w w w . jav a2 s . c o m } return rValue; } else { log.error("{}: No tasks may follow a markup task of {}.", pipelineName, taskDefinitions.get(0).getName()); return false; } }
From source file:org.mitre.mpf.wfm.service.PipelineServiceImpl.java
/** Gets an ActionDefinition by name (case-insensitive). */ @Override public ActionDefinition getAction(String name) { return actions.get(StringUtils.upperCase(name)); }
From source file:org.mitre.mpf.wfm.service.PipelineServiceImpl.java
@Override public List<TaskDefinition> getTasks(String pipelineName) { List<TaskDefinition> taskDefinitions = new ArrayList<TaskDefinition>(); for (TaskDefinitionRef taskDefinitionRef : pipelines.get(StringUtils.upperCase(pipelineName)) .getTaskRefs()) {/*from ww w. j a v a 2 s. co m*/ taskDefinitions.add(getTask(taskDefinitionRef)); } return taskDefinitions; }
From source file:org.mitre.mpf.wfm.service.PipelineServiceImpl.java
/** * Gets a TaskDefinition by name (case-insensitive). */ @Override public TaskDefinition getTask(String name) { return tasks.get(StringUtils.upperCase(name)); }