-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/folio-org/mod-tlr into MO…
…DTLR-7 # Conflicts: # src/main/java/org/folio/EcsTlrApplication.java
- Loading branch information
Showing
27 changed files
with
493 additions
and
266 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
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.controller; | ||
|
||
import static org.springframework.http.HttpStatus.CREATED; | ||
import static org.springframework.http.HttpStatus.OK; | ||
|
||
import java.util.UUID; | ||
|
||
import org.folio.domain.dto.EcsTlr; | ||
import org.folio.rest.resource.TlrApi; | ||
import org.folio.service.EcsTlrService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
@RestController | ||
@Log4j2 | ||
@AllArgsConstructor | ||
public class EcsTlrController implements TlrApi { | ||
|
||
private final EcsTlrService ecsTlrService; | ||
|
||
@Override | ||
public ResponseEntity<EcsTlr> getEcsTlrById(UUID requestId) { | ||
log.debug("getEcsTlrById:: parameters id: {}", requestId); | ||
|
||
return ecsTlrService.get(requestId) | ||
.map(ResponseEntity.status(OK)::body) | ||
.orElseGet(() -> ResponseEntity.notFound().build()); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<EcsTlr> postEcsTlr(EcsTlr ecsTlr) { | ||
log.debug("postEcsTlr:: parameters ecsTlr: {}", ecsTlr); | ||
|
||
return ResponseEntity.status(CREATED).body(ecsTlrService.post(ecsTlr)); | ||
} | ||
} |
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
29 changes: 0 additions & 29 deletions
29
src/main/java/org/folio/controller/TitleLevelRequestsController.java
This file was deleted.
Oops, something went wrong.
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.folio.domain.entity; | ||
|
||
import java.util.Date; | ||
import java.util.UUID; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Table(name = "ecs_tlr") | ||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class EcsTlrEntity { | ||
|
||
@Id | ||
private UUID id; | ||
private UUID instanceId; | ||
private UUID requesterId; | ||
private String requestType; | ||
private String requestLevel; | ||
private Date requestExpirationDate; | ||
private String patronComments; | ||
private String fulfillmentPreference; | ||
private UUID pickupServicePointId; | ||
private UUID itemId; | ||
} |
30 changes: 0 additions & 30 deletions
30
src/main/java/org/folio/domain/entity/TitleLevelRequestEntity.java
This file was deleted.
Oops, something went wrong.
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,52 @@ | ||
package org.folio.domain.mapper; | ||
|
||
import org.folio.domain.dto.EcsTlr; | ||
import org.folio.domain.entity.EcsTlrEntity; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import org.mapstruct.Named; | ||
import org.mapstruct.NullValueCheckStrategy; | ||
|
||
@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS) | ||
public interface EcsTlrMapper { | ||
|
||
@Mapping(target = "requestType", qualifiedByName = "StringToRequestType") | ||
@Mapping(target = "requestLevel", qualifiedByName = "StringToRequestLevel") | ||
@Mapping(target = "fulfillmentPreference", qualifiedByName = "StringToFulfillmentPreference") | ||
EcsTlr mapEntityToDto(EcsTlrEntity ecsTlrEntity); | ||
|
||
@Mapping(target = "requestType", qualifiedByName = "RequestTypeToString") | ||
@Mapping(target = "requestLevel", qualifiedByName = "RequestLevelToString") | ||
@Mapping(target = "fulfillmentPreference", qualifiedByName = "FulfillmentPreferenceToString") | ||
EcsTlrEntity mapDtoToEntity(EcsTlr ecsTlr); | ||
|
||
@Named("StringToRequestType") | ||
default EcsTlr.RequestTypeEnum mapRequestType(String requestType) { | ||
return requestType != null ? EcsTlr.RequestTypeEnum.fromValue(requestType) : null; | ||
} | ||
|
||
@Named("StringToRequestLevel") | ||
default EcsTlr.RequestLevelEnum mapRequestLevel(String requestLevel) { | ||
return requestLevel != null ? EcsTlr.RequestLevelEnum.fromValue(requestLevel) : null; | ||
} | ||
|
||
@Named("StringToFulfillmentPreference") | ||
default EcsTlr.FulfillmentPreferenceEnum mapFulfillmentPreference(String fulfillmentPreference) { | ||
return fulfillmentPreference != null ? EcsTlr.FulfillmentPreferenceEnum.fromValue(fulfillmentPreference) : null; | ||
} | ||
|
||
@Named("RequestTypeToString") | ||
default String mapRequestTypeToString(EcsTlr.RequestTypeEnum requestTypeEnum) { | ||
return requestTypeEnum != null ? requestTypeEnum.getValue() : null; | ||
} | ||
|
||
@Named("RequestLevelToString") | ||
default String mapRequestLevelToString(EcsTlr.RequestLevelEnum requestLevelEnum) { | ||
return requestLevelEnum != null ? requestLevelEnum.getValue() : null; | ||
} | ||
|
||
@Named("FulfillmentPreferenceToString") | ||
default String mapFulfillmentPreferenceToString(EcsTlr.FulfillmentPreferenceEnum fulfillmentPreferenceEnum) { | ||
return fulfillmentPreferenceEnum != null ? fulfillmentPreferenceEnum.getValue() : null; | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
src/main/java/org/folio/domain/mapper/TitleLevelRequestMapper.java
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...ository/TitleLevelRequestsRepository.java → ...rg/folio/repository/EcsTlrRepository.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,10 +1,10 @@ | ||
package org.folio.repository; | ||
|
||
import org.folio.domain.entity.TitleLevelRequestEntity; | ||
import org.folio.domain.entity.EcsTlrEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
import java.util.UUID; | ||
|
||
@Repository | ||
public interface TitleLevelRequestsRepository extends JpaRepository<TitleLevelRequestEntity, UUID> { | ||
public interface EcsTlrRepository extends JpaRepository<EcsTlrEntity, UUID> { | ||
} |
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,11 @@ | ||
package org.folio.service; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
import org.folio.domain.dto.EcsTlr; | ||
|
||
public interface EcsTlrService { | ||
Optional<EcsTlr> get(UUID requestId); | ||
EcsTlr post(EcsTlr ecsTlr); | ||
} |
10 changes: 0 additions & 10 deletions
10
src/main/java/org/folio/service/TitleLevelRequestsService.java
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
src/main/java/org/folio/service/impl/EcsTlrServiceImpl.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,38 @@ | ||
package org.folio.service.impl; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
import org.folio.domain.dto.EcsTlr; | ||
import org.folio.domain.mapper.EcsTlrMapper; | ||
import org.folio.repository.EcsTlrRepository; | ||
import org.folio.service.EcsTlrService; | ||
import org.springframework.stereotype.Service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Log4j2 | ||
public class EcsTlrServiceImpl implements EcsTlrService { | ||
|
||
private final EcsTlrRepository ecsTlrRepository; | ||
private final EcsTlrMapper requestsMapper; | ||
|
||
@Override | ||
public Optional<EcsTlr> get(UUID id) { | ||
log.debug("get:: parameters id: {}", id); | ||
|
||
return ecsTlrRepository.findById(id) | ||
.map(requestsMapper::mapEntityToDto); | ||
} | ||
|
||
@Override | ||
public EcsTlr post(EcsTlr ecsTlr) { | ||
log.debug("post:: parameters ecsTlr: {}", () -> ecsTlr); | ||
|
||
return requestsMapper.mapEntityToDto(ecsTlrRepository.save( | ||
requestsMapper.mapDtoToEntity(ecsTlr))); | ||
} | ||
} |
Oops, something went wrong.