Ejemplo n.º 1
0
 def parameters(self):
     parameters = TaskParameters(self.theName, self.theShortCode,
                                 self.theObjective, self.isAssumption,
                                 self.theAuthor, self.theTags,
                                 self.theEnvironmentProperties)
     parameters.setId(self.theTaskId)
     return parameters
Ejemplo n.º 2
0
  def add_task(self, task):
    """
    :type task: Task
    :rtype: int
    :raise ARMHTTPError:
    """
    task_params = TaskParameters(
      tName=task.name(),
      tSName=task.shortCode(),
      tObjt=task.objective(),
      isAssumption=task.assumption(),
      tAuth=task.author(),
      tags=task.tags(),
      cProps=task.environmentProperties()
    )

    try:
      if not self.check_existing_task(task.name()):
        new_id = self.db_proxy.addTask(task_params)
        return new_id
      else:
        self.close()
        raise OverwriteNotAllowedHTTPError(obj_name=task.name())
    except DatabaseProxyException as ex:
      self.close()
      raise ARMHTTPError(ex)
    except ARMException as ex:
      self.close()
      raise ARMHTTPError(ex)
Ejemplo n.º 3
0
 def endElement(self,name):
   if name == 'persona':
     p = PersonaParameters(self.theName,unescape(self.theActivities),unescape(self.theAttitudes),unescape(self.theAptitudes),unescape(self.theMotivations),unescape(self.theSkills),unescape(self.theIntrinsic),unescape(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,unescape(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,unescape(self.theDescription))
     self.theExternalDocuments.append(p)
     self.resetExternalDocumentAttributes()
   elif name == 'document_reference':
     p = DocumentReferenceParameters(self.theName,self.theDocument,self.theContributor,unescape(self.theExcerpt))
     self.theDocumentReferences.append(p)
     self.resetDocumentReferenceAttributes()
   elif name == 'persona_characteristic':
     p = PersonaCharacteristicParameters(self.thePersona,self.theModalQualifier,self.theBvName,unescape(self.theDefinition),self.theGrounds,self.theWarrants,[],self.theRebuttals)
     self.thePersonaCharacteristics.append(p)
     self.resetPersonaCharacteristicAttributes()
   elif name == 'task':
     p = TaskParameters(unescape(self.theName),unescape(self.theCode),unescape(self.theObjective),self.isAssumptionTask,self.theAuthor,self.theTags,self.theEnvironmentProperties)
     self.theTasks.append(p)
     self.resetTaskAttributes()
   elif name == 'task_environment':
     p = TaskEnvironmentProperties(unescape(self.theEnvironmentName),unescape(self.theDependencies),self.theTaskPersonas,self.theConcerns,self.theConcernAssociations,unescape(self.theNarrative),unescape(self.theConsequences),unescape(self.theBenefits),[],{'narrative':{},'consequences':{},'benefits':{}})
     self.theEnvironmentProperties.append(p)
     self.resetTaskEnvironmentAttributes()
   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 == 'benefits':
     self.inBenefits = 0
   elif name == 'consequences':
     self.inConsequences = 0
Ejemplo n.º 4
0
 def update_task(self, task, name):
     task_params = TaskParameters(tName=task.name(),
                                  tSName=task.shortCode(),
                                  tObjt=task.objective(),
                                  isAssumption=task.assumption(),
                                  tAuth=task.author(),
                                  tags=task.tags(),
                                  cProps=task.environmentProperties())
     try:
         taskId = self.db_proxy.getDimensionId(name, 'task')
         task_params.setId(taskId)
         self.db_proxy.updateTask(task_params)
     except DatabaseProxyException as ex:
         self.close()
         raise ARMHTTPError(ex)
     except ARMException as ex:
         self.close()
         raise ARMHTTPError(ex)
Ejemplo n.º 5
0
 def update_task(self, task, name):
   task_params = TaskParameters(
     tName=task.name(),
     tSName=task.shortCode(),
     tObjt=task.objective(),
     isAssumption=task.assumption(),
     tAuth=task.author(),
     tags=task.tags(),
     cProps=task.environmentProperties()
   )
   try:
     taskId = self.db_proxy.getDimensionId(name,'task')
     task_params.setId(taskId)
     self.db_proxy.updateTask(task_params)
   except DatabaseProxyException as ex:
     self.close()
     raise ARMHTTPError(ex)
   except ARMException as ex:
     self.close()
     raise ARMHTTPError(ex)
Ejemplo n.º 6
0
    def update_task(self, task, name):
        found_task = self.get_task_by_name(name, simplify=False)

        task_params = TaskParameters(tName=task.name(),
                                     tSName=task.shortCode(),
                                     tObjt=task.objective(),
                                     isAssumption=task.assumption(),
                                     tAuth=task.author(),
                                     tags=task.tags(),
                                     cProps=task.environmentProperties())

        task_params.setId(found_task.id())

        try:
            self.db_proxy.updateTask(task_params)
        except DatabaseProxyException as ex:
            self.close()
            raise ARMHTTPError(ex)
        except ARMException as ex:
            self.close()
            raise ARMHTTPError(ex)
Ejemplo n.º 7
0
  def update_task(self, task, name):
    found_task = self.get_task_by_name(name, simplify=False)

    task_params = TaskParameters(
      tName=task.name(),
      tSName=task.shortCode(),
      tObjt=task.objective(),
      isAssumption=task.assumption(),
      tAuth=task.author(),
      tags=task.tags(),
      cProps=task.environmentProperties()
    )

    task_params.setId(found_task.id())

    try:
      self.db_proxy.updateTask(task_params)
    except DatabaseProxyException as ex:
      self.close()
      raise ARMHTTPError(ex)
    except ARMException as ex:
      self.close()
      raise ARMHTTPError(ex)
Ejemplo n.º 8
0
  def testTask(self):
    t = self.iTasks[0]
    taskName = t["theName"]
    taskTags = t["theTaskTags"]
    taskShortCode = t["theShortCode"]
    taskObjective = t["theObjective"]
    taskAuthor = t["theAuthor"]
    isAssumptionTask = int(t["isAssumption"])
    tEnv = t["theEnvironments"][0]
    envName = tEnv["theName"]
    deps = tEnv["theDependencies"]
    taskPersona = tEnv["theTaskPersonas"][0]["thePersona"]
    taskDuration = tEnv["theTaskPersonas"][0]["theDuration"]
    taskFreq = tEnv["theTaskPersonas"][0]["theFrequency"]
    taskDemands = tEnv["theTaskPersonas"][0]["theDemands"]
    taskGoalConflict = tEnv["theTaskPersonas"][0]["theGoalConflict"]
    taskAssets = tEnv["theTaskAssets"]
    taskConcerns = []
    taskNarrative = tEnv["theNarrative"]
    taskConsequences = tEnv["theConsequences"]
    taskBenefits = tEnv["theBenefits"]
    iteps = [TaskEnvironmentProperties(envName,deps,[(taskPersona,taskDuration,taskFreq,taskDemands,taskGoalConflict)],taskAssets,taskConcerns,taskNarrative,taskConsequences,taskBenefits)]
    iTask = TaskParameters(taskName,taskShortCode,taskObjective,isAssumptionTask,taskAuthor,taskTags,iteps)
    b = Borg()
    b.dbProxy.addTask(iTask)
    theTasks = b.dbProxy.getTasks()
    oTask = theTasks[self.iTasks[0]["theName"]] 

    self.assertEqual(iTask.name(),oTask.name())
    self.assertEqual(iTask.tags(),oTask.tags())
    self.assertEqual(iTask.shortCode(),oTask.shortCode())
    self.assertEqual(iTask.objective(),oTask.objective())
    self.assertEqual(iTask.assumption(),oTask.assumption())
    self.assertEqual(iTask.author(),oTask.author())
    self.assertEqual(iTask.environmentProperties()[0].personas(),oTask.personas(envName,'',envName))
    self.assertEqual(iTask.environmentProperties()[0].assets(),oTask.assets(envName,''))
    self.assertEqual(iTask.environmentProperties()[0].narrative(),oTask.narrative(envName,''))
    self.assertEqual(iTask.environmentProperties()[0].consequences(),oTask.environmentProperties()[0].consequences())
    self.assertEqual(iTask.environmentProperties()[0].benefits(),oTask.environmentProperties()[0].benefits())
    self.assertEqual(iTask.environmentProperties()[0].dependencies(),oTask.environmentProperties()[0].dependencies())
    self.assertEqual(oTask.usability(envName,''),5)

    iTask.theName = 'Updated name'
    iTask.setId(oTask.id())
    b.dbProxy.updateTask(iTask)
    theTasks = b.dbProxy.getTasks()
    oTask = theTasks['Updated name'] 
    self.assertEqual(oTask.name(),'Updated name')
    self.assertEqual(iTask.tags(),oTask.tags())
    self.assertEqual(iTask.shortCode(),oTask.shortCode())
    self.assertEqual(iTask.objective(),oTask.objective())
    self.assertEqual(iTask.assumption(),oTask.assumption())
    self.assertEqual(iTask.author(),oTask.author())
    self.assertEqual(iTask.environmentProperties()[0].personas(),oTask.environmentProperties()[0].personas())
    self.assertEqual(iTask.environmentProperties()[0].assets(),oTask.environmentProperties()[0].assets())
    self.assertEqual(iTask.environmentProperties()[0].narrative(),oTask.environmentProperties()[0].narrative())
    self.assertEqual(iTask.environmentProperties()[0].consequences(),oTask.environmentProperties()[0].consequences())
    self.assertEqual(iTask.environmentProperties()[0].benefits(),oTask.environmentProperties()[0].benefits())
    self.assertEqual(iTask.environmentProperties()[0].dependencies(),oTask.environmentProperties()[0].dependencies())

    b.dbProxy.deleteTask(oTask.id())
Ejemplo n.º 9
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
Ejemplo n.º 10
0
 def parameters(self): 
   parameters = TaskParameters(self.theName,self.theShortCode,self.theObjective,self.isAssumption,self.theAuthor,self.theTags,self.theEnvironmentProperties)
   parameters.setId(self.theTaskId)
   return parameters
Ejemplo n.º 11
0
    def testTask(self):
        t = self.iTasks[0]
        taskName = t["theName"]
        taskTags = t["theTaskTags"]
        taskShortCode = t["theShortCode"]
        taskObjective = t["theObjective"]
        taskAuthor = t["theAuthor"]
        isAssumptionTask = int(t["isAssumption"])
        tEnv = t["theEnvironments"][0]
        envName = tEnv["theName"]
        deps = tEnv["theDependencies"]
        taskPersona = tEnv["theTaskPersonas"][0]["thePersona"]
        taskDuration = tEnv["theTaskPersonas"][0]["theDuration"]
        taskFreq = tEnv["theTaskPersonas"][0]["theFrequency"]
        taskDemands = tEnv["theTaskPersonas"][0]["theDemands"]
        taskGoalConflict = tEnv["theTaskPersonas"][0]["theGoalConflict"]
        taskAssets = tEnv["theTaskAssets"]
        taskConcerns = []
        taskNarrative = tEnv["theNarrative"]
        taskConsequences = tEnv["theConsequences"]
        taskBenefits = tEnv["theBenefits"]
        iteps = [
            TaskEnvironmentProperties(envName, deps,
                                      [(taskPersona, taskDuration, taskFreq,
                                        taskDemands, taskGoalConflict)],
                                      taskAssets, taskConcerns, taskNarrative,
                                      taskConsequences, taskBenefits)
        ]
        iTask = TaskParameters(taskName, taskShortCode, taskObjective,
                               isAssumptionTask, taskAuthor, taskTags, iteps)
        b = Borg()
        b.dbProxy.addTask(iTask)
        theTasks = b.dbProxy.getTasks()
        oTask = theTasks[self.iTasks[0]["theName"]]

        self.assertEqual(iTask.name(), oTask.name())
        self.assertEqual(iTask.tags(), oTask.tags())
        self.assertEqual(iTask.shortCode(), oTask.shortCode())
        self.assertEqual(iTask.objective(), oTask.objective())
        self.assertEqual(iTask.assumption(), oTask.assumption())
        self.assertEqual(iTask.author(), oTask.author())
        self.assertEqual(iTask.environmentProperties()[0].personas(),
                         oTask.personas(envName, '', envName))
        self.assertEqual(iTask.environmentProperties()[0].assets(),
                         oTask.assets(envName, ''))
        self.assertEqual(iTask.environmentProperties()[0].narrative(),
                         oTask.narrative(envName, ''))
        self.assertEqual(iTask.environmentProperties()[0].consequences(),
                         oTask.environmentProperties()[0].consequences())
        self.assertEqual(iTask.environmentProperties()[0].benefits(),
                         oTask.environmentProperties()[0].benefits())
        self.assertEqual(iTask.environmentProperties()[0].dependencies(),
                         oTask.environmentProperties()[0].dependencies())
        self.assertEqual(oTask.usability(envName, ''), 5)

        self.assertEqual(b.dbProxy.taskLoad(oTask.id(), 104), 5)

        iTask.theName = 'Updated name'
        iTask.setId(oTask.id())
        b.dbProxy.updateTask(iTask)
        theTasks = b.dbProxy.getTasks()
        oTask = theTasks['Updated name']
        self.assertEqual(oTask.name(), 'Updated name')
        self.assertEqual(iTask.tags(), oTask.tags())
        self.assertEqual(iTask.shortCode(), oTask.shortCode())
        self.assertEqual(iTask.objective(), oTask.objective())
        self.assertEqual(iTask.assumption(), oTask.assumption())
        self.assertEqual(iTask.author(), oTask.author())
        self.assertEqual(iTask.environmentProperties()[0].personas(),
                         oTask.environmentProperties()[0].personas())
        self.assertEqual(iTask.environmentProperties()[0].personas(),
                         oTask.personas('Psychosis', '', ''))
        self.assertEqual(
            iTask.environmentProperties()[0].personas()[0][1],
            list(oTask.personas('Psychosis', 'Maximise', ''))[0][1])
        self.assertEqual(iTask.environmentProperties()[0].assets(),
                         oTask.environmentProperties()[0].assets())
        self.assertEqual(iTask.environmentProperties()[0].assets(),
                         oTask.assets('Psychosis', ''))
        self.assertEqual(iTask.environmentProperties()[0].assets(),
                         list(oTask.assets('', 'Maximise')))
        self.assertEqual(iTask.environmentProperties()[0].narrative(),
                         oTask.environmentProperties()[0].narrative())
        self.assertEqual(iTask.environmentProperties()[0].narrative(),
                         oTask.narrative('Psychosis', ''))
        self.assertEqual(iTask.environmentProperties()[0].narrative(),
                         oTask.narrative('', 'Maximise'))
        self.assertEqual(iTask.environmentProperties()[0].consequences(),
                         oTask.environmentProperties()[0].consequences())
        self.assertEqual(iTask.environmentProperties()[0].benefits(),
                         oTask.environmentProperties()[0].benefits())
        self.assertEqual(iTask.environmentProperties()[0].dependencies(),
                         oTask.environmentProperties()[0].dependencies())
        self.assertEqual(iTask.environmentProperties()[0].dependencies(),
                         oTask.dependencies('Psychosis', ''))
        self.assertEqual(iTask.environmentProperties()[0].dependencies(),
                         oTask.dependencies('', 'Maximise'))

        b.dbProxy.deleteTask(oTask.id())