private static Category rbc2cat(RESTBackupCategory rbc) { Category ret = new Category(); ret.setName(rbc.getName()); return ret; }
@Override public Category get(SecurityContext sc, long id) throws NotFoundWebEx { if (id == -1) { if (LOGGER.isDebugEnabled()) LOGGER.debug("Retriving dummy data !"); // // return test instance // Category category = new Category(); category.setName("dummy name"); return category; } Category ret = categoryService.get(id); if (ret == null) throw new NotFoundWebEx("Category not found"); return ret; }
@Override public long insert(Category category) throws BadRequestServiceEx, NotFoundServiceEx { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Persisting Category ... "); } if (category == null) { throw new BadRequestServiceEx("Category type must be specified !"); } Category cat = new Category(); cat.setName(category.getName()); categoryDAO.persist(cat); // // // // Persisting SecurityRule // // // List<SecurityRule> rules = category.getSecurity(); // // if (rules != null) { // for (SecurityRule rule : rules) { // rule.setCategory(cat); // securityDAO.persist(rule); // } // } return cat.getId(); }
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; }