-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/remove-vitagroup-package-structure
- Loading branch information
Showing
280 changed files
with
26,576 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.highmed; | ||
|
||
|
||
|
||
import org.highmed.service.atna.AtnaProperties; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
||
@EnableScheduling | ||
@EnableAsync | ||
@SpringBootApplication | ||
@EnableConfigurationProperties({AtnaProperties.class}) | ||
public class NumPortalApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(NumPortalApplication.class, args); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/org/highmed/attachment/AttachmentRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.highmed.attachment; | ||
|
||
import org.highmed.attachment.domain.dto.AttachmentDto; | ||
import org.highmed.attachment.domain.model.Attachment; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface AttachmentRepository { | ||
|
||
List<Attachment> getAttachments(); | ||
|
||
void saveAttachment(AttachmentDto model); | ||
|
||
void deleteAttachment(Long id); | ||
|
||
Optional<Attachment> findById(Long id); | ||
|
||
void updateReviewCounterByProjectId(Long projectId); | ||
|
||
Optional<Attachment> findByIdAndProjectId(Long id, Long projectId); | ||
|
||
List<Attachment> findAttachmentsByProjectId(Long projectId); | ||
|
||
void deleteByProjectId(Long projectId); | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/highmed/attachment/domain/dto/AttachmentDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.highmed.attachment.domain.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.OffsetDateTime; | ||
|
||
@Data | ||
@Builder | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class AttachmentDto { | ||
|
||
@Schema(accessMode = Schema.AccessMode.READ_ONLY) | ||
private Long id; | ||
|
||
private String name; | ||
|
||
private String description; | ||
|
||
private String type; | ||
|
||
private byte[] content; | ||
|
||
private Long projectId; | ||
|
||
@Schema(accessMode = Schema.AccessMode.READ_ONLY) | ||
private OffsetDateTime uploadDate; | ||
|
||
private String authorId; | ||
|
||
@Schema(accessMode = Schema.AccessMode.READ_ONLY) | ||
private int reviewCounter; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/highmed/attachment/domain/dto/LightAttachmentDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.highmed.attachment.domain.dto; | ||
|
||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@Data | ||
@Builder | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class LightAttachmentDto { | ||
|
||
private List<String> description; | ||
|
||
private MultipartFile[] files; | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/org/highmed/attachment/domain/model/Attachment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.highmed.attachment.domain.model; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
import java.time.OffsetDateTime; | ||
|
||
@Data | ||
@Builder | ||
@Entity | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Attachment implements Serializable { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String name; | ||
|
||
private String description; | ||
|
||
@Column(name = "upload_date", nullable = false) | ||
private OffsetDateTime uploadDate; | ||
|
||
private String type; | ||
|
||
private byte[] content; | ||
|
||
@Column(name = "author_id") | ||
private String authorId; | ||
|
||
@Column(name = "review_counter", nullable = false, columnDefinition = "INTEGER DEFAULT 0") | ||
private int reviewCounter; | ||
|
||
@Column(name = "project_id", nullable = false, columnDefinition = "BIGINT DEFAULT 0") | ||
private Long projectId; | ||
|
||
|
||
public Attachment(Long id, String name, String description, OffsetDateTime uploadDate, int reviewCounter) { | ||
this.id = id; | ||
this.name = name; | ||
this.description = description; | ||
this.uploadDate = uploadDate; | ||
this.reviewCounter = reviewCounter; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/main/java/org/highmed/attachment/domain/repository/AttachmentRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.highmed.attachment.domain.repository; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
import org.highmed.attachment.AttachmentRepository; | ||
import org.highmed.attachment.domain.dto.AttachmentDto; | ||
import org.highmed.attachment.domain.model.Attachment; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Component | ||
@Log4j2 | ||
@AllArgsConstructor | ||
@ConditionalOnProperty(prefix = "num", name = "enableAttachmentDatabase", havingValue = "true") | ||
public class AttachmentRepositoryImpl implements AttachmentRepository { | ||
|
||
private final AttachmentRepositoryJpa attachmentRepositoryJpa; | ||
|
||
@Override | ||
public List<Attachment> getAttachments() { | ||
return attachmentRepositoryJpa.getAttachments(); | ||
} | ||
|
||
@Override | ||
public void saveAttachment(AttachmentDto model) { | ||
Attachment entity = Attachment.builder() | ||
.name(model.getName()) | ||
.description(model.getDescription()) | ||
.authorId(model.getAuthorId()) | ||
.projectId(model.getProjectId()) | ||
.uploadDate(OffsetDateTime.now()) | ||
.type(model.getType()) | ||
.content(model.getContent()) | ||
.projectId(model.getProjectId()) | ||
.build(); | ||
entity = attachmentRepositoryJpa.save(entity); | ||
log.info("New attachment with id {} and name {} saved by {} ", entity.getId(), entity.getName(), entity.getAuthorId()); | ||
} | ||
|
||
@Override | ||
public void deleteAttachment(Long id) { | ||
attachmentRepositoryJpa.deleteById(id); | ||
} | ||
|
||
@Override | ||
public Optional<Attachment> findById(Long id) { | ||
return attachmentRepositoryJpa.findById(id); | ||
} | ||
|
||
@Override | ||
@Transactional(transactionManager = "attachmentTransactionManager") | ||
public void updateReviewCounterByProjectId(Long projectId) { | ||
attachmentRepositoryJpa.updateReviewCounterByProjectId(projectId); | ||
} | ||
|
||
@Override | ||
public Optional<Attachment> findByIdAndProjectId(Long id, Long projectId) { | ||
return attachmentRepositoryJpa.findByIdAndProjectId(id, projectId); | ||
} | ||
|
||
@Override | ||
public List<Attachment> findAttachmentsByProjectId(Long projectId) { | ||
return attachmentRepositoryJpa.findAttachmentsByProjectId(projectId); | ||
} | ||
|
||
@Override | ||
public void deleteByProjectId(Long projectId) { | ||
attachmentRepositoryJpa.deleteByProjectId(projectId); | ||
} | ||
|
||
|
||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/org/highmed/attachment/domain/repository/AttachmentRepositoryJpa.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.highmed.attachment.domain.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface AttachmentRepositoryJpa extends JpaRepository<org.highmed.attachment.domain.model.Attachment, Long> { | ||
|
||
@Query("SELECT new Attachment (atc.id, atc.name, atc.description, atc.uploadDate, atc.reviewCounter) " + | ||
"FROM Attachment atc ") | ||
List<org.highmed.attachment.domain.model.Attachment> getAttachments(); | ||
|
||
@Modifying | ||
@Query("UPDATE Attachment atch SET atch.reviewCounter = atch.reviewCounter + 1 WHERE atch.projectId = :projectId") | ||
void updateReviewCounterByProjectId(@Param("projectId") Long projectId); | ||
|
||
Optional<org.highmed.attachment.domain.model.Attachment> findByIdAndProjectId(Long id, Long projectId); | ||
|
||
@Query("SELECT new Attachment (atc.id, atc.name, atc.description, atc.uploadDate, atc.reviewCounter) " + | ||
"FROM Attachment atc " + | ||
"WHERE atc.projectId = :projectId") | ||
List<org.highmed.attachment.domain.model.Attachment> findAttachmentsByProjectId(@Param("projectId") Long projectId); | ||
|
||
@Modifying | ||
@Query("DELETE FROM Attachment atch WHERE atch.projectId = :projectId") | ||
void deleteByProjectId(@Param("projectId") Long projectId); | ||
} |
Oops, something went wrong.