Using+a+new+Java+framework+to+create+ARFF+from+JPA+Entity

The Project
toc A new framework to create ARFF from JPA Entities.

What makes me want to develop this project:


 * Not having to worry about parameters of access to the database, since having my application integrated to JPA
 * Use Entities (POJO) JPA and its metadata to generate the ARFF when you need to outsource information for use by third parties.
 * Generate new Entity (POJO) JPA based on information obtained in the ARFF (planned to release V0.9.0)

Site About Project: http://socialsla.github.io/Weka-JPA-Persistence

Source on GitHub: https://github.com/SocialSLA/Weka-JPA-Persistence

How code
code try { Weka2JPAHelper l_helper; // inject with CDI or create a class with new Weka2JPAHelper(Logger,EntityManager);

l_helper.save(new File("Teste.arff"), A_JPA_Entity.class); }catch(IOException e){}

code if you want create the data to create a ARFF file from other source, you can use a JPA Entity like the example:

code try{ Weka2JPAHelper l_helper = CDIManager.get(Weka2JPAHelper.class);

Collection l_list = new ArrayList;

Classification l_positivo = new Classification(1, "Positivo"); Classification l_negativo = new Classification(-1, "Negativo"); Classification l_neutro = new Classification(0, "Neutro");

l_list.add(new Entity2Weka("Post numero 1 para teste do helper", l_positivo)); l_list.add(new Entity2Weka("Post numero 2 para teste do helper", l_negativo)); l_list.add(new Entity2Weka("Post numero 3 para teste do helper", l_neutro)); l_list.add(new Entity2Weka("Post numero 4 para teste do helper", l_negativo)); l_list.add(new Entity2Weka("Post numero 5 para teste do helper", l_positivo)); l_list.add(new Entity2Weka("Post numero 6 para teste do helper", l_negativo)); l_list.add(new Entity2Weka("Post numero 7 para teste do helper", l_positivo)); l_list.add(new Entity2Weka("Post numero 8 para teste do helper", l_neutro)); l_list.add(new Entity2Weka("Post numero 9 para teste do helper", l_negativo));

l_list.add(new Entity2Weka(null, l_positivo)); l_list.add(new Entity2Weka(null, l_neutro)); l_list.add(new Entity2Weka(null, l_negativo));

l_list.add(new Entity2Weka("Post numero 10 para teste do helper", null)); l_list.add(new Entity2Weka("Post numero 16 para teste do helper", null)); l_list.add(new Entity2Weka("Post numero 7 para teste do helper", null)); l_list.add(new Entity2Weka("Post numero 8 para teste do helper", null)); l_list.add(new Entity2Weka("Post numero 9 para teste do helper", null));

l_helper.save(new File("Test.arff"), Entity2Weka.class, l_list);

CDIManager.stop; }catch{IOException e){} code

Entity Example
The Entity class with name Entity2Weka is a Entity Base used to get attributes and make header file: code @Entity public class Entity2Weka {

@Id private Integer id; // id not is used @Column private String post; // generate a Sring Attribute @ManyToOne private Classification classification; // generate a relational attribute

public Entity2Weka{}

public Entity2Weka(String p_string, Classification p_classification) { post = p_string; classification = p_classification; } } code

Classification Entity is a slave entity from entity base: code @Entity @NamedQueries({ @NamedQuery(name = Classification.NAMED_QUERY_FIND_ALL, query = "SELECT c FROM Classification c"),       @NamedQuery(name = Classification.NAMED_QUERY_FIND_BY_NAME, query = "SELECT c FROM Classification c WHERE c.name = ?") }) public class Classification {

public static final String NAMED_QUERY_FIND_ALL = "Classification.findAll"; public static final String NAMED_QUERY_FIND_BY_NAME = "Classification.findByName";

@Id private Integer id; @Column(length = 50, nullable = false, unique = true) private String name; @Column(length = 200, nullable = true) private String description;

public Classification {

}

public Classification(int p_i, String p_name) { id = p_i; name = p_name; } .....   public toString{ return name; } } code

Result this ARFF
code @relation Entity2Weka

@attribute post string @attribute classification {'Desconhecido (-888)','Negativo (-1)','Neutro (0)','Positivo (1)','Ambiguo (999)'}

@data 'Post numero 1 para teste do helper','Positivo (1)' 'Post numero 2 para teste do helper','Negativo (-1)' 'Post numero 3 para teste do helper','Neutro (0)' 'Post numero 4 para teste do helper','Negativo (-1)' 'Post numero 5 para teste do helper','Positivo (1)' 'Post numero 6 para teste do helper','Negativo (-1)' 'Post numero 7 para teste do helper','Positivo (1)' 'Post numero 8 para teste do helper','Neutro (0)' 'Post numero 9 para teste do helper','Negativo (-1)' ?,'Positivo (1)' ?,'Neutro (0)' ?,'Negativo (-1)' 'Post numero 10 para teste do helper',? 'Post numero 16 para teste do helper',? 'Post numero 7 para teste do helper',? 'Post numero 8 para teste do helper',? 'Post numero 9 para teste do helper',? code

Download source
Download this two pakages:
 * [|WEKA JPA Persistence - V0.0.4]
 * [|CDI Utils - for Configuration Injection]

include component="comments" page="page:Using a new Java framework to create ARFF from JPA Entity" limit="10"

==media type="facebooklike" key="http%3A%2F%2Fweka.wikispaces.com%2FUsing%20a%20new%20Java%20framework%20to%20create%20ARFF%20from%20JPA%20Entity" width="450" height="80"media type="googleplusone" key="" width="450" height="24"==