def makeIndexStage(self, indexRecord, _indexassay_key, indexassay, _stageid_key, stageid): stage = GxdIndexStage() stage._indexassay_key = _indexassay_key stage.indexassay = indexassay stage._stageid_key = _stageid_key stage.stageid = stageid stage._index_key = indexRecord._index_key indexRecord.indexstages.append(stage) return stage
def update(self, key, indexrecord_domain, current_user): """ Update GxdIndexRecord with and argument object """ gxdindex_record = self.gxdindex_dao.get_by_key(key) if not gxdindex_record: raise NotFoundError("No GxdIndexRecord for _index_key=%d" % key) self.validate_input(indexrecord_domain) # set GxdIndexRecord values gxdindex_record._refs_key = indexrecord_domain._refs_key gxdindex_record._marker_key = indexrecord_domain._marker_key gxdindex_record._priority_key = indexrecord_domain._priority_key gxdindex_record._conditionalmutants_key = indexrecord_domain._conditionalmutants_key gxdindex_record.comments = indexrecord_domain.comments gxdindex_record._modifiedby_key = current_user._user_key # TODO(kstone): get SQLAlchemy to do this automatically gxdindex_record.modification_date = datetime.now() gxdindex_record.indexstages = [] for indexstage_input in indexrecord_domain.indexstages: indexstage = GxdIndexStage() indexstage._index_key = gxdindex_record._index_key indexstage._indexassay_key = indexstage_input._indexassay_key indexstage._stageid_key = indexstage_input._stageid_key indexstage._createdby_key = current_user._user_key indexstage._modifiedby_key = current_user._user_key gxdindex_record.indexstages.append(indexstage) self.gxdindex_dao.update(gxdindex_record) return convert_models(gxdindex_record, IndexRecordDomain)
def create(self, indexrecord_domain, current_user): """ Create GxdIndexRecord with an argument object """ self.validate_input(indexrecord_domain) gxdindex_record = GxdIndexRecord() # get the next primary key gxdindex_record._index_key = self.gxdindex_dao.get_next_key() # set GxdIndexRecord values gxdindex_record._refs_key = indexrecord_domain._refs_key gxdindex_record._marker_key = indexrecord_domain._marker_key gxdindex_record._priority_key = indexrecord_domain._priority_key gxdindex_record._conditionalmutants_key = indexrecord_domain._conditionalmutants_key gxdindex_record.comments = indexrecord_domain.comments gxdindex_record._createdby_key = current_user._user_key gxdindex_record._modifiedby_key = current_user._user_key if indexrecord_domain.indexstages: # add the GxdIndexStage(s) gxdindex_record.indexstages = [] for indexstage_input in indexrecord_domain.indexstages: indexstage = GxdIndexStage() indexstage._index_key = gxdindex_record._index_key indexstage._indexassay_key = indexstage_input._indexassay_key indexstage._stageid_key = indexstage_input._stageid_key indexstage._createdby_key = current_user._user_key indexstage._modifiedby_key = current_user._user_key gxdindex_record.indexstages.append(indexstage) self.gxdindex_dao.create(gxdindex_record) return convert_models(gxdindex_record, IndexRecordDomain)