Skip to content

Commit

Permalink
Merge pull request #179 from rwth-acis/feature/tags
Browse files Browse the repository at this point in the history
Feature/tags
  • Loading branch information
Tobasco99 authored May 3, 2023
2 parents 0c7ea8e + 55022cf commit 141effb
Show file tree
Hide file tree
Showing 17 changed files with 524 additions and 17 deletions.
4 changes: 2 additions & 2 deletions reqbaz/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ application {
}

repositories {
// Use JCenter for resolving dependencies.
jcenter()
mavenCentral()

// DBIS Archiva
maven {
Expand All @@ -50,6 +49,7 @@ repositories {

dependencies {
implementation 'org.jetbrains:annotations:20.1.0'
implementation 'org.liquibase:liquibase-core:4.20.0'

// Use JUnit test framework.
testImplementation 'junit:junit:4.13'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ twitterApiKey=
twitterApiKeySecret=
twitterClientId=
twitterClientSecret=
gfGameServiceUrl=
gfVisualizationServiceUrl=
gfUsername=
gfPassword=
gfGameId=
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import de.rwth.dbis.acis.bazaar.service.exception.ErrorCode;
import de.rwth.dbis.acis.bazaar.service.exception.ExceptionHandler;
import de.rwth.dbis.acis.bazaar.service.exception.ExceptionLocation;
import de.rwth.dbis.acis.bazaar.service.gamification.GamificationManager;
import de.rwth.dbis.acis.bazaar.service.internalization.Localization;
import de.rwth.dbis.acis.bazaar.service.notification.ActivityDispatcher;
import de.rwth.dbis.acis.bazaar.service.notification.EmailDispatcher;
Expand All @@ -52,7 +53,6 @@
import i5.las2peer.restMapper.RESTService;
import i5.las2peer.restMapper.annotations.ServicePath;
import io.swagger.annotations.*;
import lombok.Getter;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.http.client.utils.URIBuilder;
import org.jooq.SQLDialect;
Expand Down Expand Up @@ -91,6 +91,7 @@ public class BazaarService extends RESTService {
private final List<BazaarFunctionRegistrar> functionRegistrar;
private final NotificationDispatcher notificationDispatcher;
private final TweetDispatcher tweetDispatcher;
private final GamificationManager gamificationManager;
private final DataSource dataSource;

//CONFIG PROPERTIES
Expand All @@ -111,6 +112,12 @@ public class BazaarService extends RESTService {
protected String twitterClientId;
protected String twitterClientSecret;

protected String gfBaseUrl;
protected String gfUsername;
protected String gfPassword;
protected String gfGameId;
protected String gfNamespace;

public BazaarService() throws Exception {
setFieldValues();
Locale locale = new Locale(lang, country);
Expand Down Expand Up @@ -166,9 +173,10 @@ public BazaarService() throws Exception {
}

tweetDispatcher = new TweetDispatcher(this, twitterApiKey, twitterApiKeySecret, twitterClientId, twitterClientSecret);

new WeeklyNewProjectsTweetTask(this).schedule(timer);

gamificationManager = new GamificationManager(gfBaseUrl, gfUsername, gfPassword, gfGameId, gfNamespace);

notificationDispatcher.setBazaarService(this);
}

Expand Down Expand Up @@ -236,6 +244,10 @@ public TweetDispatcher getTweetDispatcher() {
return tweetDispatcher;
}

public GamificationManager getGamificationManager() {
return gamificationManager;
}

private void registerUserAtFirstLogin() throws Exception {
Agent agent = Context.getCurrent().getMainAgent();

Expand Down Expand Up @@ -274,9 +286,14 @@ private void registerUserAtFirstLogin() throws Exception {
int userId = user.getId();
// this.getNotificationDispatcher().dispatchNotification(user.getCreationDate(), Activity.ActivityAction.CREATE, MonitoringEvent.SERVICE_CUSTOM_MESSAGE_55, userId, Activity.DataType.USER, userId);
dalFacade.addUserToRole(userId, "LoggedInUser", null);
gamificationManager.initializeUser(userId, true);
} else {
// update lastLoginDate
dalFacade.updateLastLoginDate(userIdByLAS2PeerId);
// make sure logged-in user is added to gamification
if (!(agent instanceof AnonymousAgent)) {
gamificationManager.initializeUser(userIdByLAS2PeerId, false);
}
}
} catch (Exception ex) {
ExceptionHandler.getInstance().convertAndThrowException(ex, ExceptionLocation.BAZAARSERVICE, ErrorCode.UNKNOWN, Localization.getInstance().getResourceBundle().getString("error.first_login"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ private void synchronizeTags(Requirement modifiedRequirement, Requirement oldReq
checkTagChanges(modifiedRequirement);

// Remove tags no longer present
oldRequirement.getTags().stream().filter(tag -> modifiedRequirement.getTags().contains(tag)).forEach(tag -> {
oldRequirement.getTags().stream().filter(tag -> !modifiedRequirement.getTags().contains(tag)).forEach(tag -> {
try {
untagRequirement(tag.getId(), oldRequirement.getId());
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package de.rwth.dbis.acis.bazaar.service.dal.entities;

import com.fasterxml.jackson.annotation.JsonIgnore;
import de.rwth.dbis.acis.bazaar.service.dal.helpers.UserVote;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.jackson.Jacksonized;

import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;

@EqualsAndHashCode(callSuper = true)
@Data
Expand All @@ -26,6 +25,10 @@ public class Dashboard extends EntityBase {
@NotNull
private List<Requirement> requirements;

private List<Map<String, Object>> badges;

private Map<String, Object> status;

@JsonIgnore
@Override
public int getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import de.rwth.dbis.acis.bazaar.service.dal.helpers.SerializerViews;
import org.apache.commons.lang3.Validate;

import java.util.List;
import java.util.Map;

/**
* @since 9/16/2014
*/
public abstract class EntityBase implements IdentifiedById {

private List<Map<String, Object>> gamificationNotifications;

public String toJSON() throws JsonProcessingException {
return new ObjectMapper().registerModule(new JavaTimeModule())
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
Expand All @@ -45,4 +51,14 @@ public String toPrivateJSON() throws JsonProcessingException {
.writerWithView(SerializerViews.Private.class)
.writeValueAsString(this);
}

public void setGamificationNotifications(List<Map<String, Object>> gamificationNotifications) {
Validate.notNull(gamificationNotifications);
// prevent field to be sent if its empty
this.gamificationNotifications = gamificationNotifications.size() == 0 ? null : gamificationNotifications;
}

public List<Map<String, Object>> getGamificationNotifications() {
return gamificationNotifications;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.rwth.dbis.acis.bazaar.service.dal.entities;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
Expand All @@ -22,6 +21,5 @@ public class Tag extends EntityBase {
@NotNull
private String colour;

@JsonIgnore
private Integer projectId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package de.rwth.dbis.acis.bazaar.service.gamification;

import java.util.Map;

import lombok.Value;

@Value
public class GFNotification {

private Map<String, Object> data;
}
Loading

0 comments on commit 141effb

Please sign in to comment.