/** * Returns only extensions of the type specified. Note: at this point the entity item is a * transient object. */ public List<Extension> getExtensionsByType(EntityType entityType) { List<Extension> list = new ArrayList<Extension>(); if (entityItem != null) { for (Extension e : entityItem.getExtensions()) { if (e.getClassExtension().getEntityClass().equals(entityType)) list.add(e); } } return list; }
/** * Returns only extensions of type Location and sets the entityExtId automatically. Note: at this * point the entity item is a transient object. */ public List<Extension> getAllLocationExtensions() { List<Extension> list = new ArrayList<Extension>(); for (Extension e : entityItem.getExtensions()) { if (e.getClassExtension().getEntityClass().equals(EntityType.LOCATION)) { e.setEntityExtId(entityItem.getVisitLocation().getExtId()); list.add(e); } } return list; }
/** * Returns only extensions of type Visit and sets the entityExtId automatically. Note: at this * point the entity item is a transient object. */ public List<Extension> getAllVisitExtensions() throws ConstraintViolations { List<Extension> list = new ArrayList<Extension>(); for (Extension e : entityItem.getExtensions()) { if (e.getClassExtension().getEntityClass().equals(EntityType.VISIT)) { e.setEntityExtId(service.generateId(entityItem).getExtId()); list.add(e); } } return list; }
/** * Given the entity type, clear extensions for the current entity item. Note: at this point, * entity item is a transient object. */ private void clearExtensionsByType(EntityType entityType) { List<Extension> list = new ArrayList<Extension>(); int size = service .getExtensionsByEntityClassAndRoundNumber(entityType, entityItem.getRoundNumber()) .size(); for (Extension e : entityItem.getExtensions()) { if (e.getClassExtension().getEntityClass().equals(entityType) && e.getClassExtension().getRoundNumber().equals(entityItem.getRoundNumber())) list.add(e); } int count = 0; for (Extension e : list) { if (count >= size) entityItem.getExtensions().remove(e); count++; } extensionsInitialized = false; }