I am attempting to use a denormalizer (logic in java) for 3.0. I am trying to use it with 3.1 but it appears that the java interfaces have changed and it won’t compile at runtime. The documentation I am finding for the java interfaces online (http://www.cloveretl.com/documentation/ … index.html) are showing the outdated java interfaces.
For example, it appears as if there is now a appendDelegate() method that needs to be overridden as well as a transformDelegate() method. There is no mention of this in the userguide. Can someone point me in the right direction? Here is the 3.0 version of my denormalizer logic…
<attr name="denormalize"><![CDATA[import java.util.Properties;
import org.jetel.component.denormalize.DataRecordDenormalize;
import org.jetel.data.DataRecord;
import org.jetel.exception.ComponentNotReadyException;
import org.jetel.exception.TransformException;
import org.jetel.metadata.DataRecordMetadata;
public class MyDenormalize extends DataRecordDenormalize {
private StringBuilder[] fieldList;
private String id;
@Override
public boolean init(Properties parameters,
DataRecordMetadata sourceMetadata, DataRecordMetadata targetMetadata)
throws ComponentNotReadyException {
fieldList = new StringBuilder[sourceMetadata.getNumFields()];
for (int i = 0; i < fieldList.length; i++) {
fieldList[i] = new StringBuilder();
}
return super.init(parameters, sourceMetadata, targetMetadata);
}
@Override
public int append(DataRecord arg0) throws TransformException {
id = arg0.getField("ID").toString();
for (int i = 0; i < arg0.getNumFields(); i++) {
if (!arg0.getField(i).getMetadata().getName().equals("ID")) {
fieldList[i].append(arg0.getField(i)).append(',');
}
}
return 0;
}
@Override
public int transform(DataRecord arg0) throws TransformException {
for (int i = 0; i < fieldList.length; i++) {
if (!arg0.getField(i).getMetadata().getName().equals("ID")) {
arg0.getField(i).setValue(fieldList[i].subSequence(0, fieldList[i].length() - 1));
}else{
arg0.getField(i).setValue(id);
}
}
return 0;
}
@Override
public void clean() {
super.clean();
for (StringBuilder field : fieldList) {
field.setLength(0);
}
}
}
]]></attr>
Agata, thanks for getting back to me. Here is the error I see. It occurs at run-time, the java compilation step. The reason I concluded the java interface changed is when I started a new denormalizer component and “converted to java”, I noticed the override methods had changed. Am I barking up the wrong tree?
INFO [main] - Compiling dynamic class MyDenormalize…
ERROR [main] - Compiler output:\nMyDenormalize.java:14: cannot find symbol
symbol : class Properties
location: class MyDenormalize
public boolean init(Properties parameters,
^
1 error
ERROR [main] - Error during graph initialization !
Element [1318434231903:OneTouchTest]-Phase 0 can’t be initilized.
at org.jetel.graph.TransformationGraph.init(TransformationGraph.java:458)
at org.jetel.graph.runtime.EngineInitializer.initGraph(EngineInitializer.java:202)
at org.jetel.graph.runtime.EngineInitializer.initGraph(EngineInitializer.java:165)
at org.jetel.main.runGraph.runGraph(runGraph.java:364)
at org.jetel.main.runGraph.main(runGraph.java:328)
Caused by: DENORMALIZER0 …FAILED !
Reason: Cannot compile the dynamic class!
at org.jetel.graph.Phase.init(Phase.java:170)
at org.jetel.graph.TransformationGraph.init(TransformationGraph.java:456)
… 4 more
Caused by: Cannot compile the dynamic class!
at org.jetel.util.compile.DynamicJavaClass.instantiate(DynamicJavaClass.java:74)
at org.jetel.component.Denormalizer.createDenormalizerDynamic(Denormalizer.java:216)
at org.jetel.component.Denormalizer.createRecordDenormalizer(Denormalizer.java:269)
at org.jetel.component.Denormalizer.init(Denormalizer.java:241)
at org.jetel.graph.Phase.init(Phase.java:165)
… 5 more
Caused by: org.jetel.util.compile.CompilationException: Compilation failed! See compiler output for more details.
at org.jetel.util.compile.DynamicCompiler.compile(DynamicCompiler.java:121)
at org.jetel.util.compile.DynamicJavaClass.instantiate(DynamicJavaClass.java:66)
… 9 more
Hello, CTLRecordDenormalize implements RecordDenormalize and it is used, when transformation for Denormalizer is written in CTL2. CloverETL converts CTL2 code to the object extending CTLRecordDenormalize type. But when you write the transformation in java it’s better and easier to extend the DataRecordDenormalize type. The error above suggests that you are missing JRE System Library on the class path. Please check it in Project properties - Libraries should contain two entries: Properties.png
No other CloverETL libraries can be set.
This new libraries container was introduced in CloverETL 3.1 and all class paths should be fixed manually for projects created in older CloverETL Designer.
Thanks Agata. I checked the project properties and I do indeed have the JDK1.6 and the Clover Engine libraries on my build path. Not sure what else could confuse the issue. It seems that the compiler is unhappy because it doesn’t know what the “Properties” object type is. Is this class definition packaged elsewhere?
Most importantly, if you take my java code above, does my code compile at runtime in 3.1 for you?
Hello, java.util.Properties is part of JRE, so it is included in any java. Your code works properly in my CloverETL Designer 3.1.2.
Please try to create new CloverETL project and copy all required resources to it. I still believe, that the problem is in the class-path configuration.
Thanks. Sorry for the wild goose chase. Embarrassingly enough, this was a copy and paste mistake. I was actually missing the import java.util.Properties; line from the top of my java based transform logic.