def processFarEditedbook(srcFarEditedbook, sesTarget):
    """
		Takes in a source FarEditedbook object from biopsmodels (mysql.bio_ps.FarEditedbooks)
		and determines if the object needs to be updated, inserted in the target
		database (mysql.bio_public.FarEditedbooks), or that nothing needs doing.
	
		Selecting Booleans from the databases.  Using conjunctions to make the exists()
		a boolean return from the query() method.  Bit more syntax but a sqlalchemy object
		returned will not be truthy/falsey.
		(http://techspot.zzzeek.org/2008/09/09/selecting-booleans/)
	"""
    true, false = literal(True), literal(False)

    farEditedbookList = [
        srcFarEditedbook.editedbookid, srcFarEditedbook.src_sys_id,
        srcFarEditedbook.evaluationid, srcFarEditedbook.authors,
        srcFarEditedbook.title, srcFarEditedbook.publisher,
        srcFarEditedbook.publicationstatuscode, srcFarEditedbook.pages,
        srcFarEditedbook.isbn, srcFarEditedbook.publicationyear,
        srcFarEditedbook.volumenumber, srcFarEditedbook.edition,
        srcFarEditedbook.publicationcity, srcFarEditedbook.webaddress,
        srcFarEditedbook.translated, srcFarEditedbook.additionalinfo,
        srcFarEditedbook.dtcreated, srcFarEditedbook.dtupdated,
        srcFarEditedbook.userlastmodified, srcFarEditedbook.ispublic,
        srcFarEditedbook.activityid, srcFarEditedbook.load_error,
        srcFarEditedbook.data_origin, srcFarEditedbook.created_ew_dttm,
        srcFarEditedbook.lastupd_dw_dttm, srcFarEditedbook.batch_sid
    ]

    srcHash = hashThisList(farEditedbookList)

    def farEditedbookExists():
        """
			determine the farEditedbook exists in the target database.
			@True: The farEditedbook exists in the database
			@False: The farEditedbook does not exist in the database
		"""
        (ret, ), = sesTarget.query(exists().where(
            FarEditedbooks.editedbookid == srcFarEditedbook.editedbookid))

        return ret

    if farEditedbookExists():

        def farEditedbookUpdateRequired():
            """
				Determine if the farEditedbook that exists requires and update.
				@True: returned if source_hash is unchanged
				@False: returned if source_hash is different
			"""
            (ret, ), = sesTarget.query(exists().where(
                FarEditedbooks.editedbookid == srcFarEditedbook.editedbookid
            ).where(FarEditedbooks.source_hash == srcHash).where(
                FarEditedbooks.deleted_at.is_(None)))

            return not ret

        if farEditedbookUpdateRequired():
            # retrive the tables object to update.
            updateFarEditedbook = sesTarget.query(FarEditedbooks).filter(
                FarEditedbooks.editedbookid ==
                srcFarEditedbook.editedbookid).one()

            # repeat the following pattern for all mapped attributes:
            updateFarEditedbook.source_hash = srcHash
            updateFarEditedbook.editedbookid = srcFarEditedbook.editedbookid
            updateFarEditedbook.src_sys_id = srcFarEditedbook.src_sys_id
            updateFarEditedbook.evaluationid = srcFarEditedbook.evaluationid
            updateFarEditedbook.authors = srcFarEditedbook.authors
            updateFarEditedbook.title = srcFarEditedbook.title
            updateFarEditedbook.publisher = srcFarEditedbook.publisher
            updateFarEditedbook.publicationstatuscode = srcFarEditedbook.publicationstatuscode
            updateFarEditedbook.pages = srcFarEditedbook.pages
            updateFarEditedbook.isbn = srcFarEditedbook.isbn
            updateFarEditedbook.publicationyear = srcFarEditedbook.publicationyear
            updateFarEditedbook.volumenumber = srcFarEditedbook.volumenumber
            updateFarEditedbook.edition = srcFarEditedbook.edition
            updateFarEditedbook.publicationcity = srcFarEditedbook.publicationcity
            updateFarEditedbook.webaddress = srcFarEditedbook.webaddress
            updateFarEditedbook.translated = srcFarEditedbook.translated
            updateFarEditedbook.additionalinfo = srcFarEditedbook.additionalinfo
            updateFarEditedbook.dtcreated = srcFarEditedbook.dtcreated
            updateFarEditedbook.dtupdated = srcFarEditedbook.dtupdated
            updateFarEditedbook.userlastmodified = srcFarEditedbook.userlastmodified
            updateFarEditedbook.ispublic = srcFarEditedbook.ispublic
            updateFarEditedbook.activityid = srcFarEditedbook.activityid
            updateFarEditedbook.load_error = srcFarEditedbook.load_error
            updateFarEditedbook.data_origin = srcFarEditedbook.data_origin
            updateFarEditedbook.created_ew_dttm = srcFarEditedbook.created_ew_dttm
            updateFarEditedbook.lastupd_dw_dttm = srcFarEditedbook.lastupd_dw_dttm
            updateFarEditedbook.batch_sid = srcFarEditedbook.batch_sid
            updateFarEditedbook.updated_at = datetime.datetime.utcnow(
            ).strftime('%Y-%m-%d %H:%M:%S')
            updateFarEditedbook.deleted_at = None

            return updateFarEditedbook

    else:
        srcGetFarEvaluationId = sesTarget.query(
            FarEvaluations.id).filter(FarEvaluations.evaluationid ==
                                      srcFarEditedbook.evaluationid).one()

        insertFarEditedbook = FarEditedbooks(
            source_hash=srcHash,
            far_evaluation_id=srcGetFarEvaluationId.id,
            editedbookid=srcFarEditedbook.editedbookid,
            src_sys_id=srcFarEditedbook.src_sys_id,
            evaluationid=srcFarEditedbook.evaluationid,
            authors=srcFarEditedbook.authors,
            title=srcFarEditedbook.title,
            publisher=srcFarEditedbook.publisher,
            publicationstatuscode=srcFarEditedbook.publicationstatuscode,
            pages=srcFarEditedbook.pages,
            isbn=srcFarEditedbook.isbn,
            publicationyear=srcFarEditedbook.publicationyear,
            volumenumber=srcFarEditedbook.volumenumber,
            edition=srcFarEditedbook.edition,
            publicationcity=srcFarEditedbook.publicationcity,
            webaddress=srcFarEditedbook.webaddress,
            translated=srcFarEditedbook.translated,
            additionalinfo=srcFarEditedbook.additionalinfo,
            dtcreated=srcFarEditedbook.dtcreated,
            dtupdated=srcFarEditedbook.dtupdated,
            userlastmodified=srcFarEditedbook.userlastmodified,
            ispublic=srcFarEditedbook.ispublic,
            activityid=srcFarEditedbook.activityid,
            load_error=srcFarEditedbook.load_error,
            data_origin=srcFarEditedbook.data_origin,
            created_ew_dttm=srcFarEditedbook.created_ew_dttm,
            lastupd_dw_dttm=srcFarEditedbook.lastupd_dw_dttm,
            batch_sid=srcFarEditedbook.batch_sid,
            created_at=datetime.datetime.utcnow().strftime(
                '%Y-%m-%d %H:%M:%S'))

        return insertFarEditedbook
