This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 69e1d326e8d4c77efed8e7965db2340823e43a48 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Dec 11 15:47:44 2014 +0100 add service to get all existing themes and types for question --- .../persistence/entity/QuestionTopiaDao.java | 25 ++++++++++++++++- .../coselmar/services/v1/QuestionsWebService.java | 32 ++++++++++++++++++++++ coselmar-rest/src/main/resources/mapping | 8 ++++-- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/QuestionTopiaDao.java b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/QuestionTopiaDao.java index 0d01ed1..4db0467 100644 --- a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/QuestionTopiaDao.java +++ b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/QuestionTopiaDao.java @@ -11,7 +11,7 @@ public class QuestionTopiaDao extends AbstractQuestionTopiaDao<Question> { public List<Question> findForExpert(CoselmarUser expert) { StringBuilder hqlBuilder = new StringBuilder("SELECT Q FROM " + Question.class.getName() + " Q " - + " INNER JOIN Q.participants CUG "); + + " INNER JOIN Q." + Question.PROPERTY_PARTICIPANTS + " CUG "); Map<String, Object> args = new HashMap<>(); @@ -32,4 +32,27 @@ public class QuestionTopiaDao extends AbstractQuestionTopiaDao<Question> { return questions; } + public List<String> findAllThemes() { + + StringBuilder hqlBuilder = + new StringBuilder("SELECT DISTINCT(themes)" + + " FROM " + Question.class.getName() + " Q " + + " INNER JOIN Q." + Question.PROPERTY_THEME + " themes "); + + List<String> values = findAll(hqlBuilder.toString()); + + return values; + } + + public List<String> findAllTypes() { + + StringBuilder hqlBuilder = + new StringBuilder("SELECT DISTINCT(Q. " + Question.PROPERTY_TYPE + ")" + + " FROM " + Question.class.getName() + " Q "); + + List<String> values = findAll(hqlBuilder.toString()); + + return values; + } + } //QuestionTopiaDao diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/QuestionsWebService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/QuestionsWebService.java index 59b3f39..726cb6c 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/QuestionsWebService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/QuestionsWebService.java @@ -630,6 +630,38 @@ public class QuestionsWebService extends CoselmarWebServiceSupport { commit(); } + public List<String> getThemes() throws InvalidCredentialException, UnauthorizedException { + + //XXX ymartel 20141211 : do we need authentication check for that ? +// // Check authentication +// String authorization = getContext().getHeader("Authorization"); +// UserWebToken userWebToken = checkAuthentication(authorization); +// +// // Check current user +// String fullCurrentUserId = getFullUserIdFromShort(userWebToken.getUserId()); +// getCoselmarUserDao().forTopiaIdEquals(fullCurrentUserId).findAny(); + + List<String> themes = getQuestionDao().findAllThemes(); + + return themes; + } + + public List<String> getTypes() throws InvalidCredentialException, UnauthorizedException { + + //XXX ymartel 20141211 : do we need authentication check for that ? +// // Check authentication +// String authorization = getContext().getHeader("Authorization"); +// UserWebToken userWebToken = checkAuthentication(authorization); +// +// // Check current user +// String fullCurrentUserId = getFullUserIdFromShort(userWebToken.getUserId()); +// getCoselmarUserDao().forTopiaIdEquals(fullCurrentUserId).findAny(); + + List<String> types = getQuestionDao().findAllTypes(); + + return types; + } + //////////////////////////////////////////////////////////////////////////// /////////////////////// Internal Parts ///////////////////////////// diff --git a/coselmar-rest/src/main/resources/mapping b/coselmar-rest/src/main/resources/mapping index 0268034..5f30c59 100644 --- a/coselmar-rest/src/main/resources/mapping +++ b/coselmar-rest/src/main/resources/mapping @@ -46,9 +46,11 @@ DELETE /v1/users/{userId} UsersWebService.deleteUser # Questions Api GET /v1/questions QuestionsWebService.getQuestions -GET /v1/questions/{questionId} QuestionsWebService.getQuestion -POST /v1/questions/{questionId} QuestionsWebService.saveQuestion -POST /v1/questions/{questionId}/documents QuestionsWebService.addDocuments +GET /v1/questions/themes QuestionsWebService.getThemes +GET /v1/questions/types QuestionsWebService.getTypes +GET /v1/questions/{questionId} QuestionsWebService.getQuestion +POST /v1/questions/{questionId} QuestionsWebService.saveQuestion +POST /v1/questions/{questionId}/documents QuestionsWebService.addDocuments POST /v1/questions QuestionsWebService.addQuestion DELETE /v1/questions/{questionId} QuestionsWebService.deleteQuestion -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.