RED-9392: added new entity DownloadStatusReportEntity and corresponding... #558

Merged
ali.oezyetimoglu1 merged 1 commits from RED-9392-fp into master 2024-06-21 16:33:50 +02:00
5 changed files with 83 additions and 3 deletions

View File

@ -0,0 +1,40 @@
package com.iqser.red.service.persistence.management.v1.processor.entity.download;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Entity
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "download_status_reports")
public class DownloadStatusReportEntity {
@EmbeddedId
private DownloadStatusReportId downloadStatusReportId;
@Embeddable
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DownloadStatusReportId implements Serializable {
@Column(name = "download_status_entity_storage_id")
private String downloadStatusEntityStorageId;
@Column(name = "reports_template_id")
private String reportsTemplateId;
}
}

View File

@ -4,16 +4,16 @@ import java.time.OffsetDateTime;
import java.time.temporal.ChronoUnit;
import java.util.List;
import jakarta.transaction.Transactional;
import org.springframework.stereotype.Service;
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.ReportTemplateEntity;
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.DossierTemplateRepository;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.DownloadStatusReportRepository;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.ReportTemplateRepository;
import com.iqser.red.service.persistence.service.v1.api.shared.model.ReportTemplateUpdateRequest;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
@Service
@ -22,6 +22,7 @@ public class ReportTemplatePersistenceService {
private final ReportTemplateRepository reportTemplateRepository;
private final DossierTemplateRepository dossierTemplateRepository;
private final DownloadStatusReportRepository downloadStatusReportRepository;
public void insert(String dossierTemplateId, String templateId, String storageId, String templateName, boolean activeByDefault, boolean multiFileReport) {
@ -43,6 +44,7 @@ public class ReportTemplatePersistenceService {
@Transactional
public void delete(String templateId) {
downloadStatusReportRepository.deleteByReportsTemplateId(templateId);
reportTemplateRepository.deleteById(templateId);
}

View File

@ -0,0 +1,27 @@
package com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository;
import java.util.List;
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 com.iqser.red.service.persistence.management.v1.processor.entity.download.DownloadStatusReportEntity;
public interface DownloadStatusReportRepository extends JpaRepository<DownloadStatusReportEntity, String> {
@Modifying(flushAutomatically = true, clearAutomatically = true)
@Query("DELETE FROM DownloadStatusReportEntity d WHERE d.downloadStatusReportId.downloadStatusEntityStorageId = :downloadStatusEntityStorageId")
void deleteByDownloadStatusReportId(@Param("downloadStatusEntityStorageId") String downloadStatusEntityStorageId);
@Modifying(flushAutomatically = true, clearAutomatically = true)
@Query("DELETE FROM DownloadStatusReportEntity d WHERE d.downloadStatusReportId.reportsTemplateId = :reportsTemplateId")
void deleteByReportsTemplateId(@Param("reportsTemplateId") String reportsTemplateId);
@Query("SELECT d FROM DownloadStatusReportEntity d WHERE d.downloadStatusReportId.reportsTemplateId = :reportsTemplateId")
List<DownloadStatusReportEntity> findByReportsTemplateId(@Param("reportsTemplateId") String reportsTemplateId);
}

View File

@ -210,4 +210,6 @@ databaseChangeLog:
- include:
file: db/changelog/tenant/126-add-uuid-to-download-status.yaml
- include:
file: db/changelog/tenant/129-add-component-table.yaml
file: db/changelog/tenant/129-add-component-table.yaml
- include:
file: db/changelog/tenant/130-add-primary-key-constraint-download-status-reports.yaml

View File

@ -0,0 +1,9 @@
databaseChangeLog:
- changeSet:
id: add-primary-key-constraint-download-status-reports
author: ali
changes:
- addPrimaryKey:
columnNames: download_status_entity_storage_id,reports_template_id
constraintName: download_status_reports_pkey
tableName: download_status_reports