Example #1
0
    def get_persona_characteristics(self, constraint_id=-1, simplify=True):
        """
    :rtype: dict[str,PersonaCharacteristic]
    :return
    :raise ARMHTTPError:
    """
        try:
            pcs = self.db_proxy.getPersonaCharacteristics(constraint_id)
        except DatabaseProxyException as ex:
            self.close()
            raise ARMHTTPError(ex)
        except ARMException as ex:
            self.close()
            raise ARMHTTPError(ex)

        if simplify:
            for key, value in list(pcs.items()):
                pcs[key] = self.convert_pcrs(real_pc=value)
                pName, bvName, pcDesc = key.split('/')
                cs = self.db_proxy.getCharacteristicSynopsis(pcDesc)
                crs = CharacteristicReferenceSynopsis(cs.synopsis(),
                                                      cs.dimension(),
                                                      cs.actorType(),
                                                      cs.actor())
                pcs[key].theCharacteristicSynopsis = crs
        return pcs
Example #2
0
    def convert_pcrs(self, real_pc=None, fake_pc=None):
        if real_pc is not None:
            assert isinstance(real_pc, PersonaCharacteristic)
            pcr_list = []
            if len(real_pc.theGrounds) > 0:
                for real_pcr in real_pc.theGrounds:
                    rs = self.db_proxy.getReferenceSynopsis(real_pcr[0])
                    crs = CharacteristicReferenceSynopsis(
                        rs.synopsis(), rs.dimension(), rs.actorType(),
                        rs.actor())
                    rc = self.db_proxy.getReferenceContribution(
                        real_pc.theName, rs.reference())
                    frc = CharacteristicReferenceContribution(
                        rc.meansEnd(), rc.contribution())
                    pcr_list.append(
                        CharacteristicReference(real_pcr[0], 'grounds',
                                                real_pcr[1], real_pcr[2], crs,
                                                frc))
                real_pc.theGrounds = pcr_list
            pcr_list = []
            if len(real_pc.theWarrant) > 0:
                for real_pcr in real_pc.theWarrant:
                    rs = self.db_proxy.getReferenceSynopsis(real_pcr[0])
                    crs = CharacteristicReferenceSynopsis(
                        rs.synopsis(), rs.dimension(), rs.actorType(),
                        rs.actor())
                    rc = self.db_proxy.getReferenceContribution(
                        real_pc.theName, rs.reference())
                    frc = CharacteristicReferenceContribution(
                        rc.meansEnd(), rc.contribution())
                    pcr_list.append(
                        CharacteristicReference(real_pcr[0], 'warrant',
                                                real_pcr[1], real_pcr[2], crs,
                                                frc))
                real_pc.theWarrant = pcr_list
            pcr_list = []
            if len(real_pc.theRebuttal) > 0:
                for real_pcr in real_pc.theRebuttal:
                    rs = self.db_proxy.getReferenceSynopsis(real_pcr[0])
                    crs = CharacteristicReferenceSynopsis(
                        rs.synopsis(), rs.dimension(), rs.actorType(),
                        rs.actor())
                    rc = self.db_proxy.getReferenceContribution(
                        real_pc.theName, rs.reference())
                    frc = CharacteristicReferenceContribution(
                        rc.meansEnd(), rc.contribution())
                    pcr_list.append(
                        CharacteristicReference(real_pcr[0], 'rebuttal',
                                                real_pcr[1], real_pcr[2], crs,
                                                frc))
                real_pc.theRebuttal = pcr_list
            return real_pc
        elif fake_pc is not None:
            pcr_list = []
            ps = None
            fcs = fake_pc.theCharacteristicSynopsis
            if (fcs['theSynopsis'] != ""):
                ps = ReferenceSynopsis(-1, fake_pc.theName, fcs['theSynopsis'],
                                       fcs['theDimension'],
                                       fcs['theActorType'], fcs['theActor'])
            rss = []
            rcs = []

            if len(fake_pc.theGrounds) > 0:
                for pcr in fake_pc.theGrounds:
                    pcr_list.append((pcr['theReferenceName'],
                                     pcr['theReferenceDescription'],
                                     pcr['theDimensionName']))
                    if (ps != None):
                        frs = pcr['theReferenceSynopsis']
                        rss.append(
                            ReferenceSynopsis(-1, pcr['theReferenceName'],
                                              frs['theSynopsis'],
                                              frs['theDimension'],
                                              frs['theActorType'],
                                              frs['theActor']))
                        frc = pcr['theReferenceContribution']
                        rcs.append(
                            ReferenceContribution(frs['theSynopsis'],
                                                  fcs['theSynopsis'],
                                                  frc['theMeansEnd'],
                                                  frc['theContribution']))
                fake_pc.theGrounds = pcr_list
            if len(fake_pc.theWarrant) > 0:
                pcr_list = []
                for pcr in fake_pc.theWarrant:
                    pcr_list.append((pcr['theReferenceName'],
                                     pcr['theReferenceDescription'],
                                     pcr['theDimensionName']))
                    if (ps != None):
                        frs = pcr['theReferenceSynopsis']
                        rss.append(
                            ReferenceSynopsis(-1, pcr['theReferenceName'],
                                              frs['theSynopsis'],
                                              frs['theDimension'],
                                              frs['theActorType'],
                                              frs['theActor']))
                        frc = pcr['theReferenceContribution']
                        rcs.append(
                            ReferenceContribution(frs['theSynopsis'],
                                                  fcs['theSynopsis'],
                                                  frc['theMeansEnd'],
                                                  frc['theContribution']))
                fake_pc.theWarrant = pcr_list
            if len(fake_pc.theRebuttal) > 0:
                pcr_list = []
                for pcr in fake_pc.theRebuttal:
                    pcr_list.append((pcr['theReferenceName'],
                                     pcr['theReferenceDescription'],
                                     pcr['theDimensionName']))
                    if (ps != None):
                        frs = pcr['theReferenceSynopsis']
                        rss.append(
                            ReferenceSynopsis(-1, pcr['theReferenceName'],
                                              frs['theSynopsis'],
                                              frs['theDimension'],
                                              frs['theActorType'],
                                              frs['theActor']))
                        frc = pcr['theReferenceContribution']
                        rcs.append(
                            ReferenceContribution(frs['theSynopsis'],
                                                  fcs['theSynopsis'],
                                                  frc['theMeansEnd'],
                                                  frc['theContribution']))
                fake_pc.theRebuttal = pcr_list
            return fake_pc, ps, rss, rcs