-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtMongoDBXMLOutput_end.javajet
executable file
·60 lines (57 loc) · 1.89 KB
/
tMongoDBXMLOutput_end.javajet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.process.ElementParameterParser
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
String useExistingConn = ElementParameterParser.getValue(node,"__USE_EXISTING_CONNECTION__");
String dataAction = ElementParameterParser.getValue(node,"__DATA_ACTION__");
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
// BulkWrite is only supportted on Mongo 2.6+ drivers
String dbversion = ElementParameterParser.getValue(node, "__DB_VERSION__");
boolean setBulkWrite = "true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__SET_BULK_WRITE__"));
final boolean bulkWrite = setBulkWrite & (!"MONGODB_2_5_X".equalsIgnoreCase(dbversion));
// BulkWrite
// Last write if number of rows added is less than bulksize
if(bulkWrite){
%>
// if bulkWriteOperationCounter_<%=cid%> == 1 the ulkWriteOperation_<%=cid%> is empty, do not execute.
if (bulkWriteOperationCounter_<%=cid%> != 1) {
bulkWriteOperation_<%=cid%>.execute();
}
<%
}
if(isLog4jEnabled){
%>
log.info("<%=cid%> - Has been <%=dataAction.toLowerCase()+(dataAction.endsWith("E")?"d":"ed")%> " + nb_line_<%=cid%> + " records.");
<%
}
if(!"true".equals(useExistingConn)){
%>
if(mongo_<%=cid%> != null){
<%
if(isLog4jEnabled){
%>
log.info("<%=cid%> - Closing the connection " + mongo_<%=cid%>.getServerAddressList() + ".");
<%
}
%>
mongo_<%=cid%>.close();
<%
if(isLog4jEnabled){
%>
log.info("<%=cid%> - The connection was closed successfully.");
<%
}
%>
}
resourceMap.put("finish_<%=cid%>", true);
<%
}
%>
globalMap.put("<%=cid %>_NB_LINE", nb_line_<%=cid%>);