Skip to content

Commit

Permalink
Added enrollment description field #20
Browse files Browse the repository at this point in the history
  • Loading branch information
SMore-Napi committed Jan 4, 2022
1 parent 0b551d1 commit 57f11a2
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class EnrollmentDTO {
private Long enrollmentId;
private Long enrollerId;
private Long cardId;
private String description;
private List<String> sessionFormat;
private List<String> sessionType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ public class MyStudentDTO {
private String studentPicture;
private Long cardId;
private String subject;
private Double rating;
private Integer countVoted;
private String description;
private Double cardRating;
private Integer cardCountVoted;
private String cardDescription;
private boolean hidden;
private String enrollmentDescription;
private List<String> sessionFormat;
private List<String> sessionType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class CardEnroll {
private Long cardId;
private Long userId;
private Long statusId;
private String description;
private Timestamp creationDate;
private Timestamp lastUpdate;
private Card cardByCardId;
Expand All @@ -27,11 +28,12 @@ public class CardEnroll {
private Collection<CardEnrollSessionFormat> cardEnrollSessionFormatsByCardId;
private Collection<CardEnrollSessionType> cardEnrollSessionTypesByCardId;

public CardEnroll(final Long cardId, final Long userId, final Long statusId, final Card cardByCardId, final User userByUserId,
public CardEnroll(final Long cardId, final Long userId, final Long statusId, final String description, final Card cardByCardId, final User userByUserId,
final EnrollmentStatus enrollmentStatusByStatusId) {
this.cardId = cardId;
this.userId = userId;
this.statusId = statusId;
this.description = description;
this.cardByCardId = cardByCardId;
this.userByUserId = userByUserId;
this.enrollmentStatusByStatusId = enrollmentStatusByStatusId;
Expand Down Expand Up @@ -78,6 +80,16 @@ public void setStatusId(final Long statusId) {
this.statusId = statusId;
}

@Basic
@Column(name = "description", length = 1024)
public String getDescription() {
return description;
}

public void setDescription(final String description) {
this.description = description;
}

@Basic
@CreationTimestamp
@Column(name = "creation_date", insertable = false, updatable = false)
Expand Down Expand Up @@ -108,23 +120,26 @@ public boolean equals(final Object object) {
if (object == null || getClass() != object.getClass()) {
return false;
}
final CardEnroll that = (CardEnroll) object;
if (!Objects.equals(cardEnrollId, that.cardEnrollId)) {
final CardEnroll cardEnroll = (CardEnroll) object;
if (!Objects.equals(cardEnrollId, cardEnroll.cardEnrollId)) {
return false;
}
if (!Objects.equals(cardId, cardEnroll.cardId)) {
return false;
}
if (!Objects.equals(cardId, that.cardId)) {
if (!Objects.equals(userId, cardEnroll.userId)) {
return false;
}
if (!Objects.equals(userId, that.userId)) {
if (!Objects.equals(statusId, cardEnroll.statusId)) {
return false;
}
if (!Objects.equals(statusId, that.statusId)) {
if (!Objects.equals(description, cardEnroll.description)) {
return false;
}
if (!Objects.equals(creationDate, that.creationDate)) {
if (!Objects.equals(creationDate, cardEnroll.creationDate)) {
return false;
}
return Objects.equals(lastUpdate, that.lastUpdate);
return Objects.equals(lastUpdate, cardEnroll.lastUpdate);
}

@Override
Expand All @@ -133,6 +148,7 @@ public int hashCode() {
result = 31 * result + (cardId == null ? 0 : cardId.hashCode());
result = 31 * result + (userId == null ? 0 : userId.hashCode());
result = 31 * result + (statusId == null ? 0 : statusId.hashCode());
result = 31 * result + (description == null ? 0 : description.hashCode());
result = 31 * result + (creationDate == null ? 0 : creationDate.hashCode());
result = 31 * result + (lastUpdate == null ? 0 : lastUpdate.hashCode());
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public void setEmail(final String email) {
this.email = email;
}


@Basic
@Column(name = "picture", nullable = false, length = 512)
public String getPicture() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ public EnrollmentDTO postCardEnroll(final EnrollmentDTO enrollmentDTO) {
final CardEnroll cardEnroll = this.saveCardEnroll(
card,
userOptional.get(),
enrollmentDTO.getDescription(),
enrollmentStatusRepository.findEnrollmentStatusByStatus(REQUESTED)
);
this.saveCardEnrollSessionFormat(cardEnroll, sessionFormats);
this.saveCardEnrollSessionType(cardEnroll, sessionTypes);
return new EnrollmentDTO(cardEnroll.getCardEnrollId(), enrollerId, cardId, sessionFormats, sessionTypes);
return new EnrollmentDTO(cardEnroll.getCardEnrollId(), enrollerId, cardId, cardEnroll.getDescription(), sessionFormats, sessionTypes);
}
}
}
Expand Down Expand Up @@ -127,12 +128,13 @@ private boolean isUniquePair(final Long enrollerId, final Long cardId) {
return true;
}

private CardEnroll saveCardEnroll(final Card card, final User tutor, final EnrollmentStatus enrollmentStatus) {
private CardEnroll saveCardEnroll(final Card card, final User tutor, final String description, final EnrollmentStatus enrollmentStatus) {
return cardEnrollRepository.save(
new CardEnroll(
card.getCardId(),
tutor.getUserId(),
enrollmentStatus.getStatusId(),
description,
card,
tutor,
enrollmentStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private MyStudentDTO convertEnrollmentDTOToEnrollmentInfoDTO(EnrollmentDTO enrol
card.getCountVoted(),
card.getDescription(),
card.isHidden(),
enrollmentDTO.getDescription(),
enrollmentDTO.getSessionFormat(),
enrollmentDTO.getSessionType()
);
Expand All @@ -102,6 +103,7 @@ private List<EnrollmentDTO> getStudentsListByStatusId(final User user, final Lon
cardEnroll.getCardEnrollId(),
cardEnroll.getUserId(),
cardEnroll.getCardId(),
cardEnroll.getDescription(),
new CardEnrollSessionFormatConverter(cardEnroll.getCardEnrollSessionFormatsByCardId()).stringList(),
new CardEnrollSessionTypeConverter(cardEnroll.getCardEnrollSessionTypesByCardId()).stringList()
));
Expand All @@ -120,6 +122,7 @@ private List<EnrollmentDTO> getStudentsToWhomRequested(final User tutor, final L
cardEnroll.getCardEnrollId(),
request.getStudentId(),
card.getCardId(),
cardEnroll.getDescription(),
new CardSessionFormatConverter(card.getCardSessionFormatsByCardId()).stringList(),
new CardSessionTypeConverter(card.getCardSessionTypesByCardId()).stringList()
));
Expand Down

0 comments on commit 57f11a2

Please sign in to comment.