org.drools.verifier.dao.VerifierResultNormal Maven / Gradle / Ivy
package org.drools.verifier.dao;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.drools.verifier.report.components.Gap;
import org.drools.verifier.report.components.MissingNumberPattern;
import org.drools.verifier.report.components.RangeCheckCause;
import org.drools.verifier.report.components.Severity;
import org.drools.verifier.report.components.VerifierMessageBase;
/**
*
* @author Toni Rikkola
*/
class VerifierResultNormal implements VerifierResult {
private static final long serialVersionUID = -6207688526236713721L;
private Map gapsById = new TreeMap();
private DataTree gapsByFieldId = new DataTree();
private Map missingNumberPatternsById = new TreeMap();
private DataTree missingNumberPatternsByFieldId = new DataTree();
private List messages = new ArrayList();
private DataTree messagesBySeverity = new DataTree();
private VerifierData data = new VerifierDataMaps();
public void add(VerifierMessageBase message) {
messages.add(message);
messagesBySeverity.put(message.getSeverity(), message);
}
public Collection getBySeverity(
Severity severity) {
Collection result = messagesBySeverity
.getBranch(severity);
if (result == null) {
return Collections.emptyList();
} else {
return result;
}
}
public void add(Gap gap) {
gapsById.put(gap.getId(), gap);
// Put by field id.
gapsByFieldId.put(gap.getField().getId(), gap);
}
public void remove(Gap gap) {
gapsById.remove(gap.getId());
gapsByFieldId.remove(gap.getField().getId(), gap);
}
public Collection getGapsByFieldId(int fieldId) {
return gapsByFieldId.getBranch(fieldId);
}
public Collection getRangeCheckCauses() {
Collection result = new ArrayList();
result.addAll(gapsById.values());
result.addAll(missingNumberPatternsById.values());
return result;
}
public void add(MissingNumberPattern missingNumberPattern) {
missingNumberPatternsById.put(missingNumberPattern.getId(),
missingNumberPattern);
// Put by field id.
missingNumberPatternsByFieldId.put(missingNumberPattern.getField()
.getId(), missingNumberPattern);
}
public Collection getRangeCheckCausesByFieldId(int id) {
Collection result = new ArrayList();
result.addAll(gapsByFieldId.getBranch(id));
result.addAll(missingNumberPatternsByFieldId.getBranch(id));
return result;
}
public VerifierData getVerifierData() {
return data;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy