[jira] [Comment Edited] (JENA-1006) How read and add triples to `Graph` at the same time?

2015-08-05 Thread Eugene Tenkaev (JIRA)

[ 
https://issues.apache.org/jira/browse/JENA-1006?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14658912#comment-14658912
 ] 

Eugene Tenkaev edited comment on JENA-1006 at 8/5/15 9:04 PM:
--

Yes I read that, but how I can get from {{DatasetGraph}} or {{Graph}} the 
{{Dataset}}?
Is this
{code:java}
Dataset dataset = TDBFactory.createDataset();
DatasetGraph datasetGraph = dataset.asDatasetGraph();
Graph graph = datasetGraph.getDefaultGraph();
{code}
a good solution? Is {{dataset.asDatasetGraph()}} has a bad side?


was (Author: hronom):
Yes I read that, but how I can get from {{DatasetGraph}} or {{Graph}} the 
{{Dataset}}?
Is this
{{code:java}}
Dataset dataset = TDBFactory.createDataset();
DatasetGraph datasetGraph = dataset.asDatasetGraph();
Graph graph = datasetGraph.getDefaultGraph();
{{code}}
a good solution? Is {{dataset.asDatasetGraph()}} has a bad side?

> How read and add triples to `Graph` at the same time?
> -
>
> Key: JENA-1006
> URL: https://issues.apache.org/jira/browse/JENA-1006
> Project: Apache Jena
>  Issue Type: Question
>  Components: Core, TDB
>Affects Versions: Jena 2.13.0
>Reporter: Eugene Tenkaev
>Priority: Minor
> Fix For: Jena 3.0.1
>
>
> Here is my code:
> {code:java}
> public class App {
> public static void main(String[] args) {
> DatasetGraph datasetGraph = TDBFactory.createDatasetGraph();
> Graph graph = datasetGraph.getDefaultGraph();
> // Fill graph.
> graph.add(
> new Triple(
> NodeFactory.createURI("www.test.org/unit13"),
> NodeFactory.createURI("name"),
> NodeFactory.createLiteral("Unit 13", "en")
> )
> );
> graph.add(
> new Triple(
> NodeFactory.createURI("www.test.org/unit13"),
> NodeFactory.createURI("type"),
> NodeFactory.createURI("robot")
> )
> );
> graph.add(
> new Triple(
> NodeFactory.createURI("www.test.org/unit13"),
> NodeFactory.createURI("creationYear"),
> NodeFactory.createURI("2015")
> )
> );
> // Test
> ExtendedIterator iter = graph.find(
> Node.ANY,
> NodeFactory.createURI("creationYear"),
> NodeFactory.createURI("2015")
> );
> while (iter.hasNext()) {
> Triple triple = iter.next();
> Node subject = triple.getSubject();
> // Exception here.
> graph.add(
> new Triple(
> subject, NodeFactory.createURI("status"), 
> NodeFactory.createURI("available")
> )
> );
> }
> }
> }
> {code}
> This code gives me exception:
> {noformat}
> Exception in thread "main" java.util.ConcurrentModificationException: 
> Iterator: started at 8, now 9
> at 
> com.hp.hpl.jena.tdb.sys.DatasetControlMRSW.policyError(DatasetControlMRSW.java:157)
> at 
> com.hp.hpl.jena.tdb.sys.DatasetControlMRSW.access$000(DatasetControlMRSW.java:32)
> at 
> com.hp.hpl.jena.tdb.sys.DatasetControlMRSW$IteratorCheckNotConcurrent.checkCourrentModification(DatasetControlMRSW.java:110)
> at 
> com.hp.hpl.jena.tdb.sys.DatasetControlMRSW$IteratorCheckNotConcurrent.hasNext(DatasetControlMRSW.java:118)
> at org.apache.jena.atlas.iterator.Iter$4.hasNext(Iter.java:318)
> at org.apache.jena.atlas.iterator.Iter$4.hasNext(Iter.java:318)
> at org.apache.jena.atlas.iterator.Iter$4.hasNext(Iter.java:318)
> at org.apache.jena.atlas.iterator.Iter.hasNext(Iter.java:942)
> at 
> com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
> at com.github.hronom.test.jena.App.main(App.java:48)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
> {noformat}
> I accept this.
> But how I must change code, to add meta info {{ }} to 
> every {{}} that has {{ <2015>}}?
> Test project on [GitHub|https://github.com/Hronom/test-jena]
> Please help me:P



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Comment Edited] (JENA-1006) How read and add triples to `Graph` at the same time?

2015-08-05 Thread Eugene Tenkaev (JIRA)

