new File(cprFile).delete();
}
}
private Measurements extractMeasurements(String cprFile, List<MeasurableProperty> properties) {
Measurements result = new Measurements();
try {
ComparatorUtils compUtils = new ComparatorUtils();
List<CompareResult> compResult = compUtils.parseResponse(cprFile);
if (compResult.size() == 1) {
/* we compare two xcdl files, which correspond to one compSet */
for(MeasurableProperty p : properties) {
/*
* get all values for measureable properties that correspond to xcl properties:
* they have the pattern: xcl:<propertyName>:<metricName>
*/
String[] keyParts = p.getName().split(":");
if (keyParts.length == 3) {
if ("xcl".equals(keyParts[0])) {
CprProperty cprP =
compResult.get(0).getProperties().get(keyParts[1]);
if (cprP != null) {
String id = MetricToScaleMapping.getMetricId(keyParts[2]);
if (id != null) {
Value v = null;
Scale s = MetricToScaleMapping.getScale(id);
if (s == null) {
// There is a new XCLMetric we have not registered in MetricToScaleMapping yet...
log.debug("CPR: unkown metricId: " + id);
} else {
// scale found, so we can create a value object
v = s.createValue();
v.setScale(null);
CprMetricResult mResult = cprP.getResultMetrics().get(id);
if (mResult != null) {
if ("ok".equals(mResult.getState())) {
v.parse(mResult.getResult());
v.setComment("xcdl values(sample::result)=(" + cprP.getSource()+"::" + cprP.getTarget()+")");
} else {
v.setComment(mResult.getResult());
}
}
}
if (v != null) {
Measurement m = new Measurement();
m.setProperty(p);
// TODO: validate type of value with respect to property(scale)
m.setValue(v);
result.addMeasurement(m);
}
}
}
}
}