/**
* Loads a list of service request priority levels filter with the input parameter
*
* @param filter - the filter to filter out the service request priority levels does not match
* @return the list of service request priority levels
* @throws Exception
*/
public ArrayList<ServiceRequestPriotityLevel> getPriorityLevels(String filter) throws Exception {
ArrayList<ServiceRequestPriotityLevel> priorityLevels = new ArrayList<ServiceRequestPriotityLevel>();
CRMDOServiceRequestDefinition serviceRequestDefinition = (CRMDOServiceRequestDefinition)serviceRequestDefinitionBean.loadActiveDefinition();
ArrayList<CRMDO> definitionPriorities = serviceRequestDefinitionPriorityBean.load(serviceRequestDefinition);
if (filter!=null)
{
filter = filter.replace("%", "");
filter = filter.replace("_", "");
}
if (definitionPriorities!=null && definitionPriorities.size() > 0)
{
for (int i=0; i<definitionPriorities.size(); i++)
{
CRMDOServiceRequestDefinitionPriority definitionPriority = (CRMDOServiceRequestDefinitionPriority)definitionPriorities.get(i);
if(definitionPriority.getLabel()!=null)
{
if (filter==null || filter.length() ==0 || definitionPriority.getLabel().toUpperCase().contains(filter.toUpperCase()))
{
ServiceRequestPriotityLevel serviceRequestPriotityLevel = new ServiceRequestPriotityLevel();
serviceRequestPriotityLevel.setPriorityLevelId(definitionPriority.getPriorityCode());
serviceRequestPriotityLevel.setPriorityLevelName(definitionPriority.getLabel());
priorityLevels.add(serviceRequestPriotityLevel);
}
}
else
{
if (filter==null || filter.length() ==0 || definitionPriority.getPriorityCode().toString().toUpperCase().contains(filter.toUpperCase()))
{
ServiceRequestPriotityLevel serviceRequestPriotityLevel = new ServiceRequestPriotityLevel();
serviceRequestPriotityLevel.setPriorityLevelId(definitionPriority.getPriorityCode());
serviceRequestPriotityLevel.setPriorityLevelName(definitionPriority.getPriorityCode().toString());
priorityLevels.add(serviceRequestPriotityLevel);
}
}
}
}
return priorityLevels;
} |