0

I try to add a statement to an existing *.ttl file I can add a required text but in some different structure:

                    InputStream in  = new FileInputStream("62692504.ttl");
                    Model model = Rio.parse(in, RDFFormat.TURTLE );
                    Resource publication = iri("https://../fcrepo/rest/ajax-mingoo/"+fileName);
                    IRI namePublication = iri("http://ndl.go.jp/dcndl/publicationPlace");
                    Literal publicationValue = literal(publication_place);
                    model.add(publication, namePublication,  publicationValue);
                    FileOutputStream out = new FileOutputStream("62692504_NEW.ttl");
                    Rio.write(model, out, RDFFormat.TURTLE);

In debug mode, the new line differs from the others, but I want to have the same type. The new line should be SimpleStatement and not from type ContextStatement.

How I can change the type from "default" to SimpleStatement?

enter image description here

andy_bu
  • 113
  • 2
  • 13
  • Why would this matter? – Jeen Broekstra Apr 13 '22 at 11:06
  • I save data in Fedora Repository it should look the same. If it saves as ContextStatement it looks like an extra resource. – andy_bu Apr 13 '22 at 14:04
  • A Fedora Repository? Do you have a link where I can read more? – Jeen Broekstra Apr 14 '22 at 09:30
  • Hier the link to Fedora repository: https://duraspace.org/fedora/. I use it to save metadata (JSON-LD) and binaries. A typical collection of books and pages and their metadata. Normally I use Solr and have the metadata already in JSON format, that's why it's easy to convert it into JSON-LD. It's not possible to rewrite the existing Fedora page using the JSON-LD file. Only delete and add again. I need to convert Fedora page into *.ttl file, after it I can easily rewrite it. Hier the link to Fedora community tech: https://groups.google.com/g/fedora-tech/c/d9Rq5cGaVvU/m/slqUX1MLAwAJ – andy_bu Apr 15 '22 at 14:21
  • Thanks @andy_bu. I'll try and find time to look at this, because it really should not matter what the exact type of `Statement` is. You said earlier it should "look the same". Can you clarify for me what exact difference you see, and where? – Jeen Broekstra Apr 20 '22 at 10:06
  • Hi, @JeenBroekstra yes. If I added it to Fedora as ContextStatement it creates and saves as an extra resource inside Fedora page (it looks like a drop-down window, that contains only this new object). My goal was to find a way how to save it as a SimpleStatement, where a new field doesn't compare to other existing fields. – andy_bu Apr 22 '22 at 21:01
  • I just had a quick look at that Fedora project and it doesn't seem to be using RDF4J internally anywhere. So I'm (again) a little lost on what exactly you're trying to do here, and why things are failing. In your code example you are creating a new Turtle file with an extra added statement. Whether that extra added statement is a ContextStatement or a SimpleStatement will make no difference to what the Turtle file looks like. – Jeen Broekstra Apr 23 '22 at 01:03
  • Hi @JeenBroekstra, it looks different in Fedora. Fedora has a graphic interface. If you need I can send you two Screenshots, just to display the difference between now and before. – andy_bu Apr 24 '22 at 18:06

1 Answers1

0

I already found:

ValueFactory factory = SimpleValueFactory.getInstance();
Statement nameStatement = factory.createStatement(publication, namePublication, publicationValue);
model.add(nameStatement);
andy_bu
  • 113
  • 2
  • 13