Esempio n. 1
0
 def get_usecases(self, constraint_id=-1, simplify=True):
     """
 :rtype: dict[str,UseCase]
 :return
 :raise ARMHTTPError:
 """
     try:
         usecases = self.db_proxy.getUseCases(constraint_id)
         if simplify:
             for key, value in list(usecases.items()):
                 uc = self.simplify(value)
                 uc.theReferenceContributions = []
                 contribs = self.db_proxy.getUseCaseContributions(uc.name())
                 for rsName in contribs:
                     rrc, rsType = contribs[rsName]
                     frc = CharacteristicReferenceContribution(
                         rrc.meansEnd(), rrc.contribution())
                     uc.theReferenceContributions.append(
                         UseCaseContributionModel(rsName, frc))
                 usecases[key] = uc
         return usecases
     except DatabaseProxyException as ex:
         self.close()
         raise ARMHTTPError(ex)
     except ARMException as ex:
         self.close()
         raise ARMHTTPError(ex)
Esempio n. 2
0
    def get_usecase_by_name(self, name, simplify=True):
        """
    :rtype: UseCase
    :raise ObjectNotFoundHTTPError:
    """
        try:
            ucId = self.db_proxy.getDimensionId(name, 'usecase')
            ucs = self.db_proxy.getUseCases(ucId)
        except DatabaseProxyException as ex:
            self.close()
            raise ARMHTTPError(ex)
        except ARMException as ex:
            self.close()
            raise ARMHTTPError(ex)

        if ucs is not None:
            found_uc = ucs.get(name)

        if found_uc is None:
            self.close()
            raise ObjectNotFoundHTTPError(obj='The provided usecase name')

        found_uc = self.simplify(found_uc)
        found_uc.theReferenceContributions = []
        contribs = self.db_proxy.getUseCaseContributions(found_uc.name())
        for rsName in contribs:
            rrc, rsType = contribs[rsName]
            frc = CharacteristicReferenceContribution(rrc.meansEnd(),
                                                      rrc.contribution())
            found_uc.theReferenceContributions.append(
                UseCaseContributionModel(rsName, frc))
        return found_uc
Esempio n. 3
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