Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dashboard #65

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion etc/service_custom_message.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,16 @@ SERVICE_CUSTOM_MESSAGE_53 = Get user
SERVICE_CUSTOM_MESSAGE_54 = Get active user
SERVICE_CUSTOM_MESSAGE_55 = Create user
SERVICE_CUSTOM_MESSAGE_56 = Update user
SERVICE_CUSTOM_MESSAGE_57 = Delete user
SERVICE_CUSTOM_MESSAGE_57 = Delete user

SERVICE_CUSTOM_MESSAGE_58 = Set PersonalisationData
SERVICE_CUSTOM_MESSAGE_59 = Get PersonalisationData

SERVICE_CUSTOM_MESSAGE_60 = Get Comments
SERVICE_CUSTOM_MESSAGE_61 = Get Requirements

SERVICE_CUSTOM_MESSAGE_62 = Get EntityOverview




Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ private void registerUserAtFirstLogin() throws Exception {
// create user
User.Builder userBuilder = User.geBuilder(email);
User user = userBuilder.admin(false).las2peerId(agent.getIdentifier()).userName(loginName).profileImage(profileImage)
.emailLeadSubscription(true).emailFollowSubscription(true).build();
.emailLeadSubscription(true).emailFollowSubscription(true).personalizationEnabled(true).build();
user = dalFacade.createUser(user);
int userId = user.getId();
this.getNotificationDispatcher().dispatchNotification(user.getCreationDate(), Activity.ActivityAction.CREATE, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_55,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ public Response getCategory(@PathParam("categoryId") int categoryId) {
* @return Response with the created project as a JSON object.
*/
@POST
@Path("/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "This method allows to create a new category under a given a project.")
Expand Down
10 changes: 5 additions & 5 deletions src/main/de/rwth/dbis/acis/bazaar/service/CommentsResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ public CommentsResource() throws Exception {
*
* @param page page number
* @param perPage number of comments by page
* @param embedParents embed context/parents of comment (project, requirement)
* @param search search string
* @param sort sort order
* @param filters set of comments to return
* @param embedParents embed context/parents of comment (project, requirement)
* @return Response with list of all requirements
*/
@GET
Expand All @@ -83,7 +84,7 @@ public Response getAllComments(
@ApiParam(value = "Elements of comments by page", required = false) @DefaultValue("10") @QueryParam("per_page") int perPage,
@ApiParam(value = "Search filter", required = false) @QueryParam("search") String search,
@ApiParam(value = "Sort", required = false, allowMultiple = true, allowableValues = "name,date") @DefaultValue("name") @QueryParam("sort") List<String> sort,
@ApiParam(value = "Filter", required = true, allowMultiple = false, allowableValues = "created, following, replies") @QueryParam("filters") List<String> filters,
@ApiParam(value = "Filter", required = true, allowMultiple = false, allowableValues = "created, following, replies, developing") @QueryParam("filters") List<String> filters,
@ApiParam(value = "Embed parents", required = true, allowMultiple = true, allowableValues = "project, requirement") @QueryParam("embedParents") List<String> embedParents)
{

Expand Down Expand Up @@ -135,9 +136,8 @@ public Response getAllComments(
commentResult = dalFacade.listAllComments(pageInfo);
}

//TODO Results in "No CommentRecord found with id: 0"
//bazaarService.getNotificationDispatcher().dispatchNotification(new Date(), Activity.ActivityAction.RETRIEVE, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_3,
// 0, Activity.DataType.COMMENT, internalUserId);
bazaarService.getNotificationDispatcher().dispatchNotification(new Date(), Activity.ActivityAction.RETRIEVE_LIST, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_60,
0, Activity.DataType.COMMENT, internalUserId);

Map<String, List<String>> parameter = new HashMap<>();
parameter.put("page", new ArrayList() {{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.rwth.dbis.acis.bazaar.service;

import de.rwth.dbis.acis.bazaar.service.dal.DALFacade;
import de.rwth.dbis.acis.bazaar.service.dal.entities.Activity;
import de.rwth.dbis.acis.bazaar.service.dal.entities.PersonalisationData;
import de.rwth.dbis.acis.bazaar.service.dal.entities.PrivilegeEnum;
import de.rwth.dbis.acis.bazaar.service.exception.BazaarException;
Expand Down Expand Up @@ -88,6 +89,9 @@ public Response getPersonalisationData(@PathParam("key") String key, @PathParam(
ExceptionHandler.getInstance().throwException(ExceptionLocation.BAZAARSERVICE, ErrorCode.AUTHORIZATION, Localization.getInstance().getResourceBundle().getString("error.authorization.personalisationData.read"));
}
PersonalisationData data = dalFacade.getPersonalisationData(internalUserId, key, version);
bazaarService.getNotificationDispatcher().dispatchNotification(new Date(), Activity.ActivityAction.RETRIEVE, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_59,
0, Activity.DataType.PERSONALISATION, internalUserId, new Activity.AdditionalObject(data));

return Response.ok(data.toJSON()).build();
} catch (BazaarException bex) {
if (bex.getErrorCode() == ErrorCode.AUTHORIZATION) {
Expand All @@ -111,8 +115,10 @@ public Response getPersonalisationData(@PathParam("key") String key, @PathParam(

/**
* This method allows to save a personalisationData
*
* @param key The plugins identifier
* @param version The plugins identifier
* @param data as JSON object
*
* @return Response with the created attachment as JSON object.
*/
@PUT
Expand Down Expand Up @@ -157,6 +163,9 @@ public Response setPersonalisationData(@PathParam("key") String key, @PathParam(
}
dalFacade.setPersonalisationData(fullData);

bazaarService.getNotificationDispatcher().dispatchNotification(new Date(), Activity.ActivityAction.UPDATE, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_58,
0, Activity.DataType.PERSONALISATION, internalUserId, new Activity.AdditionalObject(fullData));


return Response.ok(fullData.toJSON()).build();
} catch (BazaarException bex) {
Expand Down
26 changes: 18 additions & 8 deletions src/main/de/rwth/dbis/acis/bazaar/service/ProjectsResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
import io.swagger.annotations.*;
import jodd.vtor.Vtor;



import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.bind.DatatypeConverter;
import java.net.HttpURLConnection;
import java.util.*;
import java.util.stream.Collectors;

@Api(value = "projects", description = "Projects resource")
@SwaggerDefinition(
Expand Down Expand Up @@ -63,10 +66,13 @@ public ProjectsResource() throws Exception {
* @param perPage number of projects by page
* @param search search string
* @param sort sort order
* @param filters set of projects to return
* @param ids list of ids for projects that should be returned
* @param context java rs context used for logging
*
* @return Response with list of all projects
*/
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "This method returns the list of projects on the server.")
@ApiResponses(value = {
Expand All @@ -79,8 +85,9 @@ public Response getProjects(
@ApiParam(value = "Elements of project by page", required = false) @DefaultValue("10") @QueryParam("per_page") int perPage,
@ApiParam(value = "Search filter", required = false) @QueryParam("search") String search,
@ApiParam(value = "Sort", required = false, allowMultiple = true, allowableValues = "name,date,last_activity,requirement,follower") @DefaultValue("name") @QueryParam("sort") List<String> sort,
@ApiParam(value = "Filter", required = false, allowMultiple = true, allowableValues = "all, created, following") @QueryParam("filters") List<String> filters,
@ApiParam(value = "Ids", required = false, allowMultiple = true) @QueryParam("ids") List<Integer> ids) {
@ApiParam(value = "Filter", required = false, allowMultiple = true, allowableValues = "all, created, following, contributed") @QueryParam("filters") List<String> filters,
@ApiParam(value = "Ids", required = false, allowMultiple = true) @QueryParam("ids") List<Integer> ids,
@javax.ws.rs.core.Context javax.ws.rs.container.ContainerRequestContext context) {

DALFacade dalFacade = null;
try {
Expand All @@ -105,6 +112,8 @@ public Response getProjects(
sortList.add(sortField);
}



dalFacade = bazaarService.getDBConnection();
Integer internalUserId = dalFacade.getUserIdByLAS2PeerId(userId);

Expand All @@ -129,8 +138,8 @@ public Response getProjects(
// return public projects and the ones the user belongs to
projectsResult = dalFacade.listPublicAndAuthorizedProjects(pageInfo, internalUserId);
}
bazaarService.getNotificationDispatcher().dispatchNotification(new Date(), Activity.ActivityAction.RETRIEVE, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_3,
0, Activity.DataType.PROJECT, internalUserId);
bazaarService.getNotificationDispatcher().dispatchNotification(new Date(), Activity.ActivityAction.RETRIEVE_LIST, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_3,
0, Activity.DataType.PROJECT, internalUserId, new Activity.AdditionalObject(new Activity.RequestInformation(context)));

Map<String, List<String>> parameter = new HashMap<>();
parameter.put("page", new ArrayList() {{
Expand All @@ -145,6 +154,8 @@ public Response getProjects(
}});
}
parameter.put("sort", sort);
parameter.put("filters", filters);
parameter.put("ids", ids.stream().map(Object::toString).collect(Collectors.toList())); //List<String> from List<Integer>, thanks to https://stackoverflow.com/a/23024375/3567992

Response.ResponseBuilder responseBuilder = Response.ok();
responseBuilder = responseBuilder.entity(projectsResult.toJSON());
Expand Down Expand Up @@ -182,7 +193,7 @@ public Response getProjects(
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found"),
@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal server problems")
})
public Response getProject(@PathParam("projectId") int projectId) {
public Response getProject(@PathParam("projectId") int projectId, @javax.ws.rs.core.Context javax.ws.rs.container.ContainerRequestContext context) {
DALFacade dalFacade = null;
try {
String registrarErrors = bazaarService.notifyRegistrars(EnumSet.of(BazaarFunction.VALIDATION, BazaarFunction.USER_FIRST_LOGIN_HANDLING));
Expand All @@ -206,7 +217,7 @@ public Response getProject(@PathParam("projectId") int projectId) {
}
Project projectToReturn = dalFacade.getProjectById(projectId, internalUserId);
bazaarService.getNotificationDispatcher().dispatchNotification(new Date(), Activity.ActivityAction.RETRIEVE, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_4,
projectId, Activity.DataType.PROJECT, internalUserId);
projectId, Activity.DataType.PROJECT, internalUserId, new Activity.AdditionalObject(new Activity.RequestInformation(context)));
return Response.ok(projectToReturn.toJSON()).build();
} catch (BazaarException bex) {
if (bex.getErrorCode() == ErrorCode.AUTHORIZATION) {
Expand Down Expand Up @@ -235,7 +246,6 @@ public Response getProject(@PathParam("projectId") int projectId) {
* @return Response with the created project as a JSON object.
*/
@POST
@Path("/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "This method allows to create a new project.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public RequirementsResource() throws Exception {
* @param perPage number of requirements by page
* @param search search string
* @param sort sort order
* @param filters set of element returned
* @param embedParents list of parents to embed with the response
* @return Response with list of all requirements
*/
@GET
Expand All @@ -80,7 +82,7 @@ public Response getRequirements(
@ApiParam(value = "Elements of requirements by page", required = false) @DefaultValue("10") @QueryParam("per_page") int perPage,
@ApiParam(value = "Search filter", required = false) @QueryParam("search") String search,
@ApiParam(value = "Sort", required = false, allowMultiple = true, allowableValues = "name,date,last_activity,requirement,follower") @DefaultValue("name") @QueryParam("sort") List<String> sort,
@ApiParam(value = "Filter", required = true, allowMultiple = true, allowableValues = "created, following") @QueryParam("filters") List<String> filters,
@ApiParam(value = "Filter", required = true, allowMultiple = false, allowableValues = "created, following, contributed") @DefaultValue("created") @QueryParam("filters") List<String> filters,
@ApiParam(value = "Embed parents", required = true, allowMultiple = true, allowableValues = "project") @QueryParam("embedParents") List<String> embedParents) {

DALFacade dalFacade = null;
Expand Down Expand Up @@ -130,9 +132,10 @@ public Response getRequirements(
} else {
requirementsResult = dalFacade.listAllRequirements(pageInfo, internalUserId);
}
//TODO NotificationDispatcher tries to find Requirement with id 0 as additional Object, need to implement logic for multiple
//bazaarService.getNotificationDispatcher().dispatchNotification(new Date(), Activity.ActivityAction.RETRIEVE, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_3,
// 0, Activity.DataType.REQUIREMENT, internalUserId);

bazaarService.getNotificationDispatcher().dispatchNotification(new Date(), Activity.ActivityAction.RETRIEVE_LIST, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_61,
0, Activity.DataType.REQUIREMENT, internalUserId);


Map<String, List<String>> parameter = new HashMap<>();
parameter.put("page", new ArrayList() {{
Expand All @@ -146,6 +149,8 @@ public Response getRequirements(
add(String.valueOf(search));
}});
}
parameter.put("filters", filters);
parameter.put("embedParents", embedParents);
parameter.put("sort", sort);

Response.ResponseBuilder responseBuilder = Response.ok();
Expand Down Expand Up @@ -415,7 +420,7 @@ public Response getRequirementsForCategory(int categoryId, int page, int perPage
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found"),
@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal server problems")
})
public Response getRequirement(@PathParam("requirementId") int requirementId) {
public Response getRequirement(@PathParam("requirementId") int requirementId, @javax.ws.rs.core.Context javax.ws.rs.container.ContainerRequestContext context) {
DALFacade dalFacade = null;
try {
Agent agent = Context.getCurrent().getMainAgent();
Expand All @@ -428,7 +433,7 @@ public Response getRequirement(@PathParam("requirementId") int requirementId) {
Integer internalUserId = dalFacade.getUserIdByLAS2PeerId(userId);
Requirement requirement = dalFacade.getRequirementById(requirementId, internalUserId);
bazaarService.getNotificationDispatcher().dispatchNotification(new Date(), Activity.ActivityAction.RETRIEVE, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_25,
requirementId, Activity.DataType.REQUIREMENT, internalUserId);
requirementId, Activity.DataType.REQUIREMENT, internalUserId, new Activity.AdditionalObject(new Activity.RequestInformation(context)));
if (dalFacade.isRequirementPublic(requirementId)) {
boolean authorized = new AuthorizationManager().isAuthorized(internalUserId, PrivilegeEnum.Read_PUBLIC_REQUIREMENT, String.valueOf(requirement.getProjectId()), dalFacade);
if (!authorized) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/de/rwth/dbis/acis/bazaar/service/UsersResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ public Response getEntityOverview(
@ApiParam(value = "Search filter", required = false) @QueryParam("search") String search,
@ApiParam(value = "Types of entities to include", required = true, allowMultiple = true, allowableValues = "projects,categories,requirements") @QueryParam("include") List<String> include,
@ApiParam(value = "Sort", required = false, allowMultiple = true, allowableValues = "name,date,last_activity,requirement,follower") @DefaultValue("date") @QueryParam("sort") List<String> sort,
@ApiParam(value = "Filter", required = false, allowMultiple = true, allowableValues = "created, following, developing") @DefaultValue("created") @QueryParam("filters") List<String> filters){
//Possibly allow filtertype "all"?
@ApiParam(value = "Filter", required = false, allowMultiple = true, allowableValues = "created, following, developing") @DefaultValue("created") @QueryParam("filters") List<String> filters,
@javax.ws.rs.core.Context javax.ws.rs.container.ContainerRequestContext context){
DALFacade dalFacade = null;
try {
String registrarErrors = bazaarService.notifyRegistrars(EnumSet.of(BazaarFunction.VALIDATION, BazaarFunction.USER_FIRST_LOGIN_HANDLING));
Expand Down Expand Up @@ -273,13 +273,13 @@ public Response getEntityOverview(
for(String filterOption : filters) {
filterMap.put(filterOption,internalUserId.toString());
}
//Only used as wrapper for filter, sort & search
PageInfo pageInfo = new PageInfo(0, 0, filterMap, sortList, search);


EntityOverview result = dalFacade.getEntitiesForUser(include, pageInfo, internalUserId);
// Wrong SERVICE_CUSTOM_MESSAGE_3 ?
bazaarService.getNotificationDispatcher().dispatchNotification(new Date(), Activity.ActivityAction.RETRIEVE, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_3,
0, Activity.DataType.USER, internalUserId);
bazaarService.getNotificationDispatcher().dispatchNotification(new Date(), Activity.ActivityAction.RETRIEVE, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_62,
0, Activity.DataType.USER, internalUserId, new Activity.AdditionalObject(new Activity.RequestInformation(context)));


Response.ResponseBuilder responseBuilder = Response.ok();
Expand Down