-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconflictDetctionAlgorithm.py
49 lines (39 loc) · 1.88 KB
/
conflictDetctionAlgorithm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from classActivityHandler import ActivityHandler
from classActionConstraints import ActionConstraints
from classConflictDetectionEngine import ConflictDetectionEngine
# The class defines all the content of an event activity
class Activity:
def __init__(self,activity):
try:
self.activityTime = activity[0]
self.action = activity[1]
self.documentID = activity[2]
self.actorName = activity[5]
except LookupError as le:
return "Error in the key or index !!\n" + str(le)
except ValueError as ve:
return "Error in Value Entered !!\n" + str(ve)
except TypeError as te:
return "Error in Type matching !!\n" + str(te)
# Main program that extracts event logs, creates object and detects conflicts uisng detection engine
def detectmain(logdata, actionConstraints):
try:
# Initialize conflict detection engine
conflictDetectionEngine = ConflictDetectionEngine()
result = []
# Create an activity object for each activity and check for the conflict
for activity in logdata:
activityObject = Activity(activity)
# Create and activity handler and action constraints for the activity object
Handler = ActivityHandler()
activityHandler = Handler.handleActivity(activityObject)
actionConstraintsObj = ActionConstraints(activityObject, actionConstraints)
# Detect Conflcit for the activity
result.append(conflictDetectionEngine.checkConflict(activityHandler, actionConstraintsObj))
return result
except LookupError as le:
return "Error in the key or index !!\n" + str(le)
except ValueError as ve:
return "Error in Value Entered !!\n" + str(ve)
except TypeError as te:
return "Error in Type matching !!\n" + str(te)