Skip to content

Commit

Permalink
apply checkstyle config
Browse files Browse the repository at this point in the history
  • Loading branch information
mafasva committed Oct 9, 2024
1 parent c86838c commit 958f34a
Show file tree
Hide file tree
Showing 178 changed files with 4,693 additions and 4,111 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.highmed.numportal;



import org.highmed.numportal.service.atna.AtnaProperties;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@

public interface AttachmentRepository {

List<Attachment> getAttachments();
List<Attachment> getAttachments();

void saveAttachment(AttachmentDto model);
void saveAttachment(AttachmentDto model);

void deleteAttachment(Long id);
void deleteAttachment(Long id);

Optional<Attachment> findById(Long id);
Optional<Attachment> findById(Long id);

void updateReviewCounterByProjectId(Long projectId);
void updateReviewCounterByProjectId(Long projectId);

Optional<Attachment> findByIdAndProjectId(Long id, Long projectId);
Optional<Attachment> findByIdAndProjectId(Long id, Long projectId);

List<Attachment> findAttachmentsByProjectId(Long projectId);
List<Attachment> findAttachmentsByProjectId(Long projectId);

void deleteByProjectId(Long projectId);
void deleteByProjectId(Long projectId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@
@AllArgsConstructor
public class AttachmentDto {

@Schema(accessMode = Schema.AccessMode.READ_ONLY)
private Long id;
@Schema(accessMode = Schema.AccessMode.READ_ONLY)
private Long id;

private String name;
private String name;

private String description;
private String description;

private String type;
private String type;

private byte[] content;
private byte[] content;

private Long projectId;
private Long projectId;

@Schema(accessMode = Schema.AccessMode.READ_ONLY)
private OffsetDateTime uploadDate;
@Schema(accessMode = Schema.AccessMode.READ_ONLY)
private OffsetDateTime uploadDate;

private String authorId;
private String authorId;

@Schema(accessMode = Schema.AccessMode.READ_ONLY)
private int reviewCounter;
@Schema(accessMode = Schema.AccessMode.READ_ONLY)
private int reviewCounter;
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
package org.highmed.numportal.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;

import java.util.List;

@Data
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
@NoArgsConstructor
@AllArgsConstructor
public class LightAttachmentDto {

private List<String> description;
private List<String> description;

private MultipartFile[] files;
private MultipartFile[] files;

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package org.highmed.numportal.attachment.domain.model;

import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -16,36 +20,36 @@
@AllArgsConstructor
public class Attachment implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String name;
private String name;

private String description;
private String description;

@Column(name = "upload_date", nullable = false)
private OffsetDateTime uploadDate;
@Column(name = "upload_date", nullable = false)
private OffsetDateTime uploadDate;

private String type;
private String type;

private byte[] content;
private byte[] content;

@Column(name = "author_id")
private String authorId;
@Column(name = "author_id")
private String authorId;

@Column(name = "review_counter", nullable = false, columnDefinition = "INTEGER DEFAULT 0")
private int reviewCounter;
@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;
@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;
}
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;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.highmed.numportal.attachment.domain.repository;

import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.highmed.numportal.attachment.AttachmentRepository;
import org.highmed.numportal.attachment.domain.dto.AttachmentDto;
import org.highmed.numportal.attachment.domain.model.Attachment;

import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -19,59 +20,59 @@
@ConditionalOnProperty(prefix = "num", name = "enableAttachmentDatabase", havingValue = "true")
public class AttachmentRepositoryImpl implements AttachmentRepository {

private final AttachmentRepositoryJpa attachmentRepositoryJpa;
private final AttachmentRepositoryJpa attachmentRepositoryJpa;

@Override
public List<Attachment> getAttachments() {
return attachmentRepositoryJpa.getAttachments();
}
@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 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 void deleteAttachment(Long id) {
attachmentRepositoryJpa.deleteById(id);
}

@Override
public Optional<Attachment> findById(Long id) {
return attachmentRepositoryJpa.findById(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
@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 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 List<Attachment> findAttachmentsByProjectId(Long projectId) {
return attachmentRepositoryJpa.findAttachmentsByProjectId(projectId);
}

@Override
public void deleteByProjectId(Long projectId) {
attachmentRepositoryJpa.deleteByProjectId(projectId);
}
@Override
public void deleteByProjectId(Long projectId) {
attachmentRepositoryJpa.deleteByProjectId(projectId);
}


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.highmed.numportal.attachment.domain.repository;

import org.highmed.numportal.attachment.domain.model.Attachment;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
Expand All @@ -13,22 +14,21 @@
@Repository
public interface AttachmentRepositoryJpa extends JpaRepository<Attachment, Long> {

@Query("SELECT new Attachment (atc.id, atc.name, atc.description, atc.uploadDate, atc.reviewCounter) " +
"FROM Attachment atc ")
List<Attachment> getAttachments();
@Query("SELECT new Attachment (atc.id, atc.name, atc.description, atc.uploadDate, atc.reviewCounter) FROM Attachment atc ")
List<Attachment> getAttachments();

@Modifying
@Query("UPDATE Attachment atch SET atch.reviewCounter = atch.reviewCounter + 1 WHERE atch.projectId = :projectId")
void updateReviewCounterByProjectId(@Param("projectId") Long projectId);
@Modifying
@Query("UPDATE Attachment atch SET atch.reviewCounter = atch.reviewCounter + 1 WHERE atch.projectId = :projectId")
void updateReviewCounterByProjectId(@Param("projectId") Long projectId);

Optional<Attachment> findByIdAndProjectId(Long id, Long projectId);
Optional<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<Attachment> findAttachmentsByProjectId(@Param("projectId") Long projectId);
@Query("SELECT new Attachment (atc.id, atc.name, atc.description, atc.uploadDate, atc.reviewCounter) "
+ "FROM Attachment atc "
+ "WHERE atc.projectId = :projectId")
List<Attachment> findAttachmentsByProjectId(@Param("projectId") Long projectId);

@Modifying
@Query("DELETE FROM Attachment atch WHERE atch.projectId = :projectId")
void deleteByProjectId(@Param("projectId") Long projectId);
@Modifying
@Query("DELETE FROM Attachment atch WHERE atch.projectId = :projectId")
void deleteByProjectId(@Param("projectId") Long projectId);
}
Loading

0 comments on commit 958f34a

Please sign in to comment.