[ 
https://issues.apache.org/jira/browse/JENA-1006?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14658912#comment-14658912
 ] 

Eugene Tenkaev edited comment on JENA-1006 at 8/5/15 9:15 PM:
--

Yes I read that, but how I can get from {{DatasetGraph}} or {{Graph}} the 
{{Dataset}}?
Is this
{code:java}
Dataset dataset = TDBFactory.createDataset();
DatasetGraph datasetGraph = dataset.asDatasetGraph();
Graph graph = datasetGraph.getDefaultGraph();
{code}
a good solution? Is {{dataset.asDatasetGraph()}} has a bad side?

Or maybe this:
{code:java}
DatasetGraph datasetGraph = TDBFactory.createDatasetGraph();
Graph graph = datasetGraph.getDefaultGraph();
Dataset dataset = DatasetImpl.wrap(datasetGraph);
{code}
{{DatasetImpl.wrap}} good solution?


was (Author: hronom):
Yes I read that, but how I can get from {{DatasetGraph}} or {{Graph}} the 
{{Dataset}}?
Is this
{code:java}
Dataset dataset = TDBFactory.createDataset();
DatasetGraph datasetGraph = dataset.asDatasetGraph();
Graph graph = datasetGraph.getDefaultGraph();
{code}
a good solution? Is {{dataset.asDatasetGraph()}} has a bad side?

> How read and add triples to `Graph` at the same time?
> -
>
> Key: JENA-1006
> URL: https://issues.apache.org/jira/browse/JENA-1006
> Project: Apache Jena
>  Issue Type: Question
>  Components: Core, TDB
>Affects Versions: Jena 2.13.0
>Reporter: Eugene Tenkaev
>Priority: Minor
> Fix For: Jena 3.0.1
>
>
> Here is my code:
> {code:java}
> public class App {
> public static void main(String[] args) {
> DatasetGraph datasetGraph = TDBFactory.createDatasetGraph();
> Graph graph = datasetGraph.getDefaultGraph();
> // Fill graph.
> graph.add(
> new Triple(
> NodeFactory.createURI("www.test.org/unit13"),
> NodeFactory.createURI("name"),
> NodeFactory.createLiteral("Unit 13", "en")
> )
> );
> graph.add(
> new Triple(
> NodeFactory.createURI("www.test.org/unit13"),
> NodeFactory.createURI("type"),
> NodeFactory.createURI("robot")
> )
> );
> graph.add(
> new Triple(
> NodeFactory.createURI("www.test.org/unit13"),
> NodeFactory.createURI("creationYear"),
> NodeFactory.createURI("2015")
> )
> );
> // Test
> ExtendedIterator iter = graph.find(
> Node.ANY,
> NodeFactory.createURI("creationYear"),
> NodeFactory.createURI("2015")
> );
> while (iter.hasNext()) {
> Triple triple = iter.next();
> Node subject = triple.getSubject();
> // Exception here.
> graph.add(
> new Triple(
> subject, NodeFactory.createURI("status"), 
> NodeFactory.createURI("available")
> )
> );
> }
> }
> }
> {code}
> This code gives me exception:
> {noformat}
> Exception in thread "main" java.util.ConcurrentModificationException: 
> Iterator: started at 8, now 9
> at 
> com.hp.hpl.jena.tdb.sys.DatasetControlMRSW.policyError(DatasetControlMRSW.java:157)
> at 
> com.hp.hpl.jena.tdb.sys.DatasetControlMRSW.access$000(DatasetControlMRSW.java:32)
> at 
> com.hp.hpl.jena.tdb.sys.DatasetControlMRSW$IteratorCheckNotConcurrent.checkCourrentModification(DatasetControlMRSW.java:110)
> at 
> com.hp.hpl.jena.tdb.sys.DatasetControlMRSW$IteratorCheckNotConcurrent.hasNext(DatasetControlMRSW.java:118)
> at org.apache.jena.atlas.iterator.Iter$4.hasNext(Iter.java:318)
> at org.apache.jena.atlas.iterator.Iter$4.hasNext(Iter.java:318)
> at org.apache.jena.atlas.iterator.Iter$4.hasNext(Iter.java:318)
> at org.apache.jena.atlas.iterator.Iter.hasNext(Iter.java:942)
> at 
> com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
> at com.github.hronom.test.jena.App.main(App.java:48)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
> {noformat}
> I accept this.
> But how I must change code, to add meta info {{ }} to 
> every {{}} that has {{ <2015>}}?
> Test project on [GitHub|https://github.com/Hronom/test-jena]
> Please help me:P



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)