public ims.core.vo.LocationServiceVo saveLocationService(ims.core.vo.LocationServiceVo locationService) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.ForeignKeyViolationException, ims.domain.exceptions.UniqueKeyViolationException { DomainFactory factory = getDomainFactory(); LocationService doLocService = LocationServiceVoAssembler.extractLocationService(factory, locationService); try { factory.save(doLocService); locationService = LocationServiceVoAssembler.create(doLocService); } catch (UnqViolationUncheckedException e) { throw new UniqueKeyViolationException(locationService.getService().getServiceName().toString() + " already exists. Duplicates not allowed.", e); } return locationService; }
public void removeLocationService(ims.core.vo.LocationServiceVo voLocationService) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.ForeignKeyViolationException { DomainFactory factory = getDomainFactory(); LocationService doLocService = LocationServiceVoAssembler.extractLocationService(factory, voLocationService); try { try { factory.delete(doLocService); } catch (ForeignKeyViolationException e) { throw new ForeignKeyViolationException(e.getMessage()); } } catch (DomainRuntimeException re) // SN: catching // DomainRuntimeException here as // this is what Hib is returning // with e.getCause() = // ConstrainViolationException { throw new ForeignKeyViolationException(re.getMessage()); } return; }
/** * expects parameters returns null if the parameters are not set */ public LocationServiceVoCollection listServicesForLocation(LocationRefVo location, ServiceVo service) { DomainFactory factory = getDomainFactory(); if (location == null || service == null) return null; if (location.getID_LocationIsNotNull() && service.getID_ServiceIsNotNull()) { java.util.List servactList = factory.find("from LocationService locService where locService.location.id = :locationId and locService.service.id = :serviceId", new String[]{"locationId", "serviceId"}, new Object[]{location.getID_Location(), service.getID_Service()}); return LocationServiceVoAssembler.createLocationServiceVoCollectionFromLocationService(servactList).sort(); } return null; }
public LocationServiceVo getLocationService(LocShortVo locShort, ServiceRefVo service) { if (locShort == null || service == null) throw new DomainRuntimeException("Failed to get LocationService record, location and/or service not supplied"); DomainFactory factory = getDomainFactory(); List lstLocService = factory.find("from LocationService locService where locService.location.id = :locationId and locService.service.id = :serviceId", new String[]{"locationId", "serviceId"}, new Object[]{locShort.getID_Location(), service.getID_Service()}); LocationServiceVoCollection voCollLocServices = LocationServiceVoAssembler.createLocationServiceVoCollectionFromLocationService(lstLocService); if (voCollLocServices != null && voCollLocServices.size() > 0) return voCollLocServices.get(0); return null; }
public LocationServiceVoCollection listLocationServices(ServiceRefVo service) { if (service == null) throw new CodingRuntimeException("Service was not supplied. Mandatory argument"); DomainFactory factory = getDomainFactory(); String hql = "from LocationService ls " + " where ls.service.id = :id and ls.isActive = :active"; List services = factory.find(hql, new String[]{"id", "active"}, new Object[]{service.getID_Service(), Boolean.TRUE}); return LocationServiceVoAssembler.createLocationServiceVoCollectionFromLocationService(services).sort(); }
public LocationServiceVo getLocationService(LocationRefVo location, ServiceRefVo service) { if(location == null || service == null) throw new CodingRuntimeException("location and service are madatory in method getLocationService"); DomainFactory factory = getDomainFactory(); List locServics = factory.find("from LocationService locSer where locSer.location.id = :idLocation and locSer.service.id = :idService", new String[] {"idLocation", "idService"}, new Object[] { location.getID_Location(), service.getID_Service()}); if(locServics != null && locServics.size() > 0) return LocationServiceVoAssembler.create((ims.core.resource.place.domain.objects.LocationService) locServics.get(0)); return null; }
public LocationServiceVoCollection listLocationService(LocationRefVo voLocation) { DomainFactory factory = getDomainFactory(); if (voLocation == null) return LocationServiceVoAssembler.createLocationServiceVoCollectionFromLocationService(factory.listDomainObjects(LocationService.class)).sort(); if (voLocation.getID_LocationIsNotNull()) { java.util.List servactList = factory.find("from LocationService locService where locService.location.id = :locationId", new String[]{"locationId"}, new Object[]{voLocation.getID_Location()}); return LocationServiceVoAssembler.createLocationServiceVoCollectionFromLocationService(servactList).sort(); } return null; }
public ims.core.vo.LocationServiceVoCollection listLocationService(ims.core.vo.LocationServiceVo locationService) { DomainFactory factory = getDomainFactory(); if (locationService == null) return LocationServiceVoAssembler.createLocationServiceVoCollectionFromLocationService(factory.listDomainObjects(LocationService.class)); String hql = " from LocationService locService "; StringBuffer condStr = new StringBuffer(); String andStr = " "; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); if (locationService.getLocationIsNotNull()) { condStr.append(andStr + " locService.location.id = :locationId"); markers.add("locationId"); values.add(locationService.getLocation().getID_Location()); andStr = " and "; } if (locationService.getServiceIsNotNull() && locationService.getService().getID_ServiceIsNotNull()) { condStr.append(andStr + " locService.service.id = :serviceId"); markers.add("serviceId"); values.add(locationService.getService().getID_Service()); andStr = " and "; } if (locationService.getServiceIsNotNull() && locationService.getService().getServiceName() != null) { condStr.append(andStr + " upper(locService.service.serviceName) like :serviceName"); markers.add("serviceName"); values.add(locationService.getService().getServiceName().toUpperCase() + "%"); andStr = " and "; } if (locationService.getIsActiveIsNotNull()) { condStr.append(andStr + " locService.isActive = :isActive"); markers.add("isActive"); values.add(locationService.getIsActive()); andStr = " and "; } if (andStr.equals(" and ")) hql += " where "; hql += condStr.toString(); return LocationServiceVoAssembler.createLocationServiceVoCollectionFromLocationService(factory.find(hql, markers, values)).sort(); }
public ims.core.vo.LocationServiceVoCollection listLocationService(ims.core.vo.LocationServiceVo locationService) { DomainFactory factory = getDomainFactory(); if (locationService == null) return LocationServiceVoAssembler.createLocationServiceVoCollectionFromLocationService(factory.listDomainObjects(LocationService.class)); String hql = " from LocationService locService "; StringBuffer condStr = new StringBuffer(); String andStr = " "; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); if (locationService.getLocationIsNotNull()) { condStr.append(andStr + " locService.location.id = :locationId"); markers.add("locationId"); values.add(locationService.getLocation().getID_Location()); andStr = " and "; } if (locationService.getServiceIsNotNull() && locationService.getService().getID_ServiceIsNotNull()) { condStr.append(andStr + " locService.service.id = :serviceId"); markers.add("serviceId"); values.add(locationService.getService().getID_Service()); andStr = " and "; } if (locationService.getServiceIsNotNull() && locationService.getService().getServiceName() != null) { condStr.append(andStr + " locService.service.upperName like :serviceName"); //WDEV-20219 upper(locService.service.serviceName) markers.add("serviceName"); values.add(locationService.getService().getServiceName().toUpperCase() + "%"); andStr = " and "; } if (locationService.getIsActiveIsNotNull()) { condStr.append(andStr + " locService.isActive = :isActive"); markers.add("isActive"); values.add(locationService.getIsActive()); andStr = " and "; } if (andStr.equals(" and ")) hql += " where "; hql += condStr.toString(); return LocationServiceVoAssembler.createLocationServiceVoCollectionFromLocationService(factory.find(hql, markers, values)).sort(); }