<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="SapReportMapper">
	<delete id="deleteSapPerPerson">
		delete from sapperperson
	</delete>

	<insert id="saveSapPerPerson">
		insert into sapperperson(personId,dateOfBirth,placeOfBirth,education) 
		values (#{personId},#{dateOfBirth},#{placeOfBirth},#{education})
	</insert>
	
	<delete id="deleteSapPerPersonal">
		delete from sapperpersonal
	</delete>
	
	<insert id="saveSapPerPersonal">
		insert into sapperpersonal(personId,firstName,lastName,displayName,
			formalName,nationality,gender,maritalStatus,firstNameAlt1,
			lastNameAlt1,firstNameAlt2,lastNameAlt2) 
		values (#{personId},#{firstName},#{lastName},#{displayName},
			#{formalName},#{nationality},#{gender},#{maritalStatus},#{firstNameAlt1},
			#{lastNameAlt1},#{firstNameAlt2},#{lastNameAlt2})
	</insert>
	
	<delete id="deleteSapPerGlobalInfoCHN">
		delete from sapperglobalinfochn
	</delete>
	
	<insert id="saveSapPerGlobalInfoCHN">
		insert into sapperglobalinfochn(personId,householdRegistrationType,nation,
			politicalOutlook,orgRelationshipLocation,socialSecurityLocation) 
		values (#{personId},#{householdRegistrationType},#{nation},
			#{politicalOutlook},#{orgRelationshipLocation},#{socialSecurityLocation})
	</insert>
	
	<delete id="deleteSapPerNationalId">
		delete from sappernationalid
	</delete>
	
	<insert id="saveSapPerNationalId">
		insert into sappernationalid(personId,countryName,cardType,nationalId) 
		values (#{personId},#{countryName},#{cardType},#{nationalId})
	</insert>
	
	<delete id="deleteSapPerEmail">
		delete from sapperemail
	</delete>
	
	<insert id="saveSapPerEmail">
		insert into sapperemail(personId,emailType,emailAddress,isPrimary) 
		values (#{personId},#{emailType},#{emailAddress},#{isPrimary})
	</insert>
	
	<delete id="deleteSapPerPhone">
		delete from sapperphone
	</delete>
	
	<insert id="saveSapPerPhone">
		insert into sapperphone(personId,phoneNumber,phoneType,isPrimary) 
		values (#{personId},#{phoneNumber},#{phoneType},#{isPrimary})
	</insert>
	
	<delete id="deleteSapPerSocialAccount">
		delete from sappersocialaccount
	</delete>
	
	<insert id="saveSapPerSocialAccount">
		insert into sappersocialaccount(personId,domain,imId) values (#{personId},#{domain},#{imId})
	</insert>
	
	<delete id="deleteSapEmpEmployment">
		delete from sapempemployment
	</delete>
	
	<insert id="saveSapEmpEmployment">
		insert into sapempemployment(personId,startDate,firstDateWorked,originalStartDate,seniorityDate,socialServiceAge,
			seniority,endDate,okToRehire,salaryEndDate,benefitsEndDate,leavingReason) 
		values (#{personId},#{startDate},#{firstDateWorked},#{originalStartDate},#{seniorityDate},#{socialServiceAge},
			#{seniority},#{endDate},#{okToRehire},#{salaryEndDate},#{benefitsEndDate},#{leavingReason})
	</insert>
	
	<delete id="deleteSapEmpJob">
		delete from sapempjob
	</delete>
	
	<insert id="saveSapEmpJob">
		insert into sapempjob(userId,positionName,positionEntryDate,companyName,businessUnitName,
			divisionName,departmentName,teamName,locationName,managerId,managerName,jobCodeName,
			jobTitle,rank,managementOrNot) 
		values (#{userId},#{positionName},#{positionEntryDate},#{companyName},#{businessUnitName},
			#{divisionName},#{departmentName},#{teamName},#{locationName},#{managerId},#{managerName},#{jobCodeName},
			#{jobTitle},#{rank},#{managementOrNot})
	</insert>
	
	<delete id="deleteSapEmpJobRelationships">
		delete from sapempjobrelationships
	</delete>
	
	<insert id="saveSapEmpJobRelationships">
		insert into sapempjobrelationships(userId,relationshipType,relUserName) 
		values (#{userId},#{relationshipType},#{relUserName})
	</insert>
	
	<delete id="deleteSapOutsideWorkExperience">
		delete from sapoutsideworkexperience
	</delete>
	
	<insert id="saveSapOutsideWorkExperience">
		insert into sapoutsideworkexperience(userId,startDate,endDate,employer,businessType,
			department,position,leavingReason,immediateSupervisorName,contactInformation) 
		values (#{userId},#{startDate},#{endDate},#{employer},#{businessType},
			#{department},#{position},#{leavingReason},#{immediateSupervisorName},#{contactInformation})
	</insert>
	
	<delete id="deleteSapInsideWorkExperience">
		delete from sapinsideworkexperience
	</delete>

	<insert id="saveSapInsideWorkExperience">
		insert into sapinsideworkexperience(userId,startDate,endDate,title,department) 
		values (#{userId},#{startDate},#{endDate},#{title},#{department})
	</insert>
	
	<delete id="deleteSapCourses">
		delete from sapcourses
	</delete>

	<insert id="saveSapCourses">
		insert into sapcourses(userId,course,startDate,endDate,type,
			place,duration,result,certificateOrNot,dueTime,remark) 
		values (#{userId},#{course},#{startDate},#{endDate},#{type},
			#{place},#{duration},#{result},#{certificateOrNot},#{dueTime},#{remark})
	</insert>
	
	<delete id="deleteSapEducation">
		delete from sapeducation
	</delete>

	<insert id="saveSapEducation">
		insert into sapeducation(userId,startDate,endDate,school,major,degree,qualification) 
		values (#{userId},#{startDate},#{endDate},#{school},#{major},#{degree},#{qualification})
	</insert>

	<delete id="deleteSapCertificates">
		delete from sapcertificates
	</delete>

	<insert id="saveSapCertificates">
		insert into sapcertificates(userId,name,description,institution,startDate,endDate) 
		values (#{userId},#{name},#{description},#{institution},#{startDate},#{endDate})
	</insert>
	
	<delete id="deleteSapLanguages">
		delete from saplanguages
	</delete>

	<insert id="saveSapLanguages">
		insert into saplanguages(userId,language,speakingProf,readingProf,writingProf) 
		values (#{userId},#{language},#{speakingProf},#{readingProf},#{writingProf})
	</insert>
	
	<delete id="deleteSapOverallPerformance">
		delete from sapoverallperformance
	</delete>

	<insert id="saveSapOverallPerformance">
		insert into sapoverallperformance(userId,startDate,endDate,module,name,description) 
		values (#{userId},#{startDate},#{endDate},#{module},#{name},#{description})
	</insert>
</mapper>