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())
def endElement(self, name): if name == 'characteristic_synopsis': self.theCharacteristicSynopses.append( ReferenceSynopsis(-1, self.theCharacteristic, self.theSynopsis, self.theDimensionName, self.theActorType, self.theActor, 'persona_characteristic', self.theInitialSatisfaction, self.theSystemGoals)) self.resetSynopsisAttributes() elif name == 'reference_synopsis': self.theReferenceSynopses.append( ReferenceSynopsis(-1, self.theReference, self.theSynopsis, self.theDimensionName, self.theActorType, self.theActor, 'document_reference', self.theInitialSatisfaction, self.theSystemGoals)) self.resetSynopsisAttributes()
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
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))
def testAddSynopsis(self): irs = ReferenceSynopsis(-1,self.rsData['theReference'],self.rsData['theSynopsis'],self.rsData['theDimension'],self.rsData['theActorType'],self.rsData['theActor']) b = Borg() b.dbProxy.addCharacteristicSynopsis(irs) ors = b.dbProxy.getCharacteristicSynopsis(self.rsData['theReference']) self.assertEqual(irs.reference(), ors.reference()) self.assertEqual(irs.synopsis(), ors.synopsis()) self.assertEqual(irs.dimension(), ors.dimension()) self.assertEqual(irs.actorType(), ors.actorType()) self.assertEqual(irs.actor(), ors.actor())
def setUp(self): self.logger = logging.getLogger(__name__) self.new_ug = ReferenceSynopsis( rsId='-1', refName='Schedules life around TV shows', synName='Schedule activities', dimName='goal', aType='persona', aName='Justin', synDim='document_reference', initialSatisfaction='None', goals=[]) self.new_ug_dict = {'session_id': 'test', 'object': self.new_ug} self.existing_ug_name = 'Schedule diary with mobile'
def testAddSynopsis(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) ors = b.dbProxy.getReferenceSynopsis(self.rsData['theReference']) self.assertEqual(irs.reference(), ors.reference()) self.assertEqual(irs.synopsis(), ors.synopsis()) self.assertEqual(irs.dimension(), ors.dimension()) self.assertEqual(irs.actorType(), ors.actorType()) self.assertEqual(irs.actor(), ors.actor())
def __init__(self, parent, objt, charDetails=None): wx.Dialog.__init__(self, parent, -1, 'Edit Reference Synopsis', style=wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX, size=(475, 250)) self.theReference = objt.reference() self.theId = objt.id() self.theSynopsis = '' self.theDimension = '' self.theActorType = '' self.theActor = '' mainSizer = wx.BoxSizer(wx.VERTICAL) self.panel = ReferenceSynopsisPanel(self) mainSizer.Add(self.panel, 1, wx.EXPAND) self.SetSizer(mainSizer) wx.EVT_BUTTON(self, REFERENCESYNOPSIS_BUTTONCOMMIT_ID, self.onCommit) if (objt.id() == -1): self.theCommitVerb = 'Create' if (charDetails != None): self.SetLabel = 'Create Characteristic Synopsis' charType = charDetails[0] tpName = charDetails[1] if (charType == 'persona'): self.theActorType = 'persona' self.theActor = tpName else: self.SetLabel = 'Create Reference Synopsis' objt = ReferenceSynopsis(-1, self.theReference, self.theSynopsis, self.theDimension, self.theActorType, self.theActor) else: if (charDetails != None): self.SetLabel = 'Edit Characteristic Synopsis' self.theReference = objt.reference() self.theSynopsis = objt.synopsis() self.theDimension = objt.dimension() self.theActorType = objt.actorType() self.theActor = objt.actor() self.theCommitVerb = 'Edit' self.panel.load(objt, charDetails)
def __init__(self, parent, objt, charDetails=None): wx.Dialog.__init__( self, parent, -1, "Edit Reference Synopsis", style=wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX, size=(475, 250), ) self.theReference = objt.reference() self.theId = objt.id() self.theSynopsis = "" self.theDimension = "" self.theActorType = "" self.theActor = "" mainSizer = wx.BoxSizer(wx.VERTICAL) self.panel = ReferenceSynopsisPanel(self) mainSizer.Add(self.panel, 1, wx.EXPAND) self.SetSizer(mainSizer) wx.EVT_BUTTON(self, REFERENCESYNOPSIS_BUTTONCOMMIT_ID, self.onCommit) if objt.id() == -1: self.theCommitVerb = "Create" if charDetails != None: self.SetLabel = "Create Characteristic Synopsis" charType = charDetails[0] tpName = charDetails[1] if charType == "persona": self.theActorType = "persona" self.theActor = tpName else: self.SetLabel = "Create Reference Synopsis" objt = ReferenceSynopsis( -1, self.theReference, self.theSynopsis, self.theDimension, self.theActorType, self.theActor ) else: if charDetails != None: self.SetLabel = "Edit Characteristic Synopsis" self.theReference = objt.reference() self.theSynopsis = objt.synopsis() self.theDimension = objt.dimension() self.theActorType = objt.actorType() self.theActor = objt.actor() self.theCommitVerb = "Edit" self.panel.load(objt, charDetails)
def parameters(self): parameters = ReferenceSynopsis(self.theId, self.theReference, self.theSynopsis, self.theDimension, self.theActorType, self.theActor) return parameters
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