Commit 7dadd56a authored by tbilos's avatar tbilos
Browse files

Merge branch 'main' into...

Merge branch 'main' into 16-change-ownership-of-performanceevaluation-from-report-to-agentassignment-uml
parents 603229b3 56997395
Pipeline #123046 waiting for manual action with stage
package cz.fi.muni.pa165.seminar4.group7.secretservice.dao;
import cz.fi.muni.pa165.seminar4.group7.secretservice.entity.Agent;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
/**
* @author Juraj Fiala
*/
public interface AgentDao {
void create(Agent a);
List<Agent> findAll();
Agent findById(Long id);
void remove(Agent a);
public interface AgentDao extends CrudRepository<Agent, Long> {
}
package cz.fi.muni.pa165.seminar4.group7.secretservice.dao;
import cz.fi.muni.pa165.seminar4.group7.secretservice.entity.Agent;
import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;
/**
* @author Juraj Fiala
*/
@Repository
public class AgentDaoImpl implements AgentDao {
@PersistenceContext
private EntityManager em;
public AgentDaoImpl(EntityManager em) {
this.em = em;
}
@Override
public void create(Agent a) {
em.persist(a);
}
@Override
public List<Agent> findAll() {
return em.createQuery("select a from Agent a", Agent.class).getResultList();
}
@Override
public Agent findById(Long id) {
return em.find(Agent.class, id);
}
@Override
public void remove(Agent a) {
em.remove(a);
}
}
\ No newline at end of file
package cz.fi.muni.pa165.seminar4.group7.secretservice.dao;
import cz.fi.muni.pa165.seminar4.group7.secretservice.entity.AgentAssignment;
import cz.fi.muni.pa165.seminar4.group7.secretservice.entity.Report;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
/**
* @author Jan Smejkal
*/
public interface ReportDao {
void create(Report report);
List<Report> findAll();
Report findById(long id);
void remove(Report report);
public interface ReportDao extends CrudRepository<Report, Long> {
}
package cz.fi.muni.pa165.seminar4.group7.secretservice.dao;
import cz.fi.muni.pa165.seminar4.group7.secretservice.entity.Report;
import java.util.List;
import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
/**
* @author Jan Smejkal
*/
@Repository
public class ReportDaoImpl implements ReportDao {
@PersistenceContext
private EntityManager em;
public ReportDaoImpl(EntityManager em) {
this.em = em;
}
@Override
public void create(Report report) {
em.persist(report);
}
@Override
public List<Report> findAll() {
return em.createQuery("select r from Report r", Report.class).getResultList();
}
@Override
public Report findById(long id) {
return em.find(Report.class, id);
}
@Override
public void remove(Report report) {
em.remove(report);
}
}
\ No newline at end of file
package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @author Juraj Fiala
*/
@Entity
@Getter
@Setter
@Accessors(chain = true)
public class Agent {
@Id
@Getter
@Setter
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToMany
@Getter
@Setter(AccessLevel.NONE)
private List<Skill> skills = new ArrayList<>();
@Getter
@Setter
private String training;
private String training = "";
@OneToMany
@Getter
private List<CodeName> codeNames;
@Setter(AccessLevel.NONE)
private List<CodeName> codeNames = new ArrayList<>();
@OneToMany(mappedBy = "agent")
@Getter
......@@ -42,7 +44,28 @@ public class Agent {
codeNames.add(codeName);
}
public void removeCodeName(CodeName codeName) {
codeNames.remove(codeName);
}
public void addSkill(Skill skill) {
skills.add(skill);
}
public void removeSkill(Skill skill) {
skills.remove(skill);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Agent)) return false;
Agent agent = (Agent) o;
return Objects.equals(getSkills(), agent.getSkills()) && Objects.equals(getTraining(), agent.getTraining()) && Objects.equals(getCodeNames(), agent.getCodeNames());
}
@Override
public int hashCode() {
return Objects.hash(getSkills(), getTraining(), getCodeNames());
}
}
package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import javax.persistence.*;
import java.sql.Date;
import java.util.HashSet;
import java.util.Set;
/**
* @author Tomáš Biloš
*
* Entity representing assignment of an agent in a mission. Contains report by agent participating in the mission and
* evaluation of his performance from his superiors.
*/
@Entity
@Getter
@Setter
@Accessors(chain = true)
public class AgentAssignment {
@Id
@Column(name = "id", nullable = false)
@Getter
@Setter
private Long id;
@Getter
@Setter
private Date start;
@Getter
@Setter
private int durationInDays;
@OneToOne
@JoinColumn(name = "report_id")
@Getter
@Setter
private Report report;
@ManyToOne
@JoinColumn(name = "mission_id", referencedColumnName = "id")
@Getter
@Setter
private Mission mission;
@ManyToOne
@Getter
@Setter
private Agent agent;
public AgentAssignment() {}
@OneToMany
@Setter(AccessLevel.NONE)
private Set<PerformanceEvaluation> performanceEvaluations = new HashSet<>();
public void addPerformanceEvaluation(PerformanceEvaluation performanceEvaluation) {
performanceEvaluations.add(performanceEvaluation);
}
public void removePerformanceEvaluation(PerformanceEvaluation performanceEvaluation) {
performanceEvaluations.remove(performanceEvaluation);
}
// TODO equal & hashcode
}
......@@ -4,31 +4,37 @@ import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import java.util.Objects;
/**
* @author Juraj Fiala
*/
@Entity
@Getter
@Setter
public class CodeName {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Getter
@Setter
private Long id;
@Getter
@Setter
private String codeName = "";
@ManyToOne
@Getter
@Setter
private Agent agent;
public CodeName(Agent agent, String codeName) {
this.agent = agent;
public CodeName(String codeName) {
this.codeName = codeName;
}
public CodeName() { }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof CodeName)) return false;
CodeName codeName1 = (CodeName) o;
return Objects.equals(getCodeName(), codeName1.getCodeName());
}
@Override
public int hashCode() {
return Objects.hash(getCodeName());
}
}
\ No newline at end of file
package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import com.sun.istack.NotNull;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import javax.persistence.*;
import java.util.List;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
/**
* @author Milan Mozolak
*/
@Entity
@Getter
@Setter
@Accessors(chain = true)
public class Country {
@Id
@Column(name = "id", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Getter
@Setter
private Long id;
@NotNull
@Column(nullable = false)
@Getter
@Setter
private String code;
@NotNull
@Column(nullable = false)
@Getter
@Setter
private String name;
@NotNull
@Column(nullable = false)
@Getter
@Setter
private String demographics;
@NotNull
@Column(nullable = false)
@Getter
@Setter
private String geography;
@NotNull
@Column(nullable = false)
@Getter
@Setter
private String communications;
@NotNull
@Column(nullable = false)
@Getter
@Setter
private String government;
@NotNull
@Column(nullable = false)
@Getter
@Setter
private String economy;
@NotNull
@Column(nullable = false)
@Getter
@Setter
private String military;
@Getter
@Setter
@Setter(AccessLevel.NONE)
@OneToMany(mappedBy = "country")
private List<Mission> missions;
private Set<Mission> missions = new HashSet<>();
public void addMission(Mission mission) {
missions.add(mission);
mission.setCountry(this);
}
public void removeMission(Mission mission) {
missions.remove(mission);
mission.setCountry(null);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Country country = (Country) o;
return id.equals(country.id) && code.equals(country.code);
return code.equals(country.code);
}
@Override
public int hashCode() {
return Objects.hash(id, code);
return Objects.hash(code);
}
}
......@@ -3,6 +3,7 @@ package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import cz.fi.muni.pa165.seminar4.group7.secretservice.enums.LanguageCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import javax.persistence.Entity;
......@@ -10,10 +11,10 @@ import javax.persistence.Entity;
* @author Juraj Fiala
*/
@Entity
@Getter
@Setter
@Accessors(chain = true)
public class LanguageSkill extends Skill {
@Getter
@Setter
private LanguageCode languageCode;
public LanguageSkill(int level, LanguageCode languageCode) {
......
......@@ -2,32 +2,27 @@ package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import javax.persistence.*;
/**
* @author Jan Smejkal
*
* Entity to represent a performance of an agent in a mission. Contains text evaluation as well as rating.
*/
@Entity
@Getter
@Setter
@Accessors(chain = true)
public class PerformanceEvaluation {
@Id
@Column(name = "id", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Getter
@Setter
private Long id;
@ManyToOne
@Getter
@Setter
private Report report;
@Getter
@Setter
private String evaluation;
@Getter
@Setter
private int rating;
public PerformanceEvaluation() {
......@@ -37,4 +32,5 @@ public class PerformanceEvaluation {
this.evaluation = evaluation;
}
// TODO equals & hashcode
}
\ No newline at end of file
......@@ -2,33 +2,28 @@ package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import javax.persistence.*;
/**
* @author Jan Smejkal
*
* Entity representing text report submited by an agent to his assignment.
*/
@Entity
@Getter
@Setter
@Accessors(chain = true)
public class Report {
@Id
@Column(name = "id", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Getter
@Setter
private Long id;
@Getter
@Setter
private String report;
@OneToOne
@Setter
@Getter
private PerformanceEvaluation performanceEvaluation;
@OneToOne(mappedBy = "report")
@Getter
@Setter
private AgentAssignment agentAssignment;
public Report() {}
......@@ -37,28 +32,5 @@ public class Report {
this.report = report;
}
@Override
public int hashCode() {
final int PRIME = 31;
int result = 1;
result = PRIME * result + ((report == null) ? 0 : report.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof Report))
return false;
Report other = (Report) obj;
if (id == null) {
if (other.getReport() != null)
return false;
} else if (!report.equals(other.getReport()))
return false;
return true;
}
// TODO equals & hashcode
}
\ No newline at end of file
......@@ -2,22 +2,23 @@ package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;