Commit 55ff6b7a by kanok

init to git

parents
File added
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ZM-CTraining</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.jboss.tools.jst.web.kb.kbbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.hibernate.eclipse.console.hibernateBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.jboss.tools.cdi.core.cdibuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.hibernate.eclipse.console.hibernateNature</nature>
<nature>org.jboss.tools.jst.web.kb.kbnature</nature>
<nature>org.jboss.tools.cdi.core.cdinature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="ZM-CTraining">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.8"/>
<installed facet="jst.utility" version="1.0"/>
</faceted-project>
disabled=06target
eclipse.preferences.version=1
default.configuration=ZM-CTraining
eclipse.preferences.version=1
hibernate3.enabled=true
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>ZM-CTraining</artifactId>
<version>${version.zm-ctraining}</version>
<name>Zeeme Training</name>
<dependencies>
<!-- time utils -->
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-TimeUtils</artifactId>
<version>${version.zm-timeutils}</version>
</dependency>
<!-- Training -->
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-DataBean-Training</artifactId>
<version>${version.zm-databean-training}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-Datasource-Cassandra-Training</artifactId>
<version>${version.zm-datasource-cassandra-training}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-Training-API</artifactId>
<version>${version.zm-training-api}</version>
</dependency>
<!-- cftp -->
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-CFTP</artifactId>
<version>${version.zm-cftp}</version>
</dependency>
<!-- csc system -->
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-CscSystem</artifactId>
<version>${version.zm-cscsystem}</version>
</dependency>
<!-- core -->
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-DataBean-company</artifactId>
<version>${version.zm-databean-company}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-Datasource-cassandra-company</artifactId>
<version>${version.zm-datasource-cassandra-company}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-Cassandra-core</artifactId>
<version>${version.zm-cassandra-core}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-Datasource-cassandra-core</artifactId>
<version>${version.zm-datasource-cassandra-core}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-DataBean-core</artifactId>
<version>${version.zm-databean-core}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-Apis</artifactId>
<version>${version.zm-api}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
<!-- export time att -->
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-ExportTimeAtt</artifactId>
<version>${version.zm-exporttimeatt}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-CscWebsocketApi</artifactId>
<version>${version.zm-cscwebsocket-api}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${version.java-servlet-api}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<parent>
<groupId>com.csc.library</groupId>
<artifactId>csc-dev1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
</project>
\ No newline at end of file
package com.csc.library.process;
import com.csc.library.utilities.CheckNull;
import com.csc.library.utilities.MyLog;
public class CourseImpProp implements CourseImportField {
private String companyid ;
private String trainingid ;
private String courseid ;
private String sessionid ;
private String title ;
private String location ;
private String startdate ;
private String starttime ;
private String enddate ;
private String endtime ;
private String trainer ;
private String desc ;
private String status ;
private String objective ;
private String rstartdate ;
private String rstarttime ;
private String renddate ;
private String rendtime ;
private String punchbefore ;
private String punchafter ;
private String picture ;
private String sourcelink ;
private String downloadlink ;
static CourseImpProp cip ;
public static CourseImpProp newInstance(String raw){
cip = new CourseImpProp(raw);
return cip ;
}
public CourseImpProp(String raw){
try {
String ls[] = raw.split("\\|");
if(ls.length >= OBJECTIVE){
setCompanyid(getStringData(ls,COMPANYID));
setTrainingid(getStringData(ls,TRAININGID));
setCourseid(getStringData(ls,COURSEID));
setSessionid(getStringData(ls,SESSIONID));
setTitle(getStringData(ls,TITLE));
setLocation(getStringData(ls,LOCATION));
setStartdate(getStringData(ls,STARTDATE));
setStarttime(getStringData(ls,STARTTIME));
setEnddate(getStringData(ls,ENDDATE));
setEndtime(getStringData(ls,ENDTIME));
setTrainer(getStringData(ls,TRAINER));
setDesc(getStringData(ls,DESC));
setObjective(getStringData(ls,OBJECTIVE));
setStatus(getStringData(ls,STATUS));
setRstartdate(getStringData(ls,RSTARTDATE));
setRstarttime(getStringData(ls,RSTARTTIME));
setRenddate(getStringData(ls,RENDDATE));
setRendtime(getStringData(ls,RENDTIME));
setPunchbefore(getStringData(ls,PUNCHBEFORE));
setPunchafter(getStringData(ls,PUNCHAFTER));
setPicture(getStringData(ls,PICTURE));
setSourcelink(getStringData(ls,SOUCELINK));
setDownloadlink(getStringData(ls,DOWNLOADLINK));
}
}catch(Exception e){
MyLog.error(this, e);
}
}
private String getStringData(String arr[], int index){
try {
return CheckNull.getInstance().chkNullString(arr[index]);
}catch(Exception e){
MyLog.error(this, "!! index out of bound : " + index + " >> " + arr);
}
return "";
}
public String getCompanyid() {
return companyid;
}
public void setCompanyid(String companyid) {
this.companyid = companyid;
}
public String getTrainingid() {
return trainingid;
}
public void setTrainingid(String trainingid) {
this.trainingid = trainingid;
}
public String getCourseid() {
return courseid;
}
public void setCourseid(String courseid) {
this.courseid = courseid;
}
public String getSessionid() {
return sessionid;
}
public void setSessionid(String sessionid) {
this.sessionid = sessionid;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getStartdate() {
return startdate;
}
public void setStartdate(String startdate) {
this.startdate = startdate;
}
public String getStarttime() {
return starttime;
}
public void setStarttime(String starttime) {
this.starttime = starttime;
}
public String getEnddate() {
return enddate;
}
public void setEnddate(String enddate) {
this.enddate = enddate;
}
public String getEndtime() {
return endtime;
}
public void setEndtime(String endtime) {
this.endtime = endtime;
}
public String getTrainer() {
return trainer;
}
public void setTrainer(String trainer) {
this.trainer = trainer;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getObjective() {
return objective;
}
public void setObjective(String objective) {
this.objective = objective;
}
public String getRstartdate() {
return rstartdate;
}
public void setRstartdate(String rstartdate) {
this.rstartdate = rstartdate;
}
public String getRstarttime() {
return rstarttime;
}
public void setRstarttime(String rstarttime) {
this.rstarttime = rstarttime;
}
public String getRenddate() {
return renddate;
}
public void setRenddate(String renddate) {
this.renddate = renddate;
}
public String getRendtime() {
return rendtime;
}
public void setRendtime(String rendtime) {
this.rendtime = rendtime;
}
public String getPunchbefore() {
return punchbefore;
}
public void setPunchbefore(String punchbefore) {
this.punchbefore = punchbefore;
}
public String getPunchafter() {
return punchafter;
}
public void setPunchafter(String punchafter) {
this.punchafter = punchafter;
}
public String getPicture() {
return picture;
}
public void setPicture(String picture) {
this.picture = picture;
}
public String getSourcelink() {
return sourcelink;
}
public void setSourcelink(String sourcelink) {
this.sourcelink = sourcelink;
}
public String getDownloadlink() {
return downloadlink;
}
public void setDownloadlink(String downloadlink) {
this.downloadlink = downloadlink;
}
}
package com.csc.library.process ;
public interface CourseImportField {
int COMPANYID = 0 ;
int TRAININGID = 1 ;
int COURSEID = 2 ;
int SESSIONID = 3 ;
int TITLE = 4 ;
int LOCATION = 5 ;
int STARTDATE = 6 ;
int STARTTIME = 7 ;
int ENDDATE = 8 ;
int ENDTIME = 9 ;
int TRAINER = 10 ;
int DESC = 11 ;
int STATUS = 12 ;
int OBJECTIVE = 13 ;
int RSTARTDATE = 14 ;
int RSTARTTIME = 15 ;
int RENDDATE = 16 ;
int RENDTIME = 17 ;
int PUNCHBEFORE = 18 ;
int PUNCHAFTER = 19 ;
int PICTURE = 20;
int SOUCELINK = 21 ;
int DOWNLOADLINK = 22 ;
}
package com.csc.library.process;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import com.csc.library.utilities.CheckNull;
import com.csc.library.utilities.CscCalendar;
import com.csc.library.utilities.MyLog;
public class EmployeeImpProp implements EmployeeImportField {
private String employeeid ;
private String companyid ;
private String fullname ;
private String gender ;
private String company ;
private String employee_group ;
private String personal_id ;
private String position ;
private String branch ;
private String department ;
private String division ;
private String section ;
private String sub_section1 ;
private String sub_section2 ;
private String working_area ;
private String boss_1 ;
private String boss_2 ;
private String boss_3 ;
private String boss_4 ;
private String boss_5 ;
private String status ;
private String nationality ;
private String privilege ;
private String resign_date ;
private String startdate ;
private String email ;
private String passportid ;
private String birthday ;
private String telephone ;
private String bossid_1 ;
private String bossid_2 ;
private String bossid_3 ;
private String bossid_4 ;
private String bossid_5 ;
public EmployeeImpProp(){
}
public EmployeeImpProp(String raw){
try {
String ls[] = raw.split("\\|");
if(ls.length >= TELEPHONE){
setEmployeeid(getStringData(ls,EMPLOYEEID));
setCompanyid(getStringData(ls,COMPANYID));
setFullname(getStringData(ls,FULLNAME));
setGender(getStringData(ls,GENDER));
setCompany(getStringData(ls,COMPANY));
setEmployee_group(getStringData(ls,EMPLOYEE_GROUP));
setPersonal_id(getStringData(ls,PERSONAL_ID));
setPosition(getStringData(ls,POSITION));
setBranch(getStringData(ls,BRANCH));
setDepartment(getStringData(ls,DEPARTMENT));
setDivision(getStringData(ls,DIVISION));
setSection(getStringData(ls,SECTION));
setSub_section1(getStringData(ls,SUB_SECTION1));
setSub_section2(getStringData(ls,SUB_SECTION2));
setWorking_area(getStringData(ls,WORKING_AREA));
setBoss_1(getStringData(ls,BOSS_1));
setBoss_2(getStringData(ls,BOSS_2));
setBoss_3(getStringData(ls,BOSS_3));
setBoss_4(getStringData(ls,BOSS_4));
setBoss_5(getStringData(ls,BOSS_5));
setStatus(getStringData(ls,STATUS));
setNationality(getStringData(ls,NATIONALITY));
setPrivilege(getStringData(ls,PRIVILEGE));
setResign_date(getStringData(ls,RESIGN_DATE));
setStartdate(getStringData(ls,STARTDATE));
setEmail(getStringData(ls,EMAIL));
setPassportid(getStringData(ls,PASSPORTID));
setBirthday(getStringData(ls,BIRTHDATE));
setTelephone(getStringData(ls,TELEPHONE));
/* boss id */
if(ls.length >= BOSSID_1){
setBossid_1(getStringData(ls, BOSSID_1));
}
if(ls.length >= BOSSID_2){
setBossid_2(getStringData(ls, BOSSID_2));
}
if(ls.length >= BOSSID_3){
setBossid_3(getStringData(ls, BOSSID_3));
}
if(ls.length >= BOSSID_4){
setBossid_4(getStringData(ls, BOSSID_4));
}
if(ls.length >= BOSSID_5){
setBossid_5(getStringData(ls, BOSSID_5));
}
if(this.getEmployeeid() == null || this.getEmployeeid().equals("")){
MyLog.error(this, "!! incorrect raw data after split into array !!" + raw);
for(String item : ls){
System.out.print(item + ":");
}
MyLog.error(this, "!! end print error !!");
}
/*testing*/
//genImportEmp(ls);
}else{
MyLog.error(this, "!! raw data is incorrect !! " + ls);
}
}catch(Exception e){
MyLog.error(this, e);
}
}
/*testing*/
private void genImportEmpFile(String ls[]){
try {
setEmail(getFullname().substring(0, 1).toLowerCase()
+ getFullname().substring(getFullname().indexOf(" ")).trim().toLowerCase() + "@peninsula.com");
writetextfile(
getEmployeeid() + "|" +
getCompanyid() + "|" +
getFullname() + "|" +
getStringData(ls,GENDER) + "|" +
getCompany() + "|" +
getEmployee_group() + "|" +
getPersonal_id() + "|" +
getPosition() + "|" +
getBranch() + "|" +
getDepartment() + "|" +
getDivision() + "|" +
getSection() + "|" +
getSub_section1() + "|" +
getSub_section2() + "|" +
getWorking_area() + "|" +
getBoss_1() + "|" +
getBoss_2() + "|" +
getBoss_3() + "|" +
getBoss_4() + "|" +
getBoss_5() + "|" +
getStringData(ls,STATUS) + "|" +
getNationality() + "|" +
getPrivilege() + "|" +
getResign_date() + "|" +
getStartdate() + "|" +
getEmail() + "|" +
getPassportid() + "|" +
getBirthday() + "|" +
getTelephone() + "|" +
getBossid_1() + "|" +
getBossid_2() + "|" +
getBossid_3() + "|" +
getBossid_4() + "|" +
getBossid_5()
);
}catch(Exception e){
e.printStackTrace();
}
}
/*testing*/
private void writetextfile(String content){
BufferedWriter bw = null;
FileWriter fw = null;
try {
File file = new File("/Users/CSC/MyDrive/zeeme_emp_data.txt");
if (!file.exists()) {
file.createNewFile();
}
fw = new FileWriter(file.getAbsoluteFile(), true);
bw = new BufferedWriter(fw);
bw.write(content + "\n");
System.out.println("Done");
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (bw != null)
bw.close();
if (fw != null)
fw.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
private String getStringData(String arr[], int index){
try {
return CheckNull.getInstance().chkNullString(arr[index].trim());
}catch(Exception e){
MyLog.error(this, "!! index out of bound : " + index + " >> " + arr);
}
return "";
}
public String getEmployeeid() {
return employeeid;
}
public void setEmployeeid(String employeeid) {
this.employeeid = employeeid;
}
public String getCompanyid() {
return companyid;
}
public void setCompanyid(String companyid) {
this.companyid = companyid;
}
public String getFullname() {
return fullname;
}
public void setFullname(String fullname) {
this.fullname = fullname;
}
public String getGender() {
return String.valueOf(convertGender());
}
public void setGender(String gender) {
this.gender = gender;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getEmployee_group() {
return employee_group;
}
public void setEmployee_group(String employee_group) {
this.employee_group = employee_group;
}
public String getPersonal_id() {
return personal_id;
}
public void setPersonal_id(String personal_id) {
this.personal_id = personal_id;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getBranch() {
return branch;
}
public void setBranch(String branch) {
this.branch = branch;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getDivision() {
return division;
}
public void setDivision(String division) {
this.division = division;
}
public String getSection() {
return section;
}
public void setSection(String section) {
this.section = section;
}
public String getSub_section1() {
return sub_section1;
}
public void setSub_section1(String sub_section1) {
this.sub_section1 = sub_section1;
}
public String getSub_section2() {
return sub_section2;
}
public void setSub_section2(String sub_section2) {
this.sub_section2 = sub_section2;
}
public String getWorking_area() {
return working_area;
}
public void setWorking_area(String working_area) {
this.working_area = working_area;
}
public String getBoss_1() {
return boss_1;
}
public void setBoss_1(String boss_1) {
this.boss_1 = boss_1;
}
public String getBoss_2() {
return boss_2;
}
public void setBoss_2(String boss_2) {
this.boss_2 = boss_2;
}
public String getBoss_3() {
return boss_3;
}
public void setBoss_3(String boss_3) {
this.boss_3 = boss_3;
}
public String getBoss_4() {
return boss_4;
}
public void setBoss_4(String boss_4) {
this.boss_4 = boss_4;
}
public String getBoss_5() {
return boss_5;
}
public void setBoss_5(String boss_5) {
this.boss_5 = boss_5;
}
public String getStatus() {
return String.valueOf(convertWorkStatus());
}
public void setStatus(String status) {
this.status = status;
}
public String getNationality() {
return nationality;
}
public void setNationality(String nationality) {
this.nationality = nationality;
}
public String getPrivilege() {
return privilege;
}
public void setPrivilege(String privilege) {
this.privilege = privilege;
}
public String getResign_date() {
if(resign_date == null || resign_date.equals("")){
return "2100-12-31"; /* default */
}else{
return resign_date;
}
}
public void setResign_date(String resign_date) {
this.resign_date = resign_date;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassportid() {
return passportid;
}
public void setPassportid(String passportid) {
this.passportid = passportid;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getBossid_1() {
return bossid_1;
}
public void setBossid_1(String bossid_1) {
this.bossid_1 = bossid_1;
}
public String getBossid_2() {
return bossid_2;
}
public void setBossid_2(String bossid_2) {
this.bossid_2 = bossid_2;
}
public String getBossid_3() {
return bossid_3;
}
public void setBossid_3(String bossid_3) {
this.bossid_3 = bossid_3;
}
public String getBossid_4() {
return bossid_4;
}
public void setBossid_4(String bossid_4) {
this.bossid_4 = bossid_4;
}
public String getBossid_5() {
return bossid_5;
}
public void setBossid_5(String bossid_5) {
this.bossid_5 = bossid_5;
}
public String getFirstName(){
try {
if(this.fullname != null && this.fullname.length() > 0){
String[] f = this.fullname.split(" ");
return f[0];
}
}catch(Exception e){
MyLog.error(this, e);
}
return "";
}
public String getLastName(){
try {
if(this.fullname != null && this.fullname.length() > 0){
String[] f = this.fullname.split(" ");
return f[f.length-1];
}
}catch(Exception e){
MyLog.error(this, e);
}
return "";
}
public int convertGender(){
try {
if(this.gender.equals("M")){
return MALE ;
}else{
return FEMALE ;
}
}catch(Exception e){
MyLog.error(this, e);
}
return MALE ;
}
public int convertWorkStatus(){
try {
if(this.status.equals("A") || this.status.equals("V")){
return 1 ;
}
}catch(Exception e){
MyLog.error(this, e);
}
return 0 ;
}
public String getStartdate() {
return startdate;
}
public void setStartdate(String startdate) {
this.startdate = startdate;
}
}
package com.csc.library.process;
public interface EmployeeImportField {
public int EMPLOYEEID = 0 ;
public int COMPANYID = 1;
public int FULLNAME = 2;
public int GENDER = 3;
public int COMPANY = 4;
public int EMPLOYEE_GROUP = 5;
public int PERSONAL_ID = 6;
public int POSITION = 7;
public int BRANCH = 8;
public int DEPARTMENT = 9;
public int DIVISION = 10;
public int SECTION = 11;
public int SUB_SECTION1 = 12;
public int SUB_SECTION2 = 13;
public int WORKING_AREA = 14;
public int BOSS_1 = 15;
public int BOSS_2 = 16;
public int BOSS_3 = 17;
public int BOSS_4 = 18;
public int BOSS_5 = 19;
public int STATUS = 20;
public int NATIONALITY = 21;
public int PRIVILEGE = 22;
public int RESIGN_DATE = 23;
public int STARTDATE = 24;
public int EMAIL = 25;
public int PASSPORTID = 26;
public int BIRTHDATE = 27;
public int TELEPHONE = 28;
public int BOSSID_1 = 29;
public int BOSSID_2 = 30;
public int BOSSID_3 = 31;
public int BOSSID_4 = 32;
public int BOSSID_5 = 33;
public int MALE = 0 ;
public int FEMALE = 1 ;
}
package com.csc.library.process;
import com.csc.library.utilities.MyLog;
import com.csc.library.utilities.TimeUtils ;
public class GenPassword {
public GenPassword(){
}
public String genPassword(EmployeeImpProp eip){
try {
/* last 4 digit of personaid + year month day of birthday */
String per = "";
if(!eip.getPersonal_id().equals("")){
per = eip.getPersonal_id().substring(eip.getPersonal_id().length() - 4) ;
}else if(!eip.getPassportid().equals("")){
per = eip.getPassportid().substring(eip.getPassportid().length() - 4) ;
}
String bdh = TimeUtils.getYYYYMMDD(eip.getBirthday()) ;
//return per + bdh ;
return "1234" ; /* fixed */
}catch(Exception e){
MyLog.error(this, e);
}
return eip.getPersonal_id() ;
}
}
package com.csc.library.process;
import com.csc.library.cdi.GetCdiInstance;
import com.csc.library.controller.ApplyCompanyController;
import com.csc.library.controller.MemberRegisterController;
import com.csc.library.controller.ApplyCompanyController.ResultApplyCompany;
import com.csc.library.controller.MemberRegisterController.ResultRegister;
import com.csc.library.entity.CompanyProfile;
import com.csc.library.entity.MemberProfile;
import com.csc.library.entity.manager.CompanyManager;
import com.csc.library.status.StatusMessage;
import com.csc.library.status.StatusResultMessage;
import com.csc.library.utilities.CscCalendar;
import com.csc.library.utilities.MyLog;
import th.co.csc.apimodel.common.FaceTemplateCommonModel;
import th.co.csc.apimodel.request.ApplyCompanyRequestModel;
import th.co.csc.apimodel.request.RegisterNewEmployeeRequestModel;
import th.co.csc.apimodel.request.RegisterRequestModel;
public class GenerateCompanyEmployee {
public GenerateCompanyEmployee(){}
public boolean process(RegisterNewEmployeeRequestModel param, EmployeeImpProp eip, MemberProfile mb
, CompanyProfile cp){
try {
RegisterRequestModel registerData = param.getMemberRegisterModel();
if(mb != null){
ApplyCompanyRequestModel applyModel = param.getApplyCompanyModel();
ApplyCompanyController applyComController = GetCdiInstance.of(ApplyCompanyController.class);
StatusResultMessage<ResultApplyCompany> srmApplyCom = applyComController.createBuilder()
.setMemberId(mb.getMemberid())
.setCompanyId(eip.getCompanyid())
.setBranchId(cp.getMainbranchId())
.setPosition(eip.getPosition())
.setDepartment(eip.getDepartment())
.apply();
if(srmApplyCom.isSuccess()){
ResultApplyCompany resultApplyCom = srmApplyCom.getResult();
StatusMessage smApprove = applyComController.createApproveBuilder()
.setCompanyId(eip.getCompanyid())
.setMemberid(mb.getMemberid())
//.setEmployeeCode(eip.getEmployeeid())
.setApplyDatetime(resultApplyCom.getApplyDateTime())
.setPosition(eip.getPosition())
.setDepartment(eip.getDepartment())
.setBossMajor(cp.getOwnerId())
.setBranchId(cp.getMainbranchId())
.approve();
if(smApprove.isSuccess()){
/* write log success */
}else{
/* write log not success */
}
}else{
/* write log auto apply unsuccess */
}
}else {
/* write log regis member not success */
}
}catch(Exception e){
MyLog.error(this,e);
}
return true ; /* default */
}
}
package com.csc.library.process;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
import com.csc.library.cdi.GetCdiInstance;
import com.csc.library.entity.CompanyProfile;
import com.csc.library.entity.TrainingCourse;
import com.csc.library.entity.TrainingCourseManager;
import com.csc.library.entity.manager.CompanyManager;
import com.csc.library.status.StatusMessage;
import com.csc.library.training.utilitis.TimeUtils;
import com.csc.library.utilities.CscCalendar;
import com.csc.library.utilities.MyLog;
public class ImportCourseManager {
private CompanyManager cm = GetCdiInstance.of(CompanyManager.class);
private CompanyProfile cpf ;
private TrainingCourseManager tcm = GetCdiInstance.of(TrainingCourseManager.class);
private TrainingCourse tc ;
public ImportCourseManager(){
}
public boolean importFromFolder(String folder, String filetype){
return process(folder, filetype, "");
}
public boolean importFromFolder(String folder, String filetype, String backupfolder){
return process(folder, filetype, backupfolder);
}
private boolean process(String folder, String filetype, String backupfolder){
try {
File directory = new File(folder);
//get all the files from a directory
File[] fList = directory.listFiles();
String content = "";
for (File file : fList){
if (file.isFile() && file.getName().endsWith(filetype) && file.getName().startsWith("course_")) {
try (BufferedReader br = new BufferedReader(new FileReader(file.getAbsolutePath()))) {
while ((content = br.readLine()) != null) {
System.out.println(content);
if(content != null && !content.equals("")){
save(content); /* raw data with '|' seperater column */
}else{
MyLog.debug(this, "!! data is empty !!");
}
}
} catch (IOException e) {
e.printStackTrace();
}
//backupFile(folder, file.getName());
}
}
}catch(Exception e){
e.printStackTrace();
return false ;
}
return true ;
}
private boolean backupFile(String folder, String filename){
return backupFile(folder, filename, "");
}
private boolean backupFile(String folder, String filename, String target){
try {
CscCalendar today = new CscCalendar();
File afile = new File(folder + "/" + filename);
if(afile.renameTo(new File(folder + "/backup/" + filename + "_" + TimeUtils.getYYYYMMDDHHMMSS(today)))) {
System.out.println("File is moved successful!");
return true ;
}else{
System.out.println("File is failed to move!");
}
}catch(Exception e){
MyLog.error(this, e);
}
return false ;
}
private boolean save(String content){
try {
boolean m_complete = false ;
boolean c_complete = false ;
CourseImpProp eip = fetchRawData(content);
if(eip != null){
initInstances(eip);
save(eip);
}
}catch(Exception e){
System.out.print(e.getMessage());
return false ;
}
return false;
}
private void initInstances(CourseImpProp eip){
try {
cpf = cm.getCompanyByCompanyId(eip.getCompanyid());
}catch(Exception e){
MyLog.error(this, e);
}
}
private boolean save(CourseImpProp cip){
try {
tc = tcm.createInstance(cip.getCompanyid()
, cip.getTrainingid()
, cip.getCourseid()
, cip.getSessionid());
tc.setTitle(cip.getTitle());
tc.setLocation(cip.getLocation());
tc.setStartdate(cip.getStartdate());
tc.setStarttime(cip.getStarttime());
tc.setEnddate(cip.getEnddate());
tc.setEndtime(cip.getEndtime());
tc.setTrainer(cip.getTrainer());
tc.setDescription(cip.getDesc());
tc.setStatus(cip.getStatus());
tc.setObjective(cip.getObjective());
tc.setReservstartdate(cip.getRstartdate());
tc.setReservstarttime(cip.getRstarttime());
tc.setReservenddate(cip.getRenddate());
tc.setReservendtime(cip.getRendtime());
tc.setPunchbefore(cip.getPunchbefore());
tc.setPunchafter(cip.getPunchafter());
tc.setPicture(cip.getPicture());
tc.setSourcedownloadlink(cip.getSourcelink());
tc.setVideolink(cip.getDownloadlink());
StatusMessage sm = tcm.save(tc);
MyLog.debug(this, "!! save emp complete : " + tc.getTrainingid()
+ "::" + tc.getCourseid() + "::" + tc.getSessionid());
return true ;
}catch(Exception e){
MyLog.error(this, e);
}
return false ;
}
/* convert raw data from file into EmployeeImpProp */
private CourseImpProp fetchRawData(String content){
try {
return CourseImpProp.newInstance(content);
}catch(Exception e){
MyLog.error(this, e);
}
return null ;
}
public boolean importWithFileName(String filename){
try (Scanner scanner = new Scanner(new File(filename))) {
while (scanner.hasNext()){
System.out.println(scanner.nextLine());
}
} catch (Exception e) {
e.printStackTrace();
return false ;
}
return true ;
}
}
package com.csc.library.process;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import com.csc.library.cdi.GetCdiInstance;
import com.csc.library.entity.CompanyEmployeeProfile;
import com.csc.library.entity.CompanyProfile;
import com.csc.library.entity.FileStore;
import com.csc.library.entity.Member;
import com.csc.library.entity.MemberProfile;
import com.csc.library.entity.MemberProfile.Sex;
import com.csc.library.entity.manager.CompanyEmployeeManager;
import com.csc.library.entity.manager.CompanyEmployeeManager.EmployeeWorkingManager;
import com.csc.library.entity.manager.CompanyManager;
import com.csc.library.entity.manager.MemberManager;
import com.csc.library.status.StatusMessage;
import com.csc.library.training.utilitis.TimeUtils;
import com.csc.library.utilities.CSCCheckUtility;
import com.csc.library.utilities.CscCalendar;
import com.csc.library.utilities.FileUtils;
import com.csc.library.utilities.MyLog;
import com.csc.library.validator.EmailValidator;
import th.co.csc.apimodel.common.FaceTemplateCommonModel;
import th.co.csc.apimodel.request.ApplyCompanyRequestModel;
import th.co.csc.apimodel.request.RegisterNewEmployeeRequestModel;
import th.co.csc.apimodel.request.RegisterRequestModel;
public class ImportEmpManager {
private static ImportEmpManager imp ;
private String company ;
private EmailValidator emailValidator = EmailValidator.getInstance();
private CompanyManager cm = GetCdiInstance.of(CompanyManager.class);
private EmployeeWorkingManager ewManager = GetCdiInstance.of(EmployeeWorkingManager.class);
private CompanyProfile cpf ;
private HashMap<String,String> hsBossList = new HashMap<String,String>();
public ImportEmpManager(){
}
public static ImportEmpManager newInstance(){
if(imp == null){
imp = new ImportEmpManager() ;
}
return imp ;
}
public boolean importFromFolder(String folder, String filetype, String backupfolder){
return process(folder, filetype, backupfolder);
}
private boolean process(String folder, String filetype, String backupfolder){
try {
File directory = new File(folder);
File[] fList = directory.listFiles();
String content = "";
for (File file : fList){
if (file.isFile() && file.getName().endsWith(filetype)) {
//try (BufferedReader br = new BufferedReader(new FileReader(file.getAbsolutePath()))) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file.getAbsolutePath()), "UTF-8"))){
while ((content = br.readLine()) != null) {
if(content != null && !content.equals("")){
save(content); /* raw data with '|' seperater column */
}else{
MyLog.debug(this, "!! data is empty !!");
}
}
} catch (IOException e) {
e.printStackTrace();
}
// set boss from legacy code
setZeeMeBossId();
//back up
FileUtils.backupFile(folder, file.getName(), "");
}
}
}catch(Exception e){
e.printStackTrace();
return false ;
}
return true ;
}
private boolean setZeeMeBossId(){
try {
CompanyEmployeeManager cem = GetCdiInstance.of(CompanyEmployeeManager.class);
if(company != null){
List<CompanyEmployeeProfile> ls = ewManager.getView().findEmployeeProfileByCompanyId(company);
ls.parallelStream().forEach(s -> {
setBossId(s, cem);
});
return true ;
}else{
MyLog.error(this, "!! companyid is null, bossmajor is not be set !!");
}
}catch(Exception e){
MyLog.error(this, e);
}
return false ;
}
private boolean setBossId(CompanyEmployeeProfile cp, CompanyEmployeeManager cem){
try {
boolean needsave = false ;
cp.setBossMajor(cpf.getOwnerId()); /*temporary*/
needsave = true ;
if(cp.getBossMajor() != null){
/*
if(cp.getBossMajor().length() < 20){
cp.setBossMajor(findMemberIdByEmployeeCode(cp.getCompanyID(), cp.getBossMajor(), cem));
needsave = true ;
}
if(cp.getBossMinor().length() < 20){
cp.setBossMinor(findMemberIdByEmployeeCode(cp.getCompanyID(), cp.getBossMinor(), cem));
needsave = true ;
}*/
if(needsave){
ewManager.getAction().saveEmployeeProfile(cp);
}
return true ;
}
}catch(Exception e){
MyLog.error(this, e);
}
return false ;
}
private String findMemberIdByEmployeeCode(String comp, String code, CompanyEmployeeManager cem){
try {
CompanyEmployeeProfile cp = ewManager.getView().getEmployeeProfileByEmployeeCode(comp, code);
if(cp != null){
return cp.getMemberID();
}
}catch(Exception e){
MyLog.error(this, e);
}
return "";
}
private void initCompany(EmployeeImpProp eip){
if(company == null) company = eip.getCompanyid();
}
private boolean save(String content){
try {
boolean m_complete = false ;
boolean c_complete = false ;
EmployeeImpProp eip = fetchRawData(content);
if(eip != null){
initCompany(eip);
MemberProfile mb = getExistMember(eip);
// temporay set default
/*
if(mb!=null && !CSCCheckUtility.isBlankOrNull(eip.getEmail()) && !emailValidator.isValid(eip.getEmail())){
if(!mb.getEmailname().equals("")){
eip.setEmail(mb.getEmailname());
}
}*/
//create member when non exist
if((mb == null || mb.getMemberid().equals("")) && !CSCCheckUtility.isBlankOrNull(eip.getEmail())
&& emailValidator.isValid(eip.getEmail())){
mb = createMember(eip); // create member
if(mb != null){
m_complete = true ;
}
}else{
if(!mb.getMemberid().equals("")){
MyLog.debug(this, "!! member already exist !!");
}else if(!CSCCheckUtility.isBlankOrNull(eip.getEmail())) {
MyLog.debug(this , "!! invalid email, this member will not be create " + eip.getEmployeeid() + ":" + eip.getEmail());
}else{
MyLog.debug(this, "!! invalid data, member will not be create " + eip.getEmployeeid());
}
}
// if found or gen member is success
if(mb != null){
c_complete = createCompanyEmployee(eip, mb); // create or update company employee
}else{
MyLog.debug(this, "!! save member incomplete, transaction rollback ");
}
}
if(c_complete){
return true;
}
}catch(Exception e){
System.out.print(e.getMessage());
return false ;
}
return false;
}
private MemberProfile getExistMember(EmployeeImpProp eip){
try {
MemberManager mm = GetCdiInstance.of(MemberManager.class);
MemberProfile m = null;
if(!eip.getPersonal_id().equals("")){
m = mm.getMemberProfileByPeopleId(eip.getPersonal_id());
}else if(!eip.getPassportid().equals("")){
m = mm.getMemberProfileByPeopleId(eip.getPassportid());
}
if(m == null && !eip.getEmail().equals("")){
m = mm.getMemberProfileByEmailname(eip.getEmail());
}
return m ;
}catch(Exception e){
MyLog.error(this, e);
}
return null ;
}
/* convert raw data from file into EmployeeImpProp */
private EmployeeImpProp fetchRawData(String content){
return new EmployeeImpProp(content);
}
private ApplyCompanyRequestModel getRegisterRequestModel(EmployeeImpProp eip, MemberProfile mb){
try {
ApplyCompanyRequestModel rr = new ApplyCompanyRequestModel();
rr.setCompanyId(eip.getCompanyid());
rr.setBranchId(eip.getBranch());
rr.setMemberId(mb.getMemberid());
//rr.setEmployeeCode(eip.getEmployeeid()); // let system auto gen employeecode
rr.setPositionName(eip.getPosition());
rr.setApplyStatus("0");
rr.setApplyDate(new CscCalendar().getDatetimeFormat());
rr.setDepartmentName(eip.getDepartment());
rr.setJointType(0);
rr.setBossMajarId(eip.getBossid_1());
return rr ;
}catch(Exception e){
MyLog.error(this, e);
}
return null ;
}
private RegisterRequestModel getMemberRegisterModel(EmployeeImpProp eip, MemberProfile mb){
try {
RegisterRequestModel rr = new RegisterRequestModel();
rr.setFirstName(eip.getFirstName());
rr.setLastName(eip.getLastName());
rr.setMobileNumber(eip.getTelephone());
rr.setSex(Integer.parseInt(eip.getGender()));
rr.setEmail(eip.getEmail());
rr.setPassword(genPasswordWithBirthday(eip.getBirthday()));
rr.setBirthDate(eip.getBirthday());
rr.setIdCard(eip.getPersonal_id());
rr.setPassportNo(eip.getPassportid());
rr.setNationality(eip.getNationality());
rr.setProfilePhoto(new byte[0]);
rr.setDeviceName("import");
/* template */
FaceTemplateCommonModel fc = new FaceTemplateCommonModel();
fc.setEnrollPhoto(new byte[0]);
fc.setEyesTemplate1(new byte[0]);
fc.setEyesTemplate2(new byte[0]);
fc.setEyesTemplate3(new byte[0]);
fc.setFacialTemplate1(new byte[0]);
fc.setFacialTemplate2(new byte[0]);
fc.setFacialTemplate3(new byte[0]);
fc.setEnrollPhotoFileName("");
fc.setFacialTemplate1FileName("");
fc.setFacialTemplate2FileName("");
fc.setFacialTemplate3FileName("");
fc.setEyesTemplate1FileName("");
fc.setEyesTemplate2FileName("");
fc.setEyesTemplate3FileName("");
rr.setFaceTemplate(fc);
return rr ;
}catch(Exception e){
MyLog.error(this, e);
}
return null ;
}
private boolean isCompEmpExist(EmployeeImpProp eip, MemberProfile mb){
try {
CompanyEmployeeManager cem = GetCdiInstance.of(CompanyEmployeeManager.class);
CompanyEmployeeProfile cep = ewManager.getView().getEmployeeProfile(eip.getCompanyid(), mb.getMemberid(), eip.getEmployeeid());
if(cep != null){
return true ;
}
}catch(Exception e){
e.printStackTrace();
}
return false ;
}
private boolean createCompanyEmployee(EmployeeImpProp eip, MemberProfile mb){
try {
//if(isCompEmpExist(eip, mb)){
if(eip != null && !eip.getEmployeeid().equals("")){
/* set company */
/*
if(company == null){
company = ConnectorUtility.getCompCode(eip.getCompanyid());
}*/
if(cpf == null){
cpf = cm.getCompanyProfileByCompanyId(eip.getCompanyid());
}
if(cpf != null){
RegisterNewEmployeeRequestModel rnrm = new RegisterNewEmployeeRequestModel();
rnrm.setApplyCompanyModel(getRegisterRequestModel(eip, mb));
rnrm.setMemberRegisterModel(getMemberRegisterModel(eip, mb));
GenerateCompanyEmployee gce = new GenerateCompanyEmployee();
gce.process(rnrm,eip,mb,cpf);
CompanyEmployeeProfile cp = ewManager.getView().getEmployeeProfile(eip.getCompanyid(), mb.getMemberid());
cp.setLagacyCode(eip.getEmployeeid());
ewManager.getAction().saveEmployeeProfile(cp);
return true ;
}else{
MyLog.debug(this, "!! company not found, employee will not be insert to companyemployee");
}
}else{
MyLog.debug(this, "!! employee data is blank ");
}
}catch(Exception e){
e.printStackTrace();
}
return false ;
}
private Member createMember(EmployeeImpProp eip){
try {
MemberManager mbm = GetCdiInstance.of(MemberManager.class);
Member mp = mbm.createMemberInstance();
mp.setFirstname(eip.getFirstName());
mp.setLastname(eip.getLastName());
mp.setIdpeople(eip.getPersonal_id());
mp.setPassportno(eip.getPassportid());
mp.setBirthday(TimeUtils.getYYYYMMDD(eip.getBirthday()));
mp.setEmailname(eip.getEmail());
mp.setNationality(eip.getNationality());
mp.setSex(Sex.getSex(eip.convertGender()));
mp.setTelnumber(eip.getTelephone());
mp.setPassword(genPassword(eip));
FileStore fs = GetCdiInstance.of(FileStore.class);
mp.setFileStoreEyetemplate1(fs);
mp.setFileStoreEyetemplate2(fs);
mp.setFileStoreEyetemplate3(fs);
mp.setFileStoreFacialtemplate1(fs);
mp.setFileStoreFacialtemplate2(fs);
mp.setFileStoreFacialtemplate1(fs);
StatusMessage sm = mbm.saveMember(mp);
return mp ;
}catch(Exception e){
MyLog.error(this, e);
}
MyLog.debug(this, "!! could not create member : " + eip.getEmployeeid()) ;
return null ;
}
private String genPassword(EmployeeImpProp eip){
try {
GenPassword gp = new GenPassword();
return gp.genPassword(eip);
}catch(Exception e){
MyLog.error(this, e);
}
return eip.getPersonal_id() ;
}
private boolean isBossCodeExist(String boss){
try {
if(hsBossList.containsKey(boss)){
return true ;
}
}catch(Exception e){
MyLog.error(this, e);
}
return false ;
}
private String getBossCode(String boss){
return hsBossList.get(boss);
}
private String genPasswordWithBirthday(String birthdate){
String DASH = "-" ;
String SLASH = "/" ;
try {
String tt[] = {"1234","",""} ;
if(birthdate.indexOf(DASH) > 0) {
tt = birthdate.split(DASH) ;
}else if(birthdate.indexOf(DASH) > 0) {
tt = birthdate.split(SLASH) ;
}
return tt[2] + tt[1] + tt[0] ; // DDMMYYYY
}catch(Exception e){
MyLog.error(this, e);
}
return "1234" ;
}
}
package com.csc.library.process;
import com.csc.library.cinterface.ImportFromTrdInterface;
import com.csc.library.csecurity.CSecurity;
import com.csc.library.ftp.ConnectProp;
import com.csc.library.resource.SystemConfig;
import com.csc.library.utilities.FileUtils;
public class UpdateEmpFromTrdParty extends UpdateFromTRDParty {
ConnectProp cnp ;
public UpdateEmpFromTrdParty(){
}
public boolean process(String comp){
try {
initConfig(comp);
if(loadFile(cnp)){
updateEmpFromFile();
}
}catch(Exception e){
e.printStackTrace();
return false ;
}
return true ;
}
public boolean initConfig(String comp){
try {
ImportFromTrdInterface ift = SystemConfig.getImportFromTrdInstance(comp);
cnp = new ConnectProp();
cnp.setAddress(ift.getEmpSourceURL());
cnp.setUsername(ift.getEmpUserName());
cnp.setPassword(CSecurity.newInstance().decrypt(ift.getEmpPassword()));
cnp.setFilename(ift.getEmpSourceFileName());
cnp.setProtocol(ift.getEmpProtocol());
cnp.setPort(ift.getEmpSourcePort());
cnp.setDirectory(ift.getEmpSourceDirectory());
cnp.setTargetFolder(FileUtils.getCanonicalPath()
+ "/"
+ ift.getEmpTargetFolder());
cnp.setTargetSubfolder(ift.getEmpTargetSubFolder());
cnp.setTarget(FileUtils.getCanonicalPath()
+ "/"
+ ift.getEmpTargetFolder()
+ ift.getEmpTargetSubFolder());
}catch(Exception e){
e.printStackTrace();
return false ;
}
return true ;
}
public boolean updateEmpFromFile(){
try {
ImportEmpManager imp = ImportEmpManager.newInstance() ;
imp.importFromFolder(cnp.getTarget(), ".txt", cnp.getTarget());
}catch(Exception e){
e.printStackTrace();
return false;
}
return true ;
}
}
package com.csc.library.process;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import com.csc.library.ftp.ConnectProp;
import com.csc.library.ftp.FTPManager;
import com.csc.library.training.utilitis.TimeUtils;
import com.csc.library.utilities.FileUtils;
import com.csc.library.utilities.MyLog;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
public class UpdateFromTRDParty {
public boolean loadFile(ConnectProp cnp){
try {
if(cnp.getProtocol().equals("FTP")){
return loadFileFTP(cnp);
}else if(cnp.getProtocol().equals("SFTP")){
return loadFileSFTP(cnp);
}
}catch(Exception e){
MyLog.error(this, e);
}
return false ;
}
public boolean loadFileFTP(ConnectProp cn){
try {
FTPManager ftm = new FTPManager();
if(!ftm.downloadAll(cn, cn.getTarget(), "")){
System.out.print("error : download failed");
return false ;
}
}catch(Exception e){
e.printStackTrace();
return false ;
}
return true ;
}
public boolean loadFileSFTP(ConnectProp cn){
Session session = null;
Channel channel = null;
ChannelSftp channelSftp = null;
BufferedInputStream bis = null;
OutputStream os = null;
BufferedOutputStream bos = null;
try {
String SFTPHOST = cn.getAddress();
int SFTPPORT = Integer.parseInt(cn.getPort());
String SFTPUSER = cn.getUsername();
String SFTPPASS = cn.getPassword();
String SFTPWORKINGDIR = cn.getDirectory();
JSch jsch = new JSch();
session = jsch.getSession(SFTPUSER, SFTPHOST, SFTPPORT);
session.setPassword(SFTPPASS);
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
channel = session.openChannel("sftp");
channel.connect();
channelSftp = (ChannelSftp) channel;
channelSftp.cd(SFTPWORKINGDIR);
byte[] buffer = new byte[1024];
bis = new BufferedInputStream(channelSftp.get(cn.getFilename()));
/*target main folder*/
if(FileUtils.folderExist(cn.getTargetFolder())){
if(FileUtils.folderExist(cn.getTarget())){
File newFile = new File(cn.getTarget() + "/" + cn.getFilename());
os = new FileOutputStream(newFile);
bos = new BufferedOutputStream(os);
int readCount;
while ((readCount = bis.read(buffer)) > 0) {
bos.write(buffer, 0, readCount);
}
}
}
MyLog.debug(this, "! Load file successful !");
return true ;
} catch (Exception ex) {
ex.printStackTrace();
}finally{
try {
bis.close();
bos.close();
}catch(Exception e){
MyLog.error(this, e);
}
}
return false ;
}
}
package com.csc.library.training.controller;
public interface EmpCourseImportField {
public int COMPANYID = 0 ;
public int TRAININGID = 1 ;
public int COURSEID = 2 ;
public int SESSION = 3 ;
public int LEGACYCODE = 4 ;
}
package com.csc.library.training.controller;
import com.csc.library.utilities.CheckNull;
import com.csc.library.utilities.MyLog;
public class EmpCourseProp implements EmpCourseImportField {
private String companyid ;
private String trainingid ;
private String courseid ;
private String sessid ;
private String legacycode ;
public static EmpCourseProp newInstance(String content){
EmpCourseProp tp = new EmpCourseProp();
tp.init(content);
return tp;
}
private void init(String raw){
try {
String ls[] = raw.split("\\|");
setCompanyid(getStringData(ls,COMPANYID));
setTrainingid(getStringData(ls,TRAININGID));
setCourseid(getStringData(ls,COURSEID));
setSessid(getStringData(ls,SESSION));
setLegacycode(getStringData(ls, LEGACYCODE));
}catch(Exception e){
MyLog.error(this, e);
}
}
private String getStringData(String arr[], int index){
try {
return CheckNull.getInstance().chkNullString(arr[index]);
}catch(Exception e){
MyLog.error(this, "!! index out of bound : " + index + " >> " + arr);
}
return "";
}
public String getCompanyid() {
return companyid;
}
public void setCompanyid(String companyid) {
this.companyid = companyid;
}
public String getTrainingid() {
return trainingid;
}
public void setTrainingid(String trainingid) {
this.trainingid = trainingid;
}
public String getCourseid() {
return courseid;
}
public void setCourseid(String courseid) {
this.courseid = courseid;
}
public String getSessid() {
return sessid;
}
public void setSessid(String sessid) {
this.sessid = sessid;
}
public String getLegacycode() {
return legacycode;
}
public void setLegacycode(String legacycode) {
this.legacycode = legacycode;
}
}
package com.csc.library.training.controller;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import com.csc.library.cdi.GetCdiInstance;
import com.csc.library.entity.CompanyEmployeeProfile;
import com.csc.library.entity.TrainingCourse;
import com.csc.library.entity.TrainingCourseManager;
import com.csc.library.status.StatusMessage;
import com.csc.library.utilities.ConnectorUtility;
import com.csc.library.utilities.FileUtils;
import com.csc.library.utilities.MyLog;
public class ImportCourse {
private TrainingCourseManager cem = GetCdiInstance.of(TrainingCourseManager.class);
public static ImportCourse newInstance(){
return new ImportCourse();
}
public boolean importFromFolder(String folder, String filetype, String backupfolder){
try {
File directory = new File(folder);
File[] fList = directory.listFiles();
String content = "";
for (File file : fList){
if (file.isFile() && file.getName().endsWith(filetype)) {
try (BufferedReader br = new BufferedReader(new FileReader(file.getAbsolutePath()))) {
while ((content = br.readLine()) != null) {
System.out.println(content);
if(content != null && !content.equals("")){
save(content); /* raw data with '|' seperater column */
}else{
MyLog.debug(this, "!! data is empty !!");
}
}
} catch (IOException e) {
e.printStackTrace();
}
FileUtils.backupFile(folder, file.getName(), "");
}
}
}catch(Exception e){
e.printStackTrace();
return false ;
}
return true ;
}
@SuppressWarnings("unused")
private boolean save(String content){
try {
TrainingProp tp = fetchRawData(content);
if(createCourse(tp)){ /* create or update company employee */
return true;
}
}catch(Exception e){
System.out.print(e.getMessage());
}
return false;
}
/* convert raw data from file into EmployeeImpProp */
private TrainingProp fetchRawData(String content){
try {
return TrainingProp.newInstance(content);
}catch(Exception e){
MyLog.error(this, e);
}
return null ;
}
private boolean createCourse(TrainingProp trc){
try {
if(trc != null && !trc.getTrainingid().equals("")){
TrainingCourse ce = cem.createInstance(ConnectorUtility.getCompCode(trc.getCompanyid())
,trc.getTrainingid()
,trc.getCourseid()
,trc.getSessid());
ce.setTitle(trc.getTitle());
ce.setLocation(trc.getLocation());
ce.setStartdate(trc.getStartdate());
ce.setStarttime(trc.getStarttime());
ce.setEnddate(trc.getEnddate());
ce.setEndtime(trc.getEndtime());
ce.setTrainer(trc.getTrainer());
ce.setDescription(trc.getDesc());
ce.setStatus(trc.getStatus());
ce.setObjective(trc.getObjective());
ce.setReservstartdate(trc.getRstartdate());
ce.setReservstarttime(trc.getStarttime());
ce.setReservenddate(trc.getRenddate());
ce.setReservendtime(trc.getRendtime());
ce.setPunchbefore(trc.getPunchbefore());
ce.setPunchafter(trc.getPunchafter());
ce.setPicture(trc.getPicture());
ce.setSourcedownloadlink(trc.getSourcelink());
ce.setVideolink(trc.getVideolink());
StatusMessage sm = cem.save(ce);
return true ;
}else{
MyLog.debug(this, "!! employee data is blank ");
}
}catch(Exception e){
e.printStackTrace();
}
return false ;
}
private HashMap<String, String> createMapping(List<CompanyEmployeeProfile> cp){
HashMap<String, String> hm = new HashMap<String, String>();
try {
for(CompanyEmployeeProfile i: cp){
hm.put(i.getEmployeeCode(), i.getMemberID());
}
}catch(Exception e){
MyLog.error(this, e);
}
return hm ;
}
private String findMemberIdByEmployeeCode(String code, HashMap<String,String> emplist){
try {
if(emplist.get(code) != null){
return emplist.get(code);
}
}catch(Exception e){
MyLog.error(this, e);
}
return "";
}
}
package com.csc.library.training.controller;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import com.csc.library.cdi.GetCdiInstance;
import com.csc.library.entity.CompanyEmployeeProfile;
import com.csc.library.entity.Trainee;
import com.csc.library.entity.TraineeManager;
import com.csc.library.entity.TrainingCourse;
import com.csc.library.entity.TrainingCourseManager;
import com.csc.library.entity.manager.CompanyEmployeeManager.EmployeeWorkingManager;
import com.csc.library.status.StatusMessage;
import com.csc.library.training.utilitis.TimeUtils;
import com.csc.library.utilities.ConnectorUtility;
import com.csc.library.utilities.CscCalendar;
import com.csc.library.utilities.FileUtils;
import com.csc.library.utilities.MyLog;
public class ImportEmpCourse {
private TraineeManager tm = GetCdiInstance.of(TraineeManager.class);
//private HashMap<String, TrainingCourse> hmCourse ;
private HashMap<String, MemberMapping> hmMember ; /*temporary*/
public static ImportEmpCourse newInstance(){
return new ImportEmpCourse();
}
public boolean importFromFolder(String folder, String filetype, String backupfolder){
try {
File directory = new File(folder);
File[] fList = directory.listFiles();
String content = "";
for (File file : fList){
if (file.isFile() && file.getName().endsWith(filetype)) {
try (BufferedReader br = new BufferedReader(new FileReader(file.getAbsolutePath()))) {
while ((content = br.readLine()) != null) {
System.out.println(content);
if(content != null && !content.equals("")){
save(content); /* raw data with '|' seperater column */
}else{
MyLog.debug(this, "!! data is empty !!");
}
}
} catch (IOException e) {
e.printStackTrace();
}
FileUtils.backupFile(folder, file.getName(), "");
}
}
}catch(Exception e){
e.printStackTrace();
return false ;
}
return true ;
}
@SuppressWarnings("unused")
private boolean save(String content){
try {
EmpCourseProp tp = fetchRawData(content);
if(createEmpCourse(tp)){ /* create or update employee course */
return true;
}
}catch(Exception e){
System.out.print(e.getMessage());
return false ;
}
return false;
}
/* convert raw data from file into EmployeeImpProp */
private EmpCourseProp fetchRawData(String content){
try {
return EmpCourseProp.newInstance(content);
}catch(Exception e){
MyLog.error(this, e);
}
return null ;
}
private MemberMapping getMemberByLegacyCode(String comp,String lg){
try {
/* temporary */
if(hmMember == null){
hmMember = new HashMap<String, MemberMapping>();
EmployeeWorkingManager ewManager = GetCdiInstance.of(EmployeeWorkingManager.class);
List<CompanyEmployeeProfile> lce = ewManager.getView().findEmployeeProfileByCompanyId(comp);
for(CompanyEmployeeProfile cp: lce){
hmMember.put(cp.getLagacyCode(), new MemberMapping(cp));
}
}
if(hmMember.containsKey(lg)){
return hmMember.get(lg);
}
/* end temporary */
/* for production */
/* need method from CompanyEmployeeManager to be called */
}catch(Exception e){
MyLog.error(this, e);
}
return null ;
}
private boolean createEmpCourse(EmpCourseProp trc){
try {
CscCalendar now = new CscCalendar();
if(trc != null && !trc.getTrainingid().equals("")){
MemberMapping mp = getMemberByLegacyCode(trc.getCompanyid(), trc.getLegacycode());
if(mp != null){
Trainee ce = tm.createInstance(ConnectorUtility.getCompCode(trc.getCompanyid())
,mp.getMemberid()
,ImportEmpCourse
.CourseFindingHandling.newInstance()
.getCourse(trc).getStartdate()
,trc.getTrainingid()
,trc.getCourseid()
,trc.getSessid());
ce.setStarttime(ImportEmpCourse
.CourseFindingHandling.newInstance()
.getCourse(trc).getStarttime());
ce.setEmployeeid(mp.getEmployeecode());
ce.setLegacycode(mp.getLegacycode());
ce.setStatus(Trainee.Status.Unread.getStatus());
ce.setEditby("ImportEmpCourse");
ce.setEditdate(TimeUtils.getYYYYMMDD(now));
ce.setEdittime(TimeUtils.getHHMMSS(now));
StatusMessage sm = tm.insert(ce);
sendNotification(ce
, ImportEmpCourse
.CourseFindingHandling.newInstance()
.getCourse(trc));/* send notification */
return true ;
}
}else{
MyLog.debug(this, "!! search member by legacy code not found ");
}
}catch(Exception e){
e.printStackTrace();
}
return false ;
}
/* send notification to mobile */
private void sendNotification(Trainee tn, TrainingCourse tc){
SendNewCourseNotification.newInstance().send(tn, tc);
}
private static class CourseFindingHandling {
private static HashMap<String, TrainingCourse> hmCourse ;
private static CourseFindingHandling cf = null ;
private TrainingCourseManager tcm = GetCdiInstance.of(TrainingCourseManager.class);
public static CourseFindingHandling newInstance(){
if(cf == null){
cf = new CourseFindingHandling();
}
if( hmCourse == null) {
hmCourse = new HashMap<String, TrainingCourse>();
}
return cf ;
}
public TrainingCourse getCourse(EmpCourseProp ecp){
try {
if(hmCourse.containsKey(genKey(ecp))){
return hmCourse.get(genKey(ecp));
}else{
TrainingCourse tc = tcm.getCourse(ecp.getCompanyid()
, ecp.getTrainingid()
, ecp.getCourseid()
, ecp.getSessid());
hmCourse.put(genKey(ecp), tc);
return tc ;
}
}catch(Exception e){
MyLog.error(this, e);
}
return null ;
}
private String genKey(EmpCourseProp ecp){
return ecp.getTrainingid() + ":" + ecp.getCourseid() + ":" + ecp.getSessid();
}
}
private class MemberMapping {
private String memberid ;
private String employeecode ;
private String legacycode ;
public MemberMapping(CompanyEmployeeProfile cep){
this.setMemberid(cep.getMemberID());
this.setEmployeecode(cep.getEmployeeCode());
this.setLegacycode(cep.getLagacyCode());
}
public String getMemberid() {
return memberid;
}
public void setMemberid(String memberid) {
this.memberid = memberid;
}
public String getEmployeecode() {
return employeecode;
}
public void setEmployeecode(String employeecode) {
this.employeecode = employeecode;
}
public String getLegacycode() {
return legacycode;
}
public void setLegacycode(String legacycode) {
this.legacycode = legacycode;
}
}
}
package com.csc.library.training.controller;
import javax.inject.Inject;
import com.csc.library.cdi.GetCdiInstance;
import com.csc.library.controller.NotificationController;
import com.csc.library.controller.NotificationController.NotificationResult;
import com.csc.library.entity.Trainee;
import com.csc.library.entity.TrainingCourse;
import com.csc.library.status.StatusResultMessage;
import com.csc.library.training.utilitis.TimeUtils;
import com.csc.library.utilities.CscCalendar;
import com.csc.library.utilities.MyLog;
public class SendNewCourseNotification {
private NotificationController notifiedController ;
public static SendNewCourseNotification sn ;
public static SendNewCourseNotification newInstance(){
if(sn == null) {
sn = new SendNewCourseNotification();
}
return sn ;
}
public void send(Trainee te, TrainingCourse tc){
try {
CourseNotificationModel model = new CourseNotificationModel();
model.setCompanyId(te.getCompanyid());
model.setMemberId(te.getMemberid());
CscCalendar cs = TimeUtils.getCscCalendar(tc.getStartdate(), tc.getStarttime());
CscCalendar ce = TimeUtils.getCscCalendar(tc.getEnddate(), tc.getEndtime());
model.setStartDate(TimeUtils.getDDMMYYYY(cs));
model.setStartTime(TimeUtils.getHHMM(cs));
model.setEndDate(TimeUtils.getDDMMYYYY(ce));
model.setEndTime(TimeUtils.getHHMM(ce));
model.setTitle(tc.getTitle());
/*
notifiedController = GetCdiInstance.of(NotificationController.class);
notifiedController.createNotificationBuilder()
*/
//StatusResultMessage<NotificationResult> srm =
// notifiedController.createNotificationBuilder(NotificationMode.N02)
// .setTitle("Course Available : " + model.getTitle())
// .setBody(model.getStartDate() + " " + model.getStartTime() + "-" + model.getEndTime())
// .setData(model)
// .pushNotifiedToEmployeeHost(model.getCompanyId(), model.getMemberId());
}catch(Exception e){
MyLog.error(this, e);
}
}
public class CourseNotificationModel{
private String CompanyId ;
private String MemberId ;
private String StartDate ;
private String StartTime ;
private String EndDate ;
private String EndTime ;
private String Title ;
public String getCompanyId() {
return CompanyId;
}
public void setCompanyId(String companyId) {
CompanyId = companyId;
}
public String getMemberId() {
return MemberId;
}
public void setMemberId(String memberId) {
MemberId = memberId;
}
public String getStartDate() {
return StartDate;
}
public void setStartDate(String startDate) {
StartDate = startDate;
}
public String getStartTime() {
return StartTime;
}
public void setStartTime(String startTime) {
StartTime = startTime;
}
public String getEndDate() {
return EndDate;
}
public void setEndDate(String endDate) {
EndDate = endDate;
}
public String getEndTime() {
return EndTime;
}
public void setEndTime(String endTime) {
EndTime = endTime;
}
public String getTitle() {
return Title;
}
public void setTitle(String title) {
Title = title;
}
}
}
package com.csc.library.training.controller;
public interface TrainingImportField {
public int COMPANYID = 0 ;
public int TRAININGID = 1 ;
public int COURSEID = 2 ;
public int SESSION = 3 ;
public int TITLE = 4 ;
public int LOCATION = 5 ;
public int STARTDATE = 6 ;
public int STARTTIME = 7 ;
public int ENDDATE = 8 ;
public int ENDTIME = 9 ;
public int TRAINER = 10 ;
public int DESC = 11 ;
public int STATUS = 12 ;
public int OBJECTIVE = 13 ;
public int RSTARTDATE = 14 ;
public int RSTARTTIME = 15 ;
public int RENDDATE = 16 ;
public int RENDTIME = 17 ;
public int PUNCHBEFORE = 18 ;
public int PUNCHAFTER = 19 ;
public int PICTURE = 20 ;
public int SOURCELINK = 21 ;
public int VIDEOLINK = 22 ;
}
package com.csc.library.training.controller;
import com.csc.library.utilities.CheckNull;
import com.csc.library.utilities.MyLog;
public class TrainingProp implements TrainingImportField {
private String companyid ;
private String trainingid ;
private String courseid ;
private String title ;
private String sessid ;
private String location ;
private String startdate ;
private String starttime ;
private String enddate ;
private String endtime ;
private String rstartdate ;
private String rstarttime ;
private String renddate ;
private String rendtime ;
private String punchbefore ;
private String punchafter ;
private String trainer ;
private String desc ;
private String status ;
private String objective ;
private String picture ;
private String sourcelink ;
private String videolink ;
public static TrainingProp newInstance(String content){
TrainingProp tp = new TrainingProp();
tp.init(content);
return tp;
}
private void init(String raw){
try {
String ls[] = raw.split("\\|");
if(ls.length >= OBJECTIVE){
setCompanyid(getStringData(ls,COMPANYID));
setTrainingid(getStringData(ls,TRAININGID));
setCourseid(getStringData(ls,COURSEID));
setTitle(getStringData(ls,TITLE));
setSessid(getStringData(ls,SESSION));
setLocation(getStringData(ls,LOCATION));
setStartdate(getStringData(ls,STARTDATE));
setStarttime(getStringData(ls,STARTTIME));
setEnddate(getStringData(ls,ENDDATE));
setEndtime(getStringData(ls,ENDTIME));
setTrainer(getStringData(ls,TRAINER));
setDesc(getStringData(ls,DESC));
setStatus(getStringData(ls,STATUS));
setObjective(getStringData(ls,OBJECTIVE));
if(ls.length >= RSTARTDATE){
setRstartdate(getStringData(ls,RSTARTDATE));
}
if(ls.length >= RSTARTTIME){
setRstarttime(getStringData(ls,RSTARTTIME));
}
if(ls.length >= RENDDATE){
setRenddate(getStringData(ls,RENDDATE));
}
if(ls.length >= RENDTIME){
setRendtime(getStringData(ls,RENDTIME));
}
if(ls.length >= PUNCHBEFORE){
setPunchbefore(getStringData(ls,PUNCHBEFORE));
}
if(ls.length >= PUNCHAFTER){
setPunchafter(getStringData(ls,PUNCHAFTER));
}
if(ls.length >= PICTURE){
setPicture(getStringData(ls,PICTURE));
}
if(ls.length >= SOURCELINK){
setSourcelink(getStringData(ls,SOURCELINK));
}
if(ls.length >= VIDEOLINK){
setVideolink(getStringData(ls,VIDEOLINK));
}
}else{
MyLog.error(this, "!! data has invalid columns !! " + raw);
}
}catch(Exception e){
MyLog.error(this, e);
}
}
private String getStringData(String arr[], int index){
try {
return CheckNull.getInstance().chkNullString(arr[index]);
}catch(Exception e){
MyLog.error(this, "!! index out of bound : " + index + " >> " + arr);
}
return "";
}
public String getCompanyid() {
return companyid;
}
public void setCompanyid(String companyid) {
this.companyid = companyid;
}
public String getTrainingid() {
return trainingid;
}
public void setTrainingid(String trainingid) {
this.trainingid = trainingid;
}
public String getCourseid() {
return courseid;
}
public void setCourseid(String courseid) {
this.courseid = courseid;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getSessid() {
return sessid;
}
public void setSessid(String sessid) {
this.sessid = sessid;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getStartdate() {
return startdate;
}
public void setStartdate(String startdate) {
this.startdate = startdate;
}
public String getStarttime() {
return starttime;
}
public void setStarttime(String starttime) {
this.starttime = starttime;
}
public String getEnddate() {
return enddate;
}
public void setEnddate(String enddate) {
this.enddate = enddate;
}
public String getEndtime() {
return endtime;
}
public void setEndtime(String endtime) {
this.endtime = endtime;
}
public String getRstartdate() {
return rstartdate;
}
public void setRstartdate(String rstartdate) {
this.rstartdate = rstartdate;
}
public String getRstarttime() {
return rstarttime;
}
public void setRstarttime(String rstarttime) {
this.rstarttime = rstarttime;
}
public String getRenddate() {
return renddate;
}
public void setRenddate(String renddate) {
this.renddate = renddate;
}
public String getRendtime() {
return rendtime;
}
public void setRendtime(String rendtime) {
this.rendtime = rendtime;
}
public String getPunchbefore() {
return punchbefore;
}
public void setPunchbefore(String punchbefore) {
this.punchbefore = punchbefore;
}
public String getPunchafter() {
return punchafter;
}
public void setPunchafter(String punchafter) {
this.punchafter = punchafter;
}
public String getTrainer() {
return trainer;
}
public void setTrainer(String trainer) {
this.trainer = trainer;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getObjective() {
return objective;
}
public void setObjective(String objective) {
this.objective = objective;
}
public String getPicture() {
return picture;
}
public void setPicture(String picture) {
this.picture = picture;
}
public String getSourcelink() {
return sourcelink;
}
public void setSourcelink(String sourcelink) {
this.sourcelink = sourcelink;
}
public String getVideolink() {
return videolink;
}
public void setVideolink(String videolink) {
this.videolink = videolink;
}
}
package com.csc.library.training.controller;
import com.csc.library.cinterface.ImportFromTrdInterface;
import com.csc.library.csecurity.CSecurity;
import com.csc.library.ftp.ConnectProp;
import com.csc.library.process.UpdateFromTRDParty;
import com.csc.library.resource.SystemConfig;
import com.csc.library.utilities.FileUtils;
public class UpdateCourseFromTrdParty extends UpdateFromTRDParty {
ConnectProp cnp ;
public UpdateCourseFromTrdParty(){
}
public boolean process(String comp){
try {
initConfig(comp);
if(loadFile(cnp)){
updateCourseFromFile();
}
}catch(Exception e){
e.printStackTrace();
return false ;
}
return true ;
}
public boolean initConfig(String comp){
try {
ImportFromTrdInterface ift = SystemConfig.getImportFromTrdInstance(comp);
cnp = new ConnectProp();
cnp.setAddress(ift.getCourseSourceURL());
cnp.setUsername(ift.getCourseUserName());
cnp.setPassword(CSecurity.newInstance().decrypt(ift.getCoursePassword()));
cnp.setFilename(ift.getCourseSourceFileName());
cnp.setProtocol(ift.getCourseProtocol());
cnp.setPort(ift.getCourseSourcePort());
cnp.setDirectory(ift.getCourseSourceDirectory());
cnp.setTargetFolder(FileUtils.getCanonicalPath()
+ "/"
+ ift.getCourseTargetFolder() );
cnp.setTargetSubfolder(ift.getCourseTargetSubFolder());
cnp.setTarget(FileUtils.getCanonicalPath()
+ "/"
+ ift.getCourseTargetFolder()
+ ift.getCourseTargetSubFolder());
}catch(Exception e){
e.printStackTrace();
return false ;
}
return true ;
}
public boolean updateCourseFromFile(){
try {
ImportCourse imp = ImportCourse.newInstance() ;
imp.importFromFolder(cnp.getTarget(), ".txt", cnp.getTarget());
}catch(Exception e){
e.printStackTrace();
return false;
}
return true ;
}
}
package com.csc.library.training.controller;
import com.csc.library.cinterface.ImportFromTrdInterface;
import com.csc.library.csecurity.CSecurity;
import com.csc.library.ftp.ConnectProp;
import com.csc.library.process.UpdateFromTRDParty;
import com.csc.library.resource.SystemConfig;
import com.csc.library.utilities.FileUtils;
public class UpdateEmpCourseFromTrdParty extends UpdateFromTRDParty {
ConnectProp cnp ;
public UpdateEmpCourseFromTrdParty(){
}
public boolean process(String comp){
try {
initConfig(comp);
if(loadFile(cnp)){
updateEmpCourseFromFile();
}
}catch(Exception e){
e.printStackTrace();
return false ;
}
return true ;
}
public boolean initConfig(String comp){
try {
ImportFromTrdInterface ift = SystemConfig.getImportFromTrdInstance(comp);
cnp = new ConnectProp();
cnp.setAddress(ift.getCourseSourceURL());
cnp.setUsername(ift.getCourseUserName());
cnp.setPassword(CSecurity.newInstance().decrypt(ift.getCoursePassword()));
cnp.setFilename(ift.getEmpCourseSourceFilename());
cnp.setProtocol(ift.getCourseProtocol());
cnp.setPort(ift.getCourseSourcePort());
cnp.setDirectory(ift.getCourseSourceDirectory());
cnp.setTargetFolder(FileUtils.getCanonicalPath()
+ "/"
+ ift.getCourseTargetFolder() );
cnp.setTargetSubfolder(ift.getEmpCourseTargetSubFolder());
cnp.setTarget(FileUtils.getCanonicalPath()
+ "/"
+ ift.getCourseTargetFolder()
+ ift.getEmpCourseTargetSubFolder());
}catch(Exception e){
e.printStackTrace();
return false ;
}
return true ;
}
public boolean updateEmpCourseFromFile(){
try {
ImportEmpCourse imp = ImportEmpCourse.newInstance();
imp.importFromFolder(cnp.getTarget(), ".txt", cnp.getTarget());
}catch(Exception e){
e.printStackTrace();
return false;
}
return true ;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<!--
<alternatives>
<class>com.csc.library.test.SimpleManager</class>
</alternatives>
-->
</beans>
\ No newline at end of file
Manifest-Version: 1.0
Built-By: Destiny
Build-Jdk: 1.8.0_65
Created-By: Maven Integration for Eclipse
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<!--
<alternatives>
<class>com.csc.library.test.SimpleManager</class>
</alternatives>
-->
</beans>
\ No newline at end of file
#Generated by Maven Integration for Eclipse
#Fri Jan 19 17:11:08 ICT 2018
version=0.0.1-SNAPSHOT
groupId=com.csc.library
m2e.projectName=ZM-CTraining
m2e.projectLocation=D\:\\eclipse-workspace\\csc-dev1\\ZM-CTraining
artifactId=ZM-CTraining
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>ZM-CTraining</artifactId>
<version>${version.zm-ctraining}</version>
<name>Zeeme Training</name>
<dependencies>
<!-- time utils -->
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-TimeUtils</artifactId>
<version>${version.zm-timeutils}</version>
</dependency>
<!-- Training -->
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-DataBean-Training</artifactId>
<version>${version.zm-databean-training}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-Datasource-Cassandra-Training</artifactId>
<version>${version.zm-datasource-cassandra-training}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-Training-API</artifactId>
<version>${version.zm-training-api}</version>
</dependency>
<!-- cftp -->
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-CFTP</artifactId>
<version>${version.zm-cftp}</version>
</dependency>
<!-- csc system -->
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-CscSystem</artifactId>
<version>${version.zm-cscsystem}</version>
</dependency>
<!-- core -->
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-DataBean-company</artifactId>
<version>${version.zm-databean-company}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-Datasource-cassandra-company</artifactId>
<version>${version.zm-datasource-cassandra-company}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-Cassandra-core</artifactId>
<version>${version.zm-cassandra-core}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-Datasource-cassandra-core</artifactId>
<version>${version.zm-datasource-cassandra-core}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-DataBean-core</artifactId>
<version>${version.zm-databean-core}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-Apis</artifactId>
<version>${version.zm-api}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
<!-- export time att -->
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-ExportTimeAtt</artifactId>
<version>${version.zm-exporttimeatt}</version>
</dependency>
<dependency>
<groupId>com.csc.library</groupId>
<artifactId>ZM-CscWebsocketApi</artifactId>
<version>${version.zm-cscwebsocket-api}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${version.java-servlet-api}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<parent>
<groupId>com.csc.library</groupId>
<artifactId>csc-dev1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
</project>
\ No newline at end of file
#Generated by Maven
#Fri Jan 19 17:10:55 ICT 2018
version=0.0.1-SNAPSHOT
groupId=com.csc.library
artifactId=ZM-CTraining
com\csc\library\training\controller\SendNewCourseNotification$CourseNotificationModel.class
com\csc\library\process\CourseImpProp.class
com\csc\library\process\ImportCourseManager.class
com\csc\library\training\controller\UpdateEmpCourseFromTrdParty.class
com\csc\library\process\GenPassword.class
com\csc\library\process\ImportEmpManager.class
com\csc\library\training\controller\TrainingImportField.class
com\csc\library\training\controller\ImportEmpCourse$MemberMapping.class
com\csc\library\process\EmployeeImpProp.class
com\csc\library\training\controller\UpdateCourseFromTrdParty.class
com\csc\library\process\CourseImportField.class
com\csc\library\training\controller\ImportCourse.class
com\csc\library\training\controller\EmpCourseImportField.class
com\csc\library\training\controller\TrainingProp.class
com\csc\library\process\GenerateCompanyEmployee.class
com\csc\library\training\controller\SendNewCourseNotification.class
com\csc\library\training\controller\ImportEmpCourse$CourseFindingHandling.class
com\csc\library\process\EmployeeImportField.class
com\csc\library\training\controller\ImportEmpCourse.class
com\csc\library\process\UpdateEmpFromTrdParty.class
com\csc\library\training\controller\EmpCourseProp.class
com\csc\library\process\UpdateFromTRDParty.class
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\training\controller\ImportEmpCourse.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\process\GenPassword.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\process\UpdateEmpFromTrdParty.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\process\UpdateFromTRDParty.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\training\controller\SendNewCourseNotification.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\training\controller\UpdateCourseFromTrdParty.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\process\EmployeeImpProp.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\process\CourseImpProp.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\training\controller\TrainingProp.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\training\controller\TrainingImportField.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\process\GenerateCompanyEmployee.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\process\ImportCourseManager.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\training\controller\UpdateEmpCourseFromTrdParty.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\training\controller\EmpCourseProp.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\training\controller\ImportCourse.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\process\CourseImportField.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\process\EmployeeImportField.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\process\ImportEmpManager.java
D:\eclipse-workspace\csc-dev1\ZM-CTraining\src\main\java\com\csc\library\training\controller\EmpCourseImportField.java
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment