Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jan Smejkal
Pa165 Secret Archive
Commits
c1f100f6
Commit
c1f100f6
authored
Mar 27, 2022
by
tbilos
Browse files
Merge main int fix/report
parents
b165b4f7
fdd60658
Pipeline
#123045
waiting for manual action with stage
Changes
11
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/dao/AgentDao.java
View file @
c1f100f6
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
>
{
}
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/dao/AgentDaoImpl.java
deleted
100644 → 0
View file @
b165b4f7
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
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/entity/Agent.java
View file @
c1f100f6
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
@
G
etter
@
S
etter
(
AccessLevel
.
NONE
)
private
List
<
Skill
>
skills
=
new
ArrayList
<>();
@Getter
@Setter
private
String
training
;
private
String
training
=
""
;
@OneToMany
@
G
etter
private
List
<
CodeName
>
codeNames
;
@
S
etter
(
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
());
}
}
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/entity/AgentAssignment.java
View file @
c1f100f6
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
}
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/entity/CodeName.java
View file @
c1f100f6
...
...
@@ -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
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/entity/Country.java
View file @
c1f100f6
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.
Lis
t
;
import
java.util.
HashSe
t
;
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
);
}
}
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/entity/LanguageSkill.java
View file @
c1f100f6
...
...
@@ -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
)
{
...
...
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/entity/PerformanceEvaluation.java
View file @
c1f100f6
...
...
@@ -8,6 +8,8 @@ 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
...
...
@@ -19,9 +21,6 @@ public class PerformanceEvaluation {
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
@ManyToOne
private
Report
report
;
private
String
evaluation
;
private
int
rating
;
...
...
@@ -33,4 +32,5 @@ public class PerformanceEvaluation {
this
.
evaluation
=
evaluation
;
}
// TODO equals & hashcode
}
\ No newline at end of file
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/entity/Report.java
View file @
c1f100f6
...
...
@@ -8,6 +8,8 @@ import javax.persistence.*;
/**
* @author Jan Smejkal
*
* Entity representing text report submited by an agent to his assignment.
*/
@Entity
@Getter
...
...
@@ -21,9 +23,6 @@ public class Report {
private
String
report
;
@OneToOne
private
PerformanceEvaluation
performanceEvaluation
;
@OneToOne
(
mappedBy
=
"report"
)
private
AgentAssignment
agentAssignment
;
...
...
@@ -33,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
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/entity/Skill.java
View file @
c1f100f6
...
...
@@ -2,22 +2,23 @@ package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
javax.persistence.*
;
import
java.util.Objects
;
/**
* @author Juraj Fiala
*/
@Entity
@Getter
@Setter
@Accessors
(
chain
=
true
)
public
abstract
class
Skill
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Getter
@Setter
private
Long
id
;
@Getter
@Setter
private
int
level
;
public
Skill
(
int
level
)
{
...
...
@@ -25,4 +26,17 @@ public abstract class Skill {
}
public
Skill
()
{
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(!(
o
instanceof
Skill
))
return
false
;
Skill
skill
=
(
Skill
)
o
;
return
getLevel
()
==
skill
.
getLevel
();
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
getLevel
());
}
}
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/entity/WeaponSkill.java
View file @
c1f100f6
...
...
@@ -3,6 +3,7 @@ package cz.fi.muni.pa165.seminar4.group7.secretservice.entity;
import
cz.fi.muni.pa165.seminar4.group7.secretservice.enums.WeaponCategory
;
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
WeaponSkill
extends
Skill
{
@Getter
@Setter
private
WeaponCategory
weaponCategory
;
public
WeaponSkill
()
{
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment