示例#1
0
class NewRequirementNodeDialog:
    def __init__(self, objt, environmentName, builder):
        self.window = builder.get_object("NewRequirementNodeDialog")
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theGoalName = objt.name()
        self.theEnvironmentName = environmentName
        self.theGoalAssociation = None
        self.decorator = NDImplementationDecorator(builder)
        reqTypes = self.dbProxy.getDimensionNames('requirement_type')
        priorityTypes = ['1', '2', '3']
        reqAssets = self.dbProxy.environmentAssets(self.theEnvironmentName)
        self.goalAssociations = []
        self.subGoalAssociations = []
        self.decorator.updateComboCtrl("newRequirementTypeCtrl", reqTypes, '')
        self.decorator.updateComboCtrl("requirementAssetCtrl", reqAssets, '')
        self.decorator.updateComboCtrl("newRequirementPriorityCtrl",
                                       priorityTypes, '')
        self.window.resize(350, 600)

    def requirementParameters(self):
        reqType = self.decorator.getComboValue("newRequirementTypeCtrl")
        reqPri = self.decorator.getComboValue("newRequirementPriorityCtrl")
        reqDesc = self.decorator.getMLText("newRequirementDescriptionCtrl")
        reqRat = self.decorator.getMLText("newRequirementRationaleCtrl")
        reqFC = self.decorator.getMLText("newRequirementFitCriterionCtrl")
        reqOrig = self.decorator.getMLText("newRequirementOriginatorCtrl")
        self.theAssetName = self.decorator.getComboValue(
            "requirementAssetCtrl")
        completeReqLabel = self.dbProxy.lastRequirementLabel(self.theAssetName)
        reqAsset, reqLabel = completeReqLabel.split('-')
        reqId = self.dbProxy.newId()
        reqLabel = int(reqLabel)
        reqLabel += 1
        r = RequirementFactory.build(reqId, reqLabel, reqDesc, reqPri, reqRat,
                                     reqFC, reqOrig, reqType,
                                     self.theAssetName)
        return r

    def requirementAsset(self):
        return self.theAssetName

    def on_newRequirementOkButton_clicked(self, callback_data):
        req = self.requirementParameters()
        self.dbProxy.addRequirement(req, self.theAssetName, True)
        reqLabel = self.dbProxy.lastRequirementLabel(self.theAssetName)
        self.theGoalAssociation = GoalAssociationParameters(
            self.theEnvironmentName,
            self.theGoalName,
            'goal',
            'and',
            reqLabel,
            'requirement',
        )
        self.dbProxy.addGoalAssociation(self.theGoalAssociation)
        self.window.destroy()

    def show(self):
        self.window.show()
class NewRequirementNodeDialog:
    def __init__(self, objt, environmentName, builder):
        self.window = builder.get_object("NewRequirementNodeDialog")
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theGoalName = objt.name()
        self.theEnvironmentName = environmentName
        self.theGoalAssociation = None
        self.decorator = NDImplementationDecorator(builder)
        reqTypes = self.dbProxy.getDimensionNames("requirement_type")
        priorityTypes = ["1", "2", "3"]
        reqAssets = self.dbProxy.environmentAssets(self.theEnvironmentName)
        self.goalAssociations = []
        self.subGoalAssociations = []
        self.decorator.updateComboCtrl("newRequirementTypeCtrl", reqTypes, "")
        self.decorator.updateComboCtrl("requirementAssetCtrl", reqAssets, "")
        self.decorator.updateComboCtrl("newRequirementPriorityCtrl", priorityTypes, "")
        self.window.resize(350, 600)

    def requirementParameters(self):
        reqType = self.decorator.getComboValue("newRequirementTypeCtrl")
        reqPri = self.decorator.getComboValue("newRequirementPriorityCtrl")
        reqDesc = self.decorator.getMLText("newRequirementDescriptionCtrl")
        reqRat = self.decorator.getMLText("newRequirementRationaleCtrl")
        reqFC = self.decorator.getMLText("newRequirementFitCriterionCtrl")
        reqOrig = self.decorator.getMLText("newRequirementOriginatorCtrl")
        self.theAssetName = self.decorator.getComboValue("requirementAssetCtrl")
        completeReqLabel = self.dbProxy.lastRequirementLabel(self.theAssetName)
        reqAsset, reqLabel = completeReqLabel.split("-")
        reqId = self.dbProxy.newId()
        reqLabel = int(reqLabel)
        reqLabel += 1
        r = RequirementFactory.build(
            reqId, reqLabel, reqDesc, reqPri, reqRat, reqFC, reqOrig, reqType, self.theAssetName
        )
        return r

    def requirementAsset(self):
        return self.theAssetName

    def on_newRequirementOkButton_clicked(self, callback_data):
        req = self.requirementParameters()
        self.dbProxy.addRequirement(req, self.theAssetName, True)
        reqLabel = self.dbProxy.lastRequirementLabel(self.theAssetName)
        self.theGoalAssociation = GoalAssociationParameters(
            self.theEnvironmentName, self.theGoalName, "goal", "and", reqLabel, "requirement"
        )
        self.dbProxy.addGoalAssociation(self.theGoalAssociation)
        self.window.destroy()

    def show(self):
        self.window.show()
示例#3
0
class ObstacleNodeDialog:
  def __init__(self,objt,environmentName,dupProperty,overridingEnvironment,builder):
    self.window = builder.get_object("ObstacleNodeDialog")
    b = Borg()
    self.dbProxy = b.dbProxy
    self.theEnvironmentName = environmentName
    self.theObstacleAssociation = None
    self.theObstacleId = -1
    self.decorator = NDImplementationDecorator(builder)
    obstacleCategories = self.dbProxy.getDimensionNames('obstacle_category_type')
    self.obstacleAssociations = []
    self.subObstacleAssociations = []
    if (objt == None):
      self.decorator.updateComboCtrl("obstacleCategoryCtrl",obstacleCategories,'')
      self.decorator.updateButtonLabel("obstacleOkButton","Create")
      self.isCreate = True
    else:
      self.theObstacleId= objt.id()
      envProperty = objt.environmentProperty(self.theEnvironmentName)
      self.obstacleAssociations = envProperty.goalRefinements()
      self.subObstacleAssociations = envProperty.subGoalRefinements()
      self.decorator.updateTextCtrl("obstacleNameCtrl",objt.name())
      self.decorator.updateComboCtrl("obstacleCategoryCtrl",obstacleCategories,objt.category(environmentName,dupProperty))
      self.decorator.updateMLTextCtrl("obstacleDefinitionCtrl",objt.definition(environmentName,dupProperty))
      self.decorator.updateButtonLabel("obstacleOkButton","Update")
      self.isCreate = False
    self.window.resize(350,600)

  def environmentProperties(self):
    obsCat = self.decorator.getComboValue("obstacleCategoryCtrl")
    obsDef = self.decorator.getMLText("obstacleDefinitionCtrl")
    envProperties = ObstacleEnvironmentProperties(self.theEnvironmentName,'',obsDef,obsCat,self.obstacleAssociations,self.subObstacleAssociations)
    return envProperties

  def newObstacleParameters(self):
    obsName = self.decorator.getText("obstacleNameCtrl")
    envProperties = self.environmentProperties()
    parameters = ObstacleParameters(obsName,'Obstacle refinement',[],[envProperties])
    parameters.setId(self.theObstacleId)
    return parameters

  def existingObstacleParameters(self):
    obsName = self.decorator.getText("obstacleNameCtrl")
    modifiedProperties = self.environmentProperties()
    envProperties = self.dbProxy.obstacleEnvironmentProperties(self.theObstacleId)
    for idx,p in enumerate(envProperties):
      if (p.name() == self.theEnvironmentName):
        envProperties[idx] = modifiedProperties
    parameters = ObstacleParameters(obsName,'Obstacle refinement',[],envProperties)
    parameters.setId(self.theObstacleId)
    return parameters

  def parentObstacle(self,obsName,assocType):
    self.theObstacleAssociation = GoalAssociationParameters(self.theEnvironmentName,obsName,'obstacle',assocType)

  def on_obstacleOkButton_clicked(self,callback_data):
    if (self.isCreate):
      parameters = self.newObstacleParameters()
      self.dbProxy.addObstacle(parameters)
      self.theObstacleAssociation.theSubGoal = parameters.name()
      self.theObstacleAssociation.theSubGoalDimension = 'obstacle'
      self.theObstacleAssociation.theAlternativeId = 0
      self.theObstacleAssociation.theRationale = ''
      self.dbProxy.addGoalAssociation(self.theObstacleAssociation)
    else:
      parameters = self.existingObstacleParameters()
      self.dbProxy.updateObstacle(parameters)
    self.window.destroy()

  def show(self):
    self.window.show()
