for(RESTSecurityRule rule : list) { SecurityRule securityRule = new SecurityRule(); Resource resource = new Resource(); resource.setId(resourceId); securityRule.setResource(resource);
/** * @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; }
Resource r = new Resource(); r.setCreation(new Date()); r.setDescription(resource.getDescription());
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; }