Changeset 348:d91f6bd7d381 for kraken-dom/src/main/java/org/krakenapps/dom/api/impl/HostApiImpl.java
- Timestamp:
- 09/20/11 03:16:11 (8 months ago)
- Branch:
- default
- Convert:
- svn:7c3792e6-d75b-4784-96a6-b298f655ee64/trunk@2782
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kraken-dom/src/main/java/org/krakenapps/dom/api/impl/HostApiImpl.java
r2 r348 59 59 EntityManager em = entityManagerService.getEntityManager(); 60 60 try { 61 return (HostExtension) em.createQuery("FROM HostExtension e WHERE e.className = ?") .setParameter(1,62 className).getSingleResult();61 return (HostExtension) em.createQuery("FROM HostExtension e WHERE e.className = ?") 62 .setParameter(1, className).getSingleResult(); 63 63 } catch (NoResultException e) { 64 64 return null; … … 83 83 84 84 @Override 85 public int createHost(int organizationId, int hostTypeId, int areaId, String name, String description) {85 public Host createHost(int organizationId, int hostTypeId, int areaId, String name, String description) { 86 86 Host host = createHostInternal(organizationId, hostTypeId, areaId, name, description); 87 87 fireEntityAdded(host); 88 return host .getId();88 return host; 89 89 } 90 90 … … 129 129 130 130 @Override 131 public voidupdateHost(int organizationId, int hostId, String name, String description) {131 public Host updateHost(int organizationId, int hostId, String name, String description) { 132 132 Host host = updateHostInternal(organizationId, hostId, name, description); 133 133 fireEntityUpdated(host); 134 return host; 134 135 } 135 136 … … 154 155 } 155 156 156 @ Transactional157 @Override158 public void updateHostGuid(int organizationId, int hostId, String guid) {159 EntityManager em = entityManagerService.getEntityManager();160 161 try {162 Host host = getHost(organizationId, hostId); 163 if (host == null)164 throw new HostNotFoundException();165 166 host.setGuid(guid);167 em.merge(host);168 169 fireEntityUpdated(host); 170 } catch (NoResultException e) {171 throw new HostNotFoundException();172 }157 @Override 158 public Host updateHostGuid(int organizationId, int hostId, String guid) { 159 Host host = updateHostGuidInternal(organizationId, hostId, guid); 160 fireEntityUpdated(host); 161 return host; 162 } 163 164 @Transactional 165 private Host updateHostGuidInternal(int organizationId, int hostId, String guid) { 166 EntityManager em = entityManagerService.getEntityManager(); 167 Host host = getHost(organizationId, hostId); 168 if (host == null) 169 throw new HostNotFoundException(); 170 171 host.setGuid(guid); 172 em.merge(host); 173 return host; 173 174 } 174 175 … … 206 207 EntityManager em = entityManagerService.getEntityManager(); 207 208 try { 208 Host host = (Host) em.createNamedQuery("Host.findById").setParameter(1, organizationId) .setParameter(2,209 hostId).getSingleResult();209 Host host = (Host) em.createNamedQuery("Host.findById").setParameter(1, organizationId) 210 .setParameter(2, hostId).getSingleResult(); 210 211 211 212 host.getExtensions().size(); // force loading … … 225 226 } 226 227 227 @Transactional 228 @Override 229 public void moveHost(int organizationId, int hostId, int areaId) { 228 @Override 229 public Host moveHost(int organizationId, int hostId, int areaId) { 230 Host host = moveHostInternal(organizationId, hostId, areaId); 231 fireEntityUpdated(host); 232 return host; 233 } 234 235 @Transactional 236 private Host moveHostInternal(int organizationId, int hostId, int areaId) { 230 237 EntityManager em = entityManagerService.getEntityManager(); 231 238 … … 238 245 239 246 em.merge(host); 240 }241 242 @Override 243 public void removeHost(int organizationId, int hostId) {244 Host host = getHost(organizationId, hostId);245 if (host == null)246 throw new HostNotFoundException();247 247 return host; 248 } 249 250 @Override 251 public Host removeHost(int organizationId, int hostId) { 252 Host host = getHost(organizationId, hostId); 253 if (host == null) 254 throw new HostNotFoundException(); 248 255 fireEntityRemoving(host); 249 256 removeHostInternal(organizationId, hostId); 250 257 fireEntityRemoved(host); 258 return host; 251 259 } 252 260 … … 255 263 EntityManager em = entityManagerService.getEntityManager(); 256 264 Host host = getHost(organizationId, hostId); 257 258 265 host.getExtensions().clear(); 259 260 266 em.remove(host); 261 267 } 262 268 263 @Transactional 264 @Override 265 public void mapHostExtensions(int organizationId, int hostId, Set<String> hostExtensionNames) { 269 @Override 270 public Host mapHostExtensions(int organizationId, int hostId, Set<String> hostExtensionNames) { 271 Host host = mapHostExtensionsInternal(organizationId, hostId, hostExtensionNames); 272 fireEntityUpdated(host); 273 return host; 274 } 275 276 @Transactional 277 private Host mapHostExtensionsInternal(int organizationId, int hostId, Set<String> hostExtensionNames) { 266 278 EntityManager em = entityManagerService.getEntityManager(); 267 279 Host host = getHost(organizationId, hostId); … … 280 292 em.merge(host); 281 293 } 294 295 return host; 282 296 } 283 297 … … 292 306 } 293 307 294 @Transactional 295 @Override 296 public void unmapHostExtensions(int organizationId, int hostId, Set<String> hostExtensionNames) { 308 @Override 309 public Host unmapHostExtensions(int organizationId, int hostId, Set<String> hostExtensionNames) { 310 Host host = unmapHostExtensionsInternal(organizationId, hostId, hostExtensionNames); 311 fireEntityUpdated(host); 312 return host; 313 } 314 315 @Transactional 316 private Host unmapHostExtensionsInternal(int organizationId, int hostId, Set<String> hostExtensionNames) { 297 317 EntityManager em = entityManagerService.getEntityManager(); 298 318 Host host = getHost(organizationId, hostId); … … 311 331 em.merge(host); 312 332 } 333 334 return host; 313 335 } 314 336
Note: See TracChangeset
for help on using the changeset viewer.
