Skip to content

Commit 8726f7c

Browse files
committed
Fix #503
1 parent 41203b4 commit 8726f7c

10 files changed

Lines changed: 228 additions & 40 deletions

File tree

cairis/config/cairis_model.dtd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,15 @@
390390
<!ATTLIST characteristic_synopsis actor_type (persona | asset | component) #REQUIRED>
391391
<!ATTLIST characteristic_synopsis actor CDATA #REQUIRED>
392392
<!ATTLIST characteristic_synopsis satisfaction (Satisfied | Weakly Satisfied | None | Weakly Denied | Denied) #IMPLIED>
393-
<!ELEMENT reference_synopsis EMPTY>
393+
<!ELEMENT reference_synopsis (system_goal*)>
394394
<!ATTLIST reference_synopsis reference CDATA #REQUIRED>
395395
<!ATTLIST reference_synopsis synopsis CDATA #REQUIRED>
396396
<!ATTLIST reference_synopsis dimension (goal | softgoal | task | belief) #REQUIRED>
397397
<!ATTLIST reference_synopsis actor_type (persona | asset | component) #REQUIRED>
398398
<!ATTLIST reference_synopsis actor CDATA #REQUIRED>
399399
<!ATTLIST reference_synopsis satisfaction (Satisfied | Weakly Satisfied | None | Weakly Denied | Denied) #IMPLIED>
400+
<!ELEMENT system_goal EMPTY>
401+
<!ATTLIST system_goal name CDATA #REQUIRED>
400402
<!ELEMENT step_synopsis EMPTY>
401403
<!ATTLIST step_synopsis usecase CDATA #REQUIRED>
402404
<!ATTLIST step_synopsis environment CDATA #REQUIRED>

cairis/config/synopses.dtd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@
2727
<!ATTLIST characteristic_synopsis actor_type (persona | asset | component) #REQUIRED>
2828
<!ATTLIST characteristic_synopsis actor CDATA #REQUIRED>
2929
<!ATTLIST characteristic_synopsis satisfaction (Satisfied | Weakly Satisfied | None | Weakly Denied | Denied) #IMPLIED>
30-
<!ELEMENT reference_synopsis EMPTY>
30+
<!ELEMENT reference_synopsis (system_goal*)>
3131
<!ATTLIST reference_synopsis reference CDATA #REQUIRED>
3232
<!ATTLIST reference_synopsis synopsis CDATA #REQUIRED>
3333
<!ATTLIST reference_synopsis dimension (goal | softgoal | task | belief) #REQUIRED>
3434
<!ATTLIST reference_synopsis actor_type (persona | asset | component) #REQUIRED>
3535
<!ATTLIST reference_synopsis actor CDATA #REQUIRED>
3636
<!ATTLIST reference_synopsis satisfaction (Satisfied | Weakly Satisfied | None | Weakly Denied | Denied) #IMPLIED>
37+
<!ELEMENT system_goal EMPTY>
38+
<!ATTLIST system_goal name CDATA #REQUIRED>
3739
<!ELEMENT step_synopsis EMPTY>
3840
<!ATTLIST step_synopsis usecase CDATA #REQUIRED>
3941
<!ATTLIST step_synopsis environment CDATA #REQUIRED>

cairis/core/MySQLDatabaseProxy.py

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,7 +3247,10 @@ def getReferenceSynopsis(self,refName):
32473247
dimName = row[2]
32483248
aType = row[3]
32493249
aName = row[4]
3250-
rs = ReferenceSynopsis(rsId,refName,synName,dimName,aType,aName)
3250+
synDim = row[5]
3251+
gsName = row[6]
3252+
goals = self.userGoalSystemGoals(rsId)
3253+
rs = ReferenceSynopsis(rsId,refName,synName,dimName,aType,aName,synDim,gsName,goals)
32513254
return rs
32523255

32533256
def getReferenceContribution(self,charName,refName):
@@ -3282,6 +3285,8 @@ def addReferenceSynopsis(self,rs):
32823285
actorName = rs.actor()
32833286
gSat = rs.satisfaction()
32843287
self.updateDatabase('call addReferenceSynopsis(:rsId,:ref,:rs,:dim,:atName,:actName,:gSat)',{'rsId':rsId,'ref':refName,'rs':rsName,'dim':rsDim,'atName':atName,'actName':actorName,'gSat':gSat},'MySQL error adding reference synopsis')
3288+
for sysGoal in rs.goals():
3289+
self.addUserSystemGoalLink(rsName,sysGoal)
32853290
return rsId
32863291

32873292
def updateReferenceSynopsis(self,rs):
@@ -3292,7 +3297,10 @@ def updateReferenceSynopsis(self,rs):
32923297
atName = rs.actorType()
32933298
actorName = rs.actor()
32943299
gSat = rs.satisfaction()
3295-
self.updateDatabase('call updateReferenceSynopsis(:rsId,:ref,:rs,:dim,:atName,:actName,:gSat)',{'rsId':rsId,'ref':refName,'rs':rsName,'dim':rsDim,'atName':atName,'actName':actorName,'gSat':gSat},'MySQL error updating reference synopsis')
3300+
session = self.updateDatabase('call deleteUserGoalComponents(:id)',{'id':rsId},'MySQL error deleting user goal components',None,False)
3301+
self.updateDatabase('call updateReferenceSynopsis(:rsId,:ref,:rs,:dim,:atName,:actName,:gSat)',{'rsId':rsId,'ref':refName,'rs':rsName,'dim':rsDim,'atName':atName,'actName':actorName,'gSat':gSat},'MySQL error updating reference synopsis',session)
3302+
for sysGoal in rs.goals():
3303+
self.addUserSystemGoalLink(rsName,sysGoal)
32963304

32973305
def addCharacteristicSynopsis(self,cs):
32983306
cName = cs.reference()
@@ -3302,6 +3310,8 @@ def addCharacteristicSynopsis(self,cs):
33023310
actorName = cs.actor()
33033311
gSat = cs.satisfaction()
33043312
self.updateDatabase('call addCharacteristicSynopsis(:cName,:csName,:csDim,:atName,:actName,:gSat)',{'cName':cName,'csName':csName,'csDim':csDim,'atName':atName,'actName':actorName,'gSat':gSat},'MySQL error adding characteristic synopsis')
3313+
for sysGoal in cs.goals():
3314+
self.addUserSystemGoalLink(csName,sysGoal)
33053315

33063316
def updateCharacteristicSynopsis(self,cs):
33073317
cName = cs.reference()
@@ -3310,7 +3320,10 @@ def updateCharacteristicSynopsis(self,cs):
33103320
atName = cs.actorType()
33113321
actorName = cs.actor()
33123322
gSat = cs.satisfaction()
3313-
self.updateDatabase('call updateCharacteristicSynopsis(:cName,:csName,:csDim,:atName,:actName,:gSat)',{'cName':cName,'csName':csName,'csDim':csDim,'atName':atName,'actName':actorName,'gSat':gSat},'MySQL error updating characteristic synopsis')
3323+
session = self.updateDatabase('call deleteUserGoalComponents(:id)',{'id':cs.id()},'MySQL error deleting user goal components',None,False)
3324+
self.updateDatabase('call updateCharacteristicSynopsis(:cName,:csName,:csDim,:atName,:actName,:gSat)',{'cName':cName,'csName':csName,'csDim':csDim,'atName':atName,'actName':actorName,'gSat':gSat},'MySQL error updating characteristic synopsis',session)
3325+
for sysGoal in cs.goals():
3326+
self.addUserSystemGoalLink(csName,sysGoal)
33143327

33153328
def referenceCharacteristic(self,refName): return self.responseList('call referenceCharacteristic(:ref)',{'ref':refName},'MySQL error getting characteristics associated with reference ' + refName)
33163329

@@ -4864,8 +4877,16 @@ def checkTrace(self,fromObjt,fromName,toObjt,toName):
48644877
def getUserGoals(self,constraintId = -1):
48654878
rows = self.responseList('call getUserGoals(:id)',{'id':constraintId},'MySQL error getting user goals')
48664879
objts = []
4867-
for row in rows:
4868-
objts.append(ReferenceSynopsis(row[0],row[1],row[2],row[3],'persona',row[4],row[5],row[6]))
4880+
for row in rows:
4881+
rsId = row[0]
4882+
refName = row[1]
4883+
synName = row[2]
4884+
dimName = row[3]
4885+
personaName = row[4]
4886+
synDim = row[5]
4887+
gsName = row[6]
4888+
sysGoals = self.userGoalSystemGoals(rsId)
4889+
objts.append(ReferenceSynopsis(rsId,refName,synName,dimName,'persona',personaName,synDim,gsName,sysGoals))
48694890
return objts
48704891

48714892
def addUserGoal(self,objt):
@@ -4876,6 +4897,8 @@ def addUserGoal(self,objt):
48764897
personaName = objt.actor()
48774898
gSat = objt.satisfaction()
48784899
self.updateDatabase('call addUserGoal(:ugId,:refName,:synName,:dimName,:personaName,:gSat)',{'ugId':ugId,'refName':refName,'synName':synName,'dimName':dimName,'personaName':personaName,'gSat':gSat},'MySQL error adding user goal')
4900+
for sysGoal in objt.goals():
4901+
self.addUserSystemGoalLink(synName,sysGoal)
48794902

