Skip to content

Commit

Permalink
SAK-40018: codacy amendments
Browse files Browse the repository at this point in the history
  • Loading branch information
bjones86 authored and ern committed May 14, 2019
1 parent 4e69213 commit 5de2dfd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -749,46 +749,44 @@ private void consolidateEvent(Date dateTime, String eventId, String resourceRef,
lock.unlock();
}

}else if(StatsManager.SITEVISITEND_EVENTID.equals(eventId)){
}else if(StatsManager.SITEVISITEND_EVENTID.equals(eventId) && statsManager.getEnableSitePresences()){
// site presence ended
if(statsManager.getEnableSitePresences()) {
String pKey = siteId+userId+date;
lock.lock();
try{
SitePresenceConsolidation spc = presencesMap.get(pKey);
if(spc == null) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DATE, -1);
Date dateOneDayBefore = c.getTime();
pKey = siteId+userId+dateOneDayBefore;
spc = presencesMap.get(pKey);
}
if(spc == null) {
SitePresence sp = new SitePresenceImpl();
sp.setSiteId(siteId);
sp.setUserId(userId);
sp.setDate(date);
sp.setLastVisitStartTime(null);
spc = new SitePresenceConsolidation(sp, dateTime);
}
if(spc.sitePresence.getLastVisitStartTime() != null) {
long existingDuration = spc.sitePresence.getDuration();
long start = spc.sitePresence.getLastVisitStartTime().getTime();
long thisEventTime = dateTime.getTime();
long additionalDuration = thisEventTime - start;
if(additionalDuration > 4*60*60*1000) {
log.warn("A site presence is longer than 4h!: duration="+(additionalDuration/1000/60)+" min (SITE:"+siteId+", USER:"+userId+", DATE:"+date+")");
}
spc.sitePresence.setDuration(existingDuration + additionalDuration);
spc.sitePresence.setLastVisitStartTime(null);
String pKey = siteId+userId+date;
lock.lock();
try{
SitePresenceConsolidation spc = presencesMap.get(pKey);
if(spc == null) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DATE, -1);
Date dateOneDayBefore = c.getTime();
pKey = siteId+userId+dateOneDayBefore;
spc = presencesMap.get(pKey);
}
if(spc == null) {
SitePresence sp = new SitePresenceImpl();
sp.setSiteId(siteId);
sp.setUserId(userId);
sp.setDate(date);
sp.setLastVisitStartTime(null);
spc = new SitePresenceConsolidation(sp, dateTime);
}
if(spc.sitePresence.getLastVisitStartTime() != null) {
long existingDuration = spc.sitePresence.getDuration();
long start = spc.sitePresence.getLastVisitStartTime().getTime();
long thisEventTime = dateTime.getTime();
long additionalDuration = thisEventTime - start;
if(additionalDuration > 4*60*60*1000) {
log.warn("A site presence is longer than 4h!: duration="+(additionalDuration/1000/60)+" min (SITE:"+siteId+", USER:"+userId+", DATE:"+date+")");
}
presencesMap.put(pKey, spc);
}finally{
lock.unlock();
spc.sitePresence.setDuration(existingDuration + additionalDuration);
spc.sitePresence.setLastVisitStartTime(null);
}
presencesMap.put(pKey, spc);
}finally{
lock.unlock();
}
}
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.util.Map;
import java.util.Observable;
import java.util.Observer;
import java.util.TimeZone;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
Expand All @@ -58,7 +57,6 @@
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.util.WorkbookUtil;
import org.apache.xpath.operations.Bool;
import org.hibernate.Criteria;
import org.hibernate.criterion.Expression;
import org.springframework.core.io.ClassPathResource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected void onPageChanged()
// noop
}

String newToolbarId()
protected String newToolbarId()
{
toolbarIdCounter++;
return String.valueOf(toolbarIdCounter).intern();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ public void setSort(final S property, final SortOrder order)
}

@Override
public void detach() {}
public void detach()
{
// noop
}
}

0 comments on commit 5de2dfd

Please sign in to comment.