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 Integer store(EnvironmentRest environmentRest) { Preconditions.checkArgument(environmentRest.getId() == null, "Id must be null"); return environmentRepository.save(environmentRest.toEnvironment()).getId(); }