48804903
def updateUserGoal(self,objt):
48814904
ugId = objt.id()
@@ -4884,7 +4907,10 @@ def updateUserGoal(self,objt):
48844907
dimName = objt.dimension()
48854908
personaName = objt.actor()
48864909
gSat = objt.satisfaction()
4887-
self.updateDatabase('call updateUserGoal(:ugId,:refName,:synName,:dimName,:personaName,:gSat)',{'ugId':ugId,'refName':refName,'synName':synName,'dimName':dimName,'personaName':personaName,'gSat':gSat},'MySQL error updating user goal')
4910+
session = self.updateDatabase('call deleteUserGoalComponents(:id)',{'id':ugId},'MySQL error deleting user goal components',None,False)
4911+
self.updateDatabase('call updateUserGoal(:ugId,:refName,:synName,:dimName,:personaName,:gSat)',{'ugId':ugId,'refName':refName,'synName':synName,'dimName':dimName,'personaName':personaName,'gSat':gSat},'MySQL error updating user goal',session)
4912+
for sysGoal in objt.goals():
4913+
self.addUserSystemGoalLink(synName,sysGoal)
48884914

48894915
def deleteUserGoal(self,ugId = -1):
48904916
self.deleteObject(ugId,'user_goal')
@@ -4904,7 +4930,7 @@ def getGoalContributionsTable(self,sourceId = -1, targetId = -1):
49044930
return objts
49054931

49064932
def deleteGoalContribution(self,src,tgt):
4907-
self.updateDatabase(' call deleteGoalContribution(:src,:tgt)',{'src':src,'tgt':tgt},'MySQL error deleting goal contribution')
4933+
self.updateDatabase('call deleteGoalContribution(:src,:tgt)',{'src':src,'tgt':tgt},'MySQL error deleting goal contribution')
49084934

49094935
def taskContributions(self,taskName,envName):
49104936
rows = self.responseList('call getTaskContributions(:taskName,:envName)',{'taskName':taskName,'envName':envName},'MySQL error getting task contributions')
@@ -4918,3 +4944,9 @@ def conflictingPersonaCharacteristics(self,pName,ugName):
49184944
if (len(objts) == 1 and objts[0] == ''):
49194945
objts = []
49204946
return objts
4947+
4948+
def addUserSystemGoalLink(self,ugName,sgName):
4949+
self.updateDatabase('call addUserSystemGoalLink(:ugName,:sgName)',{'ugName':ugName,'sgName':sgName},'MySQL error adding user/system goal link')
4950+
4951+
def userGoalSystemGoals(self,ugId):
4952+
return self.responseList('call userGoalSystemGoals(:ugId)',{'ugId':ugId},'MySQL error getting user goal system goals')

cairis/core/ReferenceSynopsis.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
__author__ = 'Shamal Faily'
1919

