backend/buisnesslogic/src/main/java/com/plannaplan/entities/Exchange.java

103 lines
2.3 KiB
Java
Raw Normal View History

package com.plannaplan.entities;
import java.sql.Timestamp;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
/**
* Entity that keeps user exchange offer.
*/
@Entity
public class Exchange {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne
@JoinColumn(name = "owned_id")
private Assignment ownedAssignment;
@OneToOne
@JoinColumn(name = "desired_id")
private Groups desiredAssignment;
private Long ownerId;
private Timestamp dateExchange;
public Exchange(){
}
/**
* @return Long ID of exchange trader
*/
public Long getOwnerId() {
return ownerId;
}
/**
* @param ownerId ID of exchange trader
*/
public void setOwnerId(Long ownerId) {
this.ownerId = ownerId;
}
public Timestamp getDataExchange() {
return this.dateExchange;
}
/**
*
* @param ownedAssignment Assignment which owner would like to trade
* @param desiredAssignment Groups instance that trader wants
*/
public Exchange(Assignment ownedAssignment, Groups desiredAssignment) {
this.ownedAssignment = ownedAssignment;
this.desiredAssignment = desiredAssignment;
this.ownerId = this.ownedAssignment != null ? this.ownedAssignment.getCommision().getCommisionOwner().getId() : null;
this.dateExchange = new Timestamp(System.currentTimeMillis());
}
/**
* @return Long ID in database
*/
public Long getId(){
return this.id;
}
/**
* @return Groups Target group
*/
public Groups getDesiredAssignment() {
return desiredAssignment;
}
/**
* @param desiredAssignment Target group
*/
public void setDesiredAssignment(Groups desiredAssignment) {
this.desiredAssignment = desiredAssignment;
}
/**
* @return Assignment Owned assignment
*/
public Assignment getOwnedAssignment() {
return ownedAssignment;
}
/**
* @param ownedAssignment Owned assignment
*/
public void setOwnedAssignment(Assignment ownedAssignment) {
this.ownedAssignment = ownedAssignment;
}
}