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
22883c39
Commit
22883c39
authored
Mar 25, 2022
by
Tomáš Biloš
Browse files
Merge branch 'xbilos/mission' into 'main'
feat: mission entity, DAO See merge request
!7
parents
85a9e532
2869eeb7
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/dao/MissionDao.java
0 → 100644
View file @
22883c39
package
cz.fi.muni.pa165.seminar4.group7.secretservice.dao
;
import
cz.fi.muni.pa165.seminar4.group7.secretservice.entity.Mission
;
import
org.springframework.data.repository.CrudRepository
;
public
interface
MissionDao
extends
CrudRepository
<
Mission
,
Long
>
{
}
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/entity/Mission.java
0 → 100644
View file @
22883c39
package
cz.fi.muni.pa165.seminar4.group7.secretservice.entity
;
import
com.sun.istack.NotNull
;
import
lombok.Getter
;
import
lombok.Setter
;
import
javax.persistence.*
;
import
java.sql.Date
;
import
java.util.List
;
/**
* @author Tomáš Biloš
*/
@Entity
public
class
Mission
{
@Id
@Column
(
name
=
"id"
,
nullable
=
false
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Getter
@Setter
private
Long
id
;
@NotNull
@Column
(
nullable
=
false
)
@Getter
@Setter
private
Date
start
;
@NotNull
@Column
(
nullable
=
false
)
@Getter
@Setter
private
int
duration
;
@NotNull
@Column
(
nullable
=
false
)
@Getter
@Setter
private
String
objective
;
@OneToMany
(
mappedBy
=
"mission"
)
private
List
<
Resource
>
resources
;
// TODO
// @ManyToOne ?
// private Country country;
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
Mission
mission
=
(
Mission
)
o
;
if
(
duration
!=
mission
.
duration
)
return
false
;
if
(!
start
.
equals
(
mission
.
start
))
return
false
;
return
objective
.
equals
(
mission
.
objective
);
}
@Override
public
int
hashCode
()
{
int
result
=
start
.
hashCode
();
result
=
31
*
result
+
duration
;
result
=
31
*
result
+
objective
.
hashCode
();
return
result
;
}
}
src/main/java/cz/fi/muni/pa165/seminar4/group7/secretservice/entity/Resource.java
View file @
22883c39
...
...
@@ -4,8 +4,13 @@ import com.sun.istack.NotNull;
import
lombok.Getter
;
import
lombok.Setter
;
import
javax.persistence.*
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
/**
* @author Tomáš Biloš
*/
...
...
@@ -23,11 +28,11 @@ public class Resource {
@Setter
private
String
name
;
//
@ManyToOne
//
@JoinColumn(name = "mission_id")
//
@Getter
//
@Setter
//
private Mission mission;
@ManyToOne
@JoinColumn
(
name
=
"mission_id"
)
@Getter
@Setter
private
Mission
mission
;
public
Resource
()
{
}
...
...
src/test/java/cz/fi/muni/pa165/seminar4/group7/secretservice/SecretServiceAppApplicationTests.java
View file @
22883c39
...
...
@@ -19,6 +19,5 @@ class SecretServiceAppApplicationTests {
resourceDao
.
save
(
new
Resource
(
1L
,
"Milk"
));
assertThat
(
resourceDao
.
findByName
(
"Milk"
).
getName
()).
isEqualTo
(
"Milk"
);
assertThat
(
resourceDao
.
findByName
(
"Milk"
).
getId
()).
isEqualTo
(
1L
);
}
}
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