2020
class ReferenceSynopsis:
21-
def __init__(self,rsId,refName,synName,dimName,aType,aName,synDim = 'document_reference',initialSatisfaction = 'None'):
21+
def __init__(self,rsId,refName,synName,dimName,aType,aName,synDim = 'document_reference',initialSatisfaction = 'None',goals=[]):
2222
self.theId = rsId
2323
self.theReference = refName
2424
self.theSynopsis = synName
@@ -27,6 +27,7 @@ def __init__(self,rsId,refName,synName,dimName,aType,aName,synDim = 'document_re
2727
self.theActor = aName
2828
self.theSynopsisDimension = synDim
2929
self.theInitialSatisfaction = initialSatisfaction
30+
self.theRelatedGoals = goals
3031

3132
def id(self): return self.theId
3233
def setId(self,newId): self.theId = newId
@@ -37,3 +38,4 @@ def actorType(self): return self.theActorType
3738
def actor(self): return self.theActor
3839
def synopsisDimension(self): return self.theSynopsisDimension
3940
def satisfaction(self): return self.theInitialSatisfaction
41+
def goals(self): return self.theRelatedGoals

cairis/mio/SynopsesContentHandler.py

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def __init__(self,session_id = None):
3535
self.theReferenceContributions = []
3636
self.theUseCaseContributions = []
3737
self.theTaskContributions = []
38+
self.resetSynopsisAttributes()
3839

3940
def resolveEntity(self,publicId,systemId):
4041
return systemId
@@ -57,32 +58,40 @@ def useCaseContributions(self):
5758
def taskContributions(self):
5859
return self.theTaskContributions
5960

61+
def resetSynopsisAttributes(self):
62+
self.theCharacteristic = ''
63+
self.theReference = ''
64+
self.theSynopsis = ''
65+
self.theDimensionName = ''
66+
self.theActorType = ''
67+
self.theActor = ''
68+
self.theInitialSatisfaction = 'None'
69+
self.theSystemGoals = []
70+
6071
def startElement(self,name,attrs):
6172
self.currentElementName = name
6273
if name == 'characteristic_synopsis':
63-
cName = attrs['characteristic']
64-
synName = attrs['synopsis']
65-
dimName = attrs['dimension']
66-
aType = attrs['actor_type']
67-
aName = attrs['actor']
68-
gSat = 'None'
74+
self.theCharacteristic = attrs['characteristic']
75+
self.theSynopsis = attrs['synopsis']
76+
self.theDimensionName = attrs['dimension']
77+
self.theActorType = attrs['actor_type']
78+
self.theActor = attrs['actor']
6979
try:
70-
gSat = attrs['satisfaction']
80+
self.theInitialSatisfaction = attrs['satisfaction']
7181
except KeyError:
72-
gSat = 'None'
73-
self.theCharacteristicSynopses.append(ReferenceSynopsis(-1,cName,synName,dimName,aType,aName,'persona_characteristic',gSat))
82+
pass
7483
elif name == 'reference_synopsis':
75-
refName = attrs['reference']
76-
synName = attrs['synopsis']
77-
dimName = attrs['dimension']
78-
aType = attrs['actor_type']
79-
aName = attrs['actor']
80-
gSat = 'None'
84+
self.theReference = attrs['reference']
85+
self.theSynopsis = attrs['synopsis']
86+
self.theDimensionName = attrs['dimension']
87+
self.theActorType = attrs['actor_type']
88+
self.theActor = attrs['actor']
8189
try:
82-
gSat = attrs['satisfaction']
90+
self.theInitialSatisfaction = attrs['satisfaction']
8391
except KeyError:
84-
gSat = 'None'
85-
self.theReferenceSynopses.append(ReferenceSynopsis(-1,refName,synName,dimName,aType,aName,'document_reference',gSat))
92+
pass
93+
elif name == 'system_goal':
94+
self.theSystemGoals.append(attrs['name'])
8695
elif name == 'step_synopsis':
8796
ucName = attrs['usecase']
8897
envName = attrs['environment']
@@ -109,3 +118,11 @@ def startElement(self,name,attrs):
109118
refName = attrs['referent']
110119
cont = attrs['contribution']
111120
self.theTaskContributions.append(TaskContribution(taskName,refName,envName,cont))
121+
122+
def endElement(self,name):
123+
if name == 'characteristic_synopsis':
124+
self.theCharacteristicSynopses.append(ReferenceSynopsis(-1,self.theCharacteristic,self.theSynopsis,self.theDimensionName,self.theActorType,self.theActor,'persona_characteristic',self.theInitialSatisfaction,self.theSystemGoals))
125+
self.resetSynopsisAttributes()
126+
elif name == 'reference_synopsis':
127+
self.theReferenceSynopses.append(ReferenceSynopsis(-1,self.theReference,self.theSynopsis,self.theDimensionName,self.theActorType,self.theActor,'document_reference',self.theInitialSatisfaction,self.theSystemGoals))
128+
self.resetSynopsisAttributes()

cairis/sql/init.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ DROP TABLE IF EXISTS usecase_pc_contribution;
8686
DROP TABLE IF EXISTS usecase_tc_contribution;
8787
DROP TABLE IF EXISTS usecase_dr_contribution;
8888
DROP TABLE IF EXISTS ice_ic_contribution;
89+
DROP TABLE IF EXISTS user_system_goal_link;
8990
DROP TABLE IF EXISTS document_reference_contribution;
9091
DROP TABLE IF EXISTS requirement_reference_contribution;
9192
DROP TABLE IF EXISTS document_reference_synopsis;
@@ -2764,6 +2765,13 @@ CREATE TABLE document_reference_contribution (
27642765
FOREIGN KEY(contribution_id) REFERENCES link_contribution(id)
27652766
) ENGINE=INNODB;
27662767

2768+
CREATE TABLE user_system_goal_link (
2769+
user_goal_id INT NOT NULL,
2770+
system_goal_id INT NOT NULL,
2771+
PRIMARY KEY(user_goal_id,system_goal_id),
2772+
FOREIGN KEY(system_goal_id) REFERENCES goal(id)
2773+
) ENGINE=INNODB;
2774+
27672775
CREATE TABLE requirement_reference_contribution (
27682776
reference_id INT NOT NULL,
27692777
characteristic_id INT NOT NULL,

0 commit comments

Comments
 (0)