Commit f6ca37a6 authored by Matija Obreza's avatar Matija Obreza

KPI presentation improved

parent 66ba35fd
......@@ -27,8 +27,7 @@ import org.springframework.data.jpa.repository.Query;
public interface ExecutionRunRepository extends JpaRepository<ExecutionRun, Long> {
List<ExecutionRun> findByExecution(Execution execution, Pageable pageable);
@Query("select er from ExecutionRun er where er.execution=?1 order by er.timestamp desc")
List<ExecutionRun> findLast(Execution execution, Pageable pageable);
......
......@@ -29,7 +29,7 @@ import org.springframework.data.jpa.repository.Query;
public interface ObservationRepository extends JpaRepository<Observation, Long>, ObservationCustomRepository {
@Query("select o from Observation o where o.executionRun=?1")
@Query("select o from Observation o where o.executionRun=?1 order by o.value desc")
List<Observation> findByExecutionRun(ExecutionRun executionRun, Pageable page);
List<Observation> findByExecutionRun(ExecutionRun executionRun);
......
......@@ -74,5 +74,6 @@ public interface KPIService {
ExecutionRun getExecutionRun(long runId);
List<Observation> listObservations(Execution execution, long dimensionKeyId, Pageable pageable);
}
......@@ -46,7 +46,6 @@ import org.genesys2.server.persistence.domain.kpi.ExecutionRunRepository;
import org.genesys2.server.persistence.domain.kpi.KPIParameterRepository;
import org.genesys2.server.persistence.domain.kpi.ObservationRepository;
import org.genesys2.server.service.KPIService;
import org.hibernate.event.spi.PreInsertEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
......@@ -283,12 +282,12 @@ public class KPIServiceImpl implements KPIService {
obs.setExecutionRun(executionRun);
}
ExecutionRun previousRun = findLastExecutionRun(execution);
if (previousRun != null) {
LOG.info("Original observations size: " + observations.size());
removeSameResult(previousRun, observations);
LOG.info("Trimmed observations size: " + observations.size());
}
// ExecutionRun previousRun = findLastExecutionRun(execution);
// if (previousRun != null) {
// LOG.info("Original observations size: " + observations.size());
// removeSameResult(previousRun, observations);
// LOG.info("Trimmed observations size: " + observations.size());
// }
if (observations.size() == 0) {
LOG.warn("No observations to save. Not storing execution run.");
......@@ -299,45 +298,50 @@ public class KPIServiceImpl implements KPIService {
return observationRepository.save(observations);
}
private void removeSameResult(ExecutionRun previousRun, List<Observation> observations) {
List<Observation> previousObservations = observationRepository.findByExecutionRun(previousRun);
LOG.info("Got previous observations size=" + previousObservations.size());
for (int i = observations.size() - 1; i >= 0; i--) {
if (!observationChanged(observations.get(i), previousObservations)) {
if (LOG.isDebugEnabled())
LOG.debug("Removing unchanged observation: " + observations.get(i));
observations.remove(i);
}
}
}
private boolean observationChanged(Observation observation, List<Observation> observations) {
Set<DimensionKey> dims = observation.getDimensions();
Observation previous = findObservationByDimensionKeys(observations, dims);
if (previous == null) {
// No matching previous observation
if (LOG.isDebugEnabled())
LOG.debug("No match found");
return true;
}
if (previous.getValue() != observation.getValue()) {
// Value is different
if (LOG.isDebugEnabled())
LOG.debug("Values are different " + previous + "!=" + observation);
return true;
}
// No change
return false;
}
private Observation findObservationByDimensionKeys(List<Observation> observations, Set<DimensionKey> dims) {
for (Observation obs : observations) {
if (obs.hasDimensionKeys(dims)) {
return obs;
}
}
return null;
}
// private void removeSameResult(ExecutionRun previousRun, List<Observation>
// observations) {
// List<Observation> previousObservations =
// observationRepository.findByExecutionRun(previousRun);
// LOG.info("Got previous observations size=" +
// previousObservations.size());
// for (int i = observations.size() - 1; i >= 0; i--) {
// if (!observationChanged(observations.get(i), previousObservations)) {
// if (LOG.isDebugEnabled())
// LOG.debug("Removing unchanged observation: " + observations.get(i));
// observations.remove(i);
// }
// }
// }
// private boolean observationChanged(Observation observation,
// List<Observation> observations) {
// Set<DimensionKey> dims = observation.getDimensions();
// Observation previous = findObservationByDimensionKeys(observations,
// dims);
// if (previous == null) {
// // No matching previous observation
// if (LOG.isDebugEnabled())
// LOG.debug("No match found");
// return true;
// }
// if (previous.getValue() != observation.getValue()) {
// // Value is different
// if (LOG.isDebugEnabled())
// LOG.debug("Values are different " + previous + "!=" + observation);
// return true;
// }
// // No change
// return false;
// }
//
// private Observation findObservationByDimensionKeys(List<Observation>
// observations, Set<DimensionKey> dims) {
// for (Observation obs : observations) {
// if (obs.hasDimensionKeys(dims)) {
// return obs;
// }
// }
// return null;
// }
@Transactional
private DimensionKey makeDimensionKey(DimensionKey dk) {
......@@ -413,6 +417,19 @@ public class KPIServiceImpl implements KPIService {
}
return res;
}
@Override
public List<Observation> listObservations(Execution execution, long dimensionKeyId, Pageable pageable) {
DimensionKey dk=dimensionKeyRepository.findOne(dimensionKeyId);
List<Observation> res = observationRepository.listObservationsByDimensionKey(execution, dk, pageable);
// Load lazy
for (Observation o : res) {
o.getExecutionRun().getId();
o.getDimensions().size();
}
return res;
}
private Set<DimensionKey> getDimensionKeys(Map<String, String> dimensionFilters) {
// TODO needs .equals()?
......@@ -433,7 +450,7 @@ public class KPIServiceImpl implements KPIService {
@Override
public List<ExecutionRun> listExecutionRuns(Execution execution, Pageable pageable) {
return executionRunRepository.findByExecution(execution, pageable);
return executionRunRepository.findLast(execution, pageable);
}
@Override
......
......@@ -39,6 +39,16 @@ public class KPIController {
model.addAttribute("executionRuns", kpiService.listExecutionRuns(execution, new PageRequest(page - 1, pageSize)));
return "/admin/kpi/execution";
}
@RequestMapping(value = "/exec/{executionName:.+}", method = RequestMethod.GET, params={"dk"})
public String execution(ModelMap model, @PathVariable("executionName") String executionName,
@RequestParam(value = "dk", required = true) long dimensionKeyId) {
Execution execution = kpiService.getExecution(executionName);
model.addAttribute("execution", execution);
model.addAttribute("observations", kpiService.listObservations(execution, dimensionKeyId, new PageRequest(0, pageSize)));
return "/admin/kpi/execution";
}
@RequestMapping(value = "/exec/{executionName}/run/{runId}", method = RequestMethod.GET)
public String executionRun(ModelMap model, @PathVariable("executionName") String executionName, @PathVariable("runId") long runId,
......@@ -48,7 +58,7 @@ public class KPIController {
model.addAttribute("execution", execution);
model.addAttribute("executionRun", executionRun);
Map<String, String> dimensionFilters = null;
model.addAttribute("observations", kpiService.listObservations(executionRun, dimensionFilters, new PageRequest(page - 1, pageSize)));
model.addAttribute("observations", kpiService.listObservations(executionRun, dimensionFilters, new PageRequest(page - 1, 500)));
return "/admin/kpi/run";
}
......
......@@ -613,3 +613,8 @@ resolver.resolve=Resolve
resolver.page.reverse.title=Resolution results
accession.purl=Permanent URL
menu.admin.kpi=KPI
admin.kpi.index.page=KPI
admin.kpi.execution.page=KPI Execution
admin.kpi.executionrun.page=Execution run details
\ No newline at end of file
......@@ -8,73 +8,74 @@
<title><spring:message code="admin.cache.page.title" /></title>
</head>
<body>
<h1>
<spring:message code="admin.cache.page.title" />
</h1>
<h1>
<spring:message code="admin.cache.page.title" />
</h1>
<div class="main-col-header clearfix">
<div class="nav-header pull-left">
<a class="" href="<c:url value="/admin/" />"><spring:message code="menu.admin.index" /></a>
<a class="" href="<c:url value="/admin/logger/" />"><spring:message code="menu.admin.loggers" /></a>
<a class="" href="<c:url value="/admin/ds2/" />"><spring:message code="menu.admin.ds2" /></a>
</div>
</div>
<%@ include file="/WEB-INF/jsp/admin/menu.jsp"%>
<form method="post" action="<c:url value="/admin/cache/clearTilesCache" />">
<input type="submit" class="btn btn-default" value="Clear Tiles cache" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<form method="post" action="<c:url value="/admin/cache/clearCaches" />">
<input type="submit" class="btn btn-default" value="Clear all caches" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
<c:forEach items="${cacheMaps}" var="cacheMap">
<h3><c:out value="${cacheMap.serviceName}" /> <c:out value="${cacheMap.name}" /></h3>
<c:set value="${cacheMap.mapStats}" var="mapStat" />
<div class="row">
<div class="col-xs-6 col-sm-4">
<spring:message code="cache.stat.map.ownedEntryCount" />
</div>
<div class="col-xs-6 col-sm-8">
<c:out value="${mapStat.ownedEntryCount}" />
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-4">
<spring:message code="cache.stat.map.lockedEntryCount" />
</div>
<div class="col-xs-6 col-sm-8">
<c:out value="${mapStat.lockedEntryCount}" />
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-4">
<spring:message code="cache.stat.map.puts" />
</div>
<div class="col-xs-6 col-sm-8">
<c:out value="${mapStat.putOperationCount}" />
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-4">
<spring:message code="cache.stat.map.hits" />
</div>
<div class="col-xs-6 col-sm-8">
<c:out value="${mapStat.hits}" />
</div>
</div>
</c:forEach>
<c:forEach items="${cacheOthers}" var="cacheOther">
<h3><c:out value="${cacheOther}" /> <c:out value="${cacheOther}" /></h3>
</c:forEach>
<form method="post" action="<c:url value="/admin/cache/clearTilesCache" />">
<input type="submit" class="btn btn-default" value="Clear Tiles cache" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<form method="post" action="<c:url value="/admin/cache/clearCaches" />">
<input type="submit" class="btn btn-default" value="Clear all caches" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<c:forEach items="${cacheMaps}" var="cacheMap">
<h3>
<c:out value="${cacheMap.serviceName}" />
<c:out value="${cacheMap.name}" />
</h3>
<c:set value="${cacheMap.mapStats}" var="mapStat" />
<div class="row">
<div class="col-xs-6 col-sm-4">
<spring:message code="cache.stat.map.ownedEntryCount" />
</div>
<div class="col-xs-6 col-sm-8">
<c:out value="${mapStat.ownedEntryCount}" />
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-4">
<spring:message code="cache.stat.map.lockedEntryCount" />
</div>
<div class="col-xs-6 col-sm-8">
<c:out value="${mapStat.lockedEntryCount}" />
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-4">
<spring:message code="cache.stat.map.puts" />
</div>
<div class="col-xs-6 col-sm-8">
<c:out value="${mapStat.putOperationCount}" />
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-4">
<spring:message code="cache.stat.map.hits" />
</div>
<div class="col-xs-6 col-sm-8">
<c:out value="${mapStat.hits}" />
</div>
</div>
</c:forEach>
<c:forEach items="${cacheOthers}" var="cacheOther">
<h3>
<c:out value="${cacheOther}" />
<c:out value="${cacheOther}" />
</h3>
</c:forEach>
</body>
</html>
\ No newline at end of file
......@@ -11,15 +11,8 @@
<h1>
<spring:message code="admin.page.title" />
</h1>
<%@ include file="/WEB-INF/jsp/admin/menu.jsp"%>
<div class="main-col-header clearfix">
<div class="nav-header pull-left">
<a class="" href="<c:url value="/admin/" />"><spring:message code="menu.admin.index" /></a>
<a class="" href="<c:url value="/admin/cache/" />"><spring:message code="menu.admin.caches" /></a>
<a class="" href="<c:url value="/admin/logger/" />"><spring:message code="menu.admin.loggers" /></a>
</div>
</div>
<h3>worldclim.org</h3>
<form method="post" action="<c:url value="/admin/ds2/worldclim/update" />">
<input type="submit" class="btn btn-default" value="Update worldclim.org" />
......
......@@ -12,14 +12,8 @@
<spring:message code="admin.page.title" />
</h1>
<div class="main-col-header clearfix">
<div class="nav-header pull-left">
<a class="" href="<c:url value="/admin/cache/" />"><spring:message code="menu.admin.caches" /></a>
<a class="" href="<c:url value="/admin/logger/" />"><spring:message code="menu.admin.loggers" /></a>
<a class="" href="<c:url value="/admin/ds2/" />"><spring:message code="menu.admin.ds2" /></a>
</div>
</div>
<%@ include file="/WEB-INF/jsp/admin/menu.jsp" %>
<h3>Full-text Search</h3>
<form method="post" action="<c:url value="/admin/reindex-elastic" />">
<input type="text" name="startAt" disabled="true" />
......
......@@ -12,31 +12,50 @@
<spring:message code="admin.kpi.execution.page" />
</h1>
<div class="main-col-header clearfix">
<div class="nav-header pull-left">
<a class="" href="<c:url value="/admin/cache/" />"><spring:message code="menu.admin.caches" /></a> <a class=""
href="<c:url value="/admin/logger/" />"
><spring:message code="menu.admin.loggers" /></a> <a class="" href="<c:url value="/admin/ds2/" />"><spring:message
code="menu.admin.ds2"
/></a> <a class="" href="<c:url value="/admin/kpi/" />"><spring:message code="menu.admin.kpi" /></a>
<%@ include file="/WEB-INF/jsp/admin/menu.jsp"%>
<c:if test="${executionRuns ne null}">
<div class="crop-details">
<c:forEach items="${executionRuns}" var="executionRun">
<div class="row">
<div class="col-xs-3">
<local:prettyTime date="${executionRun.timestamp}" locale="${pageContext.response.locale}" />
</div>
<div class="col-xs-5">
<a href="<c:url value="/admin/kpi/exec/${execution.name}/run/${executionRun.id}" />"><c:out
value="${timestamp}"
/> <local:prettyTime date="${executionRun.timestamp}" locale="${pageContext.response.locale}" /> </a>
</div>
</div>
</c:forEach>
</div>
</div>
</c:if>
<div class="crop-details">
<c:forEach items="${executionRuns}" var="executionRun">
<div class="row">
<div class="col-xs-3">
<local:prettyTime date="${executionRun.timestamp}" locale="${pageContext.response.locale}" />
<c:if test="${observations ne null}">
<div class="crop-details">
<c:forEach items="${observations}" var="obs">
<div class="row">
<div class="col-xs-4 col-sm-2 text-right">
<local:prettyTime date="${obs.executionRun.timestamp}" locale="${pageContext.response.locale}" />
</div>
<div class="col-xs-4 col-sm-2 text-right">
<c:out value="${obs.value}" />
</div>
<div class="col-xs-4 col-sm-8">
<c:forEach items="${obs.dimensions}" var="dim">
<div>
<a href="<c:url value="/admin/kpi/exec/${executionRun.execution.name}" />?dk=${dim.id}"> <c:out
value="${dim.value}"
/>
</a>
</div>
</c:forEach>
</div>
</div>
<div class="col-xs-5">
<a href="<c:url value="/admin/kpi/exec/${execution.name}/run/${executionRun.id}" />"><c:out value="${timestamp}" />
<local:prettyTime date="${executionRun.timestamp}" locale="${pageContext.response.locale}" />
</a>
</div>
</div>
</c:forEach>
</div>
</c:forEach>
</div>
</c:if>
</body>
</html>
\ No newline at end of file
......@@ -12,17 +12,7 @@
<spring:message code="admin.kpi.index.page" />
</h1>
<div class="main-col-header clearfix">
<div class="nav-header pull-left">
<a class="" href="<c:url value="/admin/cache/" />"><spring:message code="menu.admin.caches" /></a> <a class=""
href="<c:url value="/admin/logger/" />"
><spring:message code="menu.admin.loggers" /></a> <a class="" href="<c:url value="/admin/ds2/" />"><spring:message
code="menu.admin.ds2"
/></a> <a class="" href="<c:url value="/admin/kpi/" />"><spring:message code="menu.admin.kpi" /></a>
</div>
</div>
<h2>${execution}</h2>
<%@ include file="/WEB-INF/jsp/admin/menu.jsp"%>
<div class="crop-details">
<c:forEach items="${executions}" var="execution">
......@@ -35,8 +25,9 @@
</div>
<div class="col-xs-4">
<c:out value="${execution.parameter.title}" />
<small><b><c:out value="${execution.parameter.entity}" /></b>
<c:out value="${execution.parameter.condition}" /></small>
<small><b><c:out value="${execution.parameter.entity}" /></b> <c:out
value="${execution.parameter.condition}"
/></small>
</div>
<div class="col-xs-12">
<c:forEach items="${execution.executionDimensions}" var="dimension">
......
......@@ -9,20 +9,14 @@
</head>
<body>
<h1>
<spring:message code="admin.kpi.execution.page" />
<spring:message code="admin.kpi.executionrun.page" />
</h1>
<div class="main-col-header clearfix">
<div class="nav-header pull-left">
<a class="" href="<c:url value="/admin/cache/" />"><spring:message code="menu.admin.caches" /></a> <a class=""
href="<c:url value="/admin/logger/" />"
><spring:message code="menu.admin.loggers" /></a> <a class="" href="<c:url value="/admin/ds2/" />"><spring:message
code="menu.admin.ds2"
/></a> <a class="" href="<c:url value="/admin/kpi/" />"><spring:message code="menu.admin.kpi" /></a>
</div>
</div>
<%@ include file="/WEB-INF/jsp/admin/menu.jsp"%>
<h2><local:prettyTime date="${executionRun.timestamp}" locale="${pageContext.response.locale}" /></h2>
<h2>
<local:prettyTime date="${executionRun.timestamp}" locale="${pageContext.response.locale}" />
</h2>
<div class="crop-details">
<c:forEach items="${observations}" var="obs">
......@@ -31,8 +25,12 @@
<c:out value="${obs.value}" />
</div>
<div class="col-xs-8 col-sm-10">
<c:forEach items="${obs.dimensions}" var="dim">
<div><c:out value="${dim.value}" /></div>
<c:forEach items="${obs.dimensions}" var="dim">
<div>
<a href="<c:url value="/admin/kpi/exec/${executionRun.execution.name}" />?dk=${dim.id}">
<c:out value="${dim.value}" />
</a>
</div>
</c:forEach>
</div>
</div>
......
<div class="main-col-header clearfix">
<div class="nav-header pull-left">
<a class="" href="<c:url value="/admin/cache/" />"><spring:message code="menu.admin.caches" /></a> <a class=""
href="<c:url value="/admin/logger/" />"
><spring:message code="menu.admin.loggers" /></a> <a class="" href="<c:url value="/admin/ds2/" />"><spring:message
code="menu.admin.ds2"
/></a> <a class="" href="<c:url value="/admin/kpi/" />"><spring:message code="menu.admin.kpi" /></a>
</div>
</div>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment