Thursday, November 29, 2012

GWT proyect in eclipse and maven

To create a GWT proyect in eclipse or another IDE use console the Archetype execute this command Use it as you would any other Maven archetype to create a template/stub project. launch this command y your console cmd> or terminal> mvn archetype:generate \ -DarchetypeGroupId=org.codehaus.mojo \ -DarchetypeArtifactId=gwt-maven-plugin \ -DarchetypeVersion=2.5.0 The generated project can then be imported as "existing project" into Eclipse, and run command-line maven to launch GWT 'mvn gwt:run' with plugin M2E. [1] But M2E has a problem: M2E problem : Plugin execution not covered by lifecycle configuration solver. Ref in [2] put this in your pom.

            
                
                    org.eclipse.m2e
                    lifecycle-mapping
                    1.0.0
                    
                        
                            
                                
                                    
                                        org.codehaus.mojo
                                        gwt-maven-plugin
                                        [2.4.0,)
                                        
                                            resources
                                            compile
                                            i18n
                                           generateAsync
                                        
                                    
                                    
                                        
                                    
                                
                                
                                    
                                        org.apache.maven.plugins
                                        maven-war-plugin
                                        [2.1.1,)
                                        
                                            exploded
                                        
                                    
                                    
                                        
                                    
                                

                            
                        
                    
                
            
        
[1]http://mojo.codehaus.org/gwt-maven-plugin/user-guide/archetype.html [2]http://stackoverflow.com/questions/8523737/getting-error-plugin-execution-not-covered-by-lifecycle-configuration-with-gwt

Tuesday, October 30, 2012

Cassandra keys in Unix/linux server and client in java windows

In this link talk about to count in rows in cassandra. But there a little problem when Unix database and client java Windows. The serialize UUID dont work.
byte[] start = null;
byte[] lastEnd = null;
int count = 0;
while (true) {
RangeSlicesQuery rsq = HFactory
 .createRangeSlicesQuery(keyspaceOperator,
       me.prettyprint.cassandra.serializers.BytesArraySerializer.get(), StringSerializer.get(),
 StringSerializer.get());
 rsq.setColumnFamily("columnFamily");
 rsq.setColumnNames("uuid","idUser","timestamp","urlPageVisited","processed");
 rsq.setKeys(start, null);
 rsq.setReturnKeysOnly(); // Return column names instead of values
 rsq.setRowCount(3); // Arbitrary default
 OrderedRows rows = rsq.execute().get();
 int rowCount = rows.getCount();

if (rowCount == 0) {
 break;
} else {
 start = rows.peekLast().getKey();

 if (lastEnd != null && Arrays.equals(start,lastEnd) ) { // modify this line
  break;
 }
 count += rowCount - 1;
 lastEnd = start;
}
  if (count > 0) {
   count += 1;
  }
  System.out.print("count de la tabla " + count);
  return count;
 }
change the UUID identify. Put byte[]

Thursday, October 25, 2012

Kundera not implement getCriteriaBuilder


I have cassandra intalled a computer.... I try create a template to make dinamics query with JPA. This is implemente.



    public <E extends Object> List<E> getAll(E e){
   
          CriteriaBuilder cb = em.getCriteriaBuilder();
         
          CriteriaQuery<E> q = cb.createQuery((Class<E>) e);
          Root<E> c = q.from((Class<E>) e);
          return (List<E>) q.select(c);
    }

But when I executed this progran throw a exception

NotImplementedException: TODO
    at com.impetus.kundera.persistence.EntityManagerFactoryImpl.getCriteriaBuilder(EntityManagerFactoryImpl.java:199)
    at com.impetus.kundera.persistence.EntityManagerImpl.getCriteriaBuilder(EntityManagerImpl.java:682)

Friday, October 19, 2012

cant find parent project

I have a maven project with module and parent proyect. If you launch a test module with command mvn  test this work, but you add a variable inside module that reference to parent proyect. ${project.version} and now launch mvn test, this fail. You must install project parent in your local repository to launch module.

Wednesday, October 17, 2012

start reasoner in virtuoso


load Model from virtuoso

        VirtGraph set = new VirtGraph(GraphIri, "jdbc:virtuoso://" + uriServer + ":"
                + portJDBC + "", db_user, db_pass);
        System.out.println("Start inference!");
        Reasoner reasoner = PelletReasonerFactory.theInstance().create();
        reasoner = reasoner.bindSchema(set);
        InfModel infModel = ModelFactory.createInfModel(reasoner, modelVirtuoso);
        System.out.println("Stop inference!");

        Model m2 = vd.getNamedModel(GraphIri);


save inference in virtuoso

       
         System.out.print("instancias "+m2.size());
         if(m2.containsAll(infModel)){ System.out.print("no hay inferencia ");
         }else{ System.out.print("hay inferencia "); }
         if(m2.containsAny(infModel)){ System.out.print("es correcto ");
         }else{ System.out.print("es incorrecto "); }
        
        Model inferido = infModel.difference(m2);
        m2.add(inferido);

Monday, October 15, 2012

install virtuoso in windows


Download database virtuoso in http://sourceforge.net/projects/virtuoso/files/latest/download
unzip in virtuoso-opensource and add in variable path virtuoso-opensource\lib

copy  database/virtuoso.ini  as  demo.ini  in virtuoso-opensource
remove in file demo.ini  all character ../

open cmd admin mode
http://networkadminkb.com/KB/a47/how-to-allow-users-to-enumerate-service-remotely.aspx
unable to open sthe service control manager

execute in virtuoso-opensource   ./bin/virtuoso-t.exe -c demo -I Demo -S create
the service has been register

start service openlink virtuoso server [Demo]

open http://localhost:8890/




load OWL file model in virtuoso

If you try save a model from OWL file in Virtuoso with class

VirtuosoUpdateFactory  or VirtuosoQueryExecutionFactory this fail.

http://answers.semanticweb.com/questions/10520/virtrdfinsert-examples
http://answers.semanticweb.com/questions/12513/graph-in-virtuoso

To load in virtuoso used VirtDataSource

    VirtDataSource vd = new VirtDataSource("jdbc:virtuoso://localhost:1111", "dba", "dba");

        ModelMaker maker = ModelFactory.createMemModelMaker();   
        Model m = maker.createModel(BASE, false);
               
        //load owl file in model M
        FileInputStream  fis = new FileInputStream (getClass().getClassLoader().getResource("file.owl").getFile());
        m.read(fis ,null);
        fis.close();

       
        //TODO: if exist BASE in virtuoso FAIL
        //to erase datas conductor SQL> RDF_GLOBAL_RESET ();
        Model m2 =vd.getNamedModel(BASE);
        if(m2 == null)
            vd.addNamedModel(BASE, m);