Hello Lorenz, I tried to load the model from one owl file and then stored it to another file (though both files have same data, but different names). When I try to load model from owl file and store also into same file, it then works fine and data is not overwritten.
On Fri, Dec 2, 2016 at 2:00 PM, Lorenz B. < buehm...@informatik.uni-leipzig.de> wrote: > > > If you really want to write each user to a separate file > > > > I dont want each user to a separate file, rather I want to save all the > > individuals/students in one file. Some times ago, it worked for me but I > > have made some changes to my code and now when I enter an individual, it > > replaces the existing one and hence saves only one at a time. > > > > I have checked the model before saving it to a file, and the model > contains > > only one individual (replaces existing one), so I think the problem is > not > > in the file saving itself. > As I said, you have to load the existing model from the existing file. > Then work on this model. Then save this model to disk to the same file. > > > > > > > > On Fri, Dec 2, 2016 at 12:23 PM, Claude Warren <cla...@xenei.com> wrote: > > > >> It sounds to me like Kumar is thinking that he needs to store each > student > >> in an individual file and load that. Kumar, if that is the case then I > >> think you misunderstand how the graph storage works. Or you have an > >> unusual use case. In most cases you would simply write the entire > graph to > >> disk (Ususally using TDB as the storage engine as it will handle all the > >> persistence for you). If you really want to write each user to a > separate > >> file then I would suggest creating a model using the Construct select to > >> pull all the data about the user and then write that graph to disk using > >> the standard graph.write() functionality. > >> > >> Claude > >> > >> On Fri, Dec 2, 2016 at 8:18 AM, Lorenz B. < > >> buehm...@informatik.uni-leipzig.de> wrote: > >> > >>> > >>>> Hi > >>>> I want to create student instances of my Student class and enter his > >>>> details. Then at the end I writes model to the file. > >>>> > >>>> OntClass std = model.getOntClass(ns + "Student"); > >>>> Individual mystd = std.createIndividual(ns + stdname); > >>>> > >>>> In the file when I enter name of a student, i-e Bob, it saves to the > >> file > >>>> along other information like department, address etc. > >>>> Next time, when I enter another student name, i-e Alice, it replaces > >>>> previous instances of students and currently only one student is saved > >> to > >>>> file. > >>>> > >>>> I want record of all students so need all student instances. I used > for > >>>> file writing. > >>> I don't understand the problem. You have to load the existing model and > >>> add new individuals to it. If you don't open the existing model, indeed > >>> only what's added to your new model will be saved to the file. > >>>> try (FileOutputStream write = new FileOutputStream("D:// > >> students.owl")) > >>> { > >>>> model.write(write, "RDF/XML"); > >>>> > >>> -- > >>> Lorenz Bühmann > >>> AKSW group, University of Leipzig > >>> Group: http://aksw.org - semantic web research center > >>> > >>> > >> > >> -- > >> I like: Like Like - The likeliest place on the web > >> <http://like-like.xenei.com> > >> LinkedIn: http://www.linkedin.com/in/claudewarren > >> > -- > Lorenz Bühmann > AKSW group, University of Leipzig > Group: http://aksw.org - semantic web research center > >