Пример #1
0
    def update_persona_properties(self, props, name, existing_params=None):
        if existing_params is None:
            persona = self.get_persona_by_name(name, simplify=False)

            existing_params = PersonaParameters(
                name=persona.name(),
                activities=persona.activities(),
                attitudes=persona.attitudes(),
                aptitudes=persona.aptitudes(),
                motivations=persona.motivations(),
                skills=persona.skills(),
                intrinsic=persona.intrinsic(),
                contextual=persona.contextual(),
                image=persona.image(),
                isAssumption=persona.assumption(),
                pType=persona.type(),
                tags=persona.tags(),
                properties=persona.environmentProperties(),
                pCodes=persona.theCodes)
            existing_params.setId(persona.id())
        existing_params.theEnvironmentProperties = props

        try:
            self.db_proxy.updatePersona(existing_params)
        except DatabaseProxyException as ex:
            self.close()
            raise ARMHTTPError(ex)
        except ARMException as ex:
            self.close()
            raise ARMHTTPError(ex)
Пример #2
0
 def update_object(self, persona, name):
     persona_params = PersonaParameters(
         name=persona.name(),
         activities=persona.activities(),
         attitudes=persona.attitudes(),
         aptitudes=persona.aptitudes(),
         motivations=persona.motivations(),
         skills=persona.skills(),
         intrinsic=persona.intrinsic(),
         contextual=persona.contextual(),
         image=persona.image(),
         isAssumption=persona.assumption(),
         pType=persona.type(),
         tags=persona.tags(),
         properties=persona.environmentProperties(),
         pCodes=[])
     try:
         personaId = self.db_proxy.getDimensionId(name, 'persona')
         persona_params.setId(personaId)
         self.db_proxy.updatePersona(persona_params)
     except DatabaseProxyException as ex:
         self.close()
         raise ARMHTTPError(ex)
     except ARMException as ex:
         self.close()
         raise ARMHTTPError(ex)
Пример #3
0
 def update_persona(self, persona, name):
   persona_params = PersonaParameters(
     name=persona.name(),
     activities=persona.activities(),
     attitudes=persona.attitudes(),
     aptitudes=persona.aptitudes(),
     motivations=persona.motivations(),
     skills=persona.skills(),
     intrinsic=persona.intrinsic(),
     contextual=persona.contextual(),
     image=persona.image(),
     isAssumption=persona.assumption(),
     pType=persona.type(),
     tags=persona.tags(),
     properties=persona.environmentProperties(),
     pCodes=[]
   )
   try:
     personaId = self.db_proxy.getDimensionId(name,'persona')
     persona_params.setId(personaId)
     self.db_proxy.updatePersona(persona_params)
   except DatabaseProxyException as ex:
     self.close()
     raise ARMHTTPError(ex)
   except ARMException as ex:
     self.close()
     raise ARMHTTPError(ex)
Пример #4
0
  def update_persona_properties(self, props, name, existing_params=None):
    if existing_params is None:
      persona = self.get_persona_by_name(name, simplify=False)

      existing_params = PersonaParameters(
        name=persona.name(),
        activities=persona.activities(),
        attitudes=persona.attitudes(),
        aptitudes=persona.aptitudes(),
        motivations=persona.motivations(),
        skills=persona.skills(),
        intrinsic=persona.intrinsic(),
        contextual=persona.contextual(),
        image=persona.image(),
        isAssumption=persona.assumption(),
        pType=persona.type(),
        tags=persona.tags(),
        properties=persona.environmentProperties(),
        pCodes=persona.theCodes
      )
      existing_params.setId(persona.id())
    existing_params.theEnvironmentProperties = props

    try:
      self.db_proxy.updatePersona(existing_params)
    except DatabaseProxyException as ex:
      self.close()
      raise ARMHTTPError(ex)
    except ARMException as ex:
      self.close()
      raise ARMHTTPError(ex)
Пример #5
0
 def parameters(self):
     parameters = PersonaParameters(
         self.thePersonaName, self.theActivities, self.theAttitudes,
         self.theAptitudes, self.theMotivations, self.theSkills,
         self.theIntrinsic, self.theContextual, self.theImage,
         self.isAssumption, self.theType, self.theTags,
         self.theEnvironmentProperties, self.theCodes)
     parameters.setId(self.thePersonaId)
     return parameters
