コード例 #1
0
 def OnAddEnvironment(self,evt):
   self.theSelectedIdx = evt.GetIndex()
   environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
   self.theEnvironmentDictionary[environmentName] = UseCaseEnvironmentProperties(environmentName)
   self.environmentList.Select(self.theSelectedIdx)
   self.preCondCtrl.SetValue('')
   self.stepsCtrl.setEnvironment(environmentName)
   self.stepsCtrl.clear()
   self.postCondCtrl.SetValue('')
   self.preCondCtrl.setEnvironment(environmentName)
   self.preCondCtrl.setUseCase(self.theUseCaseName)
   self.postCondCtrl.setEnvironment(environmentName)
   self.postCondCtrl.setUseCase(self.theUseCaseName)
   inheritedEnv = self.environmentList.inheritedEnvironment()
   if (inheritedEnv != '' and self.theUseCaseId != None):
     p = self.dbProxy.inheritedUseCaseProperties(self.theUseCaseId,inheritedEnv)
     self.theEnvironmentDictionary[environmentName] = p
     self.preCondCtrl.SetValue(p.preconditions())
     self.stepsCtrl.reloadSteps(p.steps())
     self.stepsCtrl.setEnvironment(environmentName)
     self.postCondCtrl.SetValue(p.preconditions())
     self.preCondCtrl.setEnvironment(environmentName)
     self.preCondCtrl.setUseCase(self.theUseCaseName)
     self.postCondCtrl.setEnvironment(environmentName)
     self.postCondCtrl.setUseCase(self.theUseCaseName)
   self.preCondCtrl.Enable()
   self.stepsCtrl.Enable()
   self.postCondCtrl.Enable()
コード例 #2
0
 def prepare_new_usecase(self):
     new_usecase_props = [
         UseCaseEnvironmentProperties(
             environmentName=self.existing_environment_name,
             preCond=self.existing_precond,
             steps=self.existing_steps,
             postCond=self.existing_postcond)
     ]
     new_usecase = UseCase(ucId=-1,
                           ucName='New usecase',
                           ucAuth='NU',
                           ucCode='New objective',
                           ucActors=['Researcher'],
                           ucDesc='New Author',
                           tags=[],
                           cProps=[])
     new_usecase.theReferenceContributions = [
         UseCaseContributionModel('Security delegated', {
             'theMeansEnd': 'means',
             'theContribution': 'SomePositive'
         })
     ]
     new_usecase.theEnvironmentProperties = new_usecase_props
     new_usecase.theEnvironmentDictionary = {}
     delattr(new_usecase, 'theEnvironmentDictionary')
     return new_usecase
コード例 #3
0
 def environmentProperties(self):
     if (self.theSelectedIdx != -1):
         environmentName = self.environmentList.GetItemText(
             self.theSelectedIdx)
         self.theEnvironmentDictionary[
             environmentName] = UseCaseEnvironmentProperties(
                 environmentName, self.preCondCtrl.GetValue(),
                 self.stepsCtrl.steps(), self.postCondCtrl.GetValue())
     return self.theEnvironmentDictionary.values()
コード例 #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)
コード例 #5
0
ファイル: test_UseCase.py プロジェクト: we45/cairis
    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())
コード例 #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
コード例 #7
0
 def OnEnvironmentDeselected(self,evt):
   self.theSelectedIdx = evt.GetIndex()
   environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
   self.theEnvironmentDictionary[environmentName] = UseCaseEnvironmentProperties(environmentName,self.preCondCtrl.GetValue(),self.stepsCtrl.steps(),self.postCondCtrl.GetValue())
   self.preCondCtrl.SetValue('')
   self.stepsCtrl.clear()
   self.stepsCtrl.setEnvironment('')
   self.postCondCtrl.SetValue('')
   self.preCondCtrl.setEnvironment('')
   self.preCondCtrl.setUseCase('')
   self.postCondCtrl.setEnvironment('')
   self.postCondCtrl.setUseCase('')
   self.theSelectedIdx = -1
   self.preCondCtrl.Disable()
   self.stepsCtrl.Disable()
   self.postCondCtrl.Disable() 
コード例 #8
0
 def prepare_new_usecase(self):
     new_usecase_props = [
         UseCaseEnvironmentProperties(
             environmentName=self.existing_environment_name,
             preCond=self.existing_precond,
             steps=self.existing_steps,
             postCond=self.existing_postcond)
     ]
     new_usecase = UseCase(ucId=-1,
                           ucName='New usecase',
                           ucAuth='NU',
                           ucCode='New objective',
                           ucActors=['Researcher'],
                           ucDesc='New Author',
                           tags=[],
                           cProps=[])
     new_usecase.theEnvironmentProperties = new_usecase_props
     new_usecase.theEnvironmentDictionary = {}
     delattr(new_usecase, 'theEnvironmentDictionary')
     return new_usecase
コード例 #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
コード例 #10
0
 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
コード例 #11
0
 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
コード例 #12
0
 def inheritedUseCaseProperties(self, ucId, environmentName):
     environmentId = self.getDimensionId(environmentName, 'environment')
     preConds, postConds = self.useCaseConditions(ucId, environmentId)
     ucSteps = self.useCaseSteps(ucId, environmentId)
     return UseCaseEnvironmentProperties(environmentName, preConds, ucSteps,
                                         postConds)