-
Notifications
You must be signed in to change notification settings - Fork 37
Align observationProperties to JSON-LD reference objects and fix custom namespace lookups #576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,10 +162,21 @@ public static Mcf.McfGraph mergeGraphs(List<Mcf.McfGraph> graphs) throws Asserti | |
| } | ||
|
|
||
| public static String stripNamespace(String val) { | ||
| if (val.startsWith(Vocabulary.DCID_PREFIX) | ||
| || val.startsWith(Vocabulary.SCHEMA_ORG_PREFIX) | ||
| || val.startsWith(Vocabulary.DC_SCHEMA_PREFIX)) { | ||
| return val.substring(val.indexOf(Vocabulary.REFERENCE_DELIMITER) + 1); | ||
| if (val == null) { | ||
| return null; | ||
| } | ||
| if (val.startsWith("http://") || val.startsWith("https://")) { | ||
| int lastSlash = val.lastIndexOf('/'); | ||
| int lastHash = val.lastIndexOf('#'); | ||
| int idx = Math.max(lastSlash, lastHash); | ||
| if (idx > 0 && idx < val.length() - 1) { | ||
| return val.substring(idx + 1); | ||
| } | ||
| return val; | ||
| } | ||
|
Comment on lines
+168
to
+176
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correctness Issue: Hierarchical ID Corruption with Custom NamespacesUsing For example, if a custom namespace is Recommended SolutionThe root cause is that Instead:
|
||
| int colonIdx = val.indexOf(Vocabulary.REFERENCE_DELIMITER); | ||
| if (colonIdx > 0) { | ||
| return val.substring(colonIdx + 1); | ||
| } | ||
| return val; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential
NoneValues inobservationPropertiesIf
props_dictcontains empty keys or keys that evaluate toNoneunder_uri_ref, the resultingprop_keyslist will containNoneelements, which produces invalid JSON-LD / RDF.Filtering out
Nonevalues using an assignment expression ensures that only valid reference objects are included indcid:observationProperties.