Skip to content

Commit

Permalink
MODTLR-5 rename domain to ecs-tlr
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-barannyk committed Jan 12, 2024
1 parent 31e5304 commit 64f9639
Show file tree
Hide file tree
Showing 23 changed files with 250 additions and 244 deletions.
14 changes: 11 additions & 3 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
"name": "Folio mod-tlr module",
"provides": [
{
"id": "title-level-requests",
"id": "ecs-tlr",
"version": "1.0",
"handlers": [
{
"methods": [
"GET"
],
"pathPattern": "/title-level-requests/{requestId}",
"pathPattern": "/tlr/ecs-tlr/{requestId}",
"permissionsRequired": [],
"modulePermissions": []
},
{
"methods": [
"POST"
],
"pathPattern": "/tlr/ecs-tlr",
"permissionsRequired": [],
"modulePermissions": []
}
Expand All @@ -37,7 +45,7 @@
"handlers": [
{
"methods": [ "POST" ],
"pathPattern": "/title-level-requests-processing",
"pathPattern": "/tlr/ecs-tlr-processing",
"unit": "second",
"delay": "30"
}
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 @@ -229,7 +229,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 @@ -4,10 +4,10 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class TitleLevelRequestsApplication {
public class EcsTlrApplication {

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

}
45 changes: 45 additions & 0 deletions src/main/java/org/folio/controller/EcsTlrController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.folio.controller;

import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
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);

try {
return new ResponseEntity<>(ecsTlrService.post(ecsTlr), CREATED);
} catch (Exception e) {
log.error("postEcsTlr:: unexpected error: {}", e.getMessage());
return new ResponseEntity<>(ecsTlr, INTERNAL_SERVER_ERROR);
}
}
}
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.

Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
import lombok.ToString;

@Entity
@Table(name = "title_level_request")
@Table(name = "ecs_tlr")
@Getter
@Setter
@ToString
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class TitleLevelRequestEntity {
public class EcsTlrEntity {

@Id
@Convert(converter = UUIDConverter.class)
Expand Down
12 changes: 12 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,12 @@
package org.folio.domain.mapper;

import org.folio.domain.dto.EcsTlr;
import org.folio.domain.entity.EcsTlrEntity;
import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;

@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface EcsTlrMapper {
EcsTlr mapEntityToDto(EcsTlrEntity ecsTlrEntity);
EcsTlrEntity mapDtoToEntity(EcsTlr ecsTlr);
}
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);
}
11 changes: 0 additions & 11 deletions src/main/java/org/folio/service/TitleLevelRequestsService.java

This file was deleted.

36 changes: 36 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,36 @@
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) {
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)));
}
}

This file was deleted.

8 changes: 4 additions & 4 deletions src/main/resources/db/changelog/changes/initial_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">

<!-- Changeset for creating table title_level_request with all the required fields -->
<changeSet id="createTitleLevelRequestTable" author="OleksandrVidinieiev">
<!-- Changeset for creating table ecs_tlr with all the required fields -->
<changeSet id="createEcsTlrTable" author="OleksandrVidinieiev">
<comment>
Create title_level_request table
Create ecs_tlr table
</comment>
<createTable tableName="title_level_request">
<createTable tableName="ecs_tlr">
<column name="id" type="uuid">
<constraints primaryKey="true"/>
</column>
Expand Down
Loading

0 comments on commit 64f9639

Please sign in to comment.