Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I want to get the value of the attributes generated by an.jar that I got by tLibraryLoad, then do the mapping to load the data into a database.
Thanks
You should be able to extrapolate from the example I gave you for this.
But this is where I would put your code....
Start Code
// start part of your Java code Bak bak = BakReader.getInstance().read("D:\\test2.bak", "utf-8");
// here is the main part of the component,
// a piece of code executed in the row
// loop System.out.println("## START\n#");
//System.out.println(bak);
System.out.println("nb pylônes : " + bak.getDon().getNbPylones());
System.out.println("nb câbles : " + bak.getDon().getNbCables());
int i = 0;
for (Tow tow : bak.getDon().getTows()) {
Main Code
i++; row.reference = i + " - reference : " + tow.getReference(); row.nb_sets = i + " - nb sets : " + tow.getNbSets();
End Code
}
I've assumed your output row is called "row" and you have a "reference" column and a "nb_sets" column.
This very much depends on how you get the values from your Jar to be honest. But here is a demonstration of how it could be done. Let's assume your Java object returns rows of hashmaps. The object can tell the user whether it "hasNext" row or not and to get the next row you simply use "next". A bit like using an Iterator over an ArrayList.
Start Code
MyJar myJar = new myJar(); while(myJar.hasNext()){
Above we create an instance of our class and open a while loop which will make the Main Code fire in a loop.
Main Code
HashMap myHash = myJar.next(); row1.name = ((String)myHash.get("name")); row2.age = ((Integer)myHash.get("age")); row3.street = ((String)myHash.get("street"));
Above we get the next row from myJar and pass its values (contained in a HashMap) to the row's columns (name, age and street).
End Code
}
Here we just close the loop.
This won't be precisely what you need, but without knowledge of the Java classes you are using all I can do is give you an example of you can generate rows using a tJavaFlex and a Java object.
that's my code :
import in tLibraryLoad:
//import java.util.List; //import com.rtefrance.cacao.poc.Test; import com.rtefrance.infoliaison.cacao.readers.*; import com.rtefrance.infoliaison.cacao.plsfile.*;
in tJavaFlex i have this code:
code initial:
// start part of your Java code Bak bak = BakReader.getInstance().read("D:\\test2.bak", "utf-8");
code principal:
// here is the main part of the component, // a piece of code executed in the row // loop System.out.println("## START\n#"); //System.out.println(bak); System.out.println("nb pylônes : " + bak.getDon().getNbPylones()); System.out.println("nb câbles : " + bak.getDon().getNbCables()); int i = 0; for (Tow tow : bak.getDon().getTows()) { i++; System.out.println(i + " - reference : " + tow.getReference()); System.out.println(i + " - nb sets : " + tow.getNbSets()); }
now I want to do the mapping between the values of "nbPylone, reference, nbCable and nbSets" and the database.
have you any idea please?
Thanks
You should be able to extrapolate from the example I gave you for this.
But this is where I would put your code....
Start Code
// start part of your Java code Bak bak = BakReader.getInstance().read("D:\\test2.bak", "utf-8");
// here is the main part of the component,
// a piece of code executed in the row
// loop System.out.println("## START\n#");
//System.out.println(bak);
System.out.println("nb pylônes : " + bak.getDon().getNbPylones());
System.out.println("nb câbles : " + bak.getDon().getNbCables());
int i = 0;
for (Tow tow : bak.getDon().getTows()) {
Main Code
i++; row.reference = i + " - reference : " + tow.getReference(); row.nb_sets = i + " - nb sets : " + tow.getNbSets();
End Code
}
I've assumed your output row is called "row" and you have a "reference" column and a "nb_sets" column.