Permalink
Browse files

fixed duplicated EventResults in MeasuredValue

  • Loading branch information...
Roman Heckendorf
Roman Heckendorf committed Jan 7, 2015
1 parent cfb9dd0 commit 0319945593648fd846eab9ccc8033ac04e009d2e
@@ -11,6 +11,7 @@
*.ipr
*.iws
projectFilesBackup
.idea
# ignore sublime-specifics
*.sublime-project
@@ -45,3 +46,6 @@ testorder*.txt
# ignore h2 dumps
*.h2.gzip
#ignore dataSource-Config
OpenSpeedMonitor-config.groovy
@@ -32,7 +32,7 @@ import de.iteratec.osm.csi.CsiValue
* </p>
*
* <p>
* FIXME mze-2013-09-13: Architecture improvement:
* FIXME mze-2013-09-13: Architecture improvement:
* All calculation relevant changes should be placed here, which means:
* Instead of code like:
* <pre>
@@ -102,7 +102,7 @@ class MeasuredValue implements CsiValue {
tag(index: 'started_and_iVal_and_aggr_and_tag_idx')
closedAndCalculated(defaultValue: false)
}
/**
* <p>
* Returns a list of the database identifiers of {@linkplain
@@ -126,10 +126,23 @@ class MeasuredValue implements CsiValue {
*/
void addToResultIds(Long newResultId){
List<Long> list = getResultIdsAsList()
if(list.contains(newResultId)) log.error("Didn't add EventResult to MeasuredValue because it was already in the list! (EventResult-ID=${newResultId}, MeasuredValue-ID=${this.ident()})")
if(list.contains(newResultId)) log.error("Didn't add EventResult to MeasuredValue because it was already in the list! (EventResult-ID=${newResultId}, MeasuredValue-ID=${this.ident()})")
list.add(newResultId)
resultIds = list.join(DELIMITER_RESULTIDS)
}
/**
* Check if the ResultId containing in the list of {@link EventResult}-identifiers
* @param resultId
* @return true if the result already in the list
*/
boolean containsInResultIds(Long resultId){
List<Long> list = getResultIdsAsList()
if(list.contains(resultId)){
log.error("EventResult in MeasuredValue is already in the list! (EventResult-ID=${newResultId}, MeasuredValue-ID=${this.ident()})")
return true
}
return false
}
/**
* Adds all {@link EventResult}-identifiers in resultIdsToAddAsList to the list of {@link EventResult}-identifiers, this value was calculated from.
* The results are just added, no identifiers are removed previously.
@@ -161,7 +161,7 @@ class EventMeasuredValueService {
newResult,
osmConfigCacheService.getCachedMinDocCompleteTimeInMillisecs(24),
osmConfigCacheService.getCachedMaxDocCompleteTimeInMillisecs(24))
if(csiRelevance){
if(csiRelevance && !toBeCalculated.containsInResultIds(newResult.ident())){
if (countResults > 0 && newResult.customerSatisfactionInPercent != null) {
Double sumOfPreviousResults = (toBeCalculated.value?toBeCalculated.value:0) * countResults
newValue = (sumOfPreviousResults + newResult.customerSatisfactionInPercent) / (countResults + 1)
BIN +13 KB lib/grails-rt.jar
Binary file not shown.

0 comments on commit 0319945

Please sign in to comment.