use of org.iobserve.analysis.behavior.SingleOrNoneCollector in project iobserve-analysis by research-iobserve.
the class DynamicBehaviorModelTable method addInformation.
@Override
public void addInformation(final PayloadAwareEntryCallEvent event) {
final String eventSignature = this.getSignatureFromEvent(event);
final List<CallInformation> newCallInformations = new ArrayList<>();
try {
for (int i = 0; i < event.getParameters().length; i++) {
final String value = String.valueOf(this.parameterValueDoubleMapper.mapValue(event.getParameters()[i], event.getValues()[i]));
newCallInformations.add(new CallInformation(event.getParameters()[i], value));
}
// adding if no transition added yet
if (!this.signatures.containsKey(eventSignature)) {
this.addSignature(eventSignature);
}
final List<AggregatedCallInformation> aggCallInformations = this.signatures.get(eventSignature).getSecond();
for (final CallInformation newCallInformation : newCallInformations) {
// add new CallInfromation to the aggregation correctly
final Optional<AggregatedCallInformation> match = aggCallInformations.stream().filter(aggCallInformation -> aggCallInformation.belongsTo(newCallInformation)).collect(new SingleOrNoneCollector<AggregatedCallInformation>());
if (match.isPresent()) {
match.get().addCallInformation(newCallInformation);
} else {
// add new Callinformation
final AggregatedCallInformation newAggregatedCallInformation = new AggregatedCallInformation(this.strategy, newCallInformation);
aggCallInformations.add(newAggregatedCallInformation);
}
}
} catch (final IllegalArgumentException e) {
DynamicBehaviorModelTable.LOGGER.error("Exception while adding information to behavior table", e);
}
}
use of org.iobserve.analysis.behavior.SingleOrNoneCollector in project iobserve-analysis by research-iobserve.
the class BehaviorModelTable method addInformation.
@Override
public void addInformation(final PayloadAwareEntryCallEvent event) {
final String eventSignature = this.getSignatureFromEvent(event);
final List<CallInformation> newCallInformations = new ArrayList<>();
try {
for (int i = 0; i < event.getParameters().length; i++) {
newCallInformations.add(new CallInformation(event.getParameters()[i], String.valueOf(this.parameterValueDoubleMapper.mapValue(event.getParameters()[i], event.getValues()[i]))));
}
final List<AggregatedCallInformation> aggCallInformations = Arrays.asList(this.signatures.get(eventSignature).getSecond());
for (final CallInformation newCallInformation : newCallInformations) {
// add new CallInfromation to the aggregation correctly
final Optional<AggregatedCallInformation> match = aggCallInformations.stream().filter(aggCallInformation -> aggCallInformation.belongsTo(newCallInformation)).collect(new SingleOrNoneCollector<>());
match.ifPresent(aggCallInformation -> aggCallInformation.addCallInformation(newCallInformation));
}
} catch (final IllegalArgumentException e) {
BehaviorModelTable.LOGGER.error("Illegal argument exception", e);
}
}
Aggregations