-
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.
- Loading branch information
Showing
8 changed files
with
1,208 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
package com.maires.wnet.entity; | ||
|
||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.DiscriminatorColumn; | ||
import jakarta.persistence.DiscriminatorType; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Inheritance; | ||
import jakarta.persistence.InheritanceType; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.OneToOne; | ||
|
||
/** | ||
* The type Address. | ||
*/ | ||
@Entity(name = "addresses") | ||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) | ||
@DiscriminatorColumn(name = "address_type", | ||
discriminatorType = DiscriminatorType.STRING) | ||
public class Address { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String city; | ||
|
||
private String state; | ||
|
||
private String zipCode; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "customer_id") | ||
private Customer customer; | ||
|
||
@OneToOne(mappedBy = "address", cascade = CascadeType.ALL) | ||
private Installation installation; | ||
|
||
/** | ||
* Instantiates a new Address. | ||
*/ | ||
public Address() { | ||
} | ||
|
||
/** | ||
* Instantiates a new Address. | ||
* | ||
* @param city the city | ||
* @param state the state | ||
* @param zipCode the zipCode | ||
*/ | ||
public Address(String city, String state, String zipCode) { | ||
this.city = city; | ||
this.state = state; | ||
this.zipCode = zipCode; | ||
} | ||
|
||
/** | ||
* Gets id. | ||
* | ||
* @return the id | ||
*/ | ||
public Long getId() { | ||
return id; | ||
} | ||
|
||
/** | ||
* Sets id. | ||
* | ||
* @param id the id | ||
*/ | ||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
/** | ||
* Gets installation. | ||
* | ||
* @return the installation | ||
*/ | ||
public Installation getInstallation() { | ||
return installation; | ||
} | ||
|
||
/** | ||
* Sets installation. | ||
* | ||
* @param installation the installation | ||
*/ | ||
public void setInstallation(Installation installation) { | ||
this.installation = installation; | ||
} | ||
|
||
/** | ||
* Gets customer. | ||
* | ||
* @return the customer | ||
*/ | ||
public Customer getCustomer() { | ||
return customer; | ||
} | ||
|
||
/** | ||
* Sets customer. | ||
* | ||
* @param customer the customer | ||
*/ | ||
public void setCustomer(Customer customer) { | ||
this.customer = customer; | ||
} | ||
|
||
/** | ||
* Gets city. | ||
* | ||
* @return the city | ||
*/ | ||
public String getCity() { | ||
return city; | ||
} | ||
|
||
/** | ||
* Sets city. | ||
* | ||
* @param city the city | ||
*/ | ||
public void setCity(String city) { | ||
this.city = city; | ||
} | ||
|
||
/** | ||
* Gets state. | ||
* | ||
* @return the state | ||
*/ | ||
public String getState() { | ||
return state; | ||
} | ||
|
||
/** | ||
* Sets state. | ||
* | ||
* @param state the state | ||
*/ | ||
public void setState(String state) { | ||
this.state = state; | ||
} | ||
|
||
/** | ||
* Gets zipCode. | ||
* | ||
* @return the zipCode | ||
*/ | ||
public String getZipCode() { | ||
return zipCode; | ||
} | ||
|
||
/** | ||
* Sets zipCode. | ||
* | ||
* @param zipCode the zipCode | ||
*/ | ||
public void setZipCode(String zipCode) { | ||
this.zipCode = zipCode; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,187 @@ | ||
package com.maires.wnet.entity; | ||
|
||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.Table; | ||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.List; | ||
|
||
|
||
/** | ||
* The type Customer. | ||
*/ | ||
@Entity | ||
@Table(name = "customers") | ||
public class Customer { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
private String name; | ||
private String cpf; | ||
private String phone; | ||
|
||
@Column(unique = true) | ||
private String email; | ||
|
||
private String registrationDate; | ||
|
||
@OneToMany(mappedBy = "customer", cascade = CascadeType.ALL) | ||
private List<Address> addresses; | ||
|
||
/** | ||
* Instantiates a new Customer. | ||
*/ | ||
public Customer() { | ||
} | ||
|
||
/** | ||
* Instantiates a new Customer. | ||
* | ||
* @param name the name | ||
* @param cpf the cpf | ||
* @param phone the phone | ||
* @param email the email | ||
*/ | ||
public Customer(String name, String cpf, String phone, String email) { | ||
this.name = name; | ||
this.cpf = cpf; | ||
this.phone = phone; | ||
this.email = email; | ||
LocalDateTime now = LocalDateTime.now().minusHours(3); | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy'T'HH:mm:ss"); | ||
this.registrationDate = now.format(formatter); | ||
} | ||
|
||
/** | ||
* Gets id. | ||
* | ||
* @return the id | ||
*/ | ||
public Long getId() { | ||
return id; | ||
} | ||
|
||
/** | ||
* Sets id. | ||
* | ||
* @param id the id | ||
*/ | ||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
/** | ||
* Gets name. | ||
* | ||
* @return the name | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* Sets name. | ||
* | ||
* @param name the name | ||
*/ | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
/** | ||
* Gets cpf. | ||
* | ||
* @return the cpf | ||
*/ | ||
public String getCpf() { | ||
return cpf; | ||
} | ||
|
||
/** | ||
* Sets cpf. | ||
* | ||
* @param cpf the cpf | ||
*/ | ||
public void setCpf(String cpf) { | ||
this.cpf = cpf; | ||
} | ||
|
||
/** | ||
* Gets phone. | ||
* | ||
* @return the phone | ||
*/ | ||
public String getPhone() { | ||
return phone; | ||
} | ||
|
||
/** | ||
* Sets phone. | ||
* | ||
* @param phone the phone | ||
*/ | ||
public void setPhone(String phone) { | ||
this.phone = phone; | ||
} | ||
|
||
/** | ||
* Gets email. | ||
* | ||
* @return the email | ||
*/ | ||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
/** | ||
* Sets email. | ||
* | ||
* @param email the email | ||
*/ | ||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
|
||
/** | ||
* Gets registration date. | ||
* | ||
* @return the registration date | ||
*/ | ||
public String getRegistrationDate() { | ||
return registrationDate; | ||
} | ||
|
||
/** | ||
* Sets registration date. | ||
* | ||
* @param registrationDate the registration date | ||
*/ | ||
public void setRegistrationDate(String registrationDate) { | ||
this.registrationDate = registrationDate; | ||
} | ||
|
||
/** | ||
* Gets addresses. | ||
* | ||
* @return the addresses | ||
*/ | ||
public List<Address> getAddresses() { | ||
return addresses; | ||
} | ||
|
||
/** | ||
* Sets addresses. | ||
* | ||
* @param addresses the addresses | ||
*/ | ||
public void setAddresses(List<Address> addresses) { | ||
this.addresses = addresses; | ||
} | ||
} |
Oops, something went wrong.