-
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.
MODCON-88 Save setupStatus for Tenant and add GET endpoint to return …
…tenant details with setup status (#91) * MODCON-88 Add setupStatus to tenant table and add GET endpoint which returns tenant details containing setup status * MODCON-88 refactor * MODCON-88 add tests * MODCON-88 fix codesmell * MODCON-88 add unit test * MODCON-88 formatting and logging minor updates * MODCON-88 add logging and test * MODCON-88 add test * MODCON-88 remove COMPLETED_WITH_ERRORS status * MODCON-88 minor rename * MODCON-88 move @transactional to service * MODCON-88 address review comments * MODCON-88 fix type * MODCON-88 remove not used imports * MODCON-88 update exception
- Loading branch information
1 parent
c5a2df7
commit da159ff
Showing
20 changed files
with
512 additions
and
80 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
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
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
19 changes: 19 additions & 0 deletions
19
src/main/java/org/folio/consortia/domain/converter/TenantDetailsEntityToTenantConverter.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,19 @@ | ||
package org.folio.consortia.domain.converter; | ||
|
||
import org.folio.consortia.domain.dto.Tenant; | ||
import org.folio.consortia.domain.entity.TenantDetailsEntity; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class TenantDetailsEntityToTenantConverter implements Converter<TenantDetailsEntity, Tenant> { | ||
@Override | ||
public Tenant convert(TenantDetailsEntity source) { | ||
Tenant tenant = new Tenant(); | ||
tenant.setId(source.getId()); | ||
tenant.setCode(source.getCode()); | ||
tenant.setName(source.getName()); | ||
tenant.setIsCentral(source.getIsCentral()); | ||
return tenant; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...ava/org/folio/consortia/domain/converter/TenantDetailsEntityToTenantDetailsConverter.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,19 @@ | ||
package org.folio.consortia.domain.converter; | ||
|
||
import org.folio.consortia.domain.dto.TenantDetails; | ||
import org.folio.consortia.domain.entity.TenantDetailsEntity; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class TenantDetailsEntityToTenantDetailsConverter implements Converter<TenantDetailsEntity, TenantDetails> { | ||
@Override | ||
public TenantDetails convert(TenantDetailsEntity source) { | ||
return new TenantDetails() | ||
.id(source.getId()) | ||
.code(source.getCode()) | ||
.name(source.getName()) | ||
.isCentral(source.getIsCentral()) | ||
.setupStatus(source.getSetupStatus()); | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
src/main/java/org/folio/consortia/domain/entity/AbstractTenantEntity.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.folio.consortia.domain.entity; | ||
|
||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
import org.folio.consortia.domain.entity.base.AuditableEntity; | ||
|
||
import jakarta.persistence.Id; | ||
import jakarta.persistence.MappedSuperclass; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@Setter | ||
@ToString | ||
@RequiredArgsConstructor | ||
@MappedSuperclass | ||
public abstract class AbstractTenantEntity extends AuditableEntity { | ||
@Id | ||
private String id; | ||
private String code; | ||
private String name; | ||
private UUID consortiumId; | ||
private Boolean isCentral; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof AbstractTenantEntity that)) return false; | ||
return Objects.equals(id, that.id) && Objects.equals(code, that.code) && Objects.equals(name, that.name) && Objects.equals(consortiumId, that.consortiumId) && Objects.equals(isCentral, that.isCentral); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id, code, name, consortiumId, isCentral); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/org/folio/consortia/domain/entity/TenantDetailsEntity.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,21 @@ | ||
package org.folio.consortia.domain.entity; | ||
|
||
import org.folio.consortia.domain.dto.TenantDetails; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.Table; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@Setter | ||
@ToString | ||
@Entity | ||
@Table(name = "tenant") | ||
public class TenantDetailsEntity extends AbstractTenantEntity { | ||
@Enumerated(EnumType.STRING) | ||
private TenantDetails.SetupStatusEnum setupStatus; | ||
} |
34 changes: 1 addition & 33 deletions
34
src/main/java/org/folio/consortia/domain/entity/TenantEntity.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 |
---|---|---|
@@ -1,41 +1,9 @@ | ||
package org.folio.consortia.domain.entity; | ||
|
||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
import org.folio.consortia.domain.entity.base.AuditableEntity; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@Setter | ||
@ToString | ||
@RequiredArgsConstructor | ||
@Entity | ||
@Table(name = "tenant") | ||
public class TenantEntity extends AuditableEntity { | ||
@Id | ||
private String id; | ||
private String code; | ||
private String name; | ||
private UUID consortiumId; | ||
private Boolean isCentral; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof TenantEntity that)) return false; | ||
return Objects.equals(id, that.id) && Objects.equals(code, that.code) && Objects.equals(name, that.name) && Objects.equals(consortiumId, that.consortiumId) && Objects.equals(isCentral, that.isCentral); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id, code, name, consortiumId, isCentral); | ||
} | ||
public class TenantEntity extends AbstractTenantEntity { | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/org/folio/consortia/repository/TenantDetailsRepository.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,13 @@ | ||
package org.folio.consortia.repository; | ||
|
||
import org.folio.consortia.domain.dto.TenantDetails; | ||
import org.folio.consortia.domain.entity.TenantDetailsEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface TenantDetailsRepository extends JpaRepository<TenantDetailsEntity, String> { | ||
@Modifying | ||
@Query("UPDATE TenantDetailsEntity t SET t.setupStatus= ?1 WHERE t.id= ?2") | ||
void setSetupStatusByTenantId(TenantDetails.SetupStatusEnum setupStatus, String tenantId); | ||
} |
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
Oops, something went wrong.