diff --git a/buisnesslogic/src/main/java/com/plannaplan/entities/Commision.java b/buisnesslogic/src/main/java/com/plannaplan/entities/Commision.java index 36e3585..7ebf890 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/entities/Commision.java +++ b/buisnesslogic/src/main/java/com/plannaplan/entities/Commision.java @@ -13,7 +13,7 @@ import javax.persistence.OneToMany; import javax.persistence.OneToOne; /** - * Entity of Commision grouping of state associated about commison and owner_id + * Entity of Commision grouping of state associated about commison and owner_id */ @Entity @@ -24,6 +24,9 @@ public class Commision { @OneToOne @JoinColumn(name = "owner_id") private User commisionOwner; + @OneToOne + @JoinColumn(name = "commiter_id") + private User commisionCommiter; private Timestamp commisionDate; @OneToMany(mappedBy = "commision", fetch = FetchType.EAGER) @@ -37,37 +40,62 @@ public class Commision { public Commision(User user) { this.commisionDate = new Timestamp(System.currentTimeMillis()); this.commisionOwner = user; + this.commisionCommiter = user; + } + + /** + * + * @param user user whose shedule is being commited + * @param commiter user that commited new schedule + */ + public Commision(User user, User commiter) { + this(user); + this.commisionCommiter = commiter; } public Commision() { } /** - * Id getter - * @return id id of commision + * Id getter + * + * @return id id of commision */ public Long getId() { return this.id; } /** - * CommisionDate getter - * @return commisionDate + * CommisionDate getter + * + * @return commisionDate */ public Timestamp getCommisionDate() { return commisionDate; } /** - * User of given commision getter - * @return User commisionOwner + * User of given commision getter + * + * @return User commisionOwner */ public User getCommisionOwner() { return commisionOwner; } + /** + * @return User entity that created commision (can be owner or deanery user) + */ + public User getCommisionCommiter() { + if (commisionCommiter == null) { + return commisionOwner; + } + return commisionCommiter; + } + /** * Assigments getter + * * @return List of assignments */ public List getAssignments() { diff --git a/restservice/src/main/java/com/plannaplan/controllers/CommisionController.java b/restservice/src/main/java/com/plannaplan/controllers/CommisionController.java index 2388f12..2f1053a 100755 --- a/restservice/src/main/java/com/plannaplan/controllers/CommisionController.java +++ b/restservice/src/main/java/com/plannaplan/controllers/CommisionController.java @@ -82,7 +82,7 @@ public class CommisionController extends TokenBasedController { Assert.isTrue(!notExistingGroup.isPresent(), "Group " + notExistingGroup.orElse(Long.MIN_VALUE).toString() + "doesn't exist"); - final Commision com = new Commision(user); + final Commision com = new Commision(user, asker); this.commisionService.save(com); groups.stream().forEach((groupId) -> { diff --git a/restservice/src/main/java/com/plannaplan/responses/models/CommisionResponse.java b/restservice/src/main/java/com/plannaplan/responses/models/CommisionResponse.java index e995e27..9c91e1e 100755 --- a/restservice/src/main/java/com/plannaplan/responses/models/CommisionResponse.java +++ b/restservice/src/main/java/com/plannaplan/responses/models/CommisionResponse.java @@ -10,12 +10,29 @@ public class CommisionResponse { @ApiModelProperty(value = "ID created by database") private Long id; + @ApiModelProperty(value = "ID of user that commision belongs to") + private UserResponse owner; + + @ApiModelProperty(value = "ID of user that created commision") + private UserResponse commiter; + @ApiModelProperty(value = "Timestamp where the user commit the commision") private String commisionDate; public CommisionResponse(Commision commision) { this.id = commision.getId(); this.commisionDate = commision.getCommisionDate().toString(); + this.owner = commision.getCommisionOwner() != null ? new UserResponse(commision.getCommisionOwner()) : null; + this.commiter = commision.getCommisionCommiter() != null ? new UserResponse(commision.getCommisionCommiter()) + : null; + } + + public UserResponse getCommiter() { + return commiter; + } + + public UserResponse getOwner() { + return owner; } public String getCommisionDate() {