-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from stevensblueprint/feat/dto
Split DTOs
- Loading branch information
Showing
55 changed files
with
1,192 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,29 @@ | ||
package com.sarapis.orservice.dto; | ||
|
||
import com.sarapis.orservice.entity.Contact; | ||
import com.sarapis.orservice.entity.core.Location; | ||
import com.sarapis.orservice.entity.core.Organization; | ||
import com.sarapis.orservice.entity.core.Service; | ||
import com.sarapis.orservice.entity.core.ServiceAtLocation; | ||
import lombok.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Returned response for a contact entity. | ||
* <a href="http://docs.openreferral.org/en/v3.1.1/hsds/schema_reference.html#contact">Reference</a> | ||
*/ | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class ContactDTO { | ||
private String id; | ||
|
||
private String organizationId; | ||
private String serviceId; | ||
private String serviceAtLocationId; | ||
private String locationId; | ||
|
||
private String name; | ||
private String title; | ||
private String department; | ||
private String email; | ||
|
||
private List<PhoneDTO> phones = new ArrayList<>(); | ||
private List<AttributeDTO> attributes = new ArrayList<>(); | ||
private List<MetadataDTO> metadata = new ArrayList<>(); | ||
|
||
public Contact toEntity(Organization organization, | ||
Service service, | ||
ServiceAtLocation serviceAtLocation, | ||
Location location) { | ||
Contact contact = Contact.builder() | ||
.id(this.id == null ? UUID.randomUUID().toString() : this.id) | ||
.organization(organization) | ||
.service(service) | ||
.serviceAtLocation(serviceAtLocation) | ||
.location(location) | ||
.name(this.name) | ||
.title(this.title) | ||
.department(this.department) | ||
.email(this.email) | ||
.build(); | ||
contact.setPhones(this.phones.stream().map(e -> e.toEntity(null, null, null, contact, null)).toList()); | ||
return contact; | ||
} | ||
private List<PhoneDTO> phones; | ||
private List<AttributeDTO> attributes; | ||
private List<MetadataDTO> metadata; | ||
} |
28 changes: 6 additions & 22 deletions
28
src/main/java/com/sarapis/orservice/dto/CostOptionDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,28 @@ | ||
package com.sarapis.orservice.dto; | ||
|
||
import com.sarapis.orservice.entity.CostOption; | ||
import com.sarapis.orservice.entity.core.Service; | ||
import lombok.*; | ||
|
||
import java.time.LocalDate; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Returned response for a cost option entity. | ||
* <a href="http://docs.openreferral.org/en/v3.1.1/hsds/schema_reference.html#cost-option">Reference</a> | ||
*/ | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class CostOptionDTO { | ||
private String id; | ||
|
||
private String serviceId; | ||
|
||
private LocalDate validFrom; | ||
private LocalDate validTo; | ||
private String option; | ||
private String currency; | ||
private int amount; | ||
private String amountDescription; | ||
|
||
private List<AttributeDTO> attributes = new ArrayList<>(); | ||
private List<MetadataDTO> metadata = new ArrayList<>(); | ||
|
||
public CostOption toEntity(Service service) { | ||
return CostOption.builder() | ||
.id(this.id == null ? UUID.randomUUID().toString() : this.id) | ||
.service(service) | ||
.validFrom(this.validFrom) | ||
.validTo(this.validTo) | ||
.option(this.option) | ||
.currency(this.currency) | ||
.amount(this.amount) | ||
.amountDescription(this.amountDescription) | ||
.build(); | ||
} | ||
private List<AttributeDTO> attributes; | ||
private List<MetadataDTO> metadata; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.