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
6b3ab8b9
Commit
6b3ab8b9
authored
Mar 27, 2022
by
tbilos
Browse files
Merge branch 'main' into 16-change-relationship
parents
0a801139
4d03e523
Pipeline
#123034
waiting for manual action with stage
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/dao/AgentDao.java
View file @
6b3ab8b9
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 @
0a801139
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 @
6b3ab8b9
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/CodeName.java
View file @
6b3ab8b9
...
...
@@ -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/LanguageSkill.java
View file @
6b3ab8b9
...
...
@@ -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/Skill.java
View file @
6b3ab8b9
...
...
@@ -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 @
6b3ab8b9
...
...
@@ -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