Hello, friends

Sorry for the long post. I am into a java web project using Jena. The
architecture is MVC, and in de Model I am trying to use some javabeans to
access and perform some processing on a OWL and a RDF file. The logic is
somewhat simple, I have to extract a path from a simple ontology in OWL. So
I am using the findShortestPath from OntTools (Comments are in Portuguese,
and are just for debugging). However there is a weird thing. I got an error
if I write something as:
++++++++++++
package composicao.model;

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.*;

import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.ontology.OntTools.Path;
import com.hp.hpl.jena.ontology.OntTools.PredicatesFilter;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.util.iterator.Filter;
import com.hp.hpl.jena.vocabulary.OWL;

public class GeraSequenciaBean {
    /*
     * A Sequencia é definida aqui como o conjunto de de conceitos
     * retirados da ontologia, a partir o inicial e do final.
     *
     */

    String filename;

    OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
    m.read(filename);


    final Filter<Statement> ANY = Filter.any();


    public Path SequenciaBean( Model m, Resource start, RDFNode end,
Filter<Statement> onPath ) {
        List<Path> bfs = new LinkedList<Path>();
        Set<Resource> seen = new HashSet<Resource>();

        // initialize the paths
        for (Iterator<Statement> i = m.listStatements( start, null,
(RDFNode) null ).filterKeep( onPath ); i.hasNext(); ) {
            bfs.add( new Path().append( i.next() ) );
        }

        // search
        Path solution = null;
        while (solution == null && !bfs.isEmpty()) {
            Path candidate = bfs.remove( 0 );

            if (candidate.hasTerminus( end ) ) {
                solution = candidate;
                System.out.println("Solucao :"+ solution); //never
printed...
            }
            else {
                Resource terminus = candidate.getTerminalResource();
                if (terminus != null) {
                    seen.add( terminus );

                    // breadth-first expansion
                    for (Iterator<Statement> i =
terminus.listProperties().filterKeep( onPath ); i.hasNext(); ) {
                        Statement link = i.next();

                        // no looping allowed, so we skip this link if it
takes us to a node we've seen
                        if (!seen.contains( link.getObject() )) {
                            bfs.add( candidate.append( link ) );
                            //System.out.println("Passou aqui!");
                           // System.out.println("Caminho canditato :" +
candidate);
                        }
                    }
                }
            }
        }

        return solution;
    }
}
++++++++++++++++++



java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
    at
org.eclipse.ve.internal.java.vce.launcher.remotevm.JavaBeansLauncher.main(JavaBeansLauncher.java:86)
Caused by: java.lang.Error: Unresolved compilation problems:
    Syntax error on token(s), misplaced construct(s)
    Syntax error on token "filename", VariableDeclaratorId expected after
this token

    at composicao.model.GeraSequenciaBean.<init>(GeraSequenciaBean.java:34)
    ... 5 more
IWAV0048I Java Bean composicao.model.GeraSequenciaBean started with null
constructor
IWAV0052E Invocation Target Exception creating
composicao.model.GeraSequenciaBean

-- 
Herli Menezes
*Per Astra ad aspera.*

Reply via email to