Beispiel #1
0
        def assemble(self,row):
                if row:
                        article=Article()
                        article.id=row[0]
                        article.title=row[1]
                        article.originId=row[2]
                        article.providerId=row[3]
                        article.isEnglish=row[4]
                        article.content=row[5]
                        article.subType=row[6]
                        article.type=row[7]
                        article.allType=row[8]
                        article.ipnewsCategory=row[9]
			article.proDate=row[10]
                        if article.subType == 1:
                                article.contentType=Article.CONTENT_TYPE_NEWLAW#每日快讯(新法快报)
                        elif article.subType==3 and article.ipnewsCategory==1:
                                article.contentType=Article.CONTENT_TYPE_HOTNEWS#评论文章
                        elif article.subType==4:
                                article.contentType=Article.CONTENT_TYPE_PRACTICAL#实用资料
                        elif article.subType==6:
                                article.contentType=Article.CONTENT_TYPE_ELEARNING#在线培训
                        elif article.subType==7:
                                article.contentType=Article.CONTENT_TYPE_TPOVERVIEW
                        else:
                                article.contentType=Article.CONTENT_TYPE_OTHERS
                        return article
	def generatorAssemble(self,row):
		if row:
			article=Article()
			article.id=row[0]
			article.title=row[1]
			article.originId=row[2]
			article.providerId=row[3]
			article.isEnglish=row[4]
			article.content=row[5]
			article.subType=row[6]
			article.type=row[7]
			article.allType=row[8]
			article.ipnewsCategory=row[9]
			article.proDate=row[10]
			if article.subType == 1:
				article.contentType=Article.CONTENT_TYPE_NEWLAW#每日快讯(新法快报)
				yield article
			elif article.subType==3:
				article.contentType=Article.CONTENT_TYPE_HOTNEWS#评论文章
				yield article
			elif article.subType==4:
				article.contentType=Article.CONTENT_TYPE_PRACTICAL#实用资料
				yield article
			elif article.subType==6:
				article.contentType=Article.CONTENT_TYPE_ELEARNING#在线培训
				yield article
			elif article.subType==7:
				for topicId in article.allType.split(','):
					article.contentType=self.overviewType[topicId]
					yield article
			else:
				article.contentType=Article.CONTENT_TYPE_OTHERS
				yield article
Beispiel #3
0
 def getByOrigin(self, originId, providerId, isEnglish):
     if originId and providerId and isEnglish:
         sql = (
             "select id,title,content,origin_id,provider_id,isEnglish,ex_expert_question_id,update_time from ex_expert_answers where origin_id='%s' and provider_id=%s and isEnglish='%s';"
             % (originId, providerId, isEnglish)
         )
         try:
             self.cursor_stg.execute(sql)
             row = self.cursor_stg.fetchone()
             if row:
                 article = Article()
                 article.id = row[0]
                 article.title = row[1]
                 article.content = row[2]
                 article.originId = row[3]
                 article.providerId = row[4]
                 article.isEnglish = row[5]
                 article.questionId = row[6]
                 article.proDate = row[7]
                 article.contentType = Article.CONTENT_TYPE_MODULEQA
                 return article
             else:
                 raise Exception(
                     "No question answer with origin id:%s,provider id:%s,isEnglish:%s was found"
                     % (originId, providerId, isEnglish)
                 )
         except Exception, e:
             self.log.error(e)
             self.log.error(sql)
	def getByOrigin(self,originId,providerId,isEnglish):
		if originId and providerId and isEnglish:
			sql="""select 	profNewsletter_Ext.id as id,
					profNewsletter_Ext.title as title,
					profNewsletter.editedAt,
					profNewsletter_Ext.content,
					profNewsletter_Ext.origin_id,
					profNewsletter_Ext.provider_id,
					profNewsletter_Ext.isEnglish, 
					profNewsletter_Ext.fk_profNewsletter_id,
					profNewsletter_Ext.createdExtAt 
				from (profNewsletter_Ext INNER JOIN profNewsletter ON profNewsletter_Ext.fk_profNewsletter_id = profNewsletter.id) 
				where profNewsletter_Ext.origin_id ='%s' and profNewsletter_Ext.provider_id=%s and profNewsletter_Ext.isEnglish='%s';
				""" % (originId,providerId,isEnglish)
			try:
				self.cursor_stg.execute(sql)
				row=self.cursor_stg.fetchone()
				if row:
					article=Article()
					article.id=row[0]
					article.title=row[1]
					article.editedAt=row[2]
					article.content=row[3]
					article.originId=row[4]
					article.providerId=row[5]
					article.isEnglish=row[6]
					article.fkProfNewsletterId=row[7]
					article.proDate=row[8]
					article.contentType=Article.CONTENT_TYPE_NEWSLETTER
					return article
				else:
					raise Exception("No professional newsletter with origin_id:%s,provider_id:%s,isEnglish:%s found!" %(originId,providerId,isEnglish))
			except Exception,e:
				self.log.error(e)
				self.log.error(sql)
	def getAll(self):
		sql="""select 	profNewsletter_Ext.id as id,
			      	profNewsletter_Ext.title as title,
			      	profNewsletter.editedAt,
			      	profNewsletter_Ext.content,
				profNewsletter_Ext.origin_id,
				profNewsletter_Ext.provider_id,
				profNewsletter_Ext.isEnglish, 
				profNewsletter_Ext.fk_profNewsletter_id 
			from (profNewsletter_Ext INNER JOIN profNewsletter ON profNewsletter_Ext.fk_profNewsletter_id = profNewsletter.id) 
			where isDisplay=1 and isEnglish='Y';
			"""
		try:
			self.cursor_stg.execute(sql)
			for row in self.cursor_stg.fetchall():
				article=Article()
				article.id=row[0]
				article.title=row[1]
				article.editedAt=row[2]
				article.content=row[3]
				article.originId=row[4]
				article.providerId=row[5]
				article.isEnglish=row[6]
				article.fkProfNewsletterId=row[7]
				article.contentType=Article.CONTENT_TYPE_NEWSLETTER
				yield article
		except Exception,e:
			self.log.error(e)
			self.log.error(sql)
	def assemble(self,row):
		if row:
			article=Article()
			article.id=row[0]
			article.originId=row[1]
			article.providerId=row[2]
			article.isEnglish=row[3]
			article.content=row[4]
			article.proDate=row[5]
			article.contentType=Article.CONTENT_TYPE_OVERVIEW_SUMMARY
			return article
