use of org.iobserve.stages.general.data.EntryCallEvent in project iobserve-analysis by research-iobserve.
the class BranchWithinBranchReference method createBranch.
/**
* Create a branch.
*
* @param branchTransitionCounter
* @param entryTime
* @param entryCallSequenceModel
* @param numberOfTransitionsOfInteriorBranches
* @param listOfbranchTransitionCounterInterior
* @param userSessionIndex
* @param operationId
* @return
*/
private static int createBranch(final List<Integer> branchTransitionCounter, final int entryTime, final UserSessionCollectionModel entryCallSequenceModel, final int numberOfTransitionsOfInteriorBranches, final List<List<Integer>> listOfbranchTransitionCounterInterior, final int userSessionIndex, final int operationId) {
final int countOfBranchTransition = branchTransitionCounter.get(operationId) + 1;
branchTransitionCounter.set(operationId, countOfBranchTransition);
final EntryCallEvent entryCallEvent = new EntryCallEvent(entryTime, entryTime + 1, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[operationId], ReferenceUsageModelBuilder.CLASS_SIGNATURE[operationId], String.valueOf(userSessionIndex), "hostname");
entryCallSequenceModel.getUserSessions().get(userSessionIndex).add(entryCallEvent, true);
int branchDecisioner = TestHelper.getRandomInteger(numberOfTransitionsOfInteriorBranches - 1, 0);
for (int k = 0; k < numberOfTransitionsOfInteriorBranches; k++) {
if (listOfbranchTransitionCounterInterior.get(operationId).get(k) == 0) {
branchDecisioner = k;
break;
}
}
// Within the branch transition again a random branch transition is chosen
if (branchDecisioner == 0) {
return BranchWithinBranchReference.createEntryCallEventForBranch(userSessionIndex, operationId, 0, 0, entryCallSequenceModel, entryTime + 2, listOfbranchTransitionCounterInterior);
} else if (branchDecisioner == 1) {
return BranchWithinBranchReference.createEntryCallEventForBranch(userSessionIndex, operationId, 1, 3, entryCallSequenceModel, entryTime + 2, listOfbranchTransitionCounterInterior);
} else if (branchDecisioner == 2) {
return BranchWithinBranchReference.createEntryCallEventForBranch(userSessionIndex, operationId, 2, 4, entryCallSequenceModel, entryTime + 2, listOfbranchTransitionCounterInterior);
} else {
return entryTime + 2;
}
}
use of org.iobserve.stages.general.data.EntryCallEvent in project iobserve-analysis by research-iobserve.
the class BranchWithinBranchReference method createEntryCallEventForBranch.
/**
* Helper function to create and add an entry call event to a call sequence model.
*
* @param index
* user session index
* @param branchDecisioner
* branch decision
* @param entryCallSequenceModel
* the sequence call model
* @param entryTime
* call entry time
* @param exitTime
* call exit time
* @param listOfbranchTransitionCounterInterior
* list of iterators
*/
private static int createEntryCallEventForBranch(final int index, final int iteratorId, final int branchDecisioner, final int signatureId, final UserSessionCollectionModel entryCallSequenceModel, final int entryTime, final List<List<Integer>> listOfbranchTransitionCounterInterior) {
final int countOfBranchTransition = listOfbranchTransitionCounterInterior.get(iteratorId).get(branchDecisioner) + 1;
listOfbranchTransitionCounterInterior.get(iteratorId).set(branchDecisioner, countOfBranchTransition);
final EntryCallEvent entryCallEvent = new EntryCallEvent(entryTime, entryTime + 1, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[signatureId], ReferenceUsageModelBuilder.CLASS_SIGNATURE[signatureId], String.valueOf(index), "hostname");
entryCallSequenceModel.getUserSessions().get(index).add(entryCallEvent, true);
return entryTime + 2;
}
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 UserSessionCollectionModel 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 SimpleBranchReference method sequenceConstructor.
/**
* Sequence constructor.
*
* @param branchTransitionCounter
* @param index
* @param entryCallSequenceModel
* @param loopCount
*/
private static void sequenceConstructor(final List<Integer> branchTransitionCounter, final int index, final UserSessionCollectionModel entryCallSequenceModel, final int loopCount, final int start, final int end) {
final int countOfBranchTransition = branchTransitionCounter.get(index) + 1;
branchTransitionCounter.set(index, countOfBranchTransition);
final EntryCallEvent entryCallEvent = new EntryCallEvent(1, 2, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[start], ReferenceUsageModelBuilder.CLASS_SIGNATURE[start], String.valueOf(loopCount), "hostname");
entryCallSequenceModel.getUserSessions().get(loopCount).add(entryCallEvent, true);
final EntryCallEvent entryCallEvent2 = new EntryCallEvent(3, 4, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[end], ReferenceUsageModelBuilder.CLASS_SIGNATURE[end], String.valueOf(loopCount), "hostname");
entryCallSequenceModel.getUserSessions().get(loopCount).add(entryCallEvent2, true);
}
use of org.iobserve.stages.general.data.EntryCallEvent in project iobserve-analysis by research-iobserve.
the class UserSessionToModelConverter method eventsToModel.
/**
* Converts a list of events into a behavior model
*
* @param events
* The list of events
* @return The behavior model
*/
public static BehaviorModelGED eventsToModel(final List<EntryCallEvent> events) {
final BehaviorModelGED model = new BehaviorModelGED();
final Iterator<EntryCallEvent> iterator = events.iterator();
// start with the node "init"
BehaviorModelNode currentNode = new BehaviorModelNode("Init");
model.getNodes().put("Init", currentNode);
BehaviorModelNode lastNode = currentNode;
// for all events
while (iterator.hasNext()) {
final PayloadAwareEntryCallEvent event = (PayloadAwareEntryCallEvent) iterator.next();
// current node is an existing node with the same name or if non-existing a new node
currentNode = model.getNodes().get(event.getOperationSignature());
if (currentNode == null) {
currentNode = new BehaviorModelNode(event.getOperationSignature());
}
// add node to model
model.getNodes().put(event.getOperationSignature(), currentNode);
// add edge to model
UserSessionToModelConverter.addEdge(event, model, lastNode, currentNode);
lastNode = currentNode;
}
return model;
}
Aggregations