def processFarEvaluation(srcFarEvaluation, sesTarget):
    """
		Takes in a source FarEvaluation object from biopsmodels (mysql.bio_ps.FarEvaluations)
		and determines if the object needs to be updated, inserted in the target
		database (mysql.bio_public.FarEvaluations), or that nothing needs doing.
	
		Selecting Booleans from the databases.  Using conjunctions to make the exists()
		a boolean return from the query() method.  Bit more syntax but a sqlalchemy object
		returned will not be truthy/falsey.
		(http://techspot.zzzeek.org/2008/09/09/selecting-booleans/)
	"""
    true, false = literal(True), literal(False)

    farEvaluationList = [
        srcFarEvaluation.evaluationid, srcFarEvaluation.src_sys_id,
        srcFarEvaluation.calendaryear, srcFarEvaluation.emplid,
        srcFarEvaluation.asuriteid, srcFarEvaluation.asuid,
        srcFarEvaluation.faculty_rank_title, srcFarEvaluation.job_title,
        srcFarEvaluation.tenure_status_code,
        srcFarEvaluation.tenurehomedeptcode, srcFarEvaluation.extensiondate,
        srcFarEvaluation.completed, srcFarEvaluation.dtcreated,
        srcFarEvaluation.dtupdated, srcFarEvaluation.userlastmodified,
        srcFarEvaluation.load_error, srcFarEvaluation.data_origin,
        srcFarEvaluation.created_ew_dttm, srcFarEvaluation.lastupd_dw_dttm,
        srcFarEvaluation.batch_sid
    ]

    srcHash = hashThisList(farEvaluationList)

    def farEvaluationExists():
        """
			determine the farEvaluation exists in the target database.
			@True: The farEvaluation exists in the database
			@False: The farEvaluation does not exist in the database
		"""
        (ret, ), = sesTarget.query(exists().where(
            FarEvaluations.evaluationid == srcFarEvaluation.evaluationid
        ).where(FarEvaluations.emplid == srcFarEvaluation.emplid))

        return ret

    if farEvaluationExists():

        def farEvaluationUpdateRequired():
            """
				Determine if the farEvaluation that exists requires and update.
				@True: returned if source_hash is unchanged
				@False: returned if source_hash is different
			"""
            (ret, ), = sesTarget.query(exists().where(
                FarEvaluations.evaluationid == srcFarEvaluation.evaluationid
            ).where(FarEvaluations.emplid == srcFarEvaluation.emplid).where(
                FarEvaluations.source_hash == srcHash).where(
                    FarEvaluations.deleted_at.is_(None)))

            return not ret

        if farEvaluationUpdateRequired():
            # retrive the tables object to update.
            updateFarEvaluation = sesTarget.query(FarEvaluations).filter(
                FarEvaluations.evaluationid == srcFarEvaluation.evaluationid
            ).filter(FarEvaluations.emplid == srcFarEvaluation.emplid).one()

            # repeat the following pattern for all mapped attributes:
            updateFarEvaluation.source_hash = srcHash
            updateFarEvaluation.evaluationid = srcFarEvaluation.evaluationid
            updateFarEvaluation.src_sys_id = srcFarEvaluation.src_sys_id
            updateFarEvaluation.calendaryear = srcFarEvaluation.calendaryear
            updateFarEvaluation.emplid = srcFarEvaluation.emplid
            updateFarEvaluation.asuriteid = srcFarEvaluation.asuriteid
            updateFarEvaluation.asuid = srcFarEvaluation.asuid
            updateFarEvaluation.faculty_rank_title = srcFarEvaluation.faculty_rank_title
            updateFarEvaluation.job_title = srcFarEvaluation.job_title
            updateFarEvaluation.tenure_status_code = srcFarEvaluation.tenure_status_code
            updateFarEvaluation.tenurehomedeptcode = srcFarEvaluation.tenurehomedeptcode
            updateFarEvaluation.extensiondate = srcFarEvaluation.extensiondate
            updateFarEvaluation.completed = srcFarEvaluation.completed
            updateFarEvaluation.dtcreated = srcFarEvaluation.dtcreated
            updateFarEvaluation.dtupdated = srcFarEvaluation.dtupdated
            updateFarEvaluation.userlastmodified = srcFarEvaluation.userlastmodified
            updateFarEvaluation.load_error = srcFarEvaluation.load_error
            updateFarEvaluation.data_origin = srcFarEvaluation.data_origin
            updateFarEvaluation.created_ew_dttm = srcFarEvaluation.created_ew_dttm
            updateFarEvaluation.lastupd_dw_dttm = srcFarEvaluation.lastupd_dw_dttm
            updateFarEvaluation.batch_sid = srcFarEvaluation.batch_sid

            updateFarEvaluation.updated_at = datetime.datetime.utcnow(
            ).strftime('%Y-%m-%d %H:%M:%S')
            updateFarEvaluation.deleted_at = None

            return updateFarEvaluation

    else:
        srcGetPersonId = sesTarget.query(
            People.id).filter(People.emplid == srcFarEvaluation.emplid).one()

        insertFarEvaluation = FarEvaluations(
            person_id=srcGetPersonId.id,
            source_hash=srcHash,
            evaluationid=srcFarEvaluation.evaluationid,
            src_sys_id=srcFarEvaluation.src_sys_id,
            calendaryear=srcFarEvaluation.calendaryear,
            emplid=srcFarEvaluation.emplid,
            asuriteid=srcFarEvaluation.asuriteid,
            asuid=srcFarEvaluation.asuid,
            faculty_rank_title=srcFarEvaluation.faculty_rank_title,
            job_title=srcFarEvaluation.job_title,
            tenure_status_code=srcFarEvaluation.tenure_status_code,
            tenurehomedeptcode=srcFarEvaluation.tenurehomedeptcode,
            extensiondate=srcFarEvaluation.extensiondate,
            completed=srcFarEvaluation.completed,
            dtcreated=srcFarEvaluation.dtcreated,
            dtupdated=srcFarEvaluation.dtupdated,
            userlastmodified=srcFarEvaluation.userlastmodified,
            load_error=srcFarEvaluation.load_error,
            data_origin=srcFarEvaluation.data_origin,
            created_ew_dttm=srcFarEvaluation.created_ew_dttm,
            lastupd_dw_dttm=srcFarEvaluation.lastupd_dw_dttm,
            batch_sid=srcFarEvaluation.batch_sid,
            created_at=datetime.datetime.utcnow().strftime(
                '%Y-%m-%d %H:%M:%S'))

        return insertFarEvaluation