Beispiel #7
0
	def getAll(self):
		sql="select content,target_id,content_type,backup_time,origin_id,provider_id,isEnglish from %s" % self.tableName
		try:
			self.cursor_stg.execute(sql)
			for row in self.cursor_stg.fetchall():
				article=Article()
				article.content=row[0]
				article.id=row[1]
				article.contentType=row[2]
				article.originId=row[4]
				article.providerId=row[5]
				article.isEnglish=row[6]
				yield article 
		except Exception,e:
			self.log.error(e)
Beispiel #8
0
	def getAll(self):
		try:
			sql="select announceid,boardid,topic,body,origin_id,provider_id,isEnglish from listboard where display=1 and isEnglish='Y';"
			self.cursor_stg.execute(sql)
			for row in self.cursor_stg.fetchall():
				article=Article()
				article.id=row[0]
				article.boardid=row[1]
				article.title=row[2]
				article.content=row[3]
				article.originId=row[4]
				article.providerId=row[5]
				article.isEnglish=row[6]
				article.contentType=Article.CONTENT_TYPE_LNCQA
				yield article
		except Exception,e:
			self.log.error(e)
			self.log.error(sql)
Beispiel #9
0
	def findByKeywordId(self,keywordId=''):
		"""
		查询所有与指定关键词Id相关的文章
		"""
		try:
			self.cursor_hyperlink.execute("select article_id,content_type,origin_id,provider_id,isEnglish,target_id,action_type,status,keyword_id from "+ArticleDAO.tableName+" where keyword_id='%s'" % keywordId)
			articleList=[]
			for row in self.cursor_hyperlink.fetchall():
				article=Article()
				article.contentType=row[1]
				article.originId=row[2]
				article.providerId=row[3]
				article.isEnglish=row[4]
				article.id=row[5]
				articleList.append(article)
			return articleList
		except Exception,e:
			print e
			self.log.error(e)
Beispiel #10
0
    def getAll(self):
        sql = """
			select id,title,content,origin_id,provider_id,isEnglish,ex_expert_question_id from ex_expert_answers where isEnglish='Y' and is_display=1
		"""
        try:
            self.cursor_stg.execute(sql)
            for row in self.cursor_stg.fetchall():
                article = Article()
                article.id = row[0]
                article.title = row[1]
                article.content = row[2]
                article.originId = row[3]
                article.providerId = row[4]
                article.isEnglish = row[5]
                article.questionId = row[6]
                article.contentType = Article.CONTENT_TYPE_MODULEQA
                yield article
        except Exception, e:
            self.log.error(e)
            self.log.error(sql)
            self.log.error("Exception occured in getAll() of ModuleQADAO.py")
Beispiel #11
0
	def getByOrigin(self,originId,providerId,isEnglish):
		if originId and providerId and isEnglish:
			sql="select announceid,boardid,topic,body,origin_id,provider_id,isEnglish,dateandtime from listboard where origin_id='%s' and provider_id=%s and isEnglish='%s';" % (originId,providerId,isEnglish)
			try:
				self.cursor_stg.execute(sql)
				row=self.cursor_stg.fetchone()
				if row:
					article=Article()	
					article.id=row[0]
					article.boardid=row[1]
					article.title=row[2]
					article.content=row[3]
					article.originId=row[4]
					article.providerId=row[5]
					article.isEnglish=row[6]
					article.proDate=row[7]
					article.contentType=Article.CONTENT_TYPE_LNCQA
					return article
				else:
					raise Exception("No LNC Q&A with origin_id:%s,provider_id:%s,isEnglish:%s found!" %(originId,providerId,isEnglish))
			except Exception,e:
				self.log.error(e)
				self.log.error(sql)