Title: Infinite loop while framing data · Issue #338 · jsonld-java/jsonld-java · GitHub
Open Graph Title: Infinite loop while framing data · Issue #338 · jsonld-java/jsonld-java
X Title: Infinite loop while framing data · Issue #338 · jsonld-java/jsonld-java
Description: With the following test case and the serialized data model-ser.zip (you need to unzip and change the path to the file). When running test case we run into an infinite loop. I think something needs to be done to handle this problem becaus...
Open Graph Description: With the following test case and the serialized data model-ser.zip (you need to unzip and change the path to the file). When running test case we run into an infinite loop. I think something needs ...
X Description: With the following test case and the serialized data model-ser.zip (you need to unzip and change the path to the file). When running test case we run into an infinite loop. I think something needs ...
Opengraph URL: https://github.com/jsonld-java/jsonld-java/issues/338
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Infinite loop while framing data","articleBody":"With the following test case and the serialized data [model-ser.zip](https://github.com/jsonld-java/jsonld-java/files/11397861/model-ser.zip) (you need to unzip and change the path to the file). When running test case we run into an infinite loop. I think something needs to be done to handle this problem because you never know what data is going to be loaded.\r\n\r\n```\r\n @Test\r\n public void testJsonLdCycle() throws Exception {\r\n final JsonLdOptions opts = new JsonLdOptions();\r\n\r\n //opts.setUseRdfType(getWriterConfig().get(JSONLDSettings.USE_RDF_TYPE));\r\n opts.setUseNativeTypes(true);\r\n opts.setCompactArrays(true);\r\n //opts.setOmitGraph(getWriterConfig().get(OMIT_GRAPH));\r\n opts.setEmbed(Embed.ALWAYS);\r\n\r\n String testFrame = \"{\\\"@context\\\" : [ \\\"http://cambridgesemantics.com/ontologies/GraphmartStatus/LayerStatus\\\", \\\"http://cambridgesemantics.com/ontologies/GraphmartStatus/LayerChildStatus\\\", \\\"http://www.w3.org/2002/07/owl/Thing\\\", \\\"http://cambridgesemantics.com/ontologies/GraphmartStatus/GraphmartStatus\\\" ], \\\"@type\\\" : [ \\\"http://cambridgesemantics.com/ontologies/GraphmartStatus#GraphmartStatus\\\" ]}\";\r\n\r\n final SesameRDFParser serialiser = new SesameRDFParser();\r\n\r\n try (ObjectInputStream in = new ObjectInputStream(new UserDirFileInputStream(\"/test/resources/coredata/model.ser\"))) {\r\n Model model = (LinkedHashModel) in.readObject();\r\n\r\n Object output = JsonLdProcessor.fromRDF(model, opts, serialiser);\r\n JsonLdProcessor.frame(output, JsonUtils.fromString(testFrame), opts);\r\n }\r\n\r\n }\r\n\r\n public class SesameRDFParser implements com.github.jsonldjava.core.RDFParser {\r\n\r\n public void setPrefix(RDFDataset result, String fullUri, String prefix) {\r\n result.setNamespace(fullUri, prefix);\r\n }\r\n\r\n public void handleStatement(RDFDataset result, org.openrdf.model.Statement nextStatement) {\r\n // TODO: from a basic look at the code it seems some of these could be\r\n // null\r\n // null values for IRIs will probably break things further down the line\r\n // and i'm not sure yet if this should be something handled later on, or\r\n // something that should be checked here\r\n final String subject = getResourceValue(nextStatement.getSubject());\r\n final String predicate = getResourceValue(nextStatement.getPredicate());\r\n final Value object = nextStatement.getObject();\r\n final String graphName = getResourceValue(nextStatement.getContext());\r\n\r\n if (object instanceof Literal) {\r\n final Literal literal = (Literal) object;\r\n final String value = literal.getLabel();\r\n final String language = literal.getLanguage();\r\n\r\n String datatype = getResourceValue(literal.getDatatype());\r\n\r\n // In RDF-1.1, Language Literals internally have the datatype\r\n // rdf:langString\r\n if (language != null \u0026\u0026 datatype == null) {\r\n datatype = org.openrdf.model.vocabulary.RDF.LANGSTRING.stringValue();\r\n }\r\n\r\n // In RDF-1.1, RDF-1.0 Plain Literals are now Typed Literals with\r\n // type xsd:String\r\n if (language == null \u0026\u0026 datatype == null) {\r\n datatype = XMLSchema.STRING.stringValue();\r\n }\r\n\r\n result.addQuad(subject, predicate, value, datatype, language, graphName);\r\n\r\n } else {\r\n result.addQuad(subject, predicate, getResourceValue((Resource) object), graphName);\r\n }\r\n }\r\n\r\n private String getResourceValue(Resource subject) {\r\n if (subject == null) {\r\n return null;\r\n } else if (subject instanceof URI) {\r\n return subject.stringValue();\r\n } else if (subject instanceof BNode) {\r\n return \"_:\" + subject.stringValue();\r\n }\r\n\r\n throw new IllegalStateException(\"Did not recognise resource type: \" + subject.getClass().getName());\r\n }\r\n\r\n @Override\r\n public RDFDataset parse(Object input) throws JsonLdError {\r\n final RDFDataset result = new RDFDataset();\r\n if (input instanceof Statement) {\r\n handleStatement(result, (Statement) input);\r\n } else if (input instanceof Graph) {\r\n if (input instanceof Model) {\r\n final Set\u003cNamespace\u003e namespaces = ((Model) input).getNamespaces();\r\n for (final Namespace nextNs : namespaces) {\r\n result.setNamespace(nextNs.getName(), nextNs.getPrefix());\r\n }\r\n }\r\n\r\n for (final org.openrdf.model.Statement nextStatement : (Graph) input) {\r\n handleStatement(result, nextStatement);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n }\r\n```","author":{"url":"https://github.com/garpinc","@type":"Person","name":"garpinc"},"datePublished":"2023-05-04T13:19:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/338/jsonld-java/issues/338"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:830fd181-3ab3-70ae-36a2-e8930d8eb458 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CEDE:1FD077:38272A7:4BF11E1:6971F53D |
| html-safe-nonce | 087d3ab908388b112c384f84091d3f918018f6a37a06ea799e7c8f88d51b792a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRURFOjFGRDA3NzozODI3MkE3OjRCRjExRTE6Njk3MUY1M0QiLCJ2aXNpdG9yX2lkIjoiNDI5ODAwMTU2NzYwOTY0ODQ0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3c37ffd546ce63cabc2d947e827c9e8ef4283d588b50bd5620b39e4d5ba2846e |
| hovercard-subject-tag | issue:1696000055 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/jsonld-java/jsonld-java/338/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8068b9545aed603bacaea97216266ad19d7a91ddd767b7202a65df1fd602ae44/jsonld-java/jsonld-java/issues/338 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8068b9545aed603bacaea97216266ad19d7a91ddd767b7202a65df1fd602ae44/jsonld-java/jsonld-java/issues/338 |
| og:image:alt | With the following test case and the serialized data model-ser.zip (you need to unzip and change the path to the file). When running test case we run into an infinite loop. I think something needs ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | garpinc |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d9da1aa47d387dfb2aca0f2e5c19150dc936b8128a6b2ecd6a02fc26a378fff |
| turbo-cache-control | no-preview |
| go-import | github.com/jsonld-java/jsonld-java git https://github.com/jsonld-java/jsonld-java.git |
| octolytics-dimension-user_id | 4359856 |
| octolytics-dimension-user_login | jsonld-java |
| octolytics-dimension-repository_id | 2988730 |
| octolytics-dimension-repository_nwo | jsonld-java/jsonld-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 2988730 |
| octolytics-dimension-repository_network_root_nwo | jsonld-java/jsonld-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4332d3e3368b9bce3dfd3c4a2643112933072734 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width