public void tPostgresqlInput_1Process(
final java.util.Map<String, Object> globalMap)
throws TalendException {
globalMap.put("tPostgresqlInput_1_SUBPROCESS_STATE", 0);
String currentComponent = "";
try {
row1Struct row1 = new row1Struct();
row2Struct row2 = new row2Struct();
/**
* [tFileOutputDelimited_1 begin ] start
*/
ok_Hash.put("tFileOutputDelimited_1", false);
start_Hash
.put("tFileOutputDelimited_1", System.currentTimeMillis());
currentComponent = "tFileOutputDelimited_1";
int tos_count_tFileOutputDelimited_1 = 0;
String fileName_tFileOutputDelimited_1 = (new java.io.File(
"C:/Documents and Settings/kcherifi/Bureau/test/"
+ row2.nomFichier + ".xml")).getAbsolutePath()
.replace("\\", "/");
String fullName_tFileOutputDelimited_1 = null;
String extension_tFileOutputDelimited_1 = null;
String directory_tFileOutputDelimited_1 = null;
if ((fileName_tFileOutputDelimited_1.indexOf("/") != -1)) {
if (fileName_tFileOutputDelimited_1.lastIndexOf(".") < fileName_tFileOutputDelimited_1
.lastIndexOf("/")) {
fullName_tFileOutputDelimited_1 = fileName_tFileOutputDelimited_1;
extension_tFileOutputDelimited_1 = "";
} else {
fullName_tFileOutputDelimited_1 = fileName_tFileOutputDelimited_1
.substring(0, fileName_tFileOutputDelimited_1
.lastIndexOf("."));
extension_tFileOutputDelimited_1 = fileName_tFileOutputDelimited_1
.substring(fileName_tFileOutputDelimited_1
.lastIndexOf("."));
}
directory_tFileOutputDelimited_1 = fileName_tFileOutputDelimited_1
.substring(0, fileName_tFileOutputDelimited_1
.lastIndexOf("/"));
} else {
if (fileName_tFileOutputDelimited_1.lastIndexOf(".") != -1) {
fullName_tFileOutputDelimited_1 = fileName_tFileOutputDelimited_1
.substring(0, fileName_tFileOutputDelimited_1
.lastIndexOf("."));
extension_tFileOutputDelimited_1 = fileName_tFileOutputDelimited_1
.substring(fileName_tFileOutputDelimited_1
.lastIndexOf("."));
} else {
fullName_tFileOutputDelimited_1 = fileName_tFileOutputDelimited_1;
extension_tFileOutputDelimited_1 = "";
}
directory_tFileOutputDelimited_1 = "";
}
int nb_line_tFileOutputDelimited_1 = 0;
int splitEvery_tFileOutputDelimited_1 = 1000;
int splitedFileNo_tFileOutputDelimited_1 = 0;
int currentRow_tFileOutputDelimited_1 = 0;
final String OUT_DELIM_tFileOutputDelimited_1 = /**
* Start field
* tFileOutputDelimited_1:FIELDSEPARATOR
*/
""/** End field tFileOutputDelimited_1:FIELDSEPARATOR */
;
final String OUT_DELIM_ROWSEP_tFileOutputDelimited_1 = /**
* Start
* field
* tFileOutputDelimited_1:ROWSEPARATOR
*/
""/** End field tFileOutputDelimited_1:ROWSEPARATOR */
;
// create directory only if not exists
if (directory_tFileOutputDelimited_1 != null
&& directory_tFileOutputDelimited_1.trim().length() != 0) {
java.io.File dir_tFileOutputDelimited_1 = new java.io.File(
directory_tFileOutputDelimited_1);
if (!dir_tFileOutputDelimited_1.exists()) {
dir_tFileOutputDelimited_1.mkdirs();
}
}
// routines.system.Row
java.io.Writer outtFileOutputDelimited_1 = new java.io.BufferedWriter(
new java.io.OutputStreamWriter(
new java.io.FileOutputStream(
fileName_tFileOutputDelimited_1, false),
"ISO-8859-15"));
java.io.File filetFileOutputDelimited_1 = new java.io.File(
fileName_tFileOutputDelimited_1);
/**
* [tFileOutputDelimited_1 begin ] stop
*/
/**
* [tJavaRow_1 begin ] start
*/
ok_Hash.put("tJavaRow_1", false);
start_Hash.put("tJavaRow_1", System.currentTimeMillis());
currentComponent = "tJavaRow_1";
int tos_count_tJavaRow_1 = 0;
int nb_line_tJavaRow_1 = 0;
/**
* [tJavaRow_1 begin ] stop
*/
/**
* [tPostgresqlInput_1 begin ] start
*/
ok_Hash.put("tPostgresqlInput_1", false);
start_Hash.put("tPostgresqlInput_1", System.currentTimeMillis());
currentComponent = "tPostgresqlInput_1";
int tos_count_tPostgresqlInput_1 = 0;
int nb_line_tPostgresqlInput_1 = 0;
java.sql.Connection conn_tPostgresqlInput_1 = null;
java.lang.Class.forName("org.postgresql.Driver");
String url_tPostgresqlInput_1 = "jdbc:postgresql://"
+ "172.30.1.13:5432/baserepoposlogmom" + ":" + "5432" + "/"
+ "";
String dbUser_tPostgresqlInput_1 = "postgres";
String dbPwd_tPostgresqlInput_1 = "postgres";
conn_tPostgresqlInput_1 = java.sql.DriverManager.getConnection(
url_tPostgresqlInput_1, dbUser_tPostgresqlInput_1,
dbPwd_tPostgresqlInput_1);
conn_tPostgresqlInput_1.setAutoCommit(false);
java.sql.Statement stmt_tPostgresqlInput_1 = conn_tPostgresqlInput_1
.createStatement();
java.sql.ResultSet rs_tPostgresqlInput_1 = stmt_tPostgresqlInput_1
.executeQuery("select \"dt_dwglposlog_actif\".\"c_idenseigne\",\"dt_dwglposlog_actif\".\"c_idstore\", \"dt_dwglposlog_actif\".\"c_ncaisse\",\"dt_dwglposlog_actif\".\"c_poslogdata\", \"dt_dwglposlog_actif\".\"c_numtrx\",\"dt_dwglposlog_actif\".\"c_datetrx\" from \"public\".\"dt_dwglposlog_actif\"");
java.sql.ResultSetMetaData rsmd_tPostgresqlInput_1 = rs_tPostgresqlInput_1
.getMetaData();
int colQtyInRs_tPostgresqlInput_1 = rsmd_tPostgresqlInput_1
.getColumnCount();
globalMap
.put(
"tPostgresqlInput_1_QUERY",
"select \"dt_dwglposlog_actif\".\"c_idenseigne\",\"dt_dwglposlog_actif\".\"c_idstore\", \"dt_dwglposlog_actif\".\"c_ncaisse\",\"dt_dwglposlog_actif\".\"c_poslogdata\", \"dt_dwglposlog_actif\".\"c_numtrx\",\"dt_dwglposlog_actif\".\"c_datetrx\" from \"public\".\"dt_dwglposlog_actif\"");
String tmpContent_tPostgresqlInput_1 = null;
while (rs_tPostgresqlInput_1.next()) {
nb_line_tPostgresqlInput_1++;
if (colQtyInRs_tPostgresqlInput_1 < 1) {
row1.c_idenseigne = null;
} else {
tmpContent_tPostgresqlInput_1 = rs_tPostgresqlInput_1
.getString(1);
if (tmpContent_tPostgresqlInput_1 != null) {
row1.c_idenseigne = tmpContent_tPostgresqlInput_1;
} else {
row1.c_idenseigne = null;
}
}
if (colQtyInRs_tPostgresqlInput_1 < 2) {
row1.c_idstore = null;
} else {
if (rs_tPostgresqlInput_1.getObject(2) != null) {
row1.c_idstore = rs_tPostgresqlInput_1.getDouble(2);
} else {
row1.c_idstore = null;
}
}
if (colQtyInRs_tPostgresqlInput_1 < 3) {
row1.c_ncaisse = null;
} else {
tmpContent_tPostgresqlInput_1 = rs_tPostgresqlInput_1
.getString(3);
if (tmpContent_tPostgresqlInput_1 != null) {
row1.c_ncaisse = tmpContent_tPostgresqlInput_1;
} else {
row1.c_ncaisse = null;
}
}
if (colQtyInRs_tPostgresqlInput_1 < 4) {
row1.c_poslogdata = null;
} else {
tmpContent_tPostgresqlInput_1 = rs_tPostgresqlInput_1
.getString(4);
if (tmpContent_tPostgresqlInput_1 != null) {
row1.c_poslogdata = tmpContent_tPostgresqlInput_1;
} else {
row1.c_poslogdata = null;
}
}
if (colQtyInRs_tPostgresqlInput_1 < 5) {
row1.c_numtrx = null;
} else {
tmpContent_tPostgresqlInput_1 = rs_tPostgresqlInput_1
.getString(5);
if (tmpContent_tPostgresqlInput_1 != null) {
row1.c_numtrx = tmpContent_tPostgresqlInput_1;
} else {
row1.c_numtrx = null;
}
}
if (colQtyInRs_tPostgresqlInput_1 < 6) {
row1.c_datetrx = null;
} else {
tmpContent_tPostgresqlInput_1 = rs_tPostgresqlInput_1
.getString(6);
if (tmpContent_tPostgresqlInput_1 != null) {
row1.c_datetrx = tmpContent_tPostgresqlInput_1;
} else {
row1.c_datetrx = null;
}
}
/**
* [tPostgresqlInput_1 begin ] stop
*/
/**
* [tPostgresqlInput_1 main ] start
*/
currentComponent = "tPostgresqlInput_1";
tos_count_tPostgresqlInput_1++;
/**
* [tPostgresqlInput_1 main ] stop
*/
/**
* [tJavaRow_1 main ] start
*/
currentComponent = "tJavaRow_1";
// Code generate according to input schema and output schema
row2.contenu = row1.c_poslogdata;
nb_line_tJavaRow_1++;
tos_count_tJavaRow_1++;
/**
* [tJavaRow_1 main ] stop
*/
/**
* [tFileOutputDelimited_1 main ] start
*/
currentComponent = "tFileOutputDelimited_1";
StringBuilder sb_tFileOutputDelimited_1 = new StringBuilder();
if (row2.contenu != null) {
sb_tFileOutputDelimited_1.append(
row2.contenu
);
}
sb_tFileOutputDelimited_1
.append(OUT_DELIM_tFileOutputDelimited_1);
if (row2.nomFichier != null) {
sb_tFileOutputDelimited_1.append(
row2.nomFichier
);
}
sb_tFileOutputDelimited_1
.append(OUT_DELIM_ROWSEP_tFileOutputDelimited_1);
outtFileOutputDelimited_1.write(sb_tFileOutputDelimited_1
.toString());
nb_line_tFileOutputDelimited_1++;
tos_count_tFileOutputDelimited_1++;
/**
* [tFileOutputDelimited_1 main ] stop
*/
/**
* [tPostgresqlInput_1 end ] start
*/
currentComponent = "tPostgresqlInput_1";
}
stmt_tPostgresqlInput_1.close();
conn_tPostgresqlInput_1.commit();
conn_tPostgresqlInput_1.close();
globalMap.put("tPostgresqlInput_1_NB_LINE",
nb_line_tPostgresqlInput_1);
ok_Hash.put("tPostgresqlInput_1", true);
end_Hash.put("tPostgresqlInput_1", System.currentTimeMillis());
/**
* [tPostgresqlInput_1 end ] stop
*/
/**
* [tJavaRow_1 end ] start
*/
currentComponent = "tJavaRow_1";
globalMap.put("tJavaRow_1_NB_LINE", nb_line_tJavaRow_1);
ok_Hash.put("tJavaRow_1", true);
end_Hash.put("tJavaRow_1", System.currentTimeMillis());
/**
* [tJavaRow_1 end ] stop
*/
/**
* [tFileOutputDelimited_1 end ] start
*/
currentComponent = "tFileOutputDelimited_1";
outtFileOutputDelimited_1.close();
globalMap.put("tFileOutputDelimited_1_NB_LINE",
nb_line_tFileOutputDelimited_1);
ok_Hash.put("tFileOutputDelimited_1", true);
end_Hash.put("tFileOutputDelimited_1", System.currentTimeMillis());
/**
* [tFileOutputDelimited_1 end ] stop
*/
} catch (Exception e) {
throw new TalendException(e, currentComponent, globalMap);
}
globalMap.put("tPostgresqlInput_1_SUBPROCESS_STATE", 1);
}
Partager