Ejemplo n.º 1
0
 def convert_props(self, real_props=None, fake_props=None):
   new_props = []
   if real_props is not None:
     if len(real_props) > 0:
       for real_prop in real_props:
         assert isinstance(real_prop, UseCaseEnvironmentProperties)
         s = []
         for step in real_prop.steps().theSteps:
           s.append(StepAttributes(step.text(),step.synopsis(),step.actor(),step.actorType(),step.tags())) 
         real_prop.theSteps = s
         new_props.append(real_prop)
   elif fake_props is not None:
     if len(fake_props) > 0:
       for fake_prop in fake_props:
         check_required_keys(fake_prop, UseCaseEnvironmentPropertiesModel.required)
         steps = Steps()
         for s in fake_prop['theSteps']:
           steps.append(Step(s['theStepText'],s['theSynopsis'],s['theActor'],s['theActorType'],s['theTags']))
         fake_prop['theSteps'] = steps
         
         new_prop = UseCaseEnvironmentProperties(
                      environmentName=fake_prop['theEnvironmentName'],
                      preCond=fake_prop['thePreCond'],
                      steps=fake_prop['theSteps'],
                      postCond=fake_prop['thePostCond']
                    )
         new_props.append(new_prop)
   else:
     self.close()
     raise MissingParameterHTTPError(param_names=['real_props', 'fake_props'])
   return new_props
