after creating individual , not able to save the ontology

1 message Options
Embed this post
Permalink
mahaveer jain-2

after creating individual , not able to save the ontology

Reply Threaded More More options
Print post
Permalink
Hello,
   i am creating individuals using this code


                   import edu.stanford.smi.protegex.owl.model.*;
import edu.stanford.smi.protegex.owl.model.*;
import edu.stanford.smi.protegex.owl.*;
import java.util.*;
import java.io.*;

public class onto
{
    public static void main(String args[])
    {
     String uri = "file:///windows/E/ontologySamples/Ontology2/pol.owl";
     int found= 1;
     try
    {
      OWLModel owlModel = ProtegeOWL.createJenaOWLModelFromURI(uri);
      OWLNamedClass class1=null,class2=null;
      Collection classes = owlModel.getUserDefinedOWLNamedClasses();

        for (Iterator it = classes.iterator(); it.hasNext();)
        {
          OWLNamedClass cls = (OWLNamedClass) it.next();
           System.out.println(cls.getBrowserText()+"         "+args[0]);
          if(cls.getBrowserText().equals("pol:"+args[0]))
          {
             class1=cls;
               System.out.println("class one found");

          }
          if(cls.getBrowserText().equals("pol:"+args[1]))
          {
             class2=cls;
             System.out.println("class two found");
          }
        }


         System.out.println("properties are");
      Set set1=class1.getAssociatedProperties();
      for (Iterator it_property = set1.iterator(); it_property.hasNext();)
       {
           RDFProperty r=( RDFProperty)it_property.next(); String
name_property=r.getBrowserText();
           System.out.println("proprety:::"+name_property);
           Collection c=r.getRanges(false);
            for (Iterator it_range = c.iterator(); it_range.hasNext();)
            {
              RDFResource r_range=(RDFResource)it_range.next();
              String name_range=r_range.getBrowserText();
              System.out.println(" range for thsi properties is"+name_range);
              if(name_property.equals("pol:"+args[2]))
               {
                   System.out.println(" matched");
                    RDFIndividual individual1 =
class1.createRDFIndividual(args[3]);
                    RDFIndividual individual2 =
class2.createRDFIndividual(args[4]);
                    individual1.setPropertyValue(r,individual2);
                    found= 1;
                    owlModel.save(new File(uri).toURI());
                    if(found==1) break;
                }
              }
              if(found==1)
                 break;
         }
      }
      catch(Exception e){}
    }
  }










but i am not able to save the ontology with created individuals....plz
tell me method to do that...
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03