Skip to content

Commit d747c50

Browse files
committed
#165: format code
1 parent 1fd80c2 commit d747c50

File tree

8 files changed

+81
-60
lines changed

8 files changed

+81
-60
lines changed

src/main/java/de/doubleslash/keeptime/controller/Controller.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.ArrayList;
2323
import java.util.List;
2424

25-
import javafx.application.Platform;
2625
import org.slf4j.Logger;
2726
import org.slf4j.LoggerFactory;
2827
import org.springframework.stereotype.Service;
@@ -35,7 +34,6 @@
3534
import de.doubleslash.keeptime.model.Settings;
3635
import de.doubleslash.keeptime.model.Work;
3736
import jakarta.annotation.PreDestroy;
38-
import javafx.collections.ObservableList;
3937

4038
@Service
4139
public class Controller {
@@ -253,10 +251,14 @@ public void deleteWork(final Work workToBeDeleted) {
253251
/**
254252
* Changes the indexes of the originalList parameter to have a consistent order.
255253
*
256-
* @param originalList list of all projects to adapt the indexes for
257-
* @param changedProject the project which has changed which already has the new index
258-
* @param oldIndex the old index of the changed project
259-
* @param newIndex the new index of the changed project (which the projects also already has)
254+
* @param originalList
255+
* list of all projects to adapt the indexes for
256+
* @param changedProject
257+
* the project which has changed which already has the new index
258+
* @param oldIndex
259+
* the old index of the changed project
260+
* @param newIndex
261+
* the new index of the changed project (which the projects also already has)
260262
* @return all projects whose index has been adapted
261263
*/
262264
List<Project> resortProjectIndexes(final List<Project> originalList, final Project changedProject,
@@ -292,8 +294,10 @@ List<Project> resortProjectIndexes(final List<Project> originalList, final Proje
292294
/**
293295
* Decreases all indexes by one, after the removed index
294296
*
295-
* @param originalList list of all projects to adapt the indexes for
296-
* @param removedIndex the index which has been removed
297+
* @param originalList
298+
* list of all projects to adapt the indexes for
299+
* @param removedIndex
300+
* the index which has been removed
297301
* @return all projects whose index has been adapted
298302
*/
299303
List<Project> adaptProjectIndexesAfterRemoving(final List<Project> originalList, final int removedIndex) {

src/main/java/de/doubleslash/keeptime/model/Work.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818

1919
import java.time.LocalDateTime;
2020

21-
import jakarta.persistence.*;
21+
import jakarta.persistence.Column;
22+
import jakarta.persistence.Entity;
23+
import jakarta.persistence.GeneratedValue;
24+
import jakarta.persistence.GenerationType;
25+
import jakarta.persistence.Id;
26+
import jakarta.persistence.Lob;
27+
import jakarta.persistence.ManyToOne;
28+
import jakarta.persistence.Table;
2229

2330
@Entity
2431
@Table(name = "Work")
@@ -35,8 +42,7 @@ public class Work {
3542
@Lob
3643
private String notes;
3744

38-
public Work() {
39-
}
45+
public Work() {}
4046

4147
public Work(final LocalDateTime startTime, final LocalDateTime endTime, final Project project, final String notes) {
4248
super();

src/main/java/de/doubleslash/keeptime/rest/DTO/ProjectDTO.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ public class ProjectDTO {
3333
private int index;
3434
private boolean isEnabled;
3535

36-
public ProjectDTO( long id, String name, String description, String color, boolean isWork, int index, boolean isEnabled) {
37-
this.id= id;
36+
public ProjectDTO(long id, String name, String description, String color, boolean isWork, int index,
37+
boolean isEnabled) {
38+
this.id = id;
3839
this.name = name;
3940
this.description = description;
4041
this.color = color;

src/main/java/de/doubleslash/keeptime/rest/DTO/ProjectIdentificationDTO.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
public class ProjectIdentificationDTO {
2020
private long id;
21-
public ProjectIdentificationDTO(){}
21+
22+
public ProjectIdentificationDTO() {}
23+
2224
public ProjectIdentificationDTO(final long id) {
2325
this.id = id;
2426
}

src/main/java/de/doubleslash/keeptime/rest/DTO/WorkDTO.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
package de.doubleslash.keeptime.rest.DTO;
1818

19-
import jakarta.validation.constraints.NotNull;
20-
2119
import java.time.LocalDateTime;
2220

21+
import jakarta.validation.constraints.NotNull;
22+
2323
public class WorkDTO {
2424
private long id;
2525

@@ -34,7 +34,8 @@ public class WorkDTO {
3434

3535
private String notes;
3636

37-
public WorkDTO(long id, LocalDateTime startTime, LocalDateTime endTime, ProjectIdentificationDTO project, String notes) {
37+
public WorkDTO(long id, LocalDateTime startTime, LocalDateTime endTime, ProjectIdentificationDTO project,
38+
String notes) {
3839
this.id = id;
3940
this.startTime = startTime;
4041
this.endTime = endTime;

src/main/java/de/doubleslash/keeptime/rest/controller/ProjectController.java

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,36 @@
1616

1717
package de.doubleslash.keeptime.rest.controller;
1818

19-
import de.doubleslash.keeptime.rest.DTO.ProjectDTO;
20-
import de.doubleslash.keeptime.rest.DTO.ProjectIdentificationDTO;
21-
import de.doubleslash.keeptime.rest.DTO.WorkDTO;
22-
import de.doubleslash.keeptime.rest.mapper.ProjectMapper;
23-
import de.doubleslash.keeptime.rest.mapper.WorkMapper;
19+
import java.util.List;
20+
import java.util.Optional;
21+
22+
import org.springframework.dao.DataAccessException;
23+
import org.springframework.http.HttpStatus;
24+
import org.springframework.http.ResponseEntity;
25+
import org.springframework.web.bind.annotation.DeleteMapping;
26+
import org.springframework.web.bind.annotation.GetMapping;
27+
import org.springframework.web.bind.annotation.PathVariable;
28+
import org.springframework.web.bind.annotation.PostMapping;
29+
import org.springframework.web.bind.annotation.PutMapping;
30+
import org.springframework.web.bind.annotation.RequestBody;
31+
import org.springframework.web.bind.annotation.RequestMapping;
32+
import org.springframework.web.bind.annotation.RequestParam;
33+
import org.springframework.web.bind.annotation.ResponseStatus;
34+
import org.springframework.web.bind.annotation.RestController;
35+
import org.springframework.web.server.ResponseStatusException;
36+
2437
import de.doubleslash.keeptime.controller.Controller;
2538
import de.doubleslash.keeptime.model.Model;
2639
import de.doubleslash.keeptime.model.Project;
2740
import de.doubleslash.keeptime.model.Work;
2841
import de.doubleslash.keeptime.model.repos.ProjectRepository;
2942
import de.doubleslash.keeptime.model.repos.WorkRepository;
30-
import org.springframework.dao.DataAccessException;
31-
import org.springframework.http.HttpStatus;
32-
import org.springframework.http.ResponseEntity;
33-
import org.springframework.web.bind.annotation.*;
34-
import org.springframework.web.server.ResponseStatusException;
35-
43+
import de.doubleslash.keeptime.rest.DTO.ProjectDTO;
44+
import de.doubleslash.keeptime.rest.DTO.ProjectIdentificationDTO;
45+
import de.doubleslash.keeptime.rest.DTO.WorkDTO;
46+
import de.doubleslash.keeptime.rest.mapper.ProjectMapper;
47+
import de.doubleslash.keeptime.rest.mapper.WorkMapper;
3648
import jakarta.validation.Valid;
37-
import java.util.List;
38-
import java.util.Optional;
3949

4050
@RestController
4151
@RequestMapping("/api/projects")
@@ -67,9 +77,7 @@ public ResponseEntity<List<ProjectDTO>> getProjectColorDTOsByName(
6777
} else {
6878
projects = projectRepository.findAll();
6979
}
70-
List<ProjectDTO> projectDTOS = projects.stream()
71-
.map(projectMapper::projectToProjectDTO)
72-
.toList();
80+
List<ProjectDTO> projectDTOS = projects.stream().map(projectMapper::projectToProjectDTO).toList();
7381
return ResponseEntity.ok(projectDTOS);
7482
}
7583

@@ -93,7 +101,7 @@ public ResponseEntity<ProjectDTO> createProject(@Valid @RequestBody final Projec
93101
try {
94102
Project newProject = projectMapper.projectDTOToProject(newProjectDTO);
95103

96-
FXUtils.runInFxThreadAndWait(()-> controller.addNewProject(newProject));
104+
FXUtils.runInFxThreadAndWait(() -> controller.addNewProject(newProject));
97105

98106
ProjectDTO projectDTO = projectMapper.projectToProjectDTO(newProject);
99107
return ResponseEntity.status(HttpStatus.CREATED).body(projectDTO);
@@ -106,7 +114,7 @@ public ResponseEntity<ProjectDTO> createProject(@Valid @RequestBody final Projec
106114
public ResponseEntity<ProjectDTO> updateProject(@PathVariable final long id,
107115
@Valid @RequestBody final ProjectDTO newValuedProjectDTO) {
108116

109-
if(id != newValuedProjectDTO.getId()){
117+
if (id != newValuedProjectDTO.getId()) {
110118
return ResponseEntity.badRequest().build();
111119
}
112120
Optional<Project> optionalProject = projectRepository.findById(id);
@@ -120,8 +128,7 @@ public ResponseEntity<ProjectDTO> updateProject(@PathVariable final long id,
120128
try {
121129
Project newValuedProject = projectMapper.projectDTOToProject(newValuedProjectDTO);
122130

123-
FXUtils.runInFxThreadAndWait(()->
124-
controller.editProject(existingProject, newValuedProject));
131+
FXUtils.runInFxThreadAndWait(() -> controller.editProject(existingProject, newValuedProject));
125132

126133
ProjectDTO updatedProjectDTO = projectMapper.projectToProjectDTO(existingProject);
127134

@@ -135,7 +142,7 @@ public ResponseEntity<ProjectDTO> updateProject(@PathVariable final long id,
135142
public ResponseEntity<WorkDTO> createWorkInProject(@PathVariable final long id,
136143
@Valid @RequestBody final WorkDTO workDTO) {
137144

138-
if(id != workDTO.getProject().getId()){
145+
if (id != workDTO.getProject().getId()) {
139146
return ResponseEntity.badRequest().build();
140147
}
141148

@@ -169,8 +176,7 @@ public ResponseEntity<String> deleteProject(@PathVariable final long id) {
169176
if (project.isDefault()) {
170177
return new ResponseEntity<>("Project cannot be deleted as it is the default", HttpStatus.BAD_REQUEST);
171178
}
172-
FXUtils.runInFxThreadAndWait(()->
173-
controller.deleteProject(project));
179+
FXUtils.runInFxThreadAndWait(() -> controller.deleteProject(project));
174180

175181
return new ResponseEntity<>("Project successfully deleted", HttpStatus.OK);
176182
}
@@ -182,16 +188,16 @@ public ProjectDTO getWorkProjects() {
182188
}
183189

184190
@PutMapping("/current")
185-
public ResponseEntity<ProjectIdentificationDTO> changeProject(@Valid @RequestBody ProjectIdentificationDTO newProject) {
191+
public ResponseEntity<ProjectIdentificationDTO> changeProject(
192+
@Valid @RequestBody ProjectIdentificationDTO newProject) {
186193
Optional<Project> projectOptional = projectRepository.findById(newProject.getId());
187194

188195
if (projectOptional.isEmpty()) {
189196
return ResponseEntity.notFound().build();
190197
}
191198

192199
try {
193-
FXUtils.runInFxThreadAndWait(()->
194-
controller.changeProject(projectOptional.get()));
200+
FXUtils.runInFxThreadAndWait(() -> controller.changeProject(projectOptional.get()));
195201

196202
return ResponseEntity.ok(newProject);
197203
} catch (Exception e) {

src/main/java/de/doubleslash/keeptime/rest/controller/WorksController.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616

1717
package de.doubleslash.keeptime.rest.controller;
1818

19-
import de.doubleslash.keeptime.rest.DTO.WorkDTO;
20-
import de.doubleslash.keeptime.rest.mapper.WorkMapper;
21-
import de.doubleslash.keeptime.model.Model;
22-
import de.doubleslash.keeptime.model.Project;
23-
import de.doubleslash.keeptime.model.Work;
24-
import de.doubleslash.keeptime.model.repos.ProjectRepository;
25-
import de.doubleslash.keeptime.model.repos.WorkRepository;
19+
import java.util.List;
20+
import java.util.Optional;
21+
import java.util.stream.Stream;
22+
2623
import org.springframework.http.HttpStatus;
2724
import org.springframework.http.ResponseEntity;
2825
import org.springframework.web.bind.annotation.DeleteMapping;
@@ -34,9 +31,13 @@
3431
import org.springframework.web.bind.annotation.RequestParam;
3532
import org.springframework.web.bind.annotation.RestController;
3633

37-
import java.util.List;
38-
import java.util.Optional;
39-
import java.util.stream.Stream;
34+
import de.doubleslash.keeptime.model.Model;
35+
import de.doubleslash.keeptime.model.Project;
36+
import de.doubleslash.keeptime.model.Work;
37+
import de.doubleslash.keeptime.model.repos.ProjectRepository;
38+
import de.doubleslash.keeptime.model.repos.WorkRepository;
39+
import de.doubleslash.keeptime.rest.DTO.WorkDTO;
40+
import de.doubleslash.keeptime.rest.mapper.WorkMapper;
4041

4142
@RestController
4243
@RequestMapping("/api/works")
@@ -47,9 +48,10 @@ public class WorksController {
4748
private final Model model;
4849
private final WorkMapper workMapper;
4950

50-
public WorksController(final WorkRepository workRepository,final ProjectRepository projectRepository, Model model, WorkMapper workMapper) {
51+
public WorksController(final WorkRepository workRepository, final ProjectRepository projectRepository, Model model,
52+
WorkMapper workMapper) {
5153
this.workRepository = workRepository;
52-
this.projectRepository=projectRepository;
54+
this.projectRepository = projectRepository;
5355
this.model = model;
5456
this.workMapper = workMapper;
5557
}
@@ -69,7 +71,7 @@ public List<WorkDTO> getWorks(@RequestParam(name = "name", required = false) fin
6971
@PutMapping("/{id}")
7072
public ResponseEntity<WorkDTO> editWork(@PathVariable("id") Long workId, @RequestBody WorkDTO newValuedWorkDTO) {
7173

72-
if(workId != newValuedWorkDTO.getId() ){
74+
if (workId != newValuedWorkDTO.getId()) {
7375
return ResponseEntity.badRequest().build();
7476
}
7577

src/main/java/de/doubleslash/keeptime/rest/mapper/WorkMapper.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616

1717
package de.doubleslash.keeptime.rest.mapper;
1818

19-
import de.doubleslash.keeptime.rest.DTO.WorkDTO;
20-
import de.doubleslash.keeptime.model.Work;
2119
import org.mapstruct.Mapper;
2220

21+
import de.doubleslash.keeptime.model.Work;
22+
import de.doubleslash.keeptime.rest.DTO.WorkDTO;
23+
2324
@Mapper(componentModel = "spring")
2425
public interface WorkMapper {
2526

2627
WorkDTO workToWorkDTO(Work work);
2728

2829
Work workDTOToWork(WorkDTO workDTO);
2930
}
30-
31-

0 commit comments

Comments
 (0)