From: <jen...@us...> - 2007-08-20 15:23:29
|
Revision: 9 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=9&view=rev Author: jenslehmann Date: 2007-08-20 08:23:17 -0700 (Mon, 20 Aug 2007) Log Message: ----------- web service implementation added Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS2.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java trunk/src/dl-learner/org/dllearner/server/exceptions/ trunk/src/dl-learner/org/dllearner/server/exceptions/ClientNotKnownException.java trunk/src/dl-learner/org/dllearner/server/exceptions/NoOntologySelectedException.java trunk/src/dl-learner/org/dllearner/server/exceptions/OntologyURLNotValid.java trunk/src/dl-learner/org/dllearner/server/jaxws/ trunk/src/dl-learner/org/dllearner/server/jaxws/ClientNotKnownExceptionBean.java trunk/src/dl-learner/org/dllearner/server/jaxws/NoOntologySelectedExceptionBean.java trunk/src/dl-learner/org/dllearner/server/jaxws/OntologyURLNotValidBean.java Added: trunk/src/dl-learner/org/dllearner/server/ClientState.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientState.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-08-20 15:23:17 UTC (rev 9) @@ -0,0 +1,532 @@ +package org.dllearner.server; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.Config; +import org.dllearner.ConfigurationManager; +import org.dllearner.ConfigurationOption; +import org.dllearner.Main; +import org.dllearner.OntologyFileFormat; +import org.dllearner.algorithms.refinement.ROLearner; +import org.dllearner.dl.AtomicConcept; +import org.dllearner.dl.AtomicRole; +import org.dllearner.dl.Concept; +import org.dllearner.dl.Individual; +import org.dllearner.dl.KB; +import org.dllearner.reasoning.Reasoner; +import org.dllearner.reasoning.ReasoningMethodUnsupportedException; +import org.dllearner.reasoning.ReasoningService; + +import org.dllearner.server.exceptions.NoOntologySelectedException; +import org.dllearner.server.exceptions.OntologyURLNotValid; + +import com.hp.hpl.jena.shared.DoesNotExistException; +import com.hp.hpl.jena.shared.JenaException; + +public class ClientState { + + private String reasonerURL="http://localhost:8081"; + //private String reasonerURL="http://localhost:3490"; + + private SortedSet<Individual> positiveExamples = new TreeSet<Individual>(); + public SortedSet<Individual> getPosExamples() { return this.positiveExamples;} + + private SortedSet<Individual> negativeExamples = new TreeSet<Individual>(); + public SortedSet<Individual> getNegExamples() { return this.negativeExamples;} + + private SortedSet<String> ignoredConcept = new TreeSet<String>(); + + + private Reasoner reasoner; + public Reasoner getReasoner() { return reasoner;} + + private ReasoningService rs; + public ReasoningService getRs() { return rs; } + + private String currentOntologyURL=null; + private boolean debug_flag=true; + private LearnMonitor lm=null; + + private String lastResult=""; + public String getLastResult(){ + try{ + return ROL.getBestSolution().toString(); + }catch (Exception e) {} + return this.lastResult; } + public void setLastResult(String lastResult) {this.lastResult = lastResult;} + + private String status="maiden-like"; + public void setStatus(String status) {this.status = status;} + + ConfigurationManager confMgr; + public void addOption(ConfigurationOption c){confMgr.applyConfigurationOption(c);} + ROLearner ROL; + + public ClientState() { + + + TreeSet<ConfigurationOption> s=new TreeSet<ConfigurationOption>(); + //s.add(new ConfigurationOption("refinement","quiet","true")); + /*s.add(new ConfigurationOption()); + s.add(new ConfigurationOption()); + s.add(new ConfigurationOption()); + s.add(new ConfigurationOption()); + s.add(new ConfigurationOption()); + s.add(new ConfigurationOption());*/ + + confMgr = new ConfigurationManager(s); + addOption(new ConfigurationOption("refinement","quiet","true")); + //confMgr.applyOptions(); + + } + + + + + public void addPositiveExample(String posExample) { + positiveExamples.add(new Individual(posExample)); + p("added pos: "+posExample); + } + + + public void addNegativeExample(String negExample) { + negativeExamples.add(new Individual(negExample)); + p("added neg: "+negExample); + } + + public void addIgnoredConcept(String concept) { + ignoredConcept.add(concept); + p("added ignoredConcepts: "+concept); + } + + public String[] selectInstancesForAConcept(String Concept)throws NoOntologySelectedException{ + if(Concept.endsWith("#Thing"))return new String[]{}; + AtomicConcept SelectedConcept=new AtomicConcept(Concept); + ArrayList<String> al=new ArrayList<String>(); + Individual indtmp=null; + Set ConceptSet=null; + AtomicConcept ac=null; + + + System.out.println("selectInstancesForAConcept: "+Concept); + // add all positives + Set positives=rs.retrieval(SelectedConcept); + Iterator i = positives.iterator(); + while(i.hasNext()){ + indtmp=(Individual)i.next(); + p("added "+indtmp.getName()+" to positives"); + al.add("added "+indtmp.getName()+" to positives"); + positiveExamples.add(indtmp); + } + + //find more general concepts + ArrayList<AtomicConcept> superConcepts=new ArrayList<AtomicConcept>(); + try{ + //ConceptSet = rs.getSubsumptionHierarchy().getMoreGeneralConcepts(new AtomicConcept(Concept)); + //System.out.println(ConceptSet); + //Concept c=new AtomicConcept(Concept); + /*Set<AtomicConcept> s=rs.getAtomicConcepts(); + Set<Concept> sc=new TreeSet<Concept>(); + Iterator a=s.iterator(); + while (a.hasNext()) { + sc.add((Concept) a.next()); + } + sc=rs.subsumes(sc,new AtomicConcept(Concept));*/ + superConcepts=subsumesAll(SelectedConcept); + + //System.out.println("sizebefore: "+"size after:"+sc); + }catch (Exception e) {e.printStackTrace();} + + +// remove top + for (int j = 0; j < superConcepts.size(); ) { + //TODO no unique name assumption? + if(superConcepts.get(j).getName().equals(SelectedConcept.getName())){ + superConcepts.remove(j); + j=0; + continue; + } + if(superConcepts.get(j).getName().equals("TOP")){ + superConcepts.remove(j); + j=0; + continue; + } + j++; + } + + System.out.println("Found all those:"+ superConcepts); + + ac=null; + + if(superConcepts.size()==0){return al2s(al); }//TODO + else + { // add all negatives of all superclasses; + + //Iterator it=ConceptSet.iterator(); + for (int jj = 0; jj < superConcepts.size(); jj++) + { + ac=superConcepts.get(jj); + p("next this: "+ac.getName()); + Set negatives=rs.retrieval(ac); + Iterator i2 = negatives.iterator(); + indtmp=null; + while(i2.hasNext()){ + + indtmp=(Individual)i2.next(); + + if(!positives.contains(indtmp)){ + + p("added "+indtmp.getName()+" to NEGATIVES"); + al.add("added "+indtmp.getName()+" to NEGATIVES"); + negativeExamples.add(indtmp); + } + else{ + p("skipped "+indtmp.getName()); + al.add("skipped "+indtmp.getName()); + } + + } + }//endfor + return al2s(al); + } + + + } + + public ArrayList<AtomicConcept> subsumesAll(AtomicConcept c){ + Set s=rs.getAtomicConcepts(); + ArrayList<AtomicConcept> ret=new ArrayList<AtomicConcept>(); + Iterator i=s.iterator(); + while (i.hasNext()) { + AtomicConcept element = (AtomicConcept) i.next(); + if(rs.subsumes(element, c)) + { + ret.add(element); + } + + } + return ret; + } + public String[] getPositiveExamples(){ + String[] ret=new String[positiveExamples.size()]; + Iterator i=positiveExamples.iterator(); + int a=0; + while (i.hasNext()){ + ret[a++]=((Individual)i.next()).getName(); + } + //p("getPositiveEx"); + return ret; + } + public String[] getNegativeExamples(){ + String[] ret=new String[negativeExamples.size()]; + Iterator i=negativeExamples.iterator(); + int a=0; + while (i.hasNext()){ + ret[a++]=((Individual)i.next()).getName(); + } + //p("getNegativeEx"); + return ret; + } + + public String[] getIgnoredConcepts() { + String[] ret=new String[ignoredConcept.size()]; + Iterator i=ignoredConcept.iterator(); + int a=0; + while (i.hasNext()){ + ret[a++]=((String)i.next()); + } + //p("getNegativeEx"); + return ret; + } + + public String getSubsumptionHierarchy() throws NoOntologySelectedException { + try{ + return this.rs.getSubsumptionHierarchy().toString(); + }catch (Exception e) {throw new NoOntologySelectedException("Subsumptionhierarchy",e.getMessage());} + + } + + + + public boolean removeNegativeExample(String NegExample){ + p("removed from neg: "+NegExample); + return negativeExamples.remove(new Individual(NegExample)); + } + public boolean removePositiveExample(String PosExample){ + p("removed from pos: "+PosExample); + return positiveExamples.remove(new Individual(PosExample)); + } + + public boolean removeAllPositiveExamples(){ + positiveExamples = new TreeSet<Individual>(); + p("removing all positive examples"); + return true; + } + public boolean removeAllNegativeExamples(){ + negativeExamples = new TreeSet<Individual>(); + p("removing all negative examples"); + return true; + } + + public boolean removeAllExamples(){ + positiveExamples = new TreeSet<Individual>(); + negativeExamples = new TreeSet<Individual>(); + p("removing all examples"); + return true; + } + + public void removeIgnoredConcept(String concept) { + //ignoredConcept.add(concept); + this.ignoredConcept.remove(concept); + p("removed ignoredConcepts: "+concept); + } + + public String[] getInstances()throws NoOntologySelectedException{ + try{ + SortedSet<Individual> s=rs.getIndividuals(); + //System.out.println(s); + String[] ret=new String[s.size()]; + Iterator i=s.iterator(); + int a=0; + while (i.hasNext()){ + ret[a++]=((Individual)i.next()).getName(); + } + Arrays.sort(ret); + //p("getInstances"); + return ret; + }catch (Exception e) {throw new NoOntologySelectedException("Failed to get instances, no ontology selected","");} + } + + public String getCurrentOntologyURL()throws NoOntologySelectedException{ + p("getCurrentOntology: "+currentOntologyURL); + if(currentOntologyURL==null)throw new NoOntologySelectedException("Select Ontology First","quatsch"); + else return currentOntologyURL; + } + + public String getAlgorithmStatus(){ + return this.status; + } + + /** + * Specifies the URI of the ontology containing the background + * knowledge. Reads the ontology and sends it to the reasoner. + * + * @param ontologyURI The URI of the ontology to use. + */ + // gleiche Methoden mit verschiedenen Parametern sind offenbar problematisch + /* + @WebMethod + public void readOntology(String ontologyURI) { + readOntology(ontologyURI, "RDF/XML"); + } + */ + + + public void removeOntology() { + this.currentOntologyURL=null; + this.reasoner=null; + this.rs=null; + this.positiveExamples = new TreeSet<Individual>(); + this.negativeExamples = new TreeSet<Individual>(); + this.ignoredConcept=new TreeSet<String>(); + p("removing Ontology"); + + } + + /** + * Specifies the URI of the ontology containing the background + * knowledge and its format. Reads the ontology and sends it to + * the reasoner. + * + * @param ontologyURI The URI of the ontology to use. + * @param format "RDF/XML" or "N-TRIPLES". + */ + + + public void readOntology(String ontologyURL, String format) throws OntologyURLNotValid{ + this.currentOntologyURL=ontologyURL; + p("trying to read: "+ontologyURL+" ::"+format); + try{ + // this.ontologyURL = ontologyURL; + // this.ontologyFormat = format; + + // TODO: potentielles Sicherheitsrisiko, da man damit derzeit auch lokale Dateien + // laden könnte (Fix: nur http:// zulassen, kein file://) + URL ontology = null; + try { + ontology = new URL(ontologyURL); + } catch (MalformedURLException e1) { + this.removeOntology(); + throw new OntologyURLNotValid("The URL of the Ontology is not correct<br>\nCheck settings and URL","OntologyURLNotValid"); + + } + + OntologyFileFormat ofFormat; + if (format.equals("RDF/XML")) + ofFormat = OntologyFileFormat.RDF_XML; + else + ofFormat = OntologyFileFormat.N_TRIPLES; + + Map<URL, OntologyFileFormat> m = new HashMap<URL, OntologyFileFormat>(); + m.put(ontology, ofFormat); + + // Default-URI für DIG-Reasoner setzen + + try { + Config.digReasonerURL = new URL(reasonerURL); + } catch (MalformedURLException e) { + // Exception tritt nie auf, da URL korrekt + e.printStackTrace(); + } + + reasoner = Main.createReasoner(new KB(), m); + rs = new ReasoningService(reasoner); + + Main.autoDetectConceptsAndRoles(rs); + reasoner.prepareSubsumptionHierarchy(); + if (Config.Refinement.improveSubsumptionHierarchy) { + try { + reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); + } catch (ReasoningMethodUnsupportedException e) { + // solange DIG-Reasoner eingestellt ist, schlägt diese Operation nie fehl + e.printStackTrace(); + } + } + p(rs.getSubsumptionHierarchy().toString()); + //rs.getRoleMembers(arg0) + } + catch (DoesNotExistException e) { + this.removeOntology(); + throw new OntologyURLNotValid("The URL of the Ontology is not correct<br>\nCheck settings and URL","OntologyURLNotValid"); + } + catch (JenaException e) { + e.printStackTrace();} + + + /*catch(Exception e2) { + + //p("exception:"+e.getMessage()); + e2.printStackTrace(); + }*/ + p("Ontology read: "+currentOntologyURL); + } + + + public void learnMonitored(){ + addOption(new ConfigurationOption("refinement","ignoredConcepts",ignoredConcept)); + this.lm=new LearnMonitor(this); + this.lm.start(); + //this.lm.learn(this); + } + + /*public void relearn(){ + //TreeSet<String> s=new TreeSet<String>(); + //new ConfigurationOption(); + this.lm=new LearnMonitor(this); + this.lm.start(); + //this.lm.learn(this); + }*/ + + + public String[] getAtomicConcepts()throws NoOntologySelectedException{ + try{ + return SortedSet2StringListConcepts( rs.getAtomicConcepts()); + }catch (Exception e) {throw new NoOntologySelectedException("Select Ontology First","ddddd");} + } + + public String[] retrieval(String Concept)throws NoOntologySelectedException{ + return SortedSet2StringListIndividuals(rs.retrieval(new AtomicConcept(Concept))); + } + + public String[] getAtomicRoles()throws NoOntologySelectedException{ + return SortedSet2StringListRoles( rs.getAtomicRoles()); + } + + public String[] getIndividualsForARole(String Role)throws NoOntologySelectedException{ + Map m=rs.getRoleMembers(new AtomicRole(Role)); + Set s=m.keySet(); + return SortedSet2StringListIndividuals(s); + } + + public synchronized void stop(){ + System.out.println("ROL"+this.ROL); + + System.out.println("lm"+lm); + System.out.println("lmstate"+lm.getState()); + System.out.println("lmalive"+lm.isAlive()); + System.out.println("lminterrupt"+lm.isInterrupted()); + this.ROL.stop(); + /*try{ + synchronized (this.lm) { + //this.lm.yield(); + } + }catch (Exception e) {e.printStackTrace();}*/ + System.out.println("lmstate"+lm.getState()); + System.out.println("lmalive"+lm.isAlive()); + System.out.println("lminterrupt"+lm.isInterrupted()); + + //this.ROL.stop(); + //this.lm.interrupt(); + + //this.lm.end(); + //this.lm.notify(); + } + + public String[] SortedSet2StringListIndividuals(Set s){ + + String[] ret=new String[s.size()]; + Iterator i=s.iterator(); + int a=0; + while (i.hasNext()){ + ret[a++]=((Individual)i.next()).getName(); + } + Arrays.sort(ret); + return ret; + } + + public String[] SortedSet2StringListConcepts(Set s){ + + String[] ret=new String[s.size()]; + Iterator i=s.iterator(); + int a=0; + while (i.hasNext()){ + ret[a++]=((AtomicConcept)i.next()).getName(); + } + Arrays.sort(ret); + return ret; + } + public String[] SortedSet2StringListRoles(Set s){ + + String[] ret=new String[s.size()]; + Iterator i=s.iterator(); + int a=0; + while (i.hasNext()){ + ret[a++]=((AtomicRole)i.next()).getName(); + } + Arrays.sort(ret); + return ret; + } + + public String[] al2s(ArrayList<String> al){ + String[] ret=new String[al.size()]; + for (int i = 0; i < al.size(); i++) { + ret[i]=al.get(i); + } + return ret; + } + public void p(String s){ + if(debug_flag){ + System.out.println("\t"+s); + } + + } +} Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-08-20 15:00:11 UTC (rev 8) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-08-20 15:23:17 UTC (rev 9) @@ -1,190 +1,223 @@ -package org.dllearner.server; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.jws.WebMethod; -import javax.jws.WebService; -import javax.jws.soap.SOAPBinding; - -import org.dllearner.Config; -import org.dllearner.LearningProblem; -import org.dllearner.Main; -import org.dllearner.OntologyFileFormat; -import org.dllearner.algorithms.refinement.ROLearner; -import org.dllearner.dl.Individual; -import org.dllearner.dl.KB; -import org.dllearner.reasoning.Reasoner; -import org.dllearner.reasoning.ReasoningMethodUnsupportedException; -import org.dllearner.reasoning.ReasoningService; - -/** - * Offene Fragen: - * - * Welche Rückgabetypen sind erlaubt? - * Wie behandelt man Exceptions (z.B. aus angegebener URI kann keine Ontologie - * gelesen werden)? - * - * @author Jens Lehmann - * - */ -@WebService(name = "DLLearnerWebService") -@SOAPBinding(style = SOAPBinding.Style.RPC) -public class DLLearnerWS { - - // private String ontologyURL; - // private String ontologyFormat; - private Reasoner reasoner; - private ReasoningService rs; - private SortedSet<Individual> positiveExamples; - private SortedSet<Individual> negativeExamples; - - /* - public DLLearnerWS() { - System.out.println("call"); - }*/ - - @PostConstruct - public void postConstruct() { - System.out.println("post construct"); - positiveExamples = new TreeSet<Individual>(); - negativeExamples = new TreeSet<Individual>(); - } - - @PreDestroy - public void preConstruct() { - System.out.println("pre destroy"); - } - - /** - * Specifies the URI of the ontology containing the background - * knowledge. Reads the ontology and sends it to the reasoner. - * - * @param ontologyURI The URI of the ontology to use. - */ - // gleiche Methoden mit verschiedenen Parametern sind offenbar problematisch - /* - @WebMethod - public void readOntology(String ontologyURI) { - readOntology(ontologyURI, "RDF/XML"); - } - */ - - /** - * Specifies the URI of the ontology containing the background - * knowledge and its format. Reads the ontology and sends it to - * the reasoner. - * - * @param ontologyURI The URI of the ontology to use. - * @param format "RDF/XML" or "N-TRIPLES". - */ - @WebMethod - public void readOntology(String ontologyURL, String format) { - // this.ontologyURL = ontologyURL; - // this.ontologyFormat = format; - - // TODO: potentielles Sicherheitsrisiko, da man damit derzeit auch lokale Dateien - // laden könnte (Fix: nur http:// zulassen, kein file://) - URL ontology = null; - try { - ontology = new URL(ontologyURL); - } catch (MalformedURLException e1) { - e1.printStackTrace(); - } - - OntologyFileFormat ofFormat; - if (format.equals("RDF/XML")) - ofFormat = OntologyFileFormat.RDF_XML; - else - ofFormat = OntologyFileFormat.N_TRIPLES; - - Map<URL, OntologyFileFormat> m = new HashMap<URL, OntologyFileFormat>(); - m.put(ontology, ofFormat); - - // Default-URI für DIG-Reasoner setzen - try { - Config.digReasonerURL = new URL("http://localhost:8081"); - } catch (MalformedURLException e) { - // Exception tritt nie auf, da URL korrekt - e.printStackTrace(); - } - - reasoner = Main.createReasoner(new KB(), m); - rs = new ReasoningService(reasoner); - } - - /* - // String[] funktioniert leider noch nicht - @WebMethod - public void addPositiveExamples(String[] posExamples) { - for(String example : posExamples) - positiveExamples.add(new Individual(example)); - } - - @WebMethod - public void addNegativeExamples(String[] negExamples) { - for(String example : negExamples) - negativeExamples.add(new Individual(example)); - } - */ - - @WebMethod - public void addPositiveExample(String posExample) { - positiveExamples.add(new Individual(posExample)); - } - - @WebMethod - public void addNegativeExample(String negExample) { - negativeExamples.add(new Individual(negExample)); - } - - @WebMethod - public void removePositiveExample(String posExample) { - positiveExamples.remove(new Individual(posExample)); - } - - @WebMethod - public void removeNegativeExample(String negExample) { - negativeExamples.remove(new Individual(negExample)); - } - - @WebMethod - public String learnConcept() { - // notwendige Vorverarbeitungsschritte für den Lernalgorithmus - // - es müssen ein paar Konzepte, die ev. von Jena generiert wurden ignoriert - // werden - // - die Subsumptionhierarchie muss erstellt werden - // - die Subsumptionhierarchie wird verbessert um das Lernen effizienter zu machen - Main.autoDetectConceptsAndRoles(rs); - reasoner.prepareSubsumptionHierarchy(); - if (Config.Refinement.improveSubsumptionHierarchy) { - try { - reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); - } catch (ReasoningMethodUnsupportedException e) { - // solange DIG-Reasoner eingestellt ist, schlägt diese Operation nie fehl - e.printStackTrace(); - } - } - - System.out.println(positiveExamples); - System.out.println(negativeExamples); - - LearningProblem learningProblem = new LearningProblem(rs, positiveExamples, negativeExamples); - // erstmal wird nur der Refinement-Learner als Web-Service angeboten - ROLearner learner = new ROLearner(learningProblem); - return learner.getBestSolution().toString(); - } - - // Testmethode - @WebMethod - public String hello(String name) { - return "Hello " + name + "!"; - } - +package org.dllearner.server; + +import java.util.HashMap; +import java.util.Random; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; + +import org.dllearner.server.exceptions.ClientNotKnownException; +import org.dllearner.server.exceptions.NoOntologySelectedException; +import org.dllearner.server.exceptions.OntologyURLNotValid; + +/** + * Offene Fragen: + * + * Welche Rückgabetypen sind erlaubt? + * Wie behandelt man Exceptions (z.B. aus angegebener URI kann keine Ontologie + * gelesen werden)? + * + * @author Jens Lehmann + * + */ +@WebService(name = "DLLearnerWebService") +@SOAPBinding(style = SOAPBinding.Style.RPC) +public class DLLearnerWS { + Random rand=new Random(); + private HashMap<Integer, ClientState> clients; + + // private String ontologyURL; + // private String ontologyFormat; + + + + public DLLearnerWS(){ + this.clients=new HashMap<Integer, ClientState>(); + + } + + /** + * + * + * + */ + @WebMethod + public int getID(){ + int id=rand.nextInt(); + while (id<=0){ + id=rand.nextInt(); + } + + // dont change to local function get, cause of exception + ClientState c=this.clients.get(new Long(id)); + if(c!=null){ + return getID(); + } + else { + this.clients.put(new Integer(id), new ClientState()); + System.out.println("new Client with id: "+id); + return id; + } + + } + + @WebMethod + public void addPositiveExample(int id,String posExample) throws ClientNotKnownException{ + ClientState c=getClientState(id); + c.addPositiveExample(posExample); + //positiveExamples.add(new Individual(posExample)); + } + @WebMethod + public void addNegativeExample(int id,String negExample) throws ClientNotKnownException { + ClientState c=getClientState(id); + c.addNegativeExample(negExample); + } + @WebMethod + public void addIgnoredConcept(int id,String concept)throws ClientNotKnownException { + getClientState(id).addIgnoredConcept(concept); + } + + @WebMethod + public String[] selectInstancesForAConcept(int id,String Concept)throws ClientNotKnownException,NoOntologySelectedException{ + return getClientState(id).selectInstancesForAConcept(Concept); + } + + + @WebMethod + public String[] getPositiveExamples(int id)throws ClientNotKnownException{ + ClientState c=getClientState(id); + return c.getPositiveExamples(); + } + @WebMethod + public String[] getNegativeExamples(int id)throws ClientNotKnownException{ + ClientState c=getClientState(id); + return c.getNegativeExamples(); + } + @WebMethod + public String[] getIgnoredConcepts(int id)throws ClientNotKnownException{ + return getClientState(id).getIgnoredConcepts(); + } + + @WebMethod + public boolean removePositiveExample(int id, String pos)throws ClientNotKnownException{ + return getClientState(id).removePositiveExample(pos); + } + + @WebMethod + public boolean removeNegativeExample(int id, String neg)throws ClientNotKnownException{ + return getClientState(id).removeNegativeExample(neg); + } + @WebMethod + public boolean removeAllExamples(int id)throws ClientNotKnownException{ + return getClientState(id).removeAllExamples(); + } + @WebMethod + public boolean removeAllPositiveExamples(int id)throws ClientNotKnownException{ + return getClientState(id).removeAllPositiveExamples(); + } + @WebMethod + public boolean removeAllNegativeExamples(int id)throws ClientNotKnownException{ + return getClientState(id).removeAllNegativeExamples(); + } + @WebMethod + public void removeIgnoredConcept(int id,String concept)throws ClientNotKnownException{ + getClientState(id).removeIgnoredConcept(concept); + } + + @WebMethod + public String getCurrentOntologyURL(int id)throws ClientNotKnownException,NoOntologySelectedException{ + return getClientState(id).getCurrentOntologyURL(); + + } + + @WebMethod + public String[] getInstances(int id)throws ClientNotKnownException,NoOntologySelectedException{ + return getClientState(id).getInstances(); + } + + @WebMethod + public String[] getAtomicConcepts(int id)throws ClientNotKnownException,NoOntologySelectedException{ + return getClientState(id).getAtomicConcepts(); + } + + @WebMethod + public String[] getAtomicRoles(int id)throws ClientNotKnownException,NoOntologySelectedException{ + return getClientState(id).getAtomicRoles(); + } + @WebMethod + public String[] getIndividualsForARole(int id,String Role)throws ClientNotKnownException, NoOntologySelectedException{ + return getClientState(id).getIndividualsForARole(Role); + } + @WebMethod + public String getSubsumptionHierarchy(int id)throws ClientNotKnownException, NoOntologySelectedException{ + return getClientState(id).getSubsumptionHierarchy(); + } + + @WebMethod + public String[] retrieval(int id,String Concept)throws ClientNotKnownException,NoOntologySelectedException{ + return getClientState(id).retrieval(Concept); + } + + @WebMethod + public void readOntology(int id,String ontologyURL, String format)throws ClientNotKnownException,OntologyURLNotValid{ + getClientState(id).readOntology(ontologyURL, format); + + } + + @WebMethod + public void removeOntology(int id)throws ClientNotKnownException{ + getClientState(id).removeOntology(); + } + + @WebMethod + public String learnConcept(int id)throws ClientNotKnownException{ + return "Deprecated method"; + + } + + + @WebMethod + public String getAlgorithmStatus(int id ) throws ClientNotKnownException{ + + return getClientState(id).getAlgorithmStatus(); + } + + + @WebMethod + public void learnMonitored(int id )throws ClientNotKnownException{ + getClientState(id).learnMonitored(); + } + /*@WebMethod + public void relearn(int id,String Concept )throws ClientNotKnownException{ + getClientState(id).relearn(Concept); + }*/ + + @WebMethod + public String getLastResult(int id)throws ClientNotKnownException{ + return getClientState(id).getLastResult(); + } + + @WebMethod + public void stop(int id)throws ClientNotKnownException{ + getClientState(id).stop(); + } + + + //*************************USER MANAGEMENT + + public ClientState getClientState(int id)throws ClientNotKnownException{ + System.out.println("Request from "+id); + ClientState c=this.clients.get(new Integer(id)); + if(c==null){ + //System.out.println(clients.keySet().toString()); + throw new ClientNotKnownException("Client with id: "+id+" is not known","ClientNotKnownException");}; + return c; + + } + + + + + } \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS2.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS2.java 2007-08-20 15:23:17 UTC (rev 9) @@ -0,0 +1,68 @@ +package org.dllearner.server; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; + +import org.dllearner.server.exceptions.ClientNotKnownException; + + +/** + * Offene Fragen: + * + * Welche Rückgabetypen sind erlaubt? + * Wie behandelt man Exceptions (z.B. aus angegebener URI kann keine Ontologie + * gelesen werden)? + * + * @author Jens Lehmann + * + */ +@WebService(name = "DLLearnerWebService") + +@SOAPBinding(style = SOAPBinding.Style.RPC) +public class DLLearnerWS2 { + + /* + // String[] funktioniert leider noch nicht + @WebMethod + public void addPositiveExamples(String[] posExamples) { + for(String example : posExamples) + positiveExamples.add(new Individual(example)); + } + + @WebMethod + public void addNegativeExamples(String[] negExamples) { + for(String example : negExamples) + negativeExamples.add(new Individual(example)); + } + */ + + @WebMethod + /** + * @param name + * + * @return The sum + * @throws AddNumbersException + * if any of the numbers to be added is negative. + * + **/ + public String hellosimple(String name) throws ClientNotKnownException{ + /*for (int i = 0; i < name.length; i++) { + name[i]=i+"nnnn<br>"; + }*/ + if(name.equals("aa"))throw new ClientNotKnownException("a","b"); + + return "bbb"; + } + + + // Testmethode + @WebMethod + public String hello(String name){ + name=null; + //name.substring(5); + //throw new NullPointerException(); + return "Hello " + name + "!"; + } + +} \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java 2007-08-20 15:00:11 UTC (rev 8) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java 2007-08-20 15:23:17 UTC (rev 9) @@ -1,42 +1,71 @@ -package org.dllearner.server; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -import javax.xml.ws.Endpoint; - -public class DLLearnerWSStart { - - public static void main(String[] args) { - String url = "http://localhost:8181/services"; - if (args.length > 0) - url = args[0]; - - System.out.print("Starting DL-Learner web service at " + url + " ... "); - Endpoint endpoint = Endpoint.publish(url, new DLLearnerWS()); - System.out.println("OK."); - - System.out.println("Type \"exit\" to terminate web service."); - boolean terminate = false; - String inputString = ""; - do { - BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); - - try { - inputString = input.readLine(); - } catch (IOException e) { - e.printStackTrace(); - } - - if (inputString.equals("exit")) - terminate = true; - - } while (!terminate); - - System.out.print("Stopping web service ... "); - endpoint.stop(); - System.out.println("OK."); - } - -} +package org.dllearner.server; + + + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import javax.xml.ws.Endpoint; + +import com.sun.net.httpserver.HttpContext; +import com.sun.net.httpserver.HttpServer; + + +public class DLLearnerWSStart { + + public static void main(String[] args) { + String url = "http://139.18.114.78:8181/services"; + if (args.length > 0) + url = args[0]; + try{ + + InetSocketAddress isa=new InetSocketAddress("localhost",8181); + HttpServer server = HttpServer.create(isa, 5); + ExecutorService threads = Executors.newFixedThreadPool(5); + server.setExecutor(threads); + server.start(); + + System.out.print("Starting DL-Learner web service at http://" + + isa.getHostName()+":"+isa.getPort()+ "/services ... "); + Endpoint endpoint = Endpoint.create(new DLLearnerWS()); + //Endpoint endpoint = Endpoint.create(new CustomDataClass()); + HttpContext context = server.createContext("/services"); + endpoint.publish(context); + //Endpoint endpoint = Endpoint.publish(url, new DLLearnerWS()); + + System.out.println("OK."); + + + + System.out.println("Type \"exit\" to terminate web service."); + boolean terminate = false; + String inputString = ""; + do { + BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); + + try { + inputString = input.readLine(); + } catch (IOException e) { + e.printStackTrace(); + } + + if (inputString.equals("exit")) + terminate = true; + + } while (!terminate); + + System.out.print("Stopping web service ... "); + endpoint.stop(); + + server.stop(1); + threads.shutdown(); + System.out.println("OK."); + }catch (Exception e) {e.printStackTrace();} + } + +} Added: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java 2007-08-20 15:23:17 UTC (rev 9) @@ -0,0 +1,166 @@ +package org.dllearner.server; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; + +import org.dllearner.Config; +import org.dllearner.LearningProblem; +import org.dllearner.Main; +import org.dllearner.OntologyFileFormat; +import org.dllearner.algorithms.refinement.ROLearner; +import org.dllearner.dl.Individual; +import org.dllearner.dl.KB; +import org.dllearner.reasoning.Reasoner; +import org.dllearner.reasoning.ReasoningMethodUnsupportedException; +import org.dllearner.reasoning.ReasoningService; + +/** + * Offene Fragen: + * + * Welche Rückgabetypen sind erlaubt? + * Wie behandelt man Exceptions (z.B. aus angegebener URI kann keine Ontologie + * gelesen werden)? + * + * @author Jens Lehmann + * + */ +@WebService(name = "DLLearnerWebService") +@SOAPBinding(style = SOAPBinding.Style.RPC) +public class DLLearnerWSoriginal { + + // private String ontologyURL; + // private String ontologyFormat; + private Reasoner reasoner; + private ReasoningService rs; + private SortedSet<Individual> positiveExamples = new TreeSet<Individual>(); + private SortedSet<Individual> negativeExamples = new TreeSet<Individual>(); + + /** + * Specifies the URI of the ontology containing the background + * knowledge. Reads the ontology and sends it to the reasoner. + * + * @param ontologyURI The URI of the ontology to use. + */ + // gleiche Methoden mit verschiedenen Parametern sind offenbar problematisch + /* + @WebMethod + public void readOntology(String ontologyURI) { + readOntology(ontologyURI, "RDF/XML"); + } + */ + + /** + * Specifies the URI of the ontology containing the background + * knowledge and its format. Reads the ontology and sends it to + * the reasoner. + * + * @param ontologyURI The URI of the ontology to use. + * @param format "RDF/XML" or "N-TRIPLES". + */ + @WebMethod + public void readOntology(String ontologyURL, String format) { + // this.ontologyURL = ontologyURL; + // this.ontologyFormat = format; + + // TODO: potentielles Sicherheitsrisiko, da man damit derzeit auch lokale Dateien + // laden könnte (Fix: nur http:// zulassen, kein file://) + URL ontology = null; + try { + ontology = new URL(ontologyURL); + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + + OntologyFileFormat ofFormat; + if (format.equals("RDF/XML")) + ofFormat = OntologyFileFormat.RDF_XML; + else + ofFormat = OntologyFileFormat.N_TRIPLES; + + Map<URL, OntologyFileFormat> m = new HashMap<URL, OntologyFileFormat>(); + m.put(ontology, ofFormat); + + // Default-URI für DIG-Reasoner setzen + try { + Config.digReasonerURL = new URL("http://localhost:8081"); + } catch (MalformedURLException e) { + // Exception tritt nie auf, da URL korrekt + e.printStackTrace(); + } + + reasoner = Main.createReasoner(new KB(), m); + + rs = new ReasoningService(reasoner); + + } + + + @WebMethod + public String[] testString(String c) { + + return new String[]{"a","b"}; + } + + // String[] funktioniert leider noch nicht + @WebMethod + public void addPositiveExamples(String[] posExamples) { + for(String example : posExamples) + positiveExamples.add(new Individual(example)); + } + + @WebMethod + public void addNegativeExamples(String[] negExamples) { + for(String example : negExamples) + negativeExamples.add(new Individual(example)); + } + + + @WebMethod + public void addPositiveExample(String posExample) { + positiveExamples.add(new Individual(posExample)); + } + + @WebMethod + public void addNegativeExample(String negExample) { + negativeExamples.add(new Individual(negExample)); + } + + @WebMethod + public String learnConcept() { + // notwendige Vorverarbeitungsschritte für den Lernalgorithmus + // - es müssen ein paar Konzepte, die ev. von Jena generiert wurden ignoriert + // werden + // - die Subsumptionhierarchie muss erstellt werden + // - die Subsumptionhierarchie wird verbessert um das Lernen effizienter zu machen + Main.autoDetectConceptsAndRoles(rs); + reasoner.prepareSubsumptionHierarchy(); + if (Config.Refinement.improveSubsumptionHierarchy) { + try { + reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); + } catch (ReasoningMethodUnsupportedException e) { + // solange DIG-Reasoner eingestellt ist, schlägt diese Operation nie fehl + e.printStackTrace(); + } + } + + LearningProblem learningProblem = new LearningProblem(rs, positiveExamples, negativeExamples); + // erstmal wird nur der Refinement-Learner als Web-Service angeboten + ROLearner learner = new ROLearner(learningProblem); + return learner.getBestSolution().toString(); + } + + // Testmethode + @WebMethod + public String hello(String name) { + return "Hello " + name + "!"; + } + +} \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java 2007-08-20 15:23:17 UTC (rev 9) @@ -0,0 +1,81 @@ +package org.dllearner.server; + +import org.dllearner.Config; +import org.dllearner.LearningProblem; +import org.dllearner.Main; +import org.dllearner.algorithms.refinement.ROLearner; +import org.dllearner.reasoning.ReasoningMethodUnsupportedException; + +public class LearnMonitor extends Thread { + + + private ClientState c; + private boolean active = false; + + //private ROLearner ROL; + + public LearnMonitor(ClientState c){ + this.c=c; + } + + + public void end(){ + + System.out.println("trying to end"); + System.out.println("ROL2"+c.ROL); + this.c.ROL.stop(); + c.setLastResult(c.ROL.getBestSolution().toString()); + c.setStatus("stopped"); + } + + public void learn(){ + + this.start(); + + } + + public void run(){ + try{ + c.setStatus("still running"); + active=true; + c.setStatus("running"); + + // notwendige Vorverarbeitungsschritte für den Lernalgorithmus + // - es müssen ein paar Konzepte, die ev. von Jena generiert wurden ignoriert + // werden + // - die Subsumptionhierarchie muss erstellt werden + // - die Subsumptionhierarchie wird verbessert um das Lernen effizienter zu machen + Main.autoDetectConceptsAndRoles(c.getRs()); + c.getReasoner().prepareSubsumptionHierarchy(); + if (Config.Refinement.improveSubsumptionHierarchy) { + try { + c.getReasoner().getSubsumptionHierarchy().improveSubsumptionHierarchy(); + } catch (ReasoningMethodUnsupportedException e) { + // solange DIG-Reasoner eingestellt ist, schlägt diese Operation nie fehl + e.printStackTrace(); + } + } + c.p("learning started"); + LearningProblem learningProblem = new LearningProblem(c.getRs(), c.getPosExamples(), c.getNegExamples()); + // erstmal wird nur der Refinement-Learner als Web-Service angeboten + //System.out.println("aaaa"); + c.ROL = new ROLearner(learningProblem); + + c.ROL.start(); + //new ROLearner(); + //c.p(("ROL1"+ROL)); + + + + + + + //c.setLastResult(c.ROL.getBestSolution().toString()); + c.setLastResult(c.ROL.getBestSolution().toString()); + c.setStatus("finished"); + + }catch (Exception e) {e.printStackTrace();} + finally{active=false;}; + } + +} Added: trunk/src/dl-learner/org/dllearner/server/exceptions/ClientNotKnownException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/exceptions/ClientNotKnownException.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/exceptions/ClientNotKnownException.java 2007-08-20 15:23:17 UTC (rev 9) @@ -0,0 +1,14 @@ +package org.dllearner.server.exceptions; + +public class ClientNotKnownException extends Exception { + String detail; + + public ClientNotKnownException (String message, String detail) { + super (message); + this.detail = detail; + } + + public String getDetail () { + return detail; + } +} Added: trunk/src/dl-learner/org/dllearner/server/exceptions/NoOntologySelectedException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/exceptions/NoOntologySelectedException.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/exceptions/NoOntologySelectedException.java 2007-08-20 15:23:17 UTC (rev 9) @@ -0,0 +1,14 @@ +package org.dllearner.server.exceptions; + +public class NoOntologySelectedException extends Exception { + String detail; + + public NoOntologySelectedException (String message, String detail) { + super (message); + this.detail = detail; + } + + public String getDetail () { + return detail; + } +} Added: trunk/src/dl-learner/org/dllearner/server/exceptions/OntologyURLNotValid.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/exceptions/OntologyURLNotValid.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/exceptions/OntologyURLNotValid.java 2007-08-20 15:23:17 UTC (rev 9) @@ -0,0 +1,14 @@ +package org.dllearner.server.exceptions; + +public class OntologyURLNotValid extends Exception { + String detail; + + public OntologyURLNotValid (String message, String detail) { + super (message); + this.detail = detail; + } + + public String getDetail () { + return detail; + } +} Added: trunk/src/dl-learner/org/dllearner/server/jaxws/ClientNotKnownExceptionBean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/jaxws/ClientNotKnownExceptionBean.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/jaxws/ClientNotKnownExceptionBean.java 2007-08-20 15:23:17 UTC (rev 9) @@ -0,0 +1,63 @@ + +package org.dllearner.server.jaxws; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * This class was generated by the JAXWS SI. + * JAX-WS RI 2.0_02-b08-fcs + * Generated source version: 2.0_02 + * + */ +@XmlRootElement(name = "ClientNotKnownException", namespace = "http://ws/") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ClientNotKnownException", namespace = "http://ws/", propOrder = { + "detail", + "message" +}) +public class ClientNotKnownExceptionBean { + + private String detail; + private String message; + + /** + * + * @return + * returns String + */ + public String getDetail() { + return this.detail; + } + + /** + * + * @param detail + * the value for the detail property + */ + public void setDetail(String detail) { + this.detail = detail; + } + + /** + * + * @return + * returns String + */ + public String getMessage() { + return this.message; + } + + /** + * + * @param message + * the value for the message property + */ + public void setMessage(String message) { + this.message = message; + } + +} Added: trunk/src/dl-learner/org/dllearner/server/jaxws/NoOntologySelectedExceptionBean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/jaxws/NoOntologySelectedExceptionBean.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/jaxws/NoOntologySelectedExceptionBean.java 2007-08-20 15:23:17 UTC (rev 9) @@ -0,0 +1,63 @@ + +package org.dllearner.server.jaxws; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * This class was generated by the JAXWS SI. + * JAX-WS RI 2.0_02-b08-fcs + * Generated source version: 2.0_02 + * + */ +@XmlRootElement(name = "NoOntologySelectedException", namespace = "http://ws/") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "NoOntologySelectedException", namespace = "http://ws/", propOrder = { + "detail", + "message" +}) +public class NoOntologySelectedExceptionBean { + + private String detail; + private String message; + + /** + * + * @return + * returns String + */ + public String getDetail() { + return this.detail; + } + + /** + * + * @param detail + * the value for the detail property + */ + public void setDetail(String detail) { + this.detail = detail; + } + + /** + * + * @return + * returns String + */ + public String getMessage() { + return this.message; + } + + /** + * + * @param message + * the value for the message property + */ + public void setMessage(String message) { + this.message = message; + } + +} Added: trunk/src/dl-learner/org/dllearner/server/jaxws/OntologyURLNotValidBean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/jaxws/OntologyURLNotValidBean.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/jaxws/OntologyURLNotValidBean.java 2007-08-20 15:23:17 UTC (rev 9) @@ -0,0 +1,63 @@ + +package org.dllearner.server.jaxws; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * This class was generated by the JAXWS SI. + * JAX-WS RI 2.0_02-b08-fcs + * Generated source version: 2.0_02 + * + */ +@XmlRootElement(name = "OntologyURLNotValid", namespace = "http://ws/") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "OntologyURLNotValid", namespace = "http://ws/", propOrder = { + "detail", + "message" +}) +public class OntologyURLNotValidBean { + + private String detail; + private String message; + + /** + * + * @return + * returns String + */ + public String getDetail() { + return this.detail; + } + + /** + * + * @param detail + * the value for the detail property + */ + public void setDetail(String detail) { + this.detail = detail; + } + + /** + * + * @return + * returns String + */ + public String getMessage() { + return this.message; + } + + /** + * + * @param message + * the value for the message property + */ + public void setMessage(String message) { + this.message = message; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2007-08-22 10:39:12
|
Revision: 20 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=20&view=rev Author: kurzum Date: 2007-08-22 03:39:07 -0700 (Wed, 22 Aug 2007) Log Message: ----------- updated the web service Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS2.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java Deleted: trunk/src/dl-learner/org/dllearner/server/ClientState.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-08-22 10:27:46 UTC (rev 19) +++ trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-08-22 10:39:07 UTC (rev 20) @@ -1,532 +0,0 @@ -package org.dllearner.server; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.dllearner.Config; -import org.dllearner.ConfigurationManager; -import org.dllearner.ConfigurationOption; -import org.dllearner.Main; -import org.dllearner.OntologyFileFormat; -import org.dllearner.algorithms.refinement.ROLearner; -import org.dllearner.dl.AtomicConcept; -import org.dllearner.dl.AtomicRole; -import org.dllearner.dl.Concept; -import org.dllearner.dl.Individual; -import org.dllearner.dl.KB; -import org.dllearner.reasoning.Reasoner; -import org.dllearner.reasoning.ReasoningMethodUnsupportedException; -import org.dllearner.reasoning.ReasoningService; - -import org.dllearner.server.exceptions.NoOntologySelectedException; -import org.dllearner.server.exceptions.OntologyURLNotValid; - -import com.hp.hpl.jena.shared.DoesNotExistException; -import com.hp.hpl.jena.shared.JenaException; - -public class ClientState { - - private String reasonerURL="http://localhost:8081"; - //private String reasonerURL="http://localhost:3490"; - - private SortedSet<Individual> positiveExamples = new TreeSet<Individual>(); - public SortedSet<Individual> getPosExamples() { return this.positiveExamples;} - - private SortedSet<Individual> negativeExamples = new TreeSet<Individual>(); - public SortedSet<Individual> getNegExamples() { return this.negativeExamples;} - - private SortedSet<String> ignoredConcept = new TreeSet<String>(); - - - private Reasoner reasoner; - public Reasoner getReasoner() { return reasoner;} - - private ReasoningService rs; - public ReasoningService getRs() { return rs; } - - private String currentOntologyURL=null; - private boolean debug_flag=true; - private LearnMonitor lm=null; - - private String lastResult=""; - public String getLastResult(){ - try{ - return ROL.getBestSolution().toString(); - }catch (Exception e) {} - return this.lastResult; } - public void setLastResult(String lastResult) {this.lastResult = lastResult;} - - private String status="maiden-like"; - public void setStatus(String status) {this.status = status;} - - ConfigurationManager confMgr; - public void addOption(ConfigurationOption c){confMgr.applyConfigurationOption(c);} - ROLearner ROL; - - public ClientState() { - - - TreeSet<ConfigurationOption> s=new TreeSet<ConfigurationOption>(); - //s.add(new ConfigurationOption("refinement","quiet","true")); - /*s.add(new ConfigurationOption()); - s.add(new ConfigurationOption()); - s.add(new ConfigurationOption()); - s.add(new ConfigurationOption()); - s.add(new ConfigurationOption()); - s.add(new ConfigurationOption());*/ - - confMgr = new ConfigurationManager(s); - addOption(new ConfigurationOption("refinement","quiet","true")); - //confMgr.applyOptions(); - - } - - - - - public void addPositiveExample(String posExample) { - positiveExamples.add(new Individual(posExample)); - p("added pos: "+posExample); - } - - - public void addNegativeExample(String negExample) { - negativeExamples.add(new Individual(negExample)); - p("added neg: "+negExample); - } - - public void addIgnoredConcept(String concept) { - ignoredConcept.add(concept); - p("added ignoredConcepts: "+concept); - } - - public String[] selectInstancesForAConcept(String Concept)throws NoOntologySelectedException{ - if(Concept.endsWith("#Thing"))return new String[]{}; - AtomicConcept SelectedConcept=new AtomicConcept(Concept); - ArrayList<String> al=new ArrayList<String>(); - Individual indtmp=null; - Set ConceptSet=null; - AtomicConcept ac=null; - - - System.out.println("selectInstancesForAConcept: "+Concept); - // add all positives - Set positives=rs.retrieval(SelectedConcept); - Iterator i = positives.iterator(); - while(i.hasNext()){ - indtmp=(Individual)i.next(); - p("added "+indtmp.getName()+" to positives"); - al.add("added "+indtmp.getName()+" to positives"); - positiveExamples.add(indtmp); - } - - //find more general concepts - ArrayList<AtomicConcept> superConcepts=new ArrayList<AtomicConcept>(); - try{ - //ConceptSet = rs.getSubsumptionHierarchy().getMoreGeneralConcepts(new AtomicConcept(Concept)); - //System.out.println(ConceptSet); - //Concept c=new AtomicConcept(Concept); - /*Set<AtomicConcept> s=rs.getAtomicConcepts(); - Set<Concept> sc=new TreeSet<Concept>(); - Iterator a=s.iterator(); - while (a.hasNext()) { - sc.add((Concept) a.next()); - } - sc=rs.subsumes(sc,new AtomicConcept(Concept));*/ - superConcepts=subsumesAll(SelectedConcept); - - //System.out.println("sizebefore: "+"size after:"+sc); - }catch (Exception e) {e.printStackTrace();} - - -// remove top - for (int j = 0; j < superConcepts.size(); ) { - //TODO no unique name assumption? - if(superConcepts.get(j).getName().equals(SelectedConcept.getName())){ - superConcepts.remove(j); - j=0; - continue; - } - if(superConcepts.get(j).getName().equals("TOP")){ - superConcepts.remove(j); - j=0; - continue; - } - j++; - } - - System.out.println("Found all those:"+ superConcepts); - - ac=null; - - if(superConcepts.size()==0){return al2s(al); }//TODO - else - { // add all negatives of all superclasses; - - //Iterator it=ConceptSet.iterator(); - for (int jj = 0; jj < superConcepts.size(); jj++) - { - ac=superConcepts.get(jj); - p("next this: "+ac.getName()); - Set negatives=rs.retrieval(ac); - Iterator i2 = negatives.iterator(); - indtmp=null; - while(i2.hasNext()){ - - indtmp=(Individual)i2.next(); - - if(!positives.contains(indtmp)){ - - p("added "+indtmp.getName()+" to NEGATIVES"); - al.add("added "+indtmp.getName()+" to NEGATIVES"); - negativeExamples.add(indtmp); - } - else{ - p("skipped "+indtmp.getName()); - al.add("skipped "+indtmp.getName()); - } - - } - }//endfor - return al2s(al); - } - - - } - - public ArrayList<AtomicConcept> subsumesAll(AtomicConcept c){ - Set s=rs.getAtomicConcepts(); - ArrayList<AtomicConcept> ret=new ArrayList<AtomicConcept>(); - Iterator i=s.iterator(); - while (i.hasNext()) { - AtomicConcept element = (AtomicConcept) i.next(); - if(rs.subsumes(element, c)) - { - ret.add(element); - } - - } - return ret; - } - public String[] getPositiveExamples(){ - String[] ret=new String[positiveExamples.size()]; - Iterator i=positiveExamples.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((Individual)i.next()).getName(); - } - //p("getPositiveEx"); - return ret; - } - public String[] getNegativeExamples(){ - String[] ret=new String[negativeExamples.size()]; - Iterator i=negativeExamples.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((Individual)i.next()).getName(); - } - //p("getNegativeEx"); - return ret; - } - - public String[] getIgnoredConcepts() { - String[] ret=new String[ignoredConcept.size()]; - Iterator i=ignoredConcept.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((String)i.next()); - } - //p("getNegativeEx"); - return ret; - } - - public String getSubsumptionHierarchy() throws NoOntologySelectedException { - try{ - return this.rs.getSubsumptionHierarchy().toString(); - }catch (Exception e) {throw new NoOntologySelectedException("Subsumptionhierarchy",e.getMessage());} - - } - - - - public boolean removeNegativeExample(String NegExample){ - p("removed from neg: "+NegExample); - return negativeExamples.remove(new Individual(NegExample)); - } - public boolean removePositiveExample(String PosExample){ - p("removed from pos: "+PosExample); - return positiveExamples.remove(new Individual(PosExample)); - } - - public boolean removeAllPositiveExamples(){ - positiveExamples = new TreeSet<Individual>(); - p("removing all positive examples"); - return true; - } - public boolean removeAllNegativeExamples(){ - negativeExamples = new TreeSet<Individual>(); - p("removing all negative examples"); - return true; - } - - public boolean removeAllExamples(){ - positiveExamples = new TreeSet<Individual>(); - negativeExamples = new TreeSet<Individual>(); - p("removing all examples"); - return true; - } - - public void removeIgnoredConcept(String concept) { - //ignoredConcept.add(concept); - this.ignoredConcept.remove(concept); - p("removed ignoredConcepts: "+concept); - } - - public String[] getInstances()throws NoOntologySelectedException{ - try{ - SortedSet<Individual> s=rs.getIndividuals(); - //System.out.println(s); - String[] ret=new String[s.size()]; - Iterator i=s.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((Individual)i.next()).getName(); - } - Arrays.sort(ret); - //p("getInstances"); - return ret; - }catch (Exception e) {throw new NoOntologySelectedException("Failed to get instances, no ontology selected","");} - } - - public String getCurrentOntologyURL()throws NoOntologySelectedException{ - p("getCurrentOntology: "+currentOntologyURL); - if(currentOntologyURL==null)throw new NoOntologySelectedException("Select Ontology First","quatsch"); - else return currentOntologyURL; - } - - public String getAlgorithmStatus(){ - return this.status; - } - - /** - * Specifies the URI of the ontology containing the background - * knowledge. Reads the ontology and sends it to the reasoner. - * - * @param ontologyURI The URI of the ontology to use. - */ - // gleiche Methoden mit verschiedenen Parametern sind offenbar problematisch - /* - @WebMethod - public void readOntology(String ontologyURI) { - readOntology(ontologyURI, "RDF/XML"); - } - */ - - - public void removeOntology() { - this.currentOntologyURL=null; - this.reasoner=null; - this.rs=null; - this.positiveExamples = new TreeSet<Individual>(); - this.negativeExamples = new TreeSet<Individual>(); - this.ignoredConcept=new TreeSet<String>(); - p("removing Ontology"); - - } - - /** - * Specifies the URI of the ontology containing the background - * knowledge and its format. Reads the ontology and sends it to - * the reasoner. - * - * @param ontologyURI The URI of the ontology to use. - * @param format "RDF/XML" or "N-TRIPLES". - */ - - - public void readOntology(String ontologyURL, String format) throws OntologyURLNotValid{ - this.currentOntologyURL=ontologyURL; - p("trying to read: "+ontologyURL+" ::"+format); - try{ - // this.ontologyURL = ontologyURL; - // this.ontologyFormat = format; - - // TODO: potentielles Sicherheitsrisiko, da man damit derzeit auch lokale Dateien - // laden könnte (Fix: nur http:// zulassen, kein file://) - URL ontology = null; - try { - ontology = new URL(ontologyURL); - } catch (MalformedURLException e1) { - this.removeOntology(); - throw new OntologyURLNotValid("The URL of the Ontology is not correct<br>\nCheck settings and URL","OntologyURLNotValid"); - - } - - OntologyFileFormat ofFormat; - if (format.equals("RDF/XML")) - ofFormat = OntologyFileFormat.RDF_XML; - else - ofFormat = OntologyFileFormat.N_TRIPLES; - - Map<URL, OntologyFileFormat> m = new HashMap<URL, OntologyFileFormat>(); - m.put(ontology, ofFormat); - - // Default-URI für DIG-Reasoner setzen - - try { - Config.digReasonerURL = new URL(reasonerURL); - } catch (MalformedURLException e) { - // Exception tritt nie auf, da URL korrekt - e.printStackTrace(); - } - - reasoner = Main.createReasoner(new KB(), m); - rs = new ReasoningService(reasoner); - - Main.autoDetectConceptsAndRoles(rs); - reasoner.prepareSubsumptionHierarchy(); - if (Config.Refinement.improveSubsumptionHierarchy) { - try { - reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); - } catch (ReasoningMethodUnsupportedException e) { - // solange DIG-Reasoner eingestellt ist, schlägt diese Operation nie fehl - e.printStackTrace(); - } - } - p(rs.getSubsumptionHierarchy().toString()); - //rs.getRoleMembers(arg0) - } - catch (DoesNotExistException e) { - this.removeOntology(); - throw new OntologyURLNotValid("The URL of the Ontology is not correct<br>\nCheck settings and URL","OntologyURLNotValid"); - } - catch (JenaException e) { - e.printStackTrace();} - - - /*catch(Exception e2) { - - //p("exception:"+e.getMessage()); - e2.printStackTrace(); - }*/ - p("Ontology read: "+currentOntologyURL); - } - - - public void learnMonitored(){ - addOption(new ConfigurationOption("refinement","ignoredConcepts",ignoredConcept)); - this.lm=new LearnMonitor(this); - this.lm.start(); - //this.lm.learn(this); - } - - /*public void relearn(){ - //TreeSet<String> s=new TreeSet<String>(); - //new ConfigurationOption(); - this.lm=new LearnMonitor(this); - this.lm.start(); - //this.lm.learn(this); - }*/ - - - public String[] getAtomicConcepts()throws NoOntologySelectedException{ - try{ - return SortedSet2StringListConcepts( rs.getAtomicConcepts()); - }catch (Exception e) {throw new NoOntologySelectedException("Select Ontology First","ddddd");} - } - - public String[] retrieval(String Concept)throws NoOntologySelectedException{ - return SortedSet2StringListIndividuals(rs.retrieval(new AtomicConcept(Concept))); - } - - public String[] getAtomicRoles()throws NoOntologySelectedException{ - return SortedSet2StringListRoles( rs.getAtomicRoles()); - } - - public String[] getIndividualsForARole(String Role)throws NoOntologySelectedException{ - Map m=rs.getRoleMembers(new AtomicRole(Role)); - Set s=m.keySet(); - return SortedSet2StringListIndividuals(s); - } - - public synchronized void stop(){ - System.out.println("ROL"+this.ROL); - - System.out.println("lm"+lm); - System.out.println("lmstate"+lm.getState()); - System.out.println("lmalive"+lm.isAlive()); - System.out.println("lminterrupt"+lm.isInterrupted()); - this.ROL.stop(); - /*try{ - synchronized (this.lm) { - //this.lm.yield(); - } - }catch (Exception e) {e.printStackTrace();}*/ - System.out.println("lmstate"+lm.getState()); - System.out.println("lmalive"+lm.isAlive()); - System.out.println("lminterrupt"+lm.isInterrupted()); - - //this.ROL.stop(); - //this.lm.interrupt(); - - //this.lm.end(); - //this.lm.notify(); - } - - public String[] SortedSet2StringListIndividuals(Set s){ - - String[] ret=new String[s.size()]; - Iterator i=s.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((Individual)i.next()).getName(); - } - Arrays.sort(ret); - return ret; - } - - public String[] SortedSet2StringListConcepts(Set s){ - - String[] ret=new String[s.size()]; - Iterator i=s.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((AtomicConcept)i.next()).getName(); - } - Arrays.sort(ret); - return ret; - } - public String[] SortedSet2StringListRoles(Set s){ - - String[] ret=new String[s.size()]; - Iterator i=s.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((AtomicRole)i.next()).getName(); - } - Arrays.sort(ret); - return ret; - } - - public String[] al2s(ArrayList<String> al){ - String[] ret=new String[al.size()]; - for (int i = 0; i < al.size(); i++) { - ret[i]=al.get(i); - } - return ret; - } - public void p(String s){ - if(debug_flag){ - System.out.println("\t"+s); - } - - } -} Deleted: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-08-22 10:27:46 UTC (rev 19) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-08-22 10:39:07 UTC (rev 20) @@ -1,223 +0,0 @@ -package org.dllearner.server; - -import java.util.HashMap; -import java.util.Random; - -import javax.jws.WebMethod; -import javax.jws.WebService; -import javax.jws.soap.SOAPBinding; - -import org.dllearner.server.exceptions.ClientNotKnownException; -import org.dllearner.server.exceptions.NoOntologySelectedException; -import org.dllearner.server.exceptions.OntologyURLNotValid; - -/** - * Offene Fragen: - * - * Welche Rückgabetypen sind erlaubt? - * Wie behandelt man Exceptions (z.B. aus angegebener URI kann keine Ontologie - * gelesen werden)? - * - * @author Jens Lehmann - * - */ -@WebService(name = "DLLearnerWebService") -@SOAPBinding(style = SOAPBinding.Style.RPC) -public class DLLearnerWS { - Random rand=new Random(); - private HashMap<Integer, ClientState> clients; - - // private String ontologyURL; - // private String ontologyFormat; - - - - public DLLearnerWS(){ - this.clients=new HashMap<Integer, ClientState>(); - - } - - /** - * - * - * - */ - @WebMethod - public int getID(){ - int id=rand.nextInt(); - while (id<=0){ - id=rand.nextInt(); - } - - // dont change to local function get, cause of exception - ClientState c=this.clients.get(new Long(id)); - if(c!=null){ - return getID(); - } - else { - this.clients.put(new Integer(id), new ClientState()); - System.out.println("new Client with id: "+id); - return id; - } - - } - - @WebMethod - public void addPositiveExample(int id,String posExample) throws ClientNotKnownException{ - ClientState c=getClientState(id); - c.addPositiveExample(posExample); - //positiveExamples.add(new Individual(posExample)); - } - @WebMethod - public void addNegativeExample(int id,String negExample) throws ClientNotKnownException { - ClientState c=getClientState(id); - c.addNegativeExample(negExample); - } - @WebMethod - public void addIgnoredConcept(int id,String concept)throws ClientNotKnownException { - getClientState(id).addIgnoredConcept(concept); - } - - @WebMethod - public String[] selectInstancesForAConcept(int id,String Concept)throws ClientNotKnownException,NoOntologySelectedException{ - return getClientState(id).selectInstancesForAConcept(Concept); - } - - - @WebMethod - public String[] getPositiveExamples(int id)throws ClientNotKnownException{ - ClientState c=getClientState(id); - return c.getPositiveExamples(); - } - @WebMethod - public String[] getNegativeExamples(int id)throws ClientNotKnownException{ - ClientState c=getClientState(id); - return c.getNegativeExamples(); - } - @WebMethod - public String[] getIgnoredConcepts(int id)throws ClientNotKnownException{ - return getClientState(id).getIgnoredConcepts(); - } - - @WebMethod - public boolean removePositiveExample(int id, String pos)throws ClientNotKnownException{ - return getClientState(id).removePositiveExample(pos); - } - - @WebMethod - public boolean removeNegativeExample(int id, String neg)throws ClientNotKnownException{ - return getClientState(id).removeNegativeExample(neg); - } - @WebMethod - public boolean removeAllExamples(int id)throws ClientNotKnownException{ - return getClientState(id).removeAllExamples(); - } - @WebMethod - public boolean removeAllPositiveExamples(int id)throws ClientNotKnownException{ - return getClientState(id).removeAllPositiveExamples(); - } - @WebMethod - public boolean removeAllNegativeExamples(int id)throws ClientNotKnownException{ - return getClientState(id).removeAllNegativeExamples(); - } - @WebMethod - public void removeIgnoredConcept(int id,String concept)throws ClientNotKnownException{ - getClientState(id).removeIgnoredConcept(concept); - } - - @WebMethod - public String getCurrentOntologyURL(int id)throws ClientNotKnownException,NoOntologySelectedException{ - return getClientState(id).getCurrentOntologyURL(); - - } - - @WebMethod - public String[] getInstances(int id)throws ClientNotKnownException,NoOntologySelectedException{ - return getClientState(id).getInstances(); - } - - @WebMethod - public String[] getAtomicConcepts(int id)throws ClientNotKnownException,NoOntologySelectedException{ - return getClientState(id).getAtomicConcepts(); - } - - @WebMethod - public String[] getAtomicRoles(int id)throws ClientNotKnownException,NoOntologySelectedException{ - return getClientState(id).getAtomicRoles(); - } - @WebMethod - public String[] getIndividualsForARole(int id,String Role)throws ClientNotKnownException, NoOntologySelectedException{ - return getClientState(id).getIndividualsForARole(Role); - } - @WebMethod - public String getSubsumptionHierarchy(int id)throws ClientNotKnownException, NoOntologySelectedException{ - return getClientState(id).getSubsumptionHierarchy(); - } - - @WebMethod - public String[] retrieval(int id,String Concept)throws ClientNotKnownException,NoOntologySelectedException{ - return getClientState(id).retrieval(Concept); - } - - @WebMethod - public void readOntology(int id,String ontologyURL, String format)throws ClientNotKnownException,OntologyURLNotValid{ - getClientState(id).readOntology(ontologyURL, format); - - } - - @WebMethod - public void removeOntology(int id)throws ClientNotKnownException{ - getClientState(id).removeOntology(); - } - - @WebMethod - public String learnConcept(int id)throws ClientNotKnownException{ - return "Deprecated method"; - - } - - - @WebMethod - public String getAlgorithmStatus(int id ) throws ClientNotKnownException{ - - return getClientState(id).getAlgorithmStatus(); - } - - - @WebMethod - public void learnMonitored(int id )throws ClientNotKnownException{ - getClientState(id).learnMonitored(); - } - /*@WebMethod - public void relearn(int id,String Concept )throws ClientNotKnownException{ - getClientState(id).relearn(Concept); - }*/ - - @WebMethod - public String getLastResult(int id)throws ClientNotKnownException{ - return getClientState(id).getLastResult(); - } - - @WebMethod - public void stop(int id)throws ClientNotKnownException{ - getClientState(id).stop(); - } - - - //*************************USER MANAGEMENT - - public ClientState getClientState(int id)throws ClientNotKnownException{ - System.out.println("Request from "+id); - ClientState c=this.clients.get(new Integer(id)); - if(c==null){ - //System.out.println(clients.keySet().toString()); - throw new ClientNotKnownException("Client with id: "+id+" is not known","ClientNotKnownException");}; - return c; - - } - - - - - -} \ No newline at end of file Deleted: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS2.java 2007-08-22 10:27:46 UTC (rev 19) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS2.java 2007-08-22 10:39:07 UTC (rev 20) @@ -1,68 +0,0 @@ -package org.dllearner.server; - -import javax.jws.WebMethod; -import javax.jws.WebService; -import javax.jws.soap.SOAPBinding; - -import org.dllearner.server.exceptions.ClientNotKnownException; - - -/** - * Offene Fragen: - * - * Welche Rückgabetypen sind erlaubt? - * Wie behandelt man Exceptions (z.B. aus angegebener URI kann keine Ontologie - * gelesen werden)? - * - * @author Jens Lehmann - * - */ -@WebService(name = "DLLearnerWebService") - -@SOAPBinding(style = SOAPBinding.Style.RPC) -public class DLLearnerWS2 { - - /* - // String[] funktioniert leider noch nicht - @WebMethod - public void addPositiveExamples(String[] posExamples) { - for(String example : posExamples) - positiveExamples.add(new Individual(example)); - } - - @WebMethod - public void addNegativeExamples(String[] negExamples) { - for(String example : negExamples) - negativeExamples.add(new Individual(example)); - } - */ - - @WebMethod - /** - * @param name - * - * @return The sum - * @throws AddNumbersException - * if any of the numbers to be added is negative. - * - **/ - public String hellosimple(String name) throws ClientNotKnownException{ - /*for (int i = 0; i < name.length; i++) { - name[i]=i+"nnnn<br>"; - }*/ - if(name.equals("aa"))throw new ClientNotKnownException("a","b"); - - return "bbb"; - } - - - // Testmethode - @WebMethod - public String hello(String name){ - name=null; - //name.substring(5); - //throw new NullPointerException(); - return "Hello " + name + "!"; - } - -} \ No newline at end of file Deleted: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java 2007-08-22 10:27:46 UTC (rev 19) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java 2007-08-22 10:39:07 UTC (rev 20) @@ -1,71 +0,0 @@ -package org.dllearner.server; - - - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import javax.xml.ws.Endpoint; - -import com.sun.net.httpserver.HttpContext; -import com.sun.net.httpserver.HttpServer; - - -public class DLLearnerWSStart { - - public static void main(String[] args) { - String url = "http://139.18.114.78:8181/services"; - if (args.length > 0) - url = args[0]; - try{ - - InetSocketAddress isa=new InetSocketAddress("localhost",8181); - HttpServer server = HttpServer.create(isa, 5); - ExecutorService threads = Executors.newFixedThreadPool(5); - server.setExecutor(threads); - server.start(); - - System.out.print("Starting DL-Learner web service at http://" + - isa.getHostName()+":"+isa.getPort()+ "/services ... "); - Endpoint endpoint = Endpoint.create(new DLLearnerWS()); - //Endpoint endpoint = Endpoint.create(new CustomDataClass()); - HttpContext context = server.createContext("/services"); - endpoint.publish(context); - //Endpoint endpoint = Endpoint.publish(url, new DLLearnerWS()); - - System.out.println("OK."); - - - - System.out.println("Type \"exit\" to terminate web service."); - boolean terminate = false; - String inputString = ""; - do { - BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); - - try { - inputString = input.readLine(); - } catch (IOException e) { - e.printStackTrace(); - } - - if (inputString.equals("exit")) - terminate = true; - - } while (!terminate); - - System.out.print("Stopping web service ... "); - endpoint.stop(); - - server.stop(1); - threads.shutdown(); - System.out.println("OK."); - }catch (Exception e) {e.printStackTrace();} - } - -} Deleted: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java 2007-08-22 10:27:46 UTC (rev 19) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java 2007-08-22 10:39:07 UTC (rev 20) @@ -1,166 +0,0 @@ -package org.dllearner.server; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; - -import javax.jws.WebMethod; -import javax.jws.WebService; -import javax.jws.soap.SOAPBinding; - -import org.dllearner.Config; -import org.dllearner.LearningProblem; -import org.dllearner.Main; -import org.dllearner.OntologyFileFormat; -import org.dllearner.algorithms.refinement.ROLearner; -import org.dllearner.dl.Individual; -import org.dllearner.dl.KB; -import org.dllearner.reasoning.Reasoner; -import org.dllearner.reasoning.ReasoningMethodUnsupportedException; -import org.dllearner.reasoning.ReasoningService; - -/** - * Offene Fragen: - * - * Welche Rückgabetypen sind erlaubt? - * Wie behandelt man Exceptions (z.B. aus angegebener URI kann keine Ontologie - * gelesen werden)? - * - * @author Jens Lehmann - * - */ -@WebService(name = "DLLearnerWebService") -@SOAPBinding(style = SOAPBinding.Style.RPC) -public class DLLearnerWSoriginal { - - // private String ontologyURL; - // private String ontologyFormat; - private Reasoner reasoner; - private ReasoningService rs; - private SortedSet<Individual> positiveExamples = new TreeSet<Individual>(); - private SortedSet<Individual> negativeExamples = new TreeSet<Individual>(); - - /** - * Specifies the URI of the ontology containing the background - * knowledge. Reads the ontology and sends it to the reasoner. - * - * @param ontologyURI The URI of the ontology to use. - */ - // gleiche Methoden mit verschiedenen Parametern sind offenbar problematisch - /* - @WebMethod - public void readOntology(String ontologyURI) { - readOntology(ontologyURI, "RDF/XML"); - } - */ - - /** - * Specifies the URI of the ontology containing the background - * knowledge and its format. Reads the ontology and sends it to - * the reasoner. - * - * @param ontologyURI The URI of the ontology to use. - * @param format "RDF/XML" or "N-TRIPLES". - */ - @WebMethod - public void readOntology(String ontologyURL, String format) { - // this.ontologyURL = ontologyURL; - // this.ontologyFormat = format; - - // TODO: potentielles Sicherheitsrisiko, da man damit derzeit auch lokale Dateien - // laden könnte (Fix: nur http:// zulassen, kein file://) - URL ontology = null; - try { - ontology = new URL(ontologyURL); - } catch (MalformedURLException e1) { - e1.printStackTrace(); - } - - OntologyFileFormat ofFormat; - if (format.equals("RDF/XML")) - ofFormat = OntologyFileFormat.RDF_XML; - else - ofFormat = OntologyFileFormat.N_TRIPLES; - - Map<URL, OntologyFileFormat> m = new HashMap<URL, OntologyFileFormat>(); - m.put(ontology, ofFormat); - - // Default-URI für DIG-Reasoner setzen - try { - Config.digReasonerURL = new URL("http://localhost:8081"); - } catch (MalformedURLException e) { - // Exception tritt nie auf, da URL korrekt - e.printStackTrace(); - } - - reasoner = Main.createReasoner(new KB(), m); - - rs = new ReasoningService(reasoner); - - } - - - @WebMethod - public String[] testString(String c) { - - return new String[]{"a","b"}; - } - - // String[] funktioniert leider noch nicht - @WebMethod - public void addPositiveExamples(String[] posExamples) { - for(String example : posExamples) - positiveExamples.add(new Individual(example)); - } - - @WebMethod - public void addNegativeExamples(String[] negExamples) { - for(String example : negExamples) - negativeExamples.add(new Individual(example)); - } - - - @WebMethod - public void addPositiveExample(String posExample) { - positiveExamples.add(new Individual(posExample)); - } - - @WebMethod - public void addNegativeExample(String negExample) { - negativeExamples.add(new Individual(negExample)); - } - - @WebMethod - public String learnConcept() { - // notwendige Vorverarbeitungsschritte für den Lernalgorithmus - // - es müssen ein paar Konzepte, die ev. von Jena generiert wurden ignoriert - // werden - // - die Subsumptionhierarchie muss erstellt werden - // - die Subsumptionhierarchie wird verbessert um das Lernen effizienter zu machen - Main.autoDetectConceptsAndRoles(rs); - reasoner.prepareSubsumptionHierarchy(); - if (Config.Refinement.improveSubsumptionHierarchy) { - try { - reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); - } catch (ReasoningMethodUnsupportedException e) { - // solange DIG-Reasoner eingestellt ist, schlägt diese Operation nie fehl - e.printStackTrace(); - } - } - - LearningProblem learningProblem = new LearningProblem(rs, positiveExamples, negativeExamples); - // erstmal wird nur der Refinement-Learner als Web-Service angeboten - ROLearner learner = new ROLearner(learningProblem); - return learner.getBestSolution().toString(); - } - - // Testmethode - @WebMethod - public String hello(String name) { - return "Hello " + name + "!"; - } - -} \ No newline at end of file Deleted: trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java 2007-08-22 10:27:46 UTC (rev 19) +++ trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java 2007-08-22 10:39:07 UTC (rev 20) @@ -1,81 +0,0 @@ -package org.dllearner.server; - -import org.dllearner.Config; -import org.dllearner.LearningProblem; -import org.dllearner.Main; -import org.dllearner.algorithms.refinement.ROLearner; -import org.dllearner.reasoning.ReasoningMethodUnsupportedException; - -public class LearnMonitor extends Thread { - - - private ClientState c; - private boolean active = false; - - //private ROLearner ROL; - - public LearnMonitor(ClientState c){ - this.c=c; - } - - - public void end(){ - - System.out.println("trying to end"); - System.out.println("ROL2"+c.ROL); - this.c.ROL.stop(); - c.setLastResult(c.ROL.getBestSolution().toString()); - c.setStatus("stopped"); - } - - public void learn(){ - - this.start(); - - } - - public void run(){ - try{ - c.setStatus("still running"); - active=true; - c.setStatus("running"); - - // notwendige Vorverarbeitungsschritte für den Lernalgorithmus - // - es müssen ein paar Konzepte, die ev. von Jena generiert wurden ignoriert - // werden - // - die Subsumptionhierarchie muss erstellt werden - // - die Subsumptionhierarchie wird verbessert um das Lernen effizienter zu machen - Main.autoDetectConceptsAndRoles(c.getRs()); - c.getReasoner().prepareSubsumptionHierarchy(); - if (Config.Refinement.improveSubsumptionHierarchy) { - try { - c.getReasoner().getSubsumptionHierarchy().improveSubsumptionHierarchy(); - } catch (ReasoningMethodUnsupportedException e) { - // solange DIG-Reasoner eingestellt ist, schlägt diese Operation nie fehl - e.printStackTrace(); - } - } - c.p("learning started"); - LearningProblem learningProblem = new LearningProblem(c.getRs(), c.getPosExamples(), c.getNegExamples()); - // erstmal wird nur der Refinement-Learner als Web-Service angeboten - //System.out.println("aaaa"); - c.ROL = new ROLearner(learningProblem); - - c.ROL.start(); - //new ROLearner(); - //c.p(("ROL1"+ROL)); - - - - - - - //c.setLastResult(c.ROL.getBestSolution().toString()); - c.setLastResult(c.ROL.getBestSolution().toString()); - c.setStatus("finished"); - - }catch (Exception e) {e.printStackTrace();} - finally{active=false;}; - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2007-08-22 10:40:12
|
Revision: 21 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=21&view=rev Author: kurzum Date: 2007-08-22 03:40:10 -0700 (Wed, 22 Aug 2007) Log Message: ----------- update Added Paths: ----------- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS2.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java Added: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-08-22 10:40:10 UTC (rev 21) @@ -0,0 +1,227 @@ +package org.dllearner.server; + +import java.util.HashMap; +import java.util.Random; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; + +import org.dllearner.server.exceptions.ClientNotKnownException; +import org.dllearner.server.exceptions.NoOntologySelectedException; +import org.dllearner.server.exceptions.OntologyURLNotValid; + +/** + * Offene Fragen: + * + * Welche Rückgabetypen sind erlaubt? + * Wie behandelt man Exceptions (z.B. aus angegebener URI kann keine Ontologie + * gelesen werden)? + * + * @author Jens Lehmann + * + */ +@WebService(name = "DLLearnerWebService") +@SOAPBinding(style = SOAPBinding.Style.RPC) +public class DLLearnerWS { + Random rand=new Random(); + private HashMap<Integer, ClientState> clients; + + // private String ontologyURL; + // private String ontologyFormat; + + + + public DLLearnerWS(){ + this.clients=new HashMap<Integer, ClientState>(); + + } + + /** + * + * + * + */ + @WebMethod + public int getID(){ + int id=rand.nextInt(); + while (id<=0){ + id=rand.nextInt(); + } + + // dont change to local function get, cause of exception + ClientState c=this.clients.get(new Long(id)); + if(c!=null){ + return getID(); + } + else { + this.clients.put(new Integer(id), new ClientState()); + System.out.println("new Client with id: "+id); + return id; + } + + } + + @WebMethod + public void addPositiveExample(int id,String posExample) throws ClientNotKnownException{ + ClientState c=getClientState(id); + c.addPositiveExample(posExample); + //positiveExamples.add(new Individual(posExample)); + } + @WebMethod + public void addNegativeExample(int id,String negExample) throws ClientNotKnownException { + ClientState c=getClientState(id); + c.addNegativeExample(negExample); + } + @WebMethod + public void addIgnoredConcept(int id,String concept)throws ClientNotKnownException { + getClientState(id).addIgnoredConcept(concept); + } + + @WebMethod + public String[] selectInstancesForAConcept(int id,String Concept)throws ClientNotKnownException,NoOntologySelectedException{ + return getClientState(id).selectInstancesForAConcept(Concept); + } + + @WebMethod + public String[] selectAConcept(int id,String Concept,int Percentage)throws ClientNotKnownException,NoOntologySelectedException{ + return getClientState(id).selectAConcept(Concept, Percentage); + } + + @WebMethod + public String[] getPositiveExamples(int id)throws ClientNotKnownException{ + ClientState c=getClientState(id); + return c.getPositiveExamples(); + } + @WebMethod + public String[] getNegativeExamples(int id)throws ClientNotKnownException{ + ClientState c=getClientState(id); + return c.getNegativeExamples(); + } + @WebMethod + public String[] getIgnoredConcepts(int id)throws ClientNotKnownException{ + return getClientState(id).getIgnoredConcepts(); + } + + @WebMethod + public boolean removePositiveExample(int id, String pos)throws ClientNotKnownException{ + return getClientState(id).removePositiveExample(pos); + } + + @WebMethod + public boolean removeNegativeExample(int id, String neg)throws ClientNotKnownException{ + return getClientState(id).removeNegativeExample(neg); + } + @WebMethod + public boolean removeAllExamples(int id)throws ClientNotKnownException{ + return getClientState(id).removeAllExamples(); + } + @WebMethod + public boolean removeAllPositiveExamples(int id)throws ClientNotKnownException{ + return getClientState(id).removeAllPositiveExamples(); + } + @WebMethod + public boolean removeAllNegativeExamples(int id)throws ClientNotKnownException{ + return getClientState(id).removeAllNegativeExamples(); + } + @WebMethod + public void removeIgnoredConcept(int id,String concept)throws ClientNotKnownException{ + getClientState(id).removeIgnoredConcept(concept); + } + + @WebMethod + public String getCurrentOntologyURL(int id)throws ClientNotKnownException,NoOntologySelectedException{ + return getClientState(id).getCurrentOntologyURL(); + + } + + @WebMethod + public String[] getInstances(int id)throws ClientNotKnownException,NoOntologySelectedException{ + return getClientState(id).getInstances(); + } + + @WebMethod + public String[] getAtomicConcepts(int id)throws ClientNotKnownException,NoOntologySelectedException{ + return getClientState(id).getAtomicConcepts(); + } + + @WebMethod + public String[] getAtomicRoles(int id)throws ClientNotKnownException,NoOntologySelectedException{ + return getClientState(id).getAtomicRoles(); + } + @WebMethod + public String[] getIndividualsForARole(int id,String Role)throws ClientNotKnownException, NoOntologySelectedException{ + return getClientState(id).getIndividualsForARole(Role); + } + @WebMethod + public String getSubsumptionHierarchy(int id)throws ClientNotKnownException, NoOntologySelectedException{ + return getClientState(id).getSubsumptionHierarchy(); + } + + @WebMethod + public String[] retrieval(int id,String Concept)throws ClientNotKnownException,NoOntologySelectedException{ + return getClientState(id).retrieval(Concept); + } + + @WebMethod + public void readOntology(int id,String ontologyURL, String format)throws ClientNotKnownException,OntologyURLNotValid{ + getClientState(id).readOntology(ontologyURL, format); + + } + + @WebMethod + public void removeOntology(int id)throws ClientNotKnownException{ + getClientState(id).removeOntology(); + } + + @WebMethod + public String learnConcept(int id)throws ClientNotKnownException{ + return "Deprecated method"; + + } + + + @WebMethod + public String getAlgorithmStatus(int id ) throws ClientNotKnownException{ + + return getClientState(id).getAlgorithmStatus(); + } + + + @WebMethod + public void learnMonitored(int id )throws ClientNotKnownException{ + getClientState(id).learnMonitored(); + } + /*@WebMethod + public void relearn(int id,String Concept )throws ClientNotKnownException{ + getClientState(id).relearn(Concept); + }*/ + + @WebMethod + public String getLastResult(int id)throws ClientNotKnownException{ + return getClientState(id).getLastResult(); + } + + @WebMethod + public void stop(int id)throws ClientNotKnownException{ + getClientState(id).stop(); + } + + + //*************************USER MANAGEMENT + + public ClientState getClientState(int id)throws ClientNotKnownException{ + System.out.println("Request from "+id); + ClientState c=this.clients.get(new Integer(id)); + if(c==null){ + //System.out.println(clients.keySet().toString()); + throw new ClientNotKnownException("Client with id: "+id+" is not known","ClientNotKnownException");}; + return c; + + } + + + + + +} \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS2.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS2.java 2007-08-22 10:40:10 UTC (rev 21) @@ -0,0 +1,68 @@ +package org.dllearner.server; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; + +import org.dllearner.server.exceptions.ClientNotKnownException; + + +/** + * Offene Fragen: + * + * Welche Rückgabetypen sind erlaubt? + * Wie behandelt man Exceptions (z.B. aus angegebener URI kann keine Ontologie + * gelesen werden)? + * + * @author Jens Lehmann + * + */ +@WebService(name = "DLLearnerWebService") + +@SOAPBinding(style = SOAPBinding.Style.RPC) +public class DLLearnerWS2 { + + /* + // String[] funktioniert leider noch nicht + @WebMethod + public void addPositiveExamples(String[] posExamples) { + for(String example : posExamples) + positiveExamples.add(new Individual(example)); + } + + @WebMethod + public void addNegativeExamples(String[] negExamples) { + for(String example : negExamples) + negativeExamples.add(new Individual(example)); + } + */ + + @WebMethod + /** + * @param name + * + * @return The sum + * @throws AddNumbersException + * if any of the numbers to be added is negative. + * + **/ + public String hellosimple(String name) throws ClientNotKnownException{ + /*for (int i = 0; i < name.length; i++) { + name[i]=i+"nnnn<br>"; + }*/ + if(name.equals("aa"))throw new ClientNotKnownException("a","b"); + + return "bbb"; + } + + + // Testmethode + @WebMethod + public String hello(String name){ + name=null; + //name.substring(5); + //throw new NullPointerException(); + return "Hello " + name + "!"; + } + +} \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java 2007-08-22 10:40:10 UTC (rev 21) @@ -0,0 +1,70 @@ +package org.dllearner.server; + + + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.InetSocketAddress; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import javax.xml.ws.Endpoint; + +import com.sun.net.httpserver.HttpContext; +import com.sun.net.httpserver.HttpServer; + + +public class DLLearnerWSStart { + + public static void main(String[] args) { + String url = "http://139.18.114.78:8181/services"; + if (args.length > 0) + url = args[0]; + try{ + + InetSocketAddress isa=new InetSocketAddress("localhost",8181); + HttpServer server = HttpServer.create(isa, 5); + ExecutorService threads = Executors.newFixedThreadPool(5); + server.setExecutor(threads); + server.start(); + + System.out.print("Starting DL-Learner web service at http://" + + isa.getHostName()+":"+isa.getPort()+ "/services ... "); + Endpoint endpoint = Endpoint.create(new DLLearnerWS()); + //Endpoint endpoint = Endpoint.create(new CustomDataClass()); + HttpContext context = server.createContext("/services"); + endpoint.publish(context); + //Endpoint endpoint = Endpoint.publish(url, new DLLearnerWS()); + + System.out.println("OK."); + + + + System.out.println("Type \"exit\" to terminate web service."); + boolean terminate = false; + String inputString = ""; + do { + BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); + + try { + inputString = input.readLine(); + } catch (IOException e) { + e.printStackTrace(); + } + + if (inputString.equals("exit")) + terminate = true; + + } while (!terminate); + + System.out.print("Stopping web service ... "); + endpoint.stop(); + + server.stop(1); + threads.shutdown(); + System.out.println("OK."); + }catch (Exception e) {e.printStackTrace();} + } + +} Added: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java 2007-08-22 10:40:10 UTC (rev 21) @@ -0,0 +1,166 @@ +package org.dllearner.server; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; + +import org.dllearner.Config; +import org.dllearner.LearningProblem; +import org.dllearner.Main; +import org.dllearner.OntologyFileFormat; +import org.dllearner.algorithms.refinement.ROLearner; +import org.dllearner.dl.Individual; +import org.dllearner.dl.KB; +import org.dllearner.reasoning.Reasoner; +import org.dllearner.reasoning.ReasoningMethodUnsupportedException; +import org.dllearner.reasoning.ReasoningService; + +/** + * Offene Fragen: + * + * Welche Rückgabetypen sind erlaubt? + * Wie behandelt man Exceptions (z.B. aus angegebener URI kann keine Ontologie + * gelesen werden)? + * + * @author Jens Lehmann + * + */ +@WebService(name = "DLLearnerWebService") +@SOAPBinding(style = SOAPBinding.Style.RPC) +public class DLLearnerWSoriginal { + + // private String ontologyURL; + // private String ontologyFormat; + private Reasoner reasoner; + private ReasoningService rs; + private SortedSet<Individual> positiveExamples = new TreeSet<Individual>(); + private SortedSet<Individual> negativeExamples = new TreeSet<Individual>(); + + /** + * Specifies the URI of the ontology containing the background + * knowledge. Reads the ontology and sends it to the reasoner. + * + * @param ontologyURI The URI of the ontology to use. + */ + // gleiche Methoden mit verschiedenen Parametern sind offenbar problematisch + /* + @WebMethod + public void readOntology(String ontologyURI) { + readOntology(ontologyURI, "RDF/XML"); + } + */ + + /** + * Specifies the URI of the ontology containing the background + * knowledge and its format. Reads the ontology and sends it to + * the reasoner. + * + * @param ontologyURI The URI of the ontology to use. + * @param format "RDF/XML" or "N-TRIPLES". + */ + @WebMethod + public void readOntology(String ontologyURL, String format) { + // this.ontologyURL = ontologyURL; + // this.ontologyFormat = format; + + // TODO: potentielles Sicherheitsrisiko, da man damit derzeit auch lokale Dateien + // laden könnte (Fix: nur http:// zulassen, kein file://) + URL ontology = null; + try { + ontology = new URL(ontologyURL); + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + + OntologyFileFormat ofFormat; + if (format.equals("RDF/XML")) + ofFormat = OntologyFileFormat.RDF_XML; + else + ofFormat = OntologyFileFormat.N_TRIPLES; + + Map<URL, OntologyFileFormat> m = new HashMap<URL, OntologyFileFormat>(); + m.put(ontology, ofFormat); + + // Default-URI für DIG-Reasoner setzen + try { + Config.digReasonerURL = new URL("http://localhost:8081"); + } catch (MalformedURLException e) { + // Exception tritt nie auf, da URL korrekt + e.printStackTrace(); + } + + reasoner = Main.createReasoner(new KB(), m); + + rs = new ReasoningService(reasoner); + + } + + + @WebMethod + public String[] testString(String c) { + + return new String[]{"a","b"}; + } + + // String[] funktioniert leider noch nicht + @WebMethod + public void addPositiveExamples(String[] posExamples) { + for(String example : posExamples) + positiveExamples.add(new Individual(example)); + } + + @WebMethod + public void addNegativeExamples(String[] negExamples) { + for(String example : negExamples) + negativeExamples.add(new Individual(example)); + } + + + @WebMethod + public void addPositiveExample(String posExample) { + positiveExamples.add(new Individual(posExample)); + } + + @WebMethod + public void addNegativeExample(String negExample) { + negativeExamples.add(new Individual(negExample)); + } + + @WebMethod + public String learnConcept() { + // notwendige Vorverarbeitungsschritte für den Lernalgorithmus + // - es müssen ein paar Konzepte, die ev. von Jena generiert wurden ignoriert + // werden + // - die Subsumptionhierarchie muss erstellt werden + // - die Subsumptionhierarchie wird verbessert um das Lernen effizienter zu machen + Main.autoDetectConceptsAndRoles(rs); + reasoner.prepareSubsumptionHierarchy(); + if (Config.Refinement.improveSubsumptionHierarchy) { + try { + reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); + } catch (ReasoningMethodUnsupportedException e) { + // solange DIG-Reasoner eingestellt ist, schlägt diese Operation nie fehl + e.printStackTrace(); + } + } + + LearningProblem learningProblem = new LearningProblem(rs, positiveExamples, negativeExamples); + // erstmal wird nur der Refinement-Learner als Web-Service angeboten + ROLearner learner = new ROLearner(learningProblem); + return learner.getBestSolution().toString(); + } + + // Testmethode + @WebMethod + public String hello(String name) { + return "Hello " + name + "!"; + } + +} \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java 2007-08-22 10:40:10 UTC (rev 21) @@ -0,0 +1,81 @@ +package org.dllearner.server; + +import org.dllearner.Config; +import org.dllearner.LearningProblem; +import org.dllearner.Main; +import org.dllearner.algorithms.refinement.ROLearner; +import org.dllearner.reasoning.ReasoningMethodUnsupportedException; + +public class LearnMonitor extends Thread { + + + private ClientState c; + private boolean active = false; + + //private ROLearner ROL; + + public LearnMonitor(ClientState c){ + this.c=c; + } + + + public void end(){ + + System.out.println("trying to end"); + System.out.println("ROL2"+c.ROL); + this.c.ROL.stop(); + c.setLastResult(c.ROL.getBestSolution().toString()); + c.setStatus("stopped"); + } + + public void learn(){ + + this.start(); + + } + + public void run(){ + try{ + c.setStatus("still running"); + active=true; + c.setStatus("running"); + + // notwendige Vorverarbeitungsschritte für den Lernalgorithmus + // - es müssen ein paar Konzepte, die ev. von Jena generiert wurden ignoriert + // werden + // - die Subsumptionhierarchie muss erstellt werden + // - die Subsumptionhierarchie wird verbessert um das Lernen effizienter zu machen + Main.autoDetectConceptsAndRoles(c.getRs()); + c.getReasoner().prepareSubsumptionHierarchy(); + if (Config.Refinement.improveSubsumptionHierarchy) { + try { + c.getReasoner().getSubsumptionHierarchy().improveSubsumptionHierarchy(); + } catch (ReasoningMethodUnsupportedException e) { + // solange DIG-Reasoner eingestellt ist, schlägt diese Operation nie fehl + e.printStackTrace(); + } + } + c.p("learning started"); + LearningProblem learningProblem = new LearningProblem(c.getRs(), c.getPosExamples(), c.getNegExamples()); + // erstmal wird nur der Refinement-Learner als Web-Service angeboten + //System.out.println("aaaa"); + c.ROL = new ROLearner(learningProblem); + + c.ROL.start(); + //new ROLearner(); + //c.p(("ROL1"+ROL)); + + + + + + + //c.setLastResult(c.ROL.getBestSolution().toString()); + c.setLastResult(c.ROL.getBestSolution().toString()); + c.setStatus("finished"); + + }catch (Exception e) {e.printStackTrace();} + finally{active=false;}; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-08-22 17:53:57
|
Revision: 27 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=27&view=rev Author: jenslehmann Date: 2007-08-22 10:53:45 -0700 (Wed, 22 Aug 2007) Log Message: ----------- deleted deprecated files in org.dllearner.server Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/server/DLLearnerClientTest.java trunk/src/dl-learner/org/dllearner/server/DLLearnerServer.java Deleted: trunk/src/dl-learner/org/dllearner/server/DLLearnerClientTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerClientTest.java 2007-08-22 17:21:46 UTC (rev 26) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerClientTest.java 2007-08-22 17:53:45 UTC (rev 27) @@ -1,45 +0,0 @@ -package org.dllearner.server; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.Socket; -import java.net.UnknownHostException; - -/** - * Testklasse um Ontology Class Learning Interface zu testen. - * - * @author jl - * - */ -public class DLLearnerClientTest { - - /** - * @param args - */ - public static void main(String[] args) { - Socket server = null; - - try { - server = new Socket("localhost", 3141); - InputStream in = server.getInputStream(); - OutputStream out = server.getOutputStream(); - - out.write(4); - out.write(9); - int result = in.read(); - System.out.println(result); - } catch (UnknownHostException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (server != null) - try { - server.close(); - } catch (IOException e) { - } - } - } - -} Deleted: trunk/src/dl-learner/org/dllearner/server/DLLearnerServer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerServer.java 2007-08-22 17:21:46 UTC (rev 26) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerServer.java 2007-08-22 17:53:45 UTC (rev 27) @@ -1,46 +0,0 @@ -package org.dllearner.server; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.ServerSocket; -import java.net.Socket; - -public class DLLearnerServer { - - private static void handleConnection(Socket client) throws IOException { - InputStream in = client.getInputStream(); - OutputStream out = client.getOutputStream(); - - int factor1 = in.read(); - int factor2 = in.read(); - - out.write(factor1 * factor2); - } - - /** - * @param args - */ - public static void main(String[] args) throws IOException { - // TODO Auto-generated method stub - ServerSocket server = new ServerSocket(3141); - - while (true) { - Socket client = null; - - try { - client = server.accept(); - handleConnection(client); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (client != null) - try { - client.close(); - } catch (IOException e) { - } - } - } - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2007-08-23 09:03:56
|
Revision: 36 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=36&view=rev Author: kurzum Date: 2007-08-23 02:03:51 -0700 (Thu, 23 Aug 2007) Log Message: ----------- new exception beans with wsgen Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java trunk/src/dl-learner/org/dllearner/server/jaxws/ClientNotKnownExceptionBean.java trunk/src/dl-learner/org/dllearner/server/jaxws/NoOntologySelectedExceptionBean.java trunk/src/dl-learner/org/dllearner/server/jaxws/OntologyURLNotValidBean.java Modified: trunk/src/dl-learner/org/dllearner/server/ClientState.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-08-22 18:44:48 UTC (rev 35) +++ trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-08-23 09:03:51 UTC (rev 36) @@ -1,3 +1,4 @@ + package org.dllearner.server; import java.net.MalformedURLException; @@ -28,9 +29,6 @@ import org.dllearner.server.exceptions.NoOntologySelectedException; import org.dllearner.server.exceptions.OntologyURLNotValid; -import com.hp.hpl.jena.shared.DoesNotExistException; -import com.hp.hpl.jena.shared.JenaException; - public class ClientState { private String reasonerURL="http://localhost:8081"; @@ -445,14 +443,14 @@ p(rs.getSubsumptionHierarchy().toString()); //rs.getRoleMembers(arg0) } - catch (DoesNotExistException e) { + catch (Exception e) { //TODO this.removeOntology(); throw new OntologyURLNotValid("The URL of the Ontology is not correct<br>\nCheck settings and URL","OntologyURLNotValid"); } - catch (JenaException e) { + /*catch (JenaException e) { e.printStackTrace();} + */ - /*catch(Exception e2) { //p("exception:"+e.getMessage()); Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java 2007-08-22 18:44:48 UTC (rev 35) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java 2007-08-23 09:03:51 UTC (rev 36) @@ -18,7 +18,8 @@ public class DLLearnerWSStart { public static void main(String[] args) { - String url = "http://139.18.114.78:8181/services"; + //String url = "http://139.18.114.78:8181/services"; + String url=""; if (args.length > 0) url = args[0]; try{ Modified: trunk/src/dl-learner/org/dllearner/server/jaxws/ClientNotKnownExceptionBean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/jaxws/ClientNotKnownExceptionBean.java 2007-08-22 18:44:48 UTC (rev 35) +++ trunk/src/dl-learner/org/dllearner/server/jaxws/ClientNotKnownExceptionBean.java 2007-08-23 09:03:51 UTC (rev 36) @@ -13,9 +13,9 @@ * Generated source version: 2.0_02 * */ -@XmlRootElement(name = "ClientNotKnownException", namespace = "http://ws/") +@XmlRootElement(name = "ClientNotKnownException", namespace = "http://server.dllearner.org/") @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "ClientNotKnownException", namespace = "http://ws/", propOrder = { +@XmlType(name = "ClientNotKnownException", namespace = "http://server.dllearner.org/", propOrder = { "detail", "message" }) Modified: trunk/src/dl-learner/org/dllearner/server/jaxws/NoOntologySelectedExceptionBean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/jaxws/NoOntologySelectedExceptionBean.java 2007-08-22 18:44:48 UTC (rev 35) +++ trunk/src/dl-learner/org/dllearner/server/jaxws/NoOntologySelectedExceptionBean.java 2007-08-23 09:03:51 UTC (rev 36) @@ -13,9 +13,9 @@ * Generated source version: 2.0_02 * */ -@XmlRootElement(name = "NoOntologySelectedException", namespace = "http://ws/") +@XmlRootElement(name = "NoOntologySelectedException", namespace = "http://server.dllearner.org/") @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "NoOntologySelectedException", namespace = "http://ws/", propOrder = { +@XmlType(name = "NoOntologySelectedException", namespace = "http://server.dllearner.org/", propOrder = { "detail", "message" }) Modified: trunk/src/dl-learner/org/dllearner/server/jaxws/OntologyURLNotValidBean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/jaxws/OntologyURLNotValidBean.java 2007-08-22 18:44:48 UTC (rev 35) +++ trunk/src/dl-learner/org/dllearner/server/jaxws/OntologyURLNotValidBean.java 2007-08-23 09:03:51 UTC (rev 36) @@ -13,9 +13,9 @@ * Generated source version: 2.0_02 * */ -@XmlRootElement(name = "OntologyURLNotValid", namespace = "http://ws/") +@XmlRootElement(name = "OntologyURLNotValid", namespace = "http://server.dllearner.org/") @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "OntologyURLNotValid", namespace = "http://ws/", propOrder = { +@XmlType(name = "OntologyURLNotValid", namespace = "http://server.dllearner.org/", propOrder = { "detail", "message" }) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2007-08-27 15:14:21
|
Revision: 65 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=65&view=rev Author: kurzum Date: 2007-08-27 08:13:33 -0700 (Mon, 27 Aug 2007) Log Message: ----------- fixed the warnings Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java trunk/src/dl-learner/org/dllearner/server/exceptions/ClientNotKnownException.java trunk/src/dl-learner/org/dllearner/server/exceptions/NoOntologySelectedException.java trunk/src/dl-learner/org/dllearner/server/exceptions/OntologyURLNotValid.java Modified: trunk/src/dl-learner/org/dllearner/server/ClientState.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-08-27 15:04:36 UTC (rev 64) +++ trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-08-27 15:13:33 UTC (rev 65) @@ -110,7 +110,7 @@ AtomicConcept SelectedConcept=new AtomicConcept(Concept); ArrayList<String> al=new ArrayList<String>(); Individual indtmp=null; - Set ConceptSet=null; + Set<AtomicConcept> ConceptSet=null; AtomicConcept ac=null; @@ -173,8 +173,8 @@ { ac=superConcepts.get(jj); p("next this: "+ac.getName()); - Set negatives=rs.retrieval(ac); - Iterator i2 = negatives.iterator(); + Set<Individual> negatives=rs.retrieval(ac); + Iterator<Individual> i2 = negatives.iterator(); indtmp=null; while(i2.hasNext()){ @@ -206,15 +206,15 @@ AtomicConcept SelectedConcept=new AtomicConcept(Concept); ArrayList<String> ret=new ArrayList<String>(); Individual indtmp=null; - Set ConceptSet=null; + Set<AtomicConcept> ConceptSet=null; AtomicConcept ac=null; Random r=new Random(); System.out.println("selectAConcept: "+Concept); // add all positives - Set positives=rs.retrieval(SelectedConcept); - Iterator i = positives.iterator(); + Set<Individual> positives=rs.retrieval(SelectedConcept); + Iterator<Individual> i = positives.iterator(); while(i.hasNext()){ indtmp=(Individual)i.next(); p("added "+indtmp.getName()+" to positives"); @@ -242,9 +242,9 @@ public ArrayList<AtomicConcept> subsumesAll(AtomicConcept c){ - Set s=rs.getAtomicConcepts(); + Set<AtomicConcept> s=rs.getAtomicConcepts(); ArrayList<AtomicConcept> ret=new ArrayList<AtomicConcept>(); - Iterator i=s.iterator(); + Iterator<AtomicConcept> i=s.iterator(); while (i.hasNext()) { AtomicConcept element = (AtomicConcept) i.next(); if(rs.subsumes(element, c)) @@ -257,7 +257,7 @@ } public String[] getPositiveExamples(){ String[] ret=new String[positiveExamples.size()]; - Iterator i=positiveExamples.iterator(); + Iterator<Individual> i=positiveExamples.iterator(); int a=0; while (i.hasNext()){ ret[a++]=((Individual)i.next()).getName(); @@ -267,7 +267,7 @@ } public String[] getNegativeExamples(){ String[] ret=new String[negativeExamples.size()]; - Iterator i=negativeExamples.iterator(); + Iterator<Individual> i=negativeExamples.iterator(); int a=0; while (i.hasNext()){ ret[a++]=((Individual)i.next()).getName(); @@ -278,7 +278,7 @@ public String[] getIgnoredConcepts() { String[] ret=new String[ignoredConcept.size()]; - Iterator i=ignoredConcept.iterator(); + Iterator<String> i=ignoredConcept.iterator(); int a=0; while (i.hasNext()){ ret[a++]=((String)i.next()); @@ -334,7 +334,7 @@ SortedSet<Individual> s=rs.getIndividuals(); //System.out.println(s); String[] ret=new String[s.size()]; - Iterator i=s.iterator(); + Iterator<Individual> i=s.iterator(); int a=0; while (i.hasNext()){ ret[a++]=((Individual)i.next()).getName(); @@ -491,8 +491,8 @@ } public String[] getIndividualsForARole(String Role)throws NoOntologySelectedException{ - Map m=rs.getRoleMembers(new AtomicRole(Role)); - Set s=m.keySet(); + Map<Individual,SortedSet<Individual>> m=rs.getRoleMembers(new AtomicRole(Role)); + Set<Individual> s=m.keySet(); return SortedSet2StringListIndividuals(s); } @@ -521,10 +521,10 @@ //this.lm.notify(); } - public String[] SortedSet2StringListIndividuals(Set s){ + public String[] SortedSet2StringListIndividuals(Set<Individual> s){ String[] ret=new String[s.size()]; - Iterator i=s.iterator(); + Iterator<Individual> i=s.iterator(); int a=0; while (i.hasNext()){ ret[a++]=((Individual)i.next()).getName(); @@ -533,10 +533,10 @@ return ret; } - public String[] SortedSet2StringListConcepts(Set s){ + public String[] SortedSet2StringListConcepts(Set<AtomicConcept> s){ String[] ret=new String[s.size()]; - Iterator i=s.iterator(); + Iterator<AtomicConcept> i=s.iterator(); int a=0; while (i.hasNext()){ ret[a++]=((AtomicConcept)i.next()).getName(); @@ -544,10 +544,10 @@ Arrays.sort(ret); return ret; } - public String[] SortedSet2StringListRoles(Set s){ + public String[] SortedSet2StringListRoles(Set<AtomicRole> s){ String[] ret=new String[s.size()]; - Iterator i=s.iterator(); + Iterator<AtomicRole> i=s.iterator(); int a=0; while (i.hasNext()){ ret[a++]=((AtomicRole)i.next()).getName(); Modified: trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java 2007-08-27 15:04:36 UTC (rev 64) +++ trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java 2007-08-27 15:13:33 UTC (rev 65) @@ -37,6 +37,7 @@ public void run(){ try{ c.setStatus("still running"); + if(active); active=true; c.setStatus("running"); Modified: trunk/src/dl-learner/org/dllearner/server/exceptions/ClientNotKnownException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/exceptions/ClientNotKnownException.java 2007-08-27 15:04:36 UTC (rev 64) +++ trunk/src/dl-learner/org/dllearner/server/exceptions/ClientNotKnownException.java 2007-08-27 15:13:33 UTC (rev 65) @@ -1,7 +1,8 @@ package org.dllearner.server.exceptions; public class ClientNotKnownException extends Exception { - String detail; + static final long serialVersionUID=100; + String detail; public ClientNotKnownException (String message, String detail) { super (message); Modified: trunk/src/dl-learner/org/dllearner/server/exceptions/NoOntologySelectedException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/exceptions/NoOntologySelectedException.java 2007-08-27 15:04:36 UTC (rev 64) +++ trunk/src/dl-learner/org/dllearner/server/exceptions/NoOntologySelectedException.java 2007-08-27 15:13:33 UTC (rev 65) @@ -1,7 +1,8 @@ package org.dllearner.server.exceptions; public class NoOntologySelectedException extends Exception { - String detail; + static final long serialVersionUID=101; + String detail; public NoOntologySelectedException (String message, String detail) { super (message); Modified: trunk/src/dl-learner/org/dllearner/server/exceptions/OntologyURLNotValid.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/exceptions/OntologyURLNotValid.java 2007-08-27 15:04:36 UTC (rev 64) +++ trunk/src/dl-learner/org/dllearner/server/exceptions/OntologyURLNotValid.java 2007-08-27 15:13:33 UTC (rev 65) @@ -1,6 +1,7 @@ package org.dllearner.server.exceptions; public class OntologyURLNotValid extends Exception { + static final long serialVersionUID=102; String detail; public OntologyURLNotValid (String message, String detail) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2007-08-27 15:51:14
|
Revision: 68 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=68&view=rev Author: kurzum Date: 2007-08-27 08:51:12 -0700 (Mon, 27 Aug 2007) Log Message: ----------- warnings Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java Modified: trunk/src/dl-learner/org/dllearner/server/ClientState.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-08-27 15:49:25 UTC (rev 67) +++ trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-08-27 15:51:12 UTC (rev 68) @@ -110,7 +110,7 @@ AtomicConcept SelectedConcept=new AtomicConcept(Concept); ArrayList<String> al=new ArrayList<String>(); Individual indtmp=null; - Set<AtomicConcept> ConceptSet=null; + //Set<AtomicConcept> ConceptSet=null; AtomicConcept ac=null; @@ -206,8 +206,8 @@ AtomicConcept SelectedConcept=new AtomicConcept(Concept); ArrayList<String> ret=new ArrayList<String>(); Individual indtmp=null; - Set<AtomicConcept> ConceptSet=null; - AtomicConcept ac=null; + //Set<AtomicConcept> ConceptSet=null; + //AtomicConcept ac=null; Random r=new Random(); Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java 2007-08-27 15:49:25 UTC (rev 67) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSStart.java 2007-08-27 15:51:12 UTC (rev 68) @@ -19,9 +19,9 @@ public static void main(String[] args) { //String url = "http://139.18.114.78:8181/services"; - String url=""; + /*String url=""; if (args.length > 0) - url = args[0]; + url = args[0];*/ try{ InetSocketAddress isa=new InetSocketAddress("localhost",8181); Modified: trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java 2007-08-27 15:49:25 UTC (rev 67) +++ trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java 2007-08-27 15:51:12 UTC (rev 68) @@ -34,6 +34,10 @@ } + /** + * @override + */ + @Override public void run(){ try{ c.setStatus("still running"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2007-08-28 08:45:43
|
Revision: 76 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=76&view=rev Author: kurzum Date: 2007-08-28 01:45:40 -0700 (Tue, 28 Aug 2007) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/server/ClientNotKnownException.java trunk/src/dl-learner/org/dllearner/server/NoOntologySelectedException.java trunk/src/dl-learner/org/dllearner/server/OntologyURLNotValid.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/server/exceptions/ Copied: trunk/src/dl-learner/org/dllearner/server/ClientNotKnownException.java (from rev 75, trunk/src/dl-learner/org/dllearner/server/exceptions/ClientNotKnownException.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientNotKnownException.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/ClientNotKnownException.java 2007-08-28 08:45:40 UTC (rev 76) @@ -0,0 +1,15 @@ +package org.dllearner.server; + +public class ClientNotKnownException extends Exception { + static final long serialVersionUID=100; + String detail; + + public ClientNotKnownException (String message, String detail) { + super (message); + this.detail = detail; + } + + public String getDetail () { + return detail; + } +} Modified: trunk/src/dl-learner/org/dllearner/server/ClientState.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-08-28 08:13:35 UTC (rev 75) +++ trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-08-28 08:45:40 UTC (rev 76) @@ -26,8 +26,6 @@ import org.dllearner.reasoning.Reasoner; import org.dllearner.reasoning.ReasoningMethodUnsupportedException; import org.dllearner.reasoning.ReasoningService; -import org.dllearner.server.exceptions.NoOntologySelectedException; -import org.dllearner.server.exceptions.OntologyURLNotValid; public class ClientState { Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-08-28 08:13:35 UTC (rev 75) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-08-28 08:45:40 UTC (rev 76) @@ -7,9 +7,6 @@ import javax.jws.WebService; import javax.jws.soap.SOAPBinding; -import org.dllearner.server.exceptions.ClientNotKnownException; -import org.dllearner.server.exceptions.NoOntologySelectedException; -import org.dllearner.server.exceptions.OntologyURLNotValid; /** * Offene Fragen: Copied: trunk/src/dl-learner/org/dllearner/server/NoOntologySelectedException.java (from rev 75, trunk/src/dl-learner/org/dllearner/server/exceptions/NoOntologySelectedException.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/server/NoOntologySelectedException.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/NoOntologySelectedException.java 2007-08-28 08:45:40 UTC (rev 76) @@ -0,0 +1,15 @@ +package org.dllearner.server; + +public class NoOntologySelectedException extends Exception { + static final long serialVersionUID=101; + String detail; + + public NoOntologySelectedException (String message, String detail) { + super (message); + this.detail = detail; + } + + public String getDetail () { + return detail; + } +} Copied: trunk/src/dl-learner/org/dllearner/server/OntologyURLNotValid.java (from rev 75, trunk/src/dl-learner/org/dllearner/server/exceptions/OntologyURLNotValid.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/server/OntologyURLNotValid.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/OntologyURLNotValid.java 2007-08-28 08:45:40 UTC (rev 76) @@ -0,0 +1,15 @@ +package org.dllearner.server; + +public class OntologyURLNotValid extends Exception { + static final long serialVersionUID=102; + String detail; + + public OntologyURLNotValid (String message, String detail) { + super (message); + this.detail = detail; + } + + public String getDetail () { + return detail; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-09 14:07:00
|
Revision: 203 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=203&view=rev Author: jenslehmann Date: 2007-10-09 07:06:57 -0700 (Tue, 09 Oct 2007) Log Message: ----------- finished basic component creation in web service Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSNew.java trunk/src/dl-learner/org/dllearner/server/State.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/server/UnknownComponentException.java Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSNew.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSNew.java 2007-10-09 09:26:31 UTC (rev 202) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSNew.java 2007-10-09 14:06:57 UTC (rev 203) @@ -26,10 +26,17 @@ import javax.jws.WebService; import javax.jws.soap.SOAPBinding; +import org.dllearner.algorithms.refinement.ROLearner; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.ReasonerComponent; import org.dllearner.kb.OWLFile; import org.dllearner.kb.SparqlEndpoint; +import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegInclusionLP; +import org.dllearner.reasoning.DIGReasoner; /** * DL-Learner web service interface. @@ -71,22 +78,62 @@ } @WebMethod - public void addKnowledgeSource(long id, String type, String url) throws ClientNotKnownException { + public boolean addKnowledgeSource(long id, String component, String url) throws ClientNotKnownException { State state = getState(id); Class<? extends KnowledgeSource> ksClass; - if(type.equals("sparql")) + if(component.equals("sparql")) ksClass = SparqlEndpoint.class; else ksClass = OWLFile.class; KnowledgeSource ks = cm.knowledgeSource(ksClass); cm.applyConfigEntry(ks, "url", url); - state.addKnowledgeSource(ks); + return state.addKnowledgeSource(ks); } @WebMethod - public void setLearningAlgorithm(long id, String algorithm) throws ClientNotKnownException { + public boolean removeKnowledgeSource(long id, String url) throws ClientNotKnownException { + return getState(id).removeKnowledgeSource(url); + } + + @WebMethod + public void setReasoner(long id, String component) throws ClientNotKnownException, UnknownComponentException { State state = getState(id); - // ... + Class<? extends ReasonerComponent> rcClass; + if(component.equals("dig")) + rcClass = DIGReasoner.class; + else + throw new UnknownComponentException(component); + + ReasonerComponent rc = cm.reasoner(rcClass, state.getKnowledgeSources()); + state.setReasonerComponent(rc); } + @WebMethod + public void setLearningProblem(long id, String component) throws ClientNotKnownException, UnknownComponentException { + State state = getState(id); + Class<? extends LearningProblem> lpClass; + if(component.equals("posNegDefinition")) + lpClass = PosNegDefinitionLP.class; + else if(component.equals("posNegInclusion")) + lpClass = PosNegInclusionLP.class; + else + throw new UnknownComponentException(component); + + LearningProblem lp = cm.learningProblem(lpClass, state.getReasoningService()); + state.setLearningProblem(lp); + } + + @WebMethod + public void setLearningAlgorithm(long id, String component) throws ClientNotKnownException, UnknownComponentException { + State state = getState(id); + Class<? extends LearningAlgorithm> laClass; + if(component.equals("refinement")) + laClass = ROLearner.class; + else + throw new UnknownComponentException(component); + + LearningAlgorithm la = cm.learningAlgorithm(laClass, state.getLearningProblem(), state.getReasoningService()); + state.setLearningAlgorithm(la); + } + } Modified: trunk/src/dl-learner/org/dllearner/server/State.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/State.java 2007-10-09 09:26:31 UTC (rev 202) +++ trunk/src/dl-learner/org/dllearner/server/State.java 2007-10-09 14:06:57 UTC (rev 203) @@ -19,12 +19,16 @@ */ package org.dllearner.server; +import java.util.Iterator; import java.util.Set; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningService; +import org.dllearner.kb.OWLFile; +import org.dllearner.kb.SparqlEndpoint; /** * Stores the state of a DL-Learner client session. @@ -34,26 +38,27 @@ */ public class State { - private Set<KnowledgeSource> knowledgeSource; + private Set<KnowledgeSource> knowledgeSources; private LearningProblem learningProblem; private ReasonerComponent reasonerComponent; + private ReasoningService reasoningService; private LearningAlgorithm learningAlgorithm; /** * @return the knowledgeSource */ - public Set<KnowledgeSource> getKnowledgeSource() { - return knowledgeSource; + public Set<KnowledgeSource> getKnowledgeSources() { + return knowledgeSources; } /** - * @param knowledgeSource the knowledgeSource to set + * @param knowledgeSources the knowledgeSource to set */ - public void setKnowledgeSource(Set<KnowledgeSource> knowledgeSource) { - this.knowledgeSource = knowledgeSource; + public void setKnowledgeSources(Set<KnowledgeSource> knowledgeSources) { + this.knowledgeSources = knowledgeSources; } /** @@ -62,16 +67,25 @@ * @see java.util.Set#add(java.lang.Object) */ public boolean addKnowledgeSource(KnowledgeSource ks) { - return knowledgeSource.add(ks); + return knowledgeSources.add(ks); } /** - * @param o - * @return - * @see java.util.Set#remove(java.lang.Object) + * Removes a knowledge source with the given URL (independant of its type). + * @param url URL of the OWL file or SPARQL Endpoint. + * @return True if a knowledge source was deleted, false otherwise. */ - public boolean removeKnowledgeSource(KnowledgeSource ks) { - return knowledgeSource.remove(ks); + public boolean removeKnowledgeSource(String url) { + Iterator<KnowledgeSource> it = knowledgeSources.iterator(); + while(it.hasNext()) { + KnowledgeSource source = it.next(); + if((source instanceof OWLFile && ((OWLFile)source).getURL().toString().equals(url)) + || (source instanceof SparqlEndpoint && ((SparqlEndpoint)source).getURL().toString().equals(url)) ) { + it.remove(); + return true; + } + } + return false; } /** @@ -96,10 +110,14 @@ } /** + * Sets the reasoner component and creates the corresponding + * <code>ReasoningService</code> instance. + * * @param reasonerComponent the reasonerComponent to set */ public void setReasonerComponent(ReasonerComponent reasonerComponent) { this.reasonerComponent = reasonerComponent; + reasoningService = new ReasoningService(reasonerComponent); } /** @@ -115,5 +133,12 @@ public void setLearningAlgorithm(LearningAlgorithm learningAlgorithm) { this.learningAlgorithm = learningAlgorithm; } + + /** + * @return the reasoningService + */ + public ReasoningService getReasoningService() { + return reasoningService; + } } Added: trunk/src/dl-learner/org/dllearner/server/UnknownComponentException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/UnknownComponentException.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/UnknownComponentException.java 2007-10-09 14:06:57 UTC (rev 203) @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.server; + +/** + * @author Jens Lehmann + * + */ +public class UnknownComponentException extends Exception { + + private static final long serialVersionUID = -8736552102773724529L; + + public UnknownComponentException(String component) { + super("Component " + component + " no known in this context."); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-16 09:27:30
|
Revision: 226 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=226&view=rev Author: jenslehmann Date: 2007-10-16 02:27:26 -0700 (Tue, 16 Oct 2007) Log Message: ----------- deleted deprecated classes Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java trunk/src/dl-learner/org/dllearner/server/NoOntologySelectedException.java trunk/src/dl-learner/org/dllearner/server/OntologyURLNotValid.java trunk/src/dl-learner/org/dllearner/server/jaxws/NoOntologySelectedExceptionBean.java trunk/src/dl-learner/org/dllearner/server/jaxws/OntologyURLNotValidBean.java Deleted: trunk/src/dl-learner/org/dllearner/server/ClientState.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-10-16 09:19:34 UTC (rev 225) +++ trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-10-16 09:27:26 UTC (rev 226) @@ -1,571 +0,0 @@ - -package org.dllearner.server; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.dllearner.Config; -import org.dllearner.ConfigurationManager; -import org.dllearner.algorithms.refinement.ROLearner; -import org.dllearner.cli.ConfFileOption; -import org.dllearner.core.Reasoner; -import org.dllearner.core.ReasoningMethodUnsupportedException; -import org.dllearner.core.ReasoningService; -import org.dllearner.core.dl.AtomicConcept; -import org.dllearner.core.dl.AtomicRole; -import org.dllearner.core.dl.Individual; -import org.dllearner.kb.OntologyFileFormat; -import org.dllearner.utilities.Helper; - -public class ClientState { - - // private String reasonerURL="http://localhost:8081"; - //private String reasonerURL="http://localhost:3490"; - - private SortedSet<Individual> positiveExamples = new TreeSet<Individual>(); - public SortedSet<Individual> getPosExamples() { return this.positiveExamples;} - - private SortedSet<Individual> negativeExamples = new TreeSet<Individual>(); - public SortedSet<Individual> getNegExamples() { return this.negativeExamples;} - - private SortedSet<String> ignoredConcept = new TreeSet<String>(); - - - private Reasoner reasoner; - public Reasoner getReasoner() { return reasoner;} - - private ReasoningService rs; - public ReasoningService getRs() { return rs; } - - private String currentOntologyURL=null; - private boolean debug_flag=true; - private LearnMonitor lm=null; - - private String lastResult=""; - public String getLastResult(){ - try{ - return ROL.getBestSolution().toString(); - }catch (Exception e) {} - return this.lastResult; } - public void setLastResult(String lastResult) {this.lastResult = lastResult;} - - private String status="maiden-like"; - public void setStatus(String status) {this.status = status;} - - ConfigurationManager confMgr; - public void addOption(ConfFileOption c){confMgr.applyConfigurationOption(c);} - ROLearner ROL; - - public ClientState() { - - - TreeSet<ConfFileOption> s=new TreeSet<ConfFileOption>(); - //s.add(new ConfigurationOption("refinement","quiet","true")); - /*s.add(new ConfigurationOption()); - s.add(new ConfigurationOption()); - s.add(new ConfigurationOption()); - s.add(new ConfigurationOption()); - s.add(new ConfigurationOption()); - s.add(new ConfigurationOption());*/ - - confMgr = new ConfigurationManager(s); - addOption(new ConfFileOption("refinement","quiet","true")); - //confMgr.applyOptions(); - - } - - - - - public void addPositiveExample(String posExample) { - positiveExamples.add(new Individual(posExample)); - p("added pos: "+posExample); - } - - - public void addNegativeExample(String negExample) { - negativeExamples.add(new Individual(negExample)); - p("added neg: "+negExample); - } - - public void addIgnoredConcept(String concept) { - ignoredConcept.add(concept); - p("added ignoredConcepts: "+concept); - } - - public String[] selectInstancesForAConcept(String Concept)throws NoOntologySelectedException{ - if(Concept.endsWith("#Thing"))return new String[]{}; - AtomicConcept SelectedConcept=new AtomicConcept(Concept); - ArrayList<String> al=new ArrayList<String>(); - Individual indtmp=null; - //Set<AtomicConcept> ConceptSet=null; - AtomicConcept ac=null; - - - System.out.println("selectInstancesForAConcept: "+Concept); - // add all positives - Set<Individual> positives=rs.retrieval(SelectedConcept); - Iterator<Individual> i = positives.iterator(); - while(i.hasNext()){ - indtmp=i.next(); - p("added "+indtmp.getName()+" to positives"); - al.add("added "+indtmp.getName()+" to positives"); - positiveExamples.add(indtmp); - } - - //find more general concepts - ArrayList<AtomicConcept> superConcepts=new ArrayList<AtomicConcept>(); - try{ - //ConceptSet = rs.getSubsumptionHierarchy().getMoreGeneralConcepts(new AtomicConcept(Concept)); - //System.out.println(ConceptSet); - //Concept c=new AtomicConcept(Concept); - /*Set<AtomicConcept> s=rs.getAtomicConcepts(); - Set<Concept> sc=new TreeSet<Concept>(); - Iterator a=s.iterator(); - while (a.hasNext()) { - sc.add((Concept) a.next()); - } - sc=rs.subsumes(sc,new AtomicConcept(Concept));*/ - superConcepts=subsumesAll(SelectedConcept); - - //System.out.println("sizebefore: "+"size after:"+sc); - }catch (Exception e) {e.printStackTrace();} - - -// remove top - for (int j = 0; j < superConcepts.size(); ) { - //TODO no unique name assumption? - if(superConcepts.get(j).getName().equals(SelectedConcept.getName())){ - superConcepts.remove(j); - j=0; - continue; - } - if(superConcepts.get(j).getName().equals("TOP")){ - superConcepts.remove(j); - j=0; - continue; - } - j++; - } - - System.out.println("Found all those:"+ superConcepts); - - ac=null; - - if(superConcepts.size()==0){return al2s(al); }//TODO - else - { // add all negatives of all superclasses; - - //Iterator it=ConceptSet.iterator(); - for (int jj = 0; jj < superConcepts.size(); jj++) - { - ac=superConcepts.get(jj); - p("next this: "+ac.getName()); - Set<Individual> negatives=rs.retrieval(ac); - Iterator<Individual> i2 = negatives.iterator(); - indtmp=null; - while(i2.hasNext()){ - - indtmp=(Individual)i2.next(); - - if(!positives.contains(indtmp)){ - - p("added "+indtmp.getName()+" to NEGATIVES"); - al.add("added "+indtmp.getName()+" to NEGATIVES"); - negativeExamples.add(indtmp); - } - else{ - p("skipped "+indtmp.getName()); - al.add("skipped "+indtmp.getName()); - } - - } - }//endfor - return al2s(al); - } - - - } - - - - public String[] selectAConcept(String Concept, int Percentage)throws NoOntologySelectedException{ - if(Concept.endsWith("#Thing"))return new String[]{}; - AtomicConcept SelectedConcept=new AtomicConcept(Concept); - ArrayList<String> ret=new ArrayList<String>(); - Individual indtmp=null; - //Set<AtomicConcept> ConceptSet=null; - //AtomicConcept ac=null; - Random r=new Random(); - - - System.out.println("selectAConcept: "+Concept); - // add all positives - Set<Individual> positives=rs.retrieval(SelectedConcept); - Iterator<Individual> i = positives.iterator(); - while(i.hasNext()){ - indtmp=(Individual)i.next(); - p("added "+indtmp.getName()+" to positives"); - ret.add("added "+indtmp.getName()+" to positives"); - positiveExamples.add(indtmp); - } - - //find All other Instances concepts - Set<Individual> otherInstances=rs.getIndividuals(); - Iterator<Individual> it=otherInstances.iterator(); - while(it.hasNext()){ - indtmp=(Individual)it.next(); - - if(!positives.contains(indtmp) && (r.nextDouble()*100)<=Percentage){ - - p("added "+indtmp.getName()+" to NEGATIVES"); - ret.add("added "+indtmp.getName()+" to NEGATIVES"); - negativeExamples.add(indtmp); - } - }//while - - return al2s(ret); - - } - - - public ArrayList<AtomicConcept> subsumesAll(AtomicConcept c){ - Set<AtomicConcept> s=rs.getAtomicConcepts(); - ArrayList<AtomicConcept> ret=new ArrayList<AtomicConcept>(); - Iterator<AtomicConcept> i=s.iterator(); - while (i.hasNext()) { - AtomicConcept element = (AtomicConcept) i.next(); - if(rs.subsumes(element, c)) - { - ret.add(element); - } - - } - return ret; - } - public String[] getPositiveExamples(){ - String[] ret=new String[positiveExamples.size()]; - Iterator<Individual> i=positiveExamples.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((Individual)i.next()).getName(); - } - //p("getPositiveEx"); - return ret; - } - public String[] getNegativeExamples(){ - String[] ret=new String[negativeExamples.size()]; - Iterator<Individual> i=negativeExamples.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((Individual)i.next()).getName(); - } - //p("getNegativeEx"); - return ret; - } - - public String[] getIgnoredConcepts() { - String[] ret=new String[ignoredConcept.size()]; - Iterator<String> i=ignoredConcept.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((String)i.next()); - } - //p("getNegativeEx"); - return ret; - } - - public String getSubsumptionHierarchy() throws NoOntologySelectedException { - try{ - return this.rs.getSubsumptionHierarchy().toString(); - }catch (Exception e) {throw new NoOntologySelectedException("Subsumptionhierarchy",e.getMessage());} - - } - - - - public boolean removeNegativeExample(String NegExample){ - p("removed from neg: "+NegExample); - return negativeExamples.remove(new Individual(NegExample)); - } - public boolean removePositiveExample(String PosExample){ - p("removed from pos: "+PosExample); - return positiveExamples.remove(new Individual(PosExample)); - } - - public boolean removeAllPositiveExamples(){ - positiveExamples = new TreeSet<Individual>(); - p("removing all positive examples"); - return true; - } - public boolean removeAllNegativeExamples(){ - negativeExamples = new TreeSet<Individual>(); - p("removing all negative examples"); - return true; - } - - public boolean removeAllExamples(){ - positiveExamples = new TreeSet<Individual>(); - negativeExamples = new TreeSet<Individual>(); - p("removing all examples"); - return true; - } - - public void removeIgnoredConcept(String concept) { - //ignoredConcept.add(concept); - this.ignoredConcept.remove(concept); - p("removed ignoredConcepts: "+concept); - } - - public String[] getInstances()throws NoOntologySelectedException{ - try{ - SortedSet<Individual> s=rs.getIndividuals(); - //System.out.println(s); - String[] ret=new String[s.size()]; - Iterator<Individual> i=s.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((Individual)i.next()).getName(); - } - Arrays.sort(ret); - //p("getInstances"); - return ret; - }catch (Exception e) {throw new NoOntologySelectedException("Failed to get instances, no ontology selected","");} - } - - public String getCurrentOntologyURL()throws NoOntologySelectedException{ - p("getCurrentOntology: "+currentOntologyURL); - if(currentOntologyURL==null)throw new NoOntologySelectedException("Select Ontology First","quatsch"); - else return currentOntologyURL; - } - - public String getAlgorithmStatus(){ - return this.status; - } - - /** - * Specifies the URI of the ontology containing the background - * knowledge. Reads the ontology and sends it to the reasoner. - * - * @param ontologyURI The URI of the ontology to use. - */ - // gleiche Methoden mit verschiedenen Parametern sind offenbar problematisch - /* - @WebMethod - public void readOntology(String ontologyURI) { - readOntology(ontologyURI, "RDF/XML"); - } - */ - - - public void removeOntology() { - this.currentOntologyURL=null; - this.reasoner=null; - this.rs=null; - this.positiveExamples = new TreeSet<Individual>(); - this.negativeExamples = new TreeSet<Individual>(); - this.ignoredConcept=new TreeSet<String>(); - p("removing Ontology"); - - } - - /** - * Specifies the URI of the ontology containing the background - * knowledge and its format. Reads the ontology and sends it to - * the reasoner. - * - * @param ontologyURI The URI of the ontology to use. - * @param format "RDF/XML" or "N-TRIPLES". - */ - - - public void readOntology(String ontologyURL, String format) throws OntologyURLNotValid{ - this.currentOntologyURL=ontologyURL; - p("trying to read: "+ontologyURL+" ::"+format); - try{ - // this.ontologyURL = ontologyURL; - // this.ontologyFormat = format; - - // TODO: potentielles Sicherheitsrisiko, da man damit derzeit auch lokale Dateien - // laden könnte (Fix: nur http:// zulassen, kein file://) - URL ontology = null; - try { - ontology = new URL(ontologyURL); - } catch (MalformedURLException e1) { - this.removeOntology(); - throw new OntologyURLNotValid("The URL of the Ontology is not correct<br>\nCheck settings and URL","OntologyURLNotValid"); - - } - - OntologyFileFormat ofFormat; - if (format.equals("RDF/XML")) - ofFormat = OntologyFileFormat.RDF_XML; - else - ofFormat = OntologyFileFormat.N_TRIPLES; - - Map<URL, OntologyFileFormat> m = new HashMap<URL, OntologyFileFormat>(); - m.put(ontology, ofFormat); - - // Default-URI für DIG-Reasoner setzen - -// try { -// Config.digReasonerURL = new URL(reasonerURL); -// } catch (MalformedURLException e) { -// // Exception tritt nie auf, da URL korrekt -// e.printStackTrace(); -// } - - // reasoner = Main.createReasoner(new KB(), m); - System.err.println("TODO: rewrite webservice code"); - rs = new ReasoningService(reasoner); - - Helper.autoDetectConceptsAndRoles(rs); - reasoner.prepareSubsumptionHierarchy(); - if (Config.Refinement.improveSubsumptionHierarchy) { - try { - reasoner.prepareRoleHierarchy(); - reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); - } catch (ReasoningMethodUnsupportedException e) { - // solange DIG-Reasoner eingestellt ist, schlägt diese Operation nie fehl - e.printStackTrace(); - } - } - p(rs.getSubsumptionHierarchy().toString()); - //rs.getRoleMembers(arg0) - } - catch (Exception e) { //TODO - this.removeOntology(); - throw new OntologyURLNotValid("The URL of the Ontology is not correct<br>\nCheck settings and URL","OntologyURLNotValid"); - } - /*catch (JenaException e) { - e.printStackTrace();} - */ - - /*catch(Exception e2) { - - //p("exception:"+e.getMessage()); - e2.printStackTrace(); - }*/ - p("Ontology read: "+currentOntologyURL); - } - - - public void learnMonitored(){ - addOption(new ConfFileOption("refinement","ignoredConcepts",ignoredConcept)); - this.lm=new LearnMonitor(this); - this.lm.start(); - //this.lm.learn(this); - } - - /*public void relearn(){ - //TreeSet<String> s=new TreeSet<String>(); - //new ConfigurationOption(); - this.lm=new LearnMonitor(this); - this.lm.start(); - //this.lm.learn(this); - }*/ - - - public String[] getAtomicConcepts()throws NoOntologySelectedException{ - try{ - return SortedSet2StringListConcepts( rs.getAtomicConcepts()); - }catch (Exception e) {throw new NoOntologySelectedException("Select Ontology First","ddddd");} - } - - public String[] retrieval(String Concept)throws NoOntologySelectedException{ - return SortedSet2StringListIndividuals(rs.retrieval(new AtomicConcept(Concept))); - } - - public String[] getAtomicRoles()throws NoOntologySelectedException{ - return SortedSet2StringListRoles( rs.getAtomicRoles()); - } - - public String[] getIndividualsForARole(String Role)throws NoOntologySelectedException{ - Map<Individual,SortedSet<Individual>> m=rs.getRoleMembers(new AtomicRole(Role)); - Set<Individual> s=m.keySet(); - return SortedSet2StringListIndividuals(s); - } - - public synchronized void stop(){ - System.out.println("ROL"+this.ROL); - - System.out.println("lm"+lm); - System.out.println("lmstate"+lm.getState()); - System.out.println("lmalive"+lm.isAlive()); - System.out.println("lminterrupt"+lm.isInterrupted()); - this.ROL.stop(); - //lm.end(); - /*try{ - synchronized (this.lm) { - //this.lm.yield(); - } - }catch (Exception e) {e.printStackTrace();}*/ - System.out.println("lmstate"+lm.getState()); - System.out.println("lmalive"+lm.isAlive()); - System.out.println("lminterrupt"+lm.isInterrupted()); - - //this.ROL.stop(); - //this.lm.interrupt(); - - //this.lm.end(); - //this.lm.notify(); - } - - public String[] SortedSet2StringListIndividuals(Set<Individual> s){ - - String[] ret=new String[s.size()]; - Iterator<Individual> i=s.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((Individual)i.next()).getName(); - } - Arrays.sort(ret); - return ret; - } - - public String[] SortedSet2StringListConcepts(Set<AtomicConcept> s){ - - String[] ret=new String[s.size()]; - Iterator<AtomicConcept> i=s.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((AtomicConcept)i.next()).getName(); - } - Arrays.sort(ret); - return ret; - } - public String[] SortedSet2StringListRoles(Set<AtomicRole> s){ - - String[] ret=new String[s.size()]; - Iterator<AtomicRole> i=s.iterator(); - int a=0; - while (i.hasNext()){ - ret[a++]=((AtomicRole)i.next()).getName(); - } - Arrays.sort(ret); - return ret; - } - - public String[] al2s(ArrayList<String> al){ - String[] ret=new String[al.size()]; - for (int i = 0; i < al.size(); i++) { - ret[i]=al.get(i); - } - return ret; - } - public void p(String s){ - if(debug_flag){ - System.out.println("\t"+s); - } - - } -} Deleted: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-16 09:19:34 UTC (rev 225) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-16 09:27:26 UTC (rev 226) @@ -1,225 +0,0 @@ -package org.dllearner.server; - -import java.util.HashMap; -import java.util.Random; - -import javax.jws.WebMethod; -import javax.jws.WebService; -import javax.jws.soap.SOAPBinding; - - -/** - * Offene Fragen: - * - * Welche Rückgabetypen sind erlaubt? - * Wie behandelt man Exceptions (z.B. aus angegebener URI kann keine Ontologie - * gelesen werden)? - * - * @author Jens Lehmann - * - */ -@WebService(name = "DLLearnerWebService") -@SOAPBinding(style = SOAPBinding.Style.RPC) -public class DLLearnerWS { - Random rand=new Random(); - private HashMap<Integer, ClientState> clients; - - // private String ontologyURL; - // private String ontologyFormat; - - - - public DLLearnerWS(){ - this.clients=new HashMap<Integer, ClientState>(); - - } - - /** - * - * - * - */ - @WebMethod - public int getID(){ - int id=rand.nextInt(); - while (id<=0){ - id=rand.nextInt(); - } - - // dont change to local function get, cause of exception - ClientState c=this.clients.get(new Long(id)); - if(c!=null){ - return getID(); - } - else { - this.clients.put(new Integer(id), new ClientState()); - System.out.println("new Client with id: "+id); - return id; - } - - } - - @WebMethod - public void addPositiveExample(int id,String posExample) throws ClientNotKnownException{ - ClientState c=getClientState(id); - c.addPositiveExample(posExample); - //positiveExamples.add(new Individual(posExample)); - } - @WebMethod - public void addNegativeExample(int id,String negExample) throws ClientNotKnownException { - ClientState c=getClientState(id); - c.addNegativeExample(negExample); - } - @WebMethod - public void addIgnoredConcept(int id,String concept)throws ClientNotKnownException { - getClientState(id).addIgnoredConcept(concept); - } - - @WebMethod - public String[] selectInstancesForAConcept(int id,String Concept)throws ClientNotKnownException,NoOntologySelectedException{ - return getClientState(id).selectInstancesForAConcept(Concept); - } - - @WebMethod - public String[] selectAConcept(int id,String Concept,int Percentage)throws ClientNotKnownException,NoOntologySelectedException{ - return getClientState(id).selectAConcept(Concept, Percentage); - } - - @WebMethod - public String[] getPositiveExamples(int id)throws ClientNotKnownException{ - ClientState c=getClientState(id); - return c.getPositiveExamples(); - } - @WebMethod - public String[] getNegativeExamples(int id)throws ClientNotKnownException{ - ClientState c=getClientState(id); - return c.getNegativeExamples(); - } - @WebMethod - public String[] getIgnoredConcepts(int id)throws ClientNotKnownException{ - return getClientState(id).getIgnoredConcepts(); - } - - @WebMethod - public boolean removePositiveExample(int id, String pos)throws ClientNotKnownException{ - return getClientState(id).removePositiveExample(pos); - } - - @WebMethod - public boolean removeNegativeExample(int id, String neg)throws ClientNotKnownException{ - return getClientState(id).removeNegativeExample(neg); - } - @WebMethod - public boolean removeAllExamples(int id)throws ClientNotKnownException{ - return getClientState(id).removeAllExamples(); - } - @WebMethod - public boolean removeAllPositiveExamples(int id)throws ClientNotKnownException{ - return getClientState(id).removeAllPositiveExamples(); - } - @WebMethod - public boolean removeAllNegativeExamples(int id)throws ClientNotKnownException{ - return getClientState(id).removeAllNegativeExamples(); - } - @WebMethod - public void removeIgnoredConcept(int id,String concept)throws ClientNotKnownException{ - getClientState(id).removeIgnoredConcept(concept); - } - - @WebMethod - public String getCurrentOntologyURL(int id)throws ClientNotKnownException,NoOntologySelectedException{ - return getClientState(id).getCurrentOntologyURL(); - - } - - @WebMethod - public String[] getInstances(int id)throws ClientNotKnownException,NoOntologySelectedException{ - return getClientState(id).getInstances(); - } - - @WebMethod - public String[] getAtomicConcepts(int id)throws ClientNotKnownException,NoOntologySelectedException{ - return getClientState(id).getAtomicConcepts(); - } - - @WebMethod - public String[] getAtomicRoles(int id)throws ClientNotKnownException,NoOntologySelectedException{ - return getClientState(id).getAtomicRoles(); - } - @WebMethod - public String[] getIndividualsForARole(int id,String Role)throws ClientNotKnownException, NoOntologySelectedException{ - return getClientState(id).getIndividualsForARole(Role); - } - @WebMethod - public String getSubsumptionHierarchy(int id)throws ClientNotKnownException, NoOntologySelectedException{ - return getClientState(id).getSubsumptionHierarchy(); - } - - @WebMethod - public String[] retrieval(int id,String Concept)throws ClientNotKnownException,NoOntologySelectedException{ - return getClientState(id).retrieval(Concept); - } - - @WebMethod - public void readOntology(int id,String ontologyURL, String format)throws ClientNotKnownException,OntologyURLNotValid{ - getClientState(id).readOntology(ontologyURL, format); - - } - - @WebMethod - public void removeOntology(int id)throws ClientNotKnownException{ - getClientState(id).removeOntology(); - } - - @WebMethod - public String learnConcept(int id)throws ClientNotKnownException{ - return "Deprecated method"; - - } - - - @WebMethod - public String getAlgorithmStatus(int id ) throws ClientNotKnownException{ - - return getClientState(id).getAlgorithmStatus(); - } - - - @WebMethod - public void learnMonitored(int id )throws ClientNotKnownException{ - getClientState(id).learnMonitored(); - } - /*@WebMethod - public void relearn(int id,String Concept )throws ClientNotKnownException{ - getClientState(id).relearn(Concept); - }*/ - - @WebMethod - public String getLastResult(int id)throws ClientNotKnownException{ - return getClientState(id).getLastResult(); - } - - @WebMethod - public void stop(int id)throws ClientNotKnownException{ - getClientState(id).stop(); - } - - - //*************************USER MANAGEMENT - - public ClientState getClientState(int id)throws ClientNotKnownException{ - System.out.println("Request from "+id); - ClientState c=this.clients.get(new Integer(id)); - if(c==null){ - //System.out.println(clients.keySet().toString()); - // throw new ClientNotKnownException("Client with id: "+id+" is not known","ClientNotKnownException"); - }; - return c; - - } - - - - - -} \ No newline at end of file Deleted: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java 2007-10-16 09:19:34 UTC (rev 225) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java 2007-10-16 09:27:26 UTC (rev 226) @@ -1,166 +0,0 @@ -package org.dllearner.server; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; - -import javax.jws.WebMethod; -import javax.jws.WebService; -import javax.jws.soap.SOAPBinding; - -import org.dllearner.Config; -import org.dllearner.algorithms.refinement.ROLearner; -import org.dllearner.core.Reasoner; -import org.dllearner.core.ReasoningMethodUnsupportedException; -import org.dllearner.core.ReasoningService; -import org.dllearner.core.dl.Individual; -import org.dllearner.kb.OntologyFileFormat; -import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.utilities.Helper; - -/** - * Offene Fragen: - * - * Welche Rückgabetypen sind erlaubt? - * Wie behandelt man Exceptions (z.B. aus angegebener URI kann keine Ontologie - * gelesen werden)? - * - * @author Jens Lehmann - * - */ -@WebService(name = "DLLearnerWebService") -@SOAPBinding(style = SOAPBinding.Style.RPC) -public class DLLearnerWSoriginal { - - // private String ontologyURL; - // private String ontologyFormat; - private Reasoner reasoner; - private ReasoningService rs; - private SortedSet<Individual> positiveExamples = new TreeSet<Individual>(); - private SortedSet<Individual> negativeExamples = new TreeSet<Individual>(); - - /** - * Specifies the URI of the ontology containing the background - * knowledge. Reads the ontology and sends it to the reasoner. - * - * @param ontologyURI The URI of the ontology to use. - */ - // gleiche Methoden mit verschiedenen Parametern sind offenbar problematisch - /* - @WebMethod - public void readOntology(String ontologyURI) { - readOntology(ontologyURI, "RDF/XML"); - } - */ - - /** - * Specifies the URI of the ontology containing the background - * knowledge and its format. Reads the ontology and sends it to - * the reasoner. - * - * @param ontologyURI The URI of the ontology to use. - * @param format "RDF/XML" or "N-TRIPLES". - */ - @WebMethod - public void readOntology(String ontologyURL, String format) { - // this.ontologyURL = ontologyURL; - // this.ontologyFormat = format; - - // TODO: potentielles Sicherheitsrisiko, da man damit derzeit auch lokale Dateien - // laden könnte (Fix: nur http:// zulassen, kein file://) - URL ontology = null; - try { - ontology = new URL(ontologyURL); - } catch (MalformedURLException e1) { - e1.printStackTrace(); - } - - OntologyFileFormat ofFormat; - if (format.equals("RDF/XML")) - ofFormat = OntologyFileFormat.RDF_XML; - else - ofFormat = OntologyFileFormat.N_TRIPLES; - - Map<URL, OntologyFileFormat> m = new HashMap<URL, OntologyFileFormat>(); - m.put(ontology, ofFormat); - - // Default-URI für DIG-Reasoner setzen -// try { -// Config.digReasonerURL = new URL("http://localhost:8081"); -// } catch (MalformedURLException e) { -// // Exception tritt nie auf, da URL korrekt -// e.printStackTrace(); -// } - - // reasoner = Main.createReasoner(new KB(), m); - - rs = new ReasoningService(reasoner); - - } - - - @WebMethod - public String[] testString(String c) { - - return new String[]{"a","b"}; - } - - // String[] funktioniert leider noch nicht - @WebMethod - public void addPositiveExamples(String[] posExamples) { - for(String example : posExamples) - positiveExamples.add(new Individual(example)); - } - - @WebMethod - public void addNegativeExamples(String[] negExamples) { - for(String example : negExamples) - negativeExamples.add(new Individual(example)); - } - - - @WebMethod - public void addPositiveExample(String posExample) { - positiveExamples.add(new Individual(posExample)); - } - - @WebMethod - public void addNegativeExample(String negExample) { - negativeExamples.add(new Individual(negExample)); - } - - @WebMethod - public String learnConcept() { - // notwendige Vorverarbeitungsschritte für den Lernalgorithmus - // - es müssen ein paar Konzepte, die ev. von Jena generiert wurden ignoriert - // werden - // - die Subsumptionhierarchie muss erstellt werden - // - die Subsumptionhierarchie wird verbessert um das Lernen effizienter zu machen - Helper.autoDetectConceptsAndRoles(rs); - reasoner.prepareSubsumptionHierarchy(); - if (Config.Refinement.improveSubsumptionHierarchy) { - try { - reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); - } catch (ReasoningMethodUnsupportedException e) { - // solange DIG-Reasoner eingestellt ist, schlägt diese Operation nie fehl - e.printStackTrace(); - } - } - - // LearningProblem learningProblem = new LearningProblem(rs, positiveExamples, negativeExamples); - PosNegLP learningProblem = null; - // erstmal wird nur der Refinement-Learner als Web-Service angeboten - ROLearner learner = new ROLearner(learningProblem, null); - return learner.getBestSolution().toString(); - } - - // Testmethode - @WebMethod - public String hello(String name) { - return "Hello " + name + "!"; - } - -} \ No newline at end of file Deleted: trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java 2007-10-16 09:19:34 UTC (rev 225) +++ trunk/src/dl-learner/org/dllearner/server/LearnMonitor.java 2007-10-16 09:27:26 UTC (rev 226) @@ -1,84 +0,0 @@ -package org.dllearner.server; - -import org.dllearner.Config; -import org.dllearner.core.ReasoningMethodUnsupportedException; -import org.dllearner.utilities.Helper; - -public class LearnMonitor extends Thread { - - - private ClientState c; - private boolean active = false; - - //private ROLearner ROL; - - public LearnMonitor(ClientState c){ - this.c=c; - } - - - public void end(){ - - System.out.println("trying to end"); - System.out.println("ROL2"+c.ROL); - this.c.ROL.stop(); - c.setLastResult(c.ROL.getBestSolution().toString()); - c.setStatus("stopped"); - } - - public void learn(){ - - this.start(); - - } - - /** - * @override - */ - @Override - public void run(){ - try{ - c.setStatus("still running"); - if(active); - active=true; - c.setStatus("running"); - - // notwendige Vorverarbeitungsschritte für den Lernalgorithmus - // - es müssen ein paar Konzepte, die ev. von Jena generiert wurden ignoriert - // werden - // - die Subsumptionhierarchie muss erstellt werden - // - die Subsumptionhierarchie wird verbessert um das Lernen effizienter zu machen - Helper.autoDetectConceptsAndRoles(c.getRs()); - c.getReasoner().prepareSubsumptionHierarchy(); - if (Config.Refinement.improveSubsumptionHierarchy) { - try { - c.getReasoner().getSubsumptionHierarchy().improveSubsumptionHierarchy(); - } catch (ReasoningMethodUnsupportedException e) { - // solange DIG-Reasoner eingestellt ist, schlägt diese Operation nie fehl - e.printStackTrace(); - } - } - c.p("learning started"); - // LearningProblem learningProblem = new LearningProblem(c.getRs(), c.getPosExamples(), c.getNegExamples()); - // erstmal wird nur der Refinement-Learner als Web-Service angeboten - //System.out.println("aaaa"); - // c.ROL = new ROLearner(learningProblem); - - c.ROL.start(); - //new ROLearner(); - //c.p(("ROL1"+ROL)); - - - - - - - //c.setLastResult(c.ROL.getBestSolution().toString()); - c.setLastResult(c.ROL.getBestSolution().toString()); - c.setStatus("finished"); - - }catch (Exception e) {e.printStackTrace();} - finally{active=false;}; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/server/NoOntologySelectedException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/NoOntologySelectedException.java 2007-10-16 09:19:34 UTC (rev 225) +++ trunk/src/dl-learner/org/dllearner/server/NoOntologySelectedException.java 2007-10-16 09:27:26 UTC (rev 226) @@ -1,15 +0,0 @@ -package org.dllearner.server; - -public class NoOntologySelectedException extends Exception { - static final long serialVersionUID=101; - String detail; - - public NoOntologySelectedException (String message, String detail) { - super (message); - this.detail = detail; - } - - public String getDetail () { - return detail; - } -} Deleted: trunk/src/dl-learner/org/dllearner/server/OntologyURLNotValid.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/OntologyURLNotValid.java 2007-10-16 09:19:34 UTC (rev 225) +++ trunk/src/dl-learner/org/dllearner/server/OntologyURLNotValid.java 2007-10-16 09:27:26 UTC (rev 226) @@ -1,15 +0,0 @@ -package org.dllearner.server; - -public class OntologyURLNotValid extends Exception { - static final long serialVersionUID=102; - String detail; - - public OntologyURLNotValid (String message, String detail) { - super (message); - this.detail = detail; - } - - public String getDetail () { - return detail; - } -} Deleted: trunk/src/dl-learner/org/dllearner/server/jaxws/NoOntologySelectedExceptionBean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/jaxws/NoOntologySelectedExceptionBean.java 2007-10-16 09:19:34 UTC (rev 225) +++ trunk/src/dl-learner/org/dllearner/server/jaxws/NoOntologySelectedExceptionBean.java 2007-10-16 09:27:26 UTC (rev 226) @@ -1,63 +0,0 @@ - -package org.dllearner.server.jaxws; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - * This class was generated by the JAXWS SI. - * JAX-WS RI 2.0_02-b08-fcs - * Generated source version: 2.0_02 - * - */ -@XmlRootElement(name = "NoOntologySelectedException", namespace = "http://server.dllearner.org/") -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "NoOntologySelectedException", namespace = "http://server.dllearner.org/", propOrder = { - "detail", - "message" -}) -public class NoOntologySelectedExceptionBean { - - private String detail; - private String message; - - /** - * - * @return - * returns String - */ - public String getDetail() { - return this.detail; - } - - /** - * - * @param detail - * the value for the detail property - */ - public void setDetail(String detail) { - this.detail = detail; - } - - /** - * - * @return - * returns String - */ - public String getMessage() { - return this.message; - } - - /** - * - * @param message - * the value for the message property - */ - public void setMessage(String message) { - this.message = message; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/server/jaxws/OntologyURLNotValidBean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/jaxws/OntologyURLNotValidBean.java 2007-10-16 09:19:34 UTC (rev 225) +++ trunk/src/dl-learner/org/dllearner/server/jaxws/OntologyURLNotValidBean.java 2007-10-16 09:27:26 UTC (rev 226) @@ -1,63 +0,0 @@ - -package org.dllearner.server.jaxws; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - * This class was generated by the JAXWS SI. - * JAX-WS RI 2.0_02-b08-fcs - * Generated source version: 2.0_02 - * - */ -@XmlRootElement(name = "OntologyURLNotValid", namespace = "http://server.dllearner.org/") -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "OntologyURLNotValid", namespace = "http://server.dllearner.org/", propOrder = { - "detail", - "message" -}) -public class OntologyURLNotValidBean { - - private String detail; - private String message; - - /** - * - * @return - * returns String - */ - public String getDetail() { - return this.detail; - } - - /** - * - * @param detail - * the value for the detail property - */ - public void setDetail(String detail) { - this.detail = detail; - } - - /** - * - * @return - * returns String - */ - public String getMessage() { - return this.message; - } - - /** - * - * @param message - * the value for the message property - */ - public void setMessage(String message) { - this.message = message; - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-01-18 10:52:02
|
Revision: 390 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=390&view=rev Author: kurzum Date: 2008-01-18 02:52:00 -0800 (Fri, 18 Jan 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Modified: trunk/src/dl-learner/org/dllearner/server/ClientState.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientState.java 2008-01-18 10:48:33 UTC (rev 389) +++ trunk/src/dl-learner/org/dllearner/server/ClientState.java 2008-01-18 10:52:00 UTC (rev 390) @@ -33,7 +33,7 @@ import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; import org.dllearner.kb.OWLFile; -import org.dllearner.kb.sparql.SparqlEndpoint; +import org.dllearner.kb.SparqlKnowledgeSource; /** * Stores the state of a DL-Learner client session. @@ -113,7 +113,7 @@ while(it.hasNext()) { KnowledgeSource source = it.next(); if((source instanceof OWLFile && ((OWLFile)source).getURL().toString().equals(url)) - || (source instanceof SparqlEndpoint && ((SparqlEndpoint)source).getURL().toString().equals(url)) ) { + || (source instanceof SparqlKnowledgeSource && ((SparqlKnowledgeSource)source).getURL().toString().equals(url)) ) { it.remove(); return true; } Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-01-18 10:48:33 UTC (rev 389) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-01-18 10:52:00 UTC (rev 390) @@ -46,7 +46,7 @@ import org.dllearner.core.dl.Concept; import org.dllearner.core.dl.Individual; import org.dllearner.kb.OWLFile; -import org.dllearner.kb.sparql.SparqlEndpoint; +import org.dllearner.kb.SparqlKnowledgeSource; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegInclusionLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; @@ -79,7 +79,7 @@ public DLLearnerWS() { knowledgeSourceMapping.put("owlfile", OWLFile.class); - knowledgeSourceMapping.put("sparql", SparqlEndpoint.class); + knowledgeSourceMapping.put("sparql", SparqlKnowledgeSource.class); reasonerMapping.put("dig", DIGReasoner.class); learningProblemMapping.put("posNegDefinition", PosNegDefinitionLP.class); learningProblemMapping.put("posNegInclusion", PosNegInclusionLP.class); @@ -500,10 +500,10 @@ thread = new Thread() { @Override public void run() { - ((SparqlEndpoint)component).setSubjectThread(this); - ((SparqlEndpoint)component).setSubjectThreadRunning(true); - ((SparqlEndpoint)component).calculateSubjects(label,limit); - ((SparqlEndpoint)component).setSubjectThreadRunning(false); + ((SparqlKnowledgeSource)component).setSubjectThread(this); + ((SparqlKnowledgeSource)component).setSubjectThreadRunning(true); + ((SparqlKnowledgeSource)component).calculateSubjects(label,limit); + ((SparqlKnowledgeSource)component).setSubjectThreadRunning(false); } }; } else if (method.equals("triples")){ @@ -511,10 +511,10 @@ thread = new Thread() { @Override public void run() { - ((SparqlEndpoint)component).setTriplesThread(this); - ((SparqlEndpoint)component).setTriplesThreadRunning(true); - ((SparqlEndpoint)component).calculateTriples(subject); - ((SparqlEndpoint)component).setTriplesThreadRunning(false); + ((SparqlKnowledgeSource)component).setTriplesThread(this); + ((SparqlKnowledgeSource)component).setTriplesThreadRunning(true); + ((SparqlKnowledgeSource)component).calculateTriples(subject); + ((SparqlKnowledgeSource)component).setTriplesThreadRunning(false); } }; } else if (method.equals("conceptSubjects")){ @@ -522,10 +522,10 @@ thread = new Thread() { @Override public void run() { - ((SparqlEndpoint)component).setConceptThread(this); - ((SparqlEndpoint)component).setConceptThreadRunning(true); - ((SparqlEndpoint)component).calculateConceptSubjects(concept); - ((SparqlEndpoint)component).setConceptThreadRunning(false); + ((SparqlKnowledgeSource)component).setConceptThread(this); + ((SparqlKnowledgeSource)component).setConceptThreadRunning(true); + ((SparqlKnowledgeSource)component).calculateConceptSubjects(concept); + ((SparqlKnowledgeSource)component).setConceptThreadRunning(false); } }; } @@ -538,11 +538,11 @@ ClientState state = getState(id); Component component = state.getComponent(componentID); if (option.equals("subjects")) - return ((SparqlEndpoint)component).subjectThreadIsRunning(); + return ((SparqlKnowledgeSource)component).subjectThreadIsRunning(); else if (option.equals("triples")) - return ((SparqlEndpoint)component).triplesThreadIsRunning(); + return ((SparqlKnowledgeSource)component).triplesThreadIsRunning(); else if (option.equals("conceptSubjects")) - return ((SparqlEndpoint)component).conceptThreadIsRunning(); + return ((SparqlKnowledgeSource)component).conceptThreadIsRunning(); return true; } @@ -552,11 +552,11 @@ ClientState state = getState(id); Component component = state.getComponent(componentID); if (option.equals("subjects")) - ((SparqlEndpoint)component).getSubjectThread().stop(); + ((SparqlKnowledgeSource)component).getSubjectThread().stop(); else if (option.equals("triples")) - ((SparqlEndpoint)component).getTriplesThread().stop(); + ((SparqlKnowledgeSource)component).getTriplesThread().stop(); else if (option.equals("conceptSubjects")) - ((SparqlEndpoint)component).getConceptThread().stop(); + ((SparqlKnowledgeSource)component).getConceptThread().stop(); } @WebMethod @@ -565,11 +565,11 @@ ClientState state = getState(id); Component component = state.getComponent(componentID); if (option.equals("subjects")) - return ((SparqlEndpoint)component).getSubjects(); + return ((SparqlKnowledgeSource)component).getSubjects(); else if (option.equals("triples")) - return ((SparqlEndpoint)component).getTriples(); + return ((SparqlKnowledgeSource)component).getTriples(); else if (option.equals("conceptSubjects")) - return ((SparqlEndpoint)component).getConceptSubjects(); + return ((SparqlKnowledgeSource)component).getConceptSubjects(); return new String[0]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |