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
8765dfc9
Commit
8765dfc9
authored
Feb 22, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
solutions refactored
parent
de0d0c6f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
24 deletions
+20
-24
SolutionsResource.java
service/src/main/java/api/SolutionsResource.java
+1
-1
Solution.java
service/src/main/java/objects/Solution.java
+13
-7
SolutionsRepository.java
service/src/main/java/repositories/SolutionsRepository.java
+3
-16
UsersRepository.java
service/src/main/java/repositories/UsersRepository.java
+3
-0
No files found.
service/src/main/java/api/SolutionsResource.java
View file @
8765dfc9
...
...
@@ -37,7 +37,7 @@ public class SolutionsResource {
.
collect
(
Collectors
.
groupingBy
(
new
Function
<
Solution
,
String
>()
{
@Override
public
String
apply
(
Solution
solution
)
{
return
solution
.
getTask
Id
();
return
solution
.
getTask
Name
();
}
}))
.
entrySet
()
...
...
service/src/main/java/objects/Solution.java
View file @
8765dfc9
...
...
@@ -2,23 +2,29 @@ package objects;
import
com.google.common.collect.ImmutableMap
;
import
org.bson.Document
;
import
org.bson.types.ObjectId
;
import
org.mongodb.morphia.annotations.Entity
;
import
java.util.Map
;
/**
* Created by gpietrus on 20.02.2016.
*/
@Entity
(
"solutions"
)
public
class
Solution
{
private
String
taskId
;
private
ObjectId
id
;
private
String
taskName
;
private
String
teamId
;
public
Solution
(
String
teamId
,
String
task
Id
)
{
public
Solution
(
String
teamId
,
String
task
Name
)
{
this
.
teamId
=
teamId
;
this
.
task
Id
=
taskId
;
this
.
task
Name
=
taskName
;
}
public
String
getTaskId
()
{
return
taskId
;
public
Solution
()
{}
public
String
getTaskName
()
{
return
taskName
;
}
public
String
getTeamId
()
{
...
...
@@ -26,7 +32,7 @@ public class Solution {
}
public
Solution
(
Document
document
)
{
this
.
task
Id
=
document
.
get
(
"taskId
"
).
toString
();
//todo: refactor mapping
this
.
task
Name
=
document
.
get
(
"taskName
"
).
toString
();
//todo: refactor mapping
this
.
teamId
=
document
.
get
(
"teamId"
).
toString
();
}
...
...
@@ -34,7 +40,7 @@ public class Solution {
public
Map
<
String
,
String
>
toMap
()
{
return
ImmutableMap
.<
String
,
String
>
builder
()
.
put
(
"teamId"
,
teamId
)
.
put
(
"task
Id"
,
taskId
)
.
put
(
"task
Name"
,
taskName
)
.
build
();
}
}
service/src/main/java/repositories/SolutionsRepository.java
View file @
8765dfc9
...
...
@@ -5,9 +5,6 @@ import org.mongodb.morphia.Datastore;
import
javax.inject.Inject
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
* Created by gpietrus on 20.02.2016.
...
...
@@ -25,25 +22,15 @@ public class SolutionsRepository implements Repository {
// }
public
List
<
Solution
>
getAll
()
{
return
null
;
//todo
/* return mongoDBConnector.getCollection("solutions")
.stream()
.map(Solution::new)
.collect(Collectors.toList());*/
//todo: revert
return
datastore
.
createQuery
(
Solution
.
class
).
asList
();
}
public
void
add
(
Solution
solution
)
{
//todo
//todo: object/string
Map
<
String
,
Object
>
retypedMap
=
solution
.
toMap
().
entrySet
().
stream
()
.
collect
(
Collectors
.
toMap
(
(
Function
<
Map
.
Entry
<
String
,
String
>,
String
>)
Map
.
Entry
::
getKey
,
(
Function
<
Map
.
Entry
<
String
,
String
>,
Object
>)
Map
.
Entry
::
getValue
));
// mongoDBConnector.addDocument("solutions", new Document(retypedMap)); //todo: revert
datastore
.
save
(
solution
);
//todo: error handling?
}
public
void
clean
()
{
// mongoDBConnector.removeCollection("solutions"); //todo: revert
datastore
.
getCollection
(
Solution
.
class
).
drop
();
}
}
...
...
service/src/main/java/repositories/UsersRepository.java
View file @
8765dfc9
...
...
@@ -40,6 +40,9 @@ public class UsersRepository implements Repository {
// }
public
Optional
<
User
>
authenticateUser
(
BasicCredentials
basicCredentials
)
{
return
null
;
/*
Optional<User> userOptional = teamsRepository.getAll()
...
...
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