forked from haeusler/tMongoDBOutput
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tMongoDBOutput_begin.javajet
32 lines (31 loc) · 1.26 KB
/
tMongoDBOutput_begin.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
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.metadata.IMetadataColumn
org.talend.core.model.process.IConnection
org.talend.core.model.process.IConnectionCategory
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.metadata.types.JavaTypesManager
org.talend.core.model.metadata.types.JavaType
java.util.List
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
boolean useExistingConnection = "true".equalsIgnoreCase(ElementParameterParser.getValue(node,"__USE_EXISTING_CONNECTION__"));
String cid = node.getUniqueName();
String collection = ElementParameterParser.getValue(node,"__COLLECTION__");
if (useExistingConnection)
{
String connection = ElementParameterParser.getValue(node, "__CONNECTION__");
String dbconn = "db_" + connection;
%>
com.mongodb.DB db_<%=cid%> = (com.mongodb.DB) globalMap.get("<%=dbconn%>");
com.mongodb.DBCollection coll_<%=cid%> = db_<%=cid%>.getCollection(<%=collection%>);
<%
}
%>
int nb_line_<%=cid %> = 0;