Пример #1
0
    def prepare_new_goal(self):
        new_goal_refinements = [
            RefinementModel("PreventUnauthorised Certificate Access", "goal",
                            "or", "No", "None")
        ]
        new_subgoal_refinements = [
            RefinementModel("PreventUnauthorised Certificate Access", "goal",
                            "or", "No", "None")
        ]
        new_goal_props = [
            GoalEnvironmentProperties(
                environmentName=self.existing_environment_name_1,
                lbl='',
                definition='This is a first test property',
                category=self.existing_category,
                priority='Medium',
                fitCriterion='None',
                issue='None',
                goalRefinements=new_goal_refinements,
                subGoalRefinements=new_subgoal_refinements,
                concs=[],
                cas=[]),
            GoalEnvironmentProperties(
                environmentName=self.existing_environment_name_2,
                lbl='',
                definition='This is a second test property',
                category=self.existing_category,
                priority='Low',
                fitCriterion='None',
                issue='Test issue',
                goalRefinements=[],
                subGoalRefinements=[],
                concs=[],
                cas=[])
        ]

        new_goal = Goal(goalId=-1,
                        goalName='Test goal',
                        goalOrig='',
                        tags=['test', 'test123'],
                        environmentProperties=[])
        new_goal.theEnvironmentProperties = new_goal_props

        new_goal.theEnvironmentDictionary = {}
        new_goal.theGoalPropertyDictionary = {}

        delattr(new_goal, 'theEnvironmentDictionary')
        delattr(new_goal, 'theGoalPropertyDictionary')

        return new_goal
Пример #2
0
    def add(self,
            idx=-1,
            goalName="",
            envName="",
            newDefinition="",
            newCategory="Maintain",
            newPriority="Low",
            newFitCriterion="None",
            newIssue="None",
            newOriginator=""):
        envName = self.envCombo.GetValue()
        parentGoalName = self.goalCombo.GetValue()

        ep = GoalEnvironmentProperties(
            envName, '', newDefinition, newCategory, newPriority,
            newFitCriterion, newIssue,
            [(parentGoalName, 'goal', 'and', 'No', 'None')])
        g = Goal(-1, goalName, newOriginator, [], [ep])
        gp = GoalParameters(goalName, newOriginator, [], [ep])
        g.setId(self.dbProxy.addGoal(gp))
        if (idx != -1):
            self.goals.insert(idx, g)
        else:
            self.goals.append(g)
        return g
Пример #3
0
 def environmentProperties(self):
   goalDef = self.decorator.getMLText("goalDefinitionCtrl")
   goalCat = self.decorator.getComboValue("goalCategoryCtrl")
   goalPri = self.decorator.getComboValue("goalPriorityCtrl")
   goalFC = self.decorator.getMLText("goalFitCriterionCtrl")
   goalIssue = self.decorator.getMLText("goalIssueCtrl")
   envProperties = GoalEnvironmentProperties(self.theEnvironmentName,'',goalDef,goalCat,goalPri,goalFC,goalIssue,self.goalAssociations,self.subGoalAssociations)
   return envProperties
Пример #4
0
    def convert_properties(self, real_props=None, fake_props=None):
        new_props = []
        if real_props is not None:
            for real_prop in real_props:
                assert isinstance(real_prop, GoalEnvironmentProperties)

                new_concern_assocs = []
                for concern_assoc in real_prop.theConcernAssociations:
                    new_concern_assocs.append(list(concern_assoc))

                new_goal_refinements = []
                for goal_refinement in real_prop.theGoalRefinements:
                    new_goal_refinements.append(list(goal_refinement))

                new_subgoal_refinements = []
                for subgoal_refinement in real_prop.theSubGoalRefinements:
                    new_subgoal_refinements.append(list(subgoal_refinement))

                real_prop.theConcernAssociations = new_concern_assocs
                real_prop.theGoalRefinements = new_goal_refinements
                real_prop.theSubGoalRefinements = new_subgoal_refinements
                new_props.append(real_prop)
        elif fake_props is not None:
            for fake_prop in fake_props:
                check_required_keys(fake_prop,
                                    GoalEnvironmentPropertiesModel.required)

                new_concern_assocs = []
                for concern_assoc in fake_prop['theConcernAssociations']:
                    new_concern_assocs.append(tuple(concern_assoc))

                new_goal_refinements = []
                for goal_refinement in fake_prop['theGoalRefinements']:
                    new_goal_refinements.append(tuple(goal_refinement))

                new_subgoal_refinements = []
                for subgoal_refinement in fake_prop['theSubGoalRefinements']:
                    new_subgoal_refinements.append(tuple(subgoal_refinement))

                new_prop = GoalEnvironmentProperties(
                    environmentName=fake_prop['theEnvironmentName'],
                    lbl=fake_prop['theLabel'],
                    definition=fake_prop['theDefinition'],
                    category=fake_prop['theCategory'],
                    priority=fake_prop['thePriority'],
                    fitCriterion=fake_prop['theFitCriterion'],
                    issue=fake_prop['theIssue'],
                    goalRefinements=new_goal_refinements,
                    subGoalRefinements=new_subgoal_refinements,
                    concs=fake_prop['theConcerns'],
                    cas=new_concern_assocs)
                new_props.append(new_prop)
        else:
            self.close()
            raise MissingParameterHTTPError(
                param_names=['real_props', 'fake_props'])

        return new_props
Пример #5
0
    def __init__(self, parent, goalDef, goalCat, goalPri, goalFc, goalIssue,
                 goalAssets, defaultEnv):
        wx.Panel.__init__(self, parent, GOAL_PANELENVIRONMENT_ID)
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theGoalId = None
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1
        self.theGoalDefinition = goalDef
        self.theGoalCategory = goalCat
        self.theGoalPriority = goalPri
        self.theGoalFitCriterion = goalFc
        self.theGoalIssue = goalIssue
        self.theGoalAssets = goalAssets

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(self,
                                                   GOAL_LISTENVIRONMENTS_ID,
                                                   self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbSizer, 1, wx.EXPAND)
        self.notebook = ReqToGoalNotebook(self, self.dbProxy)
        nbSizer.Add(self.notebook, 1, wx.EXPAND)

        self.SetSizer(mainSizer)

        self.goalAssociationCtrl = self.notebook.FindWindowById(
            GOAL_LISTGOALREFINEMENTS_ID)
        self.subGoalAssociationCtrl = self.notebook.FindWindowById(
            GOAL_LISTSUBGOALREFINEMENTS_ID)

        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,
                                  self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,
                                  self.OnDeleteEnvironment)

        self.goalAssociationCtrl.Disable()
        self.subGoalAssociationCtrl.Disable()

        self.theEnvironmentDictionary[defaultEnv] = GoalEnvironmentProperties(
            defaultEnv)
        self.environmentList.Select(0)
        self.goalAssociationCtrl.setEnvironment(defaultEnv)
        self.goalAssociationCtrl.DeleteAllItems()
        self.subGoalAssociationCtrl.setEnvironment(defaultEnv)
        self.subGoalAssociationCtrl.DeleteAllItems()
        self.goalAssociationCtrl.Enable()
        self.subGoalAssociationCtrl.Enable()
