diff --git a/src/main/java/de/bstly/board/businesslogic/EntryManager.java b/src/main/java/de/bstly/board/businesslogic/EntryManager.java index c8e3239..17ad8ea 100644 --- a/src/main/java/de/bstly/board/businesslogic/EntryManager.java +++ b/src/main/java/de/bstly/board/businesslogic/EntryManager.java @@ -95,14 +95,14 @@ public class EntryManager { /** * Fetch by ranking. * - * @param username the username - * @param date the date + * @param username the username + * @param date the date * @param flaggedStatus the flagged status - * @param tag the tag - * @param gravity the gravity - * @param page the page - * @param size the size - * @param asc the asc + * @param tag the tag + * @param gravity the gravity + * @param page the page + * @param size the size + * @param asc the asc * @return the page */ public Page fetchByRanking(String username, Instant date, FlaggedStatus flaggedStatus, @@ -122,13 +122,13 @@ public class EntryManager { /** * Fetch by date. * - * @param username the username - * @param date the date + * @param username the username + * @param date the date * @param flaggedStatus the flagged status - * @param tag the tag - * @param page the page - * @param size the size - * @param asc the asc + * @param tag the tag + * @param page the page + * @param size the size + * @param asc the asc * @return the page */ public Page fetchByDate(String username, Instant date, FlaggedStatus flaggedStatus, @@ -147,14 +147,14 @@ public class EntryManager { /** * Fetch by comments. * - * @param username the username - * @param date the date + * @param username the username + * @param date the date * @param flaggedStatus the flagged status - * @param tag the tag - * @param gravity the gravity - * @param page the page - * @param size the size - * @param asc the asc + * @param tag the tag + * @param gravity the gravity + * @param page the page + * @param size the size + * @param asc the asc * @return the page */ public Page fetchByComments(String username, Instant date, FlaggedStatus flaggedStatus, @@ -175,13 +175,13 @@ public class EntryManager { /** * Fetch by last comment. * - * @param username the username - * @param date the date + * @param username the username + * @param date the date * @param flaggedStatus the flagged status - * @param tag the tag - * @param page the page - * @param size the size - * @param asc the asc + * @param tag the tag + * @param page the page + * @param size the size + * @param asc the asc * @return the page */ public Page fetchByLastComment(String username, Instant date, @@ -201,14 +201,14 @@ public class EntryManager { /** * Fetch by user. * - * @param fromUser the from user - * @param username the username - * @param date the date + * @param fromUser the from user + * @param username the username + * @param date the date * @param flaggedStatus the flagged status - * @param tag the tag - * @param page the page - * @param size the size - * @param asc the asc + * @param tag the tag + * @param page the page + * @param size the size + * @param asc the asc * @return the page */ public Page fetchByUser(String fromUser, String username, Instant date, @@ -230,13 +230,13 @@ public class EntryManager { /** * Creates the entry query. * - * @param rawQuery the raw query - * @param username the username - * @param date the date + * @param rawQuery the raw query + * @param username the username + * @param date the date * @param flaggedStatus the flagged status - * @param tag the tag - * @param additional the additional - * @param orderBy the order by + * @param tag the tag + * @param additional the additional + * @param orderBy the order by * @return the query */ protected Query createEntryQuery(String rawQuery, String username, Instant date, @@ -284,12 +284,12 @@ public class EntryManager { /** * Creates the count query. * - * @param rawQuery the raw query - * @param username the username - * @param date the date + * @param rawQuery the raw query + * @param username the username + * @param date the date * @param flaggedStatus the flagged status - * @param tag the tag - * @param additional the additional + * @param tag the tag + * @param additional the additional * @return the query */ protected Query createCountQuery(String rawQuery, String username, Instant date, @@ -333,7 +333,7 @@ public class EntryManager { * * @param page the page * @param size the size - * @param asc the asc + * @param asc the asc * @return the page */ public Page fetchFlagged(int page, int size, boolean asc) { @@ -352,8 +352,8 @@ public class EntryManager { * Fetch by bookmarks. * * @param username the username - * @param page the page - * @param size the size + * @param page the page + * @param size the size * @return the page */ public Page fetchByBookmarks(String username, int page, int size) { @@ -371,9 +371,9 @@ public class EntryManager { * Apply metadata. * * @param username the username - * @param karma the karma - * @param entry the entry - * @param ignore the ignore + * @param karma the karma + * @param entry the entry + * @param ignore the ignore */ public void applyMetadata(String username, long karma, Entry entry, List ignore) { @@ -458,9 +458,9 @@ public class EntryManager { * Apply metadata. * * @param username the username - * @param karma the karma - * @param entries the entries - * @param ignore the ignore + * @param karma the karma + * @param entries the entries + * @param ignore the ignore */ public void applyMetadata(String username, long karma, List entries, List ignore) { @@ -497,6 +497,11 @@ public class EntryManager { */ public Entry save(Entry entry) { List tags = Lists.newArrayList(entry.getTags()); + + if (tags.size() > settingsManager.getMaxTags()) { + tags = tags.subList(0, settingsManager.getMaxTags() - 1); + } + entry = entryRepository.save(entry); tagManager.setForTarget(entry.getId(), tags); return entry; @@ -533,7 +538,7 @@ public class EntryManager { /** * Gets the user points. * - * @param entryId the entry id + * @param entryId the entry id * @param username the username * @return the user points */ diff --git a/src/main/java/de/bstly/board/businesslogic/SettingsManager.java b/src/main/java/de/bstly/board/businesslogic/SettingsManager.java index 67d0c0d..1bd7011 100644 --- a/src/main/java/de/bstly/board/businesslogic/SettingsManager.java +++ b/src/main/java/de/bstly/board/businesslogic/SettingsManager.java @@ -24,6 +24,8 @@ public class SettingsManager { private long UNVOTE_THRESH; @Value("${bstly.board.flagThresh:3}") private long FLAG_THRESH; + @Value("${bstly.board.maxTags:3}") + private int MAX_TAGS; /** * Gets the gravity. @@ -78,4 +80,11 @@ public class SettingsManager { public long getFlahThresh() { return FLAG_THRESH; } + + /** + * @return + */ + public int getMaxTags() { + return MAX_TAGS; + } } diff --git a/src/main/java/de/bstly/board/controller/SettingsController.java b/src/main/java/de/bstly/board/controller/SettingsController.java index ec31c8b..1c58fb0 100644 --- a/src/main/java/de/bstly/board/controller/SettingsController.java +++ b/src/main/java/de/bstly/board/controller/SettingsController.java @@ -36,6 +36,7 @@ public class SettingsController extends BaseController { settings.put("pageSize", getPageSize()); settings.put("entryDelay", getEntryDelay()); settings.put("commentDelay", getCommentDelay()); + settings.put("maxTags", settingsManager.getMaxTags()); settings.put("defaultGravity", settingsManager.getGravity()); settings.put("defaultPageSize", settingsManager.getPageSize()); settings.put("defaultEntryDelay", settingsManager.getEntryDelay());