Commit 2eeb4ed8 authored by Ondrej Sakači's avatar Ondrej Sakači 💯
Browse files

SQL is working, maybe could be optimized, backend looks good

parent d300e5af
......@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import javax.persistence.*;
import java.util.List;
@MappedSuperclass
public abstract class Achievement extends AbstractEntity{
@Basic(optional = false)
......@@ -23,14 +24,6 @@ public abstract class Achievement extends AbstractEntity{
@ManyToMany
private List<Trip> trips;
@JsonIgnore
@ManyToMany
@JoinTable(
name = "achievement_owned_travel_journals",
joinColumns = @JoinColumn(name = "achievement_id"),
inverseJoinColumns = @JoinColumn(name = "traveljournal_id"))
private List<TravelJournal> owned_travel_journals;
public Achievement() {
}
......@@ -79,20 +72,4 @@ public abstract class Achievement extends AbstractEntity{
public void removeTrips(Trip trip) {
this.trips.remove(trip);
}
public List<TravelJournal> getOwned_travel_journals() {
return owned_travel_journals;
}
public void setOwned_travel_journals(List<TravelJournal> owned_travel_journals) {
this.owned_travel_journals = owned_travel_journals;
}
public void addOwned_travel_journals(TravelJournal journal) {
this.owned_travel_journals.add(journal);
}
public void removeOwned_travel_journal(TravelJournal journal) {
this.owned_travel_journals.remove(journal);
}
}
......@@ -3,6 +3,8 @@ package cz.cvut.fel.rsp.travelandwork.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name="ACHIEVEMENT_CATEGORIZED")
......@@ -13,14 +15,24 @@ public class AchievementCategorized extends Achievement {
private Category category;
@Basic(optional = false)
@Column(nullable = false)
@Column(nullable = false, name = "limitOf")
private int limit;
@JsonIgnore
@ManyToMany
@JoinTable(
name = "achievement_certificate_owned_travel_journals",
joinColumns = @JoinColumn(name = "achievement_certificate_id"),
inverseJoinColumns = @JoinColumn(name = "traveljournal_id"))
private List<TravelJournal> owned_travel_journals;
public AchievementCategorized() {
owned_travel_journals = new ArrayList<TravelJournal>();
}
public AchievementCategorized(String name, String description, String icon) {
super(name, description, icon);
owned_travel_journals = new ArrayList<TravelJournal>();
}
public Category getCategory() {
......@@ -38,4 +50,12 @@ public class AchievementCategorized extends Achievement {
public void setLimit(int limit) {
this.limit = limit;
}
public List<TravelJournal> getOwned_travel_journals() {
return owned_travel_journals;
}
public void setOwned_travel_journals(List<TravelJournal> owned_travel_journals) {
this.owned_travel_journals = owned_travel_journals;
}
}
......@@ -7,10 +7,27 @@ import java.util.List;
@Entity
@Table(name = "ACHIEVEMENT_CERTIFICATE")
public class AchievementCertificate extends Achievement{
@JsonIgnore
@ManyToMany
@JoinTable(
name = "achievement_certificate_owned_travel_journals",
joinColumns = @JoinColumn(name = "achievement_certificate_id"),
inverseJoinColumns = @JoinColumn(name = "traveljournal_id"))
private List<TravelJournal> owned_travel_journals;
public AchievementCertificate() {
}
public AchievementCertificate(String name, String description, String icon) {
super(name, description, icon);
}
public List<TravelJournal> getOwned_travel_journals() {
return owned_travel_journals;
}
public void setOwned_travel_journals(List<TravelJournal> owned_travel_journals) {
this.owned_travel_journals = owned_travel_journals;
}
}
package cz.cvut.fel.rsp.travelandwork.model;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
import javax.persistence.*;
import java.util.List;
@Entity
@Table(name="ACHIEVEMENT_SPECIAL")
public class AchievementSpecial extends Achievement {
@JsonIgnore
@ManyToMany
@JoinTable(
name = "achievement_special_owned_travel_journals",
joinColumns = @JoinColumn(name = "achievement_special_id"),
inverseJoinColumns = @JoinColumn(name = "traveljournal_id"))
private List<TravelJournal> owned_travel_journals;
@ManyToMany
@JoinTable(
name = "recieved_achievement_special_trip",
joinColumns = @JoinColumn(name = "achievement_special_id"),
inverseJoinColumns = @JoinColumn(name = "enrollment_id"))
private List<Enrollment> recieved_via_enrollments;
public AchievementSpecial() {
}
public AchievementSpecial(String name, String description, String icon) {
super(name, description, icon);
}
public List<TravelJournal> getOwned_travel_journals() {
return owned_travel_journals;
}
public void setOwned_travel_journals(List<TravelJournal> owned_travel_journals) {
this.owned_travel_journals = owned_travel_journals;
}
public List<Enrollment> getRecieved_via_enrollments() {
return recieved_via_enrollments;
}
public void setRecieved_via_enrollments(List<Enrollment> recieved_via_enrollments) {
this.recieved_via_enrollments = recieved_via_enrollments;
}
}
......@@ -30,9 +30,9 @@ public class Enrollment extends AbstractEntity {
@ManyToMany
@JoinTable(
name = "recieved_achievement_trip",
name = "recieved_achievement_special_trip",
joinColumns = @JoinColumn(name = "enrollment_id"),
inverseJoinColumns = @JoinColumn(name = "achievement_id"))
inverseJoinColumns = @JoinColumn(name = "achievement_special_id"))
private List<AchievementSpecial> recieved_achievements_special;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment