Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
CTF
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grzegorz
CTF
Commits
4fdffdc0
Commit
4fdffdc0
authored
Feb 21, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use jsoncreator and jsonproperty to avoid constructing problems
parent
849c83b4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
22 deletions
+71
-22
configuration.yml
service/configuration.yml
+10
-0
ApplicationConfiguration.java
service/src/main/java/core/ApplicationConfiguration.java
+10
-0
Test.java
service/src/main/java/core/Test.java
+25
-0
Team.java
service/src/main/java/objects/Team.java
+14
-12
User.java
service/src/main/java/objects/User.java
+11
-9
TeamsRepository.java
service/src/main/java/repositories/TeamsRepository.java
+1
-1
No files found.
service/configuration.yml
View file @
4fdffdc0
...
@@ -4,6 +4,16 @@ dbName: db
...
@@ -4,6 +4,16 @@ dbName: db
flagHashMethod
:
"
MD5"
flagHashMethod
:
"
MD5"
testsTemporary
:
-
value
:
"
a"
asdf
:
"
ff"
-
value
:
"
a"
asdf
:
"
ff"
-
value
:
"
a"
asdf
:
"
ff"
-
value
:
"
a"
asdf
:
"
ff"
teams
:
teams
:
-
name
:
"
misiaczki"
-
name
:
"
misiaczki"
description
:
"
misiaczki
opis"
description
:
"
misiaczki
opis"
...
...
service/src/main/java/core/ApplicationConfiguration.java
View file @
4fdffdc0
...
@@ -17,6 +17,8 @@ public class ApplicationConfiguration extends Configuration {
...
@@ -17,6 +17,8 @@ public class ApplicationConfiguration extends Configuration {
private
List
<
Team
>
teams
;
private
List
<
Team
>
teams
;
private
List
<
Test
>
testsTemporary
;
public
String
getFlagHashMethod
()
{
public
String
getFlagHashMethod
()
{
return
flagHashMethod
;
return
flagHashMethod
;
}
}
...
@@ -29,6 +31,14 @@ public class ApplicationConfiguration extends Configuration {
...
@@ -29,6 +31,14 @@ public class ApplicationConfiguration extends Configuration {
this
.
teams
=
teams
;
this
.
teams
=
teams
;
}
}
public
List
<
Test
>
getTestsTemporary
()
{
return
testsTemporary
;
}
public
void
setTestsTemporary
(
List
<
Test
>
testsTemporary
)
{
this
.
testsTemporary
=
testsTemporary
;
}
public
void
setFlagHashMethod
(
String
flagHashMethod
)
{
public
void
setFlagHashMethod
(
String
flagHashMethod
)
{
this
.
flagHashMethod
=
flagHashMethod
;
this
.
flagHashMethod
=
flagHashMethod
;
}
}
...
...
service/src/main/java/core/Test.java
0 → 100644
View file @
4fdffdc0
package
core
;
/**
* Created by gpietrus on 21.02.2016.
*/
public
class
Test
{
private
String
value
;
private
String
asdf
;
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
public
String
getAsdf
()
{
return
asdf
;
}
public
void
setAsdf
(
String
asdf
)
{
this
.
asdf
=
asdf
;
}
}
service/src/main/java/objects/Team.java
View file @
4fdffdc0
package
objects
;
package
objects
;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.ImmutableMap
;
import
org.bson.Document
;
import
org.bson.Document
;
...
@@ -16,18 +18,15 @@ public class Team {
...
@@ -16,18 +18,15 @@ public class Team {
private
String
description
;
private
String
description
;
private
List
<
User
>
members
;
private
List
<
User
>
members
;
public
Team
(
Document
document
)
{
public
static
Team
fromDocument
(
Document
document
)
{
return
new
Team
(
document
.
get
(
"name"
).
toString
(),
document
.
get
(
"description"
).
toString
(),
((
ArrayList
<
Document
>)
document
.
get
(
"members"
))
//todo
.
stream
()
.
map
(
User:
:
fromDocument
)
.
collect
(
Collectors
.
toList
())
);
//todo: refactor mapping
//todo: refactor mapping
this
.
name
=
document
.
get
(
"name"
).
toString
();
this
.
description
=
document
.
get
(
"description"
).
toString
();
this
.
members
=
((
ArrayList
<
Document
>)
document
.
get
(
"members"
))
//todo
.
stream
()
.
map
(
document1
->
new
User
(
document1
))
.
collect
(
Collectors
.
toList
());
}
public
Team
()
{
//dummy constructor for json
}
}
public
List
<
User
>
getMembers
()
{
public
List
<
User
>
getMembers
()
{
...
@@ -38,7 +37,10 @@ public class Team {
...
@@ -38,7 +37,10 @@ public class Team {
this
.
members
=
members
;
this
.
members
=
members
;
}
}
public
Team
(
String
name
,
String
description
,
List
<
User
>
members
)
{
@JsonCreator
public
Team
(
@JsonProperty
(
"name"
)
String
name
,
@JsonProperty
(
"description"
)
String
description
,
@JsonProperty
(
"members"
)
List
<
User
>
members
)
{
this
.
name
=
name
;
this
.
name
=
name
;
this
.
description
=
description
;
this
.
description
=
description
;
this
.
members
=
members
;
this
.
members
=
members
;
...
...
service/src/main/java/objects/User.java
View file @
4fdffdc0
package
objects
;
package
objects
;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.ImmutableMap
;
import
org.bson.Document
;
import
org.bson.Document
;
...
@@ -14,17 +16,17 @@ public class User implements Principal {
...
@@ -14,17 +16,17 @@ public class User implements Principal {
private
String
password
;
private
String
password
;
private
String
email
;
private
String
email
;
public
User
(
Document
document
)
{
public
static
User
fromDocument
(
Document
document
)
{
this
.
name
=
document
.
get
(
"name"
).
toString
();
return
new
User
(
document
.
get
(
"name"
).
toString
(),
this
.
password
=
document
.
get
(
"password"
).
toString
();
document
.
get
(
"password"
).
toString
(),
this
.
email
=
document
.
get
(
"password"
).
toString
();
document
.
get
(
"password"
).
toString
()
);
}
}
// public User() {
@JsonCreator
// dummy constructor for json
public
User
(
@JsonProperty
(
"name"
)
String
name
,
// }
@JsonProperty
(
"password"
)
String
password
,
@JsonProperty
(
"email"
)
String
email
)
{
public
User
(
String
name
,
String
password
,
String
email
)
{
this
.
name
=
name
;
this
.
name
=
name
;
this
.
password
=
password
;
this
.
password
=
password
;
this
.
email
=
email
;
this
.
email
=
email
;
...
...
service/src/main/java/repositories/TeamsRepository.java
View file @
4fdffdc0
...
@@ -45,7 +45,7 @@ public class TeamsRepository implements Repository {
...
@@ -45,7 +45,7 @@ public class TeamsRepository implements Repository {
public
List
<
Team
>
getAll
()
{
public
List
<
Team
>
getAll
()
{
return
mongoDBConnector
.
getCollection
(
"teams"
)
return
mongoDBConnector
.
getCollection
(
"teams"
)
.
stream
()
.
stream
()
.
map
(
Team:
:
new
)
.
map
(
Team:
:
fromDocument
)
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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