示例#4
0
class GoalNodeDialog:
  def __init__(self,objt,environmentName,dupProperty,overridingEnvironment,builder):
    self.window = builder.get_object("GoalNodeDialog")
    b = Borg()
    self.dbProxy = b.dbProxy
    self.theEnvironmentName = environmentName
    self.theGoalAssociation = None
    self.theGoalId = -1
    self.decorator = NDImplementationDecorator(builder)
    goalCategories = self.dbProxy.getDimensionNames('goal_category_type')
    priorityTypes = self.dbProxy.getDimensionNames('priority_type')
    self.goalAssociations = []
    self.subGoalAssociations= []
    if (objt == None):
      self.decorator.updateComboCtrl("goalCategoryCtrl",goalCategories,'')
      self.decorator.updateComboCtrl("goalPriorityCtrl",priorityTypes,'')
      self.decorator.updateButtonLabel("goalOkButton","Create")
      self.isCreate = True
    else:
      self.theGoalId = objt.id()
      envProperty = objt.environmentProperty(self.theEnvironmentName)
      self.goalAssociations = envProperty.goalRefinements()
      self.subGoalAssociations = envProperty.subGoalRefinements()
      self.decorator.updateTextCtrl("goalNameCtrl",objt.name())
      self.decorator.updateMLTextCtrl("goalDefinitionCtrl",objt.definition(environmentName,dupProperty))
      self.decorator.updateComboCtrl("goalCategoryCtrl",goalCategories,objt.category(environmentName,dupProperty))
      self.decorator.updateComboCtrl("goalPriorityCtrl",priorityTypes,objt.priority(environmentName,dupProperty))
      self.decorator.updateMLTextCtrl("goalFitCriterionCtrl",objt.fitCriterion(environmentName,dupProperty))
      self.decorator.updateMLTextCtrl("goalIssueCtrl",objt.issue(environmentName,dupProperty))
      self.decorator.updateButtonLabel("goalOkButton","Update")
      self.isCreate = False
    self.window.resize(350,600)


  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

  def newGoalParameters(self):
    goalName = self.decorator.getText("goalNameCtrl")
    envProperties = self.environmentProperties()
    parameters = GoalParameters(goalName,'None',[],[envProperties]) 
    parameters.setId(self.theGoalId)
    return parameters

  def existingGoalParameters(self):
    goalName = self.decorator.getText("goalNameCtrl")
    modifiedProperties = self.environmentProperties()
    goalEnvProperties = self.dbProxy.goalEnvironmentProperties(self.theGoalId)
    for idx,p in enumerate(goalEnvProperties):
      if (p.name() == self.theEnvironmentName):
        goalEnvProperties[idx] = modifiedProperties
    parameters = GoalParameters(goalName,'None',[],goalEnvProperties) 
    parameters.setId(self.theGoalId)
    return parameters

  def parentGoal(self,goalName,assocType):
    self.theGoalAssociation = GoalAssociationParameters(self.theEnvironmentName,goalName,'goal',assocType)

  def on_goalOkButton_clicked(self,callback_data):
    if (self.isCreate):
      parameters = self.newGoalParameters()
      self.dbProxy.addGoal(parameters)
      self.theGoalAssociation.theSubGoal = parameters.name()
      self.theGoalAssociation.theSubGoalDimension = 'goal'
      self.theGoalAssociation.theAlternativeId = 0
      self.theGoalAssociation.theRationale = ''
      self.dbProxy.addGoalAssociation(self.theGoalAssociation)
    else:
      parameters = self.existingGoalParameters()
      self.dbProxy.updateGoal(parameters)
    self.window.destroy()

  def show(self):
    self.window.show()
示例#5
0
class ObstacleNodeDialog:
    def __init__(self, objt, environmentName, dupProperty, overridingEnvironment, builder):
        self.window = builder.get_object("ObstacleNodeDialog")
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theEnvironmentName = environmentName
        self.theObstacleAssociation = None
        self.theObstacleId = -1
        self.decorator = NDImplementationDecorator(builder)
        obstacleCategories = self.dbProxy.getDimensionNames("obstacle_category_type")
        self.obstacleAssociations = []
        self.subObstacleAssociations = []
        if objt == None:
            self.decorator.updateComboCtrl("obstacleCategoryCtrl", obstacleCategories, "")
            self.decorator.updateButtonLabel("obstacleOkButton", "Create")
            self.isCreate = True
        else:
            self.theObstacleId = objt.id()
            envProperty = objt.environmentProperty(self.theEnvironmentName)
            self.obstacleAssociations = envProperty.goalRefinements()
            self.subObstacleAssociations = envProperty.subGoalRefinements()
            self.decorator.updateTextCtrl("obstacleNameCtrl", objt.name())
            self.decorator.updateComboCtrl(
                "obstacleCategoryCtrl", obstacleCategories, objt.category(environmentName, dupProperty)
            )
            self.decorator.updateMLTextCtrl("obstacleDefinitionCtrl", objt.definition(environmentName, dupProperty))
            self.decorator.updateButtonLabel("obstacleOkButton", "Update")
            self.isCreate = False
        self.window.resize(350, 600)

    def environmentProperties(self):
        obsCat = self.decorator.getComboValue("obstacleCategoryCtrl")
        obsDef = self.decorator.getMLText("obstacleDefinitionCtrl")
        envProperties = ObstacleEnvironmentProperties(
            self.theEnvironmentName, "", obsDef, obsCat, self.obstacleAssociations, self.subObstacleAssociations
        )
        return envProperties

    def newObstacleParameters(self):
        obsName = self.decorator.getText("obstacleNameCtrl")
        envProperties = self.environmentProperties()
        parameters = ObstacleParameters(obsName, "Obstacle refinement", [], [envProperties])
        parameters.setId(self.theObstacleId)
        return parameters

    def existingObstacleParameters(self):
        obsName = self.decorator.getText("obstacleNameCtrl")
        modifiedProperties = self.environmentProperties()
        envProperties = self.dbProxy.obstacleEnvironmentProperties(self.theObstacleId)
        for idx, p in enumerate(envProperties):
            if p.name() == self.theEnvironmentName:
                envProperties[idx] = modifiedProperties
        parameters = ObstacleParameters(obsName, "Obstacle refinement", [], envProperties)
        parameters.setId(self.theObstacleId)
        return parameters

    def parentObstacle(self, obsName, assocType):
        self.theObstacleAssociation = GoalAssociationParameters(self.theEnvironmentName, obsName, "obstacle", assocType)

    def on_obstacleOkButton_clicked(self, callback_data):
        if self.isCreate:
            parameters = self.newObstacleParameters()
            self.dbProxy.addObstacle(parameters)
            self.theObstacleAssociation.theSubGoal = parameters.name()
            self.theObstacleAssociation.theSubGoalDimension = "obstacle"
            self.theObstacleAssociation.theAlternativeId = 0
            self.theObstacleAssociation.theRationale = ""
            self.dbProxy.addGoalAssociation(self.theObstacleAssociation)
        else:
            parameters = self.existingObstacleParameters()
            self.dbProxy.updateObstacle(parameters)
        self.window.destroy()

    def show(self):
        self.window.show()