Remove unused DTOs and services.
Unused DTOs and transformation services were removed to clean up the codebase and reduce clutter. Added new utility exceptions and DTOs, including `NotFoundException`, `ReferencedException`, and `LocationDTO`, to improve error handling and code organization.
This commit is contained in:
parent
b55aca0ddf
commit
851c7823e0
103 changed files with 2078 additions and 1116 deletions
81
LocationDTO.java
Normal file
81
LocationDTO.java
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
package de.avatic.lcc.dto.generic;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents a geographical location with latitude and longitude.
|
||||
* This immutable DTO (Data Transfer Object) is used to transfer location data across system layers.
|
||||
*/
|
||||
public class LocationDTO {
|
||||
|
||||
/**
|
||||
* The latitude of the location.
|
||||
* Positive values indicate north and negative values indicate south.
|
||||
*/
|
||||
private final double latitude;
|
||||
|
||||
/**
|
||||
* The longitude of the location.
|
||||
* Positive values indicate east and negative values indicate west.
|
||||
*/
|
||||
private final double longitude;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code LocationDTO} with the specified latitude and longitude.
|
||||
*
|
||||
* @param latitude the latitude of the location, where north is positive and south is negative
|
||||
* @param longitude the longitude of the location, where east is positive and west is negative
|
||||
*/
|
||||
public LocationDTO(double latitude, double longitude) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor for creating a {@code LocationDTO} at origin (0,0).
|
||||
* Required for frameworks that use default constructors.
|
||||
*/
|
||||
public LocationDTO() {
|
||||
this(0.0, 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the latitude of the location.
|
||||
*
|
||||
* @return the latitude, where positive values indicate north and negative values indicate south
|
||||
*/
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the longitude of the location.
|
||||
*
|
||||
* @return the longitude, where positive values indicate east and negative values indicate west
|
||||
*/
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
LocationDTO that = (LocationDTO) o;
|
||||
return Double.compare(that.latitude, latitude) == 0 &&
|
||||
Double.compare(that.longitude, longitude) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(latitude, longitude);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LocationDTO{" +
|
||||
"latitude=" + latitude +
|
||||
", longitude=" + longitude +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
10
pom.xml
10
pom.xml
|
|
@ -37,7 +37,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jdbc</artifactId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
@ -80,6 +80,14 @@
|
|||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
|
|
|||
10
src/main/java/de/avatic/lcc/LccConfig.java
Normal file
10
src/main/java/de/avatic/lcc/LccConfig.java
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package de.avatic.lcc;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class LccConfig {
|
||||
|
||||
|
||||
|
||||
}
|
||||
17
src/main/java/de/avatic/lcc/config/ControllerConfig.java
Normal file
17
src/main/java/de/avatic/lcc/config/ControllerConfig.java
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package de.avatic.lcc.config;
|
||||
|
||||
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
|
||||
|
||||
@ControllerAdvice
|
||||
public class ControllerConfig {
|
||||
|
||||
@InitBinder
|
||||
public void initBinder(final WebDataBinder binder) {
|
||||
binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ package de.avatic.lcc.controller;
|
|||
|
||||
import de.avatic.lcc.dto.error.ErrorDTO;
|
||||
import de.avatic.lcc.dto.error.ErrorResponseDTO;
|
||||
import de.avatic.lcc.util.InvalidArgumentException;
|
||||
import de.avatic.lcc.util.exception.clienterror.InvalidArgumentException;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
|
@ -50,9 +50,17 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
|
|||
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@ExceptionHandler(ConstraintViolationException.class)
|
||||
public String handleConstraintViolation(ConstraintViolationException exception) { //
|
||||
// TODO you can choose to return your custom object here, which will then get transformed to json/xml etc.
|
||||
return "Sorry, that was not quite right: " + exception.getMessage();
|
||||
public ResponseEntity<ErrorResponseDTO> handleConstraintViolation(ConstraintViolationException exception) { //
|
||||
|
||||
ErrorDTO error = new ErrorDTO(
|
||||
"BAD_REQUEST",
|
||||
exception.getMessage(),
|
||||
new HashMap<>() {{
|
||||
put("errorMessage", exception.getStackTrace());
|
||||
}}
|
||||
);
|
||||
|
||||
return new ResponseEntity<>(new ErrorResponseDTO(error), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
package de.avatic.lcc.controller.bulk;
|
||||
|
||||
|
||||
import de.avatic.lcc.dto.bulk.BulkFileType;
|
||||
import de.avatic.lcc.service.bulk.BulkExportService;
|
||||
import de.avatic.lcc.service.bulk.BulkFileProcessingService;
|
||||
import de.avatic.lcc.service.bulk.TemplateGenerationService;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/bulk")
|
||||
public class BulkOperationController {
|
||||
|
||||
private final BulkFileProcessingService bulkProcessingService;
|
||||
private final TemplateGenerationService templateGenerationService;
|
||||
private final BulkExportService bulkExportService;
|
||||
|
||||
public BulkOperationController(BulkFileProcessingService bulkProcessingService, TemplateGenerationService templateGenerationService, BulkExportService bulkExportService) {
|
||||
this.bulkProcessingService = bulkProcessingService;
|
||||
this.templateGenerationService = templateGenerationService;
|
||||
this.bulkExportService = bulkExportService;
|
||||
}
|
||||
|
||||
@GetMapping("/status/{id}")
|
||||
public ResponseEntity<Void> getUploadStatus(@PathVariable Integer id) {
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@PostMapping("/upload/{type}")
|
||||
public ResponseEntity<Void> uploadFile(@PathVariable String type, @RequestParam("file") MultipartFile file) {
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@GetMapping("/templates/{type}")
|
||||
public ResponseEntity<InputStreamResource> generateTemplate(@PathVariable String type) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Content-Disposition", "attachment; filename=lcc_template_"+type.toLowerCase()+".xlsx");
|
||||
|
||||
return ResponseEntity
|
||||
.ok()
|
||||
.headers(headers)
|
||||
.contentType(MediaType.parseMediaType("application/vnd.ms-excel"))
|
||||
.body(new InputStreamResource(templateGenerationService.generateTemplate(BulkFileType.valueOf(type.toUpperCase()))));
|
||||
}
|
||||
|
||||
@GetMapping("/download/{type}")
|
||||
public ResponseEntity<InputStreamResource> downloadFile(@PathVariable String type) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Content-Disposition", "attachment; filename=lcc_export_"+type.toLowerCase()+".xlsx");
|
||||
|
||||
return ResponseEntity
|
||||
.ok()
|
||||
.headers(headers)
|
||||
.contentType(MediaType.parseMediaType("application/vnd.ms-excel"))
|
||||
.body(new InputStreamResource(bulkExportService.generateExport(BulkFileType.valueOf(type.toUpperCase()))));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package de.avatic.lcc.controller.calculation;
|
||||
|
||||
|
||||
import de.avatic.lcc.dto.calculation.PremiseDTO;
|
||||
import de.avatic.lcc.dto.calculation.SearchDTO;
|
||||
import de.avatic.lcc.dto.calculation.view.PremiseViewDTO;
|
||||
import de.avatic.lcc.service.calculation.CalclationSearchStringAnalyzerService;
|
||||
import de.avatic.lcc.service.calculation.CalculationCreationService;
|
||||
import de.avatic.lcc.service.calculation.PremisesService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/calculation")
|
||||
public class PremiseController {
|
||||
|
||||
private final CalclationSearchStringAnalyzerService calclationSearchStringAnalyzerService;
|
||||
private final PremisesService premisesServices;
|
||||
private final CalculationCreationService calculationCreationService;
|
||||
|
||||
public PremiseController(CalclationSearchStringAnalyzerService calclationSearchStringAnalyzerService, PremisesService premisesServices, CalculationCreationService calculationCreationService) {
|
||||
this.calclationSearchStringAnalyzerService = calclationSearchStringAnalyzerService;
|
||||
this.premisesServices = premisesServices;
|
||||
this.calculationCreationService = calculationCreationService;
|
||||
}
|
||||
|
||||
@GetMapping("/view")
|
||||
public ResponseEntity<List<PremiseDTO>> listPremises(@RequestParam String filter, @RequestParam(required = false) Integer page, @RequestParam(required = false) Integer limit, @RequestParam(name = "user", required = false) Integer userId, @RequestParam(required = false) Boolean deleted, @RequestParam(required = false) Boolean archived, @RequestParam(required = false) Boolean done) {
|
||||
return ResponseEntity.ok(premisesServices.listCalculation(filter, page, limit, userId, deleted, archived, done));
|
||||
}
|
||||
|
||||
@GetMapping("/search")
|
||||
public ResponseEntity<SearchDTO> findMaterialsAndSuppliers(@RequestParam String search) {
|
||||
return ResponseEntity.ok(calclationSearchStringAnalyzerService.findMaterialAndSuppliers(search));
|
||||
}
|
||||
|
||||
@GetMapping("/create")
|
||||
public ResponseEntity<List<PremiseViewDTO>> createCalculation(@RequestParam("material") List<Integer> materialIds, @RequestParam("supplier") List<Integer> supplierIds, @RequestParam("user_supplier") List<Integer> userSupplierIds, @RequestParam("from_scratch") boolean createEmpty ) {
|
||||
return ResponseEntity.ok(calculationCreationService.createCalculations(materialIds, supplierIds, userSupplierIds, createEmpty));
|
||||
}
|
||||
|
||||
@GetMapping("/edit")
|
||||
public ResponseEntity<List<PremiseViewDTO>> getPremises(@RequestParam("premiss_ids") List<Integer> premissIds) {
|
||||
return ResponseEntity.ok(premisesServices.getPremises(premissIds));
|
||||
}
|
||||
|
||||
@PutMapping("/edit")
|
||||
public ResponseEntity<Void> savePremises(@RequestBody List<PremiseViewDTO> premises ) {
|
||||
premisesServices.savePremises(premises);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package de.avatic.lcc.controller.configuration;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/rates/container")
|
||||
public class ContainerRateController {
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseEntity<ContainerRateDTO> getRates() {
|
||||
return "Container rates";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package de.avatic.lcc.controller;
|
||||
package de.avatic.lcc.controller.configuration;
|
||||
|
||||
import de.avatic.lcc.dto.countries.get.CountryGetDTO;
|
||||
import de.avatic.lcc.dto.countries.get.CountryListGetDTO;
|
||||
import de.avatic.lcc.dto.countries.post.CountryPostDTO;
|
||||
import de.avatic.lcc.dto.configuration.countries.view.CountryViewDTO;
|
||||
import de.avatic.lcc.dto.configuration.countries.update.CountryUpdateDTO;
|
||||
import de.avatic.lcc.dto.generic.CountryDTO;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import de.avatic.lcc.service.CountryService;
|
||||
import de.avatic.lcc.service.configuration.CountryService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
@ -21,11 +21,11 @@ public class CountryController {
|
|||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseEntity<List<CountryListGetDTO>> listCountries(@RequestParam(defaultValue = "20") int limit,
|
||||
public ResponseEntity<List<CountryDTO>> listCountries(@RequestParam(defaultValue = "20") int limit,
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@RequestParam(required = false, defaultValue = "") String filter) {
|
||||
|
||||
SearchQueryResult<CountryListGetDTO> countries = countryService.listMaterial(filter, page, limit);
|
||||
SearchQueryResult<CountryDTO> countries = countryService.listCountries(filter, page, limit);
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.header("X-Total-Count", String.valueOf(countries.getTotalElements()))
|
||||
|
|
@ -36,11 +36,12 @@ public class CountryController {
|
|||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<CountryGetDTO> getCountryDetails(@PathVariable Integer id) {
|
||||
public ResponseEntity<CountryViewDTO> getCountryDetails(@PathVariable Integer id) {
|
||||
return ResponseEntity.ok(countryService.getCountry(id));
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> updateCountry(@PathVariable Integer id, @RequestBody CountryPostDTO country) {
|
||||
@PostMapping("/{id}")
|
||||
public ResponseEntity<Void> updateCountry(@PathVariable Integer id, @RequestBody CountryUpdateDTO country) {
|
||||
countryService.updateCountry(id, country);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package de.avatic.lcc.controller;
|
||||
package de.avatic.lcc.controller.configuration;
|
||||
|
||||
import de.avatic.lcc.dto.material.get.MaterialGetDTO;
|
||||
import de.avatic.lcc.dto.material.post.MaterialPostDTO;
|
||||
import de.avatic.lcc.model.materials.Material;
|
||||
import de.avatic.lcc.dto.material.get.MaterialListGetDTO;
|
||||
import de.avatic.lcc.dto.configuration.material.view.MaterialViewDTO;
|
||||
import de.avatic.lcc.dto.configuration.material.update.MaterialUpdateDTO;
|
||||
import de.avatic.lcc.dto.generic.MaterialDTO;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import de.avatic.lcc.service.MaterialService;
|
||||
import de.avatic.lcc.service.configuration.MaterialService;
|
||||
import de.avatic.lcc.util.Check;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -34,12 +34,12 @@ public class MaterialController {
|
|||
* X-Total-Count (total elements), X-Page-Count (total pages), and X-Current-Page (current page).
|
||||
*/
|
||||
@GetMapping("/")
|
||||
public ResponseEntity<List<MaterialListGetDTO>> listMaterials(
|
||||
public ResponseEntity<List<MaterialDTO>> listMaterials(
|
||||
@RequestParam(defaultValue = "20") int limit,
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@RequestParam(required = false, defaultValue = "") String filter) {
|
||||
|
||||
SearchQueryResult<MaterialListGetDTO> materials = materialService.listMaterial(filter, page, limit);
|
||||
SearchQueryResult<MaterialDTO> materials = materialService.listMaterial(filter, page, limit);
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.header("X-Total-Count", String.valueOf(materials.getTotalElements()))
|
||||
|
|
@ -56,7 +56,7 @@ public class MaterialController {
|
|||
* @throws RuntimeException if the material with the given ID is not found.
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<MaterialGetDTO> getMaterialDetails(@PathVariable Integer id) {
|
||||
public ResponseEntity<MaterialViewDTO> getMaterialDetails(@PathVariable Integer id) {
|
||||
return ResponseEntity.ok(materialService.getMaterial(id));
|
||||
}
|
||||
|
||||
|
|
@ -68,11 +68,11 @@ public class MaterialController {
|
|||
* @return The updated material
|
||||
*/
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Material> updateMaterial(
|
||||
public ResponseEntity<Integer> updateMaterial(
|
||||
@PathVariable Integer id,
|
||||
@RequestBody MaterialPostDTO material) {
|
||||
materialService.updateMaterial(id, material);
|
||||
return ResponseEntity.noContent().build();
|
||||
@RequestBody MaterialUpdateDTO material) {
|
||||
Check.equals(id, material.getId());
|
||||
return ResponseEntity.ok(materialService.updateMaterial(id, material));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -88,7 +88,7 @@ public class MaterialController {
|
|||
}
|
||||
|
||||
@PostMapping("/")
|
||||
public ResponseEntity<Integer> createMaterial(@RequestBody MaterialPostDTO material) {
|
||||
public ResponseEntity<Integer> createMaterial(@RequestBody MaterialUpdateDTO material) {
|
||||
return ResponseEntity.ok(materialService.createMaterial(material));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package de.avatic.lcc.controller.configuration;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/rates/matrix")
|
||||
public class MatrixRateController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String getRates() {
|
||||
return "Matrix rates";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package de.avatic.lcc.controller.configuration;
|
||||
|
||||
import de.avatic.lcc.dto.generic.NodeDTO;
|
||||
import de.avatic.lcc.dto.configuration.nodes.view.NodeViewDTO;
|
||||
import de.avatic.lcc.dto.configuration.nodes.update.NodeUpdateDTO;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import de.avatic.lcc.service.configuration.NodeService;
|
||||
import de.avatic.lcc.util.Check;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/nodes")
|
||||
public class NodeController {
|
||||
|
||||
|
||||
private final NodeService nodeService;
|
||||
|
||||
public NodeController(NodeService nodeService) {
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseEntity<List<NodeDTO>> listNodes(@RequestParam(required = false) String filter, @RequestParam(required = false) int page, @RequestParam(required = false) int limit) {
|
||||
nodeService.listNodes(filter, page, limit);
|
||||
|
||||
SearchQueryResult<NodeDTO> countries = nodeService.listNodes(filter, page, limit);
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.header("X-Total-Count", String.valueOf(countries.getTotalElements()))
|
||||
.header("X-Page-Count", String.valueOf(countries.getTotalPages()))
|
||||
.header("X-Current-Page", String.valueOf(page))
|
||||
.body(countries.toList());
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<NodeViewDTO> getNode(@PathVariable Integer id) {
|
||||
return ResponseEntity.ok(nodeService.getNode(id));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Integer> deleteNode(@PathVariable Integer id) {
|
||||
return ResponseEntity.ok(nodeService.deleteNode(id));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Integer> updateNode(@PathVariable Integer id, @RequestBody NodeUpdateDTO node) {
|
||||
Check.equals(id, node.getId());
|
||||
return ResponseEntity.ok(nodeService.updateNode(node));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package de.avatic.lcc.controller;
|
||||
package de.avatic.lcc.controller.configuration;
|
||||
|
||||
import de.avatic.lcc.dto.packaging.get.PackagingGetDTO;
|
||||
import de.avatic.lcc.dto.packaging.post.PackagingPostDTO;
|
||||
import de.avatic.lcc.dto.configuration.packaging.view.PackagingViewDTO;
|
||||
import de.avatic.lcc.dto.configuration.packaging.update.PackagingUpdateDTO;
|
||||
import de.avatic.lcc.repositories.packaging.PackagingRepository;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import de.avatic.lcc.service.PackagingService;
|
||||
import de.avatic.lcc.service.configuration.PackagingService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -25,13 +25,13 @@ public class PackagingController {
|
|||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseEntity<List<PackagingGetDTO>> listPackaging(
|
||||
public ResponseEntity<List<PackagingViewDTO>> listPackaging(
|
||||
@RequestParam(defaultValue = "20") int limit,
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@RequestParam(required = false) Integer materialId,
|
||||
@RequestParam(required = false) Integer supplierId) {
|
||||
|
||||
SearchQueryResult<PackagingGetDTO> listEntries = packagingService.listPackaging(materialId, supplierId, page, limit);
|
||||
SearchQueryResult<PackagingViewDTO> listEntries = packagingService.listPackaging(materialId, supplierId, page, limit);
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.header("X-Total-Count", String.valueOf(listEntries.getTotalElements()))
|
||||
|
|
@ -43,13 +43,13 @@ public class PackagingController {
|
|||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<PackagingGetDTO> getPackagingDetails(@PathVariable Integer id) {
|
||||
public ResponseEntity<PackagingViewDTO> getPackagingDetails(@PathVariable Integer id) {
|
||||
return ResponseEntity.ok(packagingService.getPackaging(id));
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Void> updatePackaging(@PathVariable Integer id, @RequestBody PackagingPostDTO packaging) {
|
||||
public ResponseEntity<Void> updatePackaging(@PathVariable Integer id, @RequestBody PackagingUpdateDTO packaging) {
|
||||
packagingService.updatePackaging(id, packaging);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ public class PackagingController {
|
|||
}
|
||||
|
||||
@PostMapping("/")
|
||||
public ResponseEntity<Integer> addPackaging(@RequestBody PackagingPostDTO packaging) {
|
||||
public ResponseEntity<Integer> addPackaging(@RequestBody PackagingUpdateDTO packaging) {
|
||||
return ResponseEntity.ok(packagingService.createPackaging(packaging));
|
||||
}
|
||||
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
package de.avatic.lcc.controller;
|
||||
package de.avatic.lcc.controller.configuration;
|
||||
|
||||
import de.avatic.lcc.dto.properties.post.PropertiesPostDTO;
|
||||
import de.avatic.lcc.service.PropertiesService;
|
||||
import de.avatic.lcc.dto.configuration.properties.post.PropertiesPostDTO;
|
||||
import de.avatic.lcc.service.configuration.PropertiesService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package de.avatic.lcc.controller.report;
|
||||
|
||||
import de.avatic.lcc.dto.generic.NodeDTO;
|
||||
import de.avatic.lcc.dto.report.ReportDTO;
|
||||
import de.avatic.lcc.service.report.ExcelReportingService;
|
||||
import de.avatic.lcc.service.report.ReportFinderService;
|
||||
import de.avatic.lcc.service.report.ReportingService;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/reports")
|
||||
public class ReportingController {
|
||||
|
||||
private final ReportingService reportingService;
|
||||
private final ExcelReportingService excelReportingService;
|
||||
private final ReportFinderService reportFinderService;
|
||||
|
||||
public ReportingController(ReportingService reportingService, ExcelReportingService excelReportingService, ReportFinderService reportFinderService) {
|
||||
this.reportingService = reportingService;
|
||||
this.excelReportingService = excelReportingService;
|
||||
this.reportFinderService = reportFinderService;
|
||||
}
|
||||
|
||||
@GetMapping("/search")
|
||||
public ResponseEntity<List<List<NodeDTO>>> findSupplierForReporting(@RequestParam(value = "material") Integer materialId) {
|
||||
return ResponseEntity.ok(reportFinderService.findSupplierForReporting(materialId));
|
||||
}
|
||||
|
||||
@GetMapping("/view")
|
||||
public ResponseEntity<ReportDTO> getReport(@RequestParam(value = "material") Integer materialId, @RequestParam(value = "sources") List<Integer> nodeIds) {
|
||||
return ResponseEntity.ok(reportingService.getReport(materialId, nodeIds));
|
||||
}
|
||||
|
||||
@GetMapping("/download")
|
||||
public ResponseEntity<InputStreamResource> downloadReport(@RequestParam(value = "material") Integer materialId, @RequestParam(value = "sources") List<Integer> nodeIds) {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Content-Disposition", "attachment; filename=lcc_report.xlsx");
|
||||
|
||||
return ResponseEntity
|
||||
.ok()
|
||||
.headers(headers)
|
||||
.contentType(MediaType.parseMediaType("application/vnd.ms-excel"))
|
||||
.body(new InputStreamResource(excelReportingService.generateExcelReport(materialId, nodeIds)));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package de.avatic.lcc.controller.users;
|
||||
|
||||
import de.avatic.lcc.dto.users.GroupDTO;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import de.avatic.lcc.service.users.GroupService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/groups")
|
||||
public class GroupController {
|
||||
|
||||
private final GroupService groupService;
|
||||
|
||||
public GroupController(GroupService groupService) {
|
||||
this.groupService = groupService;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseEntity<List<GroupDTO>> listGroups(@RequestParam(defaultValue = "20") int limit,
|
||||
@RequestParam(defaultValue = "0") int page) {
|
||||
|
||||
SearchQueryResult<GroupDTO> groups = groupService.listGroups(page, limit);
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.header("X-Total-Count", String.valueOf(groups.getTotalElements()))
|
||||
.header("X-Page-Count", String.valueOf(groups.getTotalPages()))
|
||||
.header("X-Current-Page", String.valueOf(page))
|
||||
.body(groups.toList());
|
||||
}
|
||||
|
||||
@PutMapping("/")
|
||||
public void updateGroup(GroupDTO group) {
|
||||
return groupService.updateGroup(group);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package de.avatic.lcc.controller.users;
|
||||
|
||||
|
||||
import de.avatic.lcc.dto.generic.MaterialDTO;
|
||||
import de.avatic.lcc.dto.users.UserDTO;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import de.avatic.lcc.service.users.UserService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/users")
|
||||
public class UserController {
|
||||
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
public UserController(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseEntity<List<UserDTO>> listUsers(
|
||||
@RequestParam(defaultValue = "20") int limit,
|
||||
@RequestParam(defaultValue = "0") int page) {
|
||||
|
||||
SearchQueryResult<UserDTO> users = userService.listUsers(page, limit);
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.header("X-Total-Count", String.valueOf(users.getTotalElements()))
|
||||
.header("X-Page-Count", String.valueOf(users.getTotalPages()))
|
||||
.header("X-Current-Page", String.valueOf(page))
|
||||
.body(users.toList());
|
||||
}
|
||||
|
||||
@PutMapping("/")
|
||||
public void udateUser(UserDTO user) {
|
||||
userService.updateUser(user);
|
||||
}
|
||||
}
|
||||
5
src/main/java/de/avatic/lcc/dto/bulk/BulkFileType.java
Normal file
5
src/main/java/de/avatic/lcc/dto/bulk/BulkFileType.java
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
package de.avatic.lcc.dto.bulk;
|
||||
|
||||
public enum BulkFileType {
|
||||
CONTAINER_RATE, COUNTRY_MATRIX, MATERIAL, PACKAGING, NODE
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package de.avatic.lcc.dto.calculation;
|
||||
|
||||
public class PremiseDTO {
|
||||
}
|
||||
40
src/main/java/de/avatic/lcc/dto/calculation/SearchDTO.java
Normal file
40
src/main/java/de/avatic/lcc/dto/calculation/SearchDTO.java
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package de.avatic.lcc.dto.calculation;
|
||||
|
||||
import de.avatic.lcc.dto.generic.MaterialDTO;
|
||||
import de.avatic.lcc.dto.generic.NodeDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SearchDTO {
|
||||
|
||||
private List<MaterialDTO> materials;
|
||||
private List<NodeDTO> supplier;
|
||||
|
||||
|
||||
public List<MaterialDTO> getMaterials() {
|
||||
return materials;
|
||||
}
|
||||
|
||||
public void setMaterials(List<MaterialDTO> materials) {
|
||||
this.materials = materials;
|
||||
}
|
||||
|
||||
public List<NodeDTO> getSupplier() {
|
||||
return supplier;
|
||||
}
|
||||
|
||||
public void setSupplier(List<NodeDTO> supplier) {
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
public List<NodeDTO> getUser_supplier() {
|
||||
return user_supplier;
|
||||
}
|
||||
|
||||
public void setUser_supplier(List<NodeDTO> user_supplier) {
|
||||
this.user_supplier = user_supplier;
|
||||
}
|
||||
|
||||
private List<NodeDTO> user_supplier;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package de.avatic.lcc.dto.calculation.view;
|
||||
|
||||
public class PremiseViewDTO {
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package de.avatic.lcc.dto.countries.post;
|
||||
package de.avatic.lcc.dto.configuration.countries.update;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class CountryPostDTO {
|
||||
public class CountryUpdateDTO {
|
||||
|
||||
String id;
|
||||
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package de.avatic.lcc.dto.countries.get;
|
||||
package de.avatic.lcc.dto.configuration.countries.view;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class CountryGetDTO {
|
||||
public class CountryViewDTO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ public class CountryGetDTO {
|
|||
@JsonProperty("region_code")
|
||||
private String regionCode;
|
||||
|
||||
private Collection<CountryPropertyGetDTO> properties;
|
||||
private Collection<CountryViewPropertyDTO> properties;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
|
|
@ -50,11 +50,11 @@ public class CountryGetDTO {
|
|||
this.regionCode = regionCode;
|
||||
}
|
||||
|
||||
public Collection<CountryPropertyGetDTO> getProperties() {
|
||||
public Collection<CountryViewPropertyDTO> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Collection<CountryPropertyGetDTO> properties) {
|
||||
public void setProperties(Collection<CountryViewPropertyDTO> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package de.avatic.lcc.dto.countries.get;
|
||||
package de.avatic.lcc.dto.configuration.countries.view;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class CountryPropertyGetDTO {
|
||||
public class CountryViewPropertyDTO {
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
@ -1,22 +1,20 @@
|
|||
package de.avatic.lcc.dto.material.get;
|
||||
|
||||
package de.avatic.lcc.dto.configuration.material.update;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class MaterialListGetDTO {
|
||||
|
||||
public class MaterialUpdateDTO {
|
||||
private Integer id;
|
||||
@JsonProperty("part_number")
|
||||
private String partNumber;
|
||||
private String name;
|
||||
private String hsCode;
|
||||
|
||||
public MaterialListGetDTO() {
|
||||
public MaterialUpdateDTO() {
|
||||
}
|
||||
|
||||
public MaterialListGetDTO(Integer id, String partNumber, String name, String hsCode) {
|
||||
public MaterialUpdateDTO(Integer id, String partNumber, String name, String hsCode) {
|
||||
this.id = id;
|
||||
this.partNumber = partNumber;
|
||||
this.name = name;
|
||||
|
|
@ -68,7 +66,7 @@ public class MaterialListGetDTO {
|
|||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MaterialListGetDTO that = (MaterialListGetDTO) o;
|
||||
MaterialUpdateDTO that = (MaterialUpdateDTO) o;
|
||||
return Objects.equals(id, that.id) &&
|
||||
Objects.equals(partNumber, that.partNumber) &&
|
||||
Objects.equals(name, that.name);
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package de.avatic.lcc.dto.material.get;
|
||||
package de.avatic.lcc.dto.configuration.material.view;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MaterialGetDTO {
|
||||
public class MaterialViewDTO {
|
||||
private Integer id;
|
||||
|
||||
@JsonProperty("part_number")
|
||||
|
|
@ -18,12 +18,12 @@ public class MaterialGetDTO {
|
|||
|
||||
|
||||
@JsonProperty("packaging")
|
||||
private List<MaterialPackagingGetDTO> handlingUnits;
|
||||
private List<MaterialViewPackagingDTO> handlingUnits;
|
||||
|
||||
public MaterialGetDTO() {
|
||||
public MaterialViewDTO() {
|
||||
}
|
||||
|
||||
public MaterialGetDTO(Integer id, String partNumber, String name, String hs_code, List<MaterialPackagingGetDTO> handling_units) {
|
||||
public MaterialViewDTO(Integer id, String partNumber, String name, String hs_code, List<MaterialViewPackagingDTO> handling_units) {
|
||||
this.id = id;
|
||||
this.partNumber = partNumber;
|
||||
this.name = name;
|
||||
|
|
@ -68,11 +68,11 @@ public class MaterialGetDTO {
|
|||
}
|
||||
|
||||
@JsonProperty("handling_units")
|
||||
public List<MaterialPackagingGetDTO> getHandlingUnits() {
|
||||
public List<MaterialViewPackagingDTO> getHandlingUnits() {
|
||||
return handlingUnits;
|
||||
}
|
||||
|
||||
public void setHandlingUnits(List<MaterialPackagingGetDTO> handlingUnits) {
|
||||
public void setHandlingUnits(List<MaterialViewPackagingDTO> handlingUnits) {
|
||||
this.handlingUnits = handlingUnits;
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ public class MaterialGetDTO {
|
|||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MaterialGetDTO that = (MaterialGetDTO) o;
|
||||
MaterialViewDTO that = (MaterialViewDTO) o;
|
||||
return Objects.equals(id, that.id) &&
|
||||
Objects.equals(partNumber, that.partNumber) &&
|
||||
Objects.equals(name, that.name) &&
|
||||
|
|
@ -1,21 +1,23 @@
|
|||
package de.avatic.lcc.dto.material.get;
|
||||
package de.avatic.lcc.dto.configuration.material.view;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import de.avatic.lcc.dto.generic.DimensionDTO;
|
||||
import de.avatic.lcc.dto.generic.NodeDTO;
|
||||
|
||||
public class MaterialPackagingGetDTO {
|
||||
public class MaterialViewPackagingDTO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
@JsonProperty("is_deprecated")
|
||||
private Boolean isDeprecated;
|
||||
|
||||
private MaterialSupplierGetDTO supplier;
|
||||
private NodeDTO supplier;
|
||||
|
||||
@JsonProperty("handling_unit")
|
||||
private MaterialDimensionGetDTO hu;
|
||||
private DimensionDTO hu;
|
||||
|
||||
@JsonProperty("small_handling_unit")
|
||||
private MaterialDimensionGetDTO shu;
|
||||
private DimensionDTO shu;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
|
|
@ -33,27 +35,27 @@ public class MaterialPackagingGetDTO {
|
|||
isDeprecated = deprecated;
|
||||
}
|
||||
|
||||
public MaterialSupplierGetDTO getSupplier() {
|
||||
public NodeDTO getSupplier() {
|
||||
return supplier;
|
||||
}
|
||||
|
||||
public void setSupplier(MaterialSupplierGetDTO supplier) {
|
||||
public void setSupplier(NodeDTO supplier) {
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
public MaterialDimensionGetDTO getHu() {
|
||||
public DimensionDTO getHu() {
|
||||
return hu;
|
||||
}
|
||||
|
||||
public void setHu(MaterialDimensionGetDTO hu) {
|
||||
public void setHu(DimensionDTO hu) {
|
||||
this.hu = hu;
|
||||
}
|
||||
|
||||
public MaterialDimensionGetDTO getShu() {
|
||||
public DimensionDTO getShu() {
|
||||
return shu;
|
||||
}
|
||||
|
||||
public void setShu(MaterialDimensionGetDTO shu) {
|
||||
public void setShu(DimensionDTO shu) {
|
||||
this.shu = shu;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package de.avatic.lcc.dto.configuration.nodes.update;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import de.avatic.lcc.dto.generic.CountryDTO;
|
||||
import de.avatic.lcc.dto.generic.LocationDTO;
|
||||
import de.avatic.lcc.dto.generic.NodeDTO;
|
||||
import de.avatic.lcc.dto.generic.NodeTypeDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class NodeUpdateDTO {
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private CountryDTO country;
|
||||
private String address;
|
||||
private List<NodeTypeDTO> types;
|
||||
private LocationDTO location;
|
||||
@JsonProperty("is_deprecated")
|
||||
private Boolean isDeprecated;
|
||||
private Map<Integer, NodeDTO> predecessors;
|
||||
@JsonProperty("outbound_countries")
|
||||
private List<CountryDTO> outboundCountries;
|
||||
|
||||
public Integer getId() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
package de.avatic.lcc.dto.configuration.nodes.view;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import de.avatic.lcc.dto.generic.CountryDTO;
|
||||
import de.avatic.lcc.dto.generic.LocationDTO;
|
||||
import de.avatic.lcc.dto.generic.NodeDTO;
|
||||
import de.avatic.lcc.dto.generic.NodeTypeDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class NodeViewDTO {
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private CountryDTO country;
|
||||
private String address;
|
||||
private List<NodeTypeDTO> types;
|
||||
private LocationDTO location;
|
||||
@JsonProperty("is_deprecated")
|
||||
private Boolean isDeprecated;
|
||||
private Map<Integer, NodeDTO> predecessors;
|
||||
@JsonProperty("outbound_countries")
|
||||
private List<CountryDTO> outboundCountries;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public CountryDTO getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(CountryDTO country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public List<NodeTypeDTO> getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public void setTypes(List<NodeTypeDTO> types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
public LocationDTO getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(LocationDTO location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public Boolean getDeprecated() {
|
||||
return isDeprecated;
|
||||
}
|
||||
|
||||
public void setDeprecated(Boolean deprecated) {
|
||||
isDeprecated = deprecated;
|
||||
}
|
||||
|
||||
public Map<Integer, NodeDTO> getPredecessors() {
|
||||
return predecessors;
|
||||
}
|
||||
|
||||
public void setPredecessors(Map<Integer, NodeDTO> predecessors) {
|
||||
this.predecessors = predecessors;
|
||||
}
|
||||
|
||||
public List<CountryDTO> getOutboundCountries() {
|
||||
return outboundCountries;
|
||||
}
|
||||
|
||||
public void setOutboundCountries(List<CountryDTO> outboundCountries) {
|
||||
this.outboundCountries = outboundCountries;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
package de.avatic.lcc.dto.packaging.post;
|
||||
package de.avatic.lcc.dto.configuration.packaging.update;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import de.avatic.lcc.dto.generic.DimensionDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class PackagingPostDTO {
|
||||
public class PackagingUpdateDTO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
|
|
@ -18,10 +18,10 @@ public class PackagingPostDTO {
|
|||
private Integer materialId;
|
||||
|
||||
@JsonProperty("handling_unit")
|
||||
private PackagingDimensionPostDTO hu;
|
||||
private DimensionDTO hu;
|
||||
|
||||
@JsonProperty("small_handling_unit")
|
||||
private PackagingDimensionPostDTO shu;
|
||||
private DimensionDTO shu;
|
||||
|
||||
@JsonProperty("properties")
|
||||
private Map<String, String> properties;
|
||||
|
|
@ -58,19 +58,19 @@ public class PackagingPostDTO {
|
|||
this.materialId = materialId;
|
||||
}
|
||||
|
||||
public PackagingDimensionPostDTO getHu() {
|
||||
public DimensionDTO getHu() {
|
||||
return hu;
|
||||
}
|
||||
|
||||
public void setHu(PackagingDimensionPostDTO hu) {
|
||||
public void setHu(DimensionDTO hu) {
|
||||
this.hu = hu;
|
||||
}
|
||||
|
||||
public PackagingDimensionPostDTO getShu() {
|
||||
public DimensionDTO getShu() {
|
||||
return shu;
|
||||
}
|
||||
|
||||
public void setShu(PackagingDimensionPostDTO shu) {
|
||||
public void setShu(DimensionDTO shu) {
|
||||
this.shu = shu;
|
||||
}
|
||||
|
||||
|
|
@ -1,28 +1,31 @@
|
|||
package de.avatic.lcc.dto.packaging.get;
|
||||
package de.avatic.lcc.dto.configuration.packaging.view;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import de.avatic.lcc.dto.generic.DimensionDTO;
|
||||
import de.avatic.lcc.dto.generic.MaterialDTO;
|
||||
import de.avatic.lcc.dto.generic.NodeDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PackagingGetDTO {
|
||||
public class PackagingViewDTO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
@JsonProperty("is_deprecated")
|
||||
private Boolean isDeprecated;
|
||||
|
||||
private PackagingSupplierGetDTO supplier;
|
||||
private NodeDTO supplier;
|
||||
|
||||
private PackagingMaterialGetDTO material;
|
||||
private MaterialDTO material;
|
||||
|
||||
@JsonProperty("handling_unit")
|
||||
private PackagingDimensionGetDTO hu;
|
||||
private DimensionDTO hu;
|
||||
|
||||
@JsonProperty("small_handling_unit")
|
||||
private PackagingDimensionGetDTO shu;
|
||||
private DimensionDTO shu;
|
||||
|
||||
private List<PackagingPropertyGetDTO> properties;
|
||||
private List<PackagingViewPropertyDTO> properties;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
|
|
@ -40,43 +43,43 @@ public class PackagingGetDTO {
|
|||
isDeprecated = deprecated;
|
||||
}
|
||||
|
||||
public PackagingSupplierGetDTO getSupplier() {
|
||||
public NodeDTO getSupplier() {
|
||||
return supplier;
|
||||
}
|
||||
|
||||
public void setSupplier(PackagingSupplierGetDTO supplier) {
|
||||
public void setSupplier(NodeDTO supplier) {
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
public PackagingMaterialGetDTO getMaterial() {
|
||||
public MaterialDTO getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public void setMaterial(PackagingMaterialGetDTO material) {
|
||||
public void setMaterial(MaterialDTO material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
public PackagingDimensionGetDTO getHu() {
|
||||
public DimensionDTO getHu() {
|
||||
return hu;
|
||||
}
|
||||
|
||||
public void setHu(PackagingDimensionGetDTO hu) {
|
||||
public void setHu(DimensionDTO hu) {
|
||||
this.hu = hu;
|
||||
}
|
||||
|
||||
public PackagingDimensionGetDTO getShu() {
|
||||
public DimensionDTO getShu() {
|
||||
return shu;
|
||||
}
|
||||
|
||||
public void setShu(PackagingDimensionGetDTO shu) {
|
||||
public void setShu(DimensionDTO shu) {
|
||||
this.shu = shu;
|
||||
}
|
||||
|
||||
public List<PackagingPropertyGetDTO> getProperties() {
|
||||
public List<PackagingViewPropertyDTO> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(List<PackagingPropertyGetDTO> properties) {
|
||||
public void setProperties(List<PackagingViewPropertyDTO> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package de.avatic.lcc.dto.packaging.get;
|
||||
package de.avatic.lcc.dto.configuration.packaging.view;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class PackagingPropertyGetDTO {
|
||||
public class PackagingViewPropertyDTO {
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.avatic.lcc.dto.properties.post;
|
||||
package de.avatic.lcc.dto.configuration.properties.post;
|
||||
|
||||
public class PropertiesPostDTO {
|
||||
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
package de.avatic.lcc.dto.countries.get;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class CountryListGetDTO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
@JsonProperty("iso_code")
|
||||
private String isoCode;
|
||||
|
||||
@JsonProperty("region_code")
|
||||
private String regionCode;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIsoCode() {
|
||||
return isoCode;
|
||||
}
|
||||
|
||||
public void setIsoCode(String isoCode) {
|
||||
this.isoCode = isoCode;
|
||||
}
|
||||
|
||||
public String getRegionCode() {
|
||||
return regionCode;
|
||||
}
|
||||
|
||||
public void setRegionCode(String regionCode) {
|
||||
this.regionCode = regionCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CountryListGetDTO{" +
|
||||
"id=" + id +
|
||||
", isoCode='" + isoCode + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package de.avatic.lcc.dto.packaging.get;
|
||||
package de.avatic.lcc.dto.generic;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class PackagingCountryGetDTO {
|
||||
public class CountryDTO {
|
||||
|
||||
@JsonProperty("id")
|
||||
private Integer id;
|
||||
|
|
@ -13,6 +13,7 @@ public class PackagingCountryGetDTO {
|
|||
@JsonProperty("region_code")
|
||||
private String regionCode;
|
||||
|
||||
private String name;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
|
|
@ -38,4 +39,11 @@ public class PackagingCountryGetDTO {
|
|||
this.regionCode = regionCode;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package de.avatic.lcc.dto.material.get;
|
||||
package de.avatic.lcc.dto.generic;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import de.avatic.lcc.model.packaging.PackagingType;
|
||||
import de.avatic.lcc.model.utils.DimensionUnit;
|
||||
import de.avatic.lcc.model.utils.WeightUnit;
|
||||
|
||||
public class MaterialDimensionGetDTO {
|
||||
public class DimensionDTO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
81
src/main/java/de/avatic/lcc/dto/generic/LocationDTO.java
Normal file
81
src/main/java/de/avatic/lcc/dto/generic/LocationDTO.java
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
package de.avatic.lcc.dto.generic;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents a geographical location with latitude and longitude.
|
||||
* This immutable DTO (Data Transfer Object) is used to transfer location data across system layers.
|
||||
*/
|
||||
public class LocationDTO {
|
||||
|
||||
/**
|
||||
* The latitude of the location.
|
||||
* Positive values indicate north and negative values indicate south.
|
||||
*/
|
||||
private final double latitude;
|
||||
|
||||
/**
|
||||
* The longitude of the location.
|
||||
* Positive values indicate east and negative values indicate west.
|
||||
*/
|
||||
private final double longitude;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code LocationDTO} with the specified latitude and longitude.
|
||||
*
|
||||
* @param latitude the latitude of the location, where north is positive and south is negative
|
||||
* @param longitude the longitude of the location, where east is positive and west is negative
|
||||
*/
|
||||
public LocationDTO(double latitude, double longitude) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor for creating a {@code LocationDTO} at origin (0,0).
|
||||
* Required for frameworks that use default constructors.
|
||||
*/
|
||||
public LocationDTO() {
|
||||
this(0.0, 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the latitude of the location.
|
||||
*
|
||||
* @return the latitude, where positive values indicate north and negative values indicate south
|
||||
*/
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the longitude of the location.
|
||||
*
|
||||
* @return the longitude, where positive values indicate east and negative values indicate west
|
||||
*/
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
LocationDTO that = (LocationDTO) o;
|
||||
return Double.compare(that.latitude, latitude) == 0 &&
|
||||
Double.compare(that.longitude, longitude) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(latitude, longitude);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LocationDTO{" +
|
||||
"latitude=" + latitude +
|
||||
", longitude=" + longitude +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,22 @@
|
|||
package de.avatic.lcc.dto.material.post;
|
||||
package de.avatic.lcc.dto.generic;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class MaterialPostDTO {
|
||||
public class MaterialDTO {
|
||||
|
||||
private Integer id;
|
||||
@JsonProperty("part_number")
|
||||
private String partNumber;
|
||||
private String name;
|
||||
private String hsCode;
|
||||
|
||||
public MaterialPostDTO() {
|
||||
public MaterialDTO() {
|
||||
}
|
||||
|
||||
public MaterialPostDTO(Integer id, String partNumber, String name, String hsCode) {
|
||||
public MaterialDTO(Integer id, String partNumber, String name, String hsCode) {
|
||||
this.id = id;
|
||||
this.partNumber = partNumber;
|
||||
this.name = name;
|
||||
|
|
@ -66,7 +68,7 @@ public class MaterialPostDTO {
|
|||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MaterialPostDTO that = (MaterialPostDTO) o;
|
||||
MaterialDTO that = (MaterialDTO) o;
|
||||
return Objects.equals(id, that.id) &&
|
||||
Objects.equals(partNumber, that.partNumber) &&
|
||||
Objects.equals(name, that.name);
|
||||
|
|
@ -1,18 +1,17 @@
|
|||
package de.avatic.lcc.dto.material.get;
|
||||
package de.avatic.lcc.dto.generic;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import de.avatic.lcc.dto.generic.NodeTypeDTO;
|
||||
import de.avatic.lcc.dto.packaging.get.PackagingCountryGetDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MaterialSupplierGetDTO {
|
||||
public class NodeDTO {
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private MaterialCountryGetDTO country;
|
||||
private CountryDTO country;
|
||||
private String address;
|
||||
private List<NodeTypeDTO> types;
|
||||
private LocationDTO location;
|
||||
|
||||
@JsonProperty("is_deprecated")
|
||||
private Boolean isDeprecated;
|
||||
|
|
@ -33,11 +32,11 @@ public class MaterialSupplierGetDTO {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public MaterialCountryGetDTO getCountry() {
|
||||
public CountryDTO getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(MaterialCountryGetDTO country) {
|
||||
public void setCountry(CountryDTO country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
|
|
@ -64,4 +63,12 @@ public class MaterialSupplierGetDTO {
|
|||
public void setDeprecated(Boolean deprecated) {
|
||||
isDeprecated = deprecated;
|
||||
}
|
||||
|
||||
public LocationDTO getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(LocationDTO location) {
|
||||
this.location = location;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
package de.avatic.lcc.dto.material.get;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class MaterialCountryGetDTO {
|
||||
|
||||
@JsonProperty("id")
|
||||
private Integer id;
|
||||
|
||||
@JsonProperty("iso_code")
|
||||
private String isoCode;
|
||||
|
||||
@JsonProperty("region_code")
|
||||
private String regionCode;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getIsoCode() {
|
||||
return isoCode;
|
||||
}
|
||||
|
||||
public void setIsoCode(String isoCode) {
|
||||
this.isoCode = isoCode;
|
||||
}
|
||||
|
||||
public String getRegionCode() {
|
||||
return regionCode;
|
||||
}
|
||||
|
||||
public void setRegionCode(String regionCode) {
|
||||
this.regionCode = regionCode;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
package de.avatic.lcc.dto.nodes;
|
||||
|
||||
public class NodeDTO {
|
||||
|
||||
// TODO
|
||||
|
||||
}
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
package de.avatic.lcc.dto.packaging.get;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import de.avatic.lcc.model.packaging.PackagingType;
|
||||
import de.avatic.lcc.model.utils.DimensionUnit;
|
||||
import de.avatic.lcc.model.utils.WeightUnit;
|
||||
|
||||
public class PackagingDimensionGetDTO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private PackagingType type;
|
||||
|
||||
private Double length;
|
||||
|
||||
private Double width;
|
||||
|
||||
private Double height;
|
||||
|
||||
@JsonProperty("dimension_unit")
|
||||
private DimensionUnit dimensionUnit;
|
||||
|
||||
private Double weight;
|
||||
|
||||
@JsonProperty("weight_unit")
|
||||
private WeightUnit weightUnit;
|
||||
|
||||
@JsonProperty("content_unit_count")
|
||||
private Integer contentUnitCount;
|
||||
|
||||
@JsonProperty("is_deprecated")
|
||||
private Boolean isDeprecated;
|
||||
|
||||
public PackagingType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(PackagingType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Double getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public void setLength(Double length) {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public Double getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(Double width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public Double getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(Double height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public DimensionUnit getDimensionUnit() {
|
||||
return dimensionUnit;
|
||||
}
|
||||
|
||||
public void setDimensionUnit(DimensionUnit dimensionUnit) {
|
||||
this.dimensionUnit = dimensionUnit;
|
||||
}
|
||||
|
||||
public Double getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(Double weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public WeightUnit getWeightUnit() {
|
||||
return weightUnit;
|
||||
}
|
||||
|
||||
public void setWeightUnit(WeightUnit weightUnit) {
|
||||
this.weightUnit = weightUnit;
|
||||
}
|
||||
|
||||
public Integer getContentUnitCount() {
|
||||
return contentUnitCount;
|
||||
}
|
||||
|
||||
public void setContentUnitCount(Integer contentUnitCount) {
|
||||
this.contentUnitCount = contentUnitCount;
|
||||
}
|
||||
|
||||
public Boolean getDeprecated() {
|
||||
return isDeprecated;
|
||||
}
|
||||
|
||||
public void setDeprecated(Boolean deprecated) {
|
||||
isDeprecated = deprecated;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
package de.avatic.lcc.dto.packaging.get;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class PackagingMaterialGetDTO {
|
||||
|
||||
private Integer id;
|
||||
@JsonProperty("part_number")
|
||||
private String partNumber;
|
||||
private String name;
|
||||
private String hsCode;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPartNumber() {
|
||||
return partNumber;
|
||||
}
|
||||
|
||||
public void setPartNumber(String partNumber) {
|
||||
this.partNumber = partNumber;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getHsCode() {
|
||||
return hsCode;
|
||||
}
|
||||
|
||||
public void setHsCode(String hsCode) {
|
||||
this.hsCode = hsCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
package de.avatic.lcc.dto.packaging.get;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import de.avatic.lcc.dto.generic.NodeTypeDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PackagingSupplierGetDTO {
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private PackagingCountryGetDTO country;
|
||||
private String address;
|
||||
private List<NodeTypeDTO> types;
|
||||
|
||||
@JsonProperty("is_deprecated")
|
||||
private Boolean isDeprecated;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public PackagingCountryGetDTO getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(PackagingCountryGetDTO country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public List<NodeTypeDTO> getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public void setTypes(List<NodeTypeDTO> types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
public void setDeprecated(Boolean isDeprecated) {
|
||||
this.isDeprecated = isDeprecated;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
package de.avatic.lcc.dto.packaging.post;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import de.avatic.lcc.model.packaging.PackagingType;
|
||||
import de.avatic.lcc.model.utils.DimensionUnit;
|
||||
import de.avatic.lcc.model.utils.WeightUnit;
|
||||
|
||||
public class PackagingDimensionPostDTO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private PackagingType type;
|
||||
|
||||
private Double length;
|
||||
|
||||
private Double width;
|
||||
|
||||
private Double height;
|
||||
|
||||
@JsonProperty("dimension_unit")
|
||||
private DimensionUnit dimensionUnit;
|
||||
|
||||
private Double weight;
|
||||
|
||||
@JsonProperty("weight_unit")
|
||||
private WeightUnit weightUnit;
|
||||
|
||||
@JsonProperty("content_unit_count")
|
||||
private Integer contentUnitCount;
|
||||
|
||||
@JsonProperty("is_deprecated")
|
||||
private Boolean isDeprecated;
|
||||
|
||||
public PackagingType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(PackagingType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Double getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public void setLength(Double length) {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public Double getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(Double width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public Double getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(Double height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public DimensionUnit getDimensionUnit() {
|
||||
return dimensionUnit;
|
||||
}
|
||||
|
||||
public void setDimensionUnit(DimensionUnit dimensionUnit) {
|
||||
this.dimensionUnit = dimensionUnit;
|
||||
}
|
||||
|
||||
public Double getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(Double weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public WeightUnit getWeightUnit() {
|
||||
return weightUnit;
|
||||
}
|
||||
|
||||
public void setWeightUnit(WeightUnit weightUnit) {
|
||||
this.weightUnit = weightUnit;
|
||||
}
|
||||
|
||||
public Integer getContentUnitCount() {
|
||||
return contentUnitCount;
|
||||
}
|
||||
|
||||
public void setContentUnitCount(Integer contentUnitCount) {
|
||||
this.contentUnitCount = contentUnitCount;
|
||||
}
|
||||
|
||||
public Boolean getDeprecated() {
|
||||
return isDeprecated;
|
||||
}
|
||||
|
||||
public void setDeprecated(Boolean deprecated) {
|
||||
isDeprecated = deprecated;
|
||||
}
|
||||
}
|
||||
4
src/main/java/de/avatic/lcc/dto/report/ReportDTO.java
Normal file
4
src/main/java/de/avatic/lcc/dto/report/ReportDTO.java
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
package de.avatic.lcc.dto.report;
|
||||
|
||||
public class ReportDTO {
|
||||
}
|
||||
29
src/main/java/de/avatic/lcc/dto/users/GroupDTO.java
Normal file
29
src/main/java/de/avatic/lcc/dto/users/GroupDTO.java
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package de.avatic.lcc.dto.users;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class GroupDTO {
|
||||
|
||||
@JsonProperty("group_name")
|
||||
private String name;
|
||||
|
||||
@JsonProperty("group_description")
|
||||
private String description;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
75
src/main/java/de/avatic/lcc/dto/users/UserDTO.java
Normal file
75
src/main/java/de/avatic/lcc/dto/users/UserDTO.java
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
package de.avatic.lcc.dto.users;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UserDTO {
|
||||
|
||||
@JsonProperty("firstname")
|
||||
private String firstName;
|
||||
|
||||
@JsonProperty("lastname")
|
||||
private String lastName;
|
||||
|
||||
@JsonProperty("mail")
|
||||
private String email;
|
||||
|
||||
@JsonProperty("workday_id")
|
||||
private String workdayId;
|
||||
|
||||
@JsonProperty("is_active")
|
||||
private boolean isActive;
|
||||
|
||||
@JsonProperty("groups")
|
||||
private List<String> groups;
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getWorkdayId() {
|
||||
return workdayId;
|
||||
}
|
||||
|
||||
public void setWorkdayId(String workdayId) {
|
||||
this.workdayId = workdayId;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
isActive = active;
|
||||
}
|
||||
|
||||
public List<String> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public void setGroups(List<String> groups) {
|
||||
this.groups = groups;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package de.avatic.lcc.model.materials;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import de.avatic.lcc.dto.packaging.get.PackagingDimensionGetDTO;
|
||||
import de.avatic.lcc.dto.generic.DimensionDTO;
|
||||
|
||||
public class MaterialPackaging {
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ public class MaterialPackaging {
|
|||
private MaterialSupplier supplier;
|
||||
|
||||
@JsonProperty("handling_unit")
|
||||
private PackagingDimensionGetDTO hu;
|
||||
private DimensionDTO hu;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
|
|
@ -29,11 +29,11 @@ public class MaterialPackaging {
|
|||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
public PackagingDimensionGetDTO getHu() {
|
||||
public DimensionDTO getHu() {
|
||||
return hu;
|
||||
}
|
||||
|
||||
public void setHu(PackagingDimensionGetDTO hu) {
|
||||
public void setHu(DimensionDTO hu) {
|
||||
this.hu = hu;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import java.math.BigDecimal;
|
|||
import java.time.OffsetDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class Node {
|
||||
|
|
@ -48,7 +49,7 @@ public class Node {
|
|||
|
||||
private Integer countryId;
|
||||
|
||||
private List<Integer> nodePredecessors;
|
||||
private Map<Integer, Integer> nodePredecessors;
|
||||
|
||||
private Collection<Integer> outboundCountries;
|
||||
|
||||
|
|
@ -156,11 +157,11 @@ public class Node {
|
|||
this.countryId = countryId;
|
||||
}
|
||||
|
||||
public List<Integer> getNodePredecessors() {
|
||||
public Map<Integer, Integer> getNodePredecessors() {
|
||||
return nodePredecessors;
|
||||
}
|
||||
|
||||
public void setNodePredecessors(List<Integer> nodePredecessors) {
|
||||
public void setNodePredecessors(Map<Integer, Integer> nodePredecessors) {
|
||||
this.nodePredecessors = nodePredecessors;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
package de.avatic.lcc.model.nodes;
|
||||
|
||||
import de.avatic.lcc.dto.generic.NodeTypeDTO;
|
||||
import de.avatic.lcc.model.country.CountryListEntry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NodeListEntry {
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private CountryListEntry country;
|
||||
private String address;
|
||||
private List<NodeTypeDTO> types;
|
||||
|
||||
private Boolean isSink;
|
||||
private Boolean isSource;
|
||||
private Boolean isIntermediate;
|
||||
private Boolean isDeprecated;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
|
|
@ -46,11 +45,35 @@ public class NodeListEntry {
|
|||
this.address = address;
|
||||
}
|
||||
|
||||
public List<NodeTypeDTO> getTypes() {
|
||||
return types;
|
||||
public Boolean getSink() {
|
||||
return isSink;
|
||||
}
|
||||
|
||||
public void setTypes(List<NodeTypeDTO> types) {
|
||||
this.types = types;
|
||||
public void setSink(Boolean sink) {
|
||||
isSink = sink;
|
||||
}
|
||||
|
||||
public Boolean getSource() {
|
||||
return isSource;
|
||||
}
|
||||
|
||||
public void setSource(Boolean source) {
|
||||
isSource = source;
|
||||
}
|
||||
|
||||
public Boolean getIntermediate() {
|
||||
return isIntermediate;
|
||||
}
|
||||
|
||||
public void setIntermediate(Boolean intermediate) {
|
||||
isIntermediate = intermediate;
|
||||
}
|
||||
|
||||
public Boolean getDeprecated() {
|
||||
return isDeprecated;
|
||||
}
|
||||
|
||||
public void setDeprecated(Boolean deprecated) {
|
||||
isDeprecated = deprecated;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package de.avatic.lcc.model.packaging;
|
||||
|
||||
|
||||
import de.avatic.lcc.dto.packaging.get.PackagingDimensionGetDTO;
|
||||
import de.avatic.lcc.dto.generic.DimensionDTO;
|
||||
|
||||
/**
|
||||
* Represents the type of packaging used in the system.
|
||||
|
|
@ -11,7 +11,7 @@ import de.avatic.lcc.dto.packaging.get.PackagingDimensionGetDTO;
|
|||
* - HU: Handling Unit.
|
||||
*
|
||||
* It is commonly utilized in packaging-related entities such as
|
||||
* {@link PackagingDimensionGetDTO} to specify the type
|
||||
* {@link DimensionDTO} to specify the type
|
||||
* of a particular packaging instance.
|
||||
*/
|
||||
public enum PackagingType {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package de.avatic.lcc.model.premisses;
|
|||
import de.avatic.lcc.model.materials.Material;
|
||||
import de.avatic.lcc.model.nodes.Node;
|
||||
import de.avatic.lcc.model.utils.DimensionUnit;
|
||||
import de.avatic.lcc.dto.packaging.get.PackagingGetDTO;
|
||||
import de.avatic.lcc.dto.configuration.packaging.view.PackagingViewDTO;
|
||||
import de.avatic.lcc.model.utils.WeightUnit;
|
||||
import de.avatic.lcc.model.user.SysUser;
|
||||
import jakarta.validation.constraints.Digits;
|
||||
|
|
@ -89,7 +89,7 @@ public class Premiss {
|
|||
private AggregateReference<Node, Integer> userSupplierNode;
|
||||
|
||||
@Column("packaging_id")
|
||||
private AggregateReference<PackagingGetDTO, Integer> packaging;
|
||||
private AggregateReference<PackagingViewDTO, Integer> packaging;
|
||||
|
||||
@NotNull
|
||||
private AggregateReference<SysUser, Integer> user;
|
||||
|
|
@ -273,11 +273,11 @@ public class Premiss {
|
|||
this.userSupplierNode = userSupplierNode;
|
||||
}
|
||||
|
||||
public AggregateReference<PackagingGetDTO, Integer> getPackaging() {
|
||||
public AggregateReference<PackagingViewDTO, Integer> getPackaging() {
|
||||
return packaging;
|
||||
}
|
||||
|
||||
public void setPackaging(AggregateReference<PackagingGetDTO, Integer> packaging) {
|
||||
public void setPackaging(AggregateReference<PackagingViewDTO, Integer> packaging) {
|
||||
this.packaging = packaging;
|
||||
}
|
||||
|
||||
|
|
|
|||
4
src/main/java/de/avatic/lcc/model/users/User.java
Normal file
4
src/main/java/de/avatic/lcc/model/users/User.java
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
package de.avatic.lcc.model.users;
|
||||
|
||||
public class User {
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.avatic.lcc.repositories.country;
|
||||
package de.avatic.lcc.repositories;
|
||||
|
||||
import de.avatic.lcc.model.country.Country;
|
||||
import de.avatic.lcc.model.country.IsoCode;
|
||||
|
|
@ -88,7 +88,7 @@ public class CountryRepository {
|
|||
if (filter != null) {
|
||||
queryBuilder.append(" AND (iso_code LIKE ? OR region_code LIKE ?) ");
|
||||
}
|
||||
queryBuilder.append(" LIMIT ? OFFSET ?");
|
||||
queryBuilder.append("ORDER BY iso_code LIMIT ? OFFSET ?");
|
||||
return queryBuilder.toString();
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ public class MaterialRepository {
|
|||
if (filter != null) {
|
||||
queryBuilder.append(" AND (name LIKE ? OR part_number LIKE ?) ");
|
||||
}
|
||||
queryBuilder.append(" LIMIT ? OFFSET ?");
|
||||
queryBuilder.append("ORDER BY normalized_part_number LIMIT ? OFFSET ?");
|
||||
return queryBuilder.toString();
|
||||
}
|
||||
|
||||
|
|
@ -114,10 +114,9 @@ public class MaterialRepository {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public Material update(Material material) {
|
||||
public Optional<Integer> update(Material material) {
|
||||
String updateQuery = "UPDATE material SET name = ?, part_number = ?, normalized_part_number = ?, hs_code = ? WHERE id = ?";
|
||||
jdbcTemplate.update(updateQuery, material.getName(), material.getPartNumber(), material.getNormalizedPartNumber(), material.getHsCode(), material.getId());
|
||||
return material;
|
||||
return Optional.ofNullable(jdbcTemplate.update(updateQuery, material.getName(), material.getPartNumber(), material.getNormalizedPartNumber(), material.getHsCode(), material.getId()) == 0 ? null : material.getId());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
package de.avatic.lcc.repositories;
|
||||
|
||||
import de.avatic.lcc.model.nodes.Node;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryPagination;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Repository
|
||||
public class NodeRepository {
|
||||
|
|
@ -28,7 +31,98 @@ public class NodeRepository {
|
|||
FROM node
|
||||
WHERE node.id = ?""";
|
||||
|
||||
var node = jdbcTemplate.queryForObject(query, (rs, rowNum) -> {
|
||||
var node = jdbcTemplate.queryForObject(query, new NodeMapper(), id);
|
||||
|
||||
return Optional.ofNullable(node);
|
||||
}
|
||||
|
||||
private Map<Integer, Integer> getPredecessorsOf(Integer id) {
|
||||
String query = """
|
||||
SELECT node_predecessor.predecessor_node_id, node_predecessor.sequence_number
|
||||
FROM node_predecessor
|
||||
WHERE node_predecessor.node_id = ? ORDER BY node_predecessor.sequence_number""";
|
||||
|
||||
return jdbcTemplate.query(query, rs -> {
|
||||
Map<Integer, Integer> predecessors = new HashMap<>();
|
||||
|
||||
while(rs.next()) {
|
||||
predecessors.put(rs.getInt("sequence_number"), rs.getInt("predecessor_node_id"));
|
||||
}
|
||||
|
||||
return predecessors;
|
||||
}, id);
|
||||
}
|
||||
|
||||
private Collection<Integer> getOutboundCountriesOf(Integer id) {
|
||||
String query = """
|
||||
SELECT outbound_country_mapping.country_id
|
||||
FROM outbound_country_mapping
|
||||
WHERE outbound_country_mapping.node_id = ?""";
|
||||
|
||||
return jdbcTemplate.queryForList(query, Integer.class, id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public SearchQueryResult<Node> listNodes(String filter, Boolean excludeDeprecated, SearchQueryPagination pagination) {
|
||||
String query = buildQuery(filter, excludeDeprecated, pagination);
|
||||
|
||||
List<Node> entities = jdbcTemplate.query(query, new NodeMapper(), "%" + filter + "%", "%" + filter + "%", "%" + filter + "%", pagination.getLimit(), pagination.getOffset());
|
||||
Integer totalCount = jdbcTemplate.queryForObject(buildCountQuery(filter, excludeDeprecated), Integer.class, "%" + filter + "%", "%" + filter + "%", "%" + filter + "%");
|
||||
|
||||
return new SearchQueryResult<>(entities, pagination.getPage(), totalCount, pagination.getLimit());
|
||||
}
|
||||
|
||||
private String buildCountQuery(String filter, boolean excludeDeprecated) {
|
||||
StringBuilder queryBuilder = new StringBuilder("""
|
||||
SELECT COUNT(*)
|
||||
FROM WHERE 1=1""");
|
||||
|
||||
if (excludeDeprecated) {
|
||||
queryBuilder.append(" AND is_deprecated = FALSE");
|
||||
}
|
||||
if (filter != null) {
|
||||
queryBuilder.append(" AND (name LIKE ? OR address LIKE ? OR country_iso_code LIKE ?)");
|
||||
}
|
||||
|
||||
return queryBuilder.toString();
|
||||
}
|
||||
|
||||
private String buildQuery(String filter, Boolean excludeDeprecated, SearchQueryPagination searchQueryPagination) {
|
||||
StringBuilder queryBuilder = new StringBuilder("""
|
||||
SELECT node.id AS id, node.name AS name, node.address as address, node.is_source as is_source,
|
||||
node.is_sink as is_sink, node.is_intermediate as is_intermediate, node.country_id as country_id, node.predecessor_required as predecessor_required,
|
||||
country.iso_code AS country_iso_code, country.region_code AS country_region_code, country.name AS country_name, country.is_deprecated AS country_is_deprecated
|
||||
FROM node
|
||||
LEFT JOIN country ON country.id = node.country_id
|
||||
""");
|
||||
|
||||
if (excludeDeprecated) {
|
||||
queryBuilder.append(" AND is_deprecated = FALSE");
|
||||
}
|
||||
if (filter != null) {
|
||||
queryBuilder.append(" AND (name LIKE ? OR address LIKE ? OR country_iso_code LIKE ?)");
|
||||
}
|
||||
queryBuilder.append(" ORDER BY id LIMIT ? OFFSET ?");
|
||||
return queryBuilder.toString();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Optional<Integer> setDeprecatedById(Integer id) {
|
||||
String query = "UPDATE node SET is_deprecated = TRUE WHERE id = ?";
|
||||
return Optional.ofNullable(jdbcTemplate.update(query, id) == 0 ? null : id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Optional<Integer> update(Node node) {
|
||||
//TODO update predecessors and outbound_countries too
|
||||
String query = "UPDATE node SET";
|
||||
return Optional.ofNullable(jdbcTemplate.update(query, node.getId()) == 0 ? null : node.getId());
|
||||
}
|
||||
|
||||
private class NodeMapper implements RowMapper<Node> {
|
||||
|
||||
@Override
|
||||
public Node mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
var data = new Node();
|
||||
|
||||
data.setId(rs.getInt("id"));
|
||||
|
|
@ -41,29 +135,9 @@ public class NodeRepository {
|
|||
data.setPredecessorRequired(rs.getBoolean("predecessor_required"));
|
||||
|
||||
data.setNodePredecessors(getPredecessorsOf(data.getId()));
|
||||
data.setOutboundCountries(getOutboundCountriesOf(data.getId()));
|
||||
|
||||
return data;
|
||||
}, id);
|
||||
|
||||
return Optional.ofNullable(node);
|
||||
}
|
||||
|
||||
private List<Integer> getPredecessorsOf(Integer id) {
|
||||
String query = """
|
||||
SELECT node_predecessor.predecessor_node_id
|
||||
FROM node_predecessor
|
||||
WHERE node_predecessor.node_id = ? ORDER BY node_predecessor.sequence_number""";
|
||||
|
||||
return jdbcTemplate.queryForList(query, Integer.class, id);
|
||||
|
||||
}
|
||||
|
||||
private Collection<Integer> getOutboundCountriesOf(Integer id) {
|
||||
String query = """
|
||||
SELECT outbound_country_mapping.country_id
|
||||
FROM outbound_country_mapping
|
||||
WHERE outbound_country_mapping.node_id = ?""";
|
||||
|
||||
return jdbcTemplate.queryForList(query, Integer.class, id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class PackagingRepository {
|
|||
if (supplierId != null) {
|
||||
queryBuilder.append(" AND supplier_node_id = ?");
|
||||
}
|
||||
queryBuilder.append(" LIMIT ? OFFSET ?");
|
||||
queryBuilder.append("ORDER BY id LIMIT ? OFFSET ?");
|
||||
return queryBuilder.toString();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package de.avatic.lcc.repositories.pagination;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -74,4 +75,11 @@ public class SearchQueryResult<T> {
|
|||
public Integer getElementsPerPage() {
|
||||
return elementsPerPage;
|
||||
}
|
||||
|
||||
public static <T, R> SearchQueryResult<T> map(SearchQueryResult<R> queryResult, Function<R, T> mapper) {
|
||||
return new SearchQueryResult<>(queryResult.toList().stream().map(mapper).toList(),
|
||||
queryResult.getPage(),
|
||||
queryResult.getTotalElements(),
|
||||
queryResult.getElementsPerPage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package de.avatic.lcc.repositories.users;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class GroupRepository {
|
||||
public listGroups() {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package de.avatic.lcc.repositories.users;
|
||||
|
||||
import de.avatic.lcc.model.users.User;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryPagination;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public class UserRepository {
|
||||
|
||||
@Transactional
|
||||
public SearchQueryResult<User> listUsers(SearchQueryPagination pagination) {
|
||||
String query = "SELECT * FROM users";
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void update(User user) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
package de.avatic.lcc.service;
|
||||
|
||||
import de.avatic.lcc.dto.material.get.MaterialGetDTO;
|
||||
import de.avatic.lcc.dto.material.get.MaterialPackagingGetDTO;
|
||||
import de.avatic.lcc.dto.material.post.MaterialPostDTO;
|
||||
import de.avatic.lcc.model.country.Country;
|
||||
import de.avatic.lcc.model.materials.Material;
|
||||
import de.avatic.lcc.dto.material.get.MaterialListGetDTO;
|
||||
import de.avatic.lcc.model.nodes.Node;
|
||||
import de.avatic.lcc.model.packaging.PackagingDimension;
|
||||
import de.avatic.lcc.repositories.country.CountryRepository;
|
||||
import de.avatic.lcc.repositories.MaterialRepository;
|
||||
import de.avatic.lcc.repositories.NodeRepository;
|
||||
import de.avatic.lcc.repositories.packaging.PackagingDimensionRepository;
|
||||
import de.avatic.lcc.repositories.packaging.PackagingRepository;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryPagination;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import de.avatic.lcc.service.transformer.MaterialTransformerService;
|
||||
import de.avatic.lcc.util.Check;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class MaterialService {
|
||||
|
||||
private final MaterialTransformerService materialTransformerService;
|
||||
private final PackagingRepository packagingRepository;
|
||||
private final CountryRepository countryRepository;
|
||||
private final NodeRepository nodeRepository;
|
||||
private final PackagingDimensionRepository packagingDimensionRepository;
|
||||
private final MaterialRepository materialRepository;
|
||||
|
||||
public MaterialService(MaterialRepository materialRepository, MaterialTransformerService materialTransformerService, PackagingRepository packagingRepository, CountryRepository countryRepository, NodeRepository nodeRepository, PackagingDimensionRepository packagingDimensionRepository) {
|
||||
this.materialRepository = materialRepository;
|
||||
this.materialTransformerService = materialTransformerService;
|
||||
this.packagingRepository = packagingRepository;
|
||||
this.countryRepository = countryRepository;
|
||||
this.nodeRepository = nodeRepository;
|
||||
this.packagingDimensionRepository = packagingDimensionRepository;
|
||||
}
|
||||
|
||||
public SearchQueryResult<MaterialListGetDTO> listMaterial(String filter, int page, int limit) {
|
||||
SearchQueryResult<Material> queryResult = materialRepository.listMaterials(filter, true, new SearchQueryPagination(page, limit));
|
||||
List<MaterialListGetDTO> dto = queryResult.toList().stream().map(materialTransformerService::convertToMaterialListGetDTO).toList();
|
||||
return new SearchQueryResult<>(dto, queryResult.getPage(), queryResult.getTotalElements(), queryResult.getElementsPerPage());
|
||||
}
|
||||
|
||||
public MaterialGetDTO getMaterial(Integer id) {
|
||||
|
||||
List<MaterialPackagingGetDTO> packaging = packagingRepository.getByMaterialId(id).stream().map(p -> {
|
||||
|
||||
Optional<Node> supplier = nodeRepository.getById(p.getSupplierId());
|
||||
Optional<Country> country = countryRepository.getById(supplier.orElseThrow().getCountryId());
|
||||
Optional<PackagingDimension> hu = packagingDimensionRepository.getById(p.getHuId());
|
||||
Optional<PackagingDimension> shu = packagingDimensionRepository.getById(p.getShuId());
|
||||
|
||||
return materialTransformerService.convertToMaterialPackagingGetDTO(p, supplier, country, hu, shu);
|
||||
}).toList();
|
||||
|
||||
return materialTransformerService.convertToMaterialGetDTO(materialRepository.getById(id)).orElseThrow(() -> new RuntimeException("Material not found with id " + id));
|
||||
}
|
||||
|
||||
public void updateMaterial(Integer id, MaterialPostDTO dto) {
|
||||
|
||||
//check consistency
|
||||
Check.equals(id, dto.getId());
|
||||
materialRepository.update(materialTransformerService.convertFromMaterialPostDTO(dto));
|
||||
}
|
||||
|
||||
public Integer createMaterial(MaterialPostDTO dto) {
|
||||
return materialRepository.create(materialTransformerService.convertFromMaterialPostDTO(dto)).orElseThrow(() -> new RuntimeException("Unable to create Material " + dto));
|
||||
}
|
||||
|
||||
public Integer deleteMaterial(Integer id) {
|
||||
return materialRepository.setDeprecatedById(id).orElseThrow(() -> new RuntimeException("Packaging does not exists " + id));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package de.avatic.lcc.service.bulk;
|
||||
|
||||
import de.avatic.lcc.dto.bulk.BulkFileType;
|
||||
import org.springframework.core.io.InputStreamSource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class BulkExportService {
|
||||
public InputStreamSource generateExport(BulkFileType bulkFileType) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package de.avatic.lcc.service.bulk;
|
||||
|
||||
import de.avatic.lcc.dto.bulk.BulkFileType;
|
||||
import org.springframework.core.io.InputStreamSource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class BulkFileProcessingService {
|
||||
|
||||
public InputStreamSource generateExport(BulkFileType type) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package de.avatic.lcc.service.bulk;
|
||||
|
||||
import de.avatic.lcc.dto.bulk.BulkFileType;
|
||||
import org.springframework.core.io.InputStreamSource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TemplateGenerationService {
|
||||
|
||||
public InputStreamSource generateTemplate(BulkFileType bulkFileType) {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package de.avatic.lcc.service.calculation;
|
||||
|
||||
import de.avatic.lcc.dto.calculation.SearchDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class CalclationSearchStringAnalyzerService {
|
||||
|
||||
public SearchDTO findMaterialAndSuppliers(String search) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package de.avatic.lcc.service.calculation;
|
||||
|
||||
import de.avatic.lcc.dto.calculation.view.PremiseViewDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CalculationCreationService {
|
||||
public List<PremiseViewDTO> createCalculations(List<Integer> materialIds, List<Integer> supplierIds, List<Integer> userSupplierIds, boolean createEmpty) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package de.avatic.lcc.service.calculation;
|
||||
|
||||
import de.avatic.lcc.dto.calculation.PremiseDTO;
|
||||
import de.avatic.lcc.dto.calculation.view.PremiseViewDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class PremisesService {
|
||||
|
||||
public List<PremiseDTO> listCalculation(String filter, Integer page, Integer limit, Integer userId, Boolean deleted, Boolean archived, Boolean done) {
|
||||
return null;
|
||||
};
|
||||
|
||||
public List<PremiseViewDTO> getPremises(List<Integer> premissIds) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void savePremises(List<PremiseViewDTO> premises) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
package de.avatic.lcc.service;
|
||||
package de.avatic.lcc.service.configuration;
|
||||
|
||||
import de.avatic.lcc.dto.countries.get.CountryGetDTO;
|
||||
import de.avatic.lcc.dto.countries.get.CountryListGetDTO;
|
||||
import de.avatic.lcc.dto.countries.post.CountryPostDTO;
|
||||
import de.avatic.lcc.model.country.Country;
|
||||
import de.avatic.lcc.dto.configuration.countries.view.CountryViewDTO;
|
||||
import de.avatic.lcc.dto.configuration.countries.update.CountryUpdateDTO;
|
||||
import de.avatic.lcc.dto.generic.CountryDTO;
|
||||
import de.avatic.lcc.model.properties.CountryProperty;
|
||||
import de.avatic.lcc.model.properties.CountryPropertyType;
|
||||
import de.avatic.lcc.model.properties.PropertySet;
|
||||
import de.avatic.lcc.repositories.properties.CountryPropertiesRepository;
|
||||
import de.avatic.lcc.repositories.country.CountryRepository;
|
||||
import de.avatic.lcc.repositories.CountryRepository;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryPagination;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import de.avatic.lcc.repositories.properties.SystemPropertiesRepository;
|
||||
import de.avatic.lcc.service.transformer.CountryTransformerService;
|
||||
import de.avatic.lcc.service.transformer.country.CountryTransformerService;
|
||||
import de.avatic.lcc.service.transformer.generic.CountryDTOTransformer;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
|
@ -25,38 +25,28 @@ public class CountryService {
|
|||
private final CountryTransformerService countryTransformerService;
|
||||
private final CountryPropertiesRepository countryPropertiesRepository;
|
||||
private final SystemPropertiesRepository systemPropertiesRepository;
|
||||
private final CountryDTOTransformer countryDTOTransformer;
|
||||
|
||||
public CountryService(CountryRepository countryRepository, CountryTransformerService countryTransformerService, CountryPropertiesRepository countryPropertiesRepository, SystemPropertiesRepository systemPropertiesRepository) {
|
||||
public CountryService(CountryRepository countryRepository, CountryTransformerService countryTransformerService, CountryPropertiesRepository countryPropertiesRepository, SystemPropertiesRepository systemPropertiesRepository, CountryDTOTransformer countryDTOTransformer) {
|
||||
this.countryRepository = countryRepository;
|
||||
this.countryTransformerService = countryTransformerService;
|
||||
this.countryPropertiesRepository = countryPropertiesRepository;
|
||||
this.systemPropertiesRepository = systemPropertiesRepository;
|
||||
this.countryDTOTransformer = countryDTOTransformer;
|
||||
}
|
||||
|
||||
public SearchQueryResult<CountryListGetDTO> listMaterial(String filter, int page, int limit) {
|
||||
SearchQueryResult<Country> queryResult = countryRepository.listCountries(filter, true, new SearchQueryPagination(page, limit));
|
||||
|
||||
List<CountryListGetDTO> dto = queryResult.toList().stream().map(country -> {
|
||||
CountryListGetDTO dtoEntry = new CountryListGetDTO();
|
||||
|
||||
dtoEntry.setId(country.getId());
|
||||
dtoEntry.setIsoCode(country.getIsoCode().getCode());
|
||||
dtoEntry.setName(country.getIsoCode().getFullName());
|
||||
dtoEntry.setRegionCode(country.getRegionCode().getCode());
|
||||
|
||||
return dtoEntry;
|
||||
}).toList();
|
||||
|
||||
return new SearchQueryResult<>(dto, queryResult.getPage(), queryResult.getTotalElements(), queryResult.getElementsPerPage() );
|
||||
public SearchQueryResult<CountryDTO> listCountries(String filter, int page, int limit) {
|
||||
return SearchQueryResult.map(countryRepository.listCountries(filter, true, new SearchQueryPagination(page, limit)), countryDTOTransformer::toCountryDTO);
|
||||
}
|
||||
|
||||
public CountryGetDTO getCountry(Integer id) {
|
||||
@Transactional
|
||||
public CountryViewDTO getCountry(Integer id) {
|
||||
List<CountryProperty> properties = countryPropertiesRepository.listByCountryId(id);
|
||||
return countryTransformerService.convertToCountryGetDTO(countryRepository.getById(id), properties).orElseThrow();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateCountry(Integer id, CountryPostDTO dto) {
|
||||
public void updateCountry(Integer id, CountryUpdateDTO dto) {
|
||||
List<CountryPropertyType> types = countryPropertiesRepository.listTypes();
|
||||
PropertySet set = systemPropertiesRepository.getDraftSet();
|
||||
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package de.avatic.lcc.service.configuration;
|
||||
|
||||
import de.avatic.lcc.dto.configuration.material.view.MaterialViewDTO;
|
||||
import de.avatic.lcc.dto.configuration.material.update.MaterialUpdateDTO;
|
||||
import de.avatic.lcc.model.materials.Material;
|
||||
import de.avatic.lcc.dto.generic.MaterialDTO;
|
||||
import de.avatic.lcc.repositories.CountryRepository;
|
||||
import de.avatic.lcc.repositories.MaterialRepository;
|
||||
import de.avatic.lcc.repositories.NodeRepository;
|
||||
import de.avatic.lcc.repositories.packaging.PackagingDimensionRepository;
|
||||
import de.avatic.lcc.repositories.packaging.PackagingRepository;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryPagination;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import de.avatic.lcc.service.transformer.material.MaterialUpdateDTOTransformer;
|
||||
import de.avatic.lcc.service.transformer.material.MaterialViewDTOTransformer;
|
||||
import de.avatic.lcc.service.transformer.generic.DimensionDTOTransformer;
|
||||
import de.avatic.lcc.service.transformer.generic.MaterialDTOTransformer;
|
||||
import de.avatic.lcc.service.transformer.generic.NodeDTOTransformer;
|
||||
import de.avatic.lcc.util.exception.clienterror.MaterialNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MaterialService {
|
||||
|
||||
private final MaterialUpdateDTOTransformer materialUpdateDTOTransformer;
|
||||
private final PackagingRepository packagingRepository;
|
||||
private final CountryRepository countryRepository;
|
||||
private final NodeRepository nodeRepository;
|
||||
private final PackagingDimensionRepository packagingDimensionRepository;
|
||||
private final MaterialRepository materialRepository;
|
||||
private final MaterialDTOTransformer materialDTOTransformer;
|
||||
private final DimensionDTOTransformer dimensionDTOTransformer;
|
||||
private final NodeDTOTransformer nodeDTOTransformer;
|
||||
private final MaterialViewDTOTransformer materialViewDTOTransformer;
|
||||
|
||||
public MaterialService(MaterialRepository materialRepository, MaterialUpdateDTOTransformer materialUpdateDTOTransformer, PackagingRepository packagingRepository, CountryRepository countryRepository, NodeRepository nodeRepository, PackagingDimensionRepository packagingDimensionRepository, MaterialDTOTransformer materialDTOTransformer, DimensionDTOTransformer dimensionDTOTransformer, NodeDTOTransformer nodeDTOTransformer, MaterialViewDTOTransformer materialViewDTOTransformer) {
|
||||
this.materialRepository = materialRepository;
|
||||
this.materialUpdateDTOTransformer = materialUpdateDTOTransformer;
|
||||
this.packagingRepository = packagingRepository;
|
||||
this.countryRepository = countryRepository;
|
||||
this.nodeRepository = nodeRepository;
|
||||
this.packagingDimensionRepository = packagingDimensionRepository;
|
||||
this.materialDTOTransformer = materialDTOTransformer;
|
||||
this.dimensionDTOTransformer = dimensionDTOTransformer;
|
||||
this.nodeDTOTransformer = nodeDTOTransformer;
|
||||
this.materialViewDTOTransformer = materialViewDTOTransformer;
|
||||
}
|
||||
|
||||
public SearchQueryResult<MaterialDTO> listMaterial(String filter, int page, int limit) {
|
||||
SearchQueryResult<Material> queryResult = materialRepository.listMaterials(filter, true, new SearchQueryPagination(page, limit));
|
||||
return SearchQueryResult.map(queryResult, materialDTOTransformer::toMaterialDTO);
|
||||
}
|
||||
|
||||
public MaterialViewDTO getMaterial(Integer id) {
|
||||
return materialViewDTOTransformer.toMaterialViewDTO(materialRepository.getById(id).orElseThrow(() -> new MaterialNotFoundException(id)));
|
||||
}
|
||||
|
||||
public Integer updateMaterial(Integer id, MaterialUpdateDTO dto) {
|
||||
return materialRepository.update(materialUpdateDTOTransformer.fromMaterialUpdateDTO(dto)).orElseThrow(() -> new MaterialNotFoundException(id));
|
||||
}
|
||||
|
||||
public Integer createMaterial(MaterialUpdateDTO dto) {
|
||||
return materialRepository.create(materialUpdateDTOTransformer.fromMaterialUpdateDTO(dto)).orElseThrow(() -> new RuntimeException("Unable to create Material " + dto));
|
||||
}
|
||||
|
||||
public Integer deleteMaterial(Integer id) {
|
||||
return materialRepository.setDeprecatedById(id).orElseThrow(() -> new MaterialNotFoundException(id));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package de.avatic.lcc.service.configuration;
|
||||
|
||||
import de.avatic.lcc.dto.generic.NodeDTO;
|
||||
import de.avatic.lcc.dto.configuration.nodes.view.NodeViewDTO;
|
||||
import de.avatic.lcc.dto.configuration.nodes.update.NodeUpdateDTO;
|
||||
import de.avatic.lcc.repositories.NodeRepository;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryPagination;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import de.avatic.lcc.service.transformer.nodes.NodeUpdateDTOTransformer;
|
||||
import de.avatic.lcc.service.transformer.nodes.NodeViewDTOTransformer;
|
||||
import de.avatic.lcc.service.transformer.generic.NodeDTOTransformer;
|
||||
import de.avatic.lcc.util.exception.clienterror.NodeNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class NodeService {
|
||||
|
||||
private final NodeRepository nodeRepository;
|
||||
private final NodeDTOTransformer nodeDTOTransformer;
|
||||
private final NodeViewDTOTransformer nodeViewDTOTransformer;
|
||||
private final NodeUpdateDTOTransformer nodeUpdateDTOTransformer;
|
||||
|
||||
public NodeService(NodeRepository nodeRepository, NodeDTOTransformer nodeDTOTransformer, NodeViewDTOTransformer nodeViewDTOTransformer, NodeUpdateDTOTransformer nodeUpdateDTOTransformer) {
|
||||
this.nodeRepository = nodeRepository;
|
||||
this.nodeDTOTransformer = nodeDTOTransformer;
|
||||
this.nodeViewDTOTransformer = nodeViewDTOTransformer;
|
||||
this.nodeUpdateDTOTransformer = nodeUpdateDTOTransformer;
|
||||
}
|
||||
|
||||
public SearchQueryResult<NodeDTO> listNodes(String filter, int page, int limit) {
|
||||
return SearchQueryResult.map(nodeRepository.listNodes(filter, true, new SearchQueryPagination(page, limit)), nodeDTOTransformer::toNodeDTO);
|
||||
}
|
||||
|
||||
public SearchQueryResult<NodeViewDTO> listNodesView(String filter, int page, int limit) {
|
||||
return SearchQueryResult.map(nodeRepository.listNodes(filter, true, new SearchQueryPagination(page, limit)), nodeViewDTOTransformer::toNodeViewDTO);
|
||||
}
|
||||
|
||||
public NodeViewDTO getNode(Integer id) {
|
||||
return nodeViewDTOTransformer.toNodeViewDTO(nodeRepository.getById(id).orElseThrow(() -> new NodeNotFoundException(id)));
|
||||
}
|
||||
|
||||
public Integer deleteNode(Integer id) {
|
||||
return nodeRepository.setDeprecatedById(id).orElseThrow(() -> new NodeNotFoundException(id));
|
||||
}
|
||||
|
||||
public Integer updateNode(NodeUpdateDTO dto) {
|
||||
return nodeRepository.update(nodeUpdateDTOTransformer.fromNodeUpdateDTO(dto)).orElseThrow(() -> new NodeNotFoundException(dto.getId()));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package de.avatic.lcc.service;
|
||||
package de.avatic.lcc.service.configuration;
|
||||
|
||||
import de.avatic.lcc.dto.packaging.get.PackagingGetDTO;
|
||||
import de.avatic.lcc.dto.packaging.post.PackagingPostDTO;
|
||||
import de.avatic.lcc.dto.configuration.packaging.update.PackagingUpdateDTO;
|
||||
import de.avatic.lcc.dto.configuration.packaging.view.PackagingViewDTO;
|
||||
import de.avatic.lcc.model.country.Country;
|
||||
import de.avatic.lcc.model.materials.Material;
|
||||
import de.avatic.lcc.model.nodes.Node;
|
||||
|
|
@ -9,19 +9,18 @@ import de.avatic.lcc.model.packaging.Packaging;
|
|||
import de.avatic.lcc.model.packaging.PackagingDimension;
|
||||
import de.avatic.lcc.model.packaging.PackagingProperty;
|
||||
import de.avatic.lcc.model.packaging.PackagingPropertyType;
|
||||
import de.avatic.lcc.model.properties.CountryPropertyType;
|
||||
import de.avatic.lcc.model.properties.PropertySet;
|
||||
import de.avatic.lcc.repositories.CountryRepository;
|
||||
import de.avatic.lcc.repositories.MaterialRepository;
|
||||
import de.avatic.lcc.repositories.NodeRepository;
|
||||
import de.avatic.lcc.repositories.country.CountryRepository;
|
||||
import de.avatic.lcc.repositories.packaging.PackagingDimensionRepository;
|
||||
import de.avatic.lcc.repositories.packaging.PackagingRepository;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryPagination;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import de.avatic.lcc.repositories.properties.PackagingPropertiesRepository;
|
||||
import de.avatic.lcc.service.transformer.DimensionTransformerService;
|
||||
import de.avatic.lcc.service.transformer.NodeTransformerService;
|
||||
import de.avatic.lcc.service.transformer.PackagingTransformerService;
|
||||
import de.avatic.lcc.service.transformer.packaging.PackagingTransformerService;
|
||||
import de.avatic.lcc.service.transformer.generic.DimensionDTOTransformer;
|
||||
import de.avatic.lcc.service.transformer.generic.MaterialDTOTransformer;
|
||||
import de.avatic.lcc.service.transformer.generic.NodeDTOTransformer;
|
||||
import de.avatic.lcc.util.Check;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -38,8 +37,11 @@ public class PackagingService {
|
|||
private final CountryRepository countryRepository;
|
||||
private final PackagingTransformerService packagingTransformerService;
|
||||
private final PackagingPropertiesRepository packagingPropertiesRepository;
|
||||
private final MaterialDTOTransformer materialDTOTransformer;
|
||||
private final NodeDTOTransformer nodeDTOTransformer;
|
||||
private final DimensionDTOTransformer dimensionDTOTransformer;
|
||||
|
||||
public PackagingService(PackagingRepository packagingRepository, PackagingDimensionRepository packagingDimensionRepository, NodeRepository nodeRepository, MaterialRepository materialRepository, DimensionTransformerService dimensionTransformerService, NodeTransformerService nodeTransformerService, CountryRepository countryRepository, PackagingTransformerService packagingTransformerService, PackagingPropertiesRepository packagingPropertiesRepository) {
|
||||
public PackagingService(PackagingRepository packagingRepository, PackagingDimensionRepository packagingDimensionRepository, NodeRepository nodeRepository, MaterialRepository materialRepository, CountryRepository countryRepository, PackagingTransformerService packagingTransformerService, PackagingPropertiesRepository packagingPropertiesRepository, MaterialDTOTransformer materialDTOTransformer, NodeDTOTransformer nodeDTOTransformer, DimensionDTOTransformer dimensionDTOTransformer) {
|
||||
this.packagingRepository = packagingRepository;
|
||||
this.packagingDimensionRepository = packagingDimensionRepository;
|
||||
this.nodeRepository = nodeRepository;
|
||||
|
|
@ -47,33 +49,29 @@ public class PackagingService {
|
|||
this.countryRepository = countryRepository;
|
||||
this.packagingTransformerService = packagingTransformerService;
|
||||
this.packagingPropertiesRepository = packagingPropertiesRepository;
|
||||
this.materialDTOTransformer = materialDTOTransformer;
|
||||
this.nodeDTOTransformer = nodeDTOTransformer;
|
||||
this.dimensionDTOTransformer = dimensionDTOTransformer;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public SearchQueryResult<PackagingGetDTO> listPackaging(Integer materialId, Integer supplierId, int page, int limit) {
|
||||
SearchQueryResult<Packaging> queryResult = packagingRepository.listPackaging(materialId, supplierId, true, new SearchQueryPagination(page, limit));
|
||||
|
||||
List<PackagingGetDTO> dto = queryResult.toList().stream().map(packaging -> {
|
||||
PackagingGetDTO dtoEntry = new PackagingGetDTO();
|
||||
public SearchQueryResult<PackagingViewDTO> listPackaging(Integer materialId, Integer supplierId, int page, int limit) {
|
||||
return SearchQueryResult.map(packagingRepository.listPackaging(materialId, supplierId, true, new SearchQueryPagination(page, limit)), this::toPackagingGetDTO);
|
||||
}
|
||||
|
||||
private PackagingViewDTO toPackagingGetDTO(Packaging packaging) {
|
||||
PackagingViewDTO dtoEntry = new PackagingViewDTO();
|
||||
Optional<Node> node = nodeRepository.getById(packaging.getSupplierId());
|
||||
Optional<Country> country = countryRepository.getById(node.orElseThrow().getCountryId());
|
||||
Optional<Material> material = materialRepository.getById(packaging.getMaterialId());
|
||||
|
||||
dtoEntry.setHu(packagingTransformerService.convertToPackagingDimensionDTO(packagingDimensionRepository.getById(packaging.getHuId())).orElseThrow());
|
||||
dtoEntry.setShu(packagingTransformerService.convertToPackagingDimensionDTO(packagingDimensionRepository.getById(packaging.getShuId())).orElseThrow());
|
||||
dtoEntry.setSupplier(packagingTransformerService.convertToPackagingSupplierDTO(node, country).orElseThrow());
|
||||
dtoEntry.setMaterial(packagingTransformerService.convertToPackagingMaterialDTO(material).orElseThrow());
|
||||
|
||||
dtoEntry.setHu(dimensionDTOTransformer.toDimensionDTO(packagingDimensionRepository.getById(packaging.getHuId()).orElseThrow()));
|
||||
dtoEntry.setShu(dimensionDTOTransformer.toDimensionDTO(packagingDimensionRepository.getById(packaging.getShuId()).orElseThrow()));
|
||||
dtoEntry.setSupplier(nodeDTOTransformer.toNodeDTO(node.orElseThrow()));
|
||||
dtoEntry.setMaterial(materialDTOTransformer.toMaterialDTO(material.orElseThrow()));
|
||||
return dtoEntry;
|
||||
|
||||
}).toList();
|
||||
|
||||
return new SearchQueryResult<>(dto, queryResult.getPage(), queryResult.getTotalElements(), queryResult.getElementsPerPage());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public PackagingGetDTO getPackaging(Integer id) {
|
||||
public PackagingViewDTO getPackaging(Integer id) {
|
||||
|
||||
Optional<Packaging> packaging = packagingRepository.getById(id);
|
||||
Optional<Material> material = materialRepository.getById(packaging.orElseThrow().getMaterialId());
|
||||
|
|
@ -88,7 +86,7 @@ public class PackagingService {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public void updatePackaging(Integer id, PackagingPostDTO dto) {
|
||||
public void updatePackaging(Integer id, PackagingUpdateDTO dto) {
|
||||
|
||||
Optional<Packaging> entity = packagingRepository.getById(id);
|
||||
if (entity.isEmpty()) throw new RuntimeException("Packaging does not exists " + id);
|
||||
|
|
@ -98,8 +96,8 @@ public class PackagingService {
|
|||
Check.equals(dto.getHu().getId(), entity.get().getHuId());
|
||||
Check.equals(dto.getId(), id);
|
||||
|
||||
packagingDimensionRepository.update(packagingTransformerService.convertFromPackagingDimensionPostDTO(dto.getHu()));
|
||||
packagingDimensionRepository.update(packagingTransformerService.convertFromPackagingDimensionPostDTO(dto.getShu()));
|
||||
packagingDimensionRepository.update(dimensionDTOTransformer.toDimensionEntity(dto.getHu()));
|
||||
packagingDimensionRepository.update(dimensionDTOTransformer.toDimensionEntity(dto.getShu()));
|
||||
|
||||
List<PackagingPropertyType> types = packagingPropertiesRepository.listTypes();
|
||||
|
||||
|
|
@ -119,10 +117,10 @@ public class PackagingService {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public Integer createPackaging(PackagingPostDTO dto) {
|
||||
public Integer createPackaging(PackagingUpdateDTO dto) {
|
||||
|
||||
Optional<Integer> huId = packagingDimensionRepository.insert(packagingTransformerService.convertFromPackagingDimensionPostDTO(dto.getHu()));
|
||||
Optional<Integer> shuId = packagingDimensionRepository.insert(packagingTransformerService.convertFromPackagingDimensionPostDTO(dto.getShu()));
|
||||
Optional<Integer> huId = packagingDimensionRepository.insert(dimensionDTOTransformer.toDimensionEntity(dto.getHu()));
|
||||
Optional<Integer> shuId = packagingDimensionRepository.insert(dimensionDTOTransformer.toDimensionEntity(dto.getShu()));
|
||||
|
||||
Packaging entity = packagingTransformerService.convertFromPackagingPostDTO(dto);
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package de.avatic.lcc.service;
|
||||
package de.avatic.lcc.service.configuration;
|
||||
|
||||
import de.avatic.lcc.dto.properties.post.PropertiesPostDTO;
|
||||
import de.avatic.lcc.dto.configuration.properties.post.PropertiesPostDTO;
|
||||
import de.avatic.lcc.model.properties.PropertyType;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package de.avatic.lcc.service.report;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ExcelReportingService {
|
||||
|
||||
|
||||
public ByteArrayInputStream generateExcelReport(Integer materialId, List<Integer> nodeIds) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package de.avatic.lcc.service.report;
|
||||
|
||||
|
||||
import de.avatic.lcc.dto.generic.NodeDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ReportFinderService {
|
||||
|
||||
|
||||
public List<List<NodeDTO>> findSupplierForReporting(Integer materialId) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package de.avatic.lcc.service.report;
|
||||
|
||||
import de.avatic.lcc.dto.report.ReportDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ReportingService {
|
||||
public ReportDTO getReport(Integer materialId, List<Integer> nodeIds) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package de.avatic.lcc.service.transformer;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class DimensionTransformerService {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
package de.avatic.lcc.service.transformer;
|
||||
|
||||
import de.avatic.lcc.dto.generic.NodeTypeDTO;
|
||||
import de.avatic.lcc.dto.material.get.*;
|
||||
import de.avatic.lcc.dto.material.post.MaterialPostDTO;
|
||||
import de.avatic.lcc.dto.packaging.get.PackagingCountryGetDTO;
|
||||
import de.avatic.lcc.dto.packaging.get.PackagingDimensionGetDTO;
|
||||
import de.avatic.lcc.model.country.Country;
|
||||
import de.avatic.lcc.model.materials.Material;
|
||||
import de.avatic.lcc.model.nodes.Node;
|
||||
import de.avatic.lcc.model.packaging.Packaging;
|
||||
import de.avatic.lcc.model.packaging.PackagingDimension;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class MaterialTransformerService {
|
||||
|
||||
public Material convertFromMaterialPostDTO(MaterialPostDTO dto) {
|
||||
Material entity = new Material();
|
||||
|
||||
entity.setNormalizedPartNumber(normalizePartNumber(dto.getPartNumber()));
|
||||
entity.setPartNumber(dto.getPartNumber());
|
||||
entity.setName(dto.getName());
|
||||
entity.setDeprecated(false);
|
||||
entity.setId(dto.getId());
|
||||
entity.setHsCode(dto.getHsCode());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
private String normalizePartNumber(String partNumber) {
|
||||
if (partNumber.length() > 12) throw new IllegalArgumentException("Part number must be less than 12 characters");
|
||||
return "000000000000".concat(partNumber).substring(partNumber.length());
|
||||
}
|
||||
|
||||
public Optional<MaterialGetDTO> convertToMaterialGetDTO(Optional<Material> material) {
|
||||
|
||||
if (material.isEmpty()) return Optional.empty();
|
||||
Material entity = material.get();
|
||||
|
||||
MaterialGetDTO dtoEntry = new MaterialGetDTO();
|
||||
|
||||
dtoEntry.setId(entity.getId());
|
||||
dtoEntry.setPartNumber(entity.getPartNumber());
|
||||
dtoEntry.setName(entity.getName());
|
||||
dtoEntry.setHsCode(entity.getHsCode());
|
||||
|
||||
return Optional.of(dtoEntry);
|
||||
|
||||
}
|
||||
|
||||
public MaterialListGetDTO convertToMaterialListGetDTO(Material entity) {
|
||||
|
||||
MaterialListGetDTO dtoEntry = new MaterialListGetDTO();
|
||||
|
||||
dtoEntry.setId(entity.getId());
|
||||
dtoEntry.setPartNumber(entity.getPartNumber());
|
||||
dtoEntry.setName(entity.getName());
|
||||
dtoEntry.setHsCode(entity.getHsCode());
|
||||
|
||||
return dtoEntry;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public MaterialPackagingGetDTO convertToMaterialPackagingGetDTO(Packaging entity, Optional<Node> supplier, Optional<Country> country, Optional<PackagingDimension> hu, Optional<PackagingDimension> shu) {
|
||||
|
||||
MaterialPackagingGetDTO dto = new MaterialPackagingGetDTO();
|
||||
|
||||
dto.setId(entity.getId());
|
||||
dto.setDeprecated(entity.getDeprecated());
|
||||
dto.setHu(convertToMaterialDimensionGetDTO(hu).orElseThrow());
|
||||
dto.setShu(convertToMaterialDimensionGetDTO(shu).orElseThrow());
|
||||
dto.setSupplier(convertToMaterialSupplierGetDTO(supplier, country).orElseThrow());
|
||||
|
||||
return dto;
|
||||
|
||||
}
|
||||
|
||||
private Optional<MaterialSupplierGetDTO> convertToMaterialSupplierGetDTO(Optional<Node> entity, Optional<Country> country) {
|
||||
|
||||
if(entity.isEmpty()) return Optional.empty();
|
||||
Node data = entity.get();
|
||||
|
||||
MaterialSupplierGetDTO dto = new MaterialSupplierGetDTO();
|
||||
|
||||
dto.setId(data.getId());
|
||||
dto.setAddress(data.getAddress());
|
||||
dto.setName(data.getName());
|
||||
dto.setDeprecated(data.getDeprecated());
|
||||
dto.setTypes(toNodeTypeArrayList(data));
|
||||
dto.setCountry(convertToMaterialCountryGetDTO(country).orElseThrow());
|
||||
|
||||
return Optional.of(dto);
|
||||
}
|
||||
|
||||
private Optional<MaterialCountryGetDTO> convertToMaterialCountryGetDTO(Optional<Country> country) {
|
||||
if (country.isEmpty()) return Optional.empty();
|
||||
|
||||
Country data = country.get();
|
||||
MaterialCountryGetDTO dto = new MaterialCountryGetDTO();
|
||||
|
||||
dto.setId(data.getId());
|
||||
dto.setRegionCode(data.getRegionCode().name());
|
||||
dto.setIsoCode(data.getIsoCode().name());
|
||||
|
||||
return Optional.of(dto);
|
||||
}
|
||||
|
||||
private ArrayList<NodeTypeDTO> toNodeTypeArrayList(Node entity) {
|
||||
ArrayList<NodeTypeDTO> types = new ArrayList<>();
|
||||
if (entity.getSink()) types.add(NodeTypeDTO.SINK);
|
||||
if (entity.getSource()) types.add(NodeTypeDTO.SOURCE);
|
||||
if (entity.getIntermediate()) types.add(NodeTypeDTO.INTERMEDIATE);
|
||||
return types;
|
||||
}
|
||||
|
||||
private Optional<MaterialDimensionGetDTO> convertToMaterialDimensionGetDTO(Optional<PackagingDimension> data) {
|
||||
if (data.isEmpty()) return Optional.empty();
|
||||
|
||||
PackagingDimension dimension = data.get();
|
||||
MaterialDimensionGetDTO dto = new MaterialDimensionGetDTO();
|
||||
|
||||
dto.setId(dimension.getId());
|
||||
dto.setType(dimension.getType());
|
||||
dto.setLength(dimension.getDimensionUnit().convertFromMM(dimension.getLength()).doubleValue());
|
||||
dto.setWidth(dimension.getDimensionUnit().convertFromMM(dimension.getWidth()).doubleValue());
|
||||
dto.setHeight(dimension.getDimensionUnit().convertFromMM(dimension.getHeight()).doubleValue());
|
||||
dto.setDimensionUnit(dimension.getDimensionUnit());
|
||||
dto.setWeight(dimension.getWeightUnit().convertFromG(dimension.getWeight()).doubleValue());
|
||||
dto.setWeightUnit(dimension.getWeightUnit());
|
||||
dto.setContentUnitCount(dimension.getContentUnitCount());
|
||||
dto.setDeprecated(dimension.getDeprecated());
|
||||
|
||||
return Optional.of(dto);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package de.avatic.lcc.service.transformer;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class NodeTransformerService {
|
||||
|
||||
private final CountryTransformerService countryTransformerService;
|
||||
|
||||
public NodeTransformerService(CountryTransformerService countryTransformerService) {
|
||||
this.countryTransformerService = countryTransformerService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,186 +0,0 @@
|
|||
package de.avatic.lcc.service.transformer;
|
||||
|
||||
import de.avatic.lcc.dto.generic.NodeTypeDTO;
|
||||
import de.avatic.lcc.dto.packaging.get.*;
|
||||
import de.avatic.lcc.dto.packaging.post.PackagingDimensionPostDTO;
|
||||
import de.avatic.lcc.dto.packaging.post.PackagingPostDTO;
|
||||
import de.avatic.lcc.model.country.Country;
|
||||
import de.avatic.lcc.model.materials.Material;
|
||||
import de.avatic.lcc.model.nodes.Node;
|
||||
import de.avatic.lcc.model.packaging.Packaging;
|
||||
import de.avatic.lcc.model.packaging.PackagingDimension;
|
||||
import de.avatic.lcc.model.packaging.PackagingProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class PackagingTransformerService {
|
||||
|
||||
|
||||
public Optional<PackagingDimensionGetDTO> convertToPackagingDimensionDTO(Optional<PackagingDimension> data) {
|
||||
|
||||
if (data.isEmpty()) return Optional.empty();
|
||||
|
||||
PackagingDimension dimension = data.get();
|
||||
PackagingDimensionGetDTO dto = new PackagingDimensionGetDTO();
|
||||
|
||||
dto.setId(dimension.getId());
|
||||
dto.setType(dimension.getType());
|
||||
dto.setLength(dimension.getDimensionUnit().convertFromMM(dimension.getLength()).doubleValue());
|
||||
dto.setWidth(dimension.getDimensionUnit().convertFromMM(dimension.getWidth()).doubleValue());
|
||||
dto.setHeight(dimension.getDimensionUnit().convertFromMM(dimension.getHeight()).doubleValue());
|
||||
dto.setDimensionUnit(dimension.getDimensionUnit());
|
||||
dto.setWeight(dimension.getWeightUnit().convertFromG(dimension.getWeight()).doubleValue());
|
||||
dto.setWeightUnit(dimension.getWeightUnit());
|
||||
dto.setContentUnitCount(dimension.getContentUnitCount());
|
||||
dto.setDeprecated(dimension.getDeprecated());
|
||||
|
||||
return Optional.of(dto);
|
||||
}
|
||||
|
||||
public Optional<PackagingCountryGetDTO> convertToPackagingCountryDTO(Optional<Country> country) {
|
||||
|
||||
if (country.isEmpty()) return Optional.empty();
|
||||
|
||||
Country data = country.get();
|
||||
PackagingCountryGetDTO dto = new PackagingCountryGetDTO();
|
||||
|
||||
dto.setId(data.getId());
|
||||
dto.setRegionCode(data.getRegionCode().name());
|
||||
dto.setIsoCode(data.getIsoCode().name());
|
||||
|
||||
return Optional.of(dto);
|
||||
}
|
||||
|
||||
|
||||
public Optional<PackagingSupplierGetDTO> convertToPackagingSupplierDTO(Optional<Node> node, Optional<Country> country) {
|
||||
|
||||
if (node.isEmpty() || country.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
Node data = node.get();
|
||||
PackagingSupplierGetDTO dto = new PackagingSupplierGetDTO();
|
||||
|
||||
ArrayList<NodeTypeDTO> types = new ArrayList<>();
|
||||
if (data.getSink()) types.add(NodeTypeDTO.SINK);
|
||||
if (data.getSource()) types.add(NodeTypeDTO.SOURCE);
|
||||
if (data.getIntermediate()) types.add(NodeTypeDTO.INTERMEDIATE);
|
||||
|
||||
dto.setId(data.getId());
|
||||
dto.setName(data.getName());
|
||||
dto.setAddress(data.getAddress());
|
||||
dto.setCountry(convertToPackagingCountryDTO(country).orElseThrow());
|
||||
dto.setTypes(types);
|
||||
dto.setDeprecated(data.getDeprecated());
|
||||
|
||||
return Optional.of(dto);
|
||||
}
|
||||
|
||||
|
||||
public Optional<PackagingMaterialGetDTO> convertToPackagingMaterialDTO(Optional<Material> material) {
|
||||
if(material.isEmpty()) return Optional.empty();
|
||||
|
||||
Material data = material.get();
|
||||
var dto = new PackagingMaterialGetDTO();
|
||||
|
||||
dto.setName(data.getName());
|
||||
dto.setHsCode(data.getHsCode());
|
||||
dto.setPartNumber(data.getPartNumber());
|
||||
dto.setId(data.getId());
|
||||
|
||||
return Optional.of(dto);
|
||||
}
|
||||
|
||||
public Optional<PackagingGetDTO> convertToPackagingGetDTO(Optional<Packaging> packaging, Optional<Material> material, Optional<Node> supplier, Optional<Country> country, Optional<PackagingDimension> hu, Optional<PackagingDimension> shu, List<PackagingProperty> properties) {
|
||||
if(packaging.isEmpty()) return Optional.empty();
|
||||
|
||||
Packaging data = packaging.get();
|
||||
var dto = new PackagingGetDTO();
|
||||
|
||||
dto.setId(data.getId());
|
||||
dto.setMaterial(convertToPackagingMaterialDTO(material).orElseThrow());
|
||||
dto.setSupplier(convertToPackagingSupplierDTO(supplier, country).orElseThrow());
|
||||
dto.setHu(convertToPackagingDimensionDTO(hu).orElseThrow());
|
||||
dto.setShu(convertToPackagingDimensionDTO(shu).orElseThrow());
|
||||
dto.setDeprecated(data.getDeprecated());
|
||||
dto.setProperties(properties.stream().map(this::convertToPackagingPropertyGetDTO).toList());
|
||||
|
||||
return Optional.of(dto);
|
||||
}
|
||||
|
||||
private PackagingPropertyGetDTO convertToPackagingPropertyGetDTO(PackagingProperty property) {
|
||||
PackagingPropertyGetDTO dto = new PackagingPropertyGetDTO();
|
||||
|
||||
dto.setCurrentValue(property.getPropertyValue());
|
||||
dto.setDataType(property.getPackagingPropertyType().getDataType().name());
|
||||
dto.setRequired(property.getPackagingPropertyType().getRequired());
|
||||
dto.setName(property.getPackagingPropertyType().getName());
|
||||
dto.setExternalMappingId(property.getPackagingPropertyType().getExternalMappingId());
|
||||
dto.setValidationRule(property.getPackagingPropertyType().getValidationRule());
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
public Packaging convertFromPackagingPostDTO(PackagingPostDTO dto) {
|
||||
|
||||
var entity = new Packaging();
|
||||
entity.setId(dto.getId());
|
||||
entity.setDeprecated(dto.getDeprecated());
|
||||
entity.setSupplierId(dto.getSupplierId());
|
||||
entity.setMaterialId(dto.getMaterialId());
|
||||
entity.setHuId(dto.getHu().getId());
|
||||
entity.setShuId(dto.getShu().getId());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public PackagingDimension convertFromPackagingDimensionGetDTO(PackagingDimensionGetDTO dto) {
|
||||
|
||||
var entity = new PackagingDimension();
|
||||
entity.setId(dto.getId());
|
||||
entity.setType(dto.getType());
|
||||
entity.setLength(dto.getDimensionUnit().convertToMM(dto.getLength()).intValue());
|
||||
entity.setWidth(dto.getDimensionUnit().convertToMM(dto.getWidth()).intValue());
|
||||
entity.setHeight(dto.getDimensionUnit().convertToMM(dto.getHeight()).intValue());
|
||||
entity.setDimensionUnit(dto.getDimensionUnit());
|
||||
entity.setWeight(dto.getWeightUnit().convertToG(dto.getWeight()).intValue());
|
||||
entity.setWeightUnit(dto.getWeightUnit());
|
||||
entity.setContentUnitCount(dto.getContentUnitCount());
|
||||
entity.setDeprecated(dto.getDeprecated());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public PackagingDimension convertFromPackagingDimensionPostDTO(PackagingDimensionPostDTO dto) {
|
||||
|
||||
var entity = new PackagingDimension();
|
||||
entity.setId(dto.getId());
|
||||
entity.setType(dto.getType());
|
||||
entity.setLength(dto.getDimensionUnit().convertToMM(dto.getLength()).intValue());
|
||||
entity.setWidth(dto.getDimensionUnit().convertToMM(dto.getWidth()).intValue());
|
||||
entity.setHeight(dto.getDimensionUnit().convertToMM(dto.getHeight()).intValue());
|
||||
entity.setDimensionUnit(dto.getDimensionUnit());
|
||||
entity.setWeight(dto.getWeightUnit().convertToG(dto.getWeight()).intValue());
|
||||
entity.setWeightUnit(dto.getWeightUnit());
|
||||
entity.setContentUnitCount(dto.getContentUnitCount());
|
||||
entity.setDeprecated(dto.getDeprecated());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
public List<PackagingProperty> convertFromPackagingPropertyPostDTO(PackagingPropertiesPostDTO properties) {
|
||||
|
||||
return properties.stream().map(p -> {
|
||||
PackagingProperty entity = new PackagingProperty();
|
||||
|
||||
entity.set();
|
||||
|
||||
}).toList()
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package de.avatic.lcc.service.transformer;
|
||||
package de.avatic.lcc.service.transformer.country;
|
||||
|
||||
|
||||
import de.avatic.lcc.dto.countries.get.CountryGetDTO;
|
||||
import de.avatic.lcc.dto.countries.get.CountryPropertyGetDTO;
|
||||
import de.avatic.lcc.dto.configuration.countries.view.CountryViewDTO;
|
||||
import de.avatic.lcc.dto.configuration.countries.view.CountryViewPropertyDTO;
|
||||
import de.avatic.lcc.model.country.Country;
|
||||
import de.avatic.lcc.model.properties.CountryProperty;
|
||||
import de.avatic.lcc.model.properties.PropertySetState;
|
||||
|
|
@ -15,11 +15,11 @@ import java.util.Optional;
|
|||
public class CountryTransformerService {
|
||||
|
||||
|
||||
public Optional<CountryGetDTO> convertToCountryGetDTO(Optional<Country> country, List<CountryProperty> properties) {
|
||||
public Optional<CountryViewDTO> convertToCountryGetDTO(Optional<Country> country, List<CountryProperty> properties) {
|
||||
|
||||
if (country.isEmpty()) return Optional.empty();
|
||||
|
||||
CountryGetDTO dto = new CountryGetDTO();
|
||||
CountryViewDTO dto = new CountryViewDTO();
|
||||
Country entity = country.get();
|
||||
|
||||
dto.setIsoCode(entity.getIsoCode().getCode());
|
||||
|
|
@ -28,7 +28,7 @@ public class CountryTransformerService {
|
|||
dto.setId(entity.getId());
|
||||
|
||||
dto.setProperties(properties.stream().filter(p -> p.getPropertySet().getState().equals(PropertySetState.VALID)).map(p -> {
|
||||
CountryPropertyGetDTO dtoEntry = new CountryPropertyGetDTO();
|
||||
CountryViewPropertyDTO dtoEntry = new CountryViewPropertyDTO();
|
||||
|
||||
Optional<CountryProperty> draft = properties.stream().filter(d -> d.getPropertySet().getState().equals(PropertySetState.DRAFT) && d.getType().getExternalMappingId().equals(p.getType().getExternalMappingId())).findFirst();
|
||||
|
||||
|
|
@ -47,4 +47,7 @@ public class CountryTransformerService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package de.avatic.lcc.service.transformer.generic;
|
||||
|
||||
import de.avatic.lcc.dto.generic.CountryDTO;
|
||||
import de.avatic.lcc.model.country.Country;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class CountryDTOTransformer {
|
||||
|
||||
public CountryDTO toCountryDTO(Country entity) {
|
||||
|
||||
CountryDTO dto = new CountryDTO();
|
||||
|
||||
dto.setIsoCode(entity.getIsoCode().getCode());
|
||||
dto.setRegionCode(entity.getRegionCode().getCode());
|
||||
dto.setName(entity.getIsoCode().getFullName());
|
||||
dto.setId(entity.getId());
|
||||
|
||||
return dto;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package de.avatic.lcc.service.transformer.generic;
|
||||
|
||||
import de.avatic.lcc.dto.generic.DimensionDTO;
|
||||
import de.avatic.lcc.model.packaging.PackagingDimension;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class DimensionDTOTransformer {
|
||||
|
||||
public DimensionDTO toDimensionDTO(PackagingDimension entity) {
|
||||
DimensionDTO dto = new DimensionDTO();
|
||||
|
||||
dto.setId(entity.getId());
|
||||
dto.setType(entity.getType());
|
||||
dto.setLength(entity.getDimensionUnit().convertFromMM(entity.getLength()).doubleValue());
|
||||
dto.setWidth(entity.getDimensionUnit().convertFromMM(entity.getWidth()).doubleValue());
|
||||
dto.setHeight(entity.getDimensionUnit().convertFromMM(entity.getHeight()).doubleValue());
|
||||
dto.setDimensionUnit(entity.getDimensionUnit());
|
||||
dto.setWeight(entity.getWeightUnit().convertFromG(entity.getWeight()).doubleValue());
|
||||
dto.setWeightUnit(entity.getWeightUnit());
|
||||
dto.setContentUnitCount(entity.getContentUnitCount());
|
||||
dto.setDeprecated(entity.getDeprecated());
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
public PackagingDimension toDimensionEntity(DimensionDTO dto) {
|
||||
var entity = new PackagingDimension();
|
||||
entity.setId(dto.getId());
|
||||
entity.setType(dto.getType());
|
||||
entity.setLength(dto.getDimensionUnit().convertToMM(dto.getLength()).intValue());
|
||||
entity.setWidth(dto.getDimensionUnit().convertToMM(dto.getWidth()).intValue());
|
||||
entity.setHeight(dto.getDimensionUnit().convertToMM(dto.getHeight()).intValue());
|
||||
entity.setDimensionUnit(dto.getDimensionUnit());
|
||||
entity.setWeight(dto.getWeightUnit().convertToG(dto.getWeight()).intValue());
|
||||
entity.setWeightUnit(dto.getWeightUnit());
|
||||
entity.setContentUnitCount(dto.getContentUnitCount());
|
||||
entity.setDeprecated(dto.getDeprecated());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package de.avatic.lcc.service.transformer.generic;
|
||||
|
||||
import de.avatic.lcc.dto.generic.LocationDTO;
|
||||
import de.avatic.lcc.model.nodes.Node;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class LocationDTOTransformer {
|
||||
public LocationDTO toLocationDTO(Node entity) {
|
||||
return new LocationDTO(entity.getGeoLat().doubleValue(), entity.getGeoLng().doubleValue());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package de.avatic.lcc.service.transformer.generic;
|
||||
|
||||
import de.avatic.lcc.dto.generic.MaterialDTO;
|
||||
import de.avatic.lcc.model.materials.Material;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MaterialDTOTransformer {
|
||||
|
||||
public MaterialDTO toMaterialDTO(Material entity) {
|
||||
|
||||
MaterialDTO dtoEntry = new MaterialDTO();
|
||||
|
||||
dtoEntry.setId(entity.getId());
|
||||
dtoEntry.setPartNumber(entity.getPartNumber());
|
||||
dtoEntry.setName(entity.getName());
|
||||
dtoEntry.setHsCode(entity.getHsCode());
|
||||
|
||||
return dtoEntry;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package de.avatic.lcc.service.transformer.generic;
|
||||
|
||||
import de.avatic.lcc.dto.generic.NodeDTO;
|
||||
import de.avatic.lcc.dto.generic.NodeTypeDTO;
|
||||
import de.avatic.lcc.model.nodes.Node;
|
||||
import de.avatic.lcc.repositories.CountryRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Service
|
||||
public class NodeDTOTransformer {
|
||||
|
||||
private final CountryDTOTransformer countryTransformerService;
|
||||
private final CountryRepository countryRepository;
|
||||
private final LocationDTOTransformer locationDTOTransformer;
|
||||
|
||||
public NodeDTOTransformer(CountryDTOTransformer countryTransformerService, CountryRepository countryRepository, LocationDTOTransformer locationDTOTransformer) {
|
||||
this.countryTransformerService = countryTransformerService;
|
||||
this.countryRepository = countryRepository;
|
||||
this.locationDTOTransformer = locationDTOTransformer;
|
||||
}
|
||||
|
||||
public NodeDTO toNodeDTO(Node entity) {
|
||||
NodeDTO dto = new NodeDTO();
|
||||
|
||||
ArrayList<NodeTypeDTO> types = new ArrayList<>();
|
||||
if (entity.getSink()) types.add(NodeTypeDTO.SINK);
|
||||
if (entity.getSource()) types.add(NodeTypeDTO.SOURCE);
|
||||
if (entity.getIntermediate()) types.add(NodeTypeDTO.INTERMEDIATE);
|
||||
|
||||
dto.setId(entity.getId());
|
||||
dto.setName(entity.getName());
|
||||
dto.setAddress(entity.getAddress());
|
||||
dto.setCountry(countryTransformerService.toCountryDTO(countryRepository.getById(entity.getCountryId())).orElseThrow());
|
||||
dto.setTypes(types);
|
||||
dto.setDeprecated(entity.getDeprecated());
|
||||
dto.setLocation(locationDTOTransformer.toLocationDTO(entity));
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package de.avatic.lcc.service.transformer.material;
|
||||
|
||||
import de.avatic.lcc.dto.configuration.material.update.MaterialUpdateDTO;
|
||||
import de.avatic.lcc.model.materials.Material;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MaterialUpdateDTOTransformer {
|
||||
|
||||
|
||||
public Material fromMaterialUpdateDTO(MaterialUpdateDTO dto) {
|
||||
Material entity = new Material();
|
||||
|
||||
entity.setNormalizedPartNumber(normalizePartNumber(dto.getPartNumber()));
|
||||
entity.setPartNumber(dto.getPartNumber());
|
||||
entity.setName(dto.getName());
|
||||
entity.setDeprecated(false);
|
||||
entity.setId(dto.getId());
|
||||
entity.setHsCode(dto.getHsCode());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
private String normalizePartNumber(String partNumber) {
|
||||
if (partNumber.length() > 12) throw new IllegalArgumentException("Part number must be less than 12 characters");
|
||||
return "000000000000".concat(partNumber).substring(partNumber.length());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package de.avatic.lcc.service.transformer.material;
|
||||
|
||||
import de.avatic.lcc.dto.configuration.material.view.MaterialViewDTO;
|
||||
import de.avatic.lcc.dto.configuration.material.view.MaterialViewPackagingDTO;
|
||||
import de.avatic.lcc.model.materials.Material;
|
||||
import de.avatic.lcc.repositories.packaging.PackagingRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class MaterialViewDTOTransformer {
|
||||
|
||||
private final PackagingRepository packagingRepository;
|
||||
private final MaterialViewPackagingDTOTransformer materialViewPackagingDTOTransformer;
|
||||
|
||||
public MaterialViewDTOTransformer(PackagingRepository packagingRepository, MaterialViewPackagingDTOTransformer materialViewPackagingDTOTransformer) {
|
||||
this.packagingRepository = packagingRepository;
|
||||
this.materialViewPackagingDTOTransformer = materialViewPackagingDTOTransformer;
|
||||
}
|
||||
|
||||
public MaterialViewDTO toMaterialViewDTO(Material material) {
|
||||
List<MaterialViewPackagingDTO> packaging = packagingRepository.getByMaterialId(material.getId()).stream().map(materialViewPackagingDTOTransformer::toMaterialViewPackagingDTO).toList();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package de.avatic.lcc.service.transformer.material;
|
||||
|
||||
import de.avatic.lcc.dto.configuration.material.view.MaterialViewPackagingDTO;
|
||||
import de.avatic.lcc.model.nodes.Node;
|
||||
import de.avatic.lcc.model.packaging.Packaging;
|
||||
import de.avatic.lcc.model.packaging.PackagingDimension;
|
||||
import de.avatic.lcc.repositories.NodeRepository;
|
||||
import de.avatic.lcc.repositories.packaging.PackagingDimensionRepository;
|
||||
import de.avatic.lcc.service.transformer.generic.DimensionDTOTransformer;
|
||||
import de.avatic.lcc.service.transformer.generic.NodeDTOTransformer;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class MaterialViewPackagingDTOTransformer {
|
||||
|
||||
private final NodeRepository nodeRepository;
|
||||
private final PackagingDimensionRepository packagingDimensionRepository;
|
||||
private final DimensionDTOTransformer dimensionDTOTransformer;
|
||||
private final NodeDTOTransformer nodeDTOTransformer;
|
||||
|
||||
public MaterialViewPackagingDTOTransformer(NodeRepository nodeRepository, PackagingDimensionRepository packagingDimensionRepository, DimensionDTOTransformer dimensionDTOTransformer, NodeDTOTransformer nodeDTOTransformer) {
|
||||
this.nodeRepository = nodeRepository;
|
||||
this.packagingDimensionRepository = packagingDimensionRepository;
|
||||
this.dimensionDTOTransformer = dimensionDTOTransformer;
|
||||
this.nodeDTOTransformer = nodeDTOTransformer;
|
||||
}
|
||||
|
||||
public MaterialViewPackagingDTO toMaterialViewPackagingDTO(Packaging entity) {
|
||||
Optional<Node> supplier = nodeRepository.getById(entity.getSupplierId());
|
||||
Optional<PackagingDimension> hu = packagingDimensionRepository.getById(entity.getHuId());
|
||||
Optional<PackagingDimension> shu = packagingDimensionRepository.getById(entity.getShuId());
|
||||
|
||||
MaterialViewPackagingDTO dto = new MaterialViewPackagingDTO();
|
||||
dto.setId(entity.getId());
|
||||
dto.setDeprecated(entity.getDeprecated());
|
||||
dto.setHu(dimensionDTOTransformer.toDimensionDTO(hu.orElseThrow()));
|
||||
dto.setShu(dimensionDTOTransformer.toDimensionDTO(shu.orElseThrow()));
|
||||
dto.setSupplier(nodeDTOTransformer.toNodeDTO(supplier.orElseThrow()));
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package de.avatic.lcc.service.transformer.nodes;
|
||||
|
||||
import de.avatic.lcc.dto.configuration.nodes.update.NodeUpdateDTO;
|
||||
import de.avatic.lcc.model.nodes.Node;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class NodeUpdateDTOTransformer {
|
||||
|
||||
|
||||
public Node fromNodeUpdateDTO(NodeUpdateDTO dto) {
|
||||
|
||||
Node entity = new Node();
|
||||
|
||||
entity.setId(dto.getId());
|
||||
entity.setSink(dto.get);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package de.avatic.lcc.service.transformer.nodes;
|
||||
|
||||
import de.avatic.lcc.dto.generic.NodeDTO;
|
||||
import de.avatic.lcc.dto.generic.NodeTypeDTO;
|
||||
import de.avatic.lcc.dto.configuration.nodes.view.NodeViewDTO;
|
||||
import de.avatic.lcc.model.nodes.Node;
|
||||
import de.avatic.lcc.repositories.CountryRepository;
|
||||
import de.avatic.lcc.repositories.NodeRepository;
|
||||
import de.avatic.lcc.service.transformer.generic.CountryDTOTransformer;
|
||||
import de.avatic.lcc.service.transformer.generic.LocationDTOTransformer;
|
||||
import de.avatic.lcc.service.transformer.generic.NodeDTOTransformer;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class NodeViewDTOTransformer {
|
||||
|
||||
private final CountryDTOTransformer countryDTOTransformer;
|
||||
private final CountryRepository countryRepository;
|
||||
private final LocationDTOTransformer locationDTOTransformer;
|
||||
private final NodeDTOTransformer nodeDTOTransformer;
|
||||
private final NodeRepository nodeRepository;
|
||||
|
||||
public NodeViewDTOTransformer(CountryDTOTransformer countryDTOTransformer, CountryRepository countryRepository, LocationDTOTransformer locationDTOTransformer, NodeDTOTransformer nodeDTOTransformer, NodeRepository nodeRepository) {
|
||||
this.countryDTOTransformer = countryDTOTransformer;
|
||||
this.countryRepository = countryRepository;
|
||||
this.locationDTOTransformer = locationDTOTransformer;
|
||||
this.nodeDTOTransformer = nodeDTOTransformer;
|
||||
this.nodeRepository = nodeRepository;
|
||||
}
|
||||
|
||||
public NodeViewDTO toNodeViewDTO(Node node) {
|
||||
NodeViewDTO dto = new NodeViewDTO();
|
||||
|
||||
Map<Integer, NodeDTO> predecessors = new HashMap<>();
|
||||
|
||||
for (Integer seq : node.getNodePredecessors().keySet())
|
||||
predecessors.put(seq, nodeDTOTransformer.toNodeDTO(nodeRepository.getById(node.getNodePredecessors().get(seq)).orElseThrow()));
|
||||
|
||||
dto.setId(node.getId());
|
||||
dto.setDeprecated(node.getDeprecated());
|
||||
dto.setCountry(countryDTOTransformer.toCountryDTO(countryRepository.getById(node.getCountryId()).orElseThrow()));
|
||||
dto.setName(node.getName());
|
||||
dto.setAddress(node.getAddress());
|
||||
dto.setLocation(locationDTOTransformer.toLocationDTO(node));
|
||||
dto.setTypes(toNodeTypeArrayList(node));
|
||||
dto.setPredecessors(predecessors);
|
||||
dto.setOutboundCountries(node.getOutboundCountries().stream().map(id -> countryDTOTransformer.toCountryDTO(countryRepository.getById(id).orElseThrow())).toList());
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
private ArrayList<NodeTypeDTO> toNodeTypeArrayList(Node entity) {
|
||||
ArrayList<NodeTypeDTO> types = new ArrayList<>();
|
||||
if (entity.getSink()) types.add(NodeTypeDTO.SINK);
|
||||
if (entity.getSource()) types.add(NodeTypeDTO.SOURCE);
|
||||
if (entity.getIntermediate()) types.add(NodeTypeDTO.INTERMEDIATE);
|
||||
return types;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package de.avatic.lcc.service.transformer.packaging;
|
||||
|
||||
import de.avatic.lcc.dto.configuration.packaging.view.PackagingViewDTO;
|
||||
import de.avatic.lcc.dto.configuration.packaging.update.PackagingUpdateDTO;
|
||||
import de.avatic.lcc.model.country.Country;
|
||||
import de.avatic.lcc.model.materials.Material;
|
||||
import de.avatic.lcc.model.nodes.Node;
|
||||
import de.avatic.lcc.model.packaging.Packaging;
|
||||
import de.avatic.lcc.model.packaging.PackagingDimension;
|
||||
import de.avatic.lcc.model.packaging.PackagingProperty;
|
||||
import de.avatic.lcc.service.transformer.generic.DimensionDTOTransformer;
|
||||
import de.avatic.lcc.service.transformer.generic.MaterialDTOTransformer;
|
||||
import de.avatic.lcc.service.transformer.generic.NodeDTOTransformer;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class PackagingTransformerService {
|
||||
|
||||
//TODO refactor to new format
|
||||
|
||||
private final MaterialDTOTransformer materialDTOTransformer;
|
||||
private final DimensionDTOTransformer dimensionDTOTransformer;
|
||||
private final NodeDTOTransformer nodeDTOTransformer;
|
||||
private final PackagingViewPropertyDTOTransformer packagingViewPropertyDTOTransformer;
|
||||
|
||||
public PackagingTransformerService(MaterialDTOTransformer materialDTOTransformer, DimensionDTOTransformer dimensionDTOTransformer, NodeDTOTransformer nodeDTOTransformer, PackagingViewPropertyDTOTransformer packagingViewPropertyDTOTransformer) {
|
||||
this.materialDTOTransformer = materialDTOTransformer;
|
||||
this.dimensionDTOTransformer = dimensionDTOTransformer;
|
||||
this.nodeDTOTransformer = nodeDTOTransformer;
|
||||
this.packagingViewPropertyDTOTransformer = packagingViewPropertyDTOTransformer;
|
||||
}
|
||||
|
||||
|
||||
public Optional<PackagingViewDTO> convertToPackagingGetDTO(Optional<Packaging> packaging, Optional<Material> material, Optional<Node> supplier, Optional<Country> country, Optional<PackagingDimension> hu, Optional<PackagingDimension> shu, List<PackagingProperty> properties) {
|
||||
if(packaging.isEmpty()) return Optional.empty();
|
||||
|
||||
Packaging data = packaging.get();
|
||||
var dto = new PackagingViewDTO();
|
||||
|
||||
dto.setId(data.getId());
|
||||
dto.setMaterial(materialDTOTransformer.toMaterialDTO(material.orElseThrow()));
|
||||
dto.setSupplier(nodeDTOTransformer.toNodeDTO(supplier.orElseThrow()));
|
||||
dto.setHu(dimensionDTOTransformer.toDimensionDTO(hu.orElseThrow()));
|
||||
dto.setShu(dimensionDTOTransformer.toDimensionDTO(shu.orElseThrow()));
|
||||
dto.setDeprecated(data.getDeprecated());
|
||||
dto.setProperties(properties.stream().map(packagingViewPropertyDTOTransformer::toPackagingViewPropertyDTO).toList());
|
||||
|
||||
return Optional.of(dto);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Packaging convertFromPackagingPostDTO(PackagingUpdateDTO dto) {
|
||||
|
||||
var entity = new Packaging();
|
||||
entity.setId(dto.getId());
|
||||
entity.setDeprecated(dto.getDeprecated());
|
||||
entity.setSupplierId(dto.getSupplierId());
|
||||
entity.setMaterialId(dto.getMaterialId());
|
||||
entity.setHuId(dto.getHu().getId());
|
||||
entity.setShuId(dto.getShu().getId());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package de.avatic.lcc.service.transformer.packaging;
|
||||
|
||||
import de.avatic.lcc.dto.configuration.packaging.view.PackagingViewPropertyDTO;
|
||||
import de.avatic.lcc.model.packaging.PackagingProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class PackagingViewPropertyDTOTransformer {
|
||||
|
||||
public PackagingViewPropertyDTO toPackagingViewPropertyDTO(PackagingProperty property) {
|
||||
PackagingViewPropertyDTO dto = new PackagingViewPropertyDTO();
|
||||
|
||||
dto.setCurrentValue(property.getPropertyValue());
|
||||
dto.setDataType(property.getPackagingPropertyType().getDataType().name());
|
||||
dto.setRequired(property.getPackagingPropertyType().getRequired());
|
||||
dto.setName(property.getPackagingPropertyType().getName());
|
||||
dto.setExternalMappingId(property.getPackagingPropertyType().getExternalMappingId());
|
||||
dto.setValidationRule(property.getPackagingPropertyType().getValidationRule());
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package de.avatic.lcc.service.transformer.users;
|
||||
|
||||
import de.avatic.lcc.dto.users.UserDTO;
|
||||
import de.avatic.lcc.model.users.User;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UserDTOTransformer {
|
||||
|
||||
public UserDTO toUserDTO(User entity) {
|
||||
UserDTO dto = new UserDTO();
|
||||
|
||||
// todo implement
|
||||
|
||||
return dto;
|
||||
|
||||
}
|
||||
}
|
||||
28
src/main/java/de/avatic/lcc/service/users/GroupService.java
Normal file
28
src/main/java/de/avatic/lcc/service/users/GroupService.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package de.avatic.lcc.service.users;
|
||||
|
||||
import de.avatic.lcc.dto.users.GroupDTO;
|
||||
import de.avatic.lcc.dto.users.UserDTO;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import de.avatic.lcc.repositories.users.GroupRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class GroupService {
|
||||
private final GroupRepository groupRepository;
|
||||
|
||||
public GroupService(GroupRepository groupRepository) {
|
||||
this.groupRepository = groupRepository;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void updateGroup(GroupDTO group) {
|
||||
|
||||
}
|
||||
|
||||
public SearchQueryResult<GroupDTO> listGroups(int page, int limit) {
|
||||
groupRepository.listGroups()
|
||||
}
|
||||
}
|
||||
37
src/main/java/de/avatic/lcc/service/users/UserService.java
Normal file
37
src/main/java/de/avatic/lcc/service/users/UserService.java
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package de.avatic.lcc.service.users;
|
||||
|
||||
import de.avatic.lcc.dto.users.UserDTO;
|
||||
import de.avatic.lcc.model.users.User;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryPagination;
|
||||
import de.avatic.lcc.repositories.pagination.SearchQueryResult;
|
||||
import de.avatic.lcc.repositories.users.UserRepository;
|
||||
import de.avatic.lcc.service.transformer.users.UserDTOTransformer;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
private final UserDTOTransformer userDTOTransformer;
|
||||
|
||||
public UserService(UserRepository userRepository, UserDTOTransformer userDTOTransformer) {
|
||||
this.userRepository = userRepository;
|
||||
this.userDTOTransformer = userDTOTransformer;
|
||||
}
|
||||
|
||||
public SearchQueryResult<UserDTO> listUsers(int page, int limit) {
|
||||
return SearchQueryResult.map(userRepository.listUsers(new SearchQueryPagination(page, limit)), userDTOTransformer::toUserDTO);
|
||||
}
|
||||
|
||||
public void updateUser(UserDTO user) {
|
||||
|
||||
groupRepository.update
|
||||
userRepository.update(fromUserDTO(user));
|
||||
}
|
||||
|
||||
private User fromUserDTO(UserDTO dto) {
|
||||
return new User();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package de.avatic.lcc.util;
|
||||
|
||||
import de.avatic.lcc.util.exception.clienterror.InvalidArgumentException;
|
||||
|
||||
public class Check {
|
||||
|
||||
|
||||
|
|
|
|||
18
src/main/java/de/avatic/lcc/util/NotFoundException.java
Normal file
18
src/main/java/de/avatic/lcc/util/NotFoundException.java
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package de.avatic.lcc.util;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public class NotFoundException extends RuntimeException {
|
||||
|
||||
public NotFoundException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public NotFoundException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
18
src/main/java/de/avatic/lcc/util/ReferencedException.java
Normal file
18
src/main/java/de/avatic/lcc/util/ReferencedException.java
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package de.avatic.lcc.util;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
|
||||
@ResponseStatus(HttpStatus.CONFLICT)
|
||||
public class ReferencedException extends RuntimeException {
|
||||
|
||||
public ReferencedException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ReferencedException(final ReferencedWarning referencedWarning) {
|
||||
super(referencedWarning.toMessage());
|
||||
}
|
||||
|
||||
}
|
||||
42
src/main/java/de/avatic/lcc/util/ReferencedWarning.java
Normal file
42
src/main/java/de/avatic/lcc/util/ReferencedWarning.java
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
package de.avatic.lcc.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class ReferencedWarning {
|
||||
|
||||
private String key = null;
|
||||
private ArrayList<Object> params = new ArrayList<>();
|
||||
|
||||
public void addParam(final Object param) {
|
||||
params.add(param);
|
||||
}
|
||||
|
||||
public String toMessage() {
|
||||
String message = key;
|
||||
if (!params.isEmpty()) {
|
||||
message += "," + params.stream()
|
||||
.map(Object::toString)
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(final String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public ArrayList<Object> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(final ArrayList<Object> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue