22daenzeroramapackage test;
22daenzerorama
22daenzeroramaimport java.io.FileNotFoundException;
22daenzeroramaimport java.net.URISyntaxException;
22daenzeroramaimport java.util.Iterator;
22daenzerorama
22daenzeroramaimport org.mindswap.owl.OWLFactory;
22daenzeroramaimport org.mindswap.owl.OWLKnowledgeBase;
22daenzeroramaimport org.mindswap.owls.generic.list.OWLSObjList;
22daenzeroramaimport org.mindswap.owls.process.CompositeProcess;
22daenzeroramaimport org.mindswap.owls.process.ControlConstructList;
22daenzeroramaimport org.mindswap.owls.process.Input;
22daenzeroramaimport org.mindswap.owls.process.Output;
22daenzeroramaimport org.mindswap.owls.process.Perform;
22daenzeroramaimport org.mindswap.owls.process.Sequence;
22daenzeroramaimport org.mindswap.owls.service.Service;
22daenzeroramaimport org.mindswap.utils.URIUtils;
22daenzerorama
22daenzeroramapublic class RemovalTests {
22daenzerorama String uri = "http://example.com/";
22daenzerorama private OWLKnowledgeBase kb;
22daenzerorama private Perform p1;
22daenzerorama private Perform p2;
22daenzerorama private Perform p3;
22daenzerorama private Perform p4;
22daenzerorama
22daenzerorama public static void main(String[] args) {
22daenzerorama RemovalTests test = new RemovalTests();
22daenzerorama test.pelletErrorTest();
22daenzerorama test.removeCCTest();
22daenzerorama test.removeList();
22daenzerorama }
22daenzerorama
22daenzerorama public RemovalTests() {
22daenzerorama kb = OWLFactory.createKB();
22daenzerorama kb.setReasoner("Pellet");
22daenzerorama }
22daenzerorama
22daenzerorama private void pelletErrorTest() {
22daenzerorama kb.getReader().getCache().setLocalCacheDirectory("E://Workspaces//NExT//Ontologies//ont_cache");
22daenzerorama kb.getReader().getCache().setForced(true);
22daenzerorama
22daenzerorama Service service;
22daenzerorama try {
22daenzerorama service = kb.readService("http://www.ifi.unizh.ch/ddis/ont/next/ProcessSpace/Projectgigimgii.owl#gigimgii");
22daenzerorama service.getOntology().write(System.out);
22daenzerorama service.deleteProcess();
22daenzerorama service.getOntology().write(System.out);
22daenzerorama } catch (FileNotFoundException e) {
22daenzerorama e.printStackTrace();
22daenzerorama } catch (URISyntaxException e) {
22daenzerorama e.printStackTrace();
22daenzerorama }
22daenzerorama }
22daenzerorama
22daenzerorama private void removeCCTest() {
22daenzerorama String uri = "http://example.com/p";
22daenzerorama
22daenzerorama p1 = kb.createPerform(URIUtils.createURI(uri + "1"));
22daenzerorama p2 = kb.createPerform(URIUtils.createURI(uri + "2"));
22daenzerorama p3 = kb.createPerform(URIUtils.createURI(uri + "3"));
22daenzerorama p4 = kb.createPerform(URIUtils.createURI(uri + "4"));
22daenzerorama
22daenzerorama Sequence sequence = kb.createSequence(URIUtils.createURI(uri + "sequence"));
22daenzerorama sequence.addComponent(p4);
22daenzerorama sequence.addComponent(p3);
22daenzerorama sequence.addComponent(p2);
22daenzerorama sequence.addComponent(p1);
22daenzerorama
22daenzerorama Input in1 = kb.createInput(URIUtils.createURI(uri + "in1"));
22daenzerorama Input in2 = kb.createInput(URIUtils.createURI(uri + "in2"));
22daenzerorama Output out1 = kb.createOutput(URIUtils.createURI(uri + "out1"));
22daenzerorama
22daenzerorama CompositeProcess process = kb.createCompositeProcess(URIUtils.createURI(uri + "process"));
22daenzerorama process.setComposedOf(sequence);
22daenzerorama process.addInput(in1);
22daenzerorama process.addInput(in2);
22daenzerorama process.addOutput(out1);
22daenzerorama
22daenzerorama Service service = kb.createService(URIUtils.createURI(uri + "Service"));
22daenzerorama service.setProcess(process);
22daenzerorama
22daenzerorama service.deleteProcess();
22daenzerorama
22daenzerorama kb.write(System.out);
22daenzerorama }
22daenzerorama
22daenzerorama private void printSizeAndMembers(OWLSObjList list) {
22daenzerorama System.out.println("List size " + list.size());
22daenzerorama System.out.println("List members:");
22daenzerorama Iterator iter = list.iterator();
22daenzerorama while (iter.hasNext()) {
22daenzerorama System.out.println("\t" + iter.next().toString());
22daenzerorama }
22daenzerorama }
22daenzerorama
22daenzerorama private void removeList() {
22daenzerorama String uri = "http://example.com/p";
22daenzerorama
22daenzerorama p1 = kb.createPerform(URIUtils.createURI(uri + "1"));
22daenzerorama p2 = kb.createPerform(URIUtils.createURI(uri + "2"));
22daenzerorama p3 = kb.createPerform(URIUtils.createURI(uri + "3"));
22daenzerorama p4 = kb.createPerform(URIUtils.createURI(uri + "4"));
22daenzerorama
22daenzerorama Sequence sequence = kb.createSequence(URIUtils.createURI(uri + "sequence"));
22daenzerorama sequence.addComponent(p4);
22daenzerorama sequence.addComponent(p3);
22daenzerorama sequence.addComponent(p2);
22daenzerorama sequence.addComponent(p1);
22daenzerorama
22daenzerorama sequence.removeConstruct(p4);
22daenzerorama sequence.removeConstruct(p2);
22daenzerorama
22daenzerorama ControlConstructList list = sequence.getComponents();
22daenzerorama printSizeAndMembers(list);
22daenzerorama System.out.println("---------------------");
22daenzerorama kb.write(System.out);
22daenzerorama }
22daenzerorama}