Пример #6
0
 def parameters(self):
   parameters = PersonaParameters(self.thePersonaName,self.theActivities,self.theAttitudes,self.theAptitudes,self.theMotivations,self.theSkills,self.theIntrinsic,self.theContextual,self.theImage,self.isAssumption,self.theType,self.theTags,self.theEnvironmentProperties,self.theCodes)
   parameters.setId(self.thePersonaId)
   return parameters
Пример #7
0
  def testPersona(self):
    ipp = PersonaParameters(self.iPersonas[0]["theName"],self.iPersonas[0]["theActivities"],self.iPersonas[0]["theAttitudes"],self.iPersonas[0]["theAptitudes"],self.iPersonas[0]["theMotivations"],self.iPersonas[0]["theSkills"],self.iPersonas[0]["theIntrinsic"],self.iPersonas[0]["theContextual"],"","0",self.iPersonas[0]["thePersonaType"],[],[PersonaEnvironmentProperties(self.iPersonas[0]["theEnvironmentProperties"][0]["theName"],(self.iPersonas[0]["theEnvironmentProperties"][0]["theDirectFlag"] == "True"),self.iPersonas[0]["theEnvironmentProperties"][0]["theNarrative"],self.iPersonas[0]["theEnvironmentProperties"][0]["theRole"])],[])
    b = Borg()
    b.dbProxy.addPersona(ipp) 

    thePersonas = b.dbProxy.getPersonas()
    op = thePersonas[self.iPersonas[0]["theName"]]
    self.assertEqual(ipp.name(),op.name())
    self.assertEqual(ipp.activities(),op.activities())
    self.assertEqual(ipp.attitudes(),op.attitudes())
    self.assertEqual(ipp.aptitudes(),op.aptitudes())
    self.assertEqual(ipp.motivations(),op.motivations())
    self.assertEqual(ipp.skills(),op.skills())
    self.assertEqual(ipp.intrinsic(),op.intrinsic())
    self.assertEqual(ipp.contextual(),op.contextual())
    
    self.assertEqual(self.iPersonas[0]["theEnvironmentProperties"][0]["theDirectFlag"],op.environmentProperties()[0].directFlag())
    self.assertEqual(self.iPersonas[0]["theEnvironmentProperties"][0]["theNarrative"],op.environmentProperties()[0].narrative())
    self.assertEqual(self.iPersonas[0]["theEnvironmentProperties"][0]["theRole"],op.environmentProperties()[0].roles())

    iec1 = ExternalDocumentParameters(self.iExternalDocuments[0]["theName"],self.iExternalDocuments[0]["theVersion"],self.iExternalDocuments[0]["thePublicationDate"],self.iExternalDocuments[0]["theAuthors"],self.iExternalDocuments[0]["theDescription"])
    iec2 = ExternalDocumentParameters(self.iExternalDocuments[1]["theName"],self.iExternalDocuments[1]["theVersion"],self.iExternalDocuments[1]["thePublicationDate"],self.iExternalDocuments[1]["theAuthors"],self.iExternalDocuments[1]["theDescription"])
    b.dbProxy.addExternalDocument(iec1)
    b.dbProxy.addExternalDocument(iec2)
    oecs = b.dbProxy.getExternalDocuments()
    oec1 = oecs[self.iExternalDocuments[0]["theName"]]
    oec2 = oecs[self.iExternalDocuments[1]["theName"]]

    self.assertEqual(self.iExternalDocuments[0]["theName"],oec1.name())
    self.assertEqual(self.iExternalDocuments[0]["theVersion"],oec1.version())
    self.assertEqual(self.iExternalDocuments[0]["thePublicationDate"],oec1.date())
    self.assertEqual(self.iExternalDocuments[0]["theAuthors"],oec1.authors())
    self.assertEqual(self.iExternalDocuments[0]["theDescription"],oec1.description())
    self.assertEqual(self.iExternalDocuments[1]["theName"],oec2.name())
    self.assertEqual(self.iExternalDocuments[1]["theVersion"],oec2.version())
    self.assertEqual(self.iExternalDocuments[1]["thePublicationDate"],oec2.date())
    self.assertEqual(self.iExternalDocuments[1]["theAuthors"],oec2.authors())
    self.assertEqual(self.iExternalDocuments[1]["theDescription"],oec2.description())

    idr1 = DocumentReferenceParameters(self.iDocumentReferences[0]["theName"],self.iDocumentReferences[0]["theDocName"],self.iDocumentReferences[0]["theContributor"],self.iDocumentReferences[0]["theExcerpt"])
    idr2 = DocumentReferenceParameters(self.iDocumentReferences[1]["theName"],self.iDocumentReferences[1]["theDocName"],self.iDocumentReferences[1]["theContributor"],self.iDocumentReferences[1]["theExcerpt"])
    idr3 = DocumentReferenceParameters(self.iDocumentReferences[2]["theName"],self.iDocumentReferences[2]["theDocName"],self.iDocumentReferences[2]["theContributor"],self.iDocumentReferences[2]["theExcerpt"])
    
    b.dbProxy.addDocumentReference(idr1)
    b.dbProxy.addDocumentReference(idr2)
    b.dbProxy.addDocumentReference(idr3)

    odrs = b.dbProxy.getDocumentReferences()
    odr1 = odrs[self.iDocumentReferences[0]["theName"]]
    odr2 = odrs[self.iDocumentReferences[1]["theName"]]
    odr3 = odrs[self.iDocumentReferences[2]["theName"]]

    self.assertEqual(self.iDocumentReferences[0]["theName"],odr1.name())
    self.assertEqual(self.iDocumentReferences[0]["theDocName"],odr1.document())
    self.assertEqual(self.iDocumentReferences[0]["theContributor"],odr1.contributor())
    self.assertEqual(self.iDocumentReferences[0]["theExcerpt"],odr1.excerpt())
    self.assertEqual(self.iDocumentReferences[1]["theName"],odr2.name())
    self.assertEqual(self.iDocumentReferences[1]["theDocName"],odr2.document())
    self.assertEqual(self.iDocumentReferences[1]["theContributor"],odr2.contributor())
    self.assertEqual(self.iDocumentReferences[1]["theExcerpt"],odr2.excerpt())
    self.assertEqual(self.iDocumentReferences[2]["theName"],odr3.name())
    self.assertEqual(self.iDocumentReferences[2]["theDocName"],odr3.document())
    self.assertEqual(self.iDocumentReferences[2]["theContributor"],odr3.contributor())
    self.assertEqual(self.iDocumentReferences[2]["theExcerpt"],odr3.excerpt())

    ipc1 = PersonaCharacteristicParameters(self.iPersonaCharacteristics[0]["thePersonaName"],self.iPersonaCharacteristics[0]["theModQual"],self.iPersonaCharacteristics[0]["theVariable"],self.iPersonaCharacteristics[0]["theCharacteristic"],[(self.iPersonaCharacteristics[0]["ground"],'','document')],[(self.iPersonaCharacteristics[0]["warrant"],'','document')],[],[(self.iPersonaCharacteristics[0]["rebuttal"],'','document')])

    b.dbProxy.addPersonaCharacteristic(ipc1)
    opcs = b.dbProxy.getPersonaCharacteristics()
    opc1 = opcs[self.iPersonaCharacteristics[0]["thePersonaName"] + '/' + self.iPersonaCharacteristics[0]["theVariable"] + '/' + self.iPersonaCharacteristics[0]["theCharacteristic"]]

    self.assertEqual(self.iPersonaCharacteristics[0]["thePersonaName"],opc1.persona())
    self.assertEqual(self.iPersonaCharacteristics[0]["theModQual"],opc1.qualifier())
    self.assertEqual(self.iPersonaCharacteristics[0]["theVariable"],opc1.behaviouralVariable())
    self.assertEqual(self.iPersonaCharacteristics[0]["theCharacteristic"],opc1.characteristic())
    self.assertEqual(self.iPersonaCharacteristics[0]["ground"],opc1.grounds()[0][0])
    self.assertEqual(self.iPersonaCharacteristics[0]["warrant"],opc1.warrant()[0][0])
    self.assertEqual(self.iPersonaCharacteristics[0]["rebuttal"],opc1.rebuttal()[0][0])

    ipp2 = PersonaParameters('Changed name',self.iPersonas[0]["theActivities"],self.iPersonas[0]["theAttitudes"],self.iPersonas[0]["theAptitudes"],self.iPersonas[0]["theMotivations"],self.iPersonas[0]["theSkills"],self.iPersonas[0]["theIntrinsic"],self.iPersonas[0]["theContextual"],"","0",self.iPersonas[0]["thePersonaType"],[],[PersonaEnvironmentProperties(self.iPersonas[0]["theEnvironmentProperties"][0]["theName"],(self.iPersonas[0]["theEnvironmentProperties"][0]["theDirectFlag"] == "True"),self.iPersonas[0]["theEnvironmentProperties"][0]["theNarrative"],self.iPersonas[0]["theEnvironmentProperties"][0]["theRole"])],[])

    ipp2.setId(op.id())
    b.dbProxy.updatePersona(ipp2) 
    theUpdatedPersonas = b.dbProxy.getPersonas()
    op2 = theUpdatedPersonas['Changed name']
    self.assertEqual(ipp2.name(),op2.name())



    b.dbProxy.deletePersonaCharacteristic(opc1.id())

    b.dbProxy.deleteDocumentReference(odr1.id())
    b.dbProxy.deleteDocumentReference(odr2.id())
    b.dbProxy.deleteDocumentReference(odr3.id())

    b.dbProxy.deleteExternalDocument(oec1.id())
    b.dbProxy.deleteExternalDocument(oec2.id())
    b.dbProxy.deletePersona(op.id())
