Implemented project handling and updated property components according to front-end needs
This commit is contained in:
166
src/main/java/de/iwomm/propify_api/entity/Project.java
Normal file
166
src/main/java/de/iwomm/propify_api/entity/Project.java
Normal file
@@ -0,0 +1,166 @@
|
||||
package de.iwomm.propify_api.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
public class Project {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
@Column(nullable = false)
|
||||
private UUID id;
|
||||
|
||||
private String name;
|
||||
private String eventNumber;
|
||||
private String description;
|
||||
private String projectType;
|
||||
private String status;
|
||||
|
||||
@Column(nullable = false)
|
||||
private int amountRequested;
|
||||
|
||||
@Column(nullable = false)
|
||||
private LocalDate startDate;
|
||||
|
||||
@Column(nullable = false)
|
||||
private LocalDate endDate;
|
||||
|
||||
@Column(nullable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.PERSIST, optional = false)
|
||||
@JoinColumn(name = "property_id", nullable = false)
|
||||
@JsonManagedReference
|
||||
private Property property;
|
||||
|
||||
public Project() {
|
||||
this.amountRequested = 0;
|
||||
}
|
||||
|
||||
public Project(String name, String eventNumber, String description, String projectType,
|
||||
String status, Property property, int amountRequested,
|
||||
LocalDate startDate, LocalDate endDate) {
|
||||
this.name = name;
|
||||
this.eventNumber = eventNumber;
|
||||
this.description = description;
|
||||
this.projectType = projectType;
|
||||
this.status = status;
|
||||
this.property = property;
|
||||
this.amountRequested = amountRequested;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
@PrePersist
|
||||
protected void onCreate() {
|
||||
this.createdAt = LocalDateTime.now();
|
||||
this.updatedAt = LocalDateTime.now();
|
||||
}
|
||||
|
||||
@PreUpdate
|
||||
protected void onUpdate() {
|
||||
this.updatedAt = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getEventNumber() {
|
||||
return eventNumber;
|
||||
}
|
||||
|
||||
public void setEventNumber(String eventNumber) {
|
||||
this.eventNumber = eventNumber;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getProjectType() {
|
||||
return projectType;
|
||||
}
|
||||
|
||||
public void setProjectType(String projectType) {
|
||||
this.projectType = projectType;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getAmountRequested() {
|
||||
return amountRequested;
|
||||
}
|
||||
|
||||
public void setAmountRequested(int amountRequested) {
|
||||
this.amountRequested = amountRequested;
|
||||
}
|
||||
|
||||
public Property getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public void setProperty(Property property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
public LocalDate getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(LocalDate startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public LocalDate getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(LocalDate endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package de.iwomm.propify_api.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -41,6 +43,19 @@ public class Property {
|
||||
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@OneToMany(mappedBy = "property", cascade = CascadeType.PERSIST, orphanRemoval = true)
|
||||
@OrderBy("createdAt")
|
||||
@JsonBackReference
|
||||
private List<Project> projects = new ArrayList<>();
|
||||
|
||||
public List<Project> getProjects() {
|
||||
return projects;
|
||||
}
|
||||
|
||||
public void setProjects(List<Project> projects) {
|
||||
this.projects = projects;
|
||||
}
|
||||
|
||||
public List<Attachment> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user