new fields in TransactionItem.java active and relationship to registration
This commit is contained in:
@@ -42,7 +42,7 @@ public class Charge implements Serializable {
|
||||
private Event event;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JsonIgnoreProperties(value = { "user", "event" }, allowSetters = true)
|
||||
@JsonIgnoreProperties(value = { "user", "event", "transactionItems" }, allowSetters = true)
|
||||
private Registration registration;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
|
||||
@@ -44,7 +44,7 @@ public class Event implements Serializable {
|
||||
private String comment;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "event")
|
||||
@JsonIgnoreProperties(value = { "user", "event" }, allowSetters = true)
|
||||
@JsonIgnoreProperties(value = { "user", "event", "transactionItems" }, allowSetters = true)
|
||||
private Set<Registration> registrations = new HashSet<>();
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "event")
|
||||
|
||||
@@ -5,6 +5,8 @@ import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A Registration.
|
||||
@@ -44,6 +46,10 @@ public class Registration implements Serializable {
|
||||
@JsonIgnoreProperties(value = { "registrations", "transactions" }, allowSetters = true)
|
||||
private Event event;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "registration")
|
||||
@JsonIgnoreProperties(value = { "userAccount", "transaction", "event", "registration" }, allowSetters = true)
|
||||
private Set<TransactionItem> transactionItems = new HashSet<>();
|
||||
|
||||
// jhipster-needle-entity-add-field - JHipster will add fields here
|
||||
|
||||
public Long getId() {
|
||||
@@ -137,6 +143,37 @@ public class Registration implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Set<TransactionItem> getTransactionItems() {
|
||||
return this.transactionItems;
|
||||
}
|
||||
|
||||
public void setTransactionItems(Set<TransactionItem> transactionItems) {
|
||||
if (this.transactionItems != null) {
|
||||
this.transactionItems.forEach(i -> i.setRegistration(null));
|
||||
}
|
||||
if (transactionItems != null) {
|
||||
transactionItems.forEach(i -> i.setRegistration(this));
|
||||
}
|
||||
this.transactionItems = transactionItems;
|
||||
}
|
||||
|
||||
public Registration transactionItems(Set<TransactionItem> transactionItems) {
|
||||
this.setTransactionItems(transactionItems);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Registration addTransactionItem(TransactionItem transactionItem) {
|
||||
this.transactionItems.add(transactionItem);
|
||||
transactionItem.setRegistration(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Registration removeTransactionItem(TransactionItem transactionItem) {
|
||||
this.transactionItems.remove(transactionItem);
|
||||
transactionItem.setRegistration(null);
|
||||
return this;
|
||||
}
|
||||
|
||||
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Transaction implements Serializable {
|
||||
private Event event;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "transaction")
|
||||
@JsonIgnoreProperties(value = { "userAccount", "transaction", "event" }, allowSetters = true)
|
||||
@JsonIgnoreProperties(value = { "userAccount", "transaction", "event", "registration" }, allowSetters = true)
|
||||
private Set<TransactionItem> transactionItems = new HashSet<>();
|
||||
|
||||
// jhipster-needle-entity-add-field - JHipster will add fields here
|
||||
|
||||
@@ -27,6 +27,9 @@ public class TransactionItem implements Serializable {
|
||||
@Column(name = "comment")
|
||||
private String comment;
|
||||
|
||||
@Column(name = "locked")
|
||||
private Boolean locked;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JsonIgnoreProperties(value = { "users", "transactionItems" }, allowSetters = true)
|
||||
private UserAccount userAccount;
|
||||
@@ -39,6 +42,10 @@ public class TransactionItem implements Serializable {
|
||||
@JsonIgnoreProperties(value = { "registrations", "transactions" }, allowSetters = true)
|
||||
private Event event;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JsonIgnoreProperties(value = { "user", "event", "transactionItems" }, allowSetters = true)
|
||||
private Registration registration;
|
||||
|
||||
// jhipster-needle-entity-add-field - JHipster will add fields here
|
||||
|
||||
public Long getId() {
|
||||
@@ -80,6 +87,19 @@ public class TransactionItem implements Serializable {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public Boolean getLocked() {
|
||||
return this.locked;
|
||||
}
|
||||
|
||||
public TransactionItem locked(Boolean locked) {
|
||||
this.setLocked(locked);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setLocked(Boolean locked) {
|
||||
this.locked = locked;
|
||||
}
|
||||
|
||||
public UserAccount getUserAccount() {
|
||||
return this.userAccount;
|
||||
}
|
||||
@@ -119,6 +139,19 @@ public class TransactionItem implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Registration getRegistration() {
|
||||
return this.registration;
|
||||
}
|
||||
|
||||
public void setRegistration(Registration registration) {
|
||||
this.registration = registration;
|
||||
}
|
||||
|
||||
public TransactionItem registration(Registration registration) {
|
||||
this.setRegistration(registration);
|
||||
return this;
|
||||
}
|
||||
|
||||
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here
|
||||
|
||||
@Override
|
||||
@@ -145,6 +178,7 @@ public class TransactionItem implements Serializable {
|
||||
"id=" + getId() +
|
||||
", amount=" + getAmount() +
|
||||
", comment='" + getComment() + "'" +
|
||||
", locked='" + getLocked() + "'" +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class UserAccount implements Serializable {
|
||||
private Set<User> users = new HashSet<>();
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "userAccount")
|
||||
@JsonIgnoreProperties(value = { "userAccount", "transaction", "event" }, allowSetters = true)
|
||||
@JsonIgnoreProperties(value = { "userAccount", "transaction", "event", "registration" }, allowSetters = true)
|
||||
private Set<TransactionItem> transactionItems = new HashSet<>();
|
||||
|
||||
// jhipster-needle-entity-add-field - JHipster will add fields here
|
||||
|
||||
@@ -27,16 +27,18 @@ public interface TransactionItemRepository extends JpaRepository<TransactionItem
|
||||
}
|
||||
|
||||
@Query(
|
||||
value = "select transactionItem from TransactionItem transactionItem left join fetch transactionItem.event",
|
||||
value = "select transactionItem from TransactionItem transactionItem left join fetch transactionItem.event left join fetch transactionItem.registration",
|
||||
countQuery = "select count(transactionItem) from TransactionItem transactionItem"
|
||||
)
|
||||
Page<TransactionItem> findAllWithToOneRelationships(Pageable pageable);
|
||||
|
||||
@Query("select transactionItem from TransactionItem transactionItem left join fetch transactionItem.event")
|
||||
@Query(
|
||||
"select transactionItem from TransactionItem transactionItem left join fetch transactionItem.event left join fetch transactionItem.registration"
|
||||
)
|
||||
List<TransactionItem> findAllWithToOneRelationships();
|
||||
|
||||
@Query(
|
||||
"select transactionItem from TransactionItem transactionItem left join fetch transactionItem.event where transactionItem.id =:id"
|
||||
"select transactionItem from TransactionItem transactionItem left join fetch transactionItem.event left join fetch transactionItem.registration where transactionItem.id =:id"
|
||||
)
|
||||
Optional<TransactionItem> findOneWithToOneRelationships(@Param("id") Long id);
|
||||
}
|
||||
|
||||
@@ -127,6 +127,9 @@ public class TransactionItemResource {
|
||||
if (transactionItem.getComment() != null) {
|
||||
existingTransactionItem.setComment(transactionItem.getComment());
|
||||
}
|
||||
if (transactionItem.getLocked() != null) {
|
||||
existingTransactionItem.setLocked(transactionItem.getLocked());
|
||||
}
|
||||
|
||||
return existingTransactionItem;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user