Пример #6
0
  def convert_properties(self, real_props=None, fake_props=None):
    new_props = []
    if real_props is not None:
      for real_prop in real_props:
        assert isinstance(real_prop, GoalEnvironmentProperties)
        del real_prop.theLabel
        new_concern_assocs = []
        for concern_assoc in real_prop.theConcernAssociations:
          new_concern_assocs.append(ConcernAssociationModel(concern_assoc[0],concern_assoc[1],concern_assoc[2],concern_assoc[3],concern_assoc[4]))

        new_goal_refinements = []
        for gr in real_prop.theGoalRefinements:
          new_goal_refinements.append(RefinementModel(gr[0],gr[1],gr[2],gr[3],gr[4]))

        new_subgoal_refinements = []
        for sgr in real_prop.theSubGoalRefinements:
          new_subgoal_refinements.append(RefinementModel(sgr[0],sgr[1],sgr[2],sgr[3],sgr[4]))

        real_prop.theConcernAssociations = new_concern_assocs
        real_prop.theGoalRefinements = new_goal_refinements
        real_prop.theSubGoalRefinements = new_subgoal_refinements
        new_props.append(real_prop)
    elif fake_props is not None:
      for fake_prop in fake_props:
        check_required_keys(fake_prop, GoalEnvironmentPropertiesModel.required)

        new_concern_assocs = []
        for concern_assoc in fake_prop['theConcernAssociations']:
          new_concern_assocs.append([concern_assoc['theSource'],concern_assoc['theSourceNry'],concern_assoc['theLinkVerb'],concern_assoc['theTarget'],concern_assoc['theTargetNry']])

        new_goal_refinements = []
        for gr in fake_prop['theGoalRefinements']:
          new_goal_refinements.append((gr['theEndName'],gr['theEndType'],gr['theRefType'],gr['isAlternate'],gr['theRationale']))

        new_subgoal_refinements = []
        for sgr in fake_prop['theSubGoalRefinements']:
          new_subgoal_refinements.append((sgr['theEndName'],sgr['theEndType'],sgr['theRefType'],sgr['isAlternate'],sgr['theRationale']))

        new_prop = GoalEnvironmentProperties(
          environmentName=fake_prop['theEnvironmentName'],
          lbl='',
          definition=fake_prop['theDefinition'],
          category=fake_prop['theCategory'],
          priority=fake_prop['thePriority'],
          fitCriterion=fake_prop['theFitCriterion'],
          issue=fake_prop['theIssue'],
          goalRefinements=new_goal_refinements,
          subGoalRefinements=new_subgoal_refinements,
          concs=fake_prop['theConcerns'],
          cas=new_concern_assocs)
        new_props.append(new_prop)
    else:
      self.close()
      raise MissingParameterHTTPError(param_names=['real_props', 'fake_props'])

    return new_props
Пример #7
0
 def parameters(self):
     properties = GoalEnvironmentProperties(
         self.theEnvironmentName, '', self.theGoalDefinition,
         self.theGoalCategory, self.theGoalPriority,
         self.theGoalFitCriterion, self.theGoalIssues, self.theAssociations,
         self.theSubAssociations, self.theConcerns,
         self.theConcernAssociations)
     parameters = GoalParameters(self.theGoalName, self.theGoalOriginator,
                                 [], [properties])
     return parameters
