diff --git a/.github/workflows/format-action.yml b/.github/workflows/format-action.yml
index 8ab0c9dd70..09bfaddb62 100644
--- a/.github/workflows/format-action.yml
+++ b/.github/workflows/format-action.yml
@@ -3,7 +3,7 @@ name: 'Format'
on: [push]
jobs:
- Frontend:
+ frontend:
runs-on: ubuntu-latest
defaults:
run:
@@ -15,33 +15,19 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
- node-version: 22.10.0
+ node-version: ${{vars.NODE_VERSION}}
- name: Npm install
run: npm ci
- name: Format frontend
- run: npm run format
+ run: npm run check-linting:all
- - name: Commit and Push formated frontend
- shell: bash
- env:
- COMMITPREFIX: '[FM]'
- run: |
- git config --global user.email "actions@github.com"
- git config --global user.name "GitHub Actions"
- git add . || {
- echo "No files were changed, so we did not commit anything"
- exit 1
- }
- git commit -m "$COMMITPREFIX Automated formating frontend" || {
- echo "No changes to commit, skipping push"
- exit 0
- }
- git push -f
-
- Backend:
+ backend:
runs-on: ubuntu-latest
+ defaults:
+ run:
+ working-directory: backend
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -55,21 +41,4 @@ jobs:
settings-path: ${{github.workspace}}
- name: Format backend
- run: mvn formatter:format -f backend/pom.xml
-
- - name: Commit and Push formated backend
- shell: bash
- env:
- COMMITPREFIX: '[FM]'
- run: |
- git config --global user.email "actions@github.com"
- git config --global user.name "GitHub Actions"
- git add . || {
- echo "No files were changed, so we did not commit anything"
- exit 1
- }
- git commit -m "$COMMITPREFIX Automated formating backend" || {
- echo "No changes to commit, skipping push"
- exit 0
- }
- git push -f
\ No newline at end of file
+ run: mvn spotless:check
\ No newline at end of file
diff --git a/backend/README.md b/backend/README.md
index 127c7150a1..411c2aebf6 100644
--- a/backend/README.md
+++ b/backend/README.md
@@ -33,17 +33,23 @@ USING DOCKER
- backend/target
Formatting:
-- Check code formatting: `mvn formatter:validate`
-- Format the code: `mvn formatter:format`
+- Check code formatting: `mvn spotless:check`
+- Format the code: `mvn spotless:apply`
-The `compile` goal execute also a `formatter:format` goal.
+We also run the formatter with `spotless:apply` in the `compile` goal.
Verify the Backend for coverage check:
- `mvn clean verify`
## Formatting
-We use the **formatter-maven-plugin** Plugin for formatting the Java code:
-https://code.revelc.net/formatter-maven-plugin/
-
+We use the ***spotless*** Plugin for formatting the Java code:
+https://github.com/diffplug/spotless
+
+### How to update the spotless configuration using intelij:
+- Open `Go to Settings -> Editor -> Code styles -> Java`
+- Select the default project config and export it to a file
+- Then make the changes you want to the code style config ***HIT APPLY*** and then export it to a file
+- Then run the following command `git --no-pager diff --no-index -U0 default.xml changed.xml | egrep '^\+' | diff-so-fancy` to see the changes
+- then copy all additions to the formatter file in the backend project
## Build
_tbd_
diff --git a/backend/pom.xml b/backend/pom.xml
index 8a47747d55..5f01739b9c 100644
--- a/backend/pom.xml
+++ b/backend/pom.xml
@@ -231,24 +231,29 @@
maven-surefire-plugin
3.5.2
-
- net.revelc.code.formatter
- formatter-maven-plugin
- 2.24.1
-
- ${maven.compiler.source}
- ${maven.compiler.source}
- ${maven.compiler.source}
-
+ com.diffplug.spotless
+ spotless-maven-plugin
+ 2.43.0
code-format
- format
+ apply
+
+
+
+ 4.26
+ ${project.basedir}/src/main/resources/formatting.xml
+
+
+
+
+
+
@@ -305,9 +310,9 @@
- net.revelc.code.formatter
- formatter-maven-plugin
- 2.24.1
+ com.diffplug.spotless
+ spotless-maven-plugin
+ 2.43.0
code-format
diff --git a/backend/src/main/java/ch/puzzle/okr/Constants.java b/backend/src/main/java/ch/puzzle/okr/Constants.java
index c7cf839961..63989d249c 100644
--- a/backend/src/main/java/ch/puzzle/okr/Constants.java
+++ b/backend/src/main/java/ch/puzzle/okr/Constants.java
@@ -1,12 +1,11 @@
package ch.puzzle.okr;
+import static java.util.Map.entry;
+
import ch.puzzle.okr.dto.checkin.*;
import ch.puzzle.okr.dto.keyresult.*;
-
import java.util.Map;
-import static java.util.Map.entry;
-
public class Constants {
private Constants() {
}
@@ -29,11 +28,11 @@ private Constants() {
public static final String CHECK_IN_KEY_RESULT_ID_ATTRIBUTE_NAME = "keyResultId";
public static final String KEY_RESULT_TYPE_ATTRIBUTE_NAME = "keyResultType";
- public static final Map> KEY_RESULT_MAP = Map.ofEntries(
- entry(KEY_RESULT_TYPE_METRIC, KeyResultMetricDto.class),
- entry(KEY_RESULT_TYPE_ORDINAL, KeyResultOrdinalDto.class));
+ public static final Map> KEY_RESULT_MAP = Map
+ .ofEntries(entry(KEY_RESULT_TYPE_METRIC, KeyResultMetricDto.class),
+ entry(KEY_RESULT_TYPE_ORDINAL, KeyResultOrdinalDto.class));
- public static final Map> CHECK_IN_MAP = Map.ofEntries(
- entry(KEY_RESULT_TYPE_METRIC, CheckInMetricDto.class),
- entry(KEY_RESULT_TYPE_ORDINAL, CheckInOrdinalDto.class));
+ public static final Map> CHECK_IN_MAP = Map
+ .ofEntries(entry(KEY_RESULT_TYPE_METRIC, CheckInMetricDto.class),
+ entry(KEY_RESULT_TYPE_ORDINAL, CheckInOrdinalDto.class));
}
diff --git a/backend/src/main/java/ch/puzzle/okr/ErrorKey.java b/backend/src/main/java/ch/puzzle/okr/ErrorKey.java
index f5a67168eb..c460e66b4e 100644
--- a/backend/src/main/java/ch/puzzle/okr/ErrorKey.java
+++ b/backend/src/main/java/ch/puzzle/okr/ErrorKey.java
@@ -1,8 +1,22 @@
package ch.puzzle.okr;
public enum ErrorKey {
- ATTRIBUTE_NULL, ATTRIBUTE_CHANGED, ATTRIBUTE_SET_FORBIDDEN, ATTRIBUTE_NOT_SET, ATTRIBUTE_CANNOT_CHANGE,
- ATTRIBUTE_MUST_BE_DRAFT, KEY_RESULT_CONVERSION, ALREADY_EXISTS_SAME_NAME, CONVERT_TOKEN, DATA_HAS_BEEN_UPDATED,
- MODEL_NULL, MODEL_WITH_ID_NOT_FOUND, NOT_AUTHORIZED_TO_READ, NOT_AUTHORIZED_TO_WRITE, NOT_AUTHORIZED_TO_DELETE,
- TOKEN_NULL, TRIED_TO_DELETE_LAST_ADMIN, TRIED_TO_REMOVE_LAST_OKR_CHAMPION
+ ATTRIBUTE_NULL,
+ ATTRIBUTE_CHANGED,
+ ATTRIBUTE_SET_FORBIDDEN,
+ ATTRIBUTE_NOT_SET,
+ ATTRIBUTE_CANNOT_CHANGE,
+ ATTRIBUTE_MUST_BE_DRAFT,
+ KEY_RESULT_CONVERSION,
+ ALREADY_EXISTS_SAME_NAME,
+ CONVERT_TOKEN,
+ DATA_HAS_BEEN_UPDATED,
+ MODEL_NULL,
+ MODEL_WITH_ID_NOT_FOUND,
+ NOT_AUTHORIZED_TO_READ,
+ NOT_AUTHORIZED_TO_WRITE,
+ NOT_AUTHORIZED_TO_DELETE,
+ TOKEN_NULL,
+ TRIED_TO_DELETE_LAST_ADMIN,
+ TRIED_TO_REMOVE_LAST_OKR_CHAMPION
}
diff --git a/backend/src/main/java/ch/puzzle/okr/ForwardFilter.java b/backend/src/main/java/ch/puzzle/okr/ForwardFilter.java
index 2e517f4d59..40180a1765 100644
--- a/backend/src/main/java/ch/puzzle/okr/ForwardFilter.java
+++ b/backend/src/main/java/ch/puzzle/okr/ForwardFilter.java
@@ -5,14 +5,11 @@
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
+import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
import org.springframework.web.filter.GenericFilterBean;
-import java.io.IOException;
-import java.util.Arrays;
-
public class ForwardFilter extends GenericFilterBean {
private static final Logger logger = LoggerFactory.getLogger(ForwardFilter.class);
diff --git a/backend/src/main/java/ch/puzzle/okr/OkrErrorAttributes.java b/backend/src/main/java/ch/puzzle/okr/OkrErrorAttributes.java
index 0a721ff03b..1b84868059 100644
--- a/backend/src/main/java/ch/puzzle/okr/OkrErrorAttributes.java
+++ b/backend/src/main/java/ch/puzzle/okr/OkrErrorAttributes.java
@@ -1,13 +1,12 @@
package ch.puzzle.okr;
import ch.puzzle.okr.exception.OkrResponseStatusException;
+import java.util.Map;
import org.springframework.boot.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.WebRequest;
-import java.util.Map;
-
@Component
public class OkrErrorAttributes extends DefaultErrorAttributes {
diff --git a/backend/src/main/java/ch/puzzle/okr/OpenAPI30Configuration.java b/backend/src/main/java/ch/puzzle/okr/OpenAPI30Configuration.java
index a7613f5b26..f0e5fe5652 100644
--- a/backend/src/main/java/ch/puzzle/okr/OpenAPI30Configuration.java
+++ b/backend/src/main/java/ch/puzzle/okr/OpenAPI30Configuration.java
@@ -12,9 +12,15 @@ public class OpenAPI30Configuration {
@Bean
public OpenAPI customizeOpenAPI() {
final String securitySchemeName = "bearerAuth";
- return new OpenAPI().addSecurityItem(new SecurityRequirement().addList(securitySchemeName))
- .components(new Components().addSecuritySchemes(securitySchemeName, new SecurityScheme()
- .name(securitySchemeName).type(SecurityScheme.Type.HTTP).scheme("bearer").bearerFormat("JWT")));
+ return new OpenAPI()
+ .addSecurityItem(new SecurityRequirement().addList(securitySchemeName))
+ .components(new Components()
+ .addSecuritySchemes(securitySchemeName,
+ new SecurityScheme()
+ .name(securitySchemeName)
+ .type(SecurityScheme.Type.HTTP)
+ .scheme("bearer")
+ .bearerFormat("JWT")));
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/SecurityConfig.java b/backend/src/main/java/ch/puzzle/okr/SecurityConfig.java
index b4b8a07e6f..29706319e3 100644
--- a/backend/src/main/java/ch/puzzle/okr/SecurityConfig.java
+++ b/backend/src/main/java/ch/puzzle/okr/SecurityConfig.java
@@ -1,5 +1,9 @@
package ch.puzzle.okr;
+import static org.springframework.security.web.header.writers.CrossOriginEmbedderPolicyHeaderWriter.CrossOriginEmbedderPolicy.REQUIRE_CORP;
+import static org.springframework.security.web.header.writers.ReferrerPolicyHeaderWriter.ReferrerPolicy.NO_REFERRER;
+import static org.springframework.security.web.header.writers.XXssProtectionHeaderWriter.HeaderValue.ENABLED_MODE_BLOCK;
+
import com.nimbusds.jose.proc.SecurityContext;
import com.nimbusds.jwt.proc.ConfigurableJWTProcessor;
import com.nimbusds.jwt.proc.DefaultJWTProcessor;
@@ -33,10 +37,6 @@
import org.springframework.security.web.header.writers.CrossOriginResourcePolicyHeaderWriter;
import org.springframework.security.web.header.writers.StaticHeadersWriter;
-import static org.springframework.security.web.header.writers.CrossOriginEmbedderPolicyHeaderWriter.CrossOriginEmbedderPolicy.REQUIRE_CORP;
-import static org.springframework.security.web.header.writers.ReferrerPolicyHeaderWriter.ReferrerPolicy.NO_REFERRER;
-import static org.springframework.security.web.header.writers.XXssProtectionHeaderWriter.HeaderValue.ENABLED_MODE_BLOCK;
-
@Configuration
@EnableWebSecurity
@EnableMethodSecurity
@@ -58,10 +58,12 @@ public SecurityFilterChain apiSecurityFilterChain(HttpSecurity http, @Value("${c
http.addFilterAfter(new ForwardFilter(), BasicAuthenticationFilter.class);
logger.debug("*** apiSecurityFilterChain reached");
setHeaders(http);
- return http.cors(Customizer.withDefaults())
+ return http
+ .cors(Customizer.withDefaults())
.authorizeHttpRequests(e -> e.requestMatchers("/api/**").authenticated().anyRequest().permitAll())
.exceptionHandling(e -> e.authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED)))
- .oauth2ResourceServer(oauth2 -> oauth2.jwt(Customizer.withDefaults())).build();
+ .oauth2ResourceServer(oauth2 -> oauth2.jwt(Customizer.withDefaults()))
+ .build();
}
@Bean
@@ -75,14 +77,15 @@ JWTProcessor jwtProcessor(JWTClaimsSetAwareJWSKeySelector jwtProcessor, OAuth2TokenValidator jwtValidator) {
NimbusJwtDecoder decoder = new NimbusJwtDecoder(jwtProcessor);
OAuth2TokenValidator validator = new DelegatingOAuth2TokenValidator<>(JwtValidators.createDefault(),
- jwtValidator);
+ jwtValidator);
decoder.setJwtValidator(validator);
return decoder;
}
private HttpSecurity setHeaders(HttpSecurity http) throws Exception {
return http
- .headers(headers -> headers.contentSecurityPolicy(c -> c.policyDirectives(okrContentSecurityPolicy()))
+ .headers(headers -> headers
+ .contentSecurityPolicy(c -> c.policyDirectives(okrContentSecurityPolicy()))
.crossOriginEmbedderPolicy(c -> c.policy(REQUIRE_CORP))
.crossOriginOpenerPolicy(c -> c.policy(OPENER_SAME_ORIGIN))
.crossOriginResourcePolicy(c -> c.policy(RESOURCE_SAME_ORIGIN))
@@ -96,32 +99,31 @@ private HttpSecurity setHeaders(HttpSecurity http) throws Exception {
private String okrContentSecurityPolicy() {
return "default-src 'self';" //
- + "script-src 'self' 'unsafe-inline';" //
- + " style-src 'self' 'unsafe-inline';" //
- + " object-src 'none';" //
- + " base-uri 'self';" //
- + " connect-src 'self' " + connectSrc + ";" //
- + " font-src 'self';" //
- + " frame-src 'self';" //
- + " img-src 'self' data: ;" //
- + " manifest-src 'self';" //
- + " media-src 'self';" //
- + " worker-src 'none';"; //
+ + "script-src 'self' 'unsafe-inline';" //
+ + " style-src 'self' 'unsafe-inline';" //
+ + " object-src 'none';" //
+ + " base-uri 'self';" //
+ + " connect-src 'self' " + connectSrc + ";" //
+ + " font-src 'self';" //
+ + " frame-src 'self';" //
+ + " img-src 'self' data: ;" //
+ + " manifest-src 'self';" //
+ + " media-src 'self';" //
+ + " worker-src 'none';"; //
}
private String okrPermissionPolicy() {
return "accelerometer=(), ambient-light-sensor=(), autoplay=(), "
- + "battery=(), camera=(), cross-origin-isolated=(), display-capture=(), document-domain=(), encrypted-media=(), "
- + "execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(),"
- + " geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), "
- + "midi=(), navigation-override=(), payment=(), picture-in-picture=(),"
- + " publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(self), "
- + "usb=(), web-share=(), xr-spatial-tracking=()";
+ + "battery=(), camera=(), cross-origin-isolated=(), display-capture=(), document-domain=(), encrypted-media=(), "
+ + "execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(),"
+ + " geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), "
+ + "midi=(), navigation-override=(), payment=(), picture-in-picture=(),"
+ + " publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(self), "
+ + "usb=(), web-share=(), xr-spatial-tracking=()";
}
@Bean
- public AuthenticationEventPublisher authenticationEventPublisher(
- ApplicationEventPublisher applicationEventPublisher) {
+ public AuthenticationEventPublisher authenticationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
return new DefaultAuthenticationEventPublisher(applicationEventPublisher);
}
diff --git a/backend/src/main/java/ch/puzzle/okr/UserKeyGenerator.java b/backend/src/main/java/ch/puzzle/okr/UserKeyGenerator.java
index 144a056e30..c66adf8a65 100644
--- a/backend/src/main/java/ch/puzzle/okr/UserKeyGenerator.java
+++ b/backend/src/main/java/ch/puzzle/okr/UserKeyGenerator.java
@@ -2,10 +2,9 @@
import ch.puzzle.okr.models.User;
import ch.puzzle.okr.multitenancy.TenantContext;
-import org.springframework.cache.interceptor.KeyGenerator;
-
import java.lang.reflect.Method;
import java.text.MessageFormat;
+import org.springframework.cache.interceptor.KeyGenerator;
public class UserKeyGenerator implements KeyGenerator {
@Override
diff --git a/backend/src/main/java/ch/puzzle/okr/controller/ActionController.java b/backend/src/main/java/ch/puzzle/okr/controller/ActionController.java
index d6b9855b7b..7252d122bb 100644
--- a/backend/src/main/java/ch/puzzle/okr/controller/ActionController.java
+++ b/backend/src/main/java/ch/puzzle/okr/controller/ActionController.java
@@ -9,9 +9,8 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
-import org.springframework.web.bind.annotation.*;
-
import java.util.List;
+import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("api/v2/action")
@@ -30,8 +29,8 @@ public ActionController(ActionAuthorizationService actionAuthorizationService, A
@Content(mediaType = "application/json", schema = @Schema(implementation = ActionDto.class)) }),
@ApiResponse(responseCode = "400", description = "Can't update Actions, attributes are not set", content = @Content) })
@PutMapping
- public void updateActions(
- @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The Action as json to update existing Actions.", required = true) @RequestBody List actionDtoList) {
+ public void updateActions(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The Action as json to update existing Actions.", required = true)
+ @RequestBody List actionDtoList) {
List actionList = actionMapper.toActions(actionDtoList);
actionAuthorizationService.updateEntities(actionList);
}
diff --git a/backend/src/main/java/ch/puzzle/okr/controller/AlignmentController.java b/backend/src/main/java/ch/puzzle/okr/controller/AlignmentController.java
index 85b6a77ec1..f63a090ea3 100644
--- a/backend/src/main/java/ch/puzzle/okr/controller/AlignmentController.java
+++ b/backend/src/main/java/ch/puzzle/okr/controller/AlignmentController.java
@@ -8,6 +8,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
@@ -15,8 +16,6 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
-import java.util.List;
-
@RestController
@RequestMapping("api/v2/alignments")
public class AlignmentController {
@@ -24,7 +23,7 @@ public class AlignmentController {
private final AlignmentSelectionBusinessService alignmentSelectionBusinessService;
public AlignmentController(AlignmentSelectionMapper alignmentSelectionMapper,
- AlignmentSelectionBusinessService alignmentSelectionBusinessService) {
+ AlignmentSelectionBusinessService alignmentSelectionBusinessService) {
this.alignmentSelectionMapper = alignmentSelectionMapper;
this.alignmentSelectionBusinessService = alignmentSelectionBusinessService;
}
@@ -35,11 +34,12 @@ public AlignmentController(AlignmentSelectionMapper alignmentSelectionMapper,
@Content(mediaType = "application/json", schema = @Schema(implementation = AlignmentObjectiveDto.class)) }),
@ApiResponse(responseCode = "400", description = "Can't return list of objectives with their key results to select the alignment", content = @Content) })
@GetMapping("/selections")
- public ResponseEntity> getAlignmentSelections(
- @RequestParam(required = false, defaultValue = "", name = "quarter") Long quarterFilter,
- @RequestParam(required = false, defaultValue = "", name = "team") Long teamFilter) {
- return ResponseEntity.status(HttpStatus.OK)
- .body(alignmentSelectionMapper.toDto(alignmentSelectionBusinessService
- .getAlignmentSelectionByQuarterIdAndTeamIdNot(quarterFilter, teamFilter)));
+ public ResponseEntity> getAlignmentSelections(@RequestParam(required = false, defaultValue = "", name = "quarter") Long quarterFilter,
+ @RequestParam(required = false, defaultValue = "", name = "team") Long teamFilter) {
+ return ResponseEntity
+ .status(HttpStatus.OK)
+ .body(alignmentSelectionMapper
+ .toDto(alignmentSelectionBusinessService
+ .getAlignmentSelectionByQuarterIdAndTeamIdNot(quarterFilter, teamFilter)));
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/controller/CheckInController.java b/backend/src/main/java/ch/puzzle/okr/controller/CheckInController.java
index 83c6030f2e..976e0ceb24 100644
--- a/backend/src/main/java/ch/puzzle/okr/controller/CheckInController.java
+++ b/backend/src/main/java/ch/puzzle/okr/controller/CheckInController.java
@@ -34,7 +34,8 @@ public CheckInController(CheckInMapper checkInMapper, CheckInAuthorizationServic
@ApiResponse(responseCode = "404", description = "Did not find a Check-in with a specified ID", content = @Content) })
@GetMapping("/{id}")
public ResponseEntity getCheckInById(@PathVariable long id) {
- return ResponseEntity.status(HttpStatus.OK)
+ return ResponseEntity
+ .status(HttpStatus.OK)
.body(checkInMapper.toDto(this.checkInAuthorizationService.getEntityById(id)));
}
@@ -47,9 +48,8 @@ public ResponseEntity getCheckInById(@PathVariable long id) {
@ApiResponse(responseCode = "404", description = "Given ID of Check-in wasn't found.", content = @Content),
@ApiResponse(responseCode = "422", description = "Can't update Check-in since Check-in was updated or deleted by another user.", content = @Content) })
@PutMapping("/{id}")
- public ResponseEntity updateCheckIn(
- @Parameter(description = "The ID for updating a Check-in.", required = true) @PathVariable Long id,
- @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The Check-in as json to update an existing Check-in.", required = true) @RequestBody CheckInDto checkInDto) {
+ public ResponseEntity updateCheckIn(@Parameter(description = "The ID for updating a Check-in.", required = true)
+ @PathVariable Long id, @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The Check-in as json to update an existing Check-in.", required = true) @RequestBody CheckInDto checkInDto) {
CheckIn checkIn = checkInMapper.toCheckIn(checkInDto);
CheckInDto updatedCheckIn = this.checkInMapper
.toDto(this.checkInAuthorizationService.updateEntity(id, checkIn));
@@ -63,8 +63,8 @@ public ResponseEntity updateCheckIn(
@ApiResponse(responseCode = "400", description = "Can't create new Check-in, not allowed to give an ID", content = @Content),
@ApiResponse(responseCode = "401", description = "Not authorized to create Check-in", content = @Content) })
@PostMapping
- public ResponseEntity createCheckIn(
- @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The Check-in as json to create a new Check-in.", required = true) @RequestBody CheckInDto checkInDto) {
+ public ResponseEntity createCheckIn(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The Check-in as json to create a new Check-in.", required = true)
+ @RequestBody CheckInDto checkInDto) {
CheckIn checkIn = checkInMapper.toCheckIn(checkInDto);
CheckInDto createdCheckIn = checkInMapper.toDto(checkInAuthorizationService.createEntity(checkIn));
return ResponseEntity.status(HttpStatus.CREATED).body(createdCheckIn);
@@ -75,8 +75,8 @@ public ResponseEntity createCheckIn(
@ApiResponse(responseCode = "401", description = "Not authorized to delete Check-in", content = @Content),
@ApiResponse(responseCode = "404", description = "Did not find the Check-in with requested ID") })
@DeleteMapping("/{id}")
- public void deleteCheckInById(
- @Parameter(description = "The ID of an Check-in to delete it.", required = true) @PathVariable long id) {
+ public void deleteCheckInById(@Parameter(description = "The ID of an Check-in to delete it.", required = true)
+ @PathVariable long id) {
this.checkInAuthorizationService.deleteEntityById(id);
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/controller/ClientConfigController.java b/backend/src/main/java/ch/puzzle/okr/controller/ClientConfigController.java
index ec45e2f782..1fd85d9089 100644
--- a/backend/src/main/java/ch/puzzle/okr/controller/ClientConfigController.java
+++ b/backend/src/main/java/ch/puzzle/okr/controller/ClientConfigController.java
@@ -20,7 +20,8 @@ public ClientConfigController(ClientConfigService configService) {
@GetMapping("/config")
public ResponseEntity getConfig(HttpServletRequest request) {
- return ResponseEntity.status(HttpStatus.OK)
+ return ResponseEntity
+ .status(HttpStatus.OK)
.body(configService.getConfigBasedOnActiveEnv(request.getServerName()));
}
diff --git a/backend/src/main/java/ch/puzzle/okr/controller/CompletedController.java b/backend/src/main/java/ch/puzzle/okr/controller/CompletedController.java
index 4b8e10e5dc..b7cbfcaeb9 100644
--- a/backend/src/main/java/ch/puzzle/okr/controller/CompletedController.java
+++ b/backend/src/main/java/ch/puzzle/okr/controller/CompletedController.java
@@ -21,7 +21,7 @@ public class CompletedController {
private final CompletedMapper completedMapper;
public CompletedController(CompletedAuthorizationService completedAuthorizationService,
- CompletedMapper completedMapper) {
+ CompletedMapper completedMapper) {
this.completedAuthorizationService = completedAuthorizationService;
this.completedMapper = completedMapper;
}
diff --git a/backend/src/main/java/ch/puzzle/okr/controller/KeyResultController.java b/backend/src/main/java/ch/puzzle/okr/controller/KeyResultController.java
index 0940bdc333..a52c61761e 100644
--- a/backend/src/main/java/ch/puzzle/okr/controller/KeyResultController.java
+++ b/backend/src/main/java/ch/puzzle/okr/controller/KeyResultController.java
@@ -1,5 +1,7 @@
package ch.puzzle.okr.controller;
+import static org.springframework.http.HttpStatus.*;
+
import ch.puzzle.okr.dto.checkin.CheckInDto;
import ch.puzzle.okr.dto.keyresult.KeyResultDto;
import ch.puzzle.okr.dto.keyresult.KeyResultMetricDto;
@@ -18,13 +20,10 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import java.util.List;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
-import java.util.List;
-
-import static org.springframework.http.HttpStatus.*;
-
@RestController
@RequestMapping("api/v2/keyresults")
public class KeyResultController {
@@ -36,8 +35,8 @@ public class KeyResultController {
private final ActionMapper actionMapper;
public KeyResultController(KeyResultAuthorizationService keyResultAuthorizationService,
- ActionAuthorizationService actionAuthorizationService, KeyResultMapper keyResultMapper,
- CheckInMapper checkInMapper, ActionMapper actionMapper) {
+ ActionAuthorizationService actionAuthorizationService, KeyResultMapper keyResultMapper,
+ CheckInMapper checkInMapper, ActionMapper actionMapper) {
this.keyResultAuthorizationService = keyResultAuthorizationService;
this.actionAuthorizationService = actionAuthorizationService;
this.keyResultMapper = keyResultMapper;
@@ -66,8 +65,8 @@ public KeyResultDto getKeyResultById(@PathVariable long id) {
@ApiResponse(responseCode = "401", description = "Not authorized to read Check-ins from a KeyResult", content = @Content),
@ApiResponse(responseCode = "404", description = "Did not find a KeyResult with a specified ID to get Check-ins from.", content = @Content) })
@GetMapping("/{id}/checkins")
- public List getCheckInsFromKeyResult(
- @Parameter(description = "The ID for getting all Check-ins from a KeyResult.", required = true) @PathVariable long id) {
+ public List getCheckInsFromKeyResult(@Parameter(description = "The ID for getting all Check-ins from a KeyResult.", required = true)
+ @PathVariable long id) {
return keyResultAuthorizationService.getAllCheckInsByKeyResult(id).stream().map(checkInMapper::toDto).toList();
}
@@ -98,15 +97,15 @@ public ResponseEntity createKeyResult(@RequestBody KeyResultDto ke
@ApiResponse(responseCode = "404", description = "Did not find a KeyResult with a specified ID to update.", content = @Content),
@ApiResponse(responseCode = "422", description = "Can't update KeyResult since KeyResult was updated or deleted by another user.", content = @Content) })
@PutMapping("/{id}")
- public ResponseEntity updateKeyResult(
- @Parameter(description = "The ID for updating a KeyResult.", required = true) @PathVariable long id,
- @RequestBody KeyResultDto keyResultDto) {
+ public ResponseEntity updateKeyResult(@Parameter(description = "The ID for updating a KeyResult.", required = true)
+ @PathVariable long id, @RequestBody KeyResultDto keyResultDto) {
KeyResult keyResult = keyResultMapper.toKeyResult(keyResultDto);
List actionList = actionMapper.toActions(keyResultDto.getActionList(), keyResult);
boolean isKeyResultImUsed = keyResultAuthorizationService.isImUsed(id, keyResult);
- KeyResultWithActionList updatedKeyResult = keyResultAuthorizationService.updateEntities(id, keyResult,
- actionList);
- return ResponseEntity.status(isKeyResultImUsed ? IM_USED : OK)
+ KeyResultWithActionList updatedKeyResult = keyResultAuthorizationService
+ .updateEntities(id, keyResult, actionList);
+ return ResponseEntity
+ .status(isKeyResultImUsed ? IM_USED : OK)
.body(keyResultMapper.toDto(updatedKeyResult.keyResult(), updatedKeyResult.actionList()));
}
diff --git a/backend/src/main/java/ch/puzzle/okr/controller/ObjectiveController.java b/backend/src/main/java/ch/puzzle/okr/controller/ObjectiveController.java
index 7ca8ae39d8..411c11787a 100644
--- a/backend/src/main/java/ch/puzzle/okr/controller/ObjectiveController.java
+++ b/backend/src/main/java/ch/puzzle/okr/controller/ObjectiveController.java
@@ -1,9 +1,12 @@
package ch.puzzle.okr.controller;
-import ch.puzzle.okr.dto.checkin.CheckInDto;
-import ch.puzzle.okr.dto.keyresult.KeyResultDto;
+import static org.springframework.http.HttpStatus.IM_USED;
+import static org.springframework.http.HttpStatus.OK;
+
import ch.puzzle.okr.dto.DuplicateObjectiveDto;
import ch.puzzle.okr.dto.ObjectiveDto;
+import ch.puzzle.okr.dto.checkin.CheckInDto;
+import ch.puzzle.okr.dto.keyresult.KeyResultDto;
import ch.puzzle.okr.mapper.ObjectiveMapper;
import ch.puzzle.okr.mapper.keyresult.KeyResultMapper;
import ch.puzzle.okr.models.Action;
@@ -17,15 +20,11 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
-import java.util.List;
-
-import static org.springframework.http.HttpStatus.IM_USED;
-import static org.springframework.http.HttpStatus.OK;
-
@RestController
@RequestMapping("api/v2/objectives")
public class ObjectiveController {
@@ -35,8 +34,8 @@ public class ObjectiveController {
private final ActionAuthorizationService actionAuthorizationService;
public ObjectiveController(ObjectiveAuthorizationService objectiveAuthorizationService,
- ObjectiveMapper objectiveMapper, KeyResultMapper keyResultMapper,
- ActionAuthorizationService actionAuthorizationService) {
+ ObjectiveMapper objectiveMapper, KeyResultMapper keyResultMapper,
+ ActionAuthorizationService actionAuthorizationService) {
this.objectiveAuthorizationService = objectiveAuthorizationService;
this.objectiveMapper = objectiveMapper;
this.keyResultMapper = keyResultMapper;
@@ -50,9 +49,10 @@ public ObjectiveController(ObjectiveAuthorizationService objectiveAuthorizationS
@ApiResponse(responseCode = "401", description = "Not authorized to read an Objective", content = @Content),
@ApiResponse(responseCode = "404", description = "Did not find an Objective with a specified ID", content = @Content) })
@GetMapping("/{id}")
- public ResponseEntity getObjective(
- @Parameter(description = "The ID for getting an Objective.", required = true) @PathVariable Long id) {
- return ResponseEntity.status(HttpStatus.OK)
+ public ResponseEntity getObjective(@Parameter(description = "The ID for getting an Objective.", required = true)
+ @PathVariable Long id) {
+ return ResponseEntity
+ .status(HttpStatus.OK)
.body(objectiveMapper.toDto(objectiveAuthorizationService.getEntityById(id)));
}
@@ -63,9 +63,10 @@ public ResponseEntity getObjective(
@ApiResponse(responseCode = "401", description = "Not authorized to read KeyResults from an Objective", content = @Content),
@ApiResponse(responseCode = "404", description = "Did not find an Objective with the specified ID to get KeyResults from.", content = @Content) })
@GetMapping("/{id}/keyResults")
- public ResponseEntity> getKeyResultsFromObjective(
- @Parameter(description = "The ID for getting all KeyResults of an Objective", required = true) @PathVariable long id) {
- return ResponseEntity.status(OK)
+ public ResponseEntity> getKeyResultsFromObjective(@Parameter(description = "The ID for getting all KeyResults of an Objective", required = true)
+ @PathVariable long id) {
+ return ResponseEntity
+ .status(OK)
.body(objectiveAuthorizationService.getAllKeyResultsByObjective(id).stream().map(keyResult -> {
List actionList = actionAuthorizationService.getActionsByKeyResult(keyResult);
return keyResultMapper.toDto(keyResult, actionList);
@@ -77,8 +78,8 @@ public ResponseEntity> getKeyResultsFromObjective(
@ApiResponse(responseCode = "401", description = "Not authorized to delete an Objective", content = @Content),
@ApiResponse(responseCode = "404", description = "Did not find the Objective with requested ID") })
@DeleteMapping("/{id}")
- public void deleteObjectiveById(
- @Parameter(description = "The ID of an Objective to delete it.", required = true) @PathVariable long id) {
+ public void deleteObjectiveById(@Parameter(description = "The ID of an Objective to delete it.", required = true)
+ @PathVariable long id) {
objectiveAuthorizationService.deleteEntityById(id);
}
@@ -89,8 +90,8 @@ public void deleteObjectiveById(
@ApiResponse(responseCode = "400", description = "Can't create new Objective, not allowed to give an ID", content = @Content),
@ApiResponse(responseCode = "401", description = "Not authorized to create an Objective", content = @Content) })
@PostMapping
- public ResponseEntity createObjective(
- @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The Objective as json to create a new Objective.", required = true) @RequestBody ObjectiveDto objectiveDTO) {
+ public ResponseEntity createObjective(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The Objective as json to create a new Objective.", required = true)
+ @RequestBody ObjectiveDto objectiveDTO) {
Objective objective = objectiveMapper.toObjective(objectiveDTO);
ObjectiveDto createdObjective = objectiveMapper.toDto(objectiveAuthorizationService.createEntity(objective));
return ResponseEntity.status(HttpStatus.CREATED).body(createdObjective);
@@ -100,11 +101,13 @@ public ResponseEntity createObjective(
@ApiResponses(value = { @ApiResponse(responseCode = "201", description = "Duplicated a given Objective", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = ObjectiveDto.class)) }) })
@PostMapping("/{id}")
- public ResponseEntity duplicateObjective(
- @Parameter(description = "The ID for duplicating an Objective.", required = true) @PathVariable Long id,
- @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The Objective which should be duplicated as JSON", required = true) @RequestBody DuplicateObjectiveDto duplicateObjectiveDto) {
+ public ResponseEntity duplicateObjective(@Parameter(description = "The ID for duplicating an Objective.", required = true)
+ @PathVariable Long id, @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The Objective which should be duplicated as JSON", required = true) @RequestBody DuplicateObjectiveDto duplicateObjectiveDto) {
Objective objective = objectiveMapper.toObjective(duplicateObjectiveDto.objective());
- List keyResults = duplicateObjectiveDto.keyResults().stream().map(keyResultMapper::toKeyResult)
+ List keyResults = duplicateObjectiveDto
+ .keyResults()
+ .stream()
+ .map(keyResultMapper::toKeyResult)
.toList();
ObjectiveDto duplicatedObjectiveDto = objectiveMapper
.toDto(objectiveAuthorizationService.duplicateEntity(id, objective, keyResults));
@@ -122,9 +125,8 @@ public ResponseEntity duplicateObjective(
@ApiResponse(responseCode = "404", description = "Given ID of Objective wasn't found", content = @Content),
@ApiResponse(responseCode = "422", description = "Can't update Objective since Objective was updated or deleted by another user.", content = @Content) })
@PutMapping("/{id}")
- public ResponseEntity updateObjective(
- @Parameter(description = "The ID for updating an Objective.", required = true) @PathVariable Long id,
- @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The objective as json to update an existing Objective.", required = true) @RequestBody ObjectiveDto objectiveDTO) {
+ public ResponseEntity updateObjective(@Parameter(description = "The ID for updating an Objective.", required = true)
+ @PathVariable Long id, @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The objective as json to update an existing Objective.", required = true) @RequestBody ObjectiveDto objectiveDTO) {
Objective objective = objectiveMapper.toObjective(objectiveDTO);
boolean isObjectiveImUsed = objectiveAuthorizationService.isImUsed(objective);
ObjectiveDto updatedObjective = objectiveMapper
diff --git a/backend/src/main/java/ch/puzzle/okr/controller/OverviewController.java b/backend/src/main/java/ch/puzzle/okr/controller/OverviewController.java
index ff8dfe009d..3ea4163af9 100644
--- a/backend/src/main/java/ch/puzzle/okr/controller/OverviewController.java
+++ b/backend/src/main/java/ch/puzzle/okr/controller/OverviewController.java
@@ -8,6 +8,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
@@ -15,8 +16,6 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
-import java.util.List;
-
@RestController
@RequestMapping("api/v2/overview")
public class OverviewController {
@@ -24,7 +23,7 @@ public class OverviewController {
private final OverviewAuthorizationService overviewAuthorizationService;
public OverviewController(OverviewMapper overviewMapper,
- OverviewAuthorizationService overviewAuthorizationService) {
+ OverviewAuthorizationService overviewAuthorizationService) {
this.overviewMapper = overviewMapper;
this.overviewAuthorizationService = overviewAuthorizationService;
}
@@ -37,11 +36,13 @@ public OverviewController(OverviewMapper overviewMapper,
@ApiResponse(responseCode = "401", description = "Not authorized to read teams with their objectives", content = @Content),
@ApiResponse(responseCode = "404", description = "The quarter or one of the teams were not found", content = @Content) })
@GetMapping("")
- public ResponseEntity> getOverview(
- @RequestParam(required = false, defaultValue = "", name = "team") List teamFilter,
- @RequestParam(required = false, defaultValue = "", name = "quarter") Long quarterFilter,
- @RequestParam(required = false, defaultValue = "", name = "objectiveQuery") String objectiveQuery) {
- return ResponseEntity.status(HttpStatus.OK).body(overviewMapper
- .toDto(overviewAuthorizationService.getFilteredOverview(quarterFilter, teamFilter, objectiveQuery)));
+ public ResponseEntity> getOverview(@RequestParam(required = false, defaultValue = "", name = "team") List teamFilter,
+ @RequestParam(required = false, defaultValue = "", name = "quarter") Long quarterFilter,
+ @RequestParam(required = false, defaultValue = "", name = "objectiveQuery") String objectiveQuery) {
+ return ResponseEntity
+ .status(HttpStatus.OK)
+ .body(overviewMapper
+ .toDto(overviewAuthorizationService
+ .getFilteredOverview(quarterFilter, teamFilter, objectiveQuery)));
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/controller/QuarterController.java b/backend/src/main/java/ch/puzzle/okr/controller/QuarterController.java
index 1cc1383dbc..a3c16c47e7 100644
--- a/backend/src/main/java/ch/puzzle/okr/controller/QuarterController.java
+++ b/backend/src/main/java/ch/puzzle/okr/controller/QuarterController.java
@@ -1,6 +1,5 @@
package ch.puzzle.okr.controller;
-import ch.puzzle.okr.dto.TeamDto;
import ch.puzzle.okr.models.Quarter;
import ch.puzzle.okr.service.business.QuarterBusinessService;
import io.swagger.v3.oas.annotations.Operation;
@@ -8,14 +7,13 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
-import java.util.List;
-
@RestController
@RequestMapping("api/v2/quarters")
public class QuarterController {
diff --git a/backend/src/main/java/ch/puzzle/okr/controller/TeamController.java b/backend/src/main/java/ch/puzzle/okr/controller/TeamController.java
index ccaad22741..51cb9daeed 100644
--- a/backend/src/main/java/ch/puzzle/okr/controller/TeamController.java
+++ b/backend/src/main/java/ch/puzzle/okr/controller/TeamController.java
@@ -1,5 +1,7 @@
package ch.puzzle.okr.controller;
+import static org.springframework.http.HttpStatus.OK;
+
import ch.puzzle.okr.dto.TeamDto;
import ch.puzzle.okr.dto.UserDto;
import ch.puzzle.okr.mapper.TeamMapper;
@@ -11,14 +13,11 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
-import java.util.List;
-
-import static org.springframework.http.HttpStatus.OK;
-
@RestController
@RequestMapping("api/v2/teams")
public class TeamController {
@@ -45,8 +44,8 @@ public List getAllTeams() {
@ApiResponse(responseCode = "400", description = "Can't create new Team, not allowed to give an ID", content = @Content),
@ApiResponse(responseCode = "401", description = "Not authorized to create a Team", content = @Content) })
@PostMapping
- public ResponseEntity createTeam(
- @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The Team as json to create a new Team.", required = true) @RequestBody TeamDto teamDto) {
+ public ResponseEntity createTeam(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The Team as json to create a new Team.", required = true)
+ @RequestBody TeamDto teamDto) {
Team createdTeam = teamAuthorizationService.createEntity(teamMapper.toTeam(teamDto));
return ResponseEntity.status(HttpStatus.CREATED).body(teamMapper.toDto(createdTeam));
}
@@ -59,9 +58,8 @@ public ResponseEntity createTeam(
@ApiResponse(responseCode = "404", description = "Did not find a Team with a specified ID to update.", content = @Content),
@ApiResponse(responseCode = "422", description = "Can't update Team since Team was updated or deleted by another user.", content = @Content) })
@PutMapping("/{id}")
- public ResponseEntity updateTeam(
- @Parameter(description = "The ID for updating a Team.", required = true) @PathVariable long id,
- @RequestBody TeamDto teamDto) {
+ public ResponseEntity updateTeam(@Parameter(description = "The ID for updating a Team.", required = true)
+ @PathVariable long id, @RequestBody TeamDto teamDto) {
Team updatedTeam = teamAuthorizationService.updateEntity(teamMapper.toTeam(teamDto), id);
return ResponseEntity.status(OK).body(teamMapper.toDto(updatedTeam));
}
@@ -71,8 +69,8 @@ public ResponseEntity updateTeam(
@ApiResponse(responseCode = "401", description = "Not authorized to delete an Team", content = @Content),
@ApiResponse(responseCode = "404", description = "Did not find the Team with requested ID") })
@DeleteMapping("/{id}")
- public void deleteTeamById(
- @Parameter(description = "The ID of an Team to delete it.", required = true) @PathVariable long id) {
+ public void deleteTeamById(@Parameter(description = "The ID of an Team to delete it.", required = true)
+ @PathVariable long id) {
teamAuthorizationService.deleteEntity(id);
}
@@ -81,9 +79,8 @@ public void deleteTeamById(
@ApiResponse(responseCode = "401", description = "Not authorized to add users to the team", content = @Content),
@ApiResponse(responseCode = "404", description = "Did not find the Team with requested ID") })
@PutMapping("/{id}/addusers")
- public void addUsersToTeam(
- @Parameter(description = "The ID of an Team to add to users to it.", required = true) @PathVariable long id,
- @RequestBody List userDtoList) {
+ public void addUsersToTeam(@Parameter(description = "The ID of an Team to add to users to it.", required = true)
+ @PathVariable long id, @RequestBody List userDtoList) {
var userIds = userDtoList.stream().map(UserDto::id).toList();
teamAuthorizationService.addUsersToTeam(id, userIds);
}
@@ -93,22 +90,19 @@ public void addUsersToTeam(
@ApiResponse(responseCode = "401", description = "Not authorized to remove user from team", content = @Content),
@ApiResponse(responseCode = "404", description = "Did not find the Team with requested ID") })
@PutMapping("/{id}/user/{userId}/removeuser")
- public void removeUserFromTeam(
- @Parameter(description = "The ID of an team to remove the user from it.", required = true) @PathVariable long id,
- @Parameter(description = "The User ID to remove from the team.", required = true) @PathVariable long userId) {
+ public void removeUserFromTeam(@Parameter(description = "The ID of an team to remove the user from it.", required = true)
+ @PathVariable long id, @Parameter(description = "The User ID to remove from the team.", required = true) @PathVariable long userId) {
teamAuthorizationService.removeUserFromTeam(id, userId);
}
@Operation(summary = "Update or add team membership", description = "If user is already member of this team, isAdmin is set. otherwise new team membership "
- + "is added with isAdmin true or false")
+ + "is added with isAdmin true or false")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Update or add team membership"),
@ApiResponse(responseCode = "401", description = "Not authorized to update or add team membership", content = @Content),
@ApiResponse(responseCode = "404", description = "Did not find the Team with requested ID") })
@PutMapping("/{id}/user/{userId}/updateaddteammembership/{isAdmin}")
- public void updateOrAddTeamMembership(
- @Parameter(description = "The ID of an team to update or add membership", required = true) @PathVariable long id,
- @Parameter(description = "The User ID to update or add membership", required = true) @PathVariable long userId,
- @Parameter(description = "The parameter if user should be admin or not", required = true) @PathVariable boolean isAdmin) {
+ public void updateOrAddTeamMembership(@Parameter(description = "The ID of an team to update or add membership", required = true)
+ @PathVariable long id, @Parameter(description = "The User ID to update or add membership", required = true) @PathVariable long userId, @Parameter(description = "The parameter if user should be admin or not", required = true) @PathVariable boolean isAdmin) {
teamAuthorizationService.updateOrAddTeamMembership(id, userId, isAdmin);
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/controller/UserController.java b/backend/src/main/java/ch/puzzle/okr/controller/UserController.java
index 961adb7c1c..36decfb050 100644
--- a/backend/src/main/java/ch/puzzle/okr/controller/UserController.java
+++ b/backend/src/main/java/ch/puzzle/okr/controller/UserController.java
@@ -12,9 +12,8 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
-import org.springframework.web.bind.annotation.*;
-
import java.util.List;
+import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("api/v1/users")
@@ -25,7 +24,7 @@ public class UserController {
private final UserMapper userMapper;
public UserController(UserAuthorizationService userAuthorizationService, AuthorizationService authorizationService,
- UserMapper userMapper) {
+ UserMapper userMapper) {
this.userAuthorizationService = userAuthorizationService;
this.authorizationService = authorizationService;
this.userMapper = userMapper;
@@ -53,8 +52,8 @@ public UserDto getCurrentUser() {
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Returned user", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = UserDto.class)) }), })
@GetMapping(path = "/{id}")
- public UserDto getUserById(
- @Parameter(description = "The ID for requested user.", required = true) @PathVariable long id) {
+ public UserDto getUserById(@Parameter(description = "The ID for requested user.", required = true)
+ @PathVariable long id) {
var user = this.userAuthorizationService.getById(id);
return userMapper.toDto(user);
}
@@ -63,9 +62,8 @@ public UserDto getUserById(
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Returned user", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = UserDto.class)) }), })
@PutMapping(path = "/{id}/isokrchampion/{isOkrChampion}")
- public UserDto setOkrChampion(
- @Parameter(description = "The ID for requested user.", required = true) @PathVariable long id,
- @Parameter(description = "okrChampion property of user is set to this flag.", required = true) @PathVariable boolean isOkrChampion) {
+ public UserDto setOkrChampion(@Parameter(description = "The ID for requested user.", required = true)
+ @PathVariable long id, @Parameter(description = "okrChampion property of user is set to this flag.", required = true) @PathVariable boolean isOkrChampion) {
var user = this.userAuthorizationService.setIsOkrChampion(id, isOkrChampion);
return userMapper.toDto(user);
}
@@ -74,8 +72,8 @@ public UserDto setOkrChampion(
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Returned users", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = UserDto.class)) }), })
@PostMapping(path = "/createall")
- public List createUsers(
- @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The users to create", required = true) @RequestBody List newUserDtoList) {
+ public List createUsers(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The users to create", required = true)
+ @RequestBody List newUserDtoList) {
var createdUsers = this.userAuthorizationService.createUsers(userMapper.toUserList(newUserDtoList));
return userMapper.toDtos(createdUsers);
}
@@ -86,8 +84,8 @@ public List createUsers(
@Content(mediaType = "application/json", schema = @Schema(implementation = Boolean.class)) }), })
@GetMapping(path = "/{id}/ismemberofteams")
- public Boolean isUserMemberOfTeams(
- @Parameter(description = "The ID of the user.", required = true) @PathVariable long id) {
+ public Boolean isUserMemberOfTeams(@Parameter(description = "The ID of the user.", required = true)
+ @PathVariable long id) {
return this.userAuthorizationService.isUserMemberOfTeams(id);
}
diff --git a/backend/src/main/java/ch/puzzle/okr/deserializer/CheckInDeserializer.java b/backend/src/main/java/ch/puzzle/okr/deserializer/CheckInDeserializer.java
index 5cf3d6406f..c4f9ffecad 100644
--- a/backend/src/main/java/ch/puzzle/okr/deserializer/CheckInDeserializer.java
+++ b/backend/src/main/java/ch/puzzle/okr/deserializer/CheckInDeserializer.java
@@ -1,14 +1,13 @@
package ch.puzzle.okr.deserializer;
+import static ch.puzzle.okr.Constants.*;
+
import ch.puzzle.okr.dto.checkin.*;
import ch.puzzle.okr.service.business.KeyResultBusinessService;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.*;
-import org.springframework.stereotype.Component;
-
import java.io.IOException;
-
-import static ch.puzzle.okr.Constants.*;
+import org.springframework.stereotype.Component;
@Component
public class CheckInDeserializer extends JsonDeserializer implements MetricOrdinalDeserializer {
@@ -17,7 +16,7 @@ public class CheckInDeserializer extends JsonDeserializer implements
private final KeyResultBusinessService keyResultBusinessService;
public CheckInDeserializer(DeserializerHelper deserializerHelper,
- KeyResultBusinessService keyResultBusinessService) {
+ KeyResultBusinessService keyResultBusinessService) {
this.deserializerHelper = deserializerHelper;
this.keyResultBusinessService = keyResultBusinessService;
}
diff --git a/backend/src/main/java/ch/puzzle/okr/deserializer/DeserializerHelper.java b/backend/src/main/java/ch/puzzle/okr/deserializer/DeserializerHelper.java
index b305a24da8..d908110618 100644
--- a/backend/src/main/java/ch/puzzle/okr/deserializer/DeserializerHelper.java
+++ b/backend/src/main/java/ch/puzzle/okr/deserializer/DeserializerHelper.java
@@ -3,18 +3,18 @@
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.IOException;
+import java.util.Map;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ResponseStatusException;
-import java.io.IOException;
-import java.util.Map;
-
@Component
public class DeserializerHelper {
public T deserializeMetricOrdinal(JsonParser jsonParser, Map> validTypes,
- MetricOrdinalDeserializer deserializer) throws IOException {
+ MetricOrdinalDeserializer deserializer)
+ throws IOException {
ObjectMapper mapper = (ObjectMapper) jsonParser.getCodec();
ObjectNode root = mapper.readTree(jsonParser);
diff --git a/backend/src/main/java/ch/puzzle/okr/deserializer/KeyResultDeserializer.java b/backend/src/main/java/ch/puzzle/okr/deserializer/KeyResultDeserializer.java
index 7515e14d7c..4cdbb7960c 100644
--- a/backend/src/main/java/ch/puzzle/okr/deserializer/KeyResultDeserializer.java
+++ b/backend/src/main/java/ch/puzzle/okr/deserializer/KeyResultDeserializer.java
@@ -1,13 +1,12 @@
package ch.puzzle.okr.deserializer;
+import static ch.puzzle.okr.Constants.*;
+
import ch.puzzle.okr.dto.keyresult.KeyResultDto;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.*;
-
import java.io.IOException;
-import static ch.puzzle.okr.Constants.*;
-
public class KeyResultDeserializer extends JsonDeserializer implements MetricOrdinalDeserializer {
private final DeserializerHelper deserializerHelper;
diff --git a/backend/src/main/java/ch/puzzle/okr/dto/DuplicateObjectiveDto.java b/backend/src/main/java/ch/puzzle/okr/dto/DuplicateObjectiveDto.java
index d4f5bd7f8a..232fd14ae2 100644
--- a/backend/src/main/java/ch/puzzle/okr/dto/DuplicateObjectiveDto.java
+++ b/backend/src/main/java/ch/puzzle/okr/dto/DuplicateObjectiveDto.java
@@ -1,7 +1,6 @@
package ch.puzzle.okr.dto;
import ch.puzzle.okr.dto.keyresult.KeyResultDto;
-
import java.util.List;
public record DuplicateObjectiveDto(ObjectiveDto objective, List keyResults) {
diff --git a/backend/src/main/java/ch/puzzle/okr/dto/ErrorDto.java b/backend/src/main/java/ch/puzzle/okr/dto/ErrorDto.java
index 07ad03f1ae..4bd033c425 100644
--- a/backend/src/main/java/ch/puzzle/okr/dto/ErrorDto.java
+++ b/backend/src/main/java/ch/puzzle/okr/dto/ErrorDto.java
@@ -1,7 +1,6 @@
package ch.puzzle.okr.dto;
import ch.puzzle.okr.ErrorKey;
-
import java.util.List;
public record ErrorDto(String errorKey, List params) {
diff --git a/backend/src/main/java/ch/puzzle/okr/dto/ObjectiveDto.java b/backend/src/main/java/ch/puzzle/okr/dto/ObjectiveDto.java
index bf230fdcc8..9de9d8fafa 100644
--- a/backend/src/main/java/ch/puzzle/okr/dto/ObjectiveDto.java
+++ b/backend/src/main/java/ch/puzzle/okr/dto/ObjectiveDto.java
@@ -1,7 +1,6 @@
package ch.puzzle.okr.dto;
import ch.puzzle.okr.models.State;
-
import java.time.LocalDateTime;
public record ObjectiveDto(Long id, int version, String title, Long teamId, Long quarterId, String quarterLabel,
diff --git a/backend/src/main/java/ch/puzzle/okr/dto/checkin/CheckInMetricDto.java b/backend/src/main/java/ch/puzzle/okr/dto/checkin/CheckInMetricDto.java
index 03036b4cdd..190627334e 100644
--- a/backend/src/main/java/ch/puzzle/okr/dto/checkin/CheckInMetricDto.java
+++ b/backend/src/main/java/ch/puzzle/okr/dto/checkin/CheckInMetricDto.java
@@ -1,11 +1,10 @@
package ch.puzzle.okr.dto.checkin;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
import java.time.LocalDateTime;
@JsonDeserialize(as = CheckInMetricDto.class)
public record CheckInMetricDto(Long id, int version, String changeInfo, String initiatives, Integer confidence,
- Long keyResultId, LocalDateTime createdOn, LocalDateTime modifiedOn, Double value, boolean writeable)
- implements CheckInDto {
+ Long keyResultId, LocalDateTime createdOn, LocalDateTime modifiedOn, Double value,
+ boolean writeable) implements CheckInDto {
}
diff --git a/backend/src/main/java/ch/puzzle/okr/dto/checkin/CheckInOrdinalDto.java b/backend/src/main/java/ch/puzzle/okr/dto/checkin/CheckInOrdinalDto.java
index 9bab43b985..d4537437f8 100644
--- a/backend/src/main/java/ch/puzzle/okr/dto/checkin/CheckInOrdinalDto.java
+++ b/backend/src/main/java/ch/puzzle/okr/dto/checkin/CheckInOrdinalDto.java
@@ -2,11 +2,10 @@
import ch.puzzle.okr.models.checkin.Zone;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
import java.time.LocalDateTime;
@JsonDeserialize(as = CheckInOrdinalDto.class)
public record CheckInOrdinalDto(Long id, int version, String changeInfo, String initiatives, Integer confidence,
- Long keyResultId, LocalDateTime createdOn, LocalDateTime modifiedOn, Zone zone, boolean writeable)
- implements CheckInDto {
+ Long keyResultId, LocalDateTime createdOn, LocalDateTime modifiedOn, Zone zone,
+ boolean writeable) implements CheckInDto {
}
diff --git a/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultDto.java b/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultDto.java
index b461737716..95cfbc164e 100644
--- a/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultDto.java
+++ b/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultDto.java
@@ -3,7 +3,6 @@
import ch.puzzle.okr.deserializer.KeyResultDeserializer;
import ch.puzzle.okr.dto.ActionDto;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
import java.util.List;
@JsonDeserialize(using = KeyResultDeserializer.class)
diff --git a/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultLastCheckInOrdinalDto.java b/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultLastCheckInOrdinalDto.java
index 92068a47a1..16bb51003f 100644
--- a/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultLastCheckInOrdinalDto.java
+++ b/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultLastCheckInOrdinalDto.java
@@ -1,7 +1,6 @@
package ch.puzzle.okr.dto.keyresult;
import ch.puzzle.okr.models.checkin.Zone;
-
import java.time.LocalDateTime;
public record KeyResultLastCheckInOrdinalDto(Long id, int version, Zone zone, Integer confidence,
diff --git a/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultMetricDto.java b/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultMetricDto.java
index b69b360f1d..69c0d18153 100644
--- a/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultMetricDto.java
+++ b/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultMetricDto.java
@@ -3,7 +3,6 @@
import ch.puzzle.okr.dto.ActionDto;
import ch.puzzle.okr.models.Unit;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
import java.time.LocalDateTime;
import java.util.List;
diff --git a/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultOrdinalDto.java b/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultOrdinalDto.java
index 4f0365b947..44d622ea35 100644
--- a/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultOrdinalDto.java
+++ b/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultOrdinalDto.java
@@ -2,7 +2,6 @@
import ch.puzzle.okr.dto.ActionDto;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
import java.time.LocalDateTime;
import java.util.List;
diff --git a/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewKeyResultOrdinalDto.java b/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewKeyResultOrdinalDto.java
index 6097da2724..553fd0cbed 100644
--- a/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewKeyResultOrdinalDto.java
+++ b/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewKeyResultOrdinalDto.java
@@ -1,6 +1,6 @@
package ch.puzzle.okr.dto.overview;
public record OverviewKeyResultOrdinalDto(Long id, String title, String keyResultType, String commitZone,
- String targetZone, String stretchZone, OverviewLastCheckInOrdinalDto lastCheckIn)
- implements OverviewKeyResultDto {
+ String targetZone, String stretchZone,
+ OverviewLastCheckInOrdinalDto lastCheckIn) implements OverviewKeyResultDto {
}
diff --git a/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewLastCheckInMetricDto.java b/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewLastCheckInMetricDto.java
index 94e15589d8..2338903704 100644
--- a/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewLastCheckInMetricDto.java
+++ b/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewLastCheckInMetricDto.java
@@ -2,6 +2,6 @@
import java.time.LocalDateTime;
-public record OverviewLastCheckInMetricDto(Long id, Double value, Integer confidence, LocalDateTime createdOn)
- implements OverviewLastCheckInDto {
+public record OverviewLastCheckInMetricDto(Long id, Double value, Integer confidence,
+ LocalDateTime createdOn) implements OverviewLastCheckInDto {
}
diff --git a/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewLastCheckInOrdinalDto.java b/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewLastCheckInOrdinalDto.java
index 131d126373..e01f1a6781 100644
--- a/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewLastCheckInOrdinalDto.java
+++ b/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewLastCheckInOrdinalDto.java
@@ -2,6 +2,6 @@
import java.time.LocalDateTime;
-public record OverviewLastCheckInOrdinalDto(Long id, String zone, Integer confidence, LocalDateTime createdOn)
- implements OverviewLastCheckInDto {
+public record OverviewLastCheckInOrdinalDto(Long id, String zone, Integer confidence,
+ LocalDateTime createdOn) implements OverviewLastCheckInDto {
}
diff --git a/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewObjectiveDto.java b/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewObjectiveDto.java
index 403a7073b6..e0f6ccc078 100644
--- a/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewObjectiveDto.java
+++ b/backend/src/main/java/ch/puzzle/okr/dto/overview/OverviewObjectiveDto.java
@@ -1,7 +1,6 @@
package ch.puzzle.okr.dto.overview;
import ch.puzzle.okr.models.State;
-
import java.util.List;
public record OverviewObjectiveDto(Long id, String title, State state, OverviewQuarterDto quarter,
diff --git a/backend/src/main/java/ch/puzzle/okr/exception/OkrResponseStatusException.java b/backend/src/main/java/ch/puzzle/okr/exception/OkrResponseStatusException.java
index 11f666040e..712b292ecd 100644
--- a/backend/src/main/java/ch/puzzle/okr/exception/OkrResponseStatusException.java
+++ b/backend/src/main/java/ch/puzzle/okr/exception/OkrResponseStatusException.java
@@ -1,14 +1,13 @@
package ch.puzzle.okr.exception;
+import static org.springframework.http.HttpStatus.UNAUTHORIZED;
+
import ch.puzzle.okr.ErrorKey;
import ch.puzzle.okr.dto.ErrorDto;
+import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.web.server.ResponseStatusException;
-import java.util.List;
-
-import static org.springframework.http.HttpStatus.UNAUTHORIZED;
-
public class OkrResponseStatusException extends ResponseStatusException {
private final List errors;
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/ActionMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/ActionMapper.java
index 67d6d97e40..7be672faea 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/ActionMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/ActionMapper.java
@@ -4,9 +4,8 @@
import ch.puzzle.okr.models.Action;
import ch.puzzle.okr.models.keyresult.KeyResult;
import ch.puzzle.okr.service.business.KeyResultBusinessService;
-import org.springframework.stereotype.Component;
-
import java.util.List;
+import org.springframework.stereotype.Component;
@Component
public class ActionMapper {
@@ -18,8 +17,13 @@ public ActionMapper(KeyResultBusinessService keyResultBusinessService) {
}
public ActionDto toDto(Action action) {
- return new ActionDto(action.getId(), action.getVersion(), action.getAction(), action.getPriority(),
- action.isChecked(), action.getKeyResult().getId(), action.isWriteable());
+ return new ActionDto(action.getId(),
+ action.getVersion(),
+ action.getAction(),
+ action.getPriority(),
+ action.isChecked(),
+ action.getKeyResult().getId(),
+ action.isWriteable());
}
public List toActions(List actionDtos, KeyResult keyResult) {
@@ -27,14 +31,21 @@ public List toActions(List actionDtos, KeyResult keyResult) {
}
public List toActions(List actionDtos) {
- return actionDtos.stream()
+ return actionDtos
+ .stream()
.map(actionDto -> toAction(actionDto, keyResultBusinessService.getEntityById(actionDto.keyResultId())))
.toList();
}
private Action toAction(ActionDto actionDto, KeyResult keyResult) {
- return Action.Builder.builder().withId(actionDto.id()).withVersion(actionDto.version())
- .withAction(actionDto.action()).withPriority(actionDto.priority()).withIsChecked(actionDto.isChecked())
- .withKeyResult(keyResult).build();
+ return Action.Builder
+ .builder()
+ .withId(actionDto.id())
+ .withVersion(actionDto.version())
+ .withAction(actionDto.action())
+ .withPriority(actionDto.priority())
+ .withIsChecked(actionDto.isChecked())
+ .withKeyResult(keyResult)
+ .build();
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/AlignmentSelectionMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/AlignmentSelectionMapper.java
index 547181b95e..a19d82f6bb 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/AlignmentSelectionMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/AlignmentSelectionMapper.java
@@ -3,12 +3,11 @@
import ch.puzzle.okr.dto.alignment.AlignmentKeyResultDto;
import ch.puzzle.okr.dto.alignment.AlignmentObjectiveDto;
import ch.puzzle.okr.models.alignment.AlignmentSelection;
-import org.springframework.stereotype.Component;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
+import org.springframework.stereotype.Component;
@Component
public class AlignmentSelectionMapper {
@@ -20,13 +19,14 @@ public List toDto(List alignments) {
}
private Optional getMatchingObjectiveDto(Long objectiveId,
- List objectives) {
+ List objectives) {
return objectives.stream().filter(objectiveDto -> Objects.equals(objectiveId, objectiveDto.id())).findFirst();
}
private void processObjectives(List objectiveDtos, AlignmentSelection alignment) {
- Optional objectiveDto = getMatchingObjectiveDto(
- alignment.getAlignmentSelectionId().getObjectiveId(), objectiveDtos);
+ Optional objectiveDto = getMatchingObjectiveDto(alignment
+ .getAlignmentSelectionId()
+ .getObjectiveId(), objectiveDtos);
if (objectiveDto.isPresent()) {
processKeyResults(objectiveDto.get(), alignment);
} else {
@@ -44,12 +44,13 @@ private void processKeyResults(AlignmentObjectiveDto objectiveDto, AlignmentSele
private AlignmentObjectiveDto createObjectiveDto(AlignmentSelection alignment) {
return new AlignmentObjectiveDto(alignment.getAlignmentSelectionId().getObjectiveId(),
- alignment.getObjectiveTitle(), new ArrayList<>());
+ alignment.getObjectiveTitle(),
+ new ArrayList<>());
}
private AlignmentKeyResultDto createKeyResultDto(AlignmentSelection alignment) {
return new AlignmentKeyResultDto(alignment.getAlignmentSelectionId().getKeyResultId(),
- alignment.getKeyResultTitle());
+ alignment.getKeyResultTitle());
}
private boolean isValidId(Long id) {
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/CompletedMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/CompletedMapper.java
index fec0b71b93..53e29e39cc 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/CompletedMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/CompletedMapper.java
@@ -15,13 +15,14 @@ public CompletedMapper(ObjectiveMapper objectiveMapper) {
public CompletedDto toDto(Completed completed) {
return new CompletedDto( //
- completed.getId(), //
- objectiveMapper.toDto(completed.getObjective()), //
- completed.getComment());
+ completed.getId(), //
+ objectiveMapper.toDto(completed.getObjective()), //
+ completed.getComment());
}
public Completed toCompleted(CompletedDto completedDto) {
- return Completed.Builder.builder() //
+ return Completed.Builder
+ .builder() //
.withId(completedDto.id()) //
.withObjective(objectiveMapper.toObjective(completedDto.objective())) //
.withComment(completedDto.comment()) //
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/ObjectiveMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/ObjectiveMapper.java
index a65574c408..1334d6d663 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/ObjectiveMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/ObjectiveMapper.java
@@ -4,9 +4,8 @@
import ch.puzzle.okr.models.Objective;
import ch.puzzle.okr.service.business.QuarterBusinessService;
import ch.puzzle.okr.service.business.TeamBusinessService;
-import org.springframework.stereotype.Component;
-
import java.time.LocalDateTime;
+import org.springframework.stereotype.Component;
@Component
public class ObjectiveMapper {
@@ -20,17 +19,31 @@ public ObjectiveMapper(TeamBusinessService teamBusinessService, QuarterBusinessS
}
public ObjectiveDto toDto(Objective objective) {
- return new ObjectiveDto(objective.getId(), objective.getVersion(), objective.getTitle(),
- objective.getTeam().getId(), objective.getQuarter().getId(), objective.getQuarter().getLabel(),
- objective.getDescription(), objective.getState(), objective.getCreatedOn(), objective.getModifiedOn(),
- objective.isWriteable());
+ return new ObjectiveDto(objective.getId(),
+ objective.getVersion(),
+ objective.getTitle(),
+ objective.getTeam().getId(),
+ objective.getQuarter().getId(),
+ objective.getQuarter().getLabel(),
+ objective.getDescription(),
+ objective.getState(),
+ objective.getCreatedOn(),
+ objective.getModifiedOn(),
+ objective.isWriteable());
}
public Objective toObjective(ObjectiveDto objectiveDto) {
- return Objective.Builder.builder().withId(objectiveDto.id()).withVersion(objectiveDto.version())
- .withTitle(objectiveDto.title()).withTeam(teamBusinessService.getTeamById(objectiveDto.teamId()))
- .withDescription(objectiveDto.description()).withModifiedOn(LocalDateTime.now())
- .withState(objectiveDto.state()).withCreatedOn(objectiveDto.createdOn())
- .withQuarter(quarterBusinessService.getQuarterById(objectiveDto.quarterId())).build();
+ return Objective.Builder
+ .builder()
+ .withId(objectiveDto.id())
+ .withVersion(objectiveDto.version())
+ .withTitle(objectiveDto.title())
+ .withTeam(teamBusinessService.getTeamById(objectiveDto.teamId()))
+ .withDescription(objectiveDto.description())
+ .withModifiedOn(LocalDateTime.now())
+ .withState(objectiveDto.state())
+ .withCreatedOn(objectiveDto.createdOn())
+ .withQuarter(quarterBusinessService.getQuarterById(objectiveDto.quarterId()))
+ .build();
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/OverviewMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/OverviewMapper.java
index 2051b17b89..5a3a0959cd 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/OverviewMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/OverviewMapper.java
@@ -1,19 +1,18 @@
package ch.puzzle.okr.mapper;
+import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_METRIC;
+import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_ORDINAL;
+import static org.springframework.http.HttpStatus.BAD_REQUEST;
+
import ch.puzzle.okr.ErrorKey;
import ch.puzzle.okr.dto.overview.*;
import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.models.overview.Overview;
-import org.springframework.stereotype.Component;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
-
-import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_METRIC;
-import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_ORDINAL;
-import static org.springframework.http.HttpStatus.BAD_REQUEST;
+import org.springframework.stereotype.Component;
@Component
public class OverviewMapper {
@@ -31,7 +30,7 @@ private Optional getMatchingOverviewDto(Long teamId, List getMatchingObjectiveDto(Long objectiveId,
- List objectives) {
+ List objectives) {
return objectives.stream().filter(objectiveDto -> Objects.equals(objectiveId, objectiveDto.id())).findFirst();
}
@@ -45,8 +44,9 @@ private void processTeams(List overviewDtos, Overview overview) {
}
private void processObjectives(OverviewDto overviewDto, Overview overview) {
- Optional overviewObjectiveDto = getMatchingObjectiveDto(
- overview.getOverviewId().getObjectiveId(), overviewDto.objectives());
+ Optional overviewObjectiveDto = getMatchingObjectiveDto(overview
+ .getOverviewId()
+ .getObjectiveId(), overviewDto.objectives());
if (overviewObjectiveDto.isPresent()) {
processKeyResults(overviewObjectiveDto.get(), overview);
} else {
@@ -64,7 +64,8 @@ private OverviewDto createOverviewDto(Overview overview) {
objectives.add(createObjectiveDto(overview));
}
return new OverviewDto(new OverviewTeamDto(overview.getOverviewId().getTeamId(), overview.getTeamName()),
- objectives, overview.isWriteable());
+ objectives,
+ overview.isWriteable());
}
private OverviewObjectiveDto createObjectiveDto(Overview overview) {
@@ -72,9 +73,11 @@ private OverviewObjectiveDto createObjectiveDto(Overview overview) {
if (isValidId(overview.getOverviewId().getKeyResultId())) {
keyResults.add(createKeyResultDto(overview));
}
- return new OverviewObjectiveDto(overview.getOverviewId().getObjectiveId(), overview.getObjectiveTitle(),
- overview.getObjectiveState(),
- new OverviewQuarterDto(overview.getQuarterId(), overview.getQuarterLabel()), keyResults);
+ return new OverviewObjectiveDto(overview.getOverviewId().getObjectiveId(),
+ overview.getObjectiveTitle(),
+ overview.getObjectiveState(),
+ new OverviewQuarterDto(overview.getQuarterId(), overview.getQuarterLabel()),
+ keyResults);
}
private OverviewKeyResultDto createKeyResultDto(Overview overview) {
@@ -83,8 +86,9 @@ private OverviewKeyResultDto createKeyResultDto(Overview overview) {
} else if (Objects.equals(overview.getKeyResultType(), KEY_RESULT_TYPE_ORDINAL)) {
return createKeyResultOrdinalDto(overview);
} else {
- throw new OkrResponseStatusException(BAD_REQUEST, ErrorKey.KEY_RESULT_CONVERSION,
- overview.getKeyResultType());
+ throw new OkrResponseStatusException(BAD_REQUEST,
+ ErrorKey.KEY_RESULT_CONVERSION,
+ overview.getKeyResultType());
}
}
@@ -92,22 +96,34 @@ private OverviewKeyResultMetricDto createKeyResultMetricDto(Overview overview) {
OverviewLastCheckInMetricDto lastCheckIn = null;
if (isValidId(overview.getOverviewId().getCheckInId())) {
lastCheckIn = new OverviewLastCheckInMetricDto(overview.getOverviewId().getCheckInId(),
- overview.getCheckInValue(), overview.getConfidence(), overview.getCheckInCreatedOn());
+ overview.getCheckInValue(),
+ overview.getConfidence(),
+ overview.getCheckInCreatedOn());
}
- return new OverviewKeyResultMetricDto(overview.getOverviewId().getKeyResultId(), overview.getKeyResultTitle(),
- overview.getKeyResultType(), overview.getUnit(), overview.getBaseline(), overview.getStretchGoal(),
- lastCheckIn);
+ return new OverviewKeyResultMetricDto(overview.getOverviewId().getKeyResultId(),
+ overview.getKeyResultTitle(),
+ overview.getKeyResultType(),
+ overview.getUnit(),
+ overview.getBaseline(),
+ overview.getStretchGoal(),
+ lastCheckIn);
}
private OverviewKeyResultOrdinalDto createKeyResultOrdinalDto(Overview overview) {
OverviewLastCheckInOrdinalDto lastCheckIn = null;
if (isValidId(overview.getOverviewId().getCheckInId())) {
lastCheckIn = new OverviewLastCheckInOrdinalDto(overview.getOverviewId().getCheckInId(),
- overview.getCheckInZone(), overview.getConfidence(), overview.getCheckInCreatedOn());
+ overview.getCheckInZone(),
+ overview.getConfidence(),
+ overview.getCheckInCreatedOn());
}
- return new OverviewKeyResultOrdinalDto(overview.getOverviewId().getKeyResultId(), overview.getKeyResultTitle(),
- overview.getKeyResultType(), overview.getCommitZone(), overview.getTargetZone(),
- overview.getStretchZone(), lastCheckIn);
+ return new OverviewKeyResultOrdinalDto(overview.getOverviewId().getKeyResultId(),
+ overview.getKeyResultTitle(),
+ overview.getKeyResultType(),
+ overview.getCommitZone(),
+ overview.getTargetZone(),
+ overview.getStretchZone(),
+ lastCheckIn);
}
private boolean isValidId(Long id) {
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/TeamMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/TeamMapper.java
index 792bc027e6..2f9f48005b 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/TeamMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/TeamMapper.java
@@ -15,7 +15,11 @@ public TeamDto toDto(Team team) {
}
public Team toTeam(TeamDto teamDto) {
- return Team.Builder.builder().withId(teamDto.id()).withVersion(teamDto.version()).withName(teamDto.name())
+ return Team.Builder
+ .builder()
+ .withId(teamDto.id())
+ .withVersion(teamDto.version())
+ .withName(teamDto.name())
.build();
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/UserMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/UserMapper.java
index 8d2f3c1892..6ad179fd5d 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/UserMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/UserMapper.java
@@ -4,10 +4,9 @@
import ch.puzzle.okr.dto.UserDto;
import ch.puzzle.okr.dto.UserTeamDto;
import ch.puzzle.okr.models.User;
-import org.springframework.stereotype.Component;
-
import java.util.List;
import java.util.stream.Collectors;
+import org.springframework.stereotype.Component;
@Component
public class UserMapper {
@@ -23,12 +22,22 @@ public List toDtos(List userList) {
}
public UserDto toDto(User user) {
- var userTeams = user.getUserTeamList().stream().map(
- ut -> new UserTeamDto(ut.getId(), user.getVersion(), teamMapper.toDto(ut.getTeam()), ut.isTeamAdmin()))
+ var userTeams = user
+ .getUserTeamList()
+ .stream()
+ .map(ut -> new UserTeamDto(ut.getId(),
+ user.getVersion(),
+ teamMapper.toDto(ut.getTeam()),
+ ut.isTeamAdmin()))
.collect(Collectors.toList());
- return new UserDto(user.getId(), user.getVersion(), user.getFirstname(), user.getLastname(), user.getEmail(),
- userTeams, user.isOkrChampion());
+ return new UserDto(user.getId(),
+ user.getVersion(),
+ user.getFirstname(),
+ user.getLastname(),
+ user.getEmail(),
+ userTeams,
+ user.isOkrChampion());
}
public List toUserList(List newUserList) {
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/UserOkrDataMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/UserOkrDataMapper.java
index 88fc383bf2..0b4a411c15 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/UserOkrDataMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/UserOkrDataMapper.java
@@ -3,9 +3,8 @@
import ch.puzzle.okr.dto.userOkrData.UserKeyResultDataDto;
import ch.puzzle.okr.dto.userOkrData.UserOkrDataDto;
import ch.puzzle.okr.models.keyresult.KeyResult;
-import org.springframework.stereotype.Component;
-
import java.util.List;
+import org.springframework.stereotype.Component;
@Component
public class UserOkrDataMapper {
@@ -15,10 +14,13 @@ public UserOkrDataDto toDto(List keyResults) {
}
private List toUserKeyResultDataDtos(List keyResults) {
- return keyResults.stream() //
+ return keyResults
+ .stream() //
.map(keyResult -> new UserKeyResultDataDto( //
- keyResult.getId(), keyResult.getTitle(), //
- keyResult.getObjective().getId(), keyResult.getObjective().getTitle() //
+ keyResult.getId(),
+ keyResult.getTitle(), //
+ keyResult.getObjective().getId(),
+ keyResult.getObjective().getTitle() //
)) //
.toList();
}
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/checkin/CheckInMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/checkin/CheckInMapper.java
index 34ab137035..e6a0642fac 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/checkin/CheckInMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/checkin/CheckInMapper.java
@@ -27,7 +27,9 @@ public CheckInDto toDto(CheckIn checkIn) {
return checkInOrdinalMapper.toDto(checkInOrdinal);
} else {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST,
- String.format("The CheckIn %s can't be converted to a metric or ordinal CheckIn", checkIn));
+ String
+ .format("The CheckIn %s can't be converted to a metric or ordinal CheckIn",
+ checkIn));
}
}
@@ -38,7 +40,9 @@ public CheckIn toCheckIn(CheckInDto checkInDto) {
return checkInOrdinalMapper.toCheckInOrdinal((CheckInOrdinalDto) checkInDto);
} else {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST,
- String.format("The provided CheckInDto %s is neither metric nor ordinal", checkInDto));
+ String
+ .format("The provided CheckInDto %s is neither metric nor ordinal",
+ checkInDto));
}
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/checkin/CheckInMetricMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/checkin/CheckInMetricMapper.java
index 814adc85f2..fcf153ae06 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/checkin/CheckInMetricMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/checkin/CheckInMetricMapper.java
@@ -16,19 +16,20 @@ public CheckInMetricMapper(KeyResultBusinessService keyResultBusinessService) {
public CheckInMetricDto toDto(CheckInMetric checkInMetric) {
return new CheckInMetricDto(checkInMetric.getId(), //
- checkInMetric.getVersion(), //
- checkInMetric.getChangeInfo(), //
- checkInMetric.getInitiatives(), //
- checkInMetric.getConfidence(), //
- checkInMetric.getKeyResult().getId(), //
- checkInMetric.getCreatedOn(), //
- checkInMetric.getModifiedOn(), //
- checkInMetric.getValue(), //
- checkInMetric.isWriteable());
+ checkInMetric.getVersion(), //
+ checkInMetric.getChangeInfo(), //
+ checkInMetric.getInitiatives(), //
+ checkInMetric.getConfidence(), //
+ checkInMetric.getKeyResult().getId(), //
+ checkInMetric.getCreatedOn(), //
+ checkInMetric.getModifiedOn(), //
+ checkInMetric.getValue(), //
+ checkInMetric.isWriteable());
}
public CheckIn toCheckInMetric(CheckInMetricDto checkInMetricDto) {
- return CheckInMetric.Builder.builder() //
+ return CheckInMetric.Builder
+ .builder() //
.withValue(checkInMetricDto.value()) //
.withId(checkInMetricDto.id()) //
.withVersion(checkInMetricDto.version()) //
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/checkin/CheckInOrdinalMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/checkin/CheckInOrdinalMapper.java
index 5bc4f811b8..da32c06a86 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/checkin/CheckInOrdinalMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/checkin/CheckInOrdinalMapper.java
@@ -15,19 +15,21 @@ public CheckInOrdinalMapper(KeyResultBusinessService keyResultBusinessService) {
}
public CheckInOrdinalDto toDto(CheckInOrdinal checkInOrdinal) {
- return new CheckInOrdinalDto(checkInOrdinal.getId(), checkInOrdinal.getVersion(), //
- checkInOrdinal.getChangeInfo(), //
- checkInOrdinal.getInitiatives(), //
- checkInOrdinal.getConfidence(), //
- checkInOrdinal.getKeyResult().getId(), //
- checkInOrdinal.getCreatedOn(), //
- checkInOrdinal.getModifiedOn(), //
- checkInOrdinal.getZone(), //
- checkInOrdinal.isWriteable());
+ return new CheckInOrdinalDto(checkInOrdinal.getId(),
+ checkInOrdinal.getVersion(), //
+ checkInOrdinal.getChangeInfo(), //
+ checkInOrdinal.getInitiatives(), //
+ checkInOrdinal.getConfidence(), //
+ checkInOrdinal.getKeyResult().getId(), //
+ checkInOrdinal.getCreatedOn(), //
+ checkInOrdinal.getModifiedOn(), //
+ checkInOrdinal.getZone(), //
+ checkInOrdinal.isWriteable());
}
public CheckIn toCheckInOrdinal(CheckInOrdinalDto checkInOrdinalDto) {
- return CheckInOrdinal.Builder.builder() //
+ return CheckInOrdinal.Builder
+ .builder() //
.withZone(checkInOrdinalDto.zone()) //
.withId(checkInOrdinalDto.id()) //
.withVersion(checkInOrdinalDto.version()) //
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultMapper.java
index 9078dbd04d..2f9434045f 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultMapper.java
@@ -1,5 +1,7 @@
package ch.puzzle.okr.mapper.keyresult;
+import static org.springframework.http.HttpStatus.BAD_REQUEST;
+
import ch.puzzle.okr.dto.keyresult.KeyResultDto;
import ch.puzzle.okr.dto.keyresult.KeyResultMetricDto;
import ch.puzzle.okr.dto.keyresult.KeyResultOrdinalDto;
@@ -7,13 +9,10 @@
import ch.puzzle.okr.models.keyresult.KeyResult;
import ch.puzzle.okr.models.keyresult.KeyResultMetric;
import ch.puzzle.okr.models.keyresult.KeyResultOrdinal;
+import java.util.List;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ResponseStatusException;
-import java.util.List;
-
-import static org.springframework.http.HttpStatus.BAD_REQUEST;
-
@Component
public class KeyResultMapper {
@@ -32,7 +31,9 @@ public KeyResultDto toDto(KeyResult keyResult, List actionList) {
return keyResultOrdinalMapper.toDto(keyResultOrdinal, actionList);
} else {
throw new ResponseStatusException(BAD_REQUEST,
- String.format("The KeyResult %s can't be converted to a metric or ordinal KeyResult", keyResult));
+ String
+ .format("The KeyResult %s can't be converted to a metric or ordinal KeyResult",
+ keyResult));
}
}
@@ -43,7 +44,9 @@ public KeyResult toKeyResult(KeyResultDto keyResultDto) {
return keyResultOrdinalMapper.toKeyResultOrdinal((KeyResultOrdinalDto) keyResultDto);
} else {
throw new ResponseStatusException(BAD_REQUEST,
- String.format("The provided KeyResultDto %s is neither metric nor ordinal", keyResultDto));
+ String
+ .format("The provided KeyResultDto %s is neither metric nor ordinal",
+ keyResultDto));
}
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultMetricMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultMetricMapper.java
index e285304f06..e84d2520ef 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultMetricMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultMetricMapper.java
@@ -10,9 +10,8 @@
import ch.puzzle.okr.service.business.CheckInBusinessService;
import ch.puzzle.okr.service.business.ObjectiveBusinessService;
import ch.puzzle.okr.service.business.UserBusinessService;
-import org.springframework.stereotype.Component;
-
import java.util.List;
+import org.springframework.stereotype.Component;
@Component
public class KeyResultMetricMapper {
@@ -23,8 +22,8 @@ public class KeyResultMetricMapper {
private final ActionMapper actionMapper;
public KeyResultMetricMapper(UserBusinessService userBusinessService,
- ObjectiveBusinessService objectiveBusinessService, CheckInBusinessService checkInBusinessService,
- ActionMapper actionMapper) {
+ ObjectiveBusinessService objectiveBusinessService,
+ CheckInBusinessService checkInBusinessService, ActionMapper actionMapper) {
this.userBusinessService = userBusinessService;
this.objectiveBusinessService = objectiveBusinessService;
this.checkInBusinessService = checkInBusinessService;
@@ -33,42 +32,44 @@ public KeyResultMetricMapper(UserBusinessService userBusinessService,
public KeyResultDto toDto(KeyResultMetric keyResult, List actionList) {
KeyResultUserDto ownerDto = new KeyResultUserDto( //
- keyResult.getOwner().getId(), //
- keyResult.getOwner().getFirstname(), //
- keyResult.getOwner().getLastname());
+ keyResult.getOwner().getId(), //
+ keyResult.getOwner().getFirstname(), //
+ keyResult.getOwner().getLastname());
KeyResultQuarterDto quarterDto = new KeyResultQuarterDto( //
- keyResult.getObjective().getQuarter().getId(), //
- keyResult.getObjective().getQuarter().getLabel(), //
- keyResult.getObjective().getQuarter().getStartDate(), //
- keyResult.getObjective().getQuarter().getEndDate());
+ keyResult.getObjective().getQuarter().getId(), //
+ keyResult.getObjective().getQuarter().getLabel(), //
+ keyResult.getObjective().getQuarter().getStartDate(), //
+ keyResult.getObjective().getQuarter().getEndDate());
KeyResultObjectiveDto objectiveDto = new KeyResultObjectiveDto( //
- keyResult.getObjective().getId(), //
- keyResult.getObjective().getState().toString(), //
- quarterDto);
+ keyResult.getObjective().getId(), //
+ keyResult.getObjective().getState().toString(), //
+ quarterDto);
KeyResultLastCheckInMetricDto lastCheckInDto = getLastCheckInDto(keyResult.getId());
return new KeyResultMetricDto( //
- keyResult.getId(), //
- keyResult.getVersion(), //
- keyResult.getKeyResultType(), //
- keyResult.getTitle(), //
- keyResult.getDescription(), //
- keyResult.getBaseline(), //
- keyResult.getStretchGoal(), //
- keyResult.getUnit(), //
- ownerDto, objectiveDto, //
- lastCheckInDto, //
- keyResult.getCreatedOn(), //
- keyResult.getModifiedOn(), //
- keyResult.isWriteable(), //
- actionList.stream().map(actionMapper::toDto).toList());
+ keyResult.getId(), //
+ keyResult.getVersion(), //
+ keyResult.getKeyResultType(), //
+ keyResult.getTitle(), //
+ keyResult.getDescription(), //
+ keyResult.getBaseline(), //
+ keyResult.getStretchGoal(), //
+ keyResult.getUnit(), //
+ ownerDto,
+ objectiveDto, //
+ lastCheckInDto, //
+ keyResult.getCreatedOn(), //
+ keyResult.getModifiedOn(), //
+ keyResult.isWriteable(), //
+ actionList.stream().map(actionMapper::toDto).toList());
}
public KeyResult toKeyResultMetric(KeyResultMetricDto keyResultMetricDto) {
- return KeyResultMetric.Builder.builder() //
+ return KeyResultMetric.Builder
+ .builder() //
.withBaseline(keyResultMetricDto.baseline()) //
.withStretchGoal(keyResultMetricDto.stretchGoal()) //
.withUnit(keyResultMetricDto.unit()) //
@@ -88,8 +89,12 @@ public KeyResultLastCheckInMetricDto getLastCheckInDto(Long keyResultId) {
if (lastCheckIn == null) {
return null;
}
- return new KeyResultLastCheckInMetricDto(lastCheckIn.getId(), lastCheckIn.getVersion(),
- ((CheckInMetric) lastCheckIn).getValue(), lastCheckIn.getConfidence(), lastCheckIn.getCreatedOn(),
- lastCheckIn.getChangeInfo(), lastCheckIn.getInitiatives());
+ return new KeyResultLastCheckInMetricDto(lastCheckIn.getId(),
+ lastCheckIn.getVersion(),
+ ((CheckInMetric) lastCheckIn).getValue(),
+ lastCheckIn.getConfidence(),
+ lastCheckIn.getCreatedOn(),
+ lastCheckIn.getChangeInfo(),
+ lastCheckIn.getInitiatives());
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultOrdinalMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultOrdinalMapper.java
index e62c93b482..1e7f286e2c 100644
--- a/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultOrdinalMapper.java
+++ b/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultOrdinalMapper.java
@@ -10,9 +10,8 @@
import ch.puzzle.okr.service.business.CheckInBusinessService;
import ch.puzzle.okr.service.business.ObjectiveBusinessService;
import ch.puzzle.okr.service.business.UserBusinessService;
-import org.springframework.stereotype.Component;
-
import java.util.List;
+import org.springframework.stereotype.Component;
@Component
public class KeyResultOrdinalMapper {
@@ -23,8 +22,8 @@ public class KeyResultOrdinalMapper {
private final ActionMapper actionMapper;
public KeyResultOrdinalMapper(UserBusinessService userBusinessService,
- ObjectiveBusinessService objectiveBusinessService, CheckInBusinessService checkInBusinessService,
- ActionMapper actionMapper) {
+ ObjectiveBusinessService objectiveBusinessService,
+ CheckInBusinessService checkInBusinessService, ActionMapper actionMapper) {
this.userBusinessService = userBusinessService;
this.objectiveBusinessService = objectiveBusinessService;
this.checkInBusinessService = checkInBusinessService;
@@ -33,43 +32,44 @@ public KeyResultOrdinalMapper(UserBusinessService userBusinessService,
public KeyResultDto toDto(KeyResultOrdinal keyResult, List actionList) {
KeyResultUserDto ownerDto = new KeyResultUserDto( //
- keyResult.getOwner().getId(), //
- keyResult.getOwner().getFirstname(), //
- keyResult.getOwner().getLastname());
+ keyResult.getOwner().getId(), //
+ keyResult.getOwner().getFirstname(), //
+ keyResult.getOwner().getLastname());
KeyResultQuarterDto quarterDto = new KeyResultQuarterDto( //
- keyResult.getObjective().getQuarter().getId(), //
- keyResult.getObjective().getQuarter().getLabel(), //
- keyResult.getObjective().getQuarter().getStartDate(), //
- keyResult.getObjective().getQuarter().getEndDate());
+ keyResult.getObjective().getQuarter().getId(), //
+ keyResult.getObjective().getQuarter().getLabel(), //
+ keyResult.getObjective().getQuarter().getStartDate(), //
+ keyResult.getObjective().getQuarter().getEndDate());
KeyResultObjectiveDto objectiveDto = new KeyResultObjectiveDto( //
- keyResult.getObjective().getId(), //
- keyResult.getObjective().getState().toString(), //
- quarterDto);
+ keyResult.getObjective().getId(), //
+ keyResult.getObjective().getState().toString(), //
+ quarterDto);
KeyResultLastCheckInOrdinalDto lastCheckInDto = getLastCheckInDto(keyResult.getId());
return new KeyResultOrdinalDto( //
- keyResult.getId(), //
- keyResult.getVersion(), //
- keyResult.getKeyResultType(), //
- keyResult.getTitle(), //
- keyResult.getDescription(), //
- keyResult.getCommitZone(), //
- keyResult.getTargetZone(), //
- keyResult.getStretchZone(), //
- ownerDto, //
- objectiveDto, //
- lastCheckInDto, //
- keyResult.getCreatedOn(), //
- keyResult.getModifiedOn(), //
- keyResult.isWriteable(), //
- actionList.stream().map(actionMapper::toDto).toList());
+ keyResult.getId(), //
+ keyResult.getVersion(), //
+ keyResult.getKeyResultType(), //
+ keyResult.getTitle(), //
+ keyResult.getDescription(), //
+ keyResult.getCommitZone(), //
+ keyResult.getTargetZone(), //
+ keyResult.getStretchZone(), //
+ ownerDto, //
+ objectiveDto, //
+ lastCheckInDto, //
+ keyResult.getCreatedOn(), //
+ keyResult.getModifiedOn(), //
+ keyResult.isWriteable(), //
+ actionList.stream().map(actionMapper::toDto).toList());
}
public KeyResult toKeyResultOrdinal(KeyResultOrdinalDto keyResultOrdinalDto) {
- return KeyResultOrdinal.Builder.builder() //
+ return KeyResultOrdinal.Builder
+ .builder() //
.withCommitZone(keyResultOrdinalDto.commitZone()) //
.withTargetZone(keyResultOrdinalDto.targetZone()) //
.withStretchZone(keyResultOrdinalDto.stretchZone()) //
@@ -89,8 +89,12 @@ public KeyResultLastCheckInOrdinalDto getLastCheckInDto(Long keyResultId) {
if (lastCheckIn == null) {
return null;
}
- return new KeyResultLastCheckInOrdinalDto(lastCheckIn.getId(), lastCheckIn.getVersion(),
- ((CheckInOrdinal) lastCheckIn).getZone(), lastCheckIn.getConfidence(), lastCheckIn.getCreatedOn(),
- lastCheckIn.getChangeInfo(), lastCheckIn.getInitiatives());
+ return new KeyResultLastCheckInOrdinalDto(lastCheckIn.getId(),
+ lastCheckIn.getVersion(),
+ ((CheckInOrdinal) lastCheckIn).getZone(),
+ lastCheckIn.getConfidence(),
+ lastCheckIn.getCreatedOn(),
+ lastCheckIn.getChangeInfo(),
+ lastCheckIn.getInitiatives());
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/models/Action.java b/backend/src/main/java/ch/puzzle/okr/models/Action.java
index eabed114da..793f7ec297 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/Action.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/Action.java
@@ -1,7 +1,6 @@
package ch.puzzle.okr.models;
import ch.puzzle.okr.models.keyresult.KeyResult;
-
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
@@ -106,7 +105,7 @@ public void setWriteable(boolean writeable) {
@Override
public String toString() {
return "Action{" + "id=" + id + ", version=" + version + ", action='" + action + '\'' + ", priority=" + priority
- + ", isChecked=" + isChecked + ", keyResult=" + keyResult + ", writeable=" + writeable + '}';
+ + ", isChecked=" + isChecked + ", keyResult=" + keyResult + ", writeable=" + writeable + '}';
}
@Override
@@ -117,8 +116,8 @@ public boolean equals(Object o) {
return false;
Action action1 = (Action) o;
return version == action1.version && priority == action1.priority && isChecked == action1.isChecked
- && writeable == action1.writeable && Objects.equals(id, action1.id)
- && Objects.equals(action, action1.action) && Objects.equals(keyResult, action1.keyResult);
+ && writeable == action1.writeable && Objects.equals(id, action1.id)
+ && Objects.equals(action, action1.action) && Objects.equals(keyResult, action1.keyResult);
}
@Override
diff --git a/backend/src/main/java/ch/puzzle/okr/models/Completed.java b/backend/src/main/java/ch/puzzle/okr/models/Completed.java
index 7900c2910e..ea77c1d780 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/Completed.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/Completed.java
@@ -59,7 +59,7 @@ public void setComment(String comment) {
@Override
public String toString() {
return "Completed{" + "id=" + id + ", version=" + version + ", objective=" + objective + ", comment='" + comment
- + '\'' + '}';
+ + '\'' + '}';
}
@Override
@@ -70,7 +70,7 @@ public boolean equals(Object o) {
return false;
Completed completed = (Completed) o;
return Objects.equals(id, completed.id) && version == completed.version
- && Objects.equals(objective, completed.objective) && Objects.equals(comment, completed.comment);
+ && Objects.equals(objective, completed.objective) && Objects.equals(comment, completed.comment);
}
@Override
diff --git a/backend/src/main/java/ch/puzzle/okr/models/Objective.java b/backend/src/main/java/ch/puzzle/okr/models/Objective.java
index 85a96b59dd..99baa745db 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/Objective.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/Objective.java
@@ -4,7 +4,6 @@
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
-
import java.time.LocalDateTime;
import java.util.Objects;
@@ -163,9 +162,9 @@ public void setWriteable(boolean writeable) {
@Override
public String toString() {
return "Objective{" + "id=" + id + ", version=" + version + ", title='" + title + '\'' + ", createdBy="
- + createdBy + ", team=" + team + ", quarter=" + quarter + ", description='" + description + '\''
- + ", modifiedOn=" + modifiedOn + ", state=" + state + ", createdOn=" + createdOn + ", modifiedBy="
- + modifiedBy + ", writeable=" + writeable + '\'' + '}';
+ + createdBy + ", team=" + team + ", quarter=" + quarter + ", description='" + description + '\''
+ + ", modifiedOn=" + modifiedOn + ", state=" + state + ", createdOn=" + createdOn + ", modifiedBy="
+ + modifiedBy + ", writeable=" + writeable + '\'' + '}';
}
@Override
@@ -176,17 +175,27 @@ public boolean equals(Object o) {
return false;
Objective objective = (Objective) o;
return Objects.equals(id, objective.id) && version == objective.version
- && Objects.equals(title, objective.title) && Objects.equals(createdBy, objective.createdBy)
- && Objects.equals(team, objective.team) && Objects.equals(quarter, objective.quarter)
- && Objects.equals(description, objective.description)
- && Objects.equals(modifiedOn, objective.modifiedOn) && state == objective.state
- && Objects.equals(createdOn, objective.createdOn) && Objects.equals(modifiedBy, objective.modifiedBy);
+ && Objects.equals(title, objective.title) && Objects.equals(createdBy, objective.createdBy)
+ && Objects.equals(team, objective.team) && Objects.equals(quarter, objective.quarter)
+ && Objects.equals(description, objective.description) && Objects.equals(modifiedOn, objective.modifiedOn)
+ && state == objective.state && Objects.equals(createdOn, objective.createdOn)
+ && Objects.equals(modifiedBy, objective.modifiedBy);
}
@Override
public int hashCode() {
- return Objects.hash(id, version, title, createdBy, team, quarter, description, modifiedOn, state, createdOn,
- modifiedBy);
+ return Objects
+ .hash(id,
+ version,
+ title,
+ createdBy,
+ team,
+ quarter,
+ description,
+ modifiedOn,
+ state,
+ createdOn,
+ modifiedBy);
}
public static final class Builder {
diff --git a/backend/src/main/java/ch/puzzle/okr/models/Quarter.java b/backend/src/main/java/ch/puzzle/okr/models/Quarter.java
index 537e0aa955..7c008cf3b3 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/Quarter.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/Quarter.java
@@ -2,7 +2,6 @@
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
-
import java.time.LocalDate;
import java.util.Objects;
@@ -62,7 +61,7 @@ public void setEndDate(LocalDate endDate) {
@Override
public String toString() {
return "Quarter{" + "id=" + id + ", label='" + label + '\'' + ", startDate=" + startDate + ", endDate="
- + endDate + '}';
+ + endDate + '}';
}
@Override
@@ -73,7 +72,7 @@ public boolean equals(Object o) {
return false;
Quarter quarter = (Quarter) o;
return Objects.equals(id, quarter.id) && Objects.equals(label, quarter.label)
- && Objects.equals(startDate, quarter.startDate) && Objects.equals(endDate, quarter.endDate);
+ && Objects.equals(startDate, quarter.startDate) && Objects.equals(endDate, quarter.endDate);
}
@Override
diff --git a/backend/src/main/java/ch/puzzle/okr/models/State.java b/backend/src/main/java/ch/puzzle/okr/models/State.java
index 0099fcec97..5c12201a7e 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/State.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/State.java
@@ -1,5 +1,8 @@
package ch.puzzle.okr.models;
public enum State {
- SUCCESSFUL, NOTSUCCESSFUL, ONGOING, DRAFT
+ SUCCESSFUL,
+ NOTSUCCESSFUL,
+ ONGOING,
+ DRAFT
}
diff --git a/backend/src/main/java/ch/puzzle/okr/models/Team.java b/backend/src/main/java/ch/puzzle/okr/models/Team.java
index 0099a9ba43..dd81ba7f35 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/Team.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/Team.java
@@ -4,7 +4,6 @@
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
-
import java.util.List;
import java.util.Objects;
@@ -85,7 +84,7 @@ public boolean equals(Object o) {
return false;
Team team = (Team) o;
return Objects.equals(id, team.id) && Objects.equals(version, team.version) && Objects.equals(name, team.name)
- && Objects.equals(writeable, team.writeable);
+ && Objects.equals(writeable, team.writeable);
}
@Override
diff --git a/backend/src/main/java/ch/puzzle/okr/models/Unit.java b/backend/src/main/java/ch/puzzle/okr/models/Unit.java
index 13aff3bb47..941fb85f43 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/Unit.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/Unit.java
@@ -1,5 +1,9 @@
package ch.puzzle.okr.models;
public enum Unit {
- PERCENT, CHF, EUR, FTE, NUMBER
+ PERCENT,
+ CHF,
+ EUR,
+ FTE,
+ NUMBER
}
diff --git a/backend/src/main/java/ch/puzzle/okr/models/User.java b/backend/src/main/java/ch/puzzle/okr/models/User.java
index 5bfa5e425b..e92d9b2e3d 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/User.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/User.java
@@ -5,7 +5,6 @@
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -109,7 +108,7 @@ public void setOkrChampion(boolean okrChampion) {
@Override
public String toString() {
return "User{" + "id=" + id + ", version=" + version + ", firstname='" + firstname + '\'' + ", lastname='"
- + lastname + '\'' + ", email='" + email + '\'' + ", isOkrChampion='" + isOkrChampion + '\'' + '}';
+ + lastname + '\'' + ", email='" + email + '\'' + ", isOkrChampion='" + isOkrChampion + '\'' + '}';
}
@Override
@@ -120,8 +119,8 @@ public boolean equals(Object o) {
return false;
User user = (User) o;
return Objects.equals(id, user.id) && Objects.equals(version, user.version)
- && Objects.equals(firstname, user.firstname) && Objects.equals(lastname, user.lastname)
- && Objects.equals(email, user.email) && Objects.equals(isOkrChampion, user.isOkrChampion);
+ && Objects.equals(firstname, user.firstname) && Objects.equals(lastname, user.lastname)
+ && Objects.equals(email, user.email) && Objects.equals(isOkrChampion, user.isOkrChampion);
}
@Override
diff --git a/backend/src/main/java/ch/puzzle/okr/models/UserTeam.java b/backend/src/main/java/ch/puzzle/okr/models/UserTeam.java
index 3f14e7c811..281f02faf6 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/UserTeam.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/UserTeam.java
@@ -1,7 +1,6 @@
package ch.puzzle.okr.models;
import jakarta.persistence.*;
-
import java.util.Objects;
@Entity
@@ -88,7 +87,7 @@ public boolean equals(Object o) {
}
UserTeam userTeam = (UserTeam) o;
return version == userTeam.version && isTeamAdmin == userTeam.isTeamAdmin && Objects.equals(id, userTeam.id)
- && Objects.equals(user, userTeam.user) && Objects.equals(team, userTeam.team);
+ && Objects.equals(user, userTeam.user) && Objects.equals(team, userTeam.team);
}
@Override
@@ -99,7 +98,7 @@ public int hashCode() {
@Override
public String toString() {
return "UserTeam{" + "id=" + id + ", version=" + version + ", user=" + user + ", team=" + team
- + ", isTeamAdmin=" + isTeamAdmin + '}';
+ + ", isTeamAdmin=" + isTeamAdmin + '}';
}
public static class Builder {
diff --git a/backend/src/main/java/ch/puzzle/okr/models/alignment/Alignment.java b/backend/src/main/java/ch/puzzle/okr/models/alignment/Alignment.java
index cf3a64f7fc..2c6ae48992 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/alignment/Alignment.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/alignment/Alignment.java
@@ -1,7 +1,6 @@
package ch.puzzle.okr.models.alignment;
import ch.puzzle.okr.models.Objective;
-
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import java.util.Objects;
@@ -59,7 +58,7 @@ public boolean equals(Object o) {
return false;
Alignment alignment = (Alignment) o;
return Objects.equals(id, alignment.id) && version == alignment.version
- && Objects.equals(alignedObjective, alignment.alignedObjective);
+ && Objects.equals(alignedObjective, alignment.alignedObjective);
}
@Override
diff --git a/backend/src/main/java/ch/puzzle/okr/models/alignment/AlignmentSelection.java b/backend/src/main/java/ch/puzzle/okr/models/alignment/AlignmentSelection.java
index 0246817184..562b5a4fc0 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/alignment/AlignmentSelection.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/alignment/AlignmentSelection.java
@@ -2,9 +2,8 @@
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
-import org.hibernate.annotations.Immutable;
-
import java.util.Objects;
+import org.hibernate.annotations.Immutable;
@Entity
@Immutable
@@ -61,10 +60,10 @@ public boolean equals(Object o) {
return false;
AlignmentSelection alignmentSelection = (AlignmentSelection) o;
return Objects.equals(alignmentSelectionId, alignmentSelection.alignmentSelectionId)
- && Objects.equals(teamId, alignmentSelection.teamId)
- && Objects.equals(objectiveTitle, alignmentSelection.objectiveTitle)
- && Objects.equals(quarterId, alignmentSelection.quarterId)
- && Objects.equals(keyResultTitle, alignmentSelection.keyResultTitle);
+ && Objects.equals(teamId, alignmentSelection.teamId)
+ && Objects.equals(objectiveTitle, alignmentSelection.objectiveTitle)
+ && Objects.equals(quarterId, alignmentSelection.quarterId)
+ && Objects.equals(keyResultTitle, alignmentSelection.keyResultTitle);
}
@Override
@@ -75,9 +74,9 @@ public int hashCode() {
@Override
public String toString() {
return "AlignmentSelection{" + "alignmentSelectionId=" + alignmentSelectionId + ", teamId='" + teamId
- + ", teamName='" + teamName + '\'' + ", objectiveTitle='" + objectiveTitle + '\'' + ", quarterId="
- + quarterId + ", quarterLabel='" + quarterLabel + '\'' + ", keyResultTitle='" + keyResultTitle + '\''
- + '}';
+ + ", teamName='" + teamName + '\'' + ", objectiveTitle='" + objectiveTitle + '\'' + ", quarterId="
+ + quarterId + ", quarterLabel='" + quarterLabel + '\'' + ", keyResultTitle='" + keyResultTitle + '\''
+ + '}';
}
public static final class Builder {
diff --git a/backend/src/main/java/ch/puzzle/okr/models/alignment/AlignmentSelectionId.java b/backend/src/main/java/ch/puzzle/okr/models/alignment/AlignmentSelectionId.java
index 75c52cf2b8..e99a7c5611 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/alignment/AlignmentSelectionId.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/alignment/AlignmentSelectionId.java
@@ -1,7 +1,6 @@
package ch.puzzle.okr.models.alignment;
import jakarta.persistence.Embeddable;
-
import java.io.Serializable;
import java.util.Objects;
diff --git a/backend/src/main/java/ch/puzzle/okr/models/alignment/KeyResultAlignment.java b/backend/src/main/java/ch/puzzle/okr/models/alignment/KeyResultAlignment.java
index 1797ca005b..72ef8f21d7 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/alignment/KeyResultAlignment.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/alignment/KeyResultAlignment.java
@@ -1,7 +1,6 @@
package ch.puzzle.okr.models.alignment;
import ch.puzzle.okr.models.keyresult.KeyResult;
-
import jakarta.persistence.*;
import java.util.Objects;
diff --git a/backend/src/main/java/ch/puzzle/okr/models/alignment/ObjectiveAlignment.java b/backend/src/main/java/ch/puzzle/okr/models/alignment/ObjectiveAlignment.java
index f15422894f..7225c08176 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/alignment/ObjectiveAlignment.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/alignment/ObjectiveAlignment.java
@@ -4,7 +4,6 @@
import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import jakarta.persistence.ManyToOne;
-
import java.util.Objects;
@Entity
diff --git a/backend/src/main/java/ch/puzzle/okr/models/authorization/AuthorizationUser.java b/backend/src/main/java/ch/puzzle/okr/models/authorization/AuthorizationUser.java
index 829ba69765..a2acf2cc24 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/authorization/AuthorizationUser.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/authorization/AuthorizationUser.java
@@ -1,7 +1,6 @@
package ch.puzzle.okr.models.authorization;
import ch.puzzle.okr.models.User;
-
import java.util.List;
public record AuthorizationUser(User user) {
@@ -14,7 +13,9 @@ public boolean isUserMemberInTeam(Long teamId) {
}
public boolean isUserAdminInTeam(Long teamId) {
- return this.user.getUserTeamList().stream()
+ return this.user
+ .getUserTeamList()
+ .stream()
.anyMatch(ut -> ut.isTeamAdmin() && ut.getTeam().getId().equals(teamId));
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/models/checkin/CheckIn.java b/backend/src/main/java/ch/puzzle/okr/models/checkin/CheckIn.java
index 7105ca5950..8c408ff99b 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/checkin/CheckIn.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/checkin/CheckIn.java
@@ -4,10 +4,8 @@
import ch.puzzle.okr.models.User;
import ch.puzzle.okr.models.WriteableInterface;
import ch.puzzle.okr.models.keyresult.KeyResult;
-
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
-
import java.time.LocalDateTime;
import java.util.Objects;
@@ -134,9 +132,9 @@ public void setWriteable(boolean writeable) {
@Override
public String toString() {
return "CheckIn{" + "id=" + id + ", version=" + version + ", changeInfo='" + changeInfo + '\''
- + ", initiatives='" + initiatives + '\'' + ", confidence=" + confidence + ", keyResult=" + keyResult
- + ", createdBy=" + createdBy + ", createdOn=" + createdOn + ", modifiedOn=" + modifiedOn
- + ", checkInType='" + checkInType + '\'' + ", writeable=" + writeable + '\'' + '}';
+ + ", initiatives='" + initiatives + '\'' + ", confidence=" + confidence + ", keyResult=" + keyResult
+ + ", createdBy=" + createdBy + ", createdOn=" + createdOn + ", modifiedOn=" + modifiedOn
+ + ", checkInType='" + checkInType + '\'' + ", writeable=" + writeable + '\'' + '}';
}
@Override
@@ -147,16 +145,25 @@ public boolean equals(Object o) {
return false;
CheckIn checkIn = (CheckIn) o;
return Objects.equals(id, checkIn.id) && version == checkIn.version
- && Objects.equals(changeInfo, checkIn.changeInfo) && Objects.equals(initiatives, checkIn.initiatives)
- && Objects.equals(confidence, checkIn.confidence) && Objects.equals(keyResult, checkIn.keyResult)
- && Objects.equals(createdBy, checkIn.createdBy) && Objects.equals(createdOn, checkIn.createdOn)
- && Objects.equals(modifiedOn, checkIn.modifiedOn) && Objects.equals(checkInType, checkIn.checkInType);
+ && Objects.equals(changeInfo, checkIn.changeInfo) && Objects.equals(initiatives, checkIn.initiatives)
+ && Objects.equals(confidence, checkIn.confidence) && Objects.equals(keyResult, checkIn.keyResult)
+ && Objects.equals(createdBy, checkIn.createdBy) && Objects.equals(createdOn, checkIn.createdOn)
+ && Objects.equals(modifiedOn, checkIn.modifiedOn) && Objects.equals(checkInType, checkIn.checkInType);
}
@Override
public int hashCode() {
- return Objects.hash(id, version, changeInfo, initiatives, confidence, keyResult, createdBy, createdOn,
- modifiedOn, checkInType);
+ return Objects
+ .hash(id,
+ version,
+ changeInfo,
+ initiatives,
+ confidence,
+ keyResult,
+ createdBy,
+ createdOn,
+ modifiedOn,
+ checkInType);
}
/* Constructor */
diff --git a/backend/src/main/java/ch/puzzle/okr/models/checkin/CheckInMetric.java b/backend/src/main/java/ch/puzzle/okr/models/checkin/CheckInMetric.java
index 25faccff0e..b26834e455 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/checkin/CheckInMetric.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/checkin/CheckInMetric.java
@@ -1,14 +1,13 @@
package ch.puzzle.okr.models.checkin;
+import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_METRIC;
+
import ch.puzzle.okr.models.MessageKey;
import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import jakarta.validation.constraints.NotNull;
-
import java.util.Objects;
-import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_METRIC;
-
@Entity
@DiscriminatorValue(KEY_RESULT_TYPE_METRIC)
public class CheckInMetric extends CheckIn {
diff --git a/backend/src/main/java/ch/puzzle/okr/models/checkin/CheckInOrdinal.java b/backend/src/main/java/ch/puzzle/okr/models/checkin/CheckInOrdinal.java
index 62485b5101..be7deba8e6 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/checkin/CheckInOrdinal.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/checkin/CheckInOrdinal.java
@@ -1,16 +1,15 @@
package ch.puzzle.okr.models.checkin;
+import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_ORDINAL;
+
import ch.puzzle.okr.models.MessageKey;
import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.validation.constraints.NotNull;
-
import java.util.Objects;
-import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_ORDINAL;
-
@Entity
@DiscriminatorValue(KEY_RESULT_TYPE_ORDINAL)
public class CheckInOrdinal extends CheckIn {
diff --git a/backend/src/main/java/ch/puzzle/okr/models/checkin/Zone.java b/backend/src/main/java/ch/puzzle/okr/models/checkin/Zone.java
index 79eec69420..4424418197 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/checkin/Zone.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/checkin/Zone.java
@@ -1,5 +1,8 @@
package ch.puzzle.okr.models.checkin;
public enum Zone {
- FAIL, COMMIT, TARGET, STRETCH
+ FAIL,
+ COMMIT,
+ TARGET,
+ STRETCH
}
diff --git a/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResult.java b/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResult.java
index 1da614d05c..fa579e899c 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResult.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResult.java
@@ -4,7 +4,6 @@
import ch.puzzle.okr.models.Objective;
import ch.puzzle.okr.models.User;
import ch.puzzle.okr.models.WriteableInterface;
-
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
@@ -143,9 +142,9 @@ public void setWriteable(boolean writeable) {
@Override
public String toString() {
return "KeyResult{" + "id=" + id + ", version=" + version + ", objective=" + objective + ", title='" + title
- + '\'' + ", description='" + description + '\'' + ", owner=" + owner + ", createdBy=" + createdBy
- + ", createdOn=" + createdOn + ", modifiedOn=" + modifiedOn + ", keyResultType='" + keyResultType
- + ", writeable=" + writeable + '\'' + '}';
+ + '\'' + ", description='" + description + '\'' + ", owner=" + owner + ", createdBy=" + createdBy
+ + ", createdOn=" + createdOn + ", modifiedOn=" + modifiedOn + ", keyResultType='" + keyResultType
+ + ", writeable=" + writeable + '\'' + '}';
}
@Override
@@ -156,17 +155,26 @@ public boolean equals(Object o) {
return false;
KeyResult keyResult = (KeyResult) o;
return Objects.equals(id, keyResult.id) && version == keyResult.version
- && Objects.equals(objective, keyResult.objective) && Objects.equals(title, keyResult.title)
- && Objects.equals(description, keyResult.description) && Objects.equals(owner, keyResult.owner)
- && Objects.equals(createdBy, keyResult.createdBy) && Objects.equals(createdOn, keyResult.createdOn)
- && Objects.equals(modifiedOn, keyResult.modifiedOn)
- && Objects.equals(keyResultType, keyResult.keyResultType);
+ && Objects.equals(objective, keyResult.objective) && Objects.equals(title, keyResult.title)
+ && Objects.equals(description, keyResult.description) && Objects.equals(owner, keyResult.owner)
+ && Objects.equals(createdBy, keyResult.createdBy) && Objects.equals(createdOn, keyResult.createdOn)
+ && Objects.equals(modifiedOn, keyResult.modifiedOn)
+ && Objects.equals(keyResultType, keyResult.keyResultType);
}
@Override
public int hashCode() {
- return Objects.hash(id, version, objective, title, description, owner, createdBy, createdOn, modifiedOn,
- keyResultType);
+ return Objects
+ .hash(id,
+ version,
+ objective,
+ title,
+ description,
+ owner,
+ createdBy,
+ createdOn,
+ modifiedOn,
+ keyResultType);
}
protected KeyResult() {
diff --git a/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResultMetric.java b/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResultMetric.java
index 773501abc4..ece94d53f9 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResultMetric.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResultMetric.java
@@ -1,14 +1,13 @@
package ch.puzzle.okr.models.keyresult;
+import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_METRIC;
+
import ch.puzzle.okr.models.MessageKey;
import ch.puzzle.okr.models.Unit;
-
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import java.util.Objects;
-import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_METRIC;
-
@Entity
@DiscriminatorValue(KEY_RESULT_TYPE_METRIC)
public class KeyResultMetric extends KeyResult {
@@ -54,8 +53,8 @@ public KeyResultMetric() {
public boolean equals(Object o) {
if (o instanceof KeyResultMetric) {
return super.equals(o) && Objects.equals(baseline, ((KeyResultMetric) o).baseline)
- && Objects.equals(stretchGoal, ((KeyResultMetric) o).stretchGoal)
- && Objects.equals(unit, ((KeyResultMetric) o).unit);
+ && Objects.equals(stretchGoal, ((KeyResultMetric) o).stretchGoal)
+ && Objects.equals(unit, ((KeyResultMetric) o).unit);
}
return false;
}
@@ -68,7 +67,7 @@ public int hashCode() {
@Override
public String toString() {
return super.toString() + "KeyResultMetric{" + "baseline=" + baseline + ", stretchGoal=" + stretchGoal
- + ", unit='" + unit + '\'' + '}';
+ + ", unit='" + unit + '\'' + '}';
}
private KeyResultMetric(Builder builder) {
diff --git a/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResultOrdinal.java b/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResultOrdinal.java
index d95f92a302..2f98b0e962 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResultOrdinal.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResultOrdinal.java
@@ -1,14 +1,13 @@
package ch.puzzle.okr.models.keyresult;
+import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_ORDINAL;
+
import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
-
import java.util.Objects;
-import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_ORDINAL;
-
@Entity
@DiscriminatorValue(KEY_RESULT_TYPE_ORDINAL)
public class KeyResultOrdinal extends KeyResult {
@@ -56,8 +55,8 @@ public KeyResultOrdinal() {
public boolean equals(Object o) {
if (o instanceof KeyResultOrdinal) {
return super.equals(o) && Objects.equals(commitZone, ((KeyResultOrdinal) o).commitZone)
- && Objects.equals(targetZone, ((KeyResultOrdinal) o).targetZone)
- && Objects.equals(stretchZone, ((KeyResultOrdinal) o).stretchZone);
+ && Objects.equals(targetZone, ((KeyResultOrdinal) o).targetZone)
+ && Objects.equals(stretchZone, ((KeyResultOrdinal) o).stretchZone);
}
return false;
}
@@ -70,7 +69,7 @@ public int hashCode() {
@Override
public String toString() {
return super.toString() + "KeyResultOrdinal{" + "commitZone='" + commitZone + '\'' + ", targetZone='"
- + targetZone + '\'' + ", stretchZone='" + stretchZone + '\'' + '}';
+ + targetZone + '\'' + ", stretchZone='" + stretchZone + '\'' + '}';
}
private KeyResultOrdinal(Builder builder) {
diff --git a/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResultWithActionList.java b/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResultWithActionList.java
index 1fae579ab3..2b0f367d53 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResultWithActionList.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/keyresult/KeyResultWithActionList.java
@@ -1,7 +1,6 @@
package ch.puzzle.okr.models.keyresult;
import ch.puzzle.okr.models.Action;
-
import java.util.List;
public record KeyResultWithActionList(KeyResult keyResult, List actionList) {
diff --git a/backend/src/main/java/ch/puzzle/okr/models/overview/Overview.java b/backend/src/main/java/ch/puzzle/okr/models/overview/Overview.java
index b2b3eb6d79..303f400e81 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/overview/Overview.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/overview/Overview.java
@@ -6,9 +6,8 @@
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
-import org.hibernate.annotations.Immutable;
-
import java.time.LocalDateTime;
+import org.hibernate.annotations.Immutable;
@Entity
@Immutable
@@ -158,14 +157,14 @@ public void setWriteable(boolean writeable) {
@Override
public String toString() {
return "Overview{" + "overviewId=" + overviewId + ", teamVersion='" + teamVersion + ", teamName='" + teamName
- + '\'' + ", objectiveTitle='" + objectiveTitle + '\'' + ", objectiveState=" + objectiveState
- + ", objectiveCreatedOn=" + objectiveCreatedOn + ", quarterId=" + quarterId + ", quarterLabel='"
- + quarterLabel + '\'' + ", keyResultTitle='" + keyResultTitle + '\'' + ", keyResultType='"
- + keyResultType + '\'' + ", baseline=" + baseline + ", stretchGoal=" + stretchGoal + ", unit='" + unit
- + '\'' + ", commitZone='" + commitZone + '\'' + ", targetZone='" + targetZone + '\'' + ", stretchZone='"
- + stretchZone + '\'' + ", checkInValue=" + checkInValue + ", checkInZone='" + checkInZone + '\''
- + ", confidence=" + confidence + ", createdOn=" + checkInCreatedOn + ", writeable=" + writeable + '\''
- + '}';
+ + '\'' + ", objectiveTitle='" + objectiveTitle + '\'' + ", objectiveState=" + objectiveState
+ + ", objectiveCreatedOn=" + objectiveCreatedOn + ", quarterId=" + quarterId + ", quarterLabel='"
+ + quarterLabel + '\'' + ", keyResultTitle='" + keyResultTitle + '\'' + ", keyResultType='"
+ + keyResultType + '\'' + ", baseline=" + baseline + ", stretchGoal=" + stretchGoal + ", unit='" + unit
+ + '\'' + ", commitZone='" + commitZone + '\'' + ", targetZone='" + targetZone + '\'' + ", stretchZone='"
+ + stretchZone + '\'' + ", checkInValue=" + checkInValue + ", checkInZone='" + checkInZone + '\''
+ + ", confidence=" + confidence + ", createdOn=" + checkInCreatedOn + ", writeable=" + writeable + '\''
+ + '}';
}
public static final class Builder {
diff --git a/backend/src/main/java/ch/puzzle/okr/models/overview/OverviewId.java b/backend/src/main/java/ch/puzzle/okr/models/overview/OverviewId.java
index 62bfb85e60..5923ba1808 100644
--- a/backend/src/main/java/ch/puzzle/okr/models/overview/OverviewId.java
+++ b/backend/src/main/java/ch/puzzle/okr/models/overview/OverviewId.java
@@ -1,7 +1,6 @@
package ch.puzzle.okr.models.overview;
import jakarta.persistence.Embeddable;
-
import java.io.Serializable;
import java.util.Objects;
@@ -50,7 +49,7 @@ public Long getCheckInId() {
@Override
public String toString() {
return "OverviewId{" + "teamId=" + teamId + ", objectiveId=" + objectiveId + ", keyResultId=" + keyResultId
- + ", checkInId=" + checkInId + '}';
+ + ", checkInId=" + checkInId + '}';
}
@Override
@@ -61,7 +60,7 @@ public boolean equals(Object o) {
return false;
OverviewId that = (OverviewId) o;
return Objects.equals(teamId, that.teamId) && Objects.equals(objectiveId, that.objectiveId)
- && Objects.equals(keyResultId, that.keyResultId) && Objects.equals(checkInId, that.checkInId);
+ && Objects.equals(keyResultId, that.keyResultId) && Objects.equals(checkInId, that.checkInId);
}
@Override
diff --git a/backend/src/main/java/ch/puzzle/okr/multitenancy/FlywayMultitenantMigrationInitializer.java b/backend/src/main/java/ch/puzzle/okr/multitenancy/FlywayMultitenantMigrationInitializer.java
index d58c195c77..44a6801348 100644
--- a/backend/src/main/java/ch/puzzle/okr/multitenancy/FlywayMultitenantMigrationInitializer.java
+++ b/backend/src/main/java/ch/puzzle/okr/multitenancy/FlywayMultitenantMigrationInitializer.java
@@ -11,7 +11,8 @@ public class FlywayMultitenantMigrationInitializer {
private final String[] scriptLocations;
public FlywayMultitenantMigrationInitializer(TenantConfigProviderInterface tenantConfigProvider,
- final @Value("${spring.flyway.locations}") String[] scriptLocations) {
+ final @Value("${spring.flyway.locations}")
+ String[] scriptLocations) {
this.tenantConfigProvider = tenantConfigProvider;
this.scriptLocations = scriptLocations;
}
@@ -20,10 +21,11 @@ public void migrateFlyway() {
this.tenantConfigProvider.getTenantConfigs().forEach((tenantConfig) -> {
TenantConfigProvider.DataSourceConfig dataSourceConfig = this.tenantConfigProvider
.getTenantConfigById(tenantConfig.tenantId())
- .map(TenantConfigProvider.TenantConfig::dataSourceConfig).orElseThrow(
- () -> new EntityNotFoundException("Cannot find tenant for configuring flyway migration"));
+ .map(TenantConfigProvider.TenantConfig::dataSourceConfig)
+ .orElseThrow(() -> new EntityNotFoundException("Cannot find tenant for configuring flyway migration"));
- Flyway tenantSchemaFlyway = Flyway.configure() //
+ Flyway tenantSchemaFlyway = Flyway
+ .configure() //
.dataSource(dataSourceConfig.url(), dataSourceConfig.name(), dataSourceConfig.password()) //
.locations(scriptLocations) //
.baselineOnMigrate(Boolean.TRUE) //
diff --git a/backend/src/main/java/ch/puzzle/okr/multitenancy/HibernateContext.java b/backend/src/main/java/ch/puzzle/okr/multitenancy/HibernateContext.java
index 42e068ece0..d78c3ba4ac 100644
--- a/backend/src/main/java/ch/puzzle/okr/multitenancy/HibernateContext.java
+++ b/backend/src/main/java/ch/puzzle/okr/multitenancy/HibernateContext.java
@@ -1,8 +1,7 @@
package ch.puzzle.okr.multitenancy;
-import org.springframework.core.env.ConfigurableEnvironment;
-
import java.util.Properties;
+import org.springframework.core.env.ConfigurableEnvironment;
public class HibernateContext {
public static final String HIBERNATE_CONNECTION_URL = "hibernate.connection.url";
diff --git a/backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProvider.java b/backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProvider.java
index 05ff90ce53..7c8d2c0e01 100644
--- a/backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProvider.java
+++ b/backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProvider.java
@@ -1,6 +1,12 @@
package ch.puzzle.okr.multitenancy;
+import static ch.puzzle.okr.multitenancy.TenantContext.DEFAULT_TENANT_ID;
+
import ch.puzzle.okr.exception.ConnectionProviderException;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.text.MessageFormat;
+import java.util.*;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
import org.hibernate.engine.jdbc.connections.spi.AbstractMultiTenantConnectionProvider;
@@ -8,13 +14,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.text.MessageFormat;
-import java.util.*;
-
-import static ch.puzzle.okr.multitenancy.TenantContext.DEFAULT_TENANT_ID;
-
public class SchemaMultiTenantConnectionProvider extends AbstractMultiTenantConnectionProvider {
private static final Logger logger = LoggerFactory.getLogger(SchemaMultiTenantConnectionProvider.class);
@@ -55,24 +54,27 @@ protected ConnectionProvider selectConnectionProvider(String tenantIdentifier) {
}
protected ConnectionProvider getConnectionProvider(String tenantIdentifier) {
- return Optional.ofNullable(tenantIdentifier) //
+ return Optional
+ .ofNullable(tenantIdentifier) //
.map(connectionProviderMap::get) //
.orElseGet(() -> createNewConnectionProvider(tenantIdentifier));
}
private ConnectionProvider createNewConnectionProvider(String tenantIdentifier) {
- return Optional.ofNullable(tenantIdentifier) //
+ return Optional
+ .ofNullable(tenantIdentifier) //
.map(this::createConnectionProvider) //
.map(connectionProvider -> {
connectionProviderMap.put(tenantIdentifier, connectionProvider);
return connectionProvider;
}) //
- .orElseThrow(() -> new ConnectionProviderException(
- String.format("Cannot create new connection provider for tenant: %s", tenantIdentifier)));
+ .orElseThrow(() -> new ConnectionProviderException(String
+ .format("Cannot create new connection provider for tenant: %s", tenantIdentifier)));
}
private ConnectionProvider createConnectionProvider(String tenantIdentifier) {
- return Optional.ofNullable(tenantIdentifier) //
+ return Optional
+ .ofNullable(tenantIdentifier) //
.map(this::getHibernatePropertiesForTenantIdentifier) //
.map(this::initConnectionProvider) //
.orElse(null);
diff --git a/backend/src/main/java/ch/puzzle/okr/multitenancy/TenantConfigProvider.java b/backend/src/main/java/ch/puzzle/okr/multitenancy/TenantConfigProvider.java
index 97521d9d7a..374ad302d3 100644
--- a/backend/src/main/java/ch/puzzle/okr/multitenancy/TenantConfigProvider.java
+++ b/backend/src/main/java/ch/puzzle/okr/multitenancy/TenantConfigProvider.java
@@ -1,44 +1,62 @@
package ch.puzzle.okr.multitenancy;
+import java.text.MessageFormat;
+import java.util.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
-import java.text.MessageFormat;
-import java.util.*;
-
@Component
public class TenantConfigProvider implements TenantConfigProviderInterface {
private static final String EMAIL_DELIMITER = ",";
private final Map tenantConfigs = new HashMap<>();
private final Environment env;
- public TenantConfigProvider(final @Value("${okr.tenant-ids}") String[] tenantIds, Environment env) {
+ public TenantConfigProvider(final @Value("${okr.tenant-ids}")
+ String[] tenantIds, Environment env) {
this.env = env;
for (String tenantId : tenantIds) {
OauthConfig c = readOauthConfig(tenantId);
- tenantConfigs.put(tenantId,
- createTenantConfig(c.jwkSetUri(), c.frontendClientIssuerUrl(), c.frontendClientId(), tenantId));
+ tenantConfigs
+ .put(tenantId,
+ createTenantConfig(c.jwkSetUri(),
+ c.frontendClientIssuerUrl(),
+ c.frontendClientId(),
+ tenantId));
}
}
private OauthConfig readOauthConfig(String tenantId) {
- return new OauthConfig(
- env.getProperty(MessageFormat.format("okr.tenants.{0}.security.oauth2.resourceserver.jwt.jwk-set-uri",
- tenantId)),
- env.getProperty(MessageFormat.format("okr.tenants.{0}.security.oauth2.frontend.issuer-url", tenantId)),
- env.getProperty(MessageFormat.format("okr.tenants.{0}.security.oauth2.frontend.client-id", tenantId)));
+ return new OauthConfig(env
+ .getProperty(MessageFormat
+ .format("okr.tenants.{0}.security.oauth2.resourceserver.jwt.jwk-set-uri", tenantId)),
+ env
+ .getProperty(MessageFormat
+ .format("okr.tenants.{0}.security.oauth2.frontend.issuer-url",
+ tenantId)),
+ env
+ .getProperty(MessageFormat
+ .format("okr.tenants.{0}.security.oauth2.frontend.client-id",
+ tenantId)));
}
private TenantConfig createTenantConfig(String jwkSetUriTemplate, String frontendClientIssuerUrl,
- String frontendClientId, String tenantId) {
- return new TenantConfig(tenantId, getOkrChampionEmailsFromTenant(tenantId), jwkSetUriTemplate,
- frontendClientIssuerUrl, frontendClientId, this.readDataSourceConfig(tenantId));
+ String frontendClientId, String tenantId) {
+ return new TenantConfig(tenantId,
+ getOkrChampionEmailsFromTenant(tenantId),
+ jwkSetUriTemplate,
+ frontendClientIssuerUrl,
+ frontendClientId,
+ this.readDataSourceConfig(tenantId));
}
private String[] getOkrChampionEmailsFromTenant(String tenantId) {
- return Arrays.stream(env.getProperty(MessageFormat.format("okr.tenants.{0}.user.champion.emails", tenantId), "")
- .split(EMAIL_DELIMITER)).map(String::trim).toArray(String[]::new);
+ return Arrays
+ .stream(env
+ .getProperty(MessageFormat.format("okr.tenants.{0}.user.champion.emails", tenantId), "")
+ .split(EMAIL_DELIMITER))
+ .map(String::trim)
+ .toArray(String[]::new);
}
public List getTenantConfigs() {
@@ -47,10 +65,16 @@ public List getTenantConfigs() {
private DataSourceConfig readDataSourceConfig(String tenantId) {
return new DataSourceConfig(env.getProperty("okr.datasource.driver-class-name"),
- env.getProperty(MessageFormat.format("okr.tenants.{0}.datasource.url", tenantId)),
- env.getProperty(MessageFormat.format("okr.tenants.{0}.datasource.username", tenantId)),
- env.getProperty(MessageFormat.format("okr.tenants.{0}.datasource.password", tenantId)),
- env.getProperty(MessageFormat.format("okr.tenants.{0}.datasource.schema", tenantId)));
+ env.getProperty(MessageFormat.format("okr.tenants.{0}.datasource.url", tenantId)),
+ env
+ .getProperty(MessageFormat
+ .format("okr.tenants.{0}.datasource.username", tenantId)),
+ env
+ .getProperty(MessageFormat
+ .format("okr.tenants.{0}.datasource.password", tenantId)),
+ env
+ .getProperty(MessageFormat
+ .format("okr.tenants.{0}.datasource.schema", tenantId)));
}
public Optional getTenantConfigById(String tenantId) {
diff --git a/backend/src/main/java/ch/puzzle/okr/multitenancy/TenantContext.java b/backend/src/main/java/ch/puzzle/okr/multitenancy/TenantContext.java
index 7c560ecf8c..d7e16756c9 100644
--- a/backend/src/main/java/ch/puzzle/okr/multitenancy/TenantContext.java
+++ b/backend/src/main/java/ch/puzzle/okr/multitenancy/TenantContext.java
@@ -1,10 +1,9 @@
package ch.puzzle.okr.multitenancy;
+import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Optional;
-
public class TenantContext {
public static final String DEFAULT_TENANT_ID = "public";
private static final Logger logger = LoggerFactory.getLogger(TenantContext.class);
diff --git a/backend/src/main/java/ch/puzzle/okr/multitenancy/customization/TenantClientCustomizationProvider.java b/backend/src/main/java/ch/puzzle/okr/multitenancy/customization/TenantClientCustomizationProvider.java
index 3749a7ec1f..b2886711d6 100644
--- a/backend/src/main/java/ch/puzzle/okr/multitenancy/customization/TenantClientCustomizationProvider.java
+++ b/backend/src/main/java/ch/puzzle/okr/multitenancy/customization/TenantClientCustomizationProvider.java
@@ -1,15 +1,14 @@
package ch.puzzle.okr.multitenancy.customization;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.core.env.Environment;
-import org.springframework.stereotype.Component;
-
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
@Component
public class TenantClientCustomizationProvider {
@@ -23,12 +22,18 @@ public class TenantClientCustomizationProvider {
private static final String ADD_OBJECTIVE_OUTLINE_COLOR = ".okr-add-objective-outline-color";
private final Map tenantCustomizations = new HashMap<>();
- private final List customCssStyles = List.of(TOPBAR_BACKGROUND_COLOR, BANNER_BACKGROUND_COLOR,
- OVERVIEW_BACKGROUND_COLOR, TEAM_HEADER_COLOR, ADD_OBJECTIVE_TEXT_COLOR, ADD_OBJECTIVE_ICON,
- ADD_OBJECTIVE_OUTLINE_COLOR);
+ private final List customCssStyles = List
+ .of(TOPBAR_BACKGROUND_COLOR,
+ BANNER_BACKGROUND_COLOR,
+ OVERVIEW_BACKGROUND_COLOR,
+ TEAM_HEADER_COLOR,
+ ADD_OBJECTIVE_TEXT_COLOR,
+ ADD_OBJECTIVE_ICON,
+ ADD_OBJECTIVE_OUTLINE_COLOR);
private final Environment env;
- public TenantClientCustomizationProvider(final @Value("${okr.tenant-ids}") String[] tenantIds, Environment env) {
+ public TenantClientCustomizationProvider(final @Value("${okr.tenant-ids}")
+ String[] tenantIds, Environment env) {
this.env = env;
for (String tenantId : tenantIds) {
readClientCustomizationConfig(tenantId);
@@ -37,14 +42,29 @@ public TenantClientCustomizationProvider(final @Value("${okr.tenant-ids}") Strin
}
private TenantClientCustomization readClientCustomizationConfig(String tenantId) {
- return new TenantClientCustomization(
- env.getProperty(MessageFormat.format("okr.tenants.{0}.clientcustomization.favicon", tenantId)),
- env.getProperty(MessageFormat.format("okr.tenants.{0}.clientcustomization.logo", tenantId)),
- env.getProperty(MessageFormat.format("okr.tenants.{0}.clientcustomization.triangles", tenantId)),
- env.getProperty(MessageFormat.format("okr.tenants.{0}.clientcustomization.background-logo", tenantId)),
- env.getProperty(MessageFormat.format("okr.tenants.{0}.clientcustomization.title", tenantId)),
- env.getProperty(MessageFormat.format("okr.tenants.{0}.clientcustomization.helpSiteUrl", tenantId)),
- getCustomCssStyles(tenantId) //
+ return new TenantClientCustomization(env
+ .getProperty(MessageFormat.format("okr.tenants.{0}.clientcustomization.favicon", tenantId)),
+ env
+ .getProperty(MessageFormat
+ .format("okr.tenants.{0}.clientcustomization.logo",
+ tenantId)),
+ env
+ .getProperty(MessageFormat
+ .format("okr.tenants.{0}.clientcustomization.triangles",
+ tenantId)),
+ env
+ .getProperty(MessageFormat
+ .format("okr.tenants.{0}.clientcustomization.background-logo",
+ tenantId)),
+ env
+ .getProperty(MessageFormat
+ .format("okr.tenants.{0}.clientcustomization.title",
+ tenantId)),
+ env
+ .getProperty(MessageFormat
+ .format("okr.tenants.{0}.clientcustomization.helpSiteUrl",
+ tenantId)),
+ getCustomCssStyles(tenantId) //
);
}
diff --git a/backend/src/main/java/ch/puzzle/okr/repository/ActionRepository.java b/backend/src/main/java/ch/puzzle/okr/repository/ActionRepository.java
index c6baa06bb4..ed82d16e41 100644
--- a/backend/src/main/java/ch/puzzle/okr/repository/ActionRepository.java
+++ b/backend/src/main/java/ch/puzzle/okr/repository/ActionRepository.java
@@ -1,9 +1,8 @@
package ch.puzzle.okr.repository;
import ch.puzzle.okr.models.Action;
-import org.springframework.data.repository.CrudRepository;
-
import java.util.List;
+import org.springframework.data.repository.CrudRepository;
public interface ActionRepository extends CrudRepository {
List getActionsByKeyResultIdOrderByPriorityAsc(Long keyResultId);
diff --git a/backend/src/main/java/ch/puzzle/okr/repository/AlignmentRepository.java b/backend/src/main/java/ch/puzzle/okr/repository/AlignmentRepository.java
index d6ebcc70a7..12ab5a8af3 100644
--- a/backend/src/main/java/ch/puzzle/okr/repository/AlignmentRepository.java
+++ b/backend/src/main/java/ch/puzzle/okr/repository/AlignmentRepository.java
@@ -3,12 +3,11 @@
import ch.puzzle.okr.models.alignment.Alignment;
import ch.puzzle.okr.models.alignment.KeyResultAlignment;
import ch.puzzle.okr.models.alignment.ObjectiveAlignment;
+import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
-import java.util.List;
-
public interface AlignmentRepository extends CrudRepository {
List findByAlignedObjectiveId(Long alignedObjectiveId);
diff --git a/backend/src/main/java/ch/puzzle/okr/repository/AlignmentSelectionRepository.java b/backend/src/main/java/ch/puzzle/okr/repository/AlignmentSelectionRepository.java
index 50896b44f3..dcd03ab8bc 100644
--- a/backend/src/main/java/ch/puzzle/okr/repository/AlignmentSelectionRepository.java
+++ b/backend/src/main/java/ch/puzzle/okr/repository/AlignmentSelectionRepository.java
@@ -2,14 +2,13 @@
import ch.puzzle.okr.models.alignment.AlignmentSelection;
import ch.puzzle.okr.models.alignment.AlignmentSelectionId;
+import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
-import java.util.List;
-
public interface AlignmentSelectionRepository extends ReadOnlyRepository {
@Query(value = "from AlignmentSelection where quarterId = :quarter_id and teamId != :ignoredTeamId")
List getAlignmentSelectionByQuarterIdAndTeamIdNot(@Param("quarter_id") Long quarterId,
- @Param("ignoredTeamId") Long ignoredTeamId);
+ @Param("ignoredTeamId") Long ignoredTeamId);
}
diff --git a/backend/src/main/java/ch/puzzle/okr/repository/CheckInRepository.java b/backend/src/main/java/ch/puzzle/okr/repository/CheckInRepository.java
index 74622032a2..3a17fecf0e 100644
--- a/backend/src/main/java/ch/puzzle/okr/repository/CheckInRepository.java
+++ b/backend/src/main/java/ch/puzzle/okr/repository/CheckInRepository.java
@@ -1,9 +1,8 @@
package ch.puzzle.okr.repository;
import ch.puzzle.okr.models.checkin.CheckIn;
-import org.springframework.data.repository.CrudRepository;
-
import java.util.List;
+import org.springframework.data.repository.CrudRepository;
public interface CheckInRepository extends CrudRepository {
List findCheckInsByKeyResultIdOrderByCreatedOnDesc(Long keyResultId);
diff --git a/backend/src/main/java/ch/puzzle/okr/repository/KeyResultRepository.java b/backend/src/main/java/ch/puzzle/okr/repository/KeyResultRepository.java
index b5aa92dbac..a48afe82e1 100644
--- a/backend/src/main/java/ch/puzzle/okr/repository/KeyResultRepository.java
+++ b/backend/src/main/java/ch/puzzle/okr/repository/KeyResultRepository.java
@@ -1,9 +1,8 @@
package ch.puzzle.okr.repository;
import ch.puzzle.okr.models.keyresult.KeyResult;
-import org.springframework.data.repository.CrudRepository;
-
import java.util.List;
+import org.springframework.data.repository.CrudRepository;
public interface KeyResultRepository extends CrudRepository {
List findByObjectiveId(Long objectiveId);
diff --git a/backend/src/main/java/ch/puzzle/okr/repository/ObjectiveRepository.java b/backend/src/main/java/ch/puzzle/okr/repository/ObjectiveRepository.java
index 009b34ac96..95f2fe0dbf 100644
--- a/backend/src/main/java/ch/puzzle/okr/repository/ObjectiveRepository.java
+++ b/backend/src/main/java/ch/puzzle/okr/repository/ObjectiveRepository.java
@@ -3,11 +3,10 @@
import ch.puzzle.okr.models.Objective;
import ch.puzzle.okr.models.Quarter;
import ch.puzzle.okr.models.Team;
+import java.util.List;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
-import java.util.List;
-
@Repository
public interface ObjectiveRepository extends CrudRepository {
diff --git a/backend/src/main/java/ch/puzzle/okr/repository/QuarterRepository.java b/backend/src/main/java/ch/puzzle/okr/repository/QuarterRepository.java
index a742c2d236..a1089c7d09 100644
--- a/backend/src/main/java/ch/puzzle/okr/repository/QuarterRepository.java
+++ b/backend/src/main/java/ch/puzzle/okr/repository/QuarterRepository.java
@@ -1,14 +1,13 @@
package ch.puzzle.okr.repository;
import ch.puzzle.okr.models.Quarter;
+import java.time.LocalDate;
+import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
-import java.time.LocalDate;
-import java.util.List;
-
@Repository
public interface QuarterRepository extends CrudRepository {
diff --git a/backend/src/main/java/ch/puzzle/okr/repository/TeamRepository.java b/backend/src/main/java/ch/puzzle/okr/repository/TeamRepository.java
index 14e48978ed..f4aaf40bb9 100644
--- a/backend/src/main/java/ch/puzzle/okr/repository/TeamRepository.java
+++ b/backend/src/main/java/ch/puzzle/okr/repository/TeamRepository.java
@@ -1,9 +1,8 @@
package ch.puzzle.okr.repository;
import ch.puzzle.okr.models.Team;
-import org.springframework.data.repository.CrudRepository;
-
import java.util.List;
+import org.springframework.data.repository.CrudRepository;
public interface TeamRepository extends CrudRepository {
diff --git a/backend/src/main/java/ch/puzzle/okr/repository/UserRepository.java b/backend/src/main/java/ch/puzzle/okr/repository/UserRepository.java
index 2bf83e1f1d..addae09197 100644
--- a/backend/src/main/java/ch/puzzle/okr/repository/UserRepository.java
+++ b/backend/src/main/java/ch/puzzle/okr/repository/UserRepository.java
@@ -1,10 +1,9 @@
package ch.puzzle.okr.repository;
import ch.puzzle.okr.models.User;
-import org.springframework.data.repository.CrudRepository;
-
import java.util.List;
import java.util.Optional;
+import org.springframework.data.repository.CrudRepository;
public interface UserRepository extends CrudRepository {
Optional findByEmail(String email);
diff --git a/backend/src/main/java/ch/puzzle/okr/security/JwtHelper.java b/backend/src/main/java/ch/puzzle/okr/security/JwtHelper.java
index fe15d284f1..6e2034416e 100644
--- a/backend/src/main/java/ch/puzzle/okr/security/JwtHelper.java
+++ b/backend/src/main/java/ch/puzzle/okr/security/JwtHelper.java
@@ -1,5 +1,8 @@
package ch.puzzle.okr.security;
+import static ch.puzzle.okr.Constants.USER;
+import static org.springframework.http.HttpStatus.BAD_REQUEST;
+
import ch.puzzle.okr.ErrorKey;
import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.models.User;
@@ -8,28 +11,24 @@
import ch.puzzle.okr.security.helper.TokenHelper;
import com.nimbusds.jwt.JWTClaimsSet;
import jakarta.persistence.EntityNotFoundException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.security.oauth2.jwt.Jwt;
-import org.springframework.stereotype.Component;
-
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
-
-import static ch.puzzle.okr.Constants.USER;
-import static org.springframework.http.HttpStatus.BAD_REQUEST;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.security.oauth2.jwt.Jwt;
+import org.springframework.stereotype.Component;
@Component
public class JwtHelper {
public static final String CLAIM_TENANT = "tenant";
public static final String CLAIM_ISS = "iss";
public static final String ERROR_MESSAGE = "Missing `" + CLAIM_TENANT + "` and '" + CLAIM_ISS
- + "' claims in JWT token!";
+ + "' claims in JWT token!";
private static final Logger logger = LoggerFactory.getLogger(JwtHelper.class);
@@ -39,9 +38,9 @@ public class JwtHelper {
private final String email;
public JwtHelper(TenantConfigProvider tenantConfigProvider,
- @Value("${okr.jwt.claim.firstname}") final String tokenClaimsKeyFirstname,
- @Value("${okr.jwt.claim.lastname}") final String tokenClaimsKeyLastname,
- @Value("${okr.jwt.claim.email}") final String tokenClaimsKeyEmail) {
+ @Value("${okr.jwt.claim.firstname}") final String tokenClaimsKeyFirstname,
+ @Value("${okr.jwt.claim.lastname}") final String tokenClaimsKeyLastname,
+ @Value("${okr.jwt.claim.email}") final String tokenClaimsKeyEmail) {
this.tenantConfigProvider = tenantConfigProvider;
this.firstname = tokenClaimsKeyFirstname;
this.lastname = tokenClaimsKeyLastname;
@@ -53,7 +52,8 @@ public User getUserFromJwt(Jwt token) {
logger.debug("claims {}", claims);
try {
- return User.Builder.builder() //
+ return User.Builder
+ .builder() //
.withFirstname(claims.get(firstname).toString()) //
.withLastname(claims.get(lastname).toString()) //
.withEmail(claims.get(email).toString()) //
@@ -66,18 +66,20 @@ public User getUserFromJwt(Jwt token) {
public String getTenantFromToken(Jwt token) {
TokenHelper helper = new TokenHelper();
- List>> getTenantFromTokenFunctions = Arrays.asList( //
- helper::getTenantFromTokenUsingClaimIss, //
- helper::getTenantFromTokenUsingClaimTenant //
- );
+ List>> getTenantFromTokenFunctions = Arrays
+ .asList( //
+ helper::getTenantFromTokenUsingClaimIss, //
+ helper::getTenantFromTokenUsingClaimTenant //
+ );
return getFirstMatchingTenantUsingListOfHelperFunctions(token, getTenantFromTokenFunctions);
}
private String getFirstMatchingTenantUsingListOfHelperFunctions(Jwt token,
- List>> getTenantFunctions) {
+ List>> getTenantFunctions) {
- return getTenantFunctions.stream() //
+ return getTenantFunctions
+ .stream() //
.map(func -> func.apply(token)) //
.filter(Optional::isPresent) //
.map(Optional::get) //
@@ -88,28 +90,32 @@ private String getFirstMatchingTenantUsingListOfHelperFunctions(Jwt token,
public String getTenantFromJWTClaimsSet(JWTClaimsSet claimSet) {
ClaimHelper helper = new ClaimHelper();
- List>> getTenantFromClaimsSetFunctions = Arrays.asList( //
- helper::getTenantFromClaimsSetUsingClaimIss, //
- helper::getTenantFromClaimsSetUsingClaimTenant //
- );
+ List>> getTenantFromClaimsSetFunctions = Arrays
+ .asList( //
+ helper::getTenantFromClaimsSetUsingClaimIss, //
+ helper::getTenantFromClaimsSetUsingClaimTenant //
+ );
return getFirstMatchingTenantUsingListOfHelperFunctions(claimSet, getTenantFromClaimsSetFunctions);
}
private String getFirstMatchingTenantUsingListOfHelperFunctions(JWTClaimsSet claimSet,
- List>> getTenantFunctions) {
+ List>> getTenantFunctions) {
- return getTenantFunctions.stream() //
+ return getTenantFunctions
+ .stream() //
.map(func -> func.apply(claimSet)) //
.filter(Optional::isPresent) //
.map(Optional::get) //
- .map(this::getMatchingTenantFromConfigOrThrow).findFirst() //
+ .map(this::getMatchingTenantFromConfigOrThrow)
+ .findFirst() //
.orElseThrow(() -> new RuntimeException(ERROR_MESSAGE));
}
private String getMatchingTenantFromConfigOrThrow(String tenant) {
// Ensure we return only tenants for realms which really exist
- return this.tenantConfigProvider.getTenantConfigById(tenant)
+ return this.tenantConfigProvider
+ .getTenantConfigById(tenant)
.orElseThrow(() -> new EntityNotFoundException(MessageFormat.format("Cannot find tenant {0}", tenant)))
.tenantId();
}
diff --git a/backend/src/main/java/ch/puzzle/okr/security/TenantJWSKeySelector.java b/backend/src/main/java/ch/puzzle/okr/security/TenantJWSKeySelector.java
index f900296174..0df2cbc8a2 100644
--- a/backend/src/main/java/ch/puzzle/okr/security/TenantJWSKeySelector.java
+++ b/backend/src/main/java/ch/puzzle/okr/security/TenantJWSKeySelector.java
@@ -8,13 +8,12 @@
import com.nimbusds.jose.proc.SecurityContext;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.proc.JWTClaimsSetAwareJWSKeySelector;
-import org.springframework.stereotype.Component;
-
import java.net.URL;
import java.security.Key;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.springframework.stereotype.Component;
@Component
public class TenantJWSKeySelector implements JWTClaimsSetAwareJWSKeySelector {
@@ -31,9 +30,11 @@ public TenantJWSKeySelector(final TenantConfigProvider tenantConfigProvider, Jwt
@Override
public List extends Key> selectKeys(JWSHeader jwsHeader, JWTClaimsSet jwtClaimsSet,
- SecurityContext securityContext) throws KeySourceException {
+ SecurityContext securityContext)
+ throws KeySourceException {
- return this.selectors.computeIfAbsent(toTenant(jwtClaimsSet), this::fromTenant) //
+ return this.selectors
+ .computeIfAbsent(toTenant(jwtClaimsSet), this::fromTenant) //
.selectJWSKeys(jwsHeader, securityContext);
}
@@ -42,7 +43,8 @@ private String toTenant(JWTClaimsSet claimSet) {
}
private JWSKeySelector fromTenant(String tenantId) {
- return this.tenantConfigProvider.getJwkSetUri(tenantId)//
+ return this.tenantConfigProvider
+ .getJwkSetUri(tenantId)//
.map(this::fromUri) //
.orElseThrow(() -> new IllegalArgumentException("unknown tenant"));
}
diff --git a/backend/src/main/java/ch/puzzle/okr/security/TenantJwtIssuerValidator.java b/backend/src/main/java/ch/puzzle/okr/security/TenantJwtIssuerValidator.java
index 1dadd96b3f..4f84b487bc 100644
--- a/backend/src/main/java/ch/puzzle/okr/security/TenantJwtIssuerValidator.java
+++ b/backend/src/main/java/ch/puzzle/okr/security/TenantJwtIssuerValidator.java
@@ -1,15 +1,14 @@
package ch.puzzle.okr.security;
import ch.puzzle.okr.multitenancy.TenantConfigProvider;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import org.springframework.security.oauth2.core.OAuth2TokenValidator;
import org.springframework.security.oauth2.core.OAuth2TokenValidatorResult;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.security.oauth2.jwt.JwtIssuerValidator;
import org.springframework.stereotype.Component;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
@Component
public class TenantJwtIssuerValidator implements OAuth2TokenValidator {
private final TenantConfigProvider tenantConfigProvider;
@@ -31,7 +30,8 @@ public OAuth2TokenValidatorResult validate(Jwt token) {
}
private JwtIssuerValidator createValidatorForTenant(String tenant) {
- return this.tenantConfigProvider.getTenantConfigById(tenant) //
+ return this.tenantConfigProvider
+ .getTenantConfigById(tenant) //
.map(TenantConfigProvider.TenantConfig::issuerUrl) //
.map(this::createValidator) //
.orElseThrow(() -> new IllegalArgumentException("unknown tenant"));
diff --git a/backend/src/main/java/ch/puzzle/okr/security/helper/ClaimHelper.java b/backend/src/main/java/ch/puzzle/okr/security/helper/ClaimHelper.java
index 9ceb7a4034..b7fb0b88de 100644
--- a/backend/src/main/java/ch/puzzle/okr/security/helper/ClaimHelper.java
+++ b/backend/src/main/java/ch/puzzle/okr/security/helper/ClaimHelper.java
@@ -1,15 +1,14 @@
package ch.puzzle.okr.security.helper;
-import com.nimbusds.jwt.JWTClaimsSet;
-
-import java.text.ParseException;
-import java.util.Optional;
-
import static ch.puzzle.okr.security.JwtHelper.CLAIM_ISS;
import static ch.puzzle.okr.security.JwtHelper.CLAIM_TENANT;
import static ch.puzzle.okr.security.helper.JwtStatusLogger.logStatus;
import static ch.puzzle.okr.security.helper.UrlHelper.extractTenantFromIssUrl;
+import com.nimbusds.jwt.JWTClaimsSet;
+import java.text.ParseException;
+import java.util.Optional;
+
public class ClaimHelper {
public Optional getTenantFromClaimsSetUsingClaimTenant(JWTClaimsSet claimSet) {
diff --git a/backend/src/main/java/ch/puzzle/okr/security/helper/JwtStatusLogger.java b/backend/src/main/java/ch/puzzle/okr/security/helper/JwtStatusLogger.java
index ca5d678458..364f77dc83 100644
--- a/backend/src/main/java/ch/puzzle/okr/security/helper/JwtStatusLogger.java
+++ b/backend/src/main/java/ch/puzzle/okr/security/helper/JwtStatusLogger.java
@@ -1,10 +1,9 @@
package ch.puzzle.okr.security.helper;
+import java.text.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.text.ParseException;
-
public class JwtStatusLogger {
private static final Logger logger = LoggerFactory.getLogger(ClaimHelper.class);
@@ -15,17 +14,27 @@ public static void logStatus(String claim, Object context, String result) {
public static void logStatus(String claim, Object context, boolean isOk) {
if (isOk) {
- logger.info("Tenant: get claim '{}' from {}{}", claim, context.getClass().getSimpleName(),
- statusToSymbol(isOk));
+ logger
+ .info("Tenant: get claim '{}' from {}{}",
+ claim,
+ context.getClass().getSimpleName(),
+ statusToSymbol(isOk));
} else {
- logger.warn("Tenant: get claim '{}' from {}{}", claim, context.getClass().getSimpleName(),
- statusToSymbol(isOk));
+ logger
+ .warn("Tenant: get claim '{}' from {}{}",
+ claim,
+ context.getClass().getSimpleName(),
+ statusToSymbol(isOk));
}
}
public static void logStatus(String claim, Object context, ParseException e) {
- logger.warn("Tenant: get claim '{}' from {}{}", claim, context.getClass().getSimpleName(),
- statusToSymbol(false), e);
+ logger
+ .warn("Tenant: get claim '{}' from {}{}",
+ claim,
+ context.getClass().getSimpleName(),
+ statusToSymbol(false),
+ e);
}
private static String statusToSymbol(boolean isOk) {
diff --git a/backend/src/main/java/ch/puzzle/okr/security/helper/TokenHelper.java b/backend/src/main/java/ch/puzzle/okr/security/helper/TokenHelper.java
index 513241cb06..8bdab64f86 100644
--- a/backend/src/main/java/ch/puzzle/okr/security/helper/TokenHelper.java
+++ b/backend/src/main/java/ch/puzzle/okr/security/helper/TokenHelper.java
@@ -1,14 +1,13 @@
package ch.puzzle.okr.security.helper;
-import org.springframework.security.oauth2.jwt.Jwt;
-
-import java.util.Optional;
-
import static ch.puzzle.okr.security.JwtHelper.CLAIM_ISS;
import static ch.puzzle.okr.security.JwtHelper.CLAIM_TENANT;
import static ch.puzzle.okr.security.helper.JwtStatusLogger.logStatus;
import static ch.puzzle.okr.security.helper.UrlHelper.extractTenantFromIssUrl;
+import java.util.Optional;
+import org.springframework.security.oauth2.jwt.Jwt;
+
public class TokenHelper {
public Optional getTenantFromTokenUsingClaimTenant(Jwt token) {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/CacheService.java b/backend/src/main/java/ch/puzzle/okr/service/CacheService.java
index de907468c1..5a315116fd 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/CacheService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/CacheService.java
@@ -1,5 +1,7 @@
package ch.puzzle.okr.service;
+import static ch.puzzle.okr.SpringCachingConfig.AUTHORIZATION_USER_CACHE;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
@@ -8,8 +10,6 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
-import static ch.puzzle.okr.SpringCachingConfig.AUTHORIZATION_USER_CACHE;
-
@EnableScheduling
@Service
public class CacheService {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/authorization/ActionAuthorizationService.java b/backend/src/main/java/ch/puzzle/okr/service/authorization/ActionAuthorizationService.java
index a6a54a4de4..937e5a893b 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/authorization/ActionAuthorizationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/authorization/ActionAuthorizationService.java
@@ -4,9 +4,8 @@
import ch.puzzle.okr.models.authorization.AuthorizationUser;
import ch.puzzle.okr.models.keyresult.KeyResult;
import ch.puzzle.okr.service.business.ActionBusinessService;
-import org.springframework.stereotype.Service;
-
import java.util.List;
+import org.springframework.stereotype.Service;
@Service
public class ActionAuthorizationService {
@@ -15,7 +14,7 @@ public class ActionAuthorizationService {
private final AuthorizationService authorizationService;
public ActionAuthorizationService(ActionBusinessService actionBusinessService,
- AuthorizationService authorizationService) {
+ AuthorizationService authorizationService) {
this.actionBusinessService = actionBusinessService;
this.authorizationService = authorizationService;
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationRegistrationService.java b/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationRegistrationService.java
index fc1213b565..33980f8fad 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationRegistrationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationRegistrationService.java
@@ -1,5 +1,7 @@
package ch.puzzle.okr.service.authorization;
+import static ch.puzzle.okr.SpringCachingConfig.AUTHORIZATION_USER_CACHE;
+
import ch.puzzle.okr.models.User;
import ch.puzzle.okr.models.authorization.AuthorizationUser;
import ch.puzzle.okr.multitenancy.TenantConfigProvider;
@@ -9,8 +11,6 @@
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
-import static ch.puzzle.okr.SpringCachingConfig.AUTHORIZATION_USER_CACHE;
-
@Service
public class AuthorizationRegistrationService {
@@ -20,7 +20,7 @@ public class AuthorizationRegistrationService {
private final UserUpdateHelper helper = new UserUpdateHelper();
public AuthorizationRegistrationService(UserBusinessService userBusinessService,
- TenantConfigProvider tenantConfigProvider) {
+ TenantConfigProvider tenantConfigProvider) {
this.userBusinessService = userBusinessService;
this.tenantConfigProvider = tenantConfigProvider;
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationService.java b/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationService.java
index 3ddde9734b..b249332663 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationService.java
@@ -1,5 +1,8 @@
package ch.puzzle.okr.service.authorization;
+import static ch.puzzle.okr.Constants.*;
+import static ch.puzzle.okr.ErrorKey.*;
+
import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.models.Action;
import ch.puzzle.okr.models.Objective;
@@ -17,9 +20,6 @@
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.stereotype.Service;
-import static ch.puzzle.okr.Constants.*;
-import static ch.puzzle.okr.ErrorKey.*;
-
@Service
public class AuthorizationService {
@@ -29,8 +29,8 @@ public class AuthorizationService {
private final JwtHelper jwtHelper;
public AuthorizationService(AuthorizationRegistrationService authorizationRegistrationService,
- ObjectivePersistenceService objectivePersistenceService, ActionPersistenceService actionPersistenceService,
- JwtHelper jwtHelper) {
+ ObjectivePersistenceService objectivePersistenceService,
+ ActionPersistenceService actionPersistenceService, JwtHelper jwtHelper) {
this.authorizationRegistrationService = authorizationRegistrationService;
this.actionPersistenceService = actionPersistenceService;
this.objectivePersistenceService = objectivePersistenceService;
@@ -45,7 +45,7 @@ public static boolean hasRoleWriteForTeam(AuthorizationUser authorizationUser, L
}
public static void checkRoleWriteAndReadAll(AuthorizationUser user,
- OkrResponseStatusException notAuthorizedException) {
+ OkrResponseStatusException notAuthorizedException) {
if (hasRoleWriteAndReadAll(user)) {
return;
}
@@ -67,40 +67,53 @@ public AuthorizationUser updateOrAddAuthorizationUser() {
}
public void hasRoleReadByObjectiveId(Long objectiveId, AuthorizationUser authorizationUser) {
- objectivePersistenceService.findObjectiveById(objectiveId, authorizationUser,
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, OBJECTIVE));
+ objectivePersistenceService
+ .findObjectiveById(objectiveId,
+ authorizationUser,
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, OBJECTIVE));
}
public void hasRoleReadByKeyResultId(Long keyResultId, AuthorizationUser authorizationUser) {
- objectivePersistenceService.findObjectiveByKeyResultId(keyResultId, authorizationUser,
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, KEY_RESULT));
+ objectivePersistenceService
+ .findObjectiveByKeyResultId(keyResultId,
+ authorizationUser,
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, KEY_RESULT));
}
public void hasRoleReadByCheckInId(Long checkInId, AuthorizationUser authorizationUser) {
- objectivePersistenceService.findObjectiveByCheckInId(checkInId, authorizationUser,
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, CHECK_IN));
+ objectivePersistenceService
+ .findObjectiveByCheckInId(checkInId,
+ authorizationUser,
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, CHECK_IN));
}
public void hasRoleCreateOrUpdate(Objective objective, AuthorizationUser authorizationUser) {
- hasRoleWriteForTeam(authorizationUser, objective.getTeam(),
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_WRITE, OBJECTIVE));
+ hasRoleWriteForTeam(authorizationUser,
+ objective.getTeam(),
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_WRITE, OBJECTIVE));
}
public void hasRoleCreateOrUpdate(KeyResult keyResult, AuthorizationUser authorizationUser) {
- Objective objective = objectivePersistenceService.findObjectiveById(keyResult.getObjective().getId(),
- authorizationUser, OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, KEY_RESULT));
+ Objective objective = objectivePersistenceService
+ .findObjectiveById(keyResult.getObjective().getId(),
+ authorizationUser,
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, KEY_RESULT));
- hasRoleWriteForTeam(authorizationUser, objective.getTeam(),
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_WRITE, KEY_RESULT));
+ hasRoleWriteForTeam(authorizationUser,
+ objective.getTeam(),
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_WRITE, KEY_RESULT));
}
public void hasRoleCreateOrUpdate(CheckIn checkIn, AuthorizationUser authorizationUser) {
- Objective objective = objectivePersistenceService.findObjectiveByKeyResultId(checkIn.getKeyResult().getId(),
- authorizationUser, OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, CHECK_IN));
+ Objective objective = objectivePersistenceService
+ .findObjectiveByKeyResultId(checkIn.getKeyResult().getId(),
+ authorizationUser,
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, CHECK_IN));
- hasRoleWriteForTeam(authorizationUser, objective.getTeam(),
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_WRITE, CHECK_IN));
+ hasRoleWriteForTeam(authorizationUser,
+ objective.getTeam(),
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_WRITE, CHECK_IN));
}
public boolean hasRoleWriteForTeam(Objective objective, AuthorizationUser authorizationUser) {
@@ -108,59 +121,76 @@ public boolean hasRoleWriteForTeam(Objective objective, AuthorizationUser author
}
public boolean hasRoleWriteForTeam(KeyResult keyResult, AuthorizationUser authorizationUser) {
- Objective objective = objectivePersistenceService.findObjectiveById(keyResult.getObjective().getId(),
- authorizationUser, OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, KEY_RESULT));
+ Objective objective = objectivePersistenceService
+ .findObjectiveById(keyResult.getObjective().getId(),
+ authorizationUser,
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, KEY_RESULT));
return hasRoleWriteForTeam(authorizationUser, objective.getTeam());
}
public boolean hasRoleWriteForTeam(CheckIn checkIn, AuthorizationUser authorizationUser) {
- Objective objective = objectivePersistenceService.findObjectiveByKeyResultId(checkIn.getKeyResult().getId(),
- authorizationUser, OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, CHECK_IN));
+ Objective objective = objectivePersistenceService
+ .findObjectiveByKeyResultId(checkIn.getKeyResult().getId(),
+ authorizationUser,
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, CHECK_IN));
return hasRoleWriteForTeam(authorizationUser, objective.getTeam());
}
public void hasRoleCreateOrUpdateByObjectiveId(Long objectiveId, AuthorizationUser authorizationUser) {
- Objective objective = objectivePersistenceService.findObjectiveById(objectiveId, authorizationUser,
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, OBJECTIVE));
+ Objective objective = objectivePersistenceService
+ .findObjectiveById(objectiveId,
+ authorizationUser,
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, OBJECTIVE));
- hasRoleWriteForTeam(authorizationUser, objective.getTeam(),
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_WRITE, OBJECTIVE));
+ hasRoleWriteForTeam(authorizationUser,
+ objective.getTeam(),
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_WRITE, OBJECTIVE));
}
public void hasRoleDeleteByObjectiveId(Long objectiveId, AuthorizationUser authorizationUser) {
- Objective objective = objectivePersistenceService.findObjectiveById(objectiveId, authorizationUser,
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, OBJECTIVE));
+ Objective objective = objectivePersistenceService
+ .findObjectiveById(objectiveId,
+ authorizationUser,
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, OBJECTIVE));
- hasRoleWriteForTeam(authorizationUser, objective.getTeam(),
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_DELETE, OBJECTIVE));
+ hasRoleWriteForTeam(authorizationUser,
+ objective.getTeam(),
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_DELETE, OBJECTIVE));
}
public void hasRoleDeleteByKeyResultId(Long keyResultId, AuthorizationUser authorizationUser) {
- Objective objective = objectivePersistenceService.findObjectiveByKeyResultId(keyResultId, authorizationUser,
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, KEY_RESULT));
+ Objective objective = objectivePersistenceService
+ .findObjectiveByKeyResultId(keyResultId,
+ authorizationUser,
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, KEY_RESULT));
- hasRoleWriteForTeam(authorizationUser, objective.getTeam(),
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_DELETE, KEY_RESULT));
+ hasRoleWriteForTeam(authorizationUser,
+ objective.getTeam(),
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_DELETE, KEY_RESULT));
}
public void hasRoleDeleteByActionId(Long actionId, AuthorizationUser authorizationUser) {
Action action = actionPersistenceService.findById(actionId);
- hasRoleWriteForTeam(authorizationUser, action.getKeyResult().getObjective().getTeam(),
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_DELETE, ACTION));
+ hasRoleWriteForTeam(authorizationUser,
+ action.getKeyResult().getObjective().getTeam(),
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_DELETE, ACTION));
}
public void hasRoleDeleteByCheckInId(Long checkInId, AuthorizationUser authorizationUser) {
- Objective objective = objectivePersistenceService.findObjectiveByCheckInId(checkInId, authorizationUser,
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, CHECK_IN));
+ Objective objective = objectivePersistenceService
+ .findObjectiveByCheckInId(checkInId,
+ authorizationUser,
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_READ, CHECK_IN));
- hasRoleWriteForTeam(authorizationUser, objective.getTeam(),
- OkrResponseStatusException.of(NOT_AUTHORIZED_TO_DELETE, CHECK_IN));
+ hasRoleWriteForTeam(authorizationUser,
+ objective.getTeam(),
+ OkrResponseStatusException.of(NOT_AUTHORIZED_TO_DELETE, CHECK_IN));
}
private void hasRoleWriteForTeam(AuthorizationUser authorizationUser, Team team,
- OkrResponseStatusException notAuthorizedException) {
+ OkrResponseStatusException notAuthorizedException) {
if (hasRoleWriteForTeam(authorizationUser, team)) {
return;
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationServiceBase.java b/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationServiceBase.java
index 51cd7ab046..92766a80fc 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationServiceBase.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/authorization/AuthorizationServiceBase.java
@@ -17,7 +17,7 @@ public abstract class AuthorizationServiceBase businessService,
- AuthorizationService authorizationService) {
+ AuthorizationService authorizationService) {
this.businessService = businessService;
this.authorizationService = authorizationService;
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/authorization/CheckInAuthorizationService.java b/backend/src/main/java/ch/puzzle/okr/service/authorization/CheckInAuthorizationService.java
index bb6196d6f6..04c8f6f64e 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/authorization/CheckInAuthorizationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/authorization/CheckInAuthorizationService.java
@@ -9,7 +9,7 @@
public class CheckInAuthorizationService extends AuthorizationServiceBase {
public CheckInAuthorizationService(CheckInBusinessService checkInBusinessService,
- AuthorizationService authorizationService) {
+ AuthorizationService authorizationService) {
super(checkInBusinessService, authorizationService);
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/authorization/CompletedAuthorizationService.java b/backend/src/main/java/ch/puzzle/okr/service/authorization/CompletedAuthorizationService.java
index a59467a3ca..3ea9524532 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/authorization/CompletedAuthorizationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/authorization/CompletedAuthorizationService.java
@@ -11,7 +11,7 @@ public class CompletedAuthorizationService {
private final AuthorizationService authorizationService;
public CompletedAuthorizationService(CompletedBusinessService completedBusinessService,
- AuthorizationService authorizationService) {
+ AuthorizationService authorizationService) {
this.completedBusinessService = completedBusinessService;
this.authorizationService = authorizationService;
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/authorization/KeyResultAuthorizationService.java b/backend/src/main/java/ch/puzzle/okr/service/authorization/KeyResultAuthorizationService.java
index a2197e89b5..a280f33bef 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/authorization/KeyResultAuthorizationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/authorization/KeyResultAuthorizationService.java
@@ -1,23 +1,22 @@
package ch.puzzle.okr.service.authorization;
+import static org.springframework.http.HttpStatus.BAD_REQUEST;
+
import ch.puzzle.okr.models.Action;
import ch.puzzle.okr.models.authorization.AuthorizationUser;
import ch.puzzle.okr.models.checkin.CheckIn;
import ch.puzzle.okr.models.keyresult.KeyResult;
import ch.puzzle.okr.models.keyresult.KeyResultWithActionList;
import ch.puzzle.okr.service.business.KeyResultBusinessService;
+import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.server.ResponseStatusException;
-import java.util.List;
-
-import static org.springframework.http.HttpStatus.BAD_REQUEST;
-
@Service
public class KeyResultAuthorizationService extends AuthorizationServiceBase {
public KeyResultAuthorizationService(KeyResultBusinessService keyResultBusinessService,
- AuthorizationService authorizationService) {
+ AuthorizationService authorizationService) {
super(keyResultBusinessService, authorizationService);
}
@@ -52,7 +51,8 @@ public List getAllCheckInsByKeyResult(Long keyResultId) {
@Override
public KeyResult updateEntity(Long id, KeyResult keyResult) {
throw new ResponseStatusException(BAD_REQUEST,
- "unsupported method in class " + getClass().getSimpleName() + ", use updateEntities() instead");
+ "unsupported method in class " + getClass().getSimpleName()
+ + ", use updateEntities() instead");
}
public KeyResultWithActionList updateEntities(Long id, KeyResult entity, List actionList) {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/authorization/ObjectiveAuthorizationService.java b/backend/src/main/java/ch/puzzle/okr/service/authorization/ObjectiveAuthorizationService.java
index c98338d477..97d8fbb38b 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/authorization/ObjectiveAuthorizationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/authorization/ObjectiveAuthorizationService.java
@@ -4,16 +4,14 @@
import ch.puzzle.okr.models.authorization.AuthorizationUser;
import ch.puzzle.okr.models.keyresult.KeyResult;
import ch.puzzle.okr.service.business.ObjectiveBusinessService;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
import java.util.List;
+import org.springframework.stereotype.Service;
@Service
public class ObjectiveAuthorizationService extends AuthorizationServiceBase {
public ObjectiveAuthorizationService(ObjectiveBusinessService objectiveBusinessService,
- AuthorizationService authorizationService) {
+ AuthorizationService authorizationService) {
super(objectiveBusinessService, authorizationService);
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/authorization/OverviewAuthorizationService.java b/backend/src/main/java/ch/puzzle/okr/service/authorization/OverviewAuthorizationService.java
index 3f4487b31b..76f9a9f1df 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/authorization/OverviewAuthorizationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/authorization/OverviewAuthorizationService.java
@@ -1,16 +1,15 @@
package ch.puzzle.okr.service.authorization;
+import static ch.puzzle.okr.service.authorization.AuthorizationService.hasRoleWriteAndReadAll;
+
import ch.puzzle.okr.models.authorization.AuthorizationUser;
import ch.puzzle.okr.models.overview.Overview;
import ch.puzzle.okr.service.business.OverviewBusinessService;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
-import static ch.puzzle.okr.service.authorization.AuthorizationService.hasRoleWriteAndReadAll;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
@Service
public class OverviewAuthorizationService {
@@ -19,15 +18,15 @@ public class OverviewAuthorizationService {
private final AuthorizationService authorizationService;
public OverviewAuthorizationService(OverviewBusinessService overviewBusinessService,
- AuthorizationService authorizationService) {
+ AuthorizationService authorizationService) {
this.overviewBusinessService = overviewBusinessService;
this.authorizationService = authorizationService;
}
public List getFilteredOverview(Long quarterId, List teamIds, String objectiveQuery) {
AuthorizationUser authorizationUser = authorizationService.updateOrAddAuthorizationUser();
- List overviews = overviewBusinessService.getFilteredOverview(quarterId, teamIds, objectiveQuery,
- authorizationUser);
+ List overviews = overviewBusinessService
+ .getFilteredOverview(quarterId, teamIds, objectiveQuery, authorizationUser);
setRoleCreateOrUpdateTeam(overviews, authorizationUser);
return overviews;
}
@@ -40,7 +39,7 @@ private void setRoleCreateOrUpdateTeam(List overviews, AuthorizationUs
}
private void setRoleCreateOrUpdateTeam(Overview overview, AuthorizationUser authorizationUser,
- Map teamAccess) {
+ Map teamAccess) {
if (hasOverviewTeamIdAndObjectiveId(overview)) {
Long teamId = overview.getOverviewId().getTeamId();
teamAccess.putIfAbsent(teamId, isWriteable(authorizationUser, overview));
@@ -50,7 +49,7 @@ private void setRoleCreateOrUpdateTeam(Overview overview, AuthorizationUser auth
private boolean hasOverviewTeamIdAndObjectiveId(Overview overview) {
return overview.getOverviewId() != null && overview.getOverviewId().getObjectiveId() != null
- && overview.getOverviewId().getTeamId() != null;
+ && overview.getOverviewId().getTeamId() != null;
}
public boolean hasWriteAllAccess() {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/authorization/TeamAuthorizationService.java b/backend/src/main/java/ch/puzzle/okr/service/authorization/TeamAuthorizationService.java
index 33e2cecd33..0909821d35 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/authorization/TeamAuthorizationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/authorization/TeamAuthorizationService.java
@@ -1,16 +1,15 @@
package ch.puzzle.okr.service.authorization;
+import static ch.puzzle.okr.Constants.TEAM;
+import static ch.puzzle.okr.service.authorization.AuthorizationService.hasRoleWriteAndReadAll;
+
import ch.puzzle.okr.ErrorKey;
import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.models.Team;
import ch.puzzle.okr.models.authorization.AuthorizationUser;
import ch.puzzle.okr.service.business.TeamBusinessService;
-import org.springframework.stereotype.Service;
-
import java.util.List;
-
-import static ch.puzzle.okr.Constants.TEAM;
-import static ch.puzzle.okr.service.authorization.AuthorizationService.hasRoleWriteAndReadAll;
+import org.springframework.stereotype.Service;
@Service
public class TeamAuthorizationService {
@@ -18,7 +17,7 @@ public class TeamAuthorizationService {
private final AuthorizationService authorizationService;
public TeamAuthorizationService(TeamBusinessService teamBusinessService,
- AuthorizationService authorizationService) {
+ AuthorizationService authorizationService) {
this.teamBusinessService = teamBusinessService;
this.authorizationService = authorizationService;
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/authorization/UserAuthorizationService.java b/backend/src/main/java/ch/puzzle/okr/service/authorization/UserAuthorizationService.java
index fab3dba8fe..9ec8444c6e 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/authorization/UserAuthorizationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/authorization/UserAuthorizationService.java
@@ -1,5 +1,7 @@
package ch.puzzle.okr.service.authorization;
+import static ch.puzzle.okr.Constants.USER;
+
import ch.puzzle.okr.ErrorKey;
import ch.puzzle.okr.dto.userOkrData.UserOkrDataDto;
import ch.puzzle.okr.exception.OkrResponseStatusException;
@@ -9,11 +11,8 @@
import ch.puzzle.okr.models.keyresult.KeyResult;
import ch.puzzle.okr.service.business.KeyResultBusinessService;
import ch.puzzle.okr.service.business.UserBusinessService;
-import org.springframework.stereotype.Service;
-
import java.util.List;
-
-import static ch.puzzle.okr.Constants.USER;
+import org.springframework.stereotype.Service;
@Service
public class UserAuthorizationService {
@@ -24,7 +23,8 @@ public class UserAuthorizationService {
private final KeyResultBusinessService keyResultBusinessService;
public UserAuthorizationService(UserBusinessService userBusinessService, AuthorizationService authorizationService,
- TeamAuthorizationService teamAuthorizationService, KeyResultBusinessService keyResultBusinessService) {
+ TeamAuthorizationService teamAuthorizationService,
+ KeyResultBusinessService keyResultBusinessService) {
this.userBusinessService = userBusinessService;
this.authorizationService = authorizationService;
this.teamAuthorizationService = teamAuthorizationService;
@@ -54,14 +54,16 @@ public User getById(long id) {
public User setIsOkrChampion(long id, boolean isOkrChampion) {
var user = userBusinessService.getUserById(id);
- AuthorizationService.checkRoleWriteAndReadAll(authorizationService.updateOrAddAuthorizationUser(),
- OkrResponseStatusException.of(ErrorKey.NOT_AUTHORIZED_TO_WRITE, USER));
+ AuthorizationService
+ .checkRoleWriteAndReadAll(authorizationService.updateOrAddAuthorizationUser(),
+ OkrResponseStatusException.of(ErrorKey.NOT_AUTHORIZED_TO_WRITE, USER));
return userBusinessService.setIsOkrChampion(user, isOkrChampion);
}
public List createUsers(List userList) {
- AuthorizationService.checkRoleWriteAndReadAll(authorizationService.updateOrAddAuthorizationUser(),
- OkrResponseStatusException.of(ErrorKey.NOT_AUTHORIZED_TO_WRITE, USER));
+ AuthorizationService
+ .checkRoleWriteAndReadAll(authorizationService.updateOrAddAuthorizationUser(),
+ OkrResponseStatusException.of(ErrorKey.NOT_AUTHORIZED_TO_WRITE, USER));
return userBusinessService.createUsers(userList);
}
@@ -71,8 +73,9 @@ public boolean isUserMemberOfTeams(long id) {
}
public void deleteEntityById(long id) {
- AuthorizationService.checkRoleWriteAndReadAll(authorizationService.updateOrAddAuthorizationUser(),
- OkrResponseStatusException.of(ErrorKey.NOT_AUTHORIZED_TO_DELETE, USER));
+ AuthorizationService
+ .checkRoleWriteAndReadAll(authorizationService.updateOrAddAuthorizationUser(),
+ OkrResponseStatusException.of(ErrorKey.NOT_AUTHORIZED_TO_DELETE, USER));
userBusinessService.deleteEntityById(id);
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/business/ActionBusinessService.java b/backend/src/main/java/ch/puzzle/okr/service/business/ActionBusinessService.java
index 9a684f6a54..7d1d1a9188 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/business/ActionBusinessService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/business/ActionBusinessService.java
@@ -4,10 +4,9 @@
import ch.puzzle.okr.service.persistence.ActionPersistenceService;
import ch.puzzle.okr.service.validation.ActionValidationService;
import jakarta.transaction.Transactional;
-import org.springframework.stereotype.Service;
-
import java.util.ArrayList;
import java.util.List;
+import org.springframework.stereotype.Service;
@Service
public class ActionBusinessService {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/business/AlignmentBusinessService.java b/backend/src/main/java/ch/puzzle/okr/service/business/AlignmentBusinessService.java
index ea7d9644a9..4c4261fcf6 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/business/AlignmentBusinessService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/business/AlignmentBusinessService.java
@@ -5,9 +5,8 @@
import ch.puzzle.okr.models.keyresult.KeyResult;
import ch.puzzle.okr.service.persistence.AlignmentPersistenceService;
import ch.puzzle.okr.service.validation.AlignmentValidationService;
-import org.springframework.stereotype.Service;
-
import java.util.List;
+import org.springframework.stereotype.Service;
@Service
public class AlignmentBusinessService {
@@ -15,7 +14,7 @@ public class AlignmentBusinessService {
private final AlignmentValidationService validation;
public AlignmentBusinessService(AlignmentPersistenceService alignmentPersistenceService,
- AlignmentValidationService validation) {
+ AlignmentValidationService validation) {
this.alignmentPersistenceService = alignmentPersistenceService;
this.validation = validation;
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/business/AlignmentSelectionBusinessService.java b/backend/src/main/java/ch/puzzle/okr/service/business/AlignmentSelectionBusinessService.java
index 8e6feefed1..893a075c76 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/business/AlignmentSelectionBusinessService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/business/AlignmentSelectionBusinessService.java
@@ -2,22 +2,20 @@
import ch.puzzle.okr.models.alignment.AlignmentSelection;
import ch.puzzle.okr.service.persistence.AlignmentSelectionPersistenceService;
-import org.springframework.stereotype.Service;
-
import java.util.List;
+import org.springframework.stereotype.Service;
@Service
public class AlignmentSelectionBusinessService {
private final AlignmentSelectionPersistenceService alignmentSelectionPersistenceService;
- public AlignmentSelectionBusinessService(
- AlignmentSelectionPersistenceService alignmentSelectionPersistenceService) {
+ public AlignmentSelectionBusinessService(AlignmentSelectionPersistenceService alignmentSelectionPersistenceService) {
this.alignmentSelectionPersistenceService = alignmentSelectionPersistenceService;
}
public List getAlignmentSelectionByQuarterIdAndTeamIdNot(Long quarterId, Long ignoredTeamId) {
- return alignmentSelectionPersistenceService.getAlignmentSelectionByQuarterIdAndTeamIdNot(quarterId,
- ignoredTeamId);
+ return alignmentSelectionPersistenceService
+ .getAlignmentSelectionByQuarterIdAndTeamIdNot(quarterId, ignoredTeamId);
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/business/CheckInBusinessService.java b/backend/src/main/java/ch/puzzle/okr/service/business/CheckInBusinessService.java
index db6e892cb0..ad9456d175 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/business/CheckInBusinessService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/business/CheckInBusinessService.java
@@ -5,10 +5,9 @@
import ch.puzzle.okr.service.persistence.CheckInPersistenceService;
import ch.puzzle.okr.service.validation.CheckInValidationService;
import jakarta.transaction.Transactional;
-import org.springframework.stereotype.Service;
-
import java.time.LocalDateTime;
import java.util.List;
+import org.springframework.stereotype.Service;
@Service
public class CheckInBusinessService implements BusinessServiceInterface {
@@ -16,7 +15,7 @@ public class CheckInBusinessService implements BusinessServiceInterface {
@@ -28,8 +26,9 @@ public class KeyResultBusinessService implements BusinessServiceInterface acti
@Transactional
public void deleteEntityById(Long id) {
validator.validateOnDelete(id);
- checkInBusinessService.getCheckInsByKeyResultId(id)
+ checkInBusinessService
+ .getCheckInsByKeyResultId(id)
.forEach(checkIn -> checkInBusinessService.deleteEntityById(checkIn.getId()));
- actionBusinessService.getActionsByKeyResultId(id)
+ actionBusinessService
+ .getActionsByKeyResultId(id)
.forEach(action -> actionBusinessService.deleteEntityById(action.getId()));
keyResultPersistenceService.deleteById(id);
}
@@ -126,7 +127,7 @@ public boolean hasKeyResultAnyCheckIns(Long id) {
public boolean isImUsed(Long id, KeyResult keyResult) {
return hasKeyResultAnyCheckIns(id)
- && !keyResultPersistenceService.findById(id).getKeyResultType().equals(keyResult.getKeyResultType());
+ && !keyResultPersistenceService.findById(id).getKeyResultType().equals(keyResult.getKeyResultType());
}
private boolean isKeyResultTypeChangeable(Long id) {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/business/ObjectiveBusinessService.java b/backend/src/main/java/ch/puzzle/okr/service/business/ObjectiveBusinessService.java
index 40f7eefd80..05f217180c 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/business/ObjectiveBusinessService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/business/ObjectiveBusinessService.java
@@ -1,5 +1,8 @@
package ch.puzzle.okr.service.business;
+import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_METRIC;
+import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_ORDINAL;
+
import ch.puzzle.okr.models.Objective;
import ch.puzzle.okr.models.authorization.AuthorizationUser;
import ch.puzzle.okr.models.keyresult.KeyResult;
@@ -8,18 +11,14 @@
import ch.puzzle.okr.service.persistence.ObjectivePersistenceService;
import ch.puzzle.okr.service.validation.ObjectiveValidationService;
import jakarta.transaction.Transactional;
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
-import java.time.LocalDateTime;
-import java.util.List;
-import java.util.Objects;
-
-import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_METRIC;
-import static ch.puzzle.okr.Constants.KEY_RESULT_TYPE_ORDINAL;
-
@Service
public class ObjectiveBusinessService implements BusinessServiceInterface {
private static final Logger logger = LoggerFactory.getLogger(ObjectiveBusinessService.class);
@@ -29,8 +28,9 @@ public class ObjectiveBusinessService implements BusinessServiceInterface keyResultBusinessService.hasKeyResultAnyCheckIns(kr.getId()));
}
@@ -105,8 +107,8 @@ public Objective createEntity(Objective objective, AuthorizationUser authorizati
}
/**
- * Create a new Objective (with a new ID) and copy from a source Objective (identified by id) the KeyResults. The
- * CheckIns are not copied.
+ * Create a new Objective (with a new ID) and copy from a source Objective
+ * (identified by id) the KeyResults. The CheckIns are not copied.
*
* @param id
* ID of the source Objective
@@ -121,7 +123,7 @@ public Objective createEntity(Objective objective, AuthorizationUser authorizati
*/
@Transactional
public Objective duplicateObjective(Long id, Objective objective, AuthorizationUser authorizationUser,
- List keyResults) {
+ List keyResults) {
Objective duplicatedObjective = createEntity(objective, authorizationUser);
for (KeyResult keyResult : keyResults) {
duplicateKeyResult(authorizationUser, keyResult, duplicatedObjective);
@@ -130,7 +132,7 @@ public Objective duplicateObjective(Long id, Objective objective, AuthorizationU
}
private void duplicateKeyResult(AuthorizationUser authorizationUser, KeyResult keyResult,
- Objective duplicatedObjective) {
+ Objective duplicatedObjective) {
if (keyResult.getKeyResultType().equals(KEY_RESULT_TYPE_METRIC)) {
KeyResult keyResultMetric = makeCopyOfKeyResultMetric(keyResult, duplicatedObjective);
keyResultBusinessService.createEntity(keyResultMetric, authorizationUser);
@@ -141,7 +143,8 @@ private void duplicateKeyResult(AuthorizationUser authorizationUser, KeyResult k
}
private KeyResult makeCopyOfKeyResultMetric(KeyResult keyResult, Objective duplicatedObjective) {
- return KeyResultMetric.Builder.builder() //
+ return KeyResultMetric.Builder
+ .builder() //
.withObjective(duplicatedObjective) //
.withTitle(keyResult.getTitle()) //
.withDescription(keyResult.getDescription()) //
@@ -153,7 +156,8 @@ private KeyResult makeCopyOfKeyResultMetric(KeyResult keyResult, Objective dupli
}
private KeyResult makeCopyOfKeyResultOrdinal(KeyResult keyResult, Objective duplicatedObjective) {
- return KeyResultOrdinal.Builder.builder() //
+ return KeyResultOrdinal.Builder
+ .builder() //
.withObjective(duplicatedObjective) //
.withTitle(keyResult.getTitle()) //
.withDescription(keyResult.getDescription()) //
diff --git a/backend/src/main/java/ch/puzzle/okr/service/business/OverviewBusinessService.java b/backend/src/main/java/ch/puzzle/okr/service/business/OverviewBusinessService.java
index da721f6c27..677d6a626a 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/business/OverviewBusinessService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/business/OverviewBusinessService.java
@@ -4,11 +4,10 @@
import ch.puzzle.okr.models.overview.Overview;
import ch.puzzle.okr.service.persistence.OverviewPersistenceService;
import ch.puzzle.okr.service.validation.OverviewValidationService;
-import org.springframework.stereotype.Service;
-
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
+import org.springframework.stereotype.Service;
@Service
public class OverviewBusinessService {
@@ -17,14 +16,14 @@ public class OverviewBusinessService {
private final OverviewValidationService validator;
public OverviewBusinessService(OverviewPersistenceService overviewPersistenceService,
- QuarterBusinessService quarterBusinessService, OverviewValidationService validator) {
+ QuarterBusinessService quarterBusinessService, OverviewValidationService validator) {
this.overviewPersistenceService = overviewPersistenceService;
this.quarterBusinessService = quarterBusinessService;
this.validator = validator;
}
public List getFilteredOverview(Long quarterId, List teamIds, String objectiveQuery,
- AuthorizationUser authorizationUser) {
+ AuthorizationUser authorizationUser) {
if (Objects.isNull(quarterId)) {
quarterId = quarterBusinessService.getCurrentQuarter().getId();
}
@@ -35,8 +34,8 @@ public List getFilteredOverview(Long quarterId, List teamIds, St
return List.of();
}
- List overviews = overviewPersistenceService.getFilteredOverview(quarterId, teamIds, objectiveQuery,
- authorizationUser);
+ List overviews = overviewPersistenceService
+ .getFilteredOverview(quarterId, teamIds, objectiveQuery, authorizationUser);
return sortOverview(overviews, authorizationUser);
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/business/QuarterBusinessService.java b/backend/src/main/java/ch/puzzle/okr/service/business/QuarterBusinessService.java
index 5f6c35053b..7069eb4cf9 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/business/QuarterBusinessService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/business/QuarterBusinessService.java
@@ -1,8 +1,15 @@
package ch.puzzle.okr.service.business;
+import static ch.puzzle.okr.Constants.BACK_LOG_QUARTER_LABEL;
+
import ch.puzzle.okr.models.Quarter;
import ch.puzzle.okr.service.persistence.QuarterPersistenceService;
import ch.puzzle.okr.service.validation.QuarterValidationService;
+import java.time.LocalDateTime;
+import java.time.YearMonth;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -10,14 +17,6 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
-import java.time.LocalDateTime;
-import java.time.YearMonth;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static ch.puzzle.okr.Constants.BACK_LOG_QUARTER_LABEL;
-
@Service
public class QuarterBusinessService {
private static final Logger logger = LoggerFactory.getLogger(QuarterBusinessService.class);
@@ -32,7 +31,7 @@ public class QuarterBusinessService {
private String quarterFormat;
public QuarterBusinessService(QuarterPersistenceService quarterPersistenceService,
- QuarterValidationService validator) {
+ QuarterValidationService validator) {
this.quarterPersistenceService = quarterPersistenceService;
this.validator = validator;
}
@@ -66,9 +65,11 @@ private String createQuarterLabel(YearMonth startOfQuarter, int quarter) {
int yearStart = getStartOfBusinessYear(startOfQuarter, quarter);
int yearEnd = yearStart + 1;
- return StringUtils.replaceEach(quarterFormat, new String[] { "xxxx", "yyyy", "xx", "yy", "zz" },
- new String[] { String.valueOf(yearStart), String.valueOf(yearEnd), shortenYear(yearStart),
- shortenYear(yearEnd), String.valueOf(quarter) });
+ return StringUtils
+ .replaceEach(quarterFormat,
+ new String[]{ "xxxx", "yyyy", "xx", "yy", "zz" },
+ new String[]{ String.valueOf(yearStart), String.valueOf(yearEnd), shortenYear(yearStart),
+ shortenYear(yearEnd), String.valueOf(quarter) });
}
private int getStartOfBusinessYear(YearMonth startOfQuarter, int quarter) {
@@ -79,8 +80,12 @@ private int getStartOfBusinessYear(YearMonth startOfQuarter, int quarter) {
private void generateQuarter(LocalDateTime start, String label) {
YearMonth yearMonth = YearMonth.from(start);
- Quarter quarter = Quarter.Builder.builder().withLabel(label).withStartDate(start.toLocalDate())
- .withEndDate(yearMonth.plusMonths(2).atEndOfMonth()).build();
+ Quarter quarter = Quarter.Builder
+ .builder()
+ .withLabel(label)
+ .withStartDate(start.toLocalDate())
+ .withEndDate(yearMonth.plusMonths(2).atEndOfMonth())
+ .build();
validator.validateOnGeneration(quarter);
quarterPersistenceService.save(quarter);
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/business/TeamBusinessService.java b/backend/src/main/java/ch/puzzle/okr/service/business/TeamBusinessService.java
index f05a069673..e4b46423a7 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/business/TeamBusinessService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/business/TeamBusinessService.java
@@ -12,13 +12,12 @@
import ch.puzzle.okr.service.persistence.UserTeamPersistenceService;
import ch.puzzle.okr.service.validation.TeamValidationService;
import jakarta.transaction.Transactional;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Service;
-
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Service;
@Service
public class TeamBusinessService {
@@ -35,9 +34,9 @@ public class TeamBusinessService {
private final CacheService cacheService;
public TeamBusinessService(TeamPersistenceService teamPersistenceService,
- ObjectiveBusinessService objectiveBusinessService, TeamValidationService validator,
- CacheService cacheService, UserPersistenceService userPersistenceService,
- UserTeamPersistenceService userTeamPersistenceService) {
+ ObjectiveBusinessService objectiveBusinessService, TeamValidationService validator,
+ CacheService cacheService, UserPersistenceService userPersistenceService,
+ UserTeamPersistenceService userTeamPersistenceService) {
this.teamPersistenceService = teamPersistenceService;
this.objectiveBusinessService = objectiveBusinessService;
this.userPersistenceService = userPersistenceService;
@@ -52,7 +51,8 @@ public Team getTeamById(Long teamId) {
}
@Transactional
- // Creates a new team. Current authorization user is added as admin user in team.
+ // Creates a new team. Current authorization user is added as admin user in
+ // team.
public Team createTeam(Team team, AuthorizationUser authorizationUser) {
validator.validateOnCreate(team);
cacheService.emptyAuthorizationUsersCache();
@@ -72,7 +72,8 @@ public Team updateTeam(Team team, Long id) {
@Transactional
public void deleteTeam(Long id) {
validator.validateOnDelete(id);
- objectiveBusinessService.getEntitiesByTeamId(id)
+ objectiveBusinessService
+ .getEntitiesByTeamId(id)
.forEach(objective -> objectiveBusinessService.deleteEntityById(objective.getId()));
deleteUserTeamList(id);
cacheService.emptyAuthorizationUsersCache();
@@ -81,7 +82,8 @@ public void deleteTeam(Long id) {
private void deleteUserTeamList(Long id) {
var team = teamPersistenceService.findById(id);
- // remove userTeam from each user, otherwise they are still in the session and are not deleted
+ // remove userTeam from each user, otherwise they are still in the session and
+ // are not deleted
team.getUserTeamList().forEach(userTeam -> {
var user = userTeam.getUser();
user.getUserTeamList().remove(userTeam);
@@ -122,9 +124,12 @@ public void removeUserFromTeam(long teamId, long userId) {
checkTeamHasAtLeastOneAdmin(team, user);
var userTeamList = user.getUserTeamList();
- var userTeamToRemove = userTeamList.stream().filter(ut -> ut.getTeam().getId() == teamId).findFirst()
+ var userTeamToRemove = userTeamList
+ .stream()
+ .filter(ut -> ut.getTeam().getId() == teamId)
+ .findFirst()
.orElseThrow(() -> new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
- "No team found to remove from userTeam list"));
+ "No team found to remove from userTeam list"));
userTeamList.remove(userTeamToRemove);
team.getUserTeamList().remove(userTeamToRemove);
userTeamPersistenceService.delete(userTeamToRemove);
@@ -133,10 +138,13 @@ public void removeUserFromTeam(long teamId, long userId) {
}
private void checkTeamHasAtLeastOneAdmin(Team team, User user) {
- team.getUserTeamList().stream()
- .filter(ut -> ut.isTeamAdmin() && !Objects.equals(ut.getUser().getId(), user.getId())).findAny()
+ team
+ .getUserTeamList()
+ .stream()
+ .filter(ut -> ut.isTeamAdmin() && !Objects.equals(ut.getUser().getId(), user.getId()))
+ .findAny()
.orElseThrow(() -> new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
- ErrorKey.TRIED_TO_DELETE_LAST_ADMIN));
+ ErrorKey.TRIED_TO_DELETE_LAST_ADMIN));
}
@Transactional
diff --git a/backend/src/main/java/ch/puzzle/okr/service/business/UserBusinessService.java b/backend/src/main/java/ch/puzzle/okr/service/business/UserBusinessService.java
index cfb7d3901e..3bb9a10d54 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/business/UserBusinessService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/business/UserBusinessService.java
@@ -7,12 +7,11 @@
import ch.puzzle.okr.service.persistence.UserPersistenceService;
import ch.puzzle.okr.service.validation.UserValidationService;
import jakarta.transaction.Transactional;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Service;
-
import java.util.List;
import java.util.Objects;
import java.util.stream.StreamSupport;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Service;
@Service
public class UserBusinessService {
@@ -24,7 +23,7 @@ public class UserBusinessService {
private final CacheService cacheService;
public UserBusinessService(UserPersistenceService userPersistenceService, UserValidationService validationService,
- CacheService cacheService) {
+ CacheService cacheService) {
this.userPersistenceService = userPersistenceService;
this.validationService = validationService;
this.cacheService = cacheService;
@@ -55,9 +54,12 @@ public User setIsOkrChampion(User user, boolean okrChampion) {
// checks if at least one okr champion remains after removing given one
private void checkAtLeastOneOkrChampionExists(User user) {
var champions = userPersistenceService.findAllOkrChampions();
- champions.stream().filter(c -> c.isOkrChampion() && !Objects.equals(c.getId(), user.getId())).findAny()
+ champions
+ .stream()
+ .filter(c -> c.isOkrChampion() && !Objects.equals(c.getId(), user.getId()))
+ .findAny()
.orElseThrow(() -> new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
- ErrorKey.TRIED_TO_REMOVE_LAST_OKR_CHAMPION));
+ ErrorKey.TRIED_TO_REMOVE_LAST_OKR_CHAMPION));
}
public User saveUser(User user) {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/clientconfig/ClientConfigService.java b/backend/src/main/java/ch/puzzle/okr/service/clientconfig/ClientConfigService.java
index 0b83fd2f4a..29cc6ab69d 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/clientconfig/ClientConfigService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/clientconfig/ClientConfigService.java
@@ -5,14 +5,13 @@
import ch.puzzle.okr.multitenancy.customization.TenantClientCustomization;
import ch.puzzle.okr.multitenancy.customization.TenantClientCustomizationProvider;
import jakarta.persistence.EntityNotFoundException;
+import java.text.MessageFormat;
+import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
-import java.text.MessageFormat;
-import java.util.Optional;
-
@Service
public class ClientConfigService {
@@ -24,7 +23,7 @@ public class ClientConfigService {
private String activeProfile;
public ClientConfigService(final TenantClientCustomizationProvider clientCustomizationProvider,
- final TenantConfigProvider tenantConfigProvider) {
+ final TenantConfigProvider tenantConfigProvider) {
this.tenantConfigProvider = tenantConfigProvider;
this.tenantClientCustomizationProvider = clientCustomizationProvider;
}
@@ -33,32 +32,34 @@ public ClientConfigDto getConfigBasedOnActiveEnv(String hostName) {
String subdomain = hostName.split("\\.")[0];
String domainPrefixByHyphen = hostName.split("-")[0];
- Optional tenantConfig = getTenantConfig(hostName, subdomain,
- domainPrefixByHyphen);
+ Optional tenantConfig = getTenantConfig(hostName,
+ subdomain,
+ domainPrefixByHyphen);
if (tenantConfig.isEmpty()) {
- throw new EntityNotFoundException(
- MessageFormat.format("Could not find tenant config for subdomain:{0}", subdomain));
+ throw new EntityNotFoundException(MessageFormat
+ .format("Could not find tenant config for subdomain:{0}", subdomain));
}
Optional tenantClientCustomization = getTenantClientCustomization(hostName,
- subdomain, domainPrefixByHyphen);
+ subdomain,
+ domainPrefixByHyphen);
if (tenantClientCustomization.isEmpty()) {
- throw new EntityNotFoundException(
- MessageFormat.format("Could not find tenant client customization for subdomain:{0}", subdomain));
+ throw new EntityNotFoundException(MessageFormat
+ .format("Could not find tenant client customization for subdomain:{0}", subdomain));
}
return new ClientConfigDto(activeProfile, //
- tenantConfig.get().issuerUrl(), //
- tenantConfig.get().clientId(), //
- tenantClientCustomization.get().favicon(), //
- tenantClientCustomization.get().logo(), //
- tenantClientCustomization.get().triangles(), //
- tenantClientCustomization.get().backgroundLogo(), //
- tenantClientCustomization.get().title(), //
- tenantClientCustomization.get().helpSiteUrl(), //
- tenantClientCustomization.get().customStyles()); //
+ tenantConfig.get().issuerUrl(), //
+ tenantConfig.get().clientId(), //
+ tenantClientCustomization.get().favicon(), //
+ tenantClientCustomization.get().logo(), //
+ tenantClientCustomization.get().triangles(), //
+ tenantClientCustomization.get().backgroundLogo(), //
+ tenantClientCustomization.get().title(), //
+ tenantClientCustomization.get().helpSiteUrl(), //
+ tenantClientCustomization.get().customStyles()); //
}
private Optional getTenantConfig(String hostname, String... tenantsFromUrl) {
@@ -75,7 +76,7 @@ private Optional getTenantConfig(String hostn
}
private Optional getTenantClientCustomization(String hostname,
- String... tenantsFromUrl) {
+ String... tenantsFromUrl) {
for (String tenant : tenantsFromUrl) {
Optional tenantCustomization = tenantClientCustomizationProvider
.getTenantClientCustomizationsById(tenant);
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/ActionPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/ActionPersistenceService.java
index 3c3a1ff83c..2ceb3685fe 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/ActionPersistenceService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/ActionPersistenceService.java
@@ -1,12 +1,11 @@
package ch.puzzle.okr.service.persistence;
+import static ch.puzzle.okr.Constants.ACTION;
+
import ch.puzzle.okr.models.Action;
import ch.puzzle.okr.repository.ActionRepository;
-import org.springframework.stereotype.Service;
-
import java.util.List;
-
-import static ch.puzzle.okr.Constants.ACTION;
+import org.springframework.stereotype.Service;
@Service
public class ActionPersistenceService extends PersistenceBase {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/AlignmentPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/AlignmentPersistenceService.java
index 03bb2ad444..e3451cb05a 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/AlignmentPersistenceService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/AlignmentPersistenceService.java
@@ -1,14 +1,13 @@
package ch.puzzle.okr.service.persistence;
+import static ch.puzzle.okr.Constants.ALIGNMENT;
+
import ch.puzzle.okr.models.alignment.Alignment;
import ch.puzzle.okr.models.alignment.KeyResultAlignment;
import ch.puzzle.okr.models.alignment.ObjectiveAlignment;
import ch.puzzle.okr.repository.AlignmentRepository;
-import org.springframework.stereotype.Service;
-
import java.util.List;
-
-import static ch.puzzle.okr.Constants.ALIGNMENT;
+import org.springframework.stereotype.Service;
@Service
public class AlignmentPersistenceService extends PersistenceBase {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/AlignmentSelectionPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/AlignmentSelectionPersistenceService.java
index 3a439073b8..b460372231 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/AlignmentSelectionPersistenceService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/AlignmentSelectionPersistenceService.java
@@ -2,9 +2,8 @@
import ch.puzzle.okr.models.alignment.AlignmentSelection;
import ch.puzzle.okr.repository.AlignmentSelectionRepository;
-import org.springframework.stereotype.Service;
-
import java.util.List;
+import org.springframework.stereotype.Service;
@Service
public class AlignmentSelectionPersistenceService {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/AuthorizationCriteria.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/AuthorizationCriteria.java
index 50649665db..02a5dbc7ed 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/AuthorizationCriteria.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/AuthorizationCriteria.java
@@ -1,17 +1,16 @@
package ch.puzzle.okr.service.persistence;
+import static ch.puzzle.okr.models.State.*;
+import static ch.puzzle.okr.service.authorization.AuthorizationService.hasRoleWriteAndReadAll;
+import static java.lang.String.format;
+
import ch.puzzle.okr.models.authorization.AuthorizationUser;
import jakarta.persistence.TypedQuery;
+import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
-import java.util.List;
-
-import static ch.puzzle.okr.models.State.*;
-import static ch.puzzle.okr.service.authorization.AuthorizationService.hasRoleWriteAndReadAll;
-import static java.lang.String.format;
-
@Component
public class AuthorizationCriteria {
@@ -29,8 +28,9 @@ public String appendOverview(List teamIds, String objectiveQuery, Authoriz
sb.append("\n and o.overviewId.teamId in (:" + PARAM_TEAM_IDS + ")");
}
if (shouldAddObjectiveFilter(objectiveQuery)) {
- sb.append("\n and lower(coalesce(o.objectiveTitle, '')) like lower(concat('%',:" + PARAM_OBJECTIVE_QUERY
- + ",'%'))");
+ sb
+ .append("\n and lower(coalesce(o.objectiveTitle, '')) like lower(concat('%',:"
+ + PARAM_OBJECTIVE_QUERY + ",'%'))");
}
String authorizationWhereClause = append(user, alias, "objectiveState", "overviewId.teamId");
if (!authorizationWhereClause.isEmpty()) {
@@ -50,8 +50,14 @@ private String append(AuthorizationUser user, String alias, String stateColumn,
sb.append(format(" or %s.%s=:%s", alias, stateColumn, PARAM_ALL_DRAFT_STATE));
} else {
// users can read draft state of teams with admin role
- sb.append(format(" or (%s.%s=:%s and %s.%s IN (:%s))", alias, stateColumn, PARAM_TEAM_DRAFT_STATE, alias,
- teamIdColumn, PARAM_USER_TEAM_IDS));
+ sb
+ .append(format(" or (%s.%s=:%s and %s.%s IN (:%s))",
+ alias,
+ stateColumn,
+ PARAM_TEAM_DRAFT_STATE,
+ alias,
+ teamIdColumn,
+ PARAM_USER_TEAM_IDS));
}
// all users can read published state
sb.append(format(" or %s.%s IN (:%s)", alias, stateColumn, PARAM_PUBLISHED_STATES));
@@ -62,7 +68,7 @@ private String append(AuthorizationUser user, String alias, String stateColumn,
}
public void setParameters(TypedQuery typedQuery, List teamIds, String objectiveQuery,
- AuthorizationUser user) {
+ AuthorizationUser user) {
if (shouldAddTeamFilter(teamIds)) {
typedQuery.setParameter(PARAM_TEAM_IDS, teamIds);
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/CheckInPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/CheckInPersistenceService.java
index 5a96b8dcb5..8beee6fd3b 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/CheckInPersistenceService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/CheckInPersistenceService.java
@@ -1,12 +1,11 @@
package ch.puzzle.okr.service.persistence;
+import static ch.puzzle.okr.Constants.CHECK_IN;
+
import ch.puzzle.okr.models.checkin.CheckIn;
import ch.puzzle.okr.repository.CheckInRepository;
-import org.springframework.stereotype.Service;
-
import java.util.List;
-
-import static ch.puzzle.okr.Constants.CHECK_IN;
+import org.springframework.stereotype.Service;
@Service
public class CheckInPersistenceService extends PersistenceBase {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/CompletedPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/CompletedPersistenceService.java
index 48a5d2c195..4741bde78e 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/CompletedPersistenceService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/CompletedPersistenceService.java
@@ -1,11 +1,11 @@
package ch.puzzle.okr.service.persistence;
+import static ch.puzzle.okr.Constants.COMPLETED;
+
import ch.puzzle.okr.models.Completed;
import ch.puzzle.okr.repository.CompletedRepository;
import org.springframework.stereotype.Service;
-import static ch.puzzle.okr.Constants.COMPLETED;
-
@Service
public class CompletedPersistenceService extends PersistenceBase {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/KeyResultPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/KeyResultPersistenceService.java
index 392ef8266e..03e31dabb6 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/KeyResultPersistenceService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/KeyResultPersistenceService.java
@@ -1,16 +1,15 @@
package ch.puzzle.okr.service.persistence;
+import static ch.puzzle.okr.Constants.KEY_RESULT;
+
import ch.puzzle.okr.models.keyresult.KeyResult;
import ch.puzzle.okr.repository.KeyResultRepository;
import jakarta.transaction.Transactional;
+import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
-import java.util.List;
-
-import static ch.puzzle.okr.Constants.KEY_RESULT;
-
@Service
public class KeyResultPersistenceService extends PersistenceBase {
private static final Logger logger = LoggerFactory.getLogger(KeyResultPersistenceService.class);
@@ -43,7 +42,8 @@ public KeyResult updateEntity(KeyResult keyResult) {
}
public List getKeyResultsOwnedByUser(long userId) {
- return findAll().stream() //
+ return findAll()
+ .stream() //
.filter(keyResult -> keyResult.getOwner().getId().equals(userId)) //
.toList();
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/ObjectivePersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/ObjectivePersistenceService.java
index 9e7a2bcd34..aac01d8da1 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/ObjectivePersistenceService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/ObjectivePersistenceService.java
@@ -1,5 +1,7 @@
package ch.puzzle.okr.service.persistence;
+import static ch.puzzle.okr.Constants.OBJECTIVE;
+
import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.models.Objective;
import ch.puzzle.okr.models.Quarter;
@@ -9,14 +11,11 @@
import jakarta.persistence.EntityManager;
import jakarta.persistence.NoResultException;
import jakarta.persistence.TypedQuery;
+import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
-import java.util.List;
-
-import static ch.puzzle.okr.Constants.OBJECTIVE;
-
@Service
public class ObjectivePersistenceService extends PersistenceBase {
@@ -29,7 +28,7 @@ public class ObjectivePersistenceService extends PersistenceBase authorizationCriteria;
protected ObjectivePersistenceService(ObjectiveRepository repository, EntityManager entityManager,
- AuthorizationCriteria authorizationCriteria) {
+ AuthorizationCriteria authorizationCriteria) {
super(repository);
this.entityManager = entityManager;
this.authorizationCriteria = authorizationCriteria;
@@ -41,8 +40,9 @@ public String getModelName() {
}
/**
- * Get the number of Objectives of a Team in a Quarter. The underling sql looks like "select count(*) from objective
- * where teamId = team.id and quarterId = quarter.id."
+ * Get the number of Objectives of a Team in a Quarter. The underling sql looks
+ * like "select count(*) from objective where teamId = team.id and quarterId =
+ * quarter.id."
*
* @param team
* Team
@@ -56,7 +56,7 @@ public Integer countByTeamAndQuarter(Team team, Quarter quarter) {
}
public Objective findObjectiveById(Long objectiveId, AuthorizationUser authorizationUser,
- OkrResponseStatusException noResultException) {
+ OkrResponseStatusException noResultException) {
return findByAnyId(objectiveId, authorizationUser, SELECT_OBJECTIVE_BY_ID, noResultException);
}
@@ -65,17 +65,17 @@ public List findObjectiveByTeamId(Long teamId) {
}
public Objective findObjectiveByKeyResultId(Long keyResultId, AuthorizationUser authorizationUser,
- OkrResponseStatusException noResultException) {
+ OkrResponseStatusException noResultException) {
return findByAnyId(keyResultId, authorizationUser, SELECT_OBJECTIVE_BY_KEY_RESULT_ID, noResultException);
}
public Objective findObjectiveByCheckInId(Long checkInId, AuthorizationUser authorizationUser,
- OkrResponseStatusException noResultException) {
+ OkrResponseStatusException noResultException) {
return findByAnyId(checkInId, authorizationUser, SELECT_OBJECTIVE_BY_CHECK_IN_ID, noResultException);
}
private Objective findByAnyId(Long id, AuthorizationUser authorizationUser, String queryString,
- OkrResponseStatusException noResultException) {
+ OkrResponseStatusException noResultException) {
checkIdNull(id);
String fullQueryString = queryString + authorizationCriteria.appendObjective(authorizationUser);
logger.debug("select objective by id={}: {}", id, fullQueryString);
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/OverviewPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/OverviewPersistenceService.java
index 197cdc5d9d..6d2a2800b6 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/OverviewPersistenceService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/OverviewPersistenceService.java
@@ -4,12 +4,11 @@
import ch.puzzle.okr.models.overview.Overview;
import jakarta.persistence.EntityManager;
import jakarta.persistence.TypedQuery;
+import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
-import java.util.List;
-
@Service
public class OverviewPersistenceService {
@@ -20,15 +19,15 @@ public class OverviewPersistenceService {
private final AuthorizationCriteria authorizationCriteria;
public OverviewPersistenceService(EntityManager entityManager,
- AuthorizationCriteria authorizationCriteria) {
+ AuthorizationCriteria authorizationCriteria) {
this.entityManager = entityManager;
this.authorizationCriteria = authorizationCriteria;
}
public List getFilteredOverview(Long quarterId, List teamIds, String objectiveQuery,
- AuthorizationUser authorizationUser) {
+ AuthorizationUser authorizationUser) {
String queryString = SELECT_OVERVIEW
- + authorizationCriteria.appendOverview(teamIds, objectiveQuery, authorizationUser);
+ + authorizationCriteria.appendOverview(teamIds, objectiveQuery, authorizationUser);
logger.debug("select overview by quarterId={} and teamIds={}: {}", quarterId, teamIds, queryString);
TypedQuery typedQuery = entityManager.createQuery(queryString, Overview.class);
typedQuery.setParameter("quarterId", quarterId);
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/PersistenceBase.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/PersistenceBase.java
index f10ea423fc..0ca16dc599 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/PersistenceBase.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/PersistenceBase.java
@@ -1,21 +1,20 @@
package ch.puzzle.okr.service.persistence;
+import static org.springframework.http.HttpStatus.BAD_REQUEST;
+import static org.springframework.http.HttpStatus.NOT_FOUND;
+
import ch.puzzle.okr.ErrorKey;
import ch.puzzle.okr.exception.OkrResponseStatusException;
+import java.util.List;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.stream.StreamSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.data.repository.CrudRepository;
import org.springframework.http.HttpStatus;
-import java.util.List;
-import java.util.Spliterator;
-import java.util.Spliterators;
-import java.util.stream.StreamSupport;
-
-import static org.springframework.http.HttpStatus.BAD_REQUEST;
-import static org.springframework.http.HttpStatus.NOT_FOUND;
-
/**
* @param
* the Type or entity of the repository
@@ -59,8 +58,9 @@ public T save(T model) throws OkrResponseStatusException {
return repository.save(model);
} catch (OptimisticLockingFailureException ex) {
logger.info("optimistic locking exception while saving {}", model, ex);
- throw new OkrResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY, ErrorKey.DATA_HAS_BEEN_UPDATED,
- getModelName());
+ throw new OkrResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY,
+ ErrorKey.DATA_HAS_BEEN_UPDATED,
+ getModelName());
}
}
@@ -76,6 +76,7 @@ public void deleteById(ID id) {
private List iteratorToList(Iterable iterable) {
return StreamSupport
- .stream(Spliterators.spliteratorUnknownSize(iterable.iterator(), Spliterator.ORDERED), false).toList();
+ .stream(Spliterators.spliteratorUnknownSize(iterable.iterator(), Spliterator.ORDERED), false)
+ .toList();
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/QuarterPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/QuarterPersistenceService.java
index 5646a15998..d9e4d938ab 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/QuarterPersistenceService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/QuarterPersistenceService.java
@@ -1,13 +1,12 @@
package ch.puzzle.okr.service.persistence;
+import static ch.puzzle.okr.Constants.QUARTER;
+
import ch.puzzle.okr.models.Quarter;
import ch.puzzle.okr.repository.QuarterRepository;
-import org.springframework.stereotype.Service;
-
import java.time.LocalDate;
import java.util.List;
-
-import static ch.puzzle.okr.Constants.QUARTER;
+import org.springframework.stereotype.Service;
@Service
public class QuarterPersistenceService extends PersistenceBase {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/TeamPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/TeamPersistenceService.java
index 533949d848..dd485164aa 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/TeamPersistenceService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/TeamPersistenceService.java
@@ -1,12 +1,11 @@
package ch.puzzle.okr.service.persistence;
+import static ch.puzzle.okr.Constants.TEAM;
+
import ch.puzzle.okr.models.Team;
import ch.puzzle.okr.repository.TeamRepository;
-import org.springframework.stereotype.Service;
-
import java.util.List;
-
-import static ch.puzzle.okr.Constants.TEAM;
+import org.springframework.stereotype.Service;
@Service
public class TeamPersistenceService extends PersistenceBase {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/UserPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/UserPersistenceService.java
index 6d5befc699..2cfa105ec8 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/UserPersistenceService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/UserPersistenceService.java
@@ -1,13 +1,12 @@
package ch.puzzle.okr.service.persistence;
+import static ch.puzzle.okr.Constants.USER;
+
import ch.puzzle.okr.models.User;
import ch.puzzle.okr.repository.UserRepository;
-import org.springframework.stereotype.Service;
-
import java.util.List;
import java.util.Optional;
-
-import static ch.puzzle.okr.Constants.USER;
+import org.springframework.stereotype.Service;
@Service
public class UserPersistenceService extends PersistenceBase {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/UserTeamPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/UserTeamPersistenceService.java
index 326feabe4d..8bb03cd758 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/persistence/UserTeamPersistenceService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/UserTeamPersistenceService.java
@@ -1,12 +1,11 @@
package ch.puzzle.okr.service.persistence;
+import static ch.puzzle.okr.Constants.USER_TEAM;
+
import ch.puzzle.okr.models.UserTeam;
import ch.puzzle.okr.repository.UserTeamRepository;
-import org.springframework.stereotype.Service;
-
import java.util.List;
-
-import static ch.puzzle.okr.Constants.USER_TEAM;
+import org.springframework.stereotype.Service;
@Service
public class UserTeamPersistenceService extends PersistenceBase {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/validation/ActionValidationService.java b/backend/src/main/java/ch/puzzle/okr/service/validation/ActionValidationService.java
index 4e591099ff..94b9af0e89 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/validation/ActionValidationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/validation/ActionValidationService.java
@@ -7,11 +7,10 @@
import ch.puzzle.okr.models.MessageKey;
import ch.puzzle.okr.repository.ActionRepository;
import ch.puzzle.okr.service.persistence.ActionPersistenceService;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Service;
-
import java.util.List;
import java.util.Objects;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Service;
@Service
public class ActionValidationService extends ValidationBase {
@@ -19,7 +18,7 @@ public class ActionValidationService extends ValidationBase {
+ extends
+ ValidationBase {
AlignmentValidationService(AlignmentPersistenceService persistenceService) {
super(persistenceService);
diff --git a/backend/src/main/java/ch/puzzle/okr/service/validation/CheckInValidationService.java b/backend/src/main/java/ch/puzzle/okr/service/validation/CheckInValidationService.java
index 87f3f14839..b1eedc6bc0 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/validation/CheckInValidationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/validation/CheckInValidationService.java
@@ -6,15 +6,15 @@
import ch.puzzle.okr.models.checkin.CheckIn;
import ch.puzzle.okr.repository.CheckInRepository;
import ch.puzzle.okr.service.persistence.CheckInPersistenceService;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Service;
-
import java.util.List;
import java.util.Objects;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Service;
@Service
public class CheckInValidationService
- extends ValidationBase {
+ extends
+ ValidationBase {
public CheckInValidationService(CheckInPersistenceService checkInPersistenceService) {
super(checkInPersistenceService);
@@ -39,8 +39,9 @@ public void validateOnUpdate(Long id, CheckIn model) {
private static void throwExceptionWhenKeyResultHasChanged(CheckIn checkIn, CheckIn savedCheckIn) {
if (!Objects.equals(checkIn.getKeyResult().getId(), savedCheckIn.getKeyResult().getId())) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.ATTRIBUTE_CANNOT_CHANGE,
- List.of(Constants.KEY_RESULT, Constants.CHECK_IN));
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ ErrorKey.ATTRIBUTE_CANNOT_CHANGE,
+ List.of(Constants.KEY_RESULT, Constants.CHECK_IN));
}
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/validation/CompletedValidationService.java b/backend/src/main/java/ch/puzzle/okr/service/validation/CompletedValidationService.java
index 702db8e4d7..178ef9019e 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/validation/CompletedValidationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/validation/CompletedValidationService.java
@@ -7,7 +7,8 @@
@Service
public class CompletedValidationService
- extends ValidationBase {
+ extends
+ ValidationBase {
public CompletedValidationService(CompletedPersistenceService completedPersistenceService) {
super(completedPersistenceService);
diff --git a/backend/src/main/java/ch/puzzle/okr/service/validation/KeyResultValidationService.java b/backend/src/main/java/ch/puzzle/okr/service/validation/KeyResultValidationService.java
index ea5a3b68e9..8f4795fb1c 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/validation/KeyResultValidationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/validation/KeyResultValidationService.java
@@ -6,15 +6,15 @@
import ch.puzzle.okr.models.keyresult.KeyResult;
import ch.puzzle.okr.repository.KeyResultRepository;
import ch.puzzle.okr.service.persistence.KeyResultPersistenceService;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Service;
-
import java.util.List;
import java.util.Objects;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Service;
@Service
public class KeyResultValidationService
- extends ValidationBase {
+ extends
+ ValidationBase {
public KeyResultValidationService(KeyResultPersistenceService keyResultPersistenceService) {
super(keyResultPersistenceService);
@@ -39,8 +39,9 @@ public void validateOnUpdate(Long id, KeyResult model) {
private static void throwExceptionWhenObjectiveHasChanged(KeyResult keyResult, KeyResult savedKeyResult) {
if (!Objects.equals(keyResult.getObjective().getId(), savedKeyResult.getObjective().getId())) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.ATTRIBUTE_CANNOT_CHANGE,
- List.of(Constants.OBJECTIVE, Constants.KEY_RESULT));
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ ErrorKey.ATTRIBUTE_CANNOT_CHANGE,
+ List.of(Constants.OBJECTIVE, Constants.KEY_RESULT));
}
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/validation/ObjectiveValidationService.java b/backend/src/main/java/ch/puzzle/okr/service/validation/ObjectiveValidationService.java
index 72f518c738..e2761c17c8 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/validation/ObjectiveValidationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/validation/ObjectiveValidationService.java
@@ -1,5 +1,8 @@
package ch.puzzle.okr.service.validation;
+import static ch.puzzle.okr.Constants.*;
+import static ch.puzzle.okr.service.validation.QuarterValidationService.throwExceptionWhenStartEndDateQuarterIsNull;
+
import ch.puzzle.okr.ErrorKey;
import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.models.Objective;
@@ -7,18 +10,15 @@
import ch.puzzle.okr.models.Team;
import ch.puzzle.okr.repository.ObjectiveRepository;
import ch.puzzle.okr.service.persistence.ObjectivePersistenceService;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Service;
-
import java.util.List;
import java.util.Objects;
-
-import static ch.puzzle.okr.Constants.*;
-import static ch.puzzle.okr.service.validation.QuarterValidationService.throwExceptionWhenStartEndDateQuarterIsNull;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Service;
@Service
public class ObjectiveValidationService
- extends ValidationBase {
+ extends
+ ValidationBase {
public ObjectiveValidationService(ObjectivePersistenceService objectivePersistenceService) {
super(objectivePersistenceService);
@@ -49,36 +49,40 @@ public void validateOnUpdate(Long id, Objective model) {
private void throwExceptionWhenModifiedByIsSet(Objective model) {
if (model.getModifiedBy() != null) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.ATTRIBUTE_SET_FORBIDDEN,
- List.of("ModifiedBy", model.getModifiedBy()));
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ ErrorKey.ATTRIBUTE_SET_FORBIDDEN,
+ List.of("ModifiedBy", model.getModifiedBy()));
}
}
private void throwExceptionWhenModifiedByIsNull(Objective model) {
if (model.getModifiedBy() == null) {
- throw new OkrResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, ErrorKey.ATTRIBUTE_NOT_SET,
- "modifiedBy");
+ throw new OkrResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR,
+ ErrorKey.ATTRIBUTE_NOT_SET,
+ "modifiedBy");
}
}
private void throwExceptionWhenTeamHasChanged(Team team, Team savedTeam) {
if (!Objects.equals(team, savedTeam)) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.ATTRIBUTE_CANNOT_CHANGE,
- List.of(TEAM, OBJECTIVE));
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ ErrorKey.ATTRIBUTE_CANNOT_CHANGE,
+ List.of(TEAM, OBJECTIVE));
}
}
private void throwExceptionWhenNotDraftInBacklogQuarter(Objective model) {
if (isInvalidBacklogObjective(model)) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.ATTRIBUTE_MUST_BE_DRAFT,
- List.of(OBJECTIVE, STATE_DRAFT, model.getState()));
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ ErrorKey.ATTRIBUTE_MUST_BE_DRAFT,
+ List.of(OBJECTIVE, STATE_DRAFT, model.getState()));
}
}
private boolean isInvalidBacklogObjective(Objective model) {
return model.getQuarter().getLabel().equals(BACK_LOG_QUARTER_LABEL) //
- && model.getQuarter().getStartDate() == null //
- && model.getQuarter().getEndDate() == null //
- && (model.getState() != State.DRAFT);
+ && model.getQuarter().getStartDate() == null //
+ && model.getQuarter().getEndDate() == null //
+ && (model.getState() != State.DRAFT);
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/validation/OverviewValidationService.java b/backend/src/main/java/ch/puzzle/okr/service/validation/OverviewValidationService.java
index af0013b52d..1ff7e18fdf 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/validation/OverviewValidationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/validation/OverviewValidationService.java
@@ -1,7 +1,7 @@
package ch.puzzle.okr.service.validation;
-import org.springframework.stereotype.Service;
import java.util.List;
+import org.springframework.stereotype.Service;
@Service
public class OverviewValidationService {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/validation/QuarterValidationService.java b/backend/src/main/java/ch/puzzle/okr/service/validation/QuarterValidationService.java
index baa9df7252..4f1d47787b 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/validation/QuarterValidationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/validation/QuarterValidationService.java
@@ -1,20 +1,20 @@
package ch.puzzle.okr.service.validation;
+import static ch.puzzle.okr.Constants.BACK_LOG_QUARTER_LABEL;
+
import ch.puzzle.okr.ErrorKey;
import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.models.Quarter;
import ch.puzzle.okr.repository.QuarterRepository;
import ch.puzzle.okr.service.persistence.QuarterPersistenceService;
+import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
-import java.util.List;
-
-import static ch.puzzle.okr.Constants.BACK_LOG_QUARTER_LABEL;
-
@Service
public class QuarterValidationService
- extends ValidationBase {
+ extends
+ ValidationBase {
public QuarterValidationService(QuarterPersistenceService quarterPersistenceService) {
super(quarterPersistenceService);
@@ -33,11 +33,13 @@ public void validateOnUpdate(Long id, Quarter model) {
public static void throwExceptionWhenStartEndDateQuarterIsNull(Quarter model) {
if (!model.getLabel().equals(BACK_LOG_QUARTER_LABEL)) {
if (model.getStartDate() == null) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.ATTRIBUTE_NULL,
- List.of("StartDate", model.getLabel()));
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ ErrorKey.ATTRIBUTE_NULL,
+ List.of("StartDate", model.getLabel()));
} else if (model.getEndDate() == null) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.ATTRIBUTE_NULL,
- List.of("EndDate", model.getLabel()));
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ ErrorKey.ATTRIBUTE_NULL,
+ List.of("EndDate", model.getLabel()));
}
}
@@ -45,11 +47,13 @@ public static void throwExceptionWhenStartEndDateQuarterIsNull(Quarter model) {
public void validateOnGeneration(Quarter quarter) {
if (quarter.getStartDate() == null) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.ATTRIBUTE_NULL,
- List.of("StartDate", quarter.getLabel()));
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ ErrorKey.ATTRIBUTE_NULL,
+ List.of("StartDate", quarter.getLabel()));
} else if (quarter.getEndDate() == null) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.ATTRIBUTE_NULL,
- List.of("EndDate", quarter.getLabel()));
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ ErrorKey.ATTRIBUTE_NULL,
+ List.of("EndDate", quarter.getLabel()));
}
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/validation/TeamValidationService.java b/backend/src/main/java/ch/puzzle/okr/service/validation/TeamValidationService.java
index 8b08e1d4a2..560d61d2fe 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/validation/TeamValidationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/validation/TeamValidationService.java
@@ -1,17 +1,16 @@
package ch.puzzle.okr.service.validation;
+import static ch.puzzle.okr.Constants.TEAM;
+
import ch.puzzle.okr.ErrorKey;
import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.models.Team;
import ch.puzzle.okr.repository.TeamRepository;
import ch.puzzle.okr.service.persistence.TeamPersistenceService;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Service;
-
import java.util.List;
import java.util.Objects;
-
-import static ch.puzzle.okr.Constants.TEAM;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Service;
@Service
public class TeamValidationService extends ValidationBase {
@@ -39,11 +38,16 @@ public void validateOnUpdate(Long id, Team model) {
}
private void checkIfTeamWithNameAlreadyExists(String name, Long id) {
- List filteredTeam = this.getPersistenceService().findTeamsByName(name).stream()
- .filter(team -> !Objects.equals(team.getId(), id)).toList();
+ List filteredTeam = this
+ .getPersistenceService()
+ .findTeamsByName(name)
+ .stream()
+ .filter(team -> !Objects.equals(team.getId(), id))
+ .toList();
if (!filteredTeam.isEmpty()) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.ALREADY_EXISTS_SAME_NAME,
- List.of(TEAM, name));
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ ErrorKey.ALREADY_EXISTS_SAME_NAME,
+ List.of(TEAM, name));
}
}
}
diff --git a/backend/src/main/java/ch/puzzle/okr/service/validation/UserValidationService.java b/backend/src/main/java/ch/puzzle/okr/service/validation/UserValidationService.java
index 487530aa3e..b2ed76eabf 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/validation/UserValidationService.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/validation/UserValidationService.java
@@ -1,5 +1,7 @@
package ch.puzzle.okr.service.validation;
+import static org.springframework.http.HttpStatus.BAD_REQUEST;
+
import ch.puzzle.okr.ErrorKey;
import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.models.User;
@@ -10,8 +12,6 @@
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.stereotype.Service;
-import static org.springframework.http.HttpStatus.BAD_REQUEST;
-
@Service
public class UserValidationService extends ValidationBase {
diff --git a/backend/src/main/java/ch/puzzle/okr/service/validation/ValidationBase.java b/backend/src/main/java/ch/puzzle/okr/service/validation/ValidationBase.java
index e18cd9e982..e93ada1ba1 100644
--- a/backend/src/main/java/ch/puzzle/okr/service/validation/ValidationBase.java
+++ b/backend/src/main/java/ch/puzzle/okr/service/validation/ValidationBase.java
@@ -9,14 +9,13 @@
import jakarta.validation.Validation;
import jakarta.validation.Validator;
import jakarta.validation.ValidatorFactory;
-import org.springframework.http.HttpStatus;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.springframework.http.HttpStatus;
/**
* @param
@@ -62,29 +61,33 @@ public T doesEntityExist(ID id) {
public void throwExceptionWhenModelIsNull(T model) {
if (model == null) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.MODEL_NULL,
- persistenceService.getModelName());
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ ErrorKey.MODEL_NULL,
+ persistenceService.getModelName());
}
}
public void throwExceptionWhenIdIsNull(ID id) {
if (id == null) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.ATTRIBUTE_NULL,
- List.of("ID", persistenceService.getModelName()));
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ ErrorKey.ATTRIBUTE_NULL,
+ List.of("ID", persistenceService.getModelName()));
}
}
protected void throwExceptionWhenIdIsNotNull(ID id) {
if (id != null) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, MessageKey.ATTRIBUTE_NOT_NULL,
- List.of("ID", persistenceService.getModelName()));
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ MessageKey.ATTRIBUTE_NOT_NULL,
+ List.of("ID", persistenceService.getModelName()));
}
}
protected void throwExceptionWhenIdHasChanged(ID id, ID modelId) {
if (!Objects.equals(id, modelId)) {
- throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.ATTRIBUTE_CHANGED,
- List.of("ID", id, modelId));
+ throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
+ ErrorKey.ATTRIBUTE_CHANGED,
+ List.of("ID", id, modelId));
}
}
@@ -101,14 +104,16 @@ private void processViolations(Set> violations) {
}
private List createErrorDtos(Set> violations) {
- return violations.stream() //
+ return violations
+ .stream() //
.map(e -> { //
String path = e.getPropertyPath().toString(); //
List