コード例 #1
0
 @Autowired
 @Lazy
 public ProjectRepository(TaskRepository taskRepository) {
   this.taskRepository = taskRepository;
   Project project = new Project(123L);
   project.setName("Great Project");
   save(project);
 }
コード例 #2
0
 @JsonApiFindOne
 public Project findOne(Long projectId, QueryParams requestParams) {
   if (projectId == null) {
     return null;
   }
   Project project = REPOSITORY.get(projectId);
   if (project == null) {
     throw new ResourceNotFoundException("Project not found!");
   }
   if (project.getTasks().isEmpty()) {
     Iterable<Task> tasks = taskRepository.findAll(null);
     tasks.forEach(
         task -> {
           if (task.getProjectId().equals(project.getId())) {
             project.getTasks().add(task);
           }
         });
     save(project);
   }
   return project;
 }