This .javajet program uses the static class RoutinesUtil to retrieve a list of System Routines loaded in Talend Open Studio.
The class RoutinesUtil is not available at runtime, so this example loops within the code generation context. The org.talend.core classes aren't found when the component runs, but are available when the Java code is generated.
This is taken from a Begin Javajet. During the codegen phase, the getCurrentSystemRoutines() method is called and generates a System.out.println() statement for each System Routine.
<%@ 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
java.util.Map
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
%>
<%
java.util.List<org.talend.core.model.repository.IRepositoryViewObject> sysRoutines = org.talend.core.model.routines.RoutinesUtil.getCurrentSystemRoutines();
for( org.talend.core.model.repository.IRepositoryViewObject vo : sysRoutines ) {
%>
System.out.println( "<%= vo.getLabel() %>" );
<%
}
%>
The results of the running a Job that uses this Component is the following
[statistics] connecting to socket on port 4045
[statistics] connected
DataOperation
Mathematical
Numeric
Relational
StringHandling
TalendDataGenerator
TalendDate
TalendString
[statistics] disconnected
Job RepoBrowseTestJob ended at 09:51 30/03/2014. [exit code=0]
No comments:
Post a Comment