Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/folio-org/mod-tlr into MO…
Browse files Browse the repository at this point in the history
…DTLR-7

# Conflicts:
#	src/main/java/org/folio/EcsTlrApplication.java
  • Loading branch information
MagzhanArtykov committed Jan 21, 2024
2 parents 26a0517 + 42d6008 commit ff20b03
Show file tree
Hide file tree
Showing 27 changed files with 493 additions and 266 deletions.
31 changes: 23 additions & 8 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
"name": "Folio mod-tlr module",
"provides": [
{
"id": "title-level-requests",
"id": "ecs-tlr",
"version": "1.0",
"handlers": [
{
"methods": [
"GET"
],
"pathPattern": "/title-level-requests/{requestId}",
"permissionsRequired": [],
"methods": ["GET"],
"pathPattern": "/tlr/ecs-tlr/{requestId}",
"permissionsRequired": ["tlr.ecs-tlr.item.get"],
"modulePermissions": []
},
{
"methods": ["POST"],
"pathPattern": "/tlr/ecs-tlr",
"permissionsRequired": ["tlr.ecs-tlr.post"],
"modulePermissions": []
}
]
Expand All @@ -37,14 +41,25 @@
"handlers": [
{
"methods": [ "POST" ],
"pathPattern": "/title-level-requests-processing",
"pathPattern": "/tlr/ecs-tlr-processing",
"unit": "second",
"delay": "30"
}
]
}
],
"permissionSets" : [],
"permissionSets" : [
{
"permissionName": "tlr.ecs-tlr.item.get",
"displayName": "ecs-tlr - get ECS TLR by ID",
"description": "Get ECS TLR"
},
{
"permissionName": "tlr.ecs-tlr.post",
"displayName": "ecs-tlr - create ECS TLR",
"description": "Create ECS TLR"
}
],
"requires": [],
"launchDescriptor": {
"dockerImage": "@artifactId@:@version@",
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<sonar.exclusions>
<!-- define sonar exclusions here -->
src/main/java/org/folio/TitleLevelRequestsApplication.java
src/main/java/org/folio/EcsTlrApplication.java
</sonar.exclusions>
<argLine/>

Expand Down Expand Up @@ -258,7 +258,7 @@
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/swagger.api/title-level-requests.yaml</inputSpec>
<inputSpec>${project.basedir}/src/main/resources/swagger.api/ecs-tlr.yaml</inputSpec>
<output>${project.build.directory}/generated-sources</output>
<generatorName>spring</generatorName>
<modelPackage>${project.groupId}.domain.dto</modelPackage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

@SpringBootApplication
@EnableFeignClients
public class TitleLevelRequestsApplication {
public class EcsTlrApplication {

public static void main(String[] args) {
SpringApplication.run(TitleLevelRequestsApplication.class, args);
SpringApplication.run(EcsTlrApplication.class, args);
}

}
39 changes: 39 additions & 0 deletions src/main/java/org/folio/controller/EcsTlrController.java
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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class OpenRequestsProcessingController {

private final OpenRequestsProcessingService openRequestsProcessingService;

@PostMapping(value = "/title-level-requests-processing")
@PostMapping(value = "/tlr/ecs-tlr-processing")
public void processOpenRequests() {
openRequestsProcessingService.processOpenRequests();
}

}
}

This file was deleted.

33 changes: 33 additions & 0 deletions src/main/java/org/folio/domain/entity/EcsTlrEntity.java
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 src/main/java/org/folio/domain/entity/TitleLevelRequestEntity.java

This file was deleted.

52 changes: 52 additions & 0 deletions src/main/java/org/folio/domain/mapper/EcsTlrMapper.java
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 src/main/java/org/folio/domain/mapper/TitleLevelRequestMapper.java

This file was deleted.

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> {
}
11 changes: 11 additions & 0 deletions src/main/java/org/folio/service/EcsTlrService.java
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 src/main/java/org/folio/service/TitleLevelRequestsService.java

This file was deleted.

38 changes: 38 additions & 0 deletions src/main/java/org/folio/service/impl/EcsTlrServiceImpl.java
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)));
}
}
Loading

0 comments on commit ff20b03

Please sign in to comment.