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
35de28f6
Commit
35de28f6
authored
Mar 09, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move public fields to task class
parent
0ff866c7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
22 deletions
+44
-22
Task.java
service/src/main/java/objects/tasks/Task.java
+43
-13
TasksRepository.java
service/src/main/java/repositories/TasksRepository.java
+1
-9
No files found.
service/src/main/java/objects/tasks/Task.java
View file @
35de28f6
...
@@ -8,11 +8,15 @@ import org.bson.types.ObjectId;
...
@@ -8,11 +8,15 @@ import org.bson.types.ObjectId;
import
org.mongodb.morphia.annotations.Entity
;
import
org.mongodb.morphia.annotations.Entity
;
import
org.mongodb.morphia.annotations.Id
;
import
org.mongodb.morphia.annotations.Id
;
import
java.lang.reflect.Field
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
@Entity
(
"tasks"
)
@Entity
(
"tasks"
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
Task
{
public
class
Task
{
@Id
@Id
private
ObjectId
id
;
private
ObjectId
id
;
@PublicProperty
@PublicProperty
...
@@ -23,7 +27,21 @@ public class Task {
...
@@ -23,7 +27,21 @@ public class Task {
private
List
<
Flag
>
flags
;
private
List
<
Flag
>
flags
;
private
TaskContent
taskContent
;
private
TaskContent
taskContent
;
public
Task
(
String
name
,
int
level
,
TaskType
type
,
List
<
Flag
>
flags
,
TaskContent
taskContent
)
{
public
static
String
[]
getPublicFields
()
{
//todo: move to db object?
//todo: move to task
Field
[]
declaredFields
=
Task
.
class
.
getDeclaredFields
();
List
<
String
>
publicFieldsNames
=
Stream
.
of
(
declaredFields
)
.
filter
(
field
->
field
.
getAnnotation
(
PublicProperty
.
class
)
!=
null
)
.
map
(
Field:
:
getName
)
.
collect
(
Collectors
.
toList
());
return
publicFieldsNames
.
toArray
(
new
String
[
publicFieldsNames
.
size
()]);
}
public
Task
(
String
name
,
int
level
,
TaskType
type
,
List
<
Flag
>
flags
,
TaskContent
taskContent
)
{
this
.
flags
=
flags
;
this
.
flags
=
flags
;
this
.
taskType
=
type
;
this
.
taskType
=
type
;
this
.
level
=
level
;
this
.
level
=
level
;
...
@@ -31,45 +49,57 @@ public class Task {
...
@@ -31,45 +49,57 @@ public class Task {
this
.
taskContent
=
taskContent
;
this
.
taskContent
=
taskContent
;
}
}
public
Task
()
{}
public
Task
()
{
}
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
this
.
name
=
name
;
}
}
public
int
getLevel
()
{
public
int
getLevel
()
{
return
level
;
return
level
;
}
}
public
void
setLevel
(
int
level
)
{
public
void
setLevel
(
int
level
)
{
this
.
level
=
level
;
this
.
level
=
level
;
}
}
public
TaskType
getTaskType
()
{
public
TaskType
getTaskType
()
{
return
taskType
;
return
taskType
;
}
}
public
void
setTaskType
(
TaskType
taskType
)
{
public
void
setTaskType
(
TaskType
taskType
)
{
this
.
taskType
=
taskType
;
this
.
taskType
=
taskType
;
}
}
public
List
<
Flag
>
getFlags
()
{
public
List
<
Flag
>
getFlags
()
{
return
flags
;
return
flags
;
}
}
public
void
setFlags
(
List
<
Flag
>
flags
)
{
public
void
setFlags
(
List
<
Flag
>
flags
)
{
this
.
flags
=
flags
;
this
.
flags
=
flags
;
}
}
public
TaskContent
getTaskContent
()
{
public
TaskContent
getTaskContent
()
{
return
taskContent
;
return
taskContent
;
}
}
public
void
setTaskContent
(
TaskContent
taskContent
)
{
public
void
setTaskContent
(
TaskContent
taskContent
)
{
this
.
taskContent
=
taskContent
;
this
.
taskContent
=
taskContent
;
}
}
}
}
service/src/main/java/repositories/TasksRepository.java
View file @
35de28f6
...
@@ -66,16 +66,8 @@ public class TasksRepository implements Repository
...
@@ -66,16 +66,8 @@ public class TasksRepository implements Repository
public
List
<
Task
>
getAllPublic
()
public
List
<
Task
>
getAllPublic
()
{
{
//todo: move to db object?
//todo: move to task
Field
[]
declaredFields
=
Task
.
class
.
getDeclaredFields
();
List
<
String
>
collect
=
Stream
.
of
(
declaredFields
)
.
filter
(
field
->
field
.
getAnnotation
(
PublicProperty
.
class
)
!=
null
)
.
map
(
Field:
:
getName
)
.
collect
(
Collectors
.
toList
());
return
datastore
.
createQuery
(
Task
.
class
)
return
datastore
.
createQuery
(
Task
.
class
)
.
retrievedFields
(
true
,
collect
.
toArray
(
new
String
[
collect
.
size
()]
))
//todo: refactor
.
retrievedFields
(
true
,
Task
.
getPublicFields
(
))
//todo: refactor
.
asList
();
.
asList
();
}
}
...
...
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