public LocationServiceFunctionsVoCollection listLocationServiceFunction(LocationServiceVo voLocationService, ServiceFunctionVo voFunction) { DomainFactory factory = getDomainFactory(); if (voLocationService == null && voFunction == null) return LocationServiceFunctionsVoAssembler.createLocationServiceFunctionsVoCollectionFromLocationServiceFunction(factory.listDomainObjects(LocationServiceFunction.class)); String hql = " from LocationService locSer "; StringBuffer condStr = new StringBuffer(); String andStr = " "; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); if (voLocationService != null) { if (voLocationService.getID_LocationServiceIsNotNull()) { condStr.append(andStr + " locSer.locationService.id = :locServiceId"); markers.add("locServiceId"); values.add(voLocationService.getID_LocationService()); andStr = " and "; } else if ((voLocationService.getLocationIsNotNull()) && (voLocationService.getLocation().getID_LocationIsNotNull())) { // filter by location condStr.append(andStr + " locServiceActivity.locationService.location.id = :locId"); markers.add("locId"); values.add(voLocationService.getLocation().getID_Location()); andStr = " and "; } else if ((voLocationService.getServiceIsNotNull()) && (voLocationService.getService().getID_ServiceIsNotNull())) { // filter by location condStr.append(andStr + " locServiceActivity.locationService.service.id = :serId"); markers.add("serId"); values.add(voLocationService.getService().getID_Service()); andStr = " and "; } } if (voFunction != null) { // filter on Function if (voFunction.getIsActiveIsNotNull()) { condStr.append(andStr + " locServiceActivity.serviceFunction.isActive = :isActive"); markers.add("isActive"); values.add(voFunction.getIsActive()); andStr = " and "; } // filter Name if (voFunction.getFunctionIsNotNull() && !voFunction.getID_ServiceFunctionIsNotNull()) { condStr.append(andStr + " upper(locServiceActivity.serviceActivity.activity.name) like :functionName"); markers.add("functionName"); values.add("%" + voFunction.getFunction().getText().toUpperCase() + "%"); andStr = " and "; } else if (voFunction.getID_ServiceFunctionIsNotNull()) { // filter by Activity condStr.append(andStr + "locServiceActivity.serviceFunction.id = :serviceFunctionId"); markers.add("serviceFunctionId"); values.add(voFunction.getID_ServiceFunction()); andStr = " and "; } } if (andStr.equals(" and ")) hql += " where "; hql += condStr.toString(); return LocationServiceFunctionsVoAssembler.createLocationServiceFunctionsVoCollectionFromLocationServiceFunction(factory.find(hql, markers, values)).sort(); }