Commit 109866ad authored by tbilos's avatar tbilos
Browse files

Merge branch 'main' into feat/agent

parents 426c45df 17a2a8a8
package cz.fi.muni.pa165.seminar4.group7.secretservice.dao;
import cz.fi.muni.pa165.seminar4.group7.secretservice.entity.Report;
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);
}
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;
public class AgentAssignment {
}
package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
/**
* @author Jan Smejkal
*/
@Entity
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;
//on a scale of 0 upto 100
@Getter
@Setter
private int rating;
public PerformanceEvaluation() {
}
public PerformanceEvaluation(String evaluation){
this.evaluation = evaluation;
}
}
\ No newline at end of file
package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
/**
* @author Jan Smejkal
*/
@Entity
public class Report {
@Id
@Column(name = "id", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Getter
@Setter
private Long id;
@Getter
@Setter
private String report;
@OneToMany
@Getter
private List<PerformanceEvaluation> performanceEvaluations = new ArrayList();
// @ManyToOne
// @Getter
// private AgentAssignment agentAssignment;
public Report() {
}
public void addPerformanceEvaluation(PerformanceEvaluation performanceEvaluation) {
performanceEvaluations.add(performanceEvaluation);
}
public Report(String 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;
}
}
\ No newline at end of file
Supports Markdown
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