Ejemplo n.º 2
0
class StepTable(wx.grid.PyGridTableBase):
    def __init__(self, s=None):
        wx.grid.PyGridTableBase.__init__(self)
        self.colLabels = ['Step']
        if (s != None):
            self.steps = s
        else:
            self.steps = Steps()

    def GetNumberRows(self):
        return (self.steps).size()

    def GetNumberCols(self):
        return 1

    def GetColLabelValue(self, col):
        return 'Step'

    def IsEmptyCell(self, row, col):
        return False

    def GetValue(self, row, col):
        return (self.steps[row]).text()

    def SetValue(self, row, col, value):
        self.steps[row].setText(value)

    def AppendRows(self, numRows=1):
        pos = self.steps.size() - 1
        self.InsertRows(pos, numRows)

    def InsertRows(self, pos, numRows=1):
        if (pos == -1):
            pos = 0
        newPos = pos + 1
        if (self.steps.size() == 0):
            lastLabel = 0
        else:
            lastLabel = pos
        newLabel = lastLabel + 1
        try:
            self.steps.append(Step())
        except ARMException, errorText:
            dlg = wx.MessageDialog(self.GetView(), str(errorText), 'Add Step',
                                   wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return

        self.addToView(newLabel)
        grid = self.GetView()
        grid.SetCellEditor(newPos, 0, wx.grid.GridCellAutoWrapStringEditor())
        grid.SetCellRenderer(newPos, 0,
                             wx.grid.GridCellAutoWrapStringRenderer())
        return True
Ejemplo n.º 3
0
class StepTable(wx.grid.PyGridTableBase):

  def __init__(self,s = None):
    wx.grid.PyGridTableBase.__init__(self)
    self.colLabels = ['Step']
    if (s != None):
      self.steps = s
    else:
      self.steps = Steps()

  def GetNumberRows(self):
    return (self.steps).size()

  def GetNumberCols(self):
    return 1

  def GetColLabelValue(self,col):
    return 'Step'

  def IsEmptyCell(self,row,col):
    return False

  def GetValue(self,row,col):
    return (self.steps[row]).text()

  def SetValue(self,row,col,value):
    self.steps[row].setText(value)
   
  def AppendRows(self,numRows=1):
    pos = self.steps.size() - 1
    self.InsertRows(pos,numRows)

  def InsertRows(self,pos,numRows=1):
    if (pos == -1):
      pos = 0
    newPos = pos + 1
    if (self.steps.size() == 0):
      lastLabel = 0
    else:
      lastLabel = pos
    newLabel = lastLabel + 1
    try:
      self.steps.append(Step())
    except ARMException,errorText:
      dlg = wx.MessageDialog(self.GetView(),str(errorText),'Add Step',wx.OK | wx.ICON_ERROR)
      dlg.ShowModal()
      dlg.Destroy()
      return

    self.addToView(newLabel)
    grid = self.GetView()
    grid.SetCellEditor(newPos,0,wx.grid.GridCellAutoWrapStringEditor())
    grid.SetCellRenderer(newPos,0,wx.grid.GridCellAutoWrapStringRenderer())
    return True
Ejemplo n.º 4
0
    def setUpClass(cls):
        call([os.environ['CAIRIS_CFG_DIR'] + "/initdb.sh"])
        cairis.core.BorgFactory.initialise()

        f = open(os.environ['CAIRIS_SRC'] + '/test/dataflow.json')
        d = json.load(f)
        f.close()
        iEnvironments = d['environments']
        iep1 = EnvironmentParameters(iEnvironments[0]["theName"],
                                     iEnvironments[0]["theShortCode"],
                                     iEnvironments[0]["theDescription"])
        b = Borg()
        b.dbProxy.addEnvironment(iep1)

        iRoles = d['roles']
        irp = RoleParameters(iRoles[0]["theName"], iRoles[0]["theType"],
                             iRoles[0]["theShortCode"],
                             iRoles[0]["theDescription"], [])
        b.dbProxy.addRole(irp)

        iUseCases = d['use_cases']
        ucName = iUseCases[0]["theName"]
        ucAuthor = iUseCases[0]["theAuthor"]
        ucCode = iUseCases[0]["theCode"]
        ucDesc = iUseCases[0]["theDescription"]
        ucActor = iUseCases[0]["theActor"]
        ucEnv = iUseCases[0]["theEnvironments"][0]
        ucEnvName = ucEnv["theName"]
        ucPre = ucEnv["thePreconditions"]
        ucPost = ucEnv["thePostconditions"]
        ss = Steps()
        for ucStep in ucEnv["theFlow"]:
            ss.append(Step(ucStep["theDescription"]))
        ucep = UseCaseEnvironmentProperties(ucEnvName, ucPre, ss, ucPost)
        iuc = UseCaseParameters(ucName, ucAuthor, ucCode, [ucActor], ucDesc,
                                [], [ucep])
        b = Borg()
        b.dbProxy.addUseCase(iuc)

        for iAsset in d['assets']:
            iaeps = [
                AssetEnvironmentProperties(
                    iAsset["theEnvironmentProperties"][0][0],
                    iAsset["theEnvironmentProperties"][0][1],
                    iAsset["theEnvironmentProperties"][0][2])
            ]
            iap = AssetParameters(iAsset["theName"], iAsset["theShortCode"],
                                  iAsset["theDescription"],
                                  iAsset["theSignificance"], iAsset["theType"],
                                  "0", "N/A", [], [], iaeps)
            b.dbProxy.addAsset(iap)
Ejemplo n.º 5
0
    def testUseCase(self):
        ucName = self.iUseCases[0]["theName"]
        ucAuthor = self.iUseCases[0]["theAuthor"]
        ucCode = self.iUseCases[0]["theCode"]
        ucDesc = self.iUseCases[0]["theDescription"]
        ucActor = self.iUseCases[0]["theActor"]
        ucEnv = self.iUseCases[0]["theEnvironments"][0]
        ucEnvName = ucEnv["theName"]
        ucPre = ucEnv["thePreconditions"]
        ucPost = ucEnv["thePostconditions"]
        ss = Steps()
        for ucStep in ucEnv["theFlow"]:
            ss.append(Step(ucStep["theDescription"]))
        ucep = UseCaseEnvironmentProperties(ucEnvName, ucPre, ss, ucPost)
        iuc = UseCaseParameters(ucName, ucAuthor, ucCode, [ucActor], ucDesc,
                                [], [ucep])
        b = Borg()
        b.dbProxy.addUseCase(iuc)

        theUseCases = b.dbProxy.getUseCases()
        ouc = theUseCases[self.iUseCases[0]["theName"]]
        self.assertEqual(iuc.name(), ouc.name())
        self.assertEqual(iuc.tags(), ouc.tags())
        self.assertEqual(iuc.author(), ouc.author())
        self.assertEqual(iuc.code(), ouc.code())
        self.assertEqual(iuc.actors(), ouc.actors())
        self.assertEqual(iuc.description(), ouc.description())
        self.assertEqual(iuc.author(), ouc.author())
        self.assertEqual(iuc.environmentProperties()[0].preconditions(),
                         ouc.environmentProperties()[0].preconditions())
        self.assertEqual(iuc.environmentProperties()[0].postconditions(),
                         ouc.environmentProperties()[0].postconditions())

        iuc.theName = 'Updated name'
        iuc.setId(ouc.id())
        b.dbProxy.updateUseCase(iuc)
        theUseCases = b.dbProxy.getUseCases()
        ouc = theUseCases['Updated name']
        self.assertEqual(iuc.name(), ouc.name())
        self.assertEqual(iuc.tags(), ouc.tags())
        self.assertEqual(iuc.author(), ouc.author())
        self.assertEqual(iuc.code(), ouc.code())
        self.assertEqual(iuc.actors(), ouc.actors())
        self.assertEqual(iuc.description(), ouc.description())
        self.assertEqual(iuc.author(), ouc.author())
        self.assertEqual(iuc.environmentProperties()[0].preconditions(),
                         ouc.environmentProperties()[0].preconditions())
        self.assertEqual(iuc.environmentProperties()[0].postconditions(),
                         ouc.environmentProperties()[0].postconditions())

        b.dbProxy.deleteUseCase(ouc.id())
Ejemplo n.º 6
0
    def convert_props(self, real_props=None, fake_props=None):
        new_props = []
        if real_props is not None:
            if len(real_props) > 0:
                for real_prop in real_props:
                    assert isinstance(real_prop, UseCaseEnvironmentProperties)
                    s = []
                    for step in real_prop.steps().theSteps:
                        excs = []
                        for excKey in step.exceptions():
                            exc = step.exception(excKey)
                            excs.append(
                                ExceptionAttributes(exc[0], exc[1], exc[2],
                                                    exc[3], exc[4]))
                        s.append(
                            StepAttributes(step.text(), step.synopsis(),
                                           step.actor(), step.actorType(),
                                           step.tags(), excs))
                    real_prop.theSteps = s
                    new_props.append(real_prop)
        elif fake_props is not None:
            if len(fake_props) > 0:
                for fake_prop in fake_props:
                    check_required_keys(
                        fake_prop, UseCaseEnvironmentPropertiesModel.required)
                    steps = Steps()
                    for fs in fake_prop['theSteps']:
                        aStep = Step(fs['theStepText'], fs['theSynopsis'],
                                     fs['theActor'], fs['theActorType'],
                                     fs['theTags'])
                        for exc in fs['theExceptions']:
                            aStep.addException(
                                (exc['theName'], exc['theDimensionType'],
                                 exc['theDimensionValue'],
                                 exc['theCategoryName'],
                                 exc['theDescription']))
                        steps.append(aStep)
                    fake_prop['theSteps'] = steps

                    new_prop = UseCaseEnvironmentProperties(
                        environmentName=fake_prop['theEnvironmentName'],
                        preCond=fake_prop['thePreCond'],
                        steps=fake_prop['theSteps'],
                        postCond=fake_prop['thePostCond'])
                    new_props.append(new_prop)
        else:
            self.close()
            raise MissingParameterHTTPError(
                param_names=['real_props', 'fake_props'])
        return new_props
Ejemplo n.º 7
0
  def testUseCase(self):
    ucName = self.iUseCases[0]["theName"]
    ucAuthor = self.iUseCases[0]["theAuthor"]
    ucCode = self.iUseCases[0]["theCode"]
    ucDesc = self.iUseCases[0]["theDescription"]
    ucActor = self.iUseCases[0]["theActor"]
    ucEnv = self.iUseCases[0]["theEnvironments"][0]
    ucEnvName = ucEnv["theName"]
    ucPre = ucEnv["thePreconditions"]
    ucPost = ucEnv["thePostconditions"]
    ss = Steps()
    for ucStep in ucEnv["theFlow"]:
      ss.append(Step(ucStep["theDescription"]))  
    ucep = UseCaseEnvironmentProperties(ucEnvName,ucPre,ss,ucPost)
    iuc = UseCaseParameters(ucName,ucAuthor,ucCode,[ucActor],ucDesc,[],[ucep])
    b = Borg()
    b.dbProxy.addUseCase(iuc) 

    theUseCases = b.dbProxy.getUseCases()
    ouc = theUseCases[self.iUseCases[0]["theName"]]
    self.assertEqual(iuc.name(),ouc.name())
    self.assertEqual(iuc.tags(),ouc.tags())
    self.assertEqual(iuc.author(),ouc.author())
    self.assertEqual(iuc.code(),ouc.code())
    self.assertEqual(iuc.actors(),ouc.actors())
    self.assertEqual(iuc.description(),ouc.description())
    self.assertEqual(iuc.author(),ouc.author())
    self.assertEqual(iuc.environmentProperties()[0].preconditions(),ouc.environmentProperties()[0].preconditions())
    self.assertEqual(iuc.environmentProperties()[0].postconditions(),ouc.environmentProperties()[0].postconditions())

    iuc.theName = 'Updated name'
    iuc.setId(ouc.id())
    b.dbProxy.updateUseCase(iuc) 
    theUseCases = b.dbProxy.getUseCases()
    ouc = theUseCases['Updated name']
    self.assertEqual(iuc.name(),ouc.name())
    self.assertEqual(iuc.tags(),ouc.tags())
    self.assertEqual(iuc.author(),ouc.author())
    self.assertEqual(iuc.code(),ouc.code())
    self.assertEqual(iuc.actors(),ouc.actors())
    self.assertEqual(iuc.description(),ouc.description())
    self.assertEqual(iuc.author(),ouc.author())
    self.assertEqual(iuc.environmentProperties()[0].preconditions(),ouc.environmentProperties()[0].preconditions())
    self.assertEqual(iuc.environmentProperties()[0].postconditions(),ouc.environmentProperties()[0].postconditions())

    b.dbProxy.deleteUseCase(ouc.id())
Ejemplo n.º 8
0
  def setUpClass(cls):
    call([os.environ['CAIRIS_CFG_DIR'] + "/initdb.sh"])
    cairis.core.BorgFactory.initialise()

    f = open(os.environ['CAIRIS_SRC'] + '/test/dataflow.json')
    d = json.load(f)
    f.close()
    iEnvironments = d['environments']
    iep1 = EnvironmentParameters(iEnvironments[0]["theName"],iEnvironments[0]["theShortCode"],iEnvironments[0]["theDescription"])
    b = Borg()
    b.dbProxy.addEnvironment(iep1)

    iRoles = d['roles']
    irp = RoleParameters(iRoles[0]["theName"], iRoles[0]["theType"], iRoles[0]["theShortCode"], iRoles[0]["theDescription"],[])
    b.dbProxy.addRole(irp)

    iUseCases = d['use_cases']
    ucName = iUseCases[0]["theName"]
    ucAuthor = iUseCases[0]["theAuthor"]
    ucCode = iUseCases[0]["theCode"]
    ucDesc = iUseCases[0]["theDescription"]
    ucActor = iUseCases[0]["theActor"]
    ucEnv = iUseCases[0]["theEnvironments"][0]
    ucEnvName = ucEnv["theName"]
    ucPre = ucEnv["thePreconditions"]
    ucPost = ucEnv["thePostconditions"]
    ss = Steps()
    for ucStep in ucEnv["theFlow"]:
      ss.append(Step(ucStep["theDescription"]))  
    ucep = UseCaseEnvironmentProperties(ucEnvName,ucPre,ss,ucPost)
    iuc = UseCaseParameters(ucName,ucAuthor,ucCode,[ucActor],ucDesc,[],[ucep])
    b = Borg()
    b.dbProxy.addUseCase(iuc) 

    for iAsset in d['assets']:
      iaeps = [AssetEnvironmentProperties(iAsset["theEnvironmentProperties"][0][0],iAsset["theEnvironmentProperties"][0][1],iAsset["theEnvironmentProperties"][0][2])]
      iap = AssetParameters(iAsset["theName"],iAsset["theShortCode"],iAsset["theDescription"],iAsset["theSignificance"],iAsset["theType"],"0","N/A",[],[],iaeps)
      b.dbProxy.addAsset(iap)
Ejemplo n.º 9
0
    def convert_props(self, real_props=None, fake_props=None):
        new_props = []
        if real_props is not None:
            if len(real_props) > 0:
                for real_prop in real_props:
                    assert isinstance(real_prop, UseCaseEnvironmentProperties)
                    s = []
                    for step in real_prop.steps().theSteps:
                        s.append(
                            StepAttributes(step.text(), step.synopsis(),
                                           step.actor(), step.actorType(),
                                           step.tags()))
                    real_prop.theSteps = s
                    new_props.append(real_prop)
        elif fake_props is not None:
            if len(fake_props) > 0:
                for fake_prop in fake_props:
                    check_required_keys(
                        fake_prop, UseCaseEnvironmentPropertiesModel.required)
                    steps = Steps()
                    for s in fake_prop['theSteps']:
                        steps.append(
                            Step(s['theStepText'], s['theSynopsis'],
                                 s['theActor'], s['theActorType'],
                                 s['theTags']))
                    fake_prop['theSteps'] = steps

                    new_prop = UseCaseEnvironmentProperties(
                        environmentName=fake_prop['theEnvironmentName'],
                        preCond=fake_prop['thePreCond'],
                        steps=fake_prop['theSteps'],
                        postCond=fake_prop['thePostCond'])
                    new_props.append(new_prop)
        else:
            self.close()
            raise MissingParameterHTTPError(
                param_names=['real_props', 'fake_props'])
        return new_props
Ejemplo n.º 10
0
 def convert_props(self, real_props=None, fake_props=None):
   new_props = []
   if real_props is not None:
     if len(real_props) > 0:
       for real_prop in real_props:
         assert isinstance(real_prop, UseCaseEnvironmentProperties)
         s = []
         for step in real_prop.steps().theSteps:
           excs = []
           for excKey in step.exceptions():
             exc = step.exception(excKey)
             excs.append(ExceptionAttributes(exc[0],exc[1],exc[2],exc[3],exc[4]))
           s.append(StepAttributes(step.text(),step.synopsis(),step.actor(),step.actorType(),excs)) 
         real_prop.theSteps = s
         new_props.append(real_prop)
   elif fake_props is not None:
     if len(fake_props) > 0:
       for fake_prop in fake_props:
         check_required_keys(fake_prop, UseCaseEnvironmentPropertiesModel.required)
         steps = Steps()
         for fs in fake_prop['theSteps']:
           aStep = Step(fs['theStepText'],fs['theSynopsis'],fs['theActor'],fs['theActorType'],[])
           for exc in fs['theExceptions']:
             aStep.addException((exc['theName'],exc['theDimensionType'],exc['theDimensionValue'],exc['theCategoryName'],exc['theDescription']))
           steps.append(aStep)
         fake_prop['theSteps'] = steps
         
         new_prop = UseCaseEnvironmentProperties(
                      environmentName=fake_prop['theEnvironmentName'],
                      preCond=fake_prop['thePreCond'],
                      steps=fake_prop['theSteps'],
                      postCond=fake_prop['thePostCond']
                    )
         new_props.append(new_prop)
   else:
     self.close()
     raise MissingParameterHTTPError(param_names=['real_props', 'fake_props'])
   return new_props
Ejemplo n.º 11
0
class GoalsContentHandler(ContentHandler, EntityResolver):
    def __init__(self, session_id=None):
        b = Borg()
        self.dbProxy = b.get_dbproxy(session_id)
        self.configDir = b.configDir
        self.theDomainProperties = []
        self.theGoals = []
        self.theObstacles = []
        self.theRequirements = []
        self.theUseCases = []
        self.theCountermeasures = []
        self.theReferenceLabelDictionary = {}

        self.resetDomainPropertyAttributes()
        self.resetGoalAttributes()
        self.resetObstacleAttributes()
        self.resetRequirementAttributes()
        self.resetGoalAttributes()
        self.resetUseCaseAttributes()
        self.resetUseCaseEnvironmentAttributes()
        self.resetCountermeasureAttributes()

    def resolveEntity(self, publicId, systemId):
        return systemId

    def roles(self):
        return self.theRoles

    def domainProperties(self):
        return self.theDomainProperties

    def goals(self):
        return self.theGoals

    def obstacles(self):
        return self.theObstacles

    def requirements(self):
        return self.theRequirements

    def usecases(self):
        return self.theUseCases

    def countermeasures(self):
        return self.theCountermeasures

    def resetDomainPropertyAttributes(self):
        self.inDomainProperty = 0
        self.theName = ''
        self.theTags = []
        self.theType = ''
        self.theDefinition = ''
        self.theOriginator = ''

    def resetGoalAttributes(self):
        self.inGoal = 0
        self.theName = ''
        self.theTags = []
        self.theOriginator = ''
        self.theEnvironmentProperties = []
        self.resetGoalEnvironmentAttributes()

    def resetObstacleAttributes(self):
        self.inObstacle = 0
        self.theName = ''
        self.theTags = []
        self.theOriginator = ''
        self.theEnvironmentProperties = []
        self.resetObstacleEnvironmentAttributes()

    def resetGoalEnvironmentAttributes(self):
        self.inDefinition = 0
        self.inFitCriterion = 0
        self.inIssue = 0
        self.theEnvironmentName = ''
        self.theCategory = ''
        self.thePriority = ''
        self.theDefinition = ''
        self.theConcerns = []
        self.theConcernAssociations = []

    def resetObstacleEnvironmentAttributes(self):
        self.inDefinition = 0
        self.theEnvironmentName = ''
        self.theCategory = ''
        self.theDefinition = ''
        self.theConcerns = []
        self.resetProbabilityElements()

    def resetProbabilityElements(self):
        self.theProbability = 0.0
        self.inRationale = 0
        self.theRationale = ''

    def resetRequirementAttributes(self):
        self.inDescription = 0
        self.inRationale = 0
        self.inFitCriterion = 0
        self.inOriginator = 0
        self.theReference = ''
        self.theReferenceType = ''
        self.theLabel = 0
        self.theName = ''
        self.theType = ''
        self.thePriority = 0
        self.theDescription = 0
        self.theRationale = 0
        self.theFitCriterion = 0
        self.theOriginator = 0

    def resetUseCaseAttributes(self):
        self.inUseCase = 0
        self.theName = ''
        self.theTags = []
        self.theAuthor = ''
        self.theCode = ''
        self.inDescription = 0
        self.theDescription = ''
        self.theActors = []
        self.theEnvironmentProperties = []
        self.resetUseCaseEnvironmentAttributes()

    def resetUseCaseEnvironmentAttributes(self):
        self.theEnvironmentName = ''
        self.inPreconditions = 0
        self.thePreconditions = ''
        self.inPostconditions = 0
        self.thePostconditions = ''
        self.theSteps = Steps()
        self.theCurrentStep = None
        self.theCurrentStepNo = 0
        self.theExcName = ''
        self.theExcType = ''
        self.theExcValue = ''
        self.theExcCat = ''
        self.inDefinition = 0
        self.theDefinition = ''
        self.theCognitiveAttribute = {}
        self.theCognitiveAttribute['vigilance'] = (0, 'None')
        self.theCognitiveAttribute['situation awareness'] = (0, 'None')
        self.theCognitiveAttribute['stress'] = (0, 'None')
        self.theCognitiveAttribute['workload'] = (0, 'None')
        self.theCognitiveAttribute['risk awareness'] = (0, 'None')
        self.inAverage = 0
        self.theAverage = ''

    def resetCountermeasureAttributes(self):
        self.theName = ''
        self.theType = ''
        self.inDescription = 0
        self.theDescription = ''
        self.theEnvironmentProperties = []
        self.resetCountermeasureEnvironmentAttributes()

    def resetCountermeasureEnvironmentAttributes(self):
        self.theEnvironmentName = ''
        self.theCost = ''
        self.theCmRequirements = []
        self.theTargets = []
        self.theCmRoles = []
        self.theTaskPersonas = []
        self.theSpDict = {}
        self.theSpDict['confidentiality'] = (0, 'None')
        self.theSpDict['integrity'] = (0, 'None')
        self.theSpDict['availability'] = (0, 'None')
        self.theSpDict['accountability'] = (0, 'None')
        self.theSpDict['anonymity'] = (0, 'None')
        self.theSpDict['pseudonymity'] = (0, 'None')
        self.theSpDict['unlinkability'] = (0, 'None')
        self.theSpDict['unobservability'] = (0, 'None')
        self.theTargetName = ''
        self.theTargetEffectiveness = ''
        self.theTargetResponses = []
        self.resetMitigatingPropertyAttributes()

    def resetMitigatingPropertyAttributes(self):
        self.thePropertyName = ''
        self.thePropertyValue = 'None'
        self.inRationale = 0
        self.theRationale = ''

    def startElement(self, name, attrs):
        self.currentElementName = name
        if name == 'domainproperty':
            self.inDomainProperty = 1
            self.theName = attrs['name']
            self.theType = attrs['type']
            self.theOriginator = attrs['originator']
        elif name == 'goal':
            self.inGoal = 1
            self.theName = attrs['name']
            self.theOriginator = attrs['originator']
        elif name == 'obstacle':
            self.inObstacle = 1
            self.theName = attrs['name']
            self.theOriginator = attrs['originator']
        elif name == 'goal_environment':
            self.theEnvironmentName = attrs['name']
            self.theCategory = attrs['category']
            self.thePriority = attrs['priority']
        elif name == 'obstacle_environment':
            self.theEnvironmentName = attrs['name']
            self.theCategory = u2s(attrs['category'])
        elif name == 'probability':
            self.theProbability = attrs['value']
        elif name == 'rationale':
            self.inRationale = 1
            self.theRationale = ''
        elif name == 'concern':
            self.theConcerns.append(attrs['name'])
        elif name == 'concern_association':
            self.theConcernAssociations.append(
                (attrs['source_name'], a2s(attrs['source_nry']),
                 attrs['link_name'], attrs['target_name'],
                 a2s(attrs['target_nry'])))
        elif name == 'requirement':
            self.theReference = attrs['reference']
            if (self.theReference in self.theReferenceLabelDictionary):
                self.theReferenceLabelDictionary[self.theReference] += 1
            else:
                self.theReferenceLabelDictionary[self.theReference] = 1
            self.theLabel = self.theReferenceLabelDictionary[self.theReference]

            try:
                self.theName = attrs['name']
            except KeyError:
                self.theName = ''
            self.theReferenceType = attrs['reference_type']
            self.theType = u2s(attrs['type'])
            self.thePriority = attrs['priority']
        elif name == 'usecase':
            self.inUseCase = 1
            self.theName = attrs['name']
            self.theAuthor = attrs['author']
            self.theCode = attrs['code']
        elif name == 'actor':
            self.theActors.append(attrs['name'])
        elif name == 'usecase_environment':
            self.theEnvironmentName = attrs['name']
        elif name == 'step':
            self.theCurrentStepNo = attrs['number']
            self.theCurrentStep = Step(attrs['description'])
        elif name == 'exception':
            self.theExcName = attrs['name']
            self.theExcType = attrs['type']
            if (self.theExcType == 'None'):
                self.theExcValue = 'None'
                self.theExcCat = 'None'
            else:
                try:
                    self.theExcValue = attrs['value']
                    self.theExcCat = u2s(attrs['category'])
                except KeyError:
                    raise ARMException(
                        'Exception ' + self.theExcName +
                        ' has a goal or requirement exception type but no related goal/requirement name or exception category'
                    )
        elif name == 'countermeasure':
            self.theName = attrs['name']
            self.theType = attrs['type']
        elif name == 'countermeasure_environment':
            self.theEnvironmentName = attrs['name']
            self.theCost = attrs['cost']
        elif name == 'countermeasure_requirement':
            self.theCmRequirements.append(attrs['name'])
        elif name == 'target':
            self.theTargetName = attrs['name']
            self.theTargetEffectiveness = attrs['effectiveness']
        elif name == 'target_response':
            self.theTargetResponses.append(attrs['name'])
        elif name == 'mitigating_property':
            self.thePropertyName = attrs['name']
            self.thePropertyValue = a2i(attrs['value'])
        elif name == 'responsible_role':
            self.theCmRoles.append(attrs['name'])
        elif name == 'responsible_persona':
            self.theTaskPersonas.append(
                (attrs['task'], attrs['persona'], u2s(attrs['duration']),
                 u2s(attrs['frequency']), u2s(attrs['demands']),
                 u2s(attrs['goals'])))
        elif (name == 'description'):
            self.inDescription = 1
            self.theDescription = ''
        elif (name == 'definition'):
            self.inDefinition = 1
            self.theDefinition = ''
        elif name == 'fit_criterion':
            self.inFitCriterion = 1
            self.theFitCriterion = ''
        elif name == 'issue':
            self.inIssue = 1
            self.theIssue = ''
        elif name == 'rationale':
            self.inRationale = 1
            self.theRationale = ''
        elif name == 'originator':
            self.inOriginator = 1
            self.theOriginator = ''
        elif name == 'preconditions':
            self.inPreconditions = 1
            self.thePreconditions = ''
        elif name == 'postconditions':
            self.inPostconditions = 1
            self.thePostconditions = ''
        elif name == 'tag':
            if ((self.inDomainProperty == 1) or (self.inGoal == 1)
                    or (self.inObstacle == 1) or (self.inUseCase == 1)):
                self.theTags.append(attrs['name'])

    def characters(self, data):
        if self.inDescription:
            self.theDescription += data
        if self.inDefinition:
            self.theDefinition += data
        elif self.inFitCriterion:
            self.theFitCriterion += data
        elif self.inIssue:
            self.theIssue += data
        elif self.inRationale:
            self.theRationale += data
        elif self.inOriginator:
            self.theOriginator += data
        elif self.inPreconditions:
            self.thePreconditions += data
        elif self.inPostconditions:
            self.thePostconditions += data

    def endElement(self, name):
        if name == 'domainproperty':
            p = DomainPropertyParameters(unescape(self.theName),
                                         unescape(self.theDefinition),
                                         self.theType,
                                         unescape(self.theOriginator),
                                         self.theTags)
            self.theDomainProperties.append(p)
            self.resetDomainPropertyAttributes()
        elif name == 'goal_environment':
            p = GoalEnvironmentProperties(self.theEnvironmentName, '',
                                          unescape(self.theDefinition),
                                          self.theCategory, self.thePriority,
                                          unescape(self.theFitCriterion),
                                          unescape(self.theIssue), [], [],
                                          self.theConcerns,
                                          self.theConcernAssociations)
            self.theEnvironmentProperties.append(p)
            self.resetGoalEnvironmentAttributes()
        elif name == 'obstacle_environment':
            p = ObstacleEnvironmentProperties(self.theEnvironmentName, '',
                                              unescape(self.theDefinition),
                                              self.theCategory, [], [],
                                              self.theConcerns)
            p.theProbability = self.theProbability
            p.theProbabilityRationale = unescape(self.theRationale)
            self.theEnvironmentProperties.append(p)
            self.resetObstacleEnvironmentAttributes()
        elif name == 'goal':
            p = GoalParameters(unescape(self.theName),
                               unescape(self.theOriginator), self.theTags,
                               self.theEnvironmentProperties)
            self.theGoals.append(p)
            self.resetGoalAttributes()
        elif name == 'obstacle':
            p = ObstacleParameters(unescape(self.theName),
                                   unescape(self.theOriginator), self.theTags,
                                   self.theEnvironmentProperties)
            self.theObstacles.append(p)
            self.resetObstacleAttributes()
        elif name == 'requirement':
            reqId = self.dbProxy.newId()
            r = cairis.core.RequirementFactory.build(
                reqId, self.theLabel, unescape(self.theName),
                unescape(self.theDescription), self.thePriority,
                unescape(self.theRationale), unescape(self.theFitCriterion),
                unescape(self.theOriginator), self.theType, self.theReference)
            self.theRequirements.append(
                (r, self.theReference, self.theReferenceType))
            self.resetRequirementAttributes()
        elif name == 'exception':
            self.theCurrentStep.addException(
                (self.theExcName, self.theExcType.lower(), self.theExcValue,
                 self.theExcCat, unescape(self.theDefinition)))
        elif name == 'step':
            self.theCurrentStep.setTags(self.theTags)
            self.theSteps.append(self.theCurrentStep)
            self.theCurrentStep = None
        elif name == 'usecase_environment':
            vProperty, vRationale = self.theCognitiveAttribute['vigilance']
            saProperty, saRationale = self.theCognitiveAttribute[
                'situation awareness']
            sProperty, sRationale = self.theCognitiveAttribute['stress']
            wProperty, wRationale = self.theCognitiveAttribute['workload']
            raProperty, raRationale = self.theCognitiveAttribute[
                'risk awareness']
            p = UseCaseEnvironmentProperties(
                self.theEnvironmentName, unescape(self.thePreconditions),
                self.theSteps, unescape(self.thePostconditions),
                [vProperty, saProperty, sProperty, wProperty, raProperty],
                [vRationale, saRationale, sRationale, wRationale, raRationale])
            self.theEnvironmentProperties.append(p)
            self.resetUseCaseEnvironmentAttributes()
        elif name == 'usecase':
            p = UseCaseParameters(self.theName, self.theAuthor,
                                  unescape(self.theCode), self.theActors,
                                  unescape(self.theDescription), self.theTags,
                                  self.theEnvironmentProperties)
            self.theUseCases.append(p)
            self.resetUseCaseAttributes()
        elif name == 'countermeasure':
            p = CountermeasureParameters(self.theName,
                                         unescape(self.theDescription),
                                         self.theType, self.theTags,
                                         self.theEnvironmentProperties)
            self.theCountermeasures.append(p)
            self.resetCountermeasureAttributes()
        elif name == 'mitigating_property':
            self.theSpDict[self.thePropertyName] = (self.thePropertyValue,
                                                    unescape(
                                                        self.theDescription))
            self.resetMitigatingPropertyAttributes()
        elif name == 'countermeasure_environment':
            cProperty, cRationale = self.theSpDict['confidentiality']
            iProperty, iRationale = self.theSpDict['integrity']
            avProperty, avRationale = self.theSpDict['availability']
            acProperty, acRationale = self.theSpDict['accountability']
            anProperty, anRationale = self.theSpDict['anonymity']
            panProperty, panRationale = self.theSpDict['pseudonymity']
            unlProperty, unlRationale = self.theSpDict['unlinkability']
            unoProperty, unoRationale = self.theSpDict['unobservability']
            p = CountermeasureEnvironmentProperties(
                self.theEnvironmentName, self.theCmRequirements,
                self.theTargets, [
                    cProperty, iProperty, avProperty, acProperty, anProperty,
                    panProperty, unlProperty, unoProperty
                ], [
                    cRationale, iRationale, avRationale, acRationale,
                    anRationale, panRationale, unlRationale, unoRationale
                ], self.theCost, self.theCmRoles, self.theTaskPersonas)
            self.theEnvironmentProperties.append(p)
            self.resetCountermeasureEnvironmentAttributes()
        elif (name == 'target'):
            self.theTargets.append(
                Target(self.theTargetName, self.theTargetEffectiveness,
                       unescape(self.theRationale)))
            self.theTargetResponses = []
        elif (name == 'description'):
            self.inDescription = 0
        elif (name == 'definition'):
            self.inDefinition = 0
        elif name == 'fit_criterion':
            self.inFitCriterion = 0
        elif name == 'issue':
            self.inIssue = 0
        elif name == 'rationale':
            self.inRationale = 0
        elif name == 'originator':
            self.inOriginator = 0
        elif name == 'preconditions':
            self.inPreconditions = 0
        elif name == 'postconditions':
            self.inPostconditions = 0
Ejemplo n.º 12
0
class UsabilityContentHandler(ContentHandler,EntityResolver):
  def __init__(self):
    self.thePersonas = []
    self.theExternalDocuments = []
    self.theDocumentReferences = []
    self.theConceptReferences = []
    self.thePersonaCharacteristics = []
    self.theTaskCharacteristics = []
    self.theTasks = []
    self.theUseCases = []
    b = Borg()
    self.configDir = b.configDir
    self.resetPersonaAttributes()
    self.resetDocumentReferenceAttributes()
    self.resetConceptReferenceAttributes()
    self.resetPersonaCharacteristicAttributes()
    self.resetTaskCharacteristicAttributes()
    self.resetTaskAttributes()
    self.resetUseCaseAttributes()

  def resolveEntity(self,publicId,systemId):
    return systemId

  def personas(self):
    return self.thePersonas

  def externalDocuments(self):
    return self.theExternalDocuments

  def documentReferences(self):
    return self.theDocumentReferences

  def conceptReferences(self):
    return self.theConceptReferences

  def personaCharacteristics(self):
    return self.thePersonaCharacteristics

  def taskCharacteristics(self):
    return self.theTaskCharacteristics

  def tasks(self):
    return self.theTasks

  def usecases(self):
    return self.theUseCases

  def resetPersonaAttributes(self):
    self.inActivities = 0
    self.inAttitudes = 0
    self.inAptitudes = 0
    self.inMotivations = 0
    self.inSkills = 0
    self.inIntrinsic = 0
    self.inContextual = 0
    self.theName = ''
    self.theTags = []
    self.theType = ''
    self.theImage = ''
    self.isAssumptionPersona = False
    self.theActivities = ''
    self.theAptitudes = ''
    self.theMotivations = ''
    self.theSkills = ''
    self.theIntrinsic = ''
    self.theContextual = ''
    self.theEnvironmentProperties = []
    self.resetPersonaEnvironmentAttributes()

  def resetPersonaEnvironmentAttributes(self):
    self.theEnvironmentName = ''
    self.theRoles = []
    self.isDirect = True
    self.inNarrative = 0
    self.theNarrative = ''

  def resetExternalDocumentAttributes(self):
    self.theName = ''
    self.theVersion = ''
    self.theDate = ''
    self.theAuthors = ''
    self.inDescription = 0
    self.theDescription = ''

  def resetDocumentReferenceAttributes(self):
    self.inExcerpt = 0
    self.theName = ''
    self.theContributor = ''
    self.theDocument = ''
    self.theExcerpt = ''

  def resetConceptReferenceAttributes(self):
    self.inDescription = 0
    self.theName = ''
    self.theConcept = ''
    self.theObject = ''
    self.theDescription = ''

  def resetPersonaCharacteristicAttributes(self):
    self.thePersona = ''
    self.theBvName = ''
    self.theModalQualifier = ''
    self.inDefinition = 0
    self.theDefinition = ''
    self.theGrounds = []
    self.theWarrants = []
    self.theRebuttals = []

  def resetTaskCharacteristicAttributes(self):
    self.theTask = ''
    self.theModalQualifier = ''
    self.inDefinition = 0
    self.theDefinition = ''
    self.theGrounds = []
    self.theWarrants = []
    self.theRebuttals = []

  def resetTaskAttributes(self):
    self.theName = ''
    self.theTags = []
    self.theCode = ''
    self.theAuthor = ''
    self.isAssumptionTask = False
    self.inObjective = 0
    self.theObjective = ''
    self.theEnvironmentProperties = []
    self.resetTaskEnvironmentAttributes()

  def resetTaskEnvironmentAttributes(self):
    self.theEnvironmentName = ''
    self.inDependencies = 0
    self.inNarrative = 0
    self.inConsequences = 0
    self.inBenefits = 0
    self.theDependencies = ''
    self.theNarrative = ''
    self.theConsequences = ''
    self.theBenefits = ''
    self.theTaskPersonas = []
    self.theConcerns = []
    self.theConcernAssociations = []

  def resetUseCaseAttributes(self):
    self.theName = ''
    self.theTags = []
    self.theAuthor = ''
    self.theCode = ''
    self.inDescription = 0
    self.theDescription = ''
    self.theActors = []
    self.theEnvironmentProperties = []
    self.resetUseCaseEnvironmentAttributes()

  def resetUseCaseEnvironmentAttributes(self):
    self.theEnvironmentName = ''    
    self.inPreconditions = 0
    self.thePreconditions = ''
    self.inPostconditions = 0
    self.thePostconditions = ''
    self.theSteps = Steps()
    self.theCurrentStep = None
    self.theCurrentStepNo = 0
    self.theExcName = ''
    self.theExcType = ''
    self.theExcValue = ''
    self.theExcCat = ''
    self.inDefinition = 0
    self.theDefinition = ''

  def startElement(self,name,attrs):
    self.currentElementName = name
    if name == 'persona':
      self.theName = attrs['name']
      self.theType = attrs['type']
      self.theImage = attrs['image']
      if self.theImage != "" and os.path.isfile(self.theImage) == False:
        b = Borg()
        self.theImage = b.imageDir + "/" + self.theImage
      if (attrs['assumption_persona'] == 'TRUE'):
        self.isAssumptionPersona = True
    elif name == 'persona_environment':
      self.theEnvironmentName = attrs['name']
      if (attrs['is_direct'] == 'FALSE'):
        self.isDirect = False
    elif name == 'persona_role':
      self.theRoles.append(attrs['name'])
    elif name == 'external_document':
      self.theName = attrs['name'].encode('utf-8')
      self.theVersion = attrs['version']
      self.theDate = attrs['date']
      self.theAuthors = attrs['authors']
    elif name == 'document_reference':
      self.theName = attrs['name'].encode('utf-8')
      self.theContributor = attrs['contributor']
      self.theDocument = attrs['document']
    elif name == 'concept_reference':
      self.theName = attrs['name']
      self.theConcept = attrs['concept']
      self.theObject = attrs['object']
    elif name == 'persona_characteristic':
      self.thePersona = attrs['persona']
      self.theBvName = u2s(attrs['behavioural_variable'])
      self.theModalQualifier = attrs['modal_qualifier'] 
    elif name == 'task_characteristic':
      self.theTask = attrs['task']
      self.theModalQualifier = attrs['modal_qualifier'] 
    elif name == 'grounds':
      refName = attrs['reference']
      refType = attrs['type']
      refArtifact = ''
      self.theGrounds.append((refName,'',refType))
    elif name == 'warrant':
      refName = attrs['reference']
      refType = attrs['type']
      refArtifact = ''
      self.theWarrants.append((refName,'',refType))
    elif name == 'rebuttal':
      refName = attrs['reference']
      refType = attrs['type']
      refArtifact = ''
      self.theRebuttals.append((refName,'',refType))
    elif name == 'task':
      self.theName = attrs['name']
      try:
        self.theCode = attrs['code']
      except KeyError:
        self.theCode = ''
      self.theAuthor = attrs['author']
      if (attrs['assumption_task'] == 'TRUE'):
        self.isAssumptionTask = True
    elif name == 'task_environment':
      self.theEnvironmentName = attrs['name']
    elif name == 'task_persona':
      self.theTaskPersonas.append((attrs['persona'],durationValue(attrs['duration']),frequencyValue(attrs['frequency']),attrs['demands'],attrs['goal_conflict']))
    elif name == 'task_concern':
      self.theConcerns.append(attrs['asset'])
    elif name == 'task_concern_association':
      self.theConcernAssociations.append((attrs['source_name'],a2s(attrs['source_nry']),attrs['link_name'],attrs['target_name'],a2s(attrs['target_nry'])))
    elif name == 'usecase':
      self.theName = attrs['name']
      self.theAuthor = attrs['author']
      self.theCode = attrs['code']
    elif name == 'actor':
      self.theActors.append(attrs['name'])
    elif name == 'usecase_environment':
      self.theEnvironmentName = attrs['name']
    elif name == 'step':
      self.theCurrentStepNo = attrs['number']
      self.theCurrentStep = Step(attrs['description'])
    elif name == 'exception':
      self.theExcName = attrs['name']
      self.theExcType = attrs['type']
      self.theExcValue = attrs['value']
      self.theExcCat = u2s(attrs['category'])
    elif name == 'activities':
      self.inActivities = 1
      self.theActivities = ''
    elif name == 'attitudes':
      self.inAttitudes = 1
      self.theAttitudes = ''
    elif name == 'aptitudes':
      self.inAptitudes = 1
      self.theAptitudes = ''
    elif name == 'motivations':
      self.inMotivations = 1
      self.theMotivations = ''
    elif name == 'skills':
      self.inSkills = 1
      self.theSkills = ''
    elif name == 'intrinsic':
      self.inIntrinsic = 1
      self.theIntrinsic = ''
    elif name == 'contextual':
      self.inContextual = 1
      self.theContextual = ''
    elif name == 'narrative':
      self.inNarrative = 1
      self.theNarrative = ''
    elif name == 'consequences':
      self.inConsequences = 1
      self.theConsequences = ''
    elif name == 'benefits':
      self.inBenefits = 1
      self.theBenefits = ''
    elif name == 'excerpt':
      self.inExcerpt = 1
      self.theExcerpt = ''
    elif name == 'description':
      self.inDescription = 1
      self.theDescription = ''
    elif name == 'definition':
      self.inDefinition = 1
      self.theDefinition = ''
    elif name == 'dependencies':
      self.inDependencies = 1
      self.theDependencies = ''
    elif name == 'objective':
      self.inObjective = 1
      self.theObjective = ''
    elif name == 'preconditions':
      self.inPreconditions = 1
      self.thePreconditions = ''
    elif name == 'postconditions':
      self.inPostconditions = 1
      self.thePostconditions = ''
    elif name == 'tag':
      self.theTags.append(attrs['name'])

  def characters(self,data):
    if self.inActivities:
      self.theActivities += data
    elif self.inAttitudes:
      self.theAttitudes += data
    elif self.inAptitudes:
      self.theAptitudes += data
    elif self.inMotivations:
      self.theMotivations += data
    elif self.inSkills:
      self.theSkills += data
    elif self.inIntrinsic:
      self.theIntrinsic += data
    elif self.inContextual:
      self.theContextual += data
    elif self.inConsequences:
      self.theConsequences += data
    elif self.inBenefits:
      self.theBenefits += data
    elif self.inExcerpt:
      self.theExcerpt += data
    elif self.inDescription:
      self.theDescription += data
    elif self.inDefinition:
      self.theDefinition += data
    elif self.inDependencies:
      self.theDependencies += data
    elif self.inObjective:
      self.theObjective += data
    elif self.inPreconditions:
      self.thePreconditions += data
    elif self.inPostconditions:
      self.thePostconditions += data
    elif self.inNarrative:
      self.theNarrative += data

  def endElement(self,name):
    if name == 'persona':
      p = PersonaParameters(self.theName,self.theActivities,self.theAttitudes,self.theAptitudes,self.theMotivations,self.theSkills,self.theIntrinsic,self.theContextual,self.theImage,self.isAssumptionPersona,self.theType,self.theTags,self.theEnvironmentProperties,{})
      self.thePersonas.append(p)
      self.resetPersonaAttributes()
    elif name == 'persona_environment':
      p = PersonaEnvironmentProperties(self.theEnvironmentName,self.isDirect,self.theNarrative,self.theRoles,{'narrative':{}})
      self.theEnvironmentProperties.append(p)
      self.resetPersonaEnvironmentAttributes()
    elif name == 'external_document':
      p = ExternalDocumentParameters(self.theName,self.theVersion,self.theDate,self.theAuthors,self.theDescription)
      self.theExternalDocuments.append(p)
      self.resetExternalDocumentAttributes()
    elif name == 'document_reference':
      p = DocumentReferenceParameters(self.theName,self.theDocument,self.theContributor,self.theExcerpt)
      self.theDocumentReferences.append(p)
      self.resetDocumentReferenceAttributes()
    elif name == 'concept_reference':
      p = ConceptReferenceParameters(self.theName,self.theConcept,self.theObject,self.theDescription)
      self.theConceptReferences.append(p)
      self.resetConceptReferenceAttributes()
    elif name == 'persona_characteristic':
      p = PersonaCharacteristicParameters(self.thePersona,self.theModalQualifier,self.theBvName,self.theDefinition,self.theGrounds,self.theWarrants,[],self.theRebuttals)
      self.thePersonaCharacteristics.append(p)
      self.resetPersonaCharacteristicAttributes()
    elif name == 'task_characteristic':
      p = TaskCharacteristicParameters(self.theTask,self.theModalQualifier,self.theDefinition,self.theGrounds,self.theWarrants,[],self.theRebuttals)
      self.theTaskCharacteristics.append(p)
      self.resetTaskCharacteristicAttributes()
    elif name == 'task':
      p = TaskParameters(self.theName,self.theCode,self.theObjective,self.isAssumptionTask,self.theAuthor,self.theTags,self.theEnvironmentProperties)
      self.theTasks.append(p)
      self.resetTaskAttributes()
    elif name == 'task_environment':
      p = TaskEnvironmentProperties(self.theEnvironmentName,self.theDependencies,self.theTaskPersonas,self.theConcerns,self.theConcernAssociations,self.theNarrative,self.theConsequences,self.theBenefits,{'narrative':{},'consequences':{},'benefits':{}})
      self.theEnvironmentProperties.append(p)
      self.resetTaskEnvironmentAttributes()
    elif name == 'exception':
      self.theCurrentStep.addException((self.theExcName,self.theExcType,self.theExcValue,self.theExcCat,self.theDefinition))
    elif name == 'step':
      self.theCurrentStep.setTags(self.theTags)
      self.theSteps.append(self.theCurrentStep)
      self.theCurrentStep = None
    elif name == 'usecase_environment':
      p = UseCaseEnvironmentProperties(self.theEnvironmentName,self.thePreconditions,self.theSteps,self.thePostconditions)
      self.theEnvironmentProperties.append(p)
      self.resetUseCaseEnvironmentAttributes()
    elif name == 'usecase':
      p = UseCaseParameters(self.theName,self.theAuthor,self.theCode,self.theActors,self.theDescription,self.theTags,self.theEnvironmentProperties)
      self.theUseCases.append(p)
      self.resetUseCaseAttributes()
    elif name == 'activities':
      self.inActivities = 0
    elif name == 'attitudes':
      self.inAttitudes = 0
    elif name == 'aptitudes':
      self.inAptitudes = 0
    elif name == 'motivations':
      self.inMotivations = 0
    elif name == 'skills':
      self.inSkills = 0
    elif name == 'intrinsic':
      self.inIntrinsic = 0
    elif name == 'contextual':
      self.inContextual = 0
    elif name == 'narrative':
      self.inNarrative = 0
    elif name == 'excerpt':
      self.inExcerpt = 0
    elif name == 'description':
      self.inDescription = 0
    elif name == 'definition':
      self.inDefinition = 0
    elif name == 'dependencies':
      self.inDependencies = 0
    elif name == 'objective':
      self.inObjective = 0
    elif name == 'preconditions':
      self.inPreconditions = 0
    elif name == 'postconditions':
      self.inPostconditions = 0
    elif name == 'benefits':
      self.inBenefits = 0
    elif name == 'consequences':
      self.inConsequences = 0
Ejemplo n.º 13
0
class UsabilityContentHandler(ContentHandler, EntityResolver):
    def __init__(self):
        self.thePersonas = []
        self.theExternalDocuments = []
        self.theDocumentReferences = []
        self.theConceptReferences = []
        self.thePersonaCharacteristics = []
        self.theTaskCharacteristics = []
        self.theTasks = []
        self.theUseCases = []
        b = Borg()
        self.configDir = b.configDir
        self.resetPersonaAttributes()
        self.resetDocumentReferenceAttributes()
        self.resetConceptReferenceAttributes()
        self.resetPersonaCharacteristicAttributes()
        self.resetTaskCharacteristicAttributes()
        self.resetTaskAttributes()
        self.resetUseCaseAttributes()

    def resolveEntity(self, publicId, systemId):
        return systemId

    def personas(self):
        return self.thePersonas

    def externalDocuments(self):
        return self.theExternalDocuments

    def documentReferences(self):
        return self.theDocumentReferences

    def conceptReferences(self):
        return self.theConceptReferences

    def personaCharacteristics(self):
        return self.thePersonaCharacteristics

    def taskCharacteristics(self):
        return self.theTaskCharacteristics

    def tasks(self):
        return self.theTasks

    def usecases(self):
        return self.theUseCases

    def resetPersonaAttributes(self):
        self.inActivities = 0
        self.inAttitudes = 0
        self.inAptitudes = 0
        self.inMotivations = 0
        self.inSkills = 0
        self.inIntrinsic = 0
        self.inContextual = 0
        self.theName = ''
        self.theTags = []
        self.theType = ''
        self.theImage = ''
        self.isAssumptionPersona = False
        self.theActivities = ''
        self.theAptitudes = ''
        self.theMotivations = ''
        self.theSkills = ''
        self.theIntrinsic = ''
        self.theContextual = ''
        self.theEnvironmentProperties = []
        self.resetPersonaEnvironmentAttributes()

    def resetPersonaEnvironmentAttributes(self):
        self.theEnvironmentName = ''
        self.theRoles = []
        self.isDirect = True
        self.inNarrative = 0
        self.theNarrative = ''

    def resetExternalDocumentAttributes(self):
        self.theName = ''
        self.theVersion = ''
        self.theDate = ''
        self.theAuthors = ''
        self.inDescription = 0
        self.theDescription = ''

    def resetDocumentReferenceAttributes(self):
        self.inExcerpt = 0
        self.theName = ''
        self.theContributor = ''
        self.theDocument = ''
        self.theExcerpt = ''

    def resetConceptReferenceAttributes(self):
        self.inDescription = 0
        self.theName = ''
        self.theConcept = ''
        self.theObject = ''
        self.theDescription = ''

    def resetPersonaCharacteristicAttributes(self):
        self.thePersona = ''
        self.theBvName = ''
        self.theModalQualifier = ''
        self.inDefinition = 0
        self.theDefinition = ''
        self.theGrounds = []
        self.theWarrants = []
        self.theRebuttals = []

    def resetTaskCharacteristicAttributes(self):
        self.theTask = ''
        self.theModalQualifier = ''
        self.inDefinition = 0
        self.theDefinition = ''
        self.theGrounds = []
        self.theWarrants = []
        self.theRebuttals = []

    def resetTaskAttributes(self):
        self.theName = ''
        self.theTags = []
        self.theCode = ''
        self.theAuthor = ''
        self.isAssumptionTask = False
        self.inObjective = 0
        self.theObjective = ''
        self.theEnvironmentProperties = []
        self.resetTaskEnvironmentAttributes()

    def resetTaskEnvironmentAttributes(self):
        self.theEnvironmentName = ''
        self.inDependencies = 0
        self.inNarrative = 0
        self.inConsequences = 0
        self.inBenefits = 0
        self.theDependencies = ''
        self.theNarrative = ''
        self.theConsequences = ''
        self.theBenefits = ''
        self.theTaskPersonas = []
        self.theConcerns = []
        self.theConcernAssociations = []

    def resetUseCaseAttributes(self):
        self.theName = ''
        self.theTags = []
        self.theAuthor = ''
        self.theCode = ''
        self.inDescription = 0
        self.theDescription = ''
        self.theActors = []
        self.theEnvironmentProperties = []
        self.resetUseCaseEnvironmentAttributes()

    def resetUseCaseEnvironmentAttributes(self):
        self.theEnvironmentName = ''
        self.inPreconditions = 0
        self.thePreconditions = ''
        self.inPostconditions = 0
        self.thePostconditions = ''
        self.theSteps = Steps()
        self.theCurrentStep = None
        self.theCurrentStepNo = 0
        self.theExcName = ''
        self.theExcType = ''
        self.theExcValue = ''
        self.theExcCat = ''
        self.inDefinition = 0
        self.theDefinition = ''

    def startElement(self, name, attrs):
        self.currentElementName = name
        if name == 'persona':
            self.theName = attrs['name']
            self.theType = attrs['type']
            self.theImage = attrs['image']
            if self.theImage != "" and os.path.isfile(self.theImage) == False:
                b = Borg()
                self.theImage = self.theImage
            if (attrs['assumption_persona'] == 'TRUE'):
                self.isAssumptionPersona = True
        elif name == 'persona_environment':
            self.theEnvironmentName = attrs['name']
            if (attrs['is_direct'] == 'FALSE'):
                self.isDirect = False
        elif name == 'persona_role':
            self.theRoles.append(attrs['name'])
        elif name == 'external_document':
            self.theName = attrs['name'].encode('utf-8')
            self.theVersion = attrs['version']
            self.theDate = attrs['date']
            self.theAuthors = attrs['authors']
        elif name == 'document_reference':
            self.theName = attrs['name'].encode('utf-8')
            self.theContributor = attrs['contributor']
            self.theDocument = attrs['document']
        elif name == 'concept_reference':
            self.theName = attrs['name']
            self.theConcept = attrs['concept']
            self.theObject = attrs['object']
        elif name == 'persona_characteristic':
            self.thePersona = attrs['persona']
            self.theBvName = u2s(attrs['behavioural_variable'])
            self.theModalQualifier = attrs['modal_qualifier']
        elif name == 'task_characteristic':
            self.theTask = attrs['task']
            self.theModalQualifier = attrs['modal_qualifier']
        elif name == 'grounds':
            refName = attrs['reference']
            refType = attrs['type']
            refArtifact = ''
            self.theGrounds.append((refName, '', refType))
        elif name == 'warrant':
            refName = attrs['reference']
            refType = attrs['type']
            refArtifact = ''
            self.theWarrants.append((refName, '', refType))
        elif name == 'rebuttal':
            refName = attrs['reference']
            refType = attrs['type']
            refArtifact = ''
            self.theRebuttals.append((refName, '', refType))
        elif name == 'task':
            self.theName = attrs['name']
            try:
                self.theCode = attrs['code']
            except KeyError:
                self.theCode = ''
            self.theAuthor = attrs['author']
            if (attrs['assumption_task'] == 'TRUE'):
                self.isAssumptionTask = True
        elif name == 'task_environment':
            self.theEnvironmentName = attrs['name']
        elif name == 'task_persona':
            self.theTaskPersonas.append(
                (attrs['persona'], durationValue(attrs['duration']),
                 frequencyValue(attrs['frequency']), attrs['demands'],
                 attrs['goal_conflict']))
        elif name == 'task_concern':
            self.theConcerns.append(attrs['asset'])
        elif name == 'task_concern_association':
            self.theConcernAssociations.append(
                (attrs['source_name'], a2s(attrs['source_nry']),
                 attrs['link_name'], attrs['target_name'],
                 a2s(attrs['target_nry'])))
        elif name == 'usecase':
            self.theName = attrs['name']
            self.theAuthor = attrs['author']
            self.theCode = attrs['code']
        elif name == 'actor':
            self.theActors.append(attrs['name'])
        elif name == 'usecase_environment':
            self.theEnvironmentName = attrs['name']
        elif name == 'step':
            self.theCurrentStepNo = attrs['number']
            self.theCurrentStep = Step(attrs['description'])
        elif name == 'exception':
            self.theExcName = attrs['name']
            self.theExcType = attrs['type']
            self.theExcValue = attrs['value']
            self.theExcCat = u2s(attrs['category'])
        elif name == 'activities':
            self.inActivities = 1
            self.theActivities = ''
        elif name == 'attitudes':
            self.inAttitudes = 1
            self.theAttitudes = ''
        elif name == 'aptitudes':
            self.inAptitudes = 1
            self.theAptitudes = ''
        elif name == 'motivations':
            self.inMotivations = 1
            self.theMotivations = ''
        elif name == 'skills':
            self.inSkills = 1
            self.theSkills = ''
        elif name == 'intrinsic':
            self.inIntrinsic = 1
            self.theIntrinsic = ''
        elif name == 'contextual':
            self.inContextual = 1
            self.theContextual = ''
        elif name == 'narrative':
            self.inNarrative = 1
            self.theNarrative = ''
        elif name == 'consequences':
            self.inConsequences = 1
            self.theConsequences = ''
        elif name == 'benefits':
            self.inBenefits = 1
            self.theBenefits = ''
        elif name == 'excerpt':
            self.inExcerpt = 1
            self.theExcerpt = ''
        elif name == 'description':
            self.inDescription = 1
            self.theDescription = ''
        elif name == 'definition':
            self.inDefinition = 1
            self.theDefinition = ''
        elif name == 'dependencies':
            self.inDependencies = 1
            self.theDependencies = ''
        elif name == 'objective':
            self.inObjective = 1
            self.theObjective = ''
        elif name == 'preconditions':
            self.inPreconditions = 1
            self.thePreconditions = ''
        elif name == 'postconditions':
            self.inPostconditions = 1
            self.thePostconditions = ''
        elif name == 'tag':
            self.theTags.append(attrs['name'])

    def characters(self, data):
        if self.inActivities:
            self.theActivities += data
        elif self.inAttitudes:
            self.theAttitudes += data
        elif self.inAptitudes:
            self.theAptitudes += data
        elif self.inMotivations:
            self.theMotivations += data
        elif self.inSkills:
            self.theSkills += data
        elif self.inIntrinsic:
            self.theIntrinsic += data
        elif self.inContextual:
            self.theContextual += data
        elif self.inConsequences:
            self.theConsequences += data
        elif self.inBenefits:
            self.theBenefits += data
        elif self.inExcerpt:
            self.theExcerpt += data
        elif self.inDescription:
            self.theDescription += data
        elif self.inDefinition:
            self.theDefinition += data
        elif self.inDependencies:
            self.theDependencies += data
        elif self.inObjective:
            self.theObjective += data
        elif self.inPreconditions:
            self.thePreconditions += data
        elif self.inPostconditions:
            self.thePostconditions += data
        elif self.inNarrative:
            self.theNarrative += data

    def endElement(self, name):
        if name == 'persona':
            p = PersonaParameters(self.theName, self.theActivities,
                                  self.theAttitudes, self.theAptitudes,
                                  self.theMotivations, self.theSkills,
                                  self.theIntrinsic, self.theContextual,
                                  self.theImage, self.isAssumptionPersona,
                                  self.theType, self.theTags,
                                  self.theEnvironmentProperties, {})
            self.thePersonas.append(p)
            self.resetPersonaAttributes()
        elif name == 'persona_environment':
            p = PersonaEnvironmentProperties(self.theEnvironmentName,
                                             self.isDirect, self.theNarrative,
                                             self.theRoles, {'narrative': {}})
            self.theEnvironmentProperties.append(p)
            self.resetPersonaEnvironmentAttributes()
        elif name == 'external_document':
            p = ExternalDocumentParameters(self.theName, self.theVersion,
                                           self.theDate, self.theAuthors,
                                           self.theDescription)
            self.theExternalDocuments.append(p)
            self.resetExternalDocumentAttributes()
        elif name == 'document_reference':
            p = DocumentReferenceParameters(self.theName, self.theDocument,
                                            self.theContributor,
                                            self.theExcerpt)
            self.theDocumentReferences.append(p)
            self.resetDocumentReferenceAttributes()
        elif name == 'concept_reference':
            p = ConceptReferenceParameters(self.theName, self.theConcept,
                                           self.theObject, self.theDescription)
            self.theConceptReferences.append(p)
            self.resetConceptReferenceAttributes()
        elif name == 'persona_characteristic':
            p = PersonaCharacteristicParameters(
                self.thePersona, self.theModalQualifier, self.theBvName,
                self.theDefinition, self.theGrounds, self.theWarrants, [],
                self.theRebuttals)
            self.thePersonaCharacteristics.append(p)
            self.resetPersonaCharacteristicAttributes()
        elif name == 'task_characteristic':
            p = TaskCharacteristicParameters(self.theTask,
                                             self.theModalQualifier,
                                             self.theDefinition,
                                             self.theGrounds, self.theWarrants,
                                             [], self.theRebuttals)
            self.theTaskCharacteristics.append(p)
            self.resetTaskCharacteristicAttributes()
        elif name == 'task':
            p = TaskParameters(self.theName, self.theCode, self.theObjective,
                               self.isAssumptionTask, self.theAuthor,
                               self.theTags, self.theEnvironmentProperties)
            self.theTasks.append(p)
            self.resetTaskAttributes()
        elif name == 'task_environment':
            p = TaskEnvironmentProperties(
                self.theEnvironmentName, self.theDependencies,
                self.theTaskPersonas, self.theConcerns,
                self.theConcernAssociations, self.theNarrative,
                self.theConsequences, self.theBenefits, {
                    'narrative': {},
                    'consequences': {},
                    'benefits': {}
                })
            self.theEnvironmentProperties.append(p)
            self.resetTaskEnvironmentAttributes()
        elif name == 'exception':
            self.theCurrentStep.addException(
                (self.theExcName, self.theExcType, self.theExcValue,
                 self.theExcCat, self.theDefinition))
        elif name == 'step':
            self.theCurrentStep.setTags(self.theTags)
            self.theSteps.append(self.theCurrentStep)
            self.theCurrentStep = None
        elif name == 'usecase_environment':
            p = UseCaseEnvironmentProperties(self.theEnvironmentName,
                                             self.thePreconditions,
                                             self.theSteps,
                                             self.thePostconditions)
            self.theEnvironmentProperties.append(p)
            self.resetUseCaseEnvironmentAttributes()
        elif name == 'usecase':
            p = UseCaseParameters(self.theName, self.theAuthor, self.theCode,
                                  self.theActors, self.theDescription,
                                  self.theTags, self.theEnvironmentProperties)
            self.theUseCases.append(p)
            self.resetUseCaseAttributes()
        elif name == 'activities':
            self.inActivities = 0
        elif name == 'attitudes':
            self.inAttitudes = 0
        elif name == 'aptitudes':
            self.inAptitudes = 0
        elif name == 'motivations':
            self.inMotivations = 0
        elif name == 'skills':
            self.inSkills = 0
        elif name == 'intrinsic':
            self.inIntrinsic = 0
        elif name == 'contextual':
            self.inContextual = 0
        elif name == 'narrative':
            self.inNarrative = 0
        elif name == 'excerpt':
            self.inExcerpt = 0
        elif name == 'description':
            self.inDescription = 0
        elif name == 'definition':
            self.inDefinition = 0
        elif name == 'dependencies':
            self.inDependencies = 0
        elif name == 'objective':
            self.inObjective = 0
        elif name == 'preconditions':
            self.inPreconditions = 0
        elif name == 'postconditions':
            self.inPostconditions = 0
        elif name == 'benefits':
            self.inBenefits = 0
        elif name == 'consequences':
            self.inConsequences = 0
Ejemplo n.º 14
0
class GoalsContentHandler(ContentHandler,EntityResolver):
  def __init__(self,session_id = None):
    b = Borg()
    self.dbProxy = b.get_dbproxy(session_id)
    self.configDir = b.configDir
    self.theDomainProperties = []
    self.theGoals = []
    self.theObstacles = []
    self.theRequirements = []
    self.theUseCases = []
    self.theCountermeasures = []
    self.theReferenceLabelDictionary = {}

    self.resetDomainPropertyAttributes()
    self.resetGoalAttributes()
    self.resetObstacleAttributes()
    self.resetRequirementAttributes()
    self.resetGoalAttributes()
    self.resetUseCaseAttributes()
    self.resetUseCaseEnvironmentAttributes()
    self.resetCountermeasureAttributes()

  def resolveEntity(self,publicId,systemId):
    return systemId

  def roles(self):
    return self.theRoles

  def domainProperties(self):
    return self.theDomainProperties

  def goals(self):
    return self.theGoals

  def obstacles(self):
    return self.theObstacles

  def requirements(self):
    return self.theRequirements

  def usecases(self):
    return self.theUseCases

  def countermeasures(self):
    return self.theCountermeasures

  def resetDomainPropertyAttributes(self):
    self.inDomainProperty = 0
    self.theName = ''
    self.theTags = []
    self.theType = ''
    self.theDefinition = ''
    self.theOriginator = ''

  def resetGoalAttributes(self):
    self.inGoal = 0
    self.theName = ''
    self.theTags = []
    self.theOriginator = ''
    self.theEnvironmentProperties = []
    self.resetGoalEnvironmentAttributes()

  def resetObstacleAttributes(self):
    self.inObstacle = 0
    self.theName = ''
    self.theTags = []
    self.theOriginator = ''
    self.theEnvironmentProperties = []
    self.resetObstacleEnvironmentAttributes()

  def resetGoalEnvironmentAttributes(self):
    self.inDefinition = 0
    self.inFitCriterion = 0
    self.inIssue = 0
    self.theEnvironmentName = ''
    self.theCategory = ''
    self.thePriority = ''
    self.theDefinition = ''
    self.theConcerns = []
    self.theConcernAssociations = []

  def resetObstacleEnvironmentAttributes(self):
    self.inDefinition = 0
    self.theEnvironmentName = ''
    self.theCategory = ''
    self.theDefinition = ''
    self.theConcerns = []
    self.resetProbabilityElements()

  def resetProbabilityElements(self):
    self.theProbability = 0.0
    self.inRationale = 0
    self.theRationale = ''

  def resetRequirementAttributes(self):
    self.inDescription = 0
    self.inRationale = 0
    self.inFitCriterion = 0
    self.inOriginator = 0
    self.theReference = ''
    self.theReferenceType = ''
    self.theLabel = 0
    self.theName = ''
    self.theType = ''
    self.thePriority = 0
    self.theDescription = 0
    self.theRationale = 0
    self.theFitCriterion = 0
    self.theOriginator = 0

  def resetUseCaseAttributes(self):
    self.inUseCase = 0
    self.theName = ''
    self.theTags = []
    self.theAuthor = ''
    self.theCode = ''
    self.inDescription = 0
    self.theDescription = ''
    self.theActors = []
    self.theEnvironmentProperties = []
    self.resetUseCaseEnvironmentAttributes()

  def resetUseCaseEnvironmentAttributes(self):
    self.theEnvironmentName = ''    
    self.inPreconditions = 0
    self.thePreconditions = ''
    self.inPostconditions = 0
    self.thePostconditions = ''
    self.theSteps = Steps()
    self.theCurrentStep = None
    self.theCurrentStepNo = 0
    self.theExcName = ''
    self.theExcType = ''
    self.theExcValue = ''
    self.theExcCat = ''
    self.inDefinition = 0
    self.theDefinition = ''

  def resetCountermeasureAttributes(self):
    self.theName = ''
    self.theType = ''
    self.inDescription = 0
    self.theDescription = ''
    self.theEnvironmentProperties = []
    self.resetCountermeasureEnvironmentAttributes()

  def resetCountermeasureEnvironmentAttributes(self):
    self.theEnvironmentName = ''
    self.theCost = ''
    self.theCmRequirements = []
    self.theTargets = []
    self.theCmRoles = []
    self.theTaskPersonas = []
    self.theSpDict = {}
    self.theSpDict['confidentiality'] = (0,'None')
    self.theSpDict['integrity'] = (0,'None')
    self.theSpDict['availability'] = (0,'None')
    self.theSpDict['accountability'] = (0,'None')
    self.theSpDict['anonymity'] = (0,'None')
    self.theSpDict['pseudonymity'] = (0,'None')
    self.theSpDict['unlinkability'] = (0,'None')
    self.theSpDict['unobservability'] = (0,'None')
    self.theTargetName = ''
    self.theTargetEffectiveness = ''
    self.theTargetResponses = []
    self.resetMitigatingPropertyAttributes()

  def resetMitigatingPropertyAttributes(self):
    self.thePropertyName = ''
    self.thePropertyValue = 'None'
    self.inRationale = 0
    self.theRationale = ''

  def startElement(self,name,attrs):
    self.currentElementName = name
    if name == 'domainproperty':
      self.inDomainProperty = 1
      self.theName = attrs['name']
      self.theType = attrs['type']
      self.theOriginator = attrs['originator']
    elif name == 'goal':
      self.inGoal = 1
      self.theName = attrs['name']
      self.theOriginator = attrs['originator']
    elif name == 'obstacle':
      self.inObstacle = 1
      self.theName = attrs['name']
      self.theOriginator = attrs['originator']
    elif name == 'goal_environment':
      self.theEnvironmentName = attrs['name']
      self.theCategory = attrs['category']
      self.thePriority = attrs['priority']
    elif name == 'obstacle_environment':
      self.theEnvironmentName = attrs['name']
      self.theCategory = u2s(attrs['category'])
    elif name == 'probability':
      self.theProbability = attrs['value']
    elif name == 'rationale':
      self.inRationale = 1
      self.theRationale = ''
    elif name == 'concern':
      self.theConcerns.append(attrs['name'])
    elif name == 'concern_association':
      self.theConcernAssociations.append((attrs['source_name'],a2s(attrs['source_nry']),attrs['link_name'],attrs['target_name'],a2s(attrs['target_nry'])))
    elif name == 'requirement':
      self.theReference = attrs['reference']
      if (self.theReference in self.theReferenceLabelDictionary):
        self.theReferenceLabelDictionary[self.theReference] += 1
      else:
        self.theReferenceLabelDictionary[self.theReference] = 1
      self.theLabel = self.theReferenceLabelDictionary[self.theReference]

      try:
        self.theName = attrs['name']
      except KeyError:
        self.theName = ''
      self.theReferenceType = attrs['reference_type']
      self.theType = u2s(attrs['type'])
      self.thePriority = attrs['priority']
    elif name == 'usecase':
      self.inUseCase = 1
      self.theName = attrs['name']
      self.theAuthor = attrs['author']
      self.theCode = attrs['code']
    elif name == 'actor':
      self.theActors.append(attrs['name'])
    elif name == 'usecase_environment':
      self.theEnvironmentName = attrs['name']
    elif name == 'step':
      self.theCurrentStepNo = attrs['number']
      self.theCurrentStep = Step(attrs['description'])
    elif name == 'exception':
      self.theExcName = attrs['name']
      self.theExcType = attrs['type']
      if (self.theExcType == 'None'):
        self.theExcValue = 'None'
        self.theExcCat = 'None'
      else: 
        try: 
          self.theExcValue = attrs['value']
          self.theExcCat = u2s(attrs['category'])
        except KeyError:
          raise ARMException('Exception ' + self.theExcName + ' has a goal or requirement exception type but no related goal/requirement name or exception category')
    elif name == 'countermeasure':
      self.theName = attrs['name']
      self.theType = attrs['type']
    elif name == 'countermeasure_environment':
      self.theEnvironmentName = attrs['name']
      self.theCost = attrs['cost']
    elif name == 'countermeasure_requirement':
      self.theCmRequirements.append(attrs['name'])
    elif name == 'target':
      self.theTargetName = attrs['name']
      self.theTargetEffectiveness = attrs['effectiveness']
    elif name == 'target_response':
      self.theTargetResponses.append(attrs['name'])
    elif name == 'mitigating_property':
      self.thePropertyName = attrs['name']
      self.thePropertyValue = a2i(attrs['value'])
    elif name == 'responsible_role':
      self.theCmRoles.append(attrs['name'])
    elif name == 'responsible_persona':
      self.theTaskPersonas.append((attrs['task'],attrs['persona'],u2s(attrs['duration']),u2s(attrs['frequency']),u2s(attrs['demands']),u2s(attrs['goals'])))
    elif (name == 'description'):
      self.inDescription = 1
      self.theDescription = ''
    elif (name =='definition'):
      self.inDefinition = 1
      self.theDefinition = ''
    elif name == 'fit_criterion':
      self.inFitCriterion = 1
      self.theFitCriterion = ''
    elif name == 'issue':
      self.inIssue = 1
      self.theIssue = ''
    elif name == 'rationale':
      self.inRationale = 1
      self.theRationale = ''
    elif name == 'originator':
      self.inOriginator = 1
      self.theOriginator = ''
    elif name == 'preconditions':
      self.inPreconditions = 1
      self.thePreconditions = ''
    elif name == 'postconditions':
      self.inPostconditions = 1
      self.thePostconditions = ''
    elif name == 'tag':
      if ((self.inDomainProperty == 1) or (self.inGoal == 1) or (self.inObstacle == 1) or (self.inUseCase == 1)):
        self.theTags.append(attrs['name'])

  def characters(self,data):
    if self.inDescription:
      self.theDescription += data
    if self.inDefinition:
      self.theDefinition += data
    elif self.inFitCriterion:
      self.theFitCriterion += data
    elif self.inIssue:
      self.theIssue += data
    elif self.inRationale:
      self.theRationale += data
    elif self.inOriginator:
      self.theOriginator += data
    elif self.inPreconditions:
      self.thePreconditions += data
    elif self.inPostconditions:
      self.thePostconditions += data


  def endElement(self,name):
    if name == 'domainproperty':
      p = DomainPropertyParameters(unescape(self.theName),unescape(self.theDefinition),self.theType,unescape(self.theOriginator),self.theTags)
      self.theDomainProperties.append(p)
      self.resetDomainPropertyAttributes()
    elif name == 'goal_environment':
      p = GoalEnvironmentProperties(self.theEnvironmentName,'',unescape(self.theDefinition),self.theCategory,self.thePriority,unescape(self.theFitCriterion),unescape(self.theIssue),[],[],self.theConcerns,self.theConcernAssociations)
      self.theEnvironmentProperties.append(p)
      self.resetGoalEnvironmentAttributes()
    elif name == 'obstacle_environment':
      p = ObstacleEnvironmentProperties(self.theEnvironmentName,'',unescape(self.theDefinition),self.theCategory,[],[],self.theConcerns)
      p.theProbability = self.theProbability
      p.theProbabilityRationale = unescape(self.theRationale)
      self.theEnvironmentProperties.append(p)
      self.resetObstacleEnvironmentAttributes()
    elif name == 'goal':
      p = GoalParameters(unescape(self.theName),unescape(self.theOriginator),self.theTags,self.theEnvironmentProperties)
      self.theGoals.append(p)
      self.resetGoalAttributes()
    elif name == 'obstacle':
      p = ObstacleParameters(unescape(self.theName),unescape(self.theOriginator),self.theTags,self.theEnvironmentProperties)
      self.theObstacles.append(p)
      self.resetObstacleAttributes()
    elif name == 'requirement':
      reqId = self.dbProxy.newId()
      r = cairis.core.RequirementFactory.build(reqId,self.theLabel,unescape(self.theName),unescape(self.theDescription),self.thePriority,unescape(self.theRationale),unescape(self.theFitCriterion),unescape(self.theOriginator),self.theType,self.theReference)
      self.theRequirements.append((r,self.theReference,self.theReferenceType))
      self.resetRequirementAttributes()
    elif name == 'exception':
      self.theCurrentStep.addException((self.theExcName,self.theExcType.lower(),self.theExcValue,self.theExcCat,unescape(self.theDefinition)))
    elif name == 'step':
      self.theCurrentStep.setTags(self.theTags)
      self.theSteps.append(self.theCurrentStep)
      self.theCurrentStep = None
    elif name == 'usecase_environment':
      p = UseCaseEnvironmentProperties(self.theEnvironmentName,unescape(self.thePreconditions),self.theSteps,unescape(self.thePostconditions))
      self.theEnvironmentProperties.append(p)
      self.resetUseCaseEnvironmentAttributes()
    elif name == 'usecase':
      p = UseCaseParameters(self.theName,self.theAuthor,unescape(self.theCode),self.theActors,unescape(self.theDescription),self.theTags,self.theEnvironmentProperties)
      self.theUseCases.append(p)
      self.resetUseCaseAttributes()
    elif name == 'countermeasure':
      p = CountermeasureParameters(self.theName,unescape(self.theDescription),self.theType,self.theTags,self.theEnvironmentProperties)
      self.theCountermeasures.append(p)
      self.resetCountermeasureAttributes()
    elif name == 'mitigating_property':
      self.theSpDict[self.thePropertyName] = (self.thePropertyValue,unescape(self.theDescription))
      self.resetMitigatingPropertyAttributes()
    elif name == 'countermeasure_environment':
      cProperty,cRationale = self.theSpDict['confidentiality']
      iProperty,iRationale = self.theSpDict['integrity']
      avProperty,avRationale = self.theSpDict['availability']
      acProperty,acRationale = self.theSpDict['accountability']
      anProperty,anRationale = self.theSpDict['anonymity']
      panProperty,panRationale = self.theSpDict['pseudonymity']
      unlProperty,unlRationale = self.theSpDict['unlinkability']
      unoProperty,unoRationale = self.theSpDict['unobservability']
      p = CountermeasureEnvironmentProperties(self.theEnvironmentName,self.theCmRequirements,self.theTargets,[cProperty,iProperty,avProperty,acProperty,anProperty,panProperty,unlProperty,unoProperty],[cRationale,iRationale,avRationale,acRationale,anRationale,panRationale,unlRationale,unoRationale],self.theCost,self.theCmRoles,self.theTaskPersonas)
      self.theEnvironmentProperties.append(p)
      self.resetCountermeasureEnvironmentAttributes()
    elif (name == 'target'):
      self.theTargets.append(Target(self.theTargetName,self.theTargetEffectiveness,unescape(self.theRationale)))
      self.theTargetResponses = []
    elif (name == 'description'):
      self.inDescription = 0
    elif (name =='definition'):
      self.inDefinition = 0
    elif name == 'fit_criterion':
      self.inFitCriterion = 0
    elif name == 'issue':
      self.inIssue = 0
    elif name == 'rationale':
      self.inRationale = 0
    elif name == 'originator':
      self.inOriginator = 0
    elif name == 'preconditions':
      self.inPreconditions = 0
    elif name == 'postconditions':
      self.inPostconditions = 0