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 a0541add67..25d6a87c5b 100644 --- a/backend/src/main/java/ch/puzzle/okr/mapper/ObjectiveMapper.java +++ b/backend/src/main/java/ch/puzzle/okr/mapper/ObjectiveMapper.java @@ -19,6 +19,8 @@ public ObjectiveMapper(TeamBusinessService teamBusinessService, QuarterBusinessS this.quarterBusinessService = quarterBusinessService; } + // TODO: Adjust Unit Tests of ObjectiveMapper after merge of multitenancy-main + public ObjectiveDto toDto(Objective objective) { return new ObjectiveDto(objective.getId(), objective.getVersion(), objective.getTitle(), objective.getTeam().getId(), objective.getQuarter().getId(), objective.getQuarter().getLabel(), 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 acbbc438cf..08493480be 100644 --- a/backend/src/main/java/ch/puzzle/okr/models/Objective.java +++ b/backend/src/main/java/ch/puzzle/okr/models/Objective.java @@ -173,10 +173,10 @@ public void setWriteable(boolean writeable) { @Override public String toString() { - return "Objective{" + "id=" + id + ", version=" + version + ", title='" + title + '\'' + ", state=" + state - + ", description='" + description + '\'' + ", team=" + team + ", quarter=" + quarter + ", createdBy=" - + createdBy + ", createdOn=" + createdOn + ", modifiedOn=" + modifiedOn + ", modifiedBy=" + modifiedBy - + ", archived=" + archived + ", writeable=" + writeable + '}'; + return "Objective{" + "id=" + id + ", version=" + version + ", title='" + title + '\'' + ", createdBy=" + + createdBy + ", team=" + team + ", quarter=" + quarter + ", description='" + description + '\'' + + ", modifiedOn=" + modifiedOn + ", state=" + state + ", createdOn=" + createdOn + ", modifiedBy=" + + modifiedBy + ", archived=" + archived + ", writeable=" + writeable + '\'' + '}'; } @Override 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 4baa5b2dc9..9955505137 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 @@ -35,14 +35,8 @@ public List getFilteredOverview(Long quarterId, List teamIds, St return List.of(); } - List overviews; - if (quarterId == 998) { - overviews = overviewPersistenceService.getArchiveOverview(teamIds, objectiveQuery, authorizationUser); - overviews.forEach(overview -> overview.setWriteable(false)); - } else { - 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/persistence/OverviewPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/OverviewPersistenceService.java index 5f4cae8798..116a717701 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 @@ -28,21 +28,16 @@ public OverviewPersistenceService(EntityManager entityManager, public List getFilteredOverview(Long quarterId, List teamIds, String objectiveQuery, AuthorizationUser authorizationUser) { - String queryString = SELECT_OVERVIEW + boolean isArchive = quarterId == 998; + String queryString = (isArchive ? SELECT_ARCHIVE : SELECT_OVERVIEW) + 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); - authorizationCriteria.setParameters(typedQuery, teamIds, objectiveQuery, authorizationUser); - return typedQuery.getResultList(); - } - - public List getArchiveOverview(List teamIds, String objectiveQuery, - AuthorizationUser authorizationUser) { - String queryString = SELECT_ARCHIVE - + authorizationCriteria.appendOverview(teamIds, objectiveQuery, authorizationUser); - logger.debug("select overview by teamIds={}: {}", teamIds, queryString); TypedQuery typedQuery = entityManager.createQuery(queryString, Overview.class); + if (isArchive) { + logger.debug("select overview by teamIds={}: {}", teamIds, queryString); + } else { + logger.debug("select overview by quarterId={} and teamIds={}: {}", quarterId, teamIds, queryString); + typedQuery.setParameter("quarterId", quarterId); + } authorizationCriteria.setParameters(typedQuery, teamIds, objectiveQuery, authorizationUser); return typedQuery.getResultList(); }