@Override public List<StoredData> getAllFull() { List<StoredData> found = storedDataDAO.findAll(); for (StoredData data : found) { Resource resource = data.getResource(); if (resource != null) { List<SecurityRule> security = resourceDAO.findSecurityRules(resource.getId()); resource.setSecurity(security); List<Attribute> attribute = resourceDAO.findAttributes(resource.getId()); resource.setAttribute(attribute); } } return found; }
/** * @param list * @param includeAttributes * @param includeData * @param authUser * @return List<Resource> */ private List<Resource> configResourceList(List<Resource> list, boolean includeAttributes, boolean includeData, User authUser) { List<Resource> rList = new LinkedList<>(); for (Resource resource : list) { Resource res = new Resource(); res.setCategory(resource.getCategory()); res.setCreation(resource.getCreation()); res.setDescription(resource.getDescription()); res.setId(resource.getId()); res.setLastUpdate(resource.getLastUpdate()); res.setName(resource.getName()); if (includeData) { res.setData(resource.getData()); } if (includeAttributes) { res.setAttribute(resource.getAttribute()); } rList.add(res); } return rList; }
public static Resource convertResource(RESTResource resource) { Category category = new Category(); if (resource.getCategory().getName() != null) category.setName(resource.getCategory().getName()); if (resource.getCategory().getId() != null) category.setId(resource.getCategory().getId()); Resource r = new Resource(); r.setDescription(resource.getDescription()); r.setMetadata(resource.getMetadata()); r.setName(resource.getName()); r.setCategory(category); // Parsing Attributes list if (CollectionUtils.isNotEmpty(resource.getAttribute())) { List<Attribute> attributes = Convert.convertAttributeList(resource.getAttribute()); r.setAttribute(attributes); } RESTStoredData dataDto = resource.getStore(); if (dataDto != null) { StoredData data = new StoredData(); data.setData(dataDto.getData()); r.setData(data); } return r; }