Skip to content

Commit

Permalink
Merge pull request #880 from puzzle/IPA-Lias
Browse files Browse the repository at this point in the history
IPA Lias
  • Loading branch information
lkleisa authored Jun 21, 2024
2 parents 5b6a687 + 3989df2 commit 254422a
Show file tree
Hide file tree
Showing 51 changed files with 2,615 additions and 125 deletions.
3 changes: 3 additions & 0 deletions backend/src/main/java/ch/puzzle/okr/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ private Constants() {
public static final String KEY_RESULT_TYPE_METRIC = "metric";
public static final String KEY_RESULT_TYPE_ORDINAL = "ordinal";
public static final String OBJECTIVE = "Objective";
public static final String OBJECTIVE_LOWERCASE = "objective";
public static final String STATE_DRAFT = "Draft";
public static final String KEY_RESULT = "KeyResult";
public static final String CHECK_IN = "Check-in";
public static final String ACTION = "Action";
public static final String ALIGNMENT = "Alignment";
public static final String ALIGNMENT_VIEW = "AlignmentView";
public static final String ALIGNED_OBJECTIVE_ID = "alignedObjectiveId";
public static final String COMPLETED = "Completed";
public static final String ORGANISATION = "Organisation";
public static final String QUARTER = "Quarter";
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/java/ch/puzzle/okr/ErrorKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ 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, NOT_LINK_YOURSELF, NOT_LINK_IN_SAME_TEAM, ALIGNMENT_ALREADY_EXISTS
TOKEN_NULL, NOT_LINK_YOURSELF, NOT_LINK_IN_SAME_TEAM, ALIGNMENT_ALREADY_EXISTS, ALIGNMENT_DATA_FAIL
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package ch.puzzle.okr.controller;

import ch.puzzle.okr.dto.alignment.AlignmentLists;
import ch.puzzle.okr.service.business.AlignmentBusinessService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
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.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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("api/v2/alignments")
public class AlignmentController {
private final AlignmentBusinessService alignmentBusinessService;

public AlignmentController(AlignmentBusinessService alignmentBusinessService) {
this.alignmentBusinessService = alignmentBusinessService;
}

@Operation(summary = "Get AlignmentLists from filter", description = "Get a list of AlignmentObjects with all AlignmentConnections, which match current quarter, team and objective filter")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Returned AlignmentLists, which match current filters", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = AlignmentLists.class)) }),
@ApiResponse(responseCode = "400", description = "Can't generate AlignmentLists from current filters", content = @Content) })
@GetMapping("/alignmentLists")
public ResponseEntity<AlignmentLists> getAlignments(
@RequestParam(required = false, defaultValue = "", name = "teamFilter") List<Long> teamFilter,
@RequestParam(required = false, defaultValue = "", name = "quarterFilter") Long quarterFilter,
@RequestParam(required = false, defaultValue = "", name = "objectiveQuery") String objectiveQuery) {
return ResponseEntity.status(HttpStatus.OK)
.body(alignmentBusinessService.getAlignmentListsByFilters(quarterFilter, teamFilter, objectiveQuery));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

package ch.puzzle.okr.dto.alignment;

public record AlignmentConnectionDto(Long alignedObjectiveId, Long targetObjectiveId, Long targetKeyResultId) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ch.puzzle.okr.dto.alignment;

import java.util.List;

public record AlignmentLists(List<AlignmentObjectDto> alignmentObjectDtoList,
List<AlignmentConnectionDto> alignmentConnectionDtoList) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ch.puzzle.okr.dto.alignment;

public record AlignmentObjectDto(Long objectId, String objectTitle, String objectTeamName, String objectState,
String objectType) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
package ch.puzzle.okr.models.alignment;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import org.hibernate.annotations.Immutable;

import java.util.Objects;

@Entity
@Immutable
public class AlignmentView {

@Id
private String uniqueId;
private Long id;
private String title;
private Long teamId;
private String teamName;
private Long quarterId;
private String state;
private String objectType;
private String connectionRole;
private Long counterpartId;
private String counterpartType;

public AlignmentView() {
}

private AlignmentView(Builder builder) {
setUniqueId(builder.uniqueId);
setId(builder.id);
setTitle(builder.title);
setTeamId(builder.teamId);
setTeamName(builder.teamName);
setQuarterId(builder.quarterId);
setState(builder.state);
setObjectType(builder.objectType);
setConnectionRole(builder.connectionRole);
setCounterpartId(builder.counterpartId);
setCounterpartType(builder.counterpartType);
}

public void setUniqueId(String uniqueId) {
this.uniqueId = uniqueId;
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public Long getTeamId() {
return teamId;
}

public void setTeamId(Long teamId) {
this.teamId = teamId;
}

public String getTeamName() {
return teamName;
}

public void setTeamName(String teamName) {
this.teamName = teamName;
}

public Long getQuarterId() {
return quarterId;
}

public void setQuarterId(Long quarterId) {
this.quarterId = quarterId;
}

public String getState() {
return state;
}

public void setState(String state) {
this.state = state;
}

public String getObjectType() {
return objectType;
}

public void setObjectType(String objectType) {
this.objectType = objectType;
}

public String getConnectionRole() {
return connectionRole;
}

public void setConnectionRole(String connectionItem) {
this.connectionRole = connectionItem;
}

public Long getCounterpartId() {
return counterpartId;
}

public void setCounterpartId(Long refId) {
this.counterpartId = refId;
}

public String getCounterpartType() {
return counterpartType;
}

public void setCounterpartType(String refType) {
this.counterpartType = refType;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
AlignmentView that = (AlignmentView) o;
return Objects.equals(uniqueId, that.uniqueId) && Objects.equals(id, that.id)
&& Objects.equals(title, that.title) && Objects.equals(teamId, that.teamId)
&& Objects.equals(teamName, that.teamName) && Objects.equals(quarterId, that.quarterId)
&& Objects.equals(state, that.state) && Objects.equals(objectType, that.objectType)
&& Objects.equals(connectionRole, that.connectionRole)
&& Objects.equals(counterpartId, that.counterpartId)
&& Objects.equals(counterpartType, that.counterpartType);
}

@Override
public int hashCode() {
return Objects.hash(uniqueId, id, title, teamId, teamName, quarterId, state, objectType, connectionRole,
counterpartId, counterpartType);
}

@Override
public String toString() {
return "AlignmentView{" + "uniqueId='" + uniqueId + '\'' + ", id=" + id + ", title='" + title + '\''
+ ", teamId=" + teamId + ", teamName='" + teamName + '\'' + ", quarterId=" + quarterId + ", state='"
+ state + '\'' + ", objectType='" + objectType + '\'' + ", connectionItem='" + connectionRole + '\''
+ ", refId=" + counterpartId + ", refType='" + counterpartType + '\'' + '}';
}

public static final class Builder {
private String uniqueId;
private Long id;
private String title;
private Long teamId;
private String teamName;
private Long quarterId;
private String state;
private String objectType;
private String connectionRole;
private Long counterpartId;
private String counterpartType;

private Builder() {
}

public static AlignmentView.Builder builder() {
return new AlignmentView.Builder();
}

public Builder withUniqueId(String val) {
uniqueId = val;
return this;
}

public Builder withId(Long val) {
id = val;
return this;
}

public Builder withTitle(String val) {
title = val;
return this;
}

public Builder withTeamId(Long val) {
teamId = val;
return this;
}

public Builder withTeamName(String val) {
teamName = val;
return this;
}

public Builder withQuarterId(Long val) {
quarterId = val;
return this;
}

public Builder withState(String val) {
state = val;
return this;
}

public Builder withObjectType(String val) {
objectType = val;
return this;
}

public Builder withConnectionRole(String val) {
connectionRole = val;
return this;
}

public Builder withCounterpartId(Long val) {
counterpartId = val;
return this;
}

public Builder withCounterpartType(String val) {
counterpartType = val;
return this;
}

public AlignmentView build() {
return new AlignmentView(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ch.puzzle.okr.repository;

import ch.puzzle.okr.models.alignment.AlignmentView;
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 AlignmentViewRepository extends CrudRepository<AlignmentView, Long> {

@Query(value = "SELECT * FROM alignment_view where quarter_id = :quarterId ", nativeQuery = true)
List<AlignmentView> getAlignmentViewByQuarterId(@Param("quarterId") Long quarterId);
}
Loading

0 comments on commit 254422a

Please sign in to comment.