Пример #8
0
 def environmentProperties(self):
     if (self.theSelectedIdx != -1):
         environmentName = self.environmentList.GetItemText(
             self.theSelectedIdx)
         self.theEnvironmentDictionary[
             environmentName] = GoalEnvironmentProperties(
                 environmentName, '', self.theGoalDefinition,
                 self.theGoalCategory, self.theGoalPriority,
                 self.theGoalFitCriterion, self.theGoalIssue,
                 self.goalAssociationCtrl.dimensions(),
                 self.subGoalAssociationCtrl.dimensions(),
                 self.theGoalAssets, [])
     return self.theEnvironmentDictionary.values()
    def setUp(self):
        call([os.environ['CAIRIS_CFG_DIR'] + "/initdb.sh"])
        cairis.core.BorgFactory.initialise()
        f = open(os.environ['CAIRIS_SRC'] + '/test/policy_statements.json')
        d = json.load(f)
        f.close()
        ienvs = d['environments']
        iep1 = EnvironmentParameters(ienvs[0]["theName"],
                                     ienvs[0]["theShortCode"],
                                     ienvs[0]["theDescription"])
        b = Borg()
        b.dbProxy.addEnvironment(iep1)
        iassets = d['assets']
        iaeps1 = AssetEnvironmentProperties(
            iassets[0]["theEnvironmentProperties"][0][0],
            iassets[0]["theEnvironmentProperties"][0][1],
            iassets[0]["theEnvironmentProperties"][0][2])
        iap1 = AssetParameters(iassets[0]["theName"],
                               iassets[0]["theShortCode"],
                               iassets[0]["theDescription"],
                               iassets[0]["theSignificance"],
                               iassets[0]["theType"], "0", "N/A", [], [],
                               [iaeps1])
        b.dbProxy.addAsset(iap1)
        iaeps1 = AssetEnvironmentProperties(
            iassets[1]["theEnvironmentProperties"][0][0],
            iassets[1]["theEnvironmentProperties"][0][1],
            iassets[1]["theEnvironmentProperties"][0][2])
        iap2 = AssetParameters(iassets[1]["theName"],
                               iassets[1]["theShortCode"],
                               iassets[1]["theDescription"],
                               iassets[1]["theSignificance"],
                               iassets[1]["theType"], "0", "N/A", [], [],
                               [iaeps1])
        b.dbProxy.addAsset(iap2)
        self.iGoals = d['goals']

        igep1d = GoalEnvironmentProperties(
            self.iGoals[0]["theEnvironmentProperties"][0]["theName"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theLabel"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theDefinition"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theCategory"],
            self.iGoals[0]["theEnvironmentProperties"][0]["thePriority"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theFitCriterion"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theIssue"], [], [],
            self.iGoals[0]["theEnvironmentProperties"][0]["theConcerns"], [])
        igp1 = GoalParameters(self.iGoals[0]["theName"],
                              self.iGoals[0]["theOriginator"], [], [igep1d])
        b.dbProxy.addGoal(igp1)
        self.iPs = d['policy_statements']
Пример #10
0
 def environmentProperties(self):
     if (self.theSelectedIdx != -1):
         environmentName = self.environmentList.GetItemText(
             self.theSelectedIdx)
         self.theEnvironmentDictionary[
             environmentName] = GoalEnvironmentProperties(
                 environmentName, self.labelCtrl.GetValue(),
                 self.definitionCtrl.GetValue(),
                 self.categoryCtrl.GetValue(), self.priorityCtrl.GetValue(),
                 self.fitCriterionCtrl.GetValue(),
                 self.issueCtrl.GetValue(),
                 self.goalAssociationCtrl.dimensions(),
                 self.subGoalAssociationCtrl.dimensions(),
                 self.cCtrl.dimensions(), self.caCtrl.dimensions())
     return self.theEnvironmentDictionary.values()
Пример #11
0
 def OnAddEnvironment(self, evt):
     self.theSelectedIdx = evt.GetIndex()
     environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
     self.theEnvironmentDictionary[
         environmentName] = GoalEnvironmentProperties(environmentName)
     self.environmentList.Select(self.theSelectedIdx)
     self.labelCtrl.SetValue('')
     self.definitionCtrl.SetValue('None')
     self.categoryCtrl.SetValue('')
     self.priorityCtrl.SetValue('')
     self.fitCriterionCtrl.SetValue('None')
     self.issueCtrl.SetValue('None')
     self.goalAssociationCtrl.setEnvironment(environmentName)
     self.goalAssociationCtrl.DeleteAllItems()
     self.subGoalAssociationCtrl.setEnvironment(environmentName)
     self.subGoalAssociationCtrl.DeleteAllItems()
     self.cCtrl.setEnvironment(environmentName)
     self.cCtrl.DeleteAllItems()
     self.caCtrl.setEnvironment(environmentName)
     self.caCtrl.DeleteAllItems()
     self.definitionCtrl.Enable()
     self.categoryCtrl.Enable()
     self.priorityCtrl.Enable()
     self.fitCriterionCtrl.Enable()
     self.issueCtrl.Enable()
     self.goalAssociationCtrl.Enable()
     self.subGoalAssociationCtrl.Enable()
     self.cCtrl.Enable()
     self.caCtrl.Enable()
     inheritedEnv = self.environmentList.inheritedEnvironment()
     if (inheritedEnv != '' and self.theGoalId != None):
         p = self.dbProxy.inheritedGoalProperties(self.theGoalId,
                                                  inheritedEnv)
         self.theEnvironmentDictionary[environmentName] = p
         self.labelCtrl.SetValue(p.label())
         self.definitionCtrl.SetValue(p.definition())
         self.categoryCtrl.SetValue(p.category())
         self.priorityCtrl.SetValue(p.priority())
         self.fitCriterionCtrl.SetValue(p.fitCriterion())
         self.issueCtrl.SetValue(p.issue())
         self.goalAssociationCtrl.setEnvironment(environmentName)
         self.goalAssociationCtrl.load(p.goalRefinements())
         self.subGoalAssociationCtrl.setEnvironment(environmentName)
         self.subGoalAssociationCtrl.load(p.subGoalRefinements())
         self.cCtrl.setEnvironment(environmentName)
         self.caCtrl.setEnvironment(environmentName)
         self.cCtrl.load(p.concerns())
         self.caCtrl.load(p.concernAssociations())
Пример #12
0
 def inheritedGoalProperties(self, goalId, environmentName):
     environmentId = self.getDimensionId(environmentName, 'environment')
     goalDef = self.goalDefinition(goalId, environmentId)
     goalType = self.goalCategory(goalId, environmentId)
     goalPriority = self.goalPriority(goalId, environmentId)
     goalFitCriterion = self.goalFitCriterion(goalId, environmentId)
     goalIssue = self.goalIssue(goalId, environmentId)
     concs = self.goalConcerns(goalId, environmentId)
     cas = self.goalConcernAssociations(goalId, environmentId)
     goalRefinements, subGoalRefinements = self.goalRefinements(
         goalId, environmentId)
     return GoalEnvironmentProperties(environmentName, '', goalDef,
                                      goalType, goalPriority,
                                      goalFitCriterion, goalIssue,
                                      goalRefinements, subGoalRefinements,
                                      concs, cas)
Пример #13
0
 def OnEnvironmentDeselected(self, evt):
     self.theSelectedIdx = evt.GetIndex()
     environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
     self.theEnvironmentDictionary[
         environmentName] = GoalEnvironmentProperties(
             environmentName, '', self.theGoalDefinition,
             self.theGoalCategory, self.theGoalPriority,
             self.theGoalFitCriterion, self.theGoalIssue,
             self.goalAssociationCtrl.dimensions(),
             self.subGoalAssociationCtrl.dimensions(), self.theGoalAssets,
             [])
     self.goalAssociationCtrl.DeleteAllItems()
     self.goalAssociationCtrl.setEnvironment('')
     self.subGoalAssociationCtrl.DeleteAllItems()
     self.subGoalAssociationCtrl.setEnvironment('')
     self.theSelectedIdx = -1
     self.goalAssociationCtrl.Disable()
     self.subGoalAssociationCtrl.Disable()
Пример #14
0
 def OnAddEnvironment(self, evt):
     self.theSelectedIdx = evt.GetIndex()
     environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
     self.theEnvironmentDictionary[
         environmentName] = GoalEnvironmentProperties(environmentName)
     self.environmentList.Select(self.theSelectedIdx)
     self.goalAssociationCtrl.setEnvironment(environmentName)
     self.goalAssociationCtrl.DeleteAllItems()
     self.subGoalAssociationCtrl.setEnvironment(environmentName)
     self.subGoalAssociationCtrl.DeleteAllItems()
     self.goalAssociationCtrl.Enable()
     self.subGoalAssociationCtrl.Enable()
     inheritedEnv = self.environmentList.inheritedEnvironment()
     if (inheritedEnv != '' and self.theGoalId != None):
         p = self.dbProxy.inheritedGoalProperties(self.theGoalId,
                                                  inheritedEnv)
         self.theEnvironmentDictionary[environmentName] = p
         self.goalAssociationCtrl.setEnvironment(environmentName)
         self.goalAssociationCtrl.load(p.goalRefinements())
         self.subGoalAssociationCtrl.setEnvironment(environmentName)
         self.subGoalAssociationCtrl.load(p.subGoalRefinements())
Пример #15
0
 def OnEnvironmentDeselected(self, evt):
     self.theSelectedIdx = evt.GetIndex()
     environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
     self.theEnvironmentDictionary[
         environmentName] = GoalEnvironmentProperties(
             environmentName, self.labelCtrl.GetValue(),
             self.definitionCtrl.GetValue(), self.categoryCtrl.GetValue(),
             self.priorityCtrl.GetValue(), self.fitCriterionCtrl.GetValue(),
             self.issueCtrl.GetValue(),
             self.goalAssociationCtrl.dimensions(),
             self.subGoalAssociationCtrl.dimensions(),
             self.cCtrl.dimensions(), self.caCtrl.dimensions())
     self.labelCtrl.SetValue('')
     self.definitionCtrl.SetValue('')
     self.categoryCtrl.SetValue('')
     self.priorityCtrl.SetValue('')
     self.fitCriterionCtrl.SetValue('')
     self.issueCtrl.SetValue('')
     self.goalAssociationCtrl.DeleteAllItems()
     self.goalAssociationCtrl.setEnvironment('')
     self.subGoalAssociationCtrl.DeleteAllItems()
     self.subGoalAssociationCtrl.setEnvironment('')
     self.cCtrl.DeleteAllItems()
     self.caCtrl.DeleteAllItems()
     self.cCtrl.setEnvironment('')
     self.caCtrl.setEnvironment('')
     self.theSelectedIdx = -1
     self.definitionCtrl.Disable()
     self.categoryCtrl.Disable()
     self.priorityCtrl.Disable()
     self.fitCriterionCtrl.Disable()
     self.issueCtrl.Disable()
     self.goalAssociationCtrl.Disable()
     self.subGoalAssociationCtrl.Disable()
     self.cCtrl.Disable()
     self.caCtrl.Disable()
Пример #16
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
Пример #17
0
    def testGoal(self):
        b = Borg()
        igep1d = GoalEnvironmentProperties(
            self.iGoals[0]["theEnvironmentProperties"][0]["theName"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theLabel"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theDefinition"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theCategory"],
            self.iGoals[0]["theEnvironmentProperties"][0]["thePriority"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theFitCriterion"],
            self.iGoals[0]["theEnvironmentProperties"][0]["theIssue"], [], [],
            self.iGoals[0]["theEnvironmentProperties"][0]["theConcerns"], [])
        igep1n = GoalEnvironmentProperties(
            self.iGoals[0]["theEnvironmentProperties"][1]["theName"],
            self.iGoals[0]["theEnvironmentProperties"][1]["theLabel"],
            self.iGoals[0]["theEnvironmentProperties"][1]["theDefinition"],
            self.iGoals[0]["theEnvironmentProperties"][1]["theCategory"],
            self.iGoals[0]["theEnvironmentProperties"][1]["thePriority"],
            self.iGoals[0]["theEnvironmentProperties"][1]["theFitCriterion"],
            self.iGoals[0]["theEnvironmentProperties"][1]["theIssue"], [], [],
            self.iGoals[0]["theEnvironmentProperties"][1]["theConcerns"], [])

        igep2d = GoalEnvironmentProperties(
            self.iGoals[1]["theEnvironmentProperties"][0]["theName"],
            self.iGoals[1]["theEnvironmentProperties"][0]["theLabel"],
            self.iGoals[1]["theEnvironmentProperties"][0]["theDefinition"],
            self.iGoals[1]["theEnvironmentProperties"][0]["theCategory"],
            self.iGoals[1]["theEnvironmentProperties"][0]["thePriority"],
            self.iGoals[1]["theEnvironmentProperties"][0]["theFitCriterion"],
            self.iGoals[1]["theEnvironmentProperties"][0]["theIssue"], [], [],
            self.iGoals[1]["theEnvironmentProperties"][0]["theConcerns"], [])
        igep2n = GoalEnvironmentProperties(
            self.iGoals[1]["theEnvironmentProperties"][1]["theName"],
            self.iGoals[1]["theEnvironmentProperties"][1]["theLabel"],
            self.iGoals[1]["theEnvironmentProperties"][1]["theDefinition"],
            self.iGoals[1]["theEnvironmentProperties"][1]["theCategory"],
            self.iGoals[1]["theEnvironmentProperties"][1]["thePriority"],
            self.iGoals[1]["theEnvironmentProperties"][1]["theFitCriterion"],
            self.iGoals[1]["theEnvironmentProperties"][1]["theIssue"], [], [],
            self.iGoals[1]["theEnvironmentProperties"][1]["theConcerns"], [])

        igep3d = GoalEnvironmentProperties(
            self.iGoals[2]["theEnvironmentProperties"][0]["theName"],
            self.iGoals[2]["theEnvironmentProperties"][0]["theLabel"],
            self.iGoals[2]["theEnvironmentProperties"][0]["theDefinition"],
            self.iGoals[2]["theEnvironmentProperties"][0]["theCategory"],
            self.iGoals[2]["theEnvironmentProperties"][0]["thePriority"],
            self.iGoals[2]["theEnvironmentProperties"][0]["theFitCriterion"],
            self.iGoals[2]["theEnvironmentProperties"][0]["theIssue"], [], [],
            self.iGoals[2]["theEnvironmentProperties"][0]["theConcerns"], [])
        igep3n = GoalEnvironmentProperties(
            self.iGoals[2]["theEnvironmentProperties"][1]["theName"],
            self.iGoals[2]["theEnvironmentProperties"][1]["theLabel"],
            self.iGoals[2]["theEnvironmentProperties"][1]["theDefinition"],
            self.iGoals[2]["theEnvironmentProperties"][1]["theCategory"],
            self.iGoals[2]["theEnvironmentProperties"][1]["thePriority"],
            self.iGoals[2]["theEnvironmentProperties"][1]["theFitCriterion"],
            self.iGoals[2]["theEnvironmentProperties"][1]["theIssue"], [], [],
            self.iGoals[2]["theEnvironmentProperties"][1]["theConcerns"], [])
        igp1 = GoalParameters(self.iGoals[0]["theName"],
                              self.iGoals[0]["theOriginator"], [],
                              [igep1d, igep1n])
        igp2 = GoalParameters(self.iGoals[1]["theName"],
                              self.iGoals[1]["theOriginator"], [],
                              [igep2d, igep2n])
        igp3 = GoalParameters(self.iGoals[2]["theName"],
                              self.iGoals[2]["theOriginator"], [],
                              [igep3d, igep2n])
        b.dbProxy.addGoal(igp1)
        b.dbProxy.addGoal(igp2)
        b.dbProxy.addGoal(igp3)
        b.dbProxy.relabelGoals(igep1d.name())
        oGoals = b.dbProxy.getGoals()
        og1 = oGoals[self.iGoals[0]["theName"]]
        og2 = oGoals[self.iGoals[1]["theName"]]
        og3 = oGoals[self.iGoals[2]["theName"]]
        self.assertEqual(igp1.name(), og1.name())
        self.assertEqual(igp1.originator(), og1.originator())
        ogep1 = og1.environmentProperty(igep1d.name())
        ogep2 = og2.environmentProperty(igep1d.name())
        self.assertEqual(og1.refinements('Day'), False)

        self.assertEqual(igep1d.label(), ogep1.label())
        self.assertEqual(igep1d.definition(), ogep1.definition())
        self.assertEqual(
            igep1d.definition() + ' [Day].  ' + igep1d.definition() +
            ' [Night].  ', og1.definition('', 'Maximise'))
        self.assertEqual(igep1d.category(), ogep1.category())
        self.assertEqual(
            igep1d.category() + ' [Day].  ' + igep1d.category() +
            ' [Night].  ', og1.category('', 'Maximise'))
        self.assertEqual(igep1d.priority(), ogep1.priority())
        self.assertEqual(
            igep1d.priority() + ' [Day].  ' + igep1d.priority() +
            ' [Night].  ', og1.priority('', 'Maximise'))
        self.assertEqual(igep1d.fitCriterion(), ogep1.fitCriterion())
        self.assertEqual(
            igep1d.fitCriterion() + ' [Day].  ' + igep1d.fitCriterion() +
            ' [Night].  ', og1.fitCriterion('', 'Maximise'))
        self.assertEqual(igep1d.issue(), ogep1.issue())
        self.assertEqual(
            igep1d.issue() + ' [Day].  ' + igep1d.issue() + ' [Night].  ',
            og1.issue('', 'Maximise'))
        self.assertEqual(igep1d.goalRefinements(), ogep1.goalRefinements())
        self.assertEqual(igep1d.subGoalRefinements(),
                         ogep1.subGoalRefinements())
        self.assertEqual(igep1d.concerns(), ogep1.concerns())
        self.assertEqual(igep1d.concernAssociations(),
                         ogep1.concernAssociations())

        envName = self.iGoals[0]["theEnvironmentProperties"][0]['theName']
        self.assertEqual(igep1d.label(), og1.label(envName))
        self.assertEqual(igep1d.definition(), og1.definition(envName, ''))
        self.assertEqual(igep1d.category(), og1.category(envName, ''))
        self.assertEqual(igep1d.priority(), og1.priority(envName, ''))
        self.assertEqual(igep1d.fitCriterion(), og1.fitCriterion(envName, ''))
        self.assertEqual(igep1d.issue(), og1.issue(envName, ''))

        self.assertEqual(igep2d.label(), ogep2.label())
        self.assertEqual(igep2d.definition(), ogep2.definition())
        self.assertEqual(igep2d.category(), ogep2.category())
        self.assertEqual(igep2d.priority(), ogep2.priority())
        self.assertEqual(igep2d.fitCriterion(), ogep2.fitCriterion())
        self.assertEqual(igep2d.issue(), ogep2.issue())
        self.assertEqual(igep2d.goalRefinements(), ogep2.goalRefinements())
        self.assertEqual(igep2d.subGoalRefinements(),
                         ogep2.subGoalRefinements())
        self.assertEqual(igep2d.concerns(), ogep2.concerns())
        self.assertEqual(igep2d.concernAssociations(),
                         ogep2.concernAssociations())

        igop1 = GoalAssociationParameters(igep1d.name(),
                                          igp1.name(), 'goal', 'and',
                                          igp2.name(), 'goal', 0, 'None')
        igop2 = GoalAssociationParameters(igep1d.name(),
                                          igp1.name(), 'goal', 'and',
                                          igp3.name(), 'goal', 0, 'None')

        b.dbProxy.addGoalAssociation(igop1)
        b.dbProxy.addGoalAssociation(igop2)

        ogops = b.dbProxy.getGoalAssociations()
        ogop1 = ogops[igep1d.name() + '/' + igp1.name() + '/' + igp2.name() +
                      '/and']
        ogop2 = ogops[igep2d.name() + '/' + igp1.name() + '/' + igp3.name() +
                      '/and']

        self.assertEqual(igop1.environment(), ogop1.environment())
        self.assertEqual(igop1.goal(), ogop1.goal())
        self.assertEqual(igop1.goalDimension(), ogop1.goalDimension())
        self.assertEqual(igop1.type(), ogop1.type())
        self.assertEqual(igop1.subGoal(), ogop1.subGoal())
        self.assertEqual(igop1.subGoalDimension(), ogop1.subGoalDimension())
        self.assertEqual(igop1.alternative(), ogop1.alternative())
        self.assertEqual(igop1.rationale(), ogop1.rationale())

        self.assertEqual(igop2.environment(), ogop2.environment())
        self.assertEqual(igop2.goal(), ogop2.goal())
        self.assertEqual(igop2.goalDimension(), ogop2.goalDimension())
        self.assertEqual(igop2.type(), ogop2.type())
        self.assertEqual(igop2.subGoal(), ogop2.subGoal())
        self.assertEqual(igop2.subGoalDimension(), ogop2.subGoalDimension())
        self.assertEqual(igop2.alternative(), ogop2.alternative())
        self.assertEqual(igop2.rationale(), ogop2.rationale())

        b.dbProxy.deleteGoalAssociation(ogop1.id(), ogop1.goal(),
                                        ogop1.subGoal())
        b.dbProxy.deleteGoalAssociation(ogop2.id(), ogop2.goal(),
                                        ogop2.subGoal())

        b.dbProxy.deleteGoal(og1.id())
        b.dbProxy.deleteGoal(og2.id())
        b.dbProxy.deleteGoal(og3.id())
Пример #18
0
  def testGoal(self):
    b = Borg()
    igep1 = GoalEnvironmentProperties(self.iGoals[0]["theEnvironmentProperties"][0],self.iGoals[0]["theEnvironmentProperties"][1],self.iGoals[0]["theEnvironmentProperties"][2],self.iGoals[0]["theEnvironmentProperties"][3],self.iGoals[0]["theEnvironmentProperties"][4],self.iGoals[0]["theEnvironmentProperties"][5],self.iGoals[0]["theEnvironmentProperties"][6],[],[],[self.iGoals[0]["theEnvironmentProperties"][7]],[])
    igep2 = GoalEnvironmentProperties(self.iGoals[1]["theEnvironmentProperties"][0],self.iGoals[1]["theEnvironmentProperties"][1],self.iGoals[1]["theEnvironmentProperties"][2],self.iGoals[1]["theEnvironmentProperties"][3],self.iGoals[1]["theEnvironmentProperties"][4],self.iGoals[1]["theEnvironmentProperties"][5],self.iGoals[1]["theEnvironmentProperties"][6],[],[],[self.iGoals[1]["theEnvironmentProperties"][7]],[])
    igep3 = GoalEnvironmentProperties(self.iGoals[2]["theEnvironmentProperties"][0],self.iGoals[2]["theEnvironmentProperties"][1],self.iGoals[2]["theEnvironmentProperties"][2],self.iGoals[2]["theEnvironmentProperties"][3],self.iGoals[2]["theEnvironmentProperties"][4],self.iGoals[2]["theEnvironmentProperties"][5],self.iGoals[2]["theEnvironmentProperties"][6],[],[],[self.iGoals[2]["theEnvironmentProperties"][7]],[])

    igp1 = GoalParameters(self.iGoals[0]["theName"],self.iGoals[0]["theOriginator"],[],[igep1])
    igp2 = GoalParameters(self.iGoals[1]["theName"],self.iGoals[1]["theOriginator"],[],[igep2])
    igp3 = GoalParameters(self.iGoals[2]["theName"],self.iGoals[2]["theOriginator"],[],[igep3])
    b.dbProxy.addGoal(igp1)
    b.dbProxy.addGoal(igp2)
    b.dbProxy.addGoal(igp3)
    b.dbProxy.relabelGoals(igep1.name())
    oGoals = b.dbProxy.getGoals()
    og1 = oGoals[self.iGoals[0]["theName"]]
    og2 = oGoals[self.iGoals[1]["theName"]]
    og3 = oGoals[self.iGoals[2]["theName"]]
    self.assertEqual(igp1.name(), og1.name())
    self.assertEqual(igp1.originator(), og1.originator())
    ogep1 = og1.environmentProperty(igep1.name())
    ogep2 = og2.environmentProperty(igep1.name())

    self.assertEqual(igep1.label(), ogep1.label())
    self.assertEqual(igep1.definition(), ogep1.definition())
    self.assertEqual(igep1.category(), ogep1.category())
    self.assertEqual(igep1.priority(), ogep1.priority())
    self.assertEqual(igep1.fitCriterion(), ogep1.fitCriterion())
    self.assertEqual(igep1.issue(), ogep1.issue())
    self.assertEqual(igep1.goalRefinements(), ogep1.goalRefinements())
    self.assertEqual(igep1.subGoalRefinements(), ogep1.subGoalRefinements())
    self.assertEqual(igep1.concerns(), ogep1.concerns())
    self.assertEqual(igep1.concernAssociations(), ogep1.concernAssociations())

    envName = self.iGoals[0]["theEnvironmentProperties"][0]
    self.assertEqual(igep1.label(), og1.label(envName))
    self.assertEqual(igep1.definition(), og1.definition(envName,''))
    self.assertEqual(igep1.category(), og1.category(envName,''))
    self.assertEqual(igep1.priority(), og1.priority(envName,''))
    self.assertEqual(igep1.fitCriterion(), og1.fitCriterion(envName,''))
    self.assertEqual(igep1.issue(), og1.issue(envName,''))

    self.assertEqual(igep2.label(), ogep2.label())
    self.assertEqual(igep2.definition(), ogep2.definition())
    self.assertEqual(igep2.category(), ogep2.category())
    self.assertEqual(igep2.priority(), ogep2.priority())
    self.assertEqual(igep2.fitCriterion(), ogep2.fitCriterion())
    self.assertEqual(igep2.issue(), ogep2.issue())
    self.assertEqual(igep2.goalRefinements(), ogep2.goalRefinements())
    self.assertEqual(igep2.subGoalRefinements(), ogep2.subGoalRefinements())
    self.assertEqual(igep2.concerns(), ogep2.concerns())
    self.assertEqual(igep2.concernAssociations(), ogep2.concernAssociations())



    igop1 = GoalAssociationParameters(igep1.name(),igp1.name(),'goal','and',igp2.name(),'goal',0,'None')
    igop2 = GoalAssociationParameters(igep1.name(),igp1.name(),'goal','and',igp3.name(),'goal',0,'None')

    b.dbProxy.addGoalAssociation(igop1)
    b.dbProxy.addGoalAssociation(igop2)

    ogops = b.dbProxy.getGoalAssociations()
    ogop1 = ogops[igep1.name() + '/' + igp1.name() + '/' + igp2.name() + '/and']
    ogop2 = ogops[igep2.name() + '/' + igp1.name() + '/' + igp3.name() + '/and']

    self.assertEqual(igop1.environment(), ogop1.environment())
    self.assertEqual(igop1.goal(), ogop1.goal())
    self.assertEqual(igop1.goalDimension(), ogop1.goalDimension())
    self.assertEqual(igop1.type(), ogop1.type())
    self.assertEqual(igop1.subGoal(), ogop1.subGoal())
    self.assertEqual(igop1.subGoalDimension(), ogop1.subGoalDimension())
    self.assertEqual(igop1.alternative(), ogop1.alternative())
    self.assertEqual(igop1.rationale(), ogop1.rationale())

    self.assertEqual(igop2.environment(), ogop2.environment())
    self.assertEqual(igop2.goal(), ogop2.goal())
    self.assertEqual(igop2.goalDimension(), ogop2.goalDimension())
    self.assertEqual(igop2.type(), ogop2.type())
    self.assertEqual(igop2.subGoal(), ogop2.subGoal())
    self.assertEqual(igop2.subGoalDimension(), ogop2.subGoalDimension())
    self.assertEqual(igop2.alternative(), ogop2.alternative())
    self.assertEqual(igop2.rationale(), ogop2.rationale())

    b.dbProxy.deleteGoalAssociation(ogop1.id(),ogop1.goal(),ogop1.subGoal())
    b.dbProxy.deleteGoalAssociation(ogop2.id(),ogop2.goal(),ogop2.subGoal())

    b.dbProxy.deleteGoal(og1.id())
    b.dbProxy.deleteGoal(og2.id())
    b.dbProxy.deleteGoal(og3.id())
Пример #19
0
  def testGoal(self):
    b = Borg()
    igep1d = GoalEnvironmentProperties(self.iGoals[0]["theEnvironmentProperties"][0]["theName"],self.iGoals[0]["theEnvironmentProperties"][0]["theLabel"],self.iGoals[0]["theEnvironmentProperties"][0]["theDefinition"],self.iGoals[0]["theEnvironmentProperties"][0]["theCategory"],self.iGoals[0]["theEnvironmentProperties"][0]["thePriority"],self.iGoals[0]["theEnvironmentProperties"][0]["theFitCriterion"],self.iGoals[0]["theEnvironmentProperties"][0]["theIssue"],[],[],self.iGoals[0]["theEnvironmentProperties"][0]["theConcerns"],[])
    igep1n = GoalEnvironmentProperties(self.iGoals[0]["theEnvironmentProperties"][1]["theName"],self.iGoals[0]["theEnvironmentProperties"][1]["theLabel"],self.iGoals[0]["theEnvironmentProperties"][1]["theDefinition"],self.iGoals[0]["theEnvironmentProperties"][1]["theCategory"],self.iGoals[0]["theEnvironmentProperties"][1]["thePriority"],self.iGoals[0]["theEnvironmentProperties"][1]["theFitCriterion"],self.iGoals[0]["theEnvironmentProperties"][1]["theIssue"],[],[],self.iGoals[0]["theEnvironmentProperties"][1]["theConcerns"],[])

    igep2d = GoalEnvironmentProperties(self.iGoals[1]["theEnvironmentProperties"][0]["theName"],self.iGoals[1]["theEnvironmentProperties"][0]["theLabel"],self.iGoals[1]["theEnvironmentProperties"][0]["theDefinition"],self.iGoals[1]["theEnvironmentProperties"][0]["theCategory"],self.iGoals[1]["theEnvironmentProperties"][0]["thePriority"],self.iGoals[1]["theEnvironmentProperties"][0]["theFitCriterion"],self.iGoals[1]["theEnvironmentProperties"][0]["theIssue"],[],[],self.iGoals[1]["theEnvironmentProperties"][0]["theConcerns"],[])
    igep2n = GoalEnvironmentProperties(self.iGoals[1]["theEnvironmentProperties"][1]["theName"],self.iGoals[1]["theEnvironmentProperties"][1]["theLabel"],self.iGoals[1]["theEnvironmentProperties"][1]["theDefinition"],self.iGoals[1]["theEnvironmentProperties"][1]["theCategory"],self.iGoals[1]["theEnvironmentProperties"][1]["thePriority"],self.iGoals[1]["theEnvironmentProperties"][1]["theFitCriterion"],self.iGoals[1]["theEnvironmentProperties"][1]["theIssue"],[],[],self.iGoals[1]["theEnvironmentProperties"][1]["theConcerns"],[])

    igep3d = GoalEnvironmentProperties(self.iGoals[2]["theEnvironmentProperties"][0]["theName"],self.iGoals[2]["theEnvironmentProperties"][0]["theLabel"],self.iGoals[2]["theEnvironmentProperties"][0]["theDefinition"],self.iGoals[2]["theEnvironmentProperties"][0]["theCategory"],self.iGoals[2]["theEnvironmentProperties"][0]["thePriority"],self.iGoals[2]["theEnvironmentProperties"][0]["theFitCriterion"],self.iGoals[2]["theEnvironmentProperties"][0]["theIssue"],[],[],self.iGoals[2]["theEnvironmentProperties"][0]["theConcerns"],[])
    igep3n = GoalEnvironmentProperties(self.iGoals[2]["theEnvironmentProperties"][1]["theName"],self.iGoals[2]["theEnvironmentProperties"][1]["theLabel"],self.iGoals[2]["theEnvironmentProperties"][1]["theDefinition"],self.iGoals[2]["theEnvironmentProperties"][1]["theCategory"],self.iGoals[2]["theEnvironmentProperties"][1]["thePriority"],self.iGoals[2]["theEnvironmentProperties"][1]["theFitCriterion"],self.iGoals[2]["theEnvironmentProperties"][1]["theIssue"],[],[],self.iGoals[2]["theEnvironmentProperties"][1]["theConcerns"],[])
    igp1 = GoalParameters(self.iGoals[0]["theName"],self.iGoals[0]["theOriginator"],[],[igep1d,igep1n])
    igp2 = GoalParameters(self.iGoals[1]["theName"],self.iGoals[1]["theOriginator"],[],[igep2d,igep2n])
    igp3 = GoalParameters(self.iGoals[2]["theName"],self.iGoals[2]["theOriginator"],[],[igep3d,igep2n])
    b.dbProxy.addGoal(igp1)
    b.dbProxy.addGoal(igp2)
    b.dbProxy.addGoal(igp3)
    b.dbProxy.relabelGoals(igep1d.name())
    oGoals = b.dbProxy.getGoals()
    og1 = oGoals[self.iGoals[0]["theName"]]
    og2 = oGoals[self.iGoals[1]["theName"]]
    og3 = oGoals[self.iGoals[2]["theName"]]
    self.assertEqual(igp1.name(), og1.name())
    self.assertEqual(igp1.originator(), og1.originator())
    ogep1 = og1.environmentProperty(igep1d.name())
    ogep2 = og2.environmentProperty(igep1d.name())
    self.assertEqual(og1.refinements('Day'),False)

    self.assertEqual(igep1d.label(), ogep1.label())
    self.assertEqual(igep1d.definition(), ogep1.definition())
    self.assertEqual(igep1d.definition() + ' [Day].  ' + igep1d.definition() + ' [Night].  ', og1.definition('','Maximise'))
    self.assertEqual(igep1d.category(), ogep1.category())
    self.assertEqual(igep1d.category() + ' [Day].  ' + igep1d.category() + ' [Night].  ', og1.category('','Maximise'))
    self.assertEqual(igep1d.priority(), ogep1.priority())
    self.assertEqual(igep1d.priority() + ' [Day].  ' + igep1d.priority() + ' [Night].  ', og1.priority('','Maximise'))
    self.assertEqual(igep1d.fitCriterion(), ogep1.fitCriterion())
    self.assertEqual(igep1d.fitCriterion() + ' [Day].  ' + igep1d.fitCriterion() + ' [Night].  ', og1.fitCriterion('','Maximise'))
    self.assertEqual(igep1d.issue(), ogep1.issue())
    self.assertEqual(igep1d.issue() + ' [Day].  ' + igep1d.issue() + ' [Night].  ', og1.issue('','Maximise'))
    self.assertEqual(igep1d.goalRefinements(), ogep1.goalRefinements())
    self.assertEqual(igep1d.subGoalRefinements(), ogep1.subGoalRefinements())
    self.assertEqual(igep1d.concerns(), ogep1.concerns())
    self.assertEqual(igep1d.concernAssociations(), ogep1.concernAssociations())

    envName = self.iGoals[0]["theEnvironmentProperties"][0]['theName']
    self.assertEqual(igep1d.label(), og1.label(envName))
    self.assertEqual(igep1d.definition(), og1.definition(envName,''))
    self.assertEqual(igep1d.category(), og1.category(envName,''))
    self.assertEqual(igep1d.priority(), og1.priority(envName,''))
    self.assertEqual(igep1d.fitCriterion(), og1.fitCriterion(envName,''))
    self.assertEqual(igep1d.issue(), og1.issue(envName,''))

    self.assertEqual(igep2d.label(), ogep2.label())
    self.assertEqual(igep2d.definition(), ogep2.definition())
    self.assertEqual(igep2d.category(), ogep2.category())
    self.assertEqual(igep2d.priority(), ogep2.priority())
    self.assertEqual(igep2d.fitCriterion(), ogep2.fitCriterion())
    self.assertEqual(igep2d.issue(), ogep2.issue())
    self.assertEqual(igep2d.goalRefinements(), ogep2.goalRefinements())
    self.assertEqual(igep2d.subGoalRefinements(), ogep2.subGoalRefinements())
    self.assertEqual(igep2d.concerns(), ogep2.concerns())
    self.assertEqual(igep2d.concernAssociations(), ogep2.concernAssociations())



    igop1 = GoalAssociationParameters(igep1d.name(),igp1.name(),'goal','and',igp2.name(),'goal',0,'None')
    igop2 = GoalAssociationParameters(igep1d.name(),igp1.name(),'goal','and',igp3.name(),'goal',0,'None')

    b.dbProxy.addGoalAssociation(igop1)
    b.dbProxy.addGoalAssociation(igop2)

    ogops = b.dbProxy.getGoalAssociations()
    ogop1 = ogops[igep1d.name() + '/' + igp1.name() + '/' + igp2.name() + '/and']
    ogop2 = ogops[igep2d.name() + '/' + igp1.name() + '/' + igp3.name() + '/and']

    self.assertEqual(igop1.environment(), ogop1.environment())
    self.assertEqual(igop1.goal(), ogop1.goal())
    self.assertEqual(igop1.goalDimension(), ogop1.goalDimension())
    self.assertEqual(igop1.type(), ogop1.type())
    self.assertEqual(igop1.subGoal(), ogop1.subGoal())
    self.assertEqual(igop1.subGoalDimension(), ogop1.subGoalDimension())
    self.assertEqual(igop1.alternative(), ogop1.alternative())
    self.assertEqual(igop1.rationale(), ogop1.rationale())

    self.assertEqual(igop2.environment(), ogop2.environment())
    self.assertEqual(igop2.goal(), ogop2.goal())
    self.assertEqual(igop2.goalDimension(), ogop2.goalDimension())
    self.assertEqual(igop2.type(), ogop2.type())
    self.assertEqual(igop2.subGoal(), ogop2.subGoal())
    self.assertEqual(igop2.subGoalDimension(), ogop2.subGoalDimension())
    self.assertEqual(igop2.alternative(), ogop2.alternative())
    self.assertEqual(igop2.rationale(), ogop2.rationale())

    b.dbProxy.deleteGoalAssociation(ogop1.id(),ogop1.goal(),ogop1.subGoal())
    b.dbProxy.deleteGoalAssociation(ogop2.id(),ogop2.goal(),ogop2.subGoal())

    b.dbProxy.deleteGoal(og1.id())
    b.dbProxy.deleteGoal(og2.id())
    b.dbProxy.deleteGoal(og3.id())
Пример #20
0
 def endElement(self, name):
     if name == 'domainproperty':
         p = DomainPropertyParameters(self.theName, self.theDescription,
                                      self.theType, self.theOriginator,
                                      self.theTags)
         self.theDomainProperties.append(p)
         self.resetDomainPropertyAttributes()
     elif name == 'goal_environment':
         p = GoalEnvironmentProperties(self.theEnvironmentName, '',
                                       self.theDescription,
                                       self.theCategory, self.thePriority,
                                       self.theFitCriterion, self.theIssue,
                                       [], [], self.theConcerns,
                                       self.theConcernAssociations)
         self.theEnvironmentProperties.append(p)
         self.resetGoalEnvironmentAttributes()
     elif name == 'obstacle_environment':
         p = ObstacleEnvironmentProperties(self.theEnvironmentName, '',
                                           self.theDescription,
                                           self.theCategory, [], [],
                                           self.theConcerns)
         self.theEnvironmentProperties.append(p)
         self.resetObstacleEnvironmentAttributes()
     elif name == 'goal':
         p = GoalParameters(self.theName, self.theOriginator, self.theTags,
                            self.theEnvironmentProperties)
         self.theGoals.append(p)
         self.resetGoalAttributes()
     elif name == 'obstacle':
         p = ObstacleParameters(self.theName, 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, self.theName, self.theDescription,
             self.thePriority, self.theRationale, self.theFitCriterion,
             self.theOriginator, self.theType, self.theReference)
         self.theRequirements.append(
             (r, self.theReference, self.theReferenceType))
         self.resetRequirementAttributes()
     elif name == 'countermeasure':
         p = CountermeasureParameters(self.theName, self.theDescription,
                                      self.theType, self.theTags,
                                      self.theEnvironmentProperties)
         self.theCountermeasures.append(p)
         self.resetCountermeasureAttributes()
     elif name == 'mitigating_property':
         self.theSpDict[self.thePropertyName] = (self.thePropertyValue,
                                                 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,
                    self.theRationale))
         self.theTargetResponses = []
     elif (name == 'description'):
         self.inDescription = 0
     elif (name == 'definition'):
         self.inDescription = 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
Пример #21
0
    def testGoal(self):
        b = Borg()
        igep1 = GoalEnvironmentProperties(
            self.iGoals[0]["theEnvironmentProperties"][0],
            self.iGoals[0]["theEnvironmentProperties"][1],
            self.iGoals[0]["theEnvironmentProperties"][2],
            self.iGoals[0]["theEnvironmentProperties"][3],
            self.iGoals[0]["theEnvironmentProperties"][4],
            self.iGoals[0]["theEnvironmentProperties"][5],
            self.iGoals[0]["theEnvironmentProperties"][6], [], [],
            [self.iGoals[0]["theEnvironmentProperties"][7]], [])
        igep2 = GoalEnvironmentProperties(
            self.iGoals[1]["theEnvironmentProperties"][0],
            self.iGoals[1]["theEnvironmentProperties"][1],
            self.iGoals[1]["theEnvironmentProperties"][2],
            self.iGoals[1]["theEnvironmentProperties"][3],
            self.iGoals[1]["theEnvironmentProperties"][4],
            self.iGoals[1]["theEnvironmentProperties"][5],
            self.iGoals[1]["theEnvironmentProperties"][6], [], [],
            [self.iGoals[1]["theEnvironmentProperties"][7]], [])
        igep3 = GoalEnvironmentProperties(
            self.iGoals[2]["theEnvironmentProperties"][0],
            self.iGoals[2]["theEnvironmentProperties"][1],
            self.iGoals[2]["theEnvironmentProperties"][2],
            self.iGoals[2]["theEnvironmentProperties"][3],
            self.iGoals[2]["theEnvironmentProperties"][4],
            self.iGoals[2]["theEnvironmentProperties"][5],
            self.iGoals[2]["theEnvironmentProperties"][6], [], [],
            [self.iGoals[2]["theEnvironmentProperties"][7]], [])

        igp1 = GoalParameters(self.iGoals[0]["theName"],
                              self.iGoals[0]["theOriginator"], [], [igep1])
        igp2 = GoalParameters(self.iGoals[1]["theName"],
                              self.iGoals[1]["theOriginator"], [], [igep2])
        igp3 = GoalParameters(self.iGoals[2]["theName"],
                              self.iGoals[2]["theOriginator"], [], [igep3])
        b.dbProxy.addGoal(igp1)
        b.dbProxy.addGoal(igp2)
        b.dbProxy.addGoal(igp3)
        b.dbProxy.relabelGoals(igep1.name())
        oGoals = b.dbProxy.getGoals()
        og1 = oGoals[self.iGoals[0]["theName"]]
        og2 = oGoals[self.iGoals[1]["theName"]]
        og3 = oGoals[self.iGoals[2]["theName"]]
        self.assertEqual(igp1.name(), og1.name())
        self.assertEqual(igp1.originator(), og1.originator())
        ogep1 = og1.environmentProperty(igep1.name())
        ogep2 = og2.environmentProperty(igep1.name())

        self.assertEqual(igep1.label(), ogep1.label())
        self.assertEqual(igep1.definition(), ogep1.definition())
        self.assertEqual(igep1.category(), ogep1.category())
        self.assertEqual(igep1.priority(), ogep1.priority())
        self.assertEqual(igep1.fitCriterion(), ogep1.fitCriterion())
        self.assertEqual(igep1.issue(), ogep1.issue())
        self.assertEqual(igep1.goalRefinements(), ogep1.goalRefinements())
        self.assertEqual(igep1.subGoalRefinements(),
                         ogep1.subGoalRefinements())
        self.assertEqual(igep1.concerns(), ogep1.concerns())
        self.assertEqual(igep1.concernAssociations(),
                         ogep1.concernAssociations())

        envName = self.iGoals[0]["theEnvironmentProperties"][0]
        self.assertEqual(igep1.label(), og1.label(envName))
        self.assertEqual(igep1.definition(), og1.definition(envName, ''))
        self.assertEqual(igep1.category(), og1.category(envName, ''))
        self.assertEqual(igep1.priority(), og1.priority(envName, ''))
        self.assertEqual(igep1.fitCriterion(), og1.fitCriterion(envName, ''))
        self.assertEqual(igep1.issue(), og1.issue(envName, ''))

        self.assertEqual(igep2.label(), ogep2.label())
        self.assertEqual(igep2.definition(), ogep2.definition())
        self.assertEqual(igep2.category(), ogep2.category())
        self.assertEqual(igep2.priority(), ogep2.priority())
        self.assertEqual(igep2.fitCriterion(), ogep2.fitCriterion())
        self.assertEqual(igep2.issue(), ogep2.issue())
        self.assertEqual(igep2.goalRefinements(), ogep2.goalRefinements())
        self.assertEqual(igep2.subGoalRefinements(),
                         ogep2.subGoalRefinements())
        self.assertEqual(igep2.concerns(), ogep2.concerns())
        self.assertEqual(igep2.concernAssociations(),
                         ogep2.concernAssociations())

        igop1 = GoalAssociationParameters(igep1.name(),
                                          igp1.name(), 'goal', 'and',
                                          igp2.name(), 'goal', 0, 'None')
        igop2 = GoalAssociationParameters(igep1.name(),
                                          igp1.name(), 'goal', 'and',
                                          igp3.name(), 'goal', 0, 'None')

        b.dbProxy.addGoalAssociation(igop1)
        b.dbProxy.addGoalAssociation(igop2)

        ogops = b.dbProxy.getGoalAssociations()
        ogop1 = ogops[igep1.name() + '/' + igp1.name() + '/' + igp2.name() +
                      '/and']
        ogop2 = ogops[igep2.name() + '/' + igp1.name() + '/' + igp3.name() +
                      '/and']

        self.assertEqual(igop1.environment(), ogop1.environment())
        self.assertEqual(igop1.goal(), ogop1.goal())
        self.assertEqual(igop1.goalDimension(), ogop1.goalDimension())
        self.assertEqual(igop1.type(), ogop1.type())
        self.assertEqual(igop1.subGoal(), ogop1.subGoal())
        self.assertEqual(igop1.subGoalDimension(), ogop1.subGoalDimension())
        self.assertEqual(igop1.alternative(), ogop1.alternative())
        self.assertEqual(igop1.rationale(), ogop1.rationale())

        self.assertEqual(igop2.environment(), ogop2.environment())
        self.assertEqual(igop2.goal(), ogop2.goal())
        self.assertEqual(igop2.goalDimension(), ogop2.goalDimension())
        self.assertEqual(igop2.type(), ogop2.type())
        self.assertEqual(igop2.subGoal(), ogop2.subGoal())
        self.assertEqual(igop2.subGoalDimension(), ogop2.subGoalDimension())
        self.assertEqual(igop2.alternative(), ogop2.alternative())
        self.assertEqual(igop2.rationale(), ogop2.rationale())

        b.dbProxy.deleteGoalAssociation(ogop1.id(), ogop1.goal(),
                                        ogop1.subGoal())
        b.dbProxy.deleteGoalAssociation(ogop2.id(), ogop2.goal(),
                                        ogop2.subGoal())

        b.dbProxy.deleteGoal(og1.id())
        b.dbProxy.deleteGoal(og2.id())
        b.dbProxy.deleteGoal(og3.id())