Ejemplo n.º 1
0
 def startElement(self, name, attrs):
     self.currentElementName = name
     if name == 'characteristic_synopsis':
         self.theCharacteristic = attrs['characteristic']
         self.theSynopsis = attrs['synopsis']
         self.theDimensionName = attrs['dimension']
         self.theActorType = attrs['actor_type']
         self.theActor = attrs['actor']
         try:
             self.theInitialSatisfaction = attrs['satisfaction']
         except KeyError:
             pass
     elif name == 'reference_synopsis':
         self.theReference = attrs['reference']
         self.theSynopsis = attrs['synopsis']
         self.theDimensionName = attrs['dimension']
         self.theActorType = attrs['actor_type']
         self.theActor = attrs['actor']
         try:
             self.theInitialSatisfaction = attrs['satisfaction']
         except KeyError:
             pass
     elif name == 'system_goal':
         self.theSystemGoals.append(attrs['name'])
     elif name == 'step_synopsis':
         ucName = attrs['usecase']
         envName = attrs['environment']
         stepNo = attrs['step_no']
         synName = attrs['synopsis']
         aType = attrs['actor_type']
         aName = attrs['actor']
         self.theStepSynopses.append(
             (ucName, envName, stepNo, synName, aType, aName))
     elif name == 'reference_contribution':
         src = attrs['source']
         dest = attrs['destination']
         me = attrs['means_end']
         cont = attrs['contribution']
         self.theReferenceContributions.append(
             ReferenceContribution(src, dest, me, cont))
     elif name == 'usecase_contribution':
         ucName = attrs['usecase']
         refName = attrs['referent']
         me = attrs['means_end']
         cont = attrs['contribution']
         self.theUseCaseContributions.append(
             ReferenceContribution(ucName, refName, me, cont))
     elif name == 'task_contribution':
         taskName = attrs['task']
         envName = attrs['environment']
         refName = attrs['referent']
         cont = attrs['contribution']
         self.theTaskContributions.append(
             TaskContribution(taskName, refName, envName, cont))
Ejemplo n.º 2
0
    def from_json(self, request):
        json = request.get_json(silent=True)
        if json is False or json is None:
            self.close()
            raise MalformedJSONHTTPError(data=request.get_data())

        json_dict = json['object']
        check_required_keys(json_dict, UseCaseModel.required)
        json_dict[
            '__python_obj__'] = UseCase.__module__ + '.' + UseCase.__name__

        usecase_props = self.convert_props(
            fake_props=json_dict['theEnvironmentProperties'])
        json_dict['theEnvironmentProperties'] = []

        usecase = json_serialize(json_dict)
        usecase = json_deserialize(usecase)
        usecase.theEnvironmentProperties = usecase_props

        if not isinstance(usecase, UseCase):
            self.close()
            raise MalformedJSONHTTPError(data=request.get_data())
        else:
            frcs = json_dict['theReferenceContributions']
            refContribs = []
            for frc in frcs:
                refContribs.append(
                    ReferenceContribution(
                        usecase.theName, frc['theContributionTo'],
                        frc['theReferenceContribution']['theMeansEnd'],
                        frc['theReferenceContribution']['theContribution']))
            return usecase, refContribs
Ejemplo n.º 3
0
 def onUseCaseContribution(self,evt):
   ucName = self.GetItemText(self.theSelectedIdx)
   ucs  = self.dbProxy.getUseCaseContributions(ucName)
   ucKeys = ucs.keys()
   ucKeys.append('[New Contribution]')
   rsDlg = DimensionNameDialog(self,'usecase_contribution',ucKeys,'Select')
   if (rsDlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
     synName = rsDlg.dimensionName()
     rType = 'reference'
     if (synName != '[New Contribution]'):
       rc,rType = ucs[synName]
     else:
       rc = ReferenceContribution(ucName,'','','')
     dlg = UseCaseContributionDialog(self,rc,rType)
     if (dlg.ShowModal() == REFERENCECONTRIBUTION_BUTTONCOMMIT_ID):
       if (rc.meansEnd() == ''):
         self.dbProxy.addUseCaseContribution(dlg.parameters())
       else:
         self.dbProxy.updateUseCaseContribution(dlg.parameters())
Ejemplo n.º 4
0
 def onUseCaseContribution(self, evt):
     ucName = self.GetItemText(self.theSelectedIdx)
     ucs = self.dbProxy.getUseCaseContributions(ucName)
     ucKeys = ucs.keys()
     ucKeys.append("[New Contribution]")
     rsDlg = DimensionNameDialog(self, "usecase_contribution", ucKeys, "Select")
     if rsDlg.ShowModal() == DIMNAME_BUTTONACTION_ID:
         synName = rsDlg.dimensionName()
         rType = "reference"
         if synName != "[New Contribution]":
             rc, rType = ucs[synName]
         else:
             rc = ReferenceContribution(ucName, "", "", "")
         dlg = UseCaseContributionDialog(self, rc, rType)
         if dlg.ShowModal() == REFERENCECONTRIBUTION_BUTTONCOMMIT_ID:
             if rc.meansEnd() == "":
                 self.dbProxy.addUseCaseContribution(dlg.parameters())
             else:
                 self.dbProxy.updateUseCaseContribution(dlg.parameters())
Ejemplo n.º 5
0
 def onUseCaseContribution(self,evt):
   ucName = self.GetItemText(self.theSelectedIdx)
   ucs  = self.dbProxy.getUseCaseContributions(ucName)
   ucKeys = ucs.keys()
   ucKeys.append('[New Contribution]')
   rsDlg = DimensionNameDialog(self,'usecase_contribution',ucKeys,'Select')
   if (rsDlg.ShowModal() == DIMNAME_BUTTONACTION_ID):
     synName = rsDlg.dimensionName()
     rType = 'reference'
     if (synName != '[New Contribution]'):
       rc,rType = ucs[synName]
     else:
       rc = ReferenceContribution(ucName,'','','')
     dlg = UseCaseContributionDialog(self,rc,rType)
     if (dlg.ShowModal() == REFERENCECONTRIBUTION_BUTTONCOMMIT_ID):
       if (rc.meansEnd() == ''):
         self.dbProxy.addUseCaseContribution(dlg.parameters())
       else:
         self.dbProxy.updateUseCaseContribution(dlg.parameters())
Ejemplo n.º 6
0
 def startElement(self, name, attrs):
     self.currentElementName = name
     if name == 'characteristic_synopsis':
         cName = attrs['characteristic']
         synName = attrs['synopsis']
         dimName = attrs['dimension']
         aType = attrs['actor_type']
         aName = attrs['actor']
         self.theCharacteristicSynopses.append(
             ReferenceSynopsis(-1, cName, synName, dimName, aType, aName))
     elif name == 'reference_synopsis':
         refName = attrs['reference']
         synName = attrs['synopsis']
         dimName = attrs['dimension']
         aType = attrs['actor_type']
         aName = attrs['actor']
         self.theReferenceSynopses.append(
             ReferenceSynopsis(-1, refName, synName, dimName, aType, aName))
     elif name == 'step_synopsis':
         ucName = attrs['usecase']
         envName = attrs['environment']
         stepNo = attrs['step_no']
         synName = attrs['synopsis']
         aType = attrs['actor_type']
         aName = attrs['actor']
         self.theStepSynopses.append(
             (ucName, envName, stepNo, synName, aType, aName))
     elif name == 'reference_contribution':
         src = attrs['source']
         dest = attrs['destination']
         me = attrs['means_end']
         cont = attrs['contribution']
         self.theReferenceContributions.append(
             ReferenceContribution(src, dest, me, cont))
     elif name == 'usecase_contribution':
         ucName = attrs['usecase']
         refName = attrs['referent']
         me = attrs['means_end']
         cont = attrs['contribution']
         self.theUseCaseContributions.append(
             ReferenceContribution(ucName, refName, me, cont))
Ejemplo n.º 7
0
def importUserGoalWorkbook(wbFile,session_id):
  charSyns = []
  refSyns = []
  refConts = []

  wb = load_workbook(filename = wbFile,data_only=True)
  ugSheet = wb.worksheets[0]
  for row in ugSheet.iter_rows(min_row=2):
    refName = row[0].value
    refDesc = row[1].value
    pName = row[2].value
    pdRef = row[3].value
    elType = row[4].value
    ugName = row[5].value
    if (ugName != '' and ugName != None and ugName != 0):
      initSat = row[6].value
      if (pdRef == 'persona'):
        charSyns.append(ReferenceSynopsis(-1,refName,ugName,elType,'persona',pName,'persona_characteristic',initSat))
      else:
        refSyns.append(ReferenceSynopsis(-1,refName,ugName,elType,'persona',pName,'document_reference',initSat))

  contSheet = wb.worksheets[1]
  for row in contSheet.iter_rows(min_row=2):
    srcName = row[0].value
    destName = row[1].value
    meName = row[2].value
    contName = row[3].value
    if (srcName != '' and srcName != None and srcName != 0 and destName != '' and destName != None and destName != 0):
      refConts.append(ReferenceContribution(srcName,destName,meName,contName))

  b = Borg()
  db_proxy = b.get_dbproxy(session_id)
  for cs in charSyns:
    db_proxy.addCharacteristicSynopsis(cs)
  for rs in refSyns:
    db_proxy.addReferenceSynopsis(rs)
  db_proxy.conn.commit()
  for rc in refConts:
    db_proxy.addReferenceContribution(rc)

  msgStr = 'Imported ' + str(len(charSyns)) + ' characteristic synopses, ' + str(len(refSyns)) + ' reference synopses, and ' + str(len(refConts)) + ' reference contributions.'
  return msgStr
Ejemplo n.º 8
0
  def testAddContribution(self):
    irs = ReferenceSynopsis(-1,self.rsData['theReference'],self.rsData['theSynopsis'],self.rsData['theDimension'],self.rsData['theActorType'],self.rsData['theActor'])
    b = Borg()
    b.dbProxy.addReferenceSynopsis(irs)
    ics = ReferenceSynopsis(-1,self.csData['theReference'],self.csData['theSynopsis'],self.csData['theDimension'],self.csData['theActorType'],self.csData['theActor'])
    b.dbProxy.addCharacteristicSynopsis(ics)

    irc = ReferenceContribution(self.rcData['theSource'],self.rcData['theDestination'],self.rcData['theMeansEnd'],self.rcData['theContribution'])
    b.dbProxy.addReferenceContribution(irc)

    orc = b.dbProxy.getReferenceContribution(self.csData['theReference'],self.rsData['theReference'])
    self.assertEqual(orc.source(), irc.source())
    self.assertEqual(orc.destination(), irc.destination())
    self.assertEqual(orc.meansEnd(), irc.meansEnd())
    self.assertEqual(orc.contribution(), irc.contribution())
Ejemplo n.º 9
0
 def parameters(self):
   parameters = ReferenceContribution(self.theSource,self.theDestination,self.theMeansEnd,self.theContribution)
   return parameters
Ejemplo n.º 10
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