Пример #8
0
    def testPersona(self):
        ipp = PersonaParameters(
            self.iPersonas[0]["theName"], self.iPersonas[0]["theActivities"],
            self.iPersonas[0]["theAttitudes"],
            self.iPersonas[0]["theAptitudes"],
            self.iPersonas[0]["theMotivations"],
            self.iPersonas[0]["theSkills"], self.iPersonas[0]["theIntrinsic"],
            self.iPersonas[0]["theContextual"], "", "0",
            self.iPersonas[0]["thePersonaType"], [], [
                PersonaEnvironmentProperties(
                    self.iPersonas[0]["theEnvironmentProperties"][0]
                    ["theName"], (self.iPersonas[0]["theEnvironmentProperties"]
                                  [0]["theDirectFlag"] == "True"),
                    self.iPersonas[0]["theEnvironmentProperties"][0]
                    ["theNarrative"], self.iPersonas[0]
                    ["theEnvironmentProperties"][0]["theRole"])
            ], [])
        b = Borg()
        b.dbProxy.addPersona(ipp)

        thePersonas = b.dbProxy.getPersonas()
        op = thePersonas[self.iPersonas[0]["theName"]]
        self.assertEqual(ipp.name(), op.name())
        self.assertEqual(ipp.activities(), op.activities())
        self.assertEqual(ipp.attitudes(), op.attitudes())
        self.assertEqual(ipp.aptitudes(), op.aptitudes())
        self.assertEqual(ipp.motivations(), op.motivations())
        self.assertEqual(ipp.skills(), op.skills())
        self.assertEqual(ipp.intrinsic(), op.intrinsic())
        self.assertEqual(ipp.contextual(), op.contextual())
        self.assertEqual(op.roles('Psychosis', '')[0], 'Researcher')
        self.assertEqual('Researcher' in op.roles('Psychosis', 'override'),
                         True)
        self.assertEqual(op.directFlag('Psychosis', ''), 'False')
        self.assertEqual(op.directFlag('Psychosis', 'override'), 'False')
        self.assertEqual(op.narrative('Psychosis', ''), 'Nothing stipulated')
        self.assertEqual(op.narrative('Psychosis', 'override'),
                         'Nothing stipulated')

        self.assertEqual(
            self.iPersonas[0]["theEnvironmentProperties"][0]["theDirectFlag"],
            op.environmentProperties()[0].directFlag())
        self.assertEqual(
            self.iPersonas[0]["theEnvironmentProperties"][0]["theNarrative"],
            op.environmentProperties()[0].narrative())
        self.assertEqual(
            self.iPersonas[0]["theEnvironmentProperties"][0]["theRole"],
            op.environmentProperties()[0].roles())

        iec1 = ExternalDocumentParameters(
            self.iExternalDocuments[0]["theName"],
            self.iExternalDocuments[0]["theVersion"],
            self.iExternalDocuments[0]["thePublicationDate"],
            self.iExternalDocuments[0]["theAuthors"],
            self.iExternalDocuments[0]["theDescription"])
        iec2 = ExternalDocumentParameters(
            self.iExternalDocuments[1]["theName"],
            self.iExternalDocuments[1]["theVersion"],
            self.iExternalDocuments[1]["thePublicationDate"],
            self.iExternalDocuments[1]["theAuthors"],
            self.iExternalDocuments[1]["theDescription"])
        b.dbProxy.addExternalDocument(iec1)
        b.dbProxy.addExternalDocument(iec2)
        oecs = b.dbProxy.getExternalDocuments()
        oec1 = oecs[self.iExternalDocuments[0]["theName"]]
        oec2 = oecs[self.iExternalDocuments[1]["theName"]]

        self.assertEqual(self.iExternalDocuments[0]["theName"], oec1.name())
        self.assertEqual(self.iExternalDocuments[0]["theVersion"],
                         oec1.version())
        self.assertEqual(self.iExternalDocuments[0]["thePublicationDate"],
                         oec1.date())
        self.assertEqual(self.iExternalDocuments[0]["theAuthors"],
                         oec1.authors())
        self.assertEqual(self.iExternalDocuments[0]["theDescription"],
                         oec1.description())
        self.assertEqual(self.iExternalDocuments[1]["theName"], oec2.name())
        self.assertEqual(self.iExternalDocuments[1]["theVersion"],
                         oec2.version())
        self.assertEqual(self.iExternalDocuments[1]["thePublicationDate"],
                         oec2.date())
        self.assertEqual(self.iExternalDocuments[1]["theAuthors"],
                         oec2.authors())
        self.assertEqual(self.iExternalDocuments[1]["theDescription"],
                         oec2.description())

        idr1 = DocumentReferenceParameters(
            self.iDocumentReferences[0]["theName"],
            self.iDocumentReferences[0]["theDocName"],
            self.iDocumentReferences[0]["theContributor"],
            self.iDocumentReferences[0]["theExcerpt"])
        idr2 = DocumentReferenceParameters(
            self.iDocumentReferences[1]["theName"],
            self.iDocumentReferences[1]["theDocName"],
            self.iDocumentReferences[1]["theContributor"],
            self.iDocumentReferences[1]["theExcerpt"])
        idr3 = DocumentReferenceParameters(
            self.iDocumentReferences[2]["theName"],
            self.iDocumentReferences[2]["theDocName"],
            self.iDocumentReferences[2]["theContributor"],
            self.iDocumentReferences[2]["theExcerpt"])

        b.dbProxy.addDocumentReference(idr1)
        b.dbProxy.addDocumentReference(idr2)
        b.dbProxy.addDocumentReference(idr3)

        odrs = b.dbProxy.getDocumentReferences()
        odr1 = odrs[self.iDocumentReferences[0]["theName"]]
        odr2 = odrs[self.iDocumentReferences[1]["theName"]]
        odr3 = odrs[self.iDocumentReferences[2]["theName"]]

        self.assertEqual(self.iDocumentReferences[0]["theName"], odr1.name())
        self.assertEqual(self.iDocumentReferences[0]["theDocName"],
                         odr1.document())
        self.assertEqual(self.iDocumentReferences[0]["theContributor"],
                         odr1.contributor())
        self.assertEqual(self.iDocumentReferences[0]["theExcerpt"],
                         odr1.excerpt())
        self.assertEqual(self.iDocumentReferences[1]["theName"], odr2.name())
        self.assertEqual(self.iDocumentReferences[1]["theDocName"],
                         odr2.document())
        self.assertEqual(self.iDocumentReferences[1]["theContributor"],
                         odr2.contributor())
        self.assertEqual(self.iDocumentReferences[1]["theExcerpt"],
                         odr2.excerpt())
        self.assertEqual(self.iDocumentReferences[2]["theName"], odr3.name())
        self.assertEqual(self.iDocumentReferences[2]["theDocName"],
                         odr3.document())
        self.assertEqual(self.iDocumentReferences[2]["theContributor"],
                         odr3.contributor())
        self.assertEqual(self.iDocumentReferences[2]["theExcerpt"],
                         odr3.excerpt())

        ipc1 = PersonaCharacteristicParameters(
            self.iPersonaCharacteristics[0]["thePersonaName"],
            self.iPersonaCharacteristics[0]["theModQual"],
            self.iPersonaCharacteristics[0]["theVariable"],
            self.iPersonaCharacteristics[0]["theCharacteristic"],
            [(self.iPersonaCharacteristics[0]["ground"], '', 'document')],
            [(self.iPersonaCharacteristics[0]["warrant"], '', 'document')], [],
            [(self.iPersonaCharacteristics[0]["rebuttal"], '', 'document')])

        b.dbProxy.addPersonaCharacteristic(ipc1)
        opcs = b.dbProxy.getPersonaCharacteristics()
        opc1 = opcs[self.iPersonaCharacteristics[0]["thePersonaName"] + '/' +
                    self.iPersonaCharacteristics[0]["theVariable"] + '/' +
                    self.iPersonaCharacteristics[0]["theCharacteristic"]]

        self.assertEqual(self.iPersonaCharacteristics[0]["thePersonaName"],
                         opc1.persona())
        self.assertEqual(self.iPersonaCharacteristics[0]["theModQual"],
                         opc1.qualifier())
        self.assertEqual(self.iPersonaCharacteristics[0]["theVariable"],
                         opc1.behaviouralVariable())
        self.assertEqual(self.iPersonaCharacteristics[0]["theCharacteristic"],
                         opc1.characteristic())
        self.assertEqual(self.iPersonaCharacteristics[0]["ground"],
                         opc1.grounds()[0][0])
        self.assertEqual(self.iPersonaCharacteristics[0]["warrant"],
                         opc1.warrant()[0][0])
        self.assertEqual(self.iPersonaCharacteristics[0]["rebuttal"],
                         opc1.rebuttal()[0][0])

        cGrounds = b.dbProxy.getGrounds(opc1.grounds()[0][0])
        self.assertEqual(opc1.grounds()[0][1], cGrounds[2])

        cWarrant = b.dbProxy.getWarrant(opc1.warrant()[0][0])
        self.assertEqual(opc1.warrant()[0][1], cWarrant[2])

        cRebuttal = b.dbProxy.getRebuttal(opc1.rebuttal()[0][0])
        self.assertEqual(opc1.rebuttal()[0][1], cRebuttal[2])

        ipp2 = PersonaParameters(
            'Changed name', self.iPersonas[0]["theActivities"],
            self.iPersonas[0]["theAttitudes"],
            self.iPersonas[0]["theAptitudes"],
            self.iPersonas[0]["theMotivations"],
            self.iPersonas[0]["theSkills"], self.iPersonas[0]["theIntrinsic"],
            self.iPersonas[0]["theContextual"], "", "0",
            self.iPersonas[0]["thePersonaType"], [], [
                PersonaEnvironmentProperties(
                    self.iPersonas[0]["theEnvironmentProperties"][0]
                    ["theName"], (self.iPersonas[0]["theEnvironmentProperties"]
                                  [0]["theDirectFlag"] == "True"),
                    self.iPersonas[0]["theEnvironmentProperties"][0]
                    ["theNarrative"], self.iPersonas[0]
                    ["theEnvironmentProperties"][0]["theRole"])
            ], [])

        ipp2.setId(op.id())
        b.dbProxy.updatePersona(ipp2)
        theUpdatedPersonas = b.dbProxy.getPersonas()
        op2 = theUpdatedPersonas['Changed name']
        self.assertEqual(ipp2.name(), op2.name())

        b.dbProxy.deletePersonaCharacteristic(opc1.id())
        b.dbProxy.deleteDocumentReference(odr1.id())
        b.dbProxy.deleteDocumentReference(odr2.id())
        b.dbProxy.deleteDocumentReference(odr3.id())
        b.dbProxy.deleteExternalDocument(oec1.id())
        b.dbProxy.deleteExternalDocument(oec2.id())
        b.dbProxy.deletePersona(op.id())