[GitHub] jena issue #139: JSON-LD output

2016-10-03 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
@ajs6f ah, OK, thank you. So I'll do it shortly


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-10-03 Thread ajs6f
Github user ajs6f commented on the issue:

https://github.com/apache/jena/pull/139
  
@fpservant, No, using that button, you can send a patch for the page now, 
but it will not be applied until the trigger is pulled to republish the docs 
pages. That will happen for the release.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-10-03 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
@afs thanks to you.

> What should I link to to say "it's new - read this"?

good question. I think that the best is to link to the sample code, where 
I've tried to explain what can be done, and how: 
``jena-arq/src-examples/arq/examples/riot/ExJsonLD.java``

I already had mentioned it, but note that I haven't done anything regarding 
the ["Writing RDF in Apache Jena" page]( 
https://jena.apache.org/documentation/io/rdf-output.html). The only way I saw 
is the " Improve this Page" link on the page, so this would mean that this can 
only be done after the release. Am I correct?



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-10-03 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/139
  
Merged! Thank you!

I'd like to announce it on dev@ (and maybe encourage some people on users@) 
to get feedback before we do the 3.1.1 release.

What should I link to to say "it's new - read this"?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-10-02 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/139
  
OK - I can work with that.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-10-02 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
@afs as I said in y previous mess, I don't seem to be able to get rid of 
the conflict (but I am not an expert with git and github) The only solution I 
see that would probably work would mean to move back ``JsonLDWriter`` from 
``org.apache.jena.riot.writer`` to ``org.apache.jena.riot``.

The merge should be simple enough: the conflicting file is to be removed 
(there is a new version of it in 
``jena-arq/src/main/java/org/apache/jena/riot/out/writer/JsonLDWriter.java``)





---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-10-02 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/139
  
> do you mean: "see if I can do something to get rid of the conflict" ?

Yes. If you can't cause git(hub) to not complain, just log here what to do 
for the person doing the git merge on this pull request.

(with `.diff` files and especially with `patch` files, I've found that 
multiple commits to the same file cause GH confusion. This could be the same 
issue.)



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-10-02 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
@afs, 

> If possible, please see if the PR can be alighed to the current Jena 
master branch for a clean merge 

do you mean: "see if I can do something to get rid of the conflict" ?

Regarding the conflict, I tried the following: I replaced my local rio/out 
with the one from upstream/master (-> the old JsonLDWriter is back in my 
riot/out), and I committed/pushed it. (that was my "trying to solve conflict 
with master regarding JsonLDWriter" commit)
-> no more conflict.
Then I tried to delete the JsonLDWriter ("trying to solve conflict with 
master regarding JsonLDWriter, step2" commit)
-> conflict again
-> I don't know what I can do


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-10-02 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/139
  
@acoburn - thanks - that sort of feedback is very useful.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-09-30 Thread acoburn
Github user acoburn commented on the issue:

https://github.com/apache/jena/pull/139
  
While this isn't exactly a review, I would add that what @fpservant has 
implemented here is _exactly_ what I need for some projects I work on -- 
projects that make heavy use of Jena, but when it comes to JSON-LD output, I 
mostly have to use the `jsonld-java` directly -- especially for handling 
flattened and expanded profiles.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-09-26 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
@stain yes, JSONLD-java can download a context from a URL, and cache it. 
The problem is, there is no way that I know of that would allow me to use that 
context in a write operation initiated from jena. I opened a JSONLD-java 
[issue](https://github.com/jsonld-java/jsonld-java/issues/184) about this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-09-26 Thread stain
Github user stain commented on the issue:

https://github.com/apache/jena/pull/139
  
If you get the HTTPClient working again, then you should be able to use 
JSONLD-Java's
[Caching 
mechanism](https://github.com/jsonld-java/jsonld-java#loading-contexts-from-classpathjar)
 to avoid external retrieval of http://schema.org/  

(but note that a download of the schema.org context is covered by 
http://creativecommons.org/licenses/by-sa/3.0/ )





---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-09-24 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
I updated this with some sample code, and it seems to me that this is as 
good as *I* can. The sample code is the best place to learn how it works and 
what it does. 

Andy, answering your remarks (Jul 10):

> Examples can go in jena-arq/src-examples/arq/examples/riot/.

done

> A new section about JSON-LD output for 
https://jena.apache.org/documentation/io/rdf-output.html

this still has to be done, but if I understand correctly, this is the 
documentation about the release, isn't it? (so should be updated later)

> Symbols are fine but URI's please!

done

> RDFDataMgr The way to set things specially for a writing is to do:...

ok. No new "write" methods with a Context argument (as there were in my 
frist attempt)

> If you want, add a new API class specific to JSON output ``JsonLdMgr ``

I created only a JSONLDWriteContext class (extending Context), with setters 
for the relevant Symbols

> Constants This could be tidied out with a subclass of ``RDFFormatVariant``

see ``public static class JSONLDVariant extends RDFFormatVariant`` inside 
RDFFormat.java, with methods such as ``isCompact()``, `isFratten()``etc.

> We need to be able to run the tests without assuing that external network 
resources

done

> Code organisation. If you feel there classes, fell free to create a 
package org.apache.jena.riot.out.jsonld 

very few classes, actually.

I moved ``jena/riot/out/JsonLDWriter.java`` (and ``JenaRDF2JSONLD``) to 
``jena/riot/writer`` to have it with other writers. Only one new 
file``jena/riot/JsonLDWriteContext``


> Indentation: spaces, not tabs please.

done

Tell me if you want me to change things

Best





---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-09-20 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
Andy,
I have reverted to an unmodified version of RDFDataMgr (without write 
methods with a context param). 

I am sorry that I take so long to finalize this stuff. Remember that one 
thing that we want to be able to do is to pass a (JSONLD) context (as a jena 
context) to the Writer, in order to have it used when computing the output. But 
there is a problem with JSONLD java (see [issue 
184](https://github.com/jsonld-java/jsonld-java/issues/184)): it doesn't seem 
possible (or at least, easy) to let the user set the (JSONLD) context to 
something like ``"@context": "http://schema.org/"``. The best that I can do is 
to pass the content corresponding to the URL (downloaded and converted to a 
map) to the JSONLD API, and then to substitute the @context value with 
"http://schema.org/; at the end of the process (just before writing the output).

(I hadn't seen this problem when I created the pull request, because at 
this time, there was no way to have JSON-LD java download externally defined 
contexts, because of incompatible versions of HttpClient used by jena and 
json-ld java).

Regarding the way to expose the Symbols that can be set it the (jena) 
context, and the classes expected for the corresponding values, are you OK with 
a JSONLDWriteContext class (extending Context), with methods such as:
```
public void setOptions(JsonLdOptions opts) { 
set(JSONLD_OPTIONS_SYMBOL, opts);
}
```

I try to finalize something quickly and I update this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-09-16 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/139
  
So how many additional 'write+Context' operations? Just the RDFFormat ones 
for now?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-08-30 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/139
  
I'm not opposed to adding "Context" variants on principle, just a concern 
about warping the API in the application writers view by many operations (not 
that there are a few at the moment!). There are 22 write(...) operations 
currently. Or maybe only for the 11 `RDFFormat` forms (the Lang/RDFFormat being 
one of the causes of so many options)

Adding the PrefixMap variants (4 new operations : 2 each for graph and 
datasetgraph writers).

This should work and it's a bit shorter: the machinery for 
DatasetGarph/Graph is built-in:

```
private void writeExample(OutputStream out, Model m, RDFFormat f, Context 
jenaContext) {
WriterGraphRIOT w = RDFDataMgr.createGraphWriter(f) ;
Graph g = m.getGraph() ;
w.write(out, g, RiotLib.prefixMap(g), null, jenaContext);
}
```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-08-25 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
Hi Andy,
getting back to this after, well, a long summer.
I have a remark regarding your following comment:
> RDFDataMgr
>
> The way to set things specially for a writing is to do:
>
>WriterDatasetRIOT w = 
RDFDataMgr.createDatasetWriter(RDFFormat.JSONLD_COMPACT_FLAT) ;
>w.write(System.out,  dataset.asDatasetGraph(), null, "http://base;, 
RIOT.getContext()) ;
> 
> rather than add RDFDataMgr.write(..., Context cxt)

I understand the point of not adding new methods to RDFDataMgr.
However:
- there are read methods with a Context param (so, we would get some 
symetry between read and write methods)
- and I have the feeling that writing down a Model gets more convoluted for 
the user without the write methods with the Context param.

If we have a write with the Context param, one just has to:
```
private void writeExample(OutputStream out, Model m, RDFFormat f, Context 
jenaContext) {
  try {
RDFDataMgr.write(out, m, f, jenaContext) ;
...
 ```

Without it:
```
private void writeExample(OutputStream out, Model m, RDFFormat f, Context 
jenaContext) {
  try {
WriterDatasetRIOT w = RDFDataMgr.createDatasetWriter(f) ;
DatasetGraph g = DatasetFactory.create(m).asDatasetGraph();
PrefixMap pm = RiotLib.prefixMap(g);
String base = null;
w.write(out,  g, pm, base, jenaContext) ;
...
 ```

I've had to search a little bit to write it. I guess that other users also 
would. Would it justify the extra RDFDataMgr.write(..., Context cxt)? That's 
the question I am asking.

Best,

fps


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-07-10 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
Andy
> Apologies that this has taken so long.
no problem, really. Thanks for this answer. Give me some time to take all 
your valuable comments into account.

just one remark:
> I ran the tests for JSONLD but got:
>> 10:13:04 INFO  TestJsonLDWriter  :: Sorry to get this exception
>>org.apache.jena.riot.RiotException: 
com.github.jsonldjava.core.JsonLdError: loading remote context failed: 
http://schema.org/
...
> The tests and build should work if there is no extenral connectivity.

I understand the point, and I'll take it into account. But actually, I'm 
happy to see this, because it shows that one problem that I had at the time has 
been solved. As was noted in a comment in the code:
```
} catch (Throwable e) {
Logger.getLogger(getClass()).info("Sorry to get this 
exception",e);
}

// It seems to work, but there's a problem with httpclient version: the 
one used by jena
// is not compatible with the one expected by JSONLD-java API. We get
/*
java.lang.NoSuchMethodError: 
org.apache.http.impl.client.cache.CacheConfig.custom()Lorg/apache/http/impl/client/cache/CacheConfig$Builder;
```
Looks like the work on " (JENA-576) Upgrade Apache HTTP Client to 4.3" has 
solved the issue



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-07-10 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/139
  
JIRA created to track this: https://issues.apache.org/jira/browse/JENA-1208



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-07-10 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/139
  
Apologies that this has taken so long.

> TODO some documentation. Where should it be added? The best form would be 
small sample code. 

Examples can go in `jena-arq/src-examples/arq/examples/riot/`. A new 
section about JSON-LD output for 
https://jena.apache.org/documentation/io/rdf-output.html, and use code links to 
apache/jena github, master branch. 

Symbols are fine but URI's please! (changing `RIOT.riotIRI` to 
"http://jena.apache.org/riot;):

e.g.  in JsonLDWriter
```
public static final Symbol JSONLD_CONTEXT = 
Symbol.create("JSONLD_CONTEXT");
```

**RDFDataMgr**

The way to set things specially for a writing is to do:

```
WriterDatasetRIOT w = 
RDFDataMgr.createDatasetWriter(RDFFormat.JSONLD_COMPACT_FLAT) ;
w.write(System.out,  dataset.asDatasetGraph(), null, "http://base;, 
RIOT.getContext()) ;
```
rather than add `RDFDataMgr.write(..., Context cxt)`

See 
[examples/riot/ExRIOT_2](https://github.com/apache/jena/blob/master/jena-arq/src-examples/arq/examples/riot/ExRIOT_2.java)
 for an example for a reader.

If you want, add a new API class specific to JSON output `JsonLdMgr` (to go 
in the same package as `RDFDataMgr`) with JSON-LD-specific functions to wrap 
common ways to call JSON-LD output. 

**Constants**

This could be tidied out with a subclass of `RDFFormatVariant` that carries 
JSON-LD information:

```
// From JSON writer
public static enum JSONLD_FORMAT {
COMPACT, FLATTEN, EXPAND, FRAME
}

static class JSONLDFormatVariant extends RDFFormatVariant {
private JSONLD_FORMAT option ;
private boolean prettyJson ;

public JSONLDFormatVariant(String name, boolean prettyJson, 
JSONLD_FORMAT option) { 
super(name) ;
this.options = option ;
this.prettyJson = prettyJson ;
}

public boolean prettyJson() { return prettyJson ; }

public boolean option(JSONLD_FORMAT fmt) {
for ( JSONLD_FORMAT f : options ) {
if ( fmt == f )
return true ; 
}
return false ;
}
}


private static final RDFFormatVariant JSONLD_EXPAND_PRETTY  = new 
JSONLDFormatVariant("expand pretty", true, JSONLD_FORMAT.EXPAND) ;
private static final RDFFormatVariant JSONLD_EXPAND_FLAT= new 
JSONLDFormatVariant("expand flat", false, JSONLD_FORMAT.COMPACT) ;
...
```
then use in JsonLDWriter by casting to and JSONLDFormatVariant
```
JSONLDFormatVariant format = (JSONLDFormatVariant)format ;
```
```
if ( format.option(COMPACT) ) {
  ...
}
```

**Tests**

I ran the tests for JSONLD but got:

```
10:13:04 WARN  JsonLDWriter  :: JSONLD_CONTEXT value is not a 
String. Assuming a context object expected by JSON-LD JsonLdProcessor.compact 
or flatten
10:13:04 INFO  TestJsonLDWriter  :: Sorry to get this exception
org.apache.jena.riot.RiotException: com.github.jsonldjava.core.JsonLdError: 
loading remote context failed: http://schema.org/
at 
org.apache.jena.riot.out.JsonLDWriter.serialize(JsonLDWriter.java:218)
at org.apache.jena.riot.out.JsonLDWriter.write(JsonLDWriter.java:123)
at org.apache.jena.riot.out.JsonLDWriter.write(JsonLDWriter.java:129)
at 
org.apache.jena.riot.system.RiotLib$WriterAdapter.write(RiotLib.java:376)
at org.apache.jena.riot.RDFDataMgr.write$(RDFDataMgr.java:1232)
...
```

We need to be able to run the tests without assuing that external network 
resources are availanle and functioning.

The tests and build should work if there is no extenral connectivity.

**Code organisation**

If you feel there classes, fell free to create a package 
org.apache.jena.riot.out.jsonld to put them together.

**Other**

Indentation: spaces, not tabs please.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---