private Resource rbr2res(RESTBackupResource rbr, long catId) { Resource ret = Convert.convertResource(rbr.getResource()); ret.getCategory().setId(catId); // remap category return ret; }
public UNREDDResource(Resource resource) { // category sanity check if(! getCategoryName().equals(resource.getCategory().getName())) { throw new IllegalArgumentException("Bad resource category " + resource.getCategory().getName() + ": only handling " + getCategoryName()); } // copy attribs if (resource.getAttribute() != null) { // SG - when there are no attributes, resource.getAttribute() returns null - can't modify resource.getAttribute() for (Attribute a : resource.getAttribute()) { originalAttributes.put(a.getName(), a); DataType type = getAttributeMap().get(a.getName()); if(type == null) { if( ! getReverseAttributes().contains(a.getTextValue())) { LOGGER.error("Bad attribute name " + a + " for class " + this.getClass().getSimpleName()); continue; } } else if( type != a.getType()) { LOGGER.error("Bad attribute type " + a + " for class " + this.getClass().getSimpleName()); continue; } attributes.put(a.getName(), a.getValue()); } } // TODO: copy other resource info }
private RESTResource createRESTResource(Resource resource) { RESTResource ret = new RESTResource(); ret.setCategory(new RESTCategory(resource.getCategory().getName())); ret.setName(resource.getName()); ret.setDescription(resource.getDescription()); ret.setMetadata(resource.getMetadata()); if (resource.getData() != null) ret.setData(resource.getData().getData()); if (CollectionUtils.isNotEmpty(resource.getAttribute())) ret.setAttribute(Convert.convertToShortAttributeList(resource.getAttribute())); return ret; }
/** * @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; }
Category oldrc = old.getCategory(); if ((newrc.getId() != null && !newrc.getId().equals(oldrc.getId())) || (newrc.getName() != null && !newrc.getName().equals(oldrc.getName()))) {
Category category = resource.getCategory(); if (category == null) { throw new BadRequestServiceEx("Category type must be specified");