use of org.iobserve.stages.general.data.EntryCallEvent in project iobserve-analysis by research-iobserve.
the class SimpleBranchReference method computeBranchTransitions.
/**
* According to the reference usage model user sessions are created that exactly represent the
* user behavior of the reference usage model. The entry and exit times enable that the calls
* within the user sessions are ordered according to the reference usage model The branch
* transition counter ensures that each branch transition is visited by at least one user
* session.
*
* @param entryCallSequenceModel
* @param branch
* @param numberOfBranchTransitions
*
* @return list of branch transition counter
*/
private static List<Integer> computeBranchTransitions(final EntryCallSequenceModel entryCallSequenceModel, final Branch branch, final int numberOfBranchTransitions) {
final List<Integer> branchTransitionCounter = new ArrayList<>();
boolean areAllBranchesVisited = true;
do {
for (int i = 0; i < branch.getBranchTransitions_Branch().size(); i++) {
branchTransitionCounter.add(i, 0);
}
for (int i = 0; i < entryCallSequenceModel.getUserSessions().size(); i++) {
// Each user sessions represents randomly one of the branch transitions
final int branchDecisioner = TestHelper.getRandomInteger(numberOfBranchTransitions - 1, 0);
if (branchDecisioner == 0) {
SimpleBranchReference.sequenceConstructor(branchTransitionCounter, 0, entryCallSequenceModel, i, 0, 1);
} else if (branchDecisioner == 1) {
SimpleBranchReference.sequenceConstructor(branchTransitionCounter, 1, entryCallSequenceModel, i, 1, 0);
} else if (branchDecisioner == 2) {
SimpleBranchReference.sequenceConstructor(branchTransitionCounter, 2, entryCallSequenceModel, i, 2, 0);
} else if (branchDecisioner == 3) {
SimpleBranchReference.sequenceConstructor(branchTransitionCounter, 3, entryCallSequenceModel, i, 3, 0);
} else if (branchDecisioner == 4) {
SimpleBranchReference.sequenceConstructor(branchTransitionCounter, 4, entryCallSequenceModel, i, 4, 0);
} else {
throw new IllegalArgumentException("Illegal value of model element parameter");
}
final EntryCallEvent entryCallEvent3 = new EntryCallEvent(3, 4, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[2], ReferenceUsageModelBuilder.CLASS_SIGNATURE[2], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent3, true);
}
// Checks whether all branch transitions are represented within the user sessions
for (int i = 0; i < branchTransitionCounter.size(); i++) {
if (branchTransitionCounter.get(i) == 0) {
areAllBranchesVisited = false;
break;
}
}
} while (!areAllBranchesVisited);
return branchTransitionCounter;
}
use of org.iobserve.stages.general.data.EntryCallEvent in project iobserve-analysis by research-iobserve.
the class BranchModelCreator method setBranchSequence.
/**
* Sets the passed events as branch sequence of the passed branch. The sequenceStartIndex
* defines at which position of the passed events the branch sequence starts
*
* @param examinedBranch
* for that the branchSequence will be set
* @param events
* represent the sequence to set
* @param sequenceStartIndex
* states at which position of the passed events the branch sequence starts
*/
private void setBranchSequence(final Branch examinedBranch, final List<EntryCallEvent> events, final int sequenceStartIndex) {
final List<ISequenceElement> branchSequence = new ArrayList<>();
for (int j = sequenceStartIndex; j < events.size(); j++) {
final EntryCallEvent callEvent = events.get(j);
final CallElement callElement = new CallElement(callEvent.getClassSignature(), callEvent.getOperationSignature());
callElement.setAbsoluteCount(1);
branchSequence.add(callElement);
}
final ExitElement exitElement = new ExitElement();
exitElement.setAbsoluteCount(1);
branchSequence.add(exitElement);
examinedBranch.setBranchSequence(branchSequence);
}
use of org.iobserve.stages.general.data.EntryCallEvent in project iobserve-analysis by research-iobserve.
the class TBehaviorModelTableGeneration method execute.
@Override
protected void execute(final EntryCallSequenceModel entryCallSequenceModel) {
final List<UserSession> userSessions = entryCallSequenceModel.getUserSessions();
for (final UserSession userSession : userSessions) {
final List<EntryCallEvent> entryCalls = userSession.getEvents();
EntryCallEvent lastCall = null;
for (final EntryCallEvent eventCall : entryCalls) {
if (lastCall != null) {
this.modelTable.addTransition(lastCall, eventCall);
this.modelTable.addInformation(eventCall);
} else {
/**
* only called at first valid event (condition lastCall == null is not needed)
*/
this.modelTable.addInformation(eventCall);
}
lastCall = eventCall;
}
}
}
use of org.iobserve.stages.general.data.EntryCallEvent in project iobserve-analysis by research-iobserve.
the class TBehaviorModelPreperation method executeEntryCallSequenceModel.
/**
* Execute case object instanceof EntryCallSequenceModel.
*
* @param entryCallSequenceModel
* entryCallSequenceModel
*/
private void executeEntryCallSequenceModel(final EntryCallSequenceModel entryCallSequenceModel) {
if (this.behaviorModelTable == null) {
this.sequenceModelCache.add(entryCallSequenceModel);
} else {
final List<UserSession> userSessions = entryCallSequenceModel.getUserSessions();
for (final UserSession userSession : userSessions) {
final BehaviorModelTable modelTable = this.behaviorModelTable.getClearedCopy(this.keepEmptyTransitions);
final List<EntryCallEvent> entryCalls = userSession.getEvents();
EntryCallEvent lastCall = null;
for (final EntryCallEvent eventCall : entryCalls) {
final boolean isAllowed = modelTable.isAllowedSignature(eventCall);
if (lastCall != null && isAllowed) {
modelTable.addTransition(lastCall, eventCall);
modelTable.addInformation(eventCall);
} else if (isAllowed) {
// only called at first valid event
// (condition lastCall == null is not needed
modelTable.addInformation(eventCall);
}
lastCall = isAllowed ? eventCall : lastCall;
}
this.outputPort.send(modelTable);
}
}
}
use of org.iobserve.stages.general.data.EntryCallEvent in project iobserve-analysis by research-iobserve.
the class TraceOperationCleanupFilter method execute.
@Override
protected void execute(final UserSession session) throws Exception {
for (final EntryCallEvent event : session.getEvents()) {
event.setClassSignature(this.rewriter.rewriteClassSignature(event.getClassSignature()));
event.setClassSignature(this.rewriter.rewriteOperationSignature(event.getOperationSignature()));
}
}
Aggregations