public void update(Integer id, EnvironmentRest environmentRest) { Preconditions.checkArgument(id != null, "Id must not be null"); Preconditions.checkArgument( environmentRest.getId() == null || environmentRest.getId().equals(id), "Entity id does not match the id to update"); environmentRest.setId(id); Environment license = environmentRepository.queryById(environmentRest.getId()); Preconditions.checkArgument( license != null, "Couldn't find environment with id " + environmentRest.getId()); environmentRepository.save(environmentRest.toEnvironment()); }
public EnvironmentRest getSpecific(Integer environmentId) { Environment environment = environmentRepository.queryById(environmentId); if (environment != null) { return toRestModel().apply(environment); } return null; }
public List<EnvironmentRest> getAll( int pageIndex, int pageSize, String sortingRsql, String query) { Predicate<Environment> rsqlPredicate = rsqlPredicateProducer.getPredicate(Environment.class, query); PageInfo pageInfo = pageInfoProducer.getPageInfo(pageIndex, pageSize); SortInfo sortInfo = sortInfoProducer.getSortInfo(sortingRsql); return nullableStreamOf( environmentRepository.queryWithPredicates(pageInfo, sortInfo, rsqlPredicate)) .map(toRestModel()) .collect(Collectors.toList()); }
public void delete(Integer environmentId) { Preconditions.checkArgument( environmentRepository.queryById(environmentId) != null, "Couldn't find environment with id " + environmentId); environmentRepository.delete(environmentId); }
public Integer store(EnvironmentRest environmentRest) { Preconditions.checkArgument(environmentRest.getId() == null, "Id must be null"); return environmentRepository.save(environmentRest.toEnvironment()).getId(); }