Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into feature/pipeline
  • Loading branch information
miguel-merlin committed Dec 8, 2024
2 parents 5836975 + e0bb8c1 commit 10553b8
Show file tree
Hide file tree
Showing 80 changed files with 3,011 additions and 858 deletions.
7 changes: 5 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down Expand Up @@ -80,7 +79,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.8</version>
</dependency>
</dependencies>

<build>
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/com/sarapis/orservice/OrserviceApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
public class OrserviceApplication {

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.sarapis.orservice.controller;

import com.sarapis.orservice.dto.AccessibilityDTO;
import com.sarapis.orservice.service.AccessibilityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping("/api/accessibilities")
public class AccessibilityController {
private final AccessibilityService accessibilityService;

@Autowired
public AccessibilityController(AccessibilityService accessibilityService) {
this.accessibilityService = accessibilityService;
}

@GetMapping
public ResponseEntity<List<AccessibilityDTO>> getAllAccessibilities() {
List<AccessibilityDTO> accessibilityDTOs = this.accessibilityService.getAllAccessibilities();
return ResponseEntity.ok(accessibilityDTOs);
}

@GetMapping("/{id}")
public ResponseEntity<AccessibilityDTO> getAccessibilityById(@PathVariable String id) {
AccessibilityDTO accessibility = this.accessibilityService.getAccessibilityById(id);
return ResponseEntity.ok(accessibility);
}

@PostMapping
public ResponseEntity<AccessibilityDTO> createAccessibility(@RequestBody AccessibilityDTO accessibilityDTO) {
if (accessibilityDTO.getId() == null) {
accessibilityDTO.setId(UUID.randomUUID().toString());
}
AccessibilityDTO createdAccessibility = this.accessibilityService.createAccessibility(accessibilityDTO);
return ResponseEntity.ok(createdAccessibility);
}

@PutMapping("/{id}")
public ResponseEntity<AccessibilityDTO> updateAccessibility(@PathVariable String id, @RequestBody AccessibilityDTO accessibilityDTO) {
AccessibilityDTO updatedAccessibility = this.accessibilityService.updateAccessibility(id, accessibilityDTO);
return ResponseEntity.ok(updatedAccessibility);
}

@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteAccessibility(@PathVariable String id) {
this.accessibilityService.deleteAccessibility(id);
return ResponseEntity.noContent().build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.sarapis.orservice.controller;

import com.sarapis.orservice.dto.AddressDTO;
import com.sarapis.orservice.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/addresses")
public class AddressController {
public final AddressService addressService;

@Autowired
public AddressController(AddressService addressService) {
this.addressService = addressService;
}

@GetMapping
public ResponseEntity<List<AddressDTO>> getAllAddresses() {
List<AddressDTO> addressDTOs = this.addressService.getAllAddresses();
return ResponseEntity.ok(addressDTOs);
}

@GetMapping("/{id}")
public ResponseEntity<AddressDTO> getAddressById(@PathVariable String id) {
AddressDTO queried = this.addressService.getAddressById(id);
return ResponseEntity.ok(queried);
}

@PostMapping
public ResponseEntity<AddressDTO> createAddress(@RequestBody AddressDTO addressDTO) {
AddressDTO createdAddress = this.addressService.createAddress(addressDTO);
return ResponseEntity.ok(createdAddress);
}

@PutMapping("/{id}")
public ResponseEntity<AddressDTO> updateAddress(@PathVariable String id, @RequestBody AddressDTO addressDTO) {
AddressDTO updateAddress = this.addressService.updateAddress(id, addressDTO);
return ResponseEntity.ok(updateAddress);
}

@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteAddress(@PathVariable String id) {
this.addressService.deleteAddress(id);
return ResponseEntity.noContent().build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.sarapis.orservice.controller;

import com.sarapis.orservice.dto.AttributeDTO;
import com.sarapis.orservice.service.AttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/attributes")
public class AttributeController {
private final AttributeService attributeService;

@Autowired
public AttributeController(AttributeService attributeService) {
this.attributeService = attributeService;
}

@GetMapping
public ResponseEntity<List<AttributeDTO>> getAllAttributes() {
List<AttributeDTO> attributeDTOs = this.attributeService.getAllAttributes();
return ResponseEntity.ok(attributeDTOs);
}

@GetMapping("/{id}")
public ResponseEntity<AttributeDTO> getAttributeById(@PathVariable String id) {
AttributeDTO queried = this.attributeService.getAttributeById(id);
return ResponseEntity.ok(queried);
}

@PostMapping
public ResponseEntity<AttributeDTO> createAttribute(@RequestBody AttributeDTO attributeDTO) {
AttributeDTO createdAttribute = this.attributeService.createAttribute(attributeDTO);
return ResponseEntity.ok(createdAttribute);
}

@PutMapping("/{id}")
public ResponseEntity<AttributeDTO> updateAttribute(@PathVariable String id, @RequestBody AttributeDTO attributeDTO) {
AttributeDTO updatedAttribute = this.attributeService.updateAttribute(id, attributeDTO);
return ResponseEntity.ok(updatedAttribute);
}

@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteAttribute(@PathVariable String id) {
this.attributeService.deleteAttribute(id);
return ResponseEntity.noContent().build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.sarapis.orservice.controller;

import com.sarapis.orservice.service.OrganizationService;
import java.io.ByteArrayInputStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/export")
public class ExportController {
private final OrganizationService organizationService;

@Autowired
public ExportController(OrganizationService organizationService) {
this.organizationService = organizationService;
}

@RequestMapping("/csv")
public ResponseEntity<Resource> exportCSV() {
String filename = "organizations.csv";
InputStreamResource organizationCSV = new InputStreamResource(organizationService.loadCSV());
return ResponseEntity.ok()
.body(organizationCSV);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.sarapis.orservice.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/import")
public class ImportController {
@GetMapping("/csv")
public void exportCSV() {
}

@PostMapping("/csv")
public void importCSV() {
}

@GetMapping("/pdf")
public void exportPDF() {

}

@PostMapping("/pdf")
public void importPDF() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,63 @@
import com.sarapis.orservice.dto.OrganizationDTO;
import com.sarapis.orservice.dto.PaginationDTO;
import com.sarapis.orservice.service.OrganizationService;
import java.util.List;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping("/api/organizations")
public class OrganizationController {
private final OrganizationService organizationService;

private final OrganizationService organizationService;

@Autowired
public OrganizationController(OrganizationService organizationService) {
this.organizationService = organizationService;
}

@GetMapping
public ResponseEntity<PaginationDTO<OrganizationDTO>> getAllOrganizations() {
List<OrganizationDTO> organizations = organizationService.getAllOrganizations();
PaginationDTO<OrganizationDTO> paginationDTO = PaginationDTO.of(
organizations.size(),
1,
1,
organizations.size(),
true,
false,
false,
organizations
);
return ResponseEntity.ok(paginationDTO);
}
@Autowired
public OrganizationController(OrganizationService organizationService) {
this.organizationService = organizationService;
}

@GetMapping("/{id}")
public ResponseEntity<OrganizationDTO> getOrganizationById(@PathVariable String id) {
OrganizationDTO organization = organizationService.getOrganizationById(id);
return ResponseEntity.ok(organization);
}
@GetMapping
public ResponseEntity<PaginationDTO<OrganizationDTO>> getAllOrganizations() {
List<OrganizationDTO> organizations = organizationService.getAllOrganizations();
PaginationDTO<OrganizationDTO> paginationDTO = PaginationDTO.of(
organizations.size(),
1,
1,
organizations.size(),
true,
false,
false,
organizations
);
return ResponseEntity.ok(paginationDTO);
}

@PostMapping
public ResponseEntity<OrganizationDTO> createOrganization(@RequestBody OrganizationDTO organizationDTO) {
if (organizationDTO.getId() == null) {
organizationDTO.setId(UUID.randomUUID().toString());
@GetMapping("/{id}")
public ResponseEntity<OrganizationDTO> getOrganizationById(@PathVariable String id) {
OrganizationDTO organization = organizationService.getOrganizationById(id);
return ResponseEntity.ok(organization);
}
OrganizationDTO createdOrganization = organizationService.createOrganization(organizationDTO);
return ResponseEntity.ok(createdOrganization);
}

@PutMapping("/{id}")
public ResponseEntity<OrganizationDTO> updateOrganization(@PathVariable String id, @RequestBody OrganizationDTO organizationDTO) {
OrganizationDTO updatedOrganization = organizationService.updateOrganization(id, organizationDTO);
return ResponseEntity.ok(updatedOrganization);
}
@PostMapping
public ResponseEntity<OrganizationDTO> createOrganization(@RequestBody OrganizationDTO organizationDTO) {
if (organizationDTO.getId() == null) {
organizationDTO.setId(UUID.randomUUID().toString());
}
OrganizationDTO createdOrganization = organizationService.createOrganization(organizationDTO);
return ResponseEntity.ok(createdOrganization);
}

@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteOrganization(@PathVariable String id) {
organizationService.deleteOrganization(id);
return ResponseEntity.noContent().build();
}
@PutMapping("/{id}")
public ResponseEntity<OrganizationDTO> updateOrganization(@PathVariable String id, @RequestBody OrganizationDTO organizationDTO) {
OrganizationDTO updatedOrganization = organizationService.updateOrganization(id, organizationDTO);
return ResponseEntity.ok(updatedOrganization);
}

@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteOrganization(@PathVariable String id) {
organizationService.deleteOrganization(id);
return ResponseEntity.noContent().build();
}
}
Loading

0 comments on commit 10553b8

Please sign in to comment.