Skip to content

Commit

Permalink
Moved description from earned_certificate to certificate and renamed …
Browse files Browse the repository at this point in the history
…certificate_image_url to validation_url.
  • Loading branch information
ocielliottc committed Sep 27, 2024
1 parent 4eb5d5b commit 86913d5
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public class Certification {
@Schema(description = "name of the certification")
private String name;

@NotBlank
@Column(name = "description")
@TypeDef(type = DataType.STRING)
@Schema(description = "description of the certification")
private String description;

@Nullable
@Column(name = "badge_url")
@Schema(description = "url of the badge")
Expand All @@ -47,18 +53,19 @@ public class Certification {
public Certification() {
}

Certification(UUID id, String name, @Nullable String badgeUrl, boolean active) {
Certification(UUID id, String name, @NotBlank String description, @Nullable String badgeUrl, boolean active) {
this.id = id;
this.name = name;
this.description = description;
this.badgeUrl = badgeUrl;
this.active = active;
}

public Certification(String name, @Nullable String badgeUrl) {
this(null, name, badgeUrl, true);
public Certification(String name, @NotBlank String description, @Nullable String badgeUrl) {
this(null, name, description, badgeUrl, true);
}

public Certification(String name, String badgeUrl, boolean active) {
this(null, name, badgeUrl, active);
public Certification(String name, String description, String badgeUrl, boolean active) {
this(null, name, description, badgeUrl, active);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ List<Certification> findAll(@Nullable Boolean includeInactive) {
Certification create(@Body @Valid CertificationDTO certification) {
return certificationService.saveCertification(new Certification(
certification.getName(),
certification.getDescription(),
certification.getBadgeUrl(),
!Boolean.FALSE.equals(certification.getActive())
));
Expand All @@ -72,6 +73,7 @@ Certification update(@NotNull UUID id, @Body @Valid CertificationDTO certificati
return certificationService.updateCertification(new Certification(
id,
certification.getName(),
certification.getDescription(),
certification.getBadgeUrl(),
!Boolean.FALSE.equals(certification.getActive())
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.micronaut.core.annotation.Introspected;
import io.micronaut.core.annotation.Nullable;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -18,6 +19,10 @@ class CertificationDTO {
@Schema(description = "name of the certification")
private String name;

@NotBlank
@Schema(description = "description of the certification")
private String description;

@Nullable
@Schema(description = "badge url of the certification")
private String badgeUrl;
Expand All @@ -26,7 +31,7 @@ class CertificationDTO {
@Schema(description = "whether the Certification is active")
private Boolean active;

CertificationDTO(String name, String badgeUrl) {
this(name, badgeUrl, true);
CertificationDTO(String name, String description, String badgeUrl) {
this(name, description, badgeUrl, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
Expand Down Expand Up @@ -47,12 +46,6 @@ public class EarnedCertification {
@Schema(description = "id of the certification")
private UUID certificationId;

@NotBlank
@Column(name = "description")
@TypeDef(type = DataType.STRING)
@Schema(description = "description of the certification earned")
private String description;

@NotNull
@Column(name = "earned_date")
@TypeDef(type = DataType.DATE, converter = LocalDateConverter.class)
Expand All @@ -68,26 +61,25 @@ public class EarnedCertification {
private LocalDate expirationDate;

@Nullable
@Column(name = "certificate_image_url")
@Column(name = "validation_url")
@TypeDef(type = DataType.STRING)
@Schema(description = "optionally the url of the certificate image")
private String certificateImageUrl;
@Schema(description = "optionally the url of the validation")
private String validationUrl;

public EarnedCertification() {
}

public EarnedCertification(UUID memberId, UUID certificationId, String description, LocalDate earnedDate, LocalDate expirationDate, String certificateImageUrl) {
this(null, memberId, certificationId, description, earnedDate, expirationDate, certificateImageUrl);
public EarnedCertification(UUID memberId, UUID certificationId, LocalDate earnedDate, LocalDate expirationDate, String validationUrl) {
this(null, memberId, certificationId, earnedDate, expirationDate, validationUrl);
}

public EarnedCertification(UUID id, UUID memberId, UUID certificationId, String description, LocalDate earnedDate, LocalDate expirationDate, String certificateImageUrl) {
public EarnedCertification(UUID id, UUID memberId, UUID certificationId, LocalDate earnedDate, LocalDate expirationDate, String validationUrl) {
this.id = id;
this.memberId = memberId;
this.certificationId = certificationId;
this.description = description;
this.earnedDate = earnedDate;
this.expirationDate = expirationDate;
this.certificateImageUrl = certificateImageUrl;
this.validationUrl = validationUrl;
}

EarnedCertification withCertification(@NonNull UUID certificationId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ EarnedCertification create(@Body @Valid EarnedCertificationDTO certification, Ht
new EarnedCertification(
certification.getMemberId(),
certification.getCertificationId(),
certification.getDescription(),
certification.getEarnedDate(),
certification.getExpirationDate(),
certification.getCertificateImageUrl()
certification.getValidationUrl()
)
);
}
Expand All @@ -86,10 +85,9 @@ EarnedCertification update(@NotNull UUID id, @Body @Valid EarnedCertificationDTO
id,
certification.getMemberId(),
certification.getCertificationId(),
certification.getDescription(),
certification.getEarnedDate(),
certification.getExpirationDate(),
certification.getCertificateImageUrl()
certification.getValidationUrl()
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.micronaut.core.annotation.Introspected;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -25,21 +24,17 @@ class EarnedCertificationDTO {
@Schema(description = "id of the certification")
private UUID certificationId;

@NotBlank
@Schema(description = "description of the certification earned")
private String description;

@NotNull
@Schema(description = "when the certification was earned")
private LocalDate earnedDate;

@Schema(description = "optionally when the certification expires")
private LocalDate expirationDate;

@Schema(description = "optionally the image of the certification")
private String certificateImageUrl;
@Schema(description = "optionally the validation URL of the certification")
private String validationUrl;

EarnedCertificationDTO(UUID memberId, UUID certificationId, String description, LocalDate earnedDate) {
this(memberId, certificationId, description, earnedDate, null, null);
EarnedCertificationDTO(UUID memberId, UUID certificationId, LocalDate earnedDate) {
this(memberId, certificationId, earnedDate, null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface EarnedCertificationRepository extends CrudRepository<EarnedCert
FROM earned_certification AS earned
JOIN certification AS cert USING(certification_id)
WHERE cert.is_active = TRUE OR :includeDeactivated = TRUE
ORDER BY earned.earned_date DESC, earned.description""", nativeQuery = true)
ORDER BY earned.earned_date DESC""", nativeQuery = true)
List<EarnedCertification> findAllOrderByEarnedDateDesc(boolean includeDeactivated);

@Query(value = """
Expand All @@ -30,7 +30,7 @@ JOIN certification AS cert USING(certification_id)
JOIN certification AS cert USING(certification_id)
WHERE earned.certification_id = :certificationId
AND (cert.is_active = TRUE OR :includeDeactivated = TRUE)
ORDER BY earned.earned_date DESC, earned.description""", nativeQuery = true)
ORDER BY earned.earned_date DESC""", nativeQuery = true)
List<EarnedCertification> findByCertificationIdOrderByEarnedDateDesc(@NotNull UUID certificationId, boolean includeDeactivated);

@Query(value = """
Expand All @@ -39,7 +39,7 @@ JOIN certification AS cert USING(certification_id)
JOIN certification AS cert USING(certification_id)
WHERE earned.member_id = :memberId
AND (cert.is_active = TRUE OR :includeDeactivated = TRUE)
ORDER BY earned.earned_date DESC, earned.description""", nativeQuery = true)
ORDER BY earned.earned_date DESC""", nativeQuery = true)
List<EarnedCertification> findByMemberIdOrderByEarnedDateDesc(@NotNull UUID memberId, boolean includeDeactivated);

@Query(value = """
Expand All @@ -49,7 +49,7 @@ JOIN certification AS cert USING(certification_id)
WHERE earned.certification_id = :certificationId
AND earned.member_id = :memberId
AND (cert.is_active = TRUE OR :includeDeactivated = TRUE)
ORDER BY earned.earned_date DESC, earned.description""", nativeQuery = true)
ORDER BY earned.earned_date DESC""", nativeQuery = true)
List<EarnedCertification> findByMemberIdAndCertificationIdOrderByEarnedDateDesc(@NotNull UUID memberId, @NotNull UUID certificationId, boolean includeDeactivated);

Optional<EarnedCertification> findById(@Nullable UUID id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CREATE TABLE certification
(
certification_id varchar PRIMARY KEY,
name varchar NOT NULL UNIQUE,
description varchar NOT NULL,
badge_url varchar,
is_active boolean NOT NULL DEFAULT TRUE
);
Expand All @@ -15,8 +16,7 @@ CREATE TABLE earned_certification
earned_certification_id varchar PRIMARY KEY,
member_id varchar REFERENCES member_profile (id),
certification_id varchar REFERENCES certification (certification_id),
description varchar NOT NULL,
earned_date timestamp NOT NULL,
expiration_date timestamp,
certificate_image_url varchar
validation_url varchar
);
20 changes: 10 additions & 10 deletions server/src/main/resources/db/dev/R__Load_testing_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1828,31 +1828,31 @@ values
--- CERTIFICATIONS

INSERT INTO certification
(certification_id, name, badge_url)
(certification_id, name, description, badge_url)
VALUES
('23b248e1-40f3-4477-b1b6-544b743e6ee3', 'Java', 'https://images.credly.com/images/235d5b25-d41e-48c2-9c0e-63b373e78fc8/image.png');
('23b248e1-40f3-4477-b1b6-544b743e6ee3', 'Java', 'Java Certification', 'https://images.credly.com/images/235d5b25-d41e-48c2-9c0e-63b373e78fc8/image.png');

INSERT INTO certification
(certification_id, name, badge_url)
(certification_id, name, description, badge_url)
VALUES
('68343978-4072-4b48-aa9c-01f7ec910c9b', 'Python', 'https://pythoninstitute.org/assets/61f11f7719dd3800707549.png');
('68343978-4072-4b48-aa9c-01f7ec910c9b', 'Python', 'Python Certification', 'https://pythoninstitute.org/assets/61f11f7719dd3800707549.png');

--- MEMBER CERTIFICATIONS

INSERT INTO earned_certification
(earned_certification_id, member_id, certification_id, description, earned_date)
(earned_certification_id, member_id, certification_id, earned_date)
VALUES -- Michael Kimberlin, Java
('d946dfaa-4bae-4a4e-a3c3-9378ce1cae37', '6207b3fd-042d-49aa-9e28-dcc04f537c2d', '23b248e1-40f3-4477-b1b6-544b743e6ee3', 'Java certification', '2024-04-01');
('d946dfaa-4bae-4a4e-a3c3-9378ce1cae37', '6207b3fd-042d-49aa-9e28-dcc04f537c2d', '23b248e1-40f3-4477-b1b6-544b743e6ee3', '2024-04-01');

INSERT INTO earned_certification
(earned_certification_id, member_id, certification_id, description, earned_date)
(earned_certification_id, member_id, certification_id, earned_date)
VALUES -- Revolver Ocelot, Java
('42471a8c-8851-42a0-8cc2-bc42cb1020cc', '105f2968-a182-45a3-892c-eeff76383fe0', '23b248e1-40f3-4477-b1b6-544b743e6ee3', 'Java certification', '2022-06-01');
('42471a8c-8851-42a0-8cc2-bc42cb1020cc', '105f2968-a182-45a3-892c-eeff76383fe0', '23b248e1-40f3-4477-b1b6-544b743e6ee3', '2022-06-01');

INSERT INTO earned_certification
(earned_certification_id, member_id, certification_id, description, earned_date)
(earned_certification_id, member_id, certification_id, earned_date)
VALUES -- Revolver Ocelot, Python
('1f4272da-6ecb-4c15-b4a8-28739405bd1c', '105f2968-a182-45a3-892c-eeff76383fe0', '68343978-4072-4b48-aa9c-01f7ec910c9b', 'Python certification', '2024-03-01');
('1f4272da-6ecb-4c15-b4a8-28739405bd1c', '105f2968-a182-45a3-892c-eeff76383fe0', '68343978-4072-4b48-aa9c-01f7ec910c9b', '2024-03-01');

-- Volunteering

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#earned-certifications-table {
display: flex;
justify-content: center;

.MuiCardHeader-root {
padding-bottom: 0;
}
Expand All @@ -9,6 +12,7 @@
}

table {
margin: 0 auto;
border-collapse: collapse;

img {
Expand All @@ -19,19 +23,23 @@
td,
th {
padding: 0.5rem;
text-align: center;
color: black;
}

th {
background-color: var(--oci-orange);
border-right: 1px solid var(--oci-light-blue);
}

th:last-child {
border-right: none;
}

tr:nth-child(even) {
background-color: #eee;
}

tr:nth-child(odd) {
background-color: #ffffff;
}
Expand Down
Loading

0 comments on commit 86913d5

Please sign in to comment.