diff --git a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java index c17dfbee60aa2fc2fb0d3662065a27b8ce1def55..03504abbda4bf6154ae4778f8b7caca230ec6f85 100644 --- a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java +++ b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java @@ -2017,6 +2017,7 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware return qids; } + @Cacheable(value = "sortorder", key = "#p0.concat('-').concat(#p1).concat('-').concat(#p2)") @Override public SortOrder getSortOrder(String sessionId, String questionVariant, String subject) { String viewString = ""; @@ -2057,6 +2058,7 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware return sortOrder; } + @CachePut(value = "sortorder", key ="#sortOrder.sessionId.concat('-').concat(#sortOrder.questionVariant).concat('-').concat(#sortOrder.subject)") @Override public SortOrder createOrUpdateSortOrder(SortOrder sortOrder) { try { @@ -2089,6 +2091,7 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware return null; } + @CacheEvict(value = "sortorder", key ="#sortOrder.sessionId.concat('-').concat(#sortOrder.questionVariant).concat('-').concat(#sortOrder.subject)") @Override public void deleteSortOrder(SortOrder sortOrder) { try { diff --git a/src/main/java/de/thm/arsnova/entities/SortOrder.java b/src/main/java/de/thm/arsnova/entities/SortOrder.java index 468023f543f7e1551f5a9e488d2d1de721e2af25..f31950da37fa4e21ec26367aa866403ff5500719 100644 --- a/src/main/java/de/thm/arsnova/entities/SortOrder.java +++ b/src/main/java/de/thm/arsnova/entities/SortOrder.java @@ -84,5 +84,53 @@ public class SortOrder { public String get_rev() { return _rev; - } + } + + @Override + public int hashCode() { + // auto-generated! + final int prime = 31; + int result = 1; + result = prime * result + ((questionVariant == null) ? 0 : questionVariant.hashCode()); + result = prime * result + ((sessionId == null) ? 0 : sessionId.hashCode()); + result = prime * result + ((subject == null) ? 0 : subject.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + // auto-generated! + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + SortOrder other = (SortOrder) obj; + if (questionVariant == null) { + if (other.questionVariant != null) { + return false; + } + } else if (!questionVariant.equals(other.questionVariant)) { + return false; + } + if (sessionId == null) { + if (other.sessionId != null) { + return false; + } + } else if (!sessionId.equals(other.sessionId)) { + return false; + } + if (subject == null) { + if (other.subject != null) { + return false; + } + } else if (!subject.equals(other.subject)) { + return false; + } + return true; + } }