def _validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor = ModelDataBase.ksValidateFor_Other): dErrors = SchedGroupData._validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor); # # Fetch the extended build source bits. # if self.ksParam_idBuildSrc not in dErrors: if self.idBuildSrc in self.getAttributeParamNullValues('idBuildSrc') \ or self.idBuildSrc is None: self.oBuildSrc = None; else: try: self.oBuildSrc = BuildSourceData().initFromDbWithId(oDb, self.idBuildSrc); except Exception as oXcpt: self.oBuildSrc = BuildSourceData(); dErrors[self.ksParam_idBuildSrc] = str(oXcpt); if self.ksParam_idBuildSrcTestSuite not in dErrors: if self.idBuildSrcTestSuite in self.getAttributeParamNullValues('idBuildSrcTestSuite') \ or self.idBuildSrcTestSuite is None: self.oBuildSrcValidationKit = None; else: try: self.oBuildSrcValidationKit = BuildSourceData().initFromDbWithId(oDb, self.idBuildSrcTestSuite); except Exception as oXcpt: self.oBuildSrcValidationKit = BuildSourceData(); dErrors[self.ksParam_idBuildSrcTestSuite] = str(oXcpt); return dErrors;
def _initExtraMembersFromDb(self, oDb, tsNow = None, sPeriodBack = None): """ Worker shared by the initFromDb* methods. Returns self. Raises exception if no row or database error. """ # # It all upfront so the object has some kind of consistency if anything # below raises exceptions. # self.oBuildSrc = None; self.oBuildSrcValidationKit = None; self.aoTestBoxes = []; self.aoMembers = []; # # Build source. # if self.idBuildSrc: self.oBuildSrc = BuildSourceData().initFromDbWithId(oDb, self.idBuildSrc, tsNow, sPeriodBack); if self.idBuildSrcTestSuite: self.oBuildSrcValidationKit = BuildSourceData().initFromDbWithId(oDb, self.idBuildSrcTestSuite, tsNow, sPeriodBack); # # Test Boxes. # oDb.execute('SELECT TestBoxesWithStrings.*\n' 'FROM TestBoxesWithStrings,\n' ' TestBoxesInSchedGroups\n' 'WHERE TestBoxesInSchedGroups.idSchedGroup = %s\n' + self.formatSimpleNowAndPeriod(oDb, tsNow, sPeriodBack, sTablePrefix = 'TestBoxesInSchedGroups.') + ' AND TestBoxesWithStrings.idTestBox = TestBoxesInSchedGroups.idTestBox\n' + self.formatSimpleNowAndPeriod(oDb, tsNow, sPeriodBack, sTablePrefix = 'TestBoxesWithStrings.') + 'ORDER BY TestBoxesWithStrings.sName, TestBoxesWithStrings.idTestBox\n' , (self.idSchedGroup,)); for aoRow in oDb.fetchAll(): self.aoTestBoxes.append(TestBoxData().initFromDbRow(aoRow)); # # Test groups. # oDb.execute('SELECT SchedGroupMembers.*, TestGroups.*\n' 'FROM SchedGroupMembers\n' 'LEFT OUTER JOIN TestGroups ON (SchedGroupMembers.idTestGroup = TestGroups.idTestGroup)\n' 'WHERE SchedGroupMembers.idSchedGroup = %s\n' + self.formatSimpleNowAndPeriod(oDb, tsNow, sPeriodBack, sTablePrefix = 'SchedGroupMembers.') + self.formatSimpleNowAndPeriod(oDb, tsNow, sPeriodBack, sTablePrefix = 'TestGroups.') + 'ORDER BY SchedGroupMembers.idTestGroupPreReq, SchedGroupMembers.idTestGroup\n' , (self.idSchedGroup,)); for aoRow in oDb.fetchAll(): self.aoMembers.append(SchedGroupMemberDataEx().initFromDbRow(aoRow)); return self;
def _initExtraMembersFromDb(self, oDb, tsNow=None, sPeriodBack=None): """ Worker shared by the initFromDb* methods. Returns self. Raises exception if no row or database error. """ # # It all upfront so the object has some kind of consistency if anything # below raises exceptions. # self.oBuildSrc = None self.oBuildSrcValidationKit = None self.aoTestBoxes = [] self.aoMembers = [] # # Build source. # if self.idBuildSrc: self.oBuildSrc = BuildSourceData().initFromDbWithId( oDb, self.idBuildSrc, tsNow, sPeriodBack) if self.idBuildSrcTestSuite: self.oBuildSrcValidationKit = BuildSourceData().initFromDbWithId( oDb, self.idBuildSrcTestSuite, tsNow, sPeriodBack) # # Test Boxes. # ## @todo sPeriodBack! if tsNow is None: oDb.execute( 'SELECT *\n' 'FROM TestBoxes\n' 'WHERE TestBoxes.idSchedGroup = %s\n' ' AND TestBoxes.tsExpire = \'infinity\'::TIMESTAMP\n' 'ORDER BY TestBoxes.sName, TestBoxes.idTestBox\n', (self.idSchedGroup, )) else: oDb.execute( 'SELECT *\n' 'FROM TestBoxes\n' 'WHERE TestBoxes.idSchedGroup = %s\n' ' AND TestBoxes.tsExpire > %s\n' ' AND TestBoxes.tsEffective <= %s\n' 'ORDER BY TestBoxes.sName, TestBoxes.idTestBox\n', (self.idSchedGroup, tsNow, tsNow, tsNow, tsNow)) for aoRow in oDb.fetchAll(): self.aoTestBoxes.append(TestBoxData().initFromDbRow(aoRow)) # # Test groups. # ## @todo sPeriodBack! if tsNow is None: oDb.execute( 'SELECT SchedGroupMembers.*, TestGroups.*\n' 'FROM SchedGroupMembers\n' 'LEFT OUTER JOIN TestGroups ON (SchedGroupMembers.idTestGroup = TestGroups.idTestGroup)\n' 'WHERE SchedGroupMembers.idSchedGroup = %s\n' ' AND SchedGroupMembers.tsExpire = \'infinity\'::TIMESTAMP\n' ' AND TestGroups.tsExpire = \'infinity\'::TIMESTAMP\n' 'ORDER BY SchedGroupMembers.idTestGroupPreReq, SchedGroupMembers.idTestGroup\n', (self.idSchedGroup, )) else: oDb.execute( 'SELECT SchedGroupMembers.*, TestGroups.*\n' 'FROM SchedGroupMembers\n' 'LEFT OUTER JOIN TestGroups ON (SchedGroupMembers.idTestGroup = TestGroups.idTestGroup)\n' 'WHERE SchedGroupMembers.idSchedGroup = %s\n' ' AND SchedGroupMembers.tsExpire > %s\n' ' AND SchedGroupMembers.tsEffective <= %s\n' ' AND TestGroups.tsExpire > %s\n' ' AND TestGroups.tsEffective <= %s\n' 'ORDER BY SchedGroupMembers.idTestGroupPreReq, SchedGroupMembers.idTestGroup\n', (self.idSchedGroup, tsNow, tsNow, tsNow, tsNow)) for aoRow in oDb.fetchAll(): self.aoMembers.append( SchedGroupMemberDataEx().initFromDbRow(aoRow)) return self