Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
adapt
ace
Commits
8022b48a
Commit
8022b48a
authored
Nov 11, 2016
by
Michael Ritter
Browse files
Endpoint for querying collections
parent
16fb0803
Changes
1
Hide whitespace changes
Inline
Side-by-side
ace-am/src/main/java/edu/umiacs/ace/rest/ListController.java
View file @
8022b48a
...
@@ -5,15 +5,21 @@ import edu.umiacs.ace.util.PersistUtil;
...
@@ -5,15 +5,21 @@ import edu.umiacs.ace.util.PersistUtil;
import
javax.persistence.EntityManager
;
import
javax.persistence.EntityManager
;
import
javax.persistence.Query
;
import
javax.persistence.Query
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Root
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.MediaType
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
/**
/**
* Get a listing of groups/collections in ACE
*
* Created by shake on 10/22/14.
* Created by shake on 10/22/14.
*/
*/
@Path
(
"/"
)
@Path
(
"/"
)
...
@@ -75,4 +81,31 @@ public class ListController {
...
@@ -75,4 +81,31 @@ public class ListController {
return
groupless
;
return
groupless
;
}
}
/**
* New API method to get all collections with query parameters
*
* @return
*/
@GET
@Path
(
"collections"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
List
<
Collection
>
getCollections
(
@QueryParam
(
"group"
)
String
group
,
@QueryParam
(
"active"
)
Boolean
active
,
@QueryParam
(
"corrupt"
)
Boolean
corrupt
)
{
EntityManager
entityManager
=
PersistUtil
.
getEntityManager
();
CriteriaBuilder
cb
=
entityManager
.
getCriteriaBuilder
();
CriteriaQuery
<
Collection
>
cq
=
cb
.
createQuery
(
Collection
.
class
);
Root
<
Collection
>
coll
=
cq
.
from
(
Collection
.
class
);
cq
.
select
(
coll
);
if
(
active
!=
null
&&
active
)
{
cq
.
where
(
cb
.
equal
(
coll
.
get
(
"state"
),
'A'
));
}
if
(
corrupt
!=
null
&&
corrupt
)
{
cq
.
where
(
cb
.
equal
(
coll
.
get
(
"state"
),
'E'
));
}
return
entityManager
.
createQuery
(
cq
).
getResultList
();
}
}
}
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