Skip to content

Commit e56db1b

Browse files
committed
Release 2.3.4
* Update release tags * Add Alternate Template Import / Export * showOpenFilePicker() is not avaiable is some browsers * Fix Namespaces issues for new Namespace format * Get namespace defaults before project namespaces * Update RDFTransformNamespacesManager getNamespaceOfPrefix() * Process old namespaces into new namespaces * Change depricated jQuery focus() to trigger("focus") * Change depricated jQuery select() to trigger("select") * Change div scrollWidth get * Update latest release note
1 parent b338c0d commit e56db1b

19 files changed

+241
-153
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
# Change Log
22
[//]: # (RDF Transform Version Control)
33

4+
## 2.3.4 Released
5+
This version is updates RDF Template import and export processing. The prior extension used
6+
showOpenFilePicker() exclusively which is not used by some browsers due to topical developer
7+
differences on undefined, esoteric, local file access security issues. This release provides for
8+
alternative, classical file processing.
9+
This release also finished conversion to the new Prefixed Namespace format for processing ontologies
10+
from URL, file, and "none" sources--the old system had no stored designation from which it loaded
11+
an ontology so would erroniously default to URL on reload even when "none" where avaiable. This
12+
resulted is slow startups. A file Prefixed Namespace loads its ontology from locally store files.
13+
A "none" Prefixed Namespace does not attempt to load an ontology. The namespace processing attempts
14+
a "best effort" to convert an old namespace format to the new format.
15+
This release also updates some deprecated jQuery calls.
16+
417
## 2.3.3 Released
518
This version is updates RDF output format processing. The preview and export processes were
619
changed from using a Model to a DatasetGraph to manage statement. This allows for Named Graph

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
<groupId>org.openrefine</groupId>
3737
<artifactId>rdf-transform</artifactId>
38-
<version>2.3.3</version><!-- RDF Transform Version Control -->
38+
<version>2.3.4</version><!-- RDF Transform Version Control -->
3939
<!--packaging>jar</packaging--><!--We don't need no stink'n JAR file-->
4040

4141
<properties>

reserve/src/main/resources/module/scripts/rdf-transform-resource.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ class Reserve_RDFTransformResourceResolveDialog {
195195
var elements = DOM.bind(menu);
196196
elements.rdftNewResourceIRI
197197
.val(defaultVal)
198-
.focus()
199-
.select();
198+
.trigger("focus")
199+
.trigger("select");
200200

201201
elements.buttonCancel
202202
.on("click", () => { MenuSystem.dismissAll(); } );

src/main/java/org/openrefine/rdf/RDFTransform.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static public final class Reconstructor {
7878
// RDF Transform Version Control
7979
static public final String VERSION_MAJOR = "2";
8080
static public final String VERSION_MINOR = "3";
81-
static public final String VERSION_MICRO = "3";
81+
static public final String VERSION_MICRO = "4";
8282
static public final String VERSION =
8383
RDFTransform.VERSION_MAJOR + "." +
8484
RDFTransform.VERSION_MINOR + "." +
@@ -139,36 +139,38 @@ static public RDFTransform load(Project theProject, JsonNode jnodeTransform) {
139139
return RDFTransform.reconstruct(theProject, jnodeTransform);
140140
}
141141

142-
static public Vocabulary getVocabFromPrefixNode(Entry<String, JsonNode> prefix) {
143-
String strPrefix = prefix.getKey();
142+
static public Vocabulary getVocabFromPrefixNode(Entry<String, JsonNode> entryPrefix) {
143+
String strPrefix = entryPrefix.getKey();
144144
String[] astrValues = { null, null, null }; // 0 = Namespace, 1 = Location, 2 = Location Type
145145
Vocabulary.LocationType theLocType = Vocabulary.LocationType.NONE;
146146
Vocabulary vocab = null;
147-
boolean bOld = false;
147+
JsonNode nodePrefix = entryPrefix.getValue();
148148

149-
// If the prefix does not have field, then it only has a namespace value (DEPRECATED Old Format)...
150-
if ( prefix.getValue().properties().isEmpty() ) {
149+
// If the prefix value is a simple JSON Node, it only has a namespace value (DEPRECATED Old Format)...
150+
if ( nodePrefix.isValueNode() ) {
151151
// Upgrade to New Format...
152-
bOld = true;
153-
astrValues[0] = prefix.getValue().asText();
152+
astrValues[0] = nodePrefix.asText();
153+
vocab = new Vocabulary( strPrefix, astrValues[0] );
154154
}
155+
// Otherwise, process the prefix...
155156
else {
156-
prefix.getValue().properties().forEach(value -> {
157-
String strKey = value.getKey();
158-
String strVal = value.getValue().asText();
159-
if ( strKey.equals("namespace") ) astrValues[0] = strVal;
160-
else if ( strKey.equals("location") ) astrValues[1] = strVal;
161-
else if ( strKey.equals("loctype") ) astrValues[2] = strVal;
162-
});
157+
nodePrefix.properties().forEach(
158+
entryPrefixVal -> {
159+
String strKey = entryPrefixVal.getKey();
160+
String strVal = entryPrefixVal.getValue().asText();
161+
if ( strKey.equals("namespace") ) astrValues[0] = strVal;
162+
else if ( strKey.equals("location") ) astrValues[1] = strVal;
163+
else if ( strKey.equals("loctype") ) astrValues[2] = strVal;
164+
}
165+
);
163166
if ( astrValues[2] != null && ! astrValues[2].isEmpty() ) theLocType = Vocabulary.fromLocTypeString( astrValues[2] ) ;
167+
168+
if (astrValues[1] == null)
169+
vocab = new Vocabulary( strPrefix, astrValues[0], "", theLocType );
170+
else
171+
vocab = new Vocabulary( strPrefix, astrValues[0], astrValues[1], theLocType );
164172
}
165173

166-
if (bOld)
167-
vocab = new Vocabulary( strPrefix, astrValues[0] );
168-
else if (astrValues[1] == null)
169-
vocab = new Vocabulary( strPrefix, astrValues[0], "", theLocType );
170-
else
171-
vocab = new Vocabulary( strPrefix, astrValues[0], astrValues[1], theLocType );
172174
return vocab;
173175
}
174176

@@ -645,10 +647,12 @@ public void setNamespaces(JsonNode jnodeNamespaces) {
645647

646648
if ( jnodeNamespaces.isObject() ) {
647649
if ( Util.isDebugMode() ) RDFTransform.logger.info("DEBUG: setNamespaces(): Namespaces set by JSON Object...");
648-
jnodeNamespaces.properties().forEach(prefix -> {
649-
Vocabulary vocab = RDFTransform.getVocabFromPrefixNode(prefix);
650-
this.theNamespaces.add(vocab);
651-
});
650+
jnodeNamespaces.properties().forEach(
651+
entryPrefix -> {
652+
Vocabulary vocab = RDFTransform.getVocabFromPrefixNode(entryPrefix);
653+
if (vocab != null) this.theNamespaces.add(vocab);
654+
}
655+
);
652656
}
653657
if ( this.theNamespaces.isEmpty() ) {
654658
if ( Util.isDebugMode() ) RDFTransform.logger.info("DEBUG: setNamespaces(): Namespaces set by Predefined defaults...");

src/main/java/org/openrefine/rdf/command/NamespacesGetDefaultCommand.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ private void getDefaultNamespaces(HttpServletRequest request, HttpServletRespons
7373
if ( Util.isDebugMode() ) NamespacesGetDefaultCommand.logger.info("DEBUG: Existing namespaces: size=" + listVocabs.size());
7474
if ( listVocabs == null || listVocabs.isEmpty() ) {
7575
listVocabs =
76-
RDFTransform.getGlobalContext().
77-
getPredefinedVocabularyManager().
78-
getPredefinedVocabularies().clone();
76+
RDFTransform.getGlobalContext().getPredefinedVocabularyManager().getPredefinedVocabularies().clone();
7977
if ( Util.isDebugMode() ) NamespacesGetDefaultCommand.logger.info("DEBUG: Predefined namespaces: size=" + listVocabs.size());
8078
}
8179

@@ -94,10 +92,10 @@ private void getDefaultNamespaces(HttpServletRequest request, HttpServletRespons
9492
for (Vocabulary vocab : listVocabs) {
9593
if ( Util.isDebugMode() )
9694
NamespacesGetDefaultCommand.logger.info(
97-
" Prefix: " + vocab.getPrefix() +
98-
" Namespace: " + vocab.getNamespace() +
99-
" Location: " + vocab.getLocation() +
100-
" LocType: " + vocab.getLocationType().toString()
95+
" Prefix[" + vocab.getPrefix() + "]" +
96+
" Namespace[" + vocab.getNamespace() + "]" +
97+
" Location[" + vocab.getLocation() + "]" +
98+
" LocType[" + vocab.getLocationType().toString() + "]"
10199
);
102100
Exception except = null;
103101
boolean bError = false; // ...not fetchable

src/main/java/org/openrefine/rdf/command/NamespacesSaveCommand.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
7070
// ...
7171
// }
7272

73-
theNamespaces.properties().forEach(prefix -> {
74-
Vocabulary vocab = RDFTransform.getVocabFromPrefixNode(prefix);
75-
listVocabs.add(vocab);
76-
});
73+
theNamespaces.properties().forEach(
74+
entryPrefix -> {
75+
Vocabulary vocab = RDFTransform.getVocabFromPrefixNode(entryPrefix);
76+
if (vocab != null) listVocabs.add(vocab);
77+
}
78+
);
7779
this.getRDFTransform(request).setNamespaces(listVocabs);
7880

7981
// ...and the namespaces' vocabulary searcher...

src/main/java/org/openrefine/rdf/model/vocab/PredefinedVocabularyManager.java

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,36 +63,34 @@ public PredefinedVocabularyManager(ApplicationContext context, File workingDir)
6363
this.context = context;
6464
this.workingDir = workingDir;
6565

66-
if ( Util.isDebugMode() ) PredefinedVocabularyManager.logger.info("Attempting vocabulary reconstruct...");
6766
try {
68-
this.reconstructVocabulariesFromFile();
69-
if ( predefinedVocabularies.isEmpty() ) {
70-
throw new FileNotFoundException("Predefined Vocabularies list is empty!");
67+
if ( Util.isDebugMode() ) PredefinedVocabularyManager.logger.info("Loading predefined vocabularies...");
68+
this.addPredefinedVocabularies();
69+
}
70+
catch (Exception ex) {
71+
// Predefined vocabularies are not defined properly...
72+
if ( Util.isVerbose() ) {
73+
PredefinedVocabularyManager.logger.warn("Loading predefined vocabularies failed: " + ex.getMessage(), ex);
74+
if ( Util.isVerbose(2) ) ex.printStackTrace();
7175
}
7276
}
77+
if ( this.predefinedVocabularies.isEmpty() ) {
78+
throw new FileNotFoundException("Predefined Vocabularies list is empty!");
79+
}
80+
81+
if ( Util.isDebugMode() ) PredefinedVocabularyManager.logger.info("Attempting vocabularies reconstruct...");
82+
try {
83+
this.reconstructVocabulariesFromFile();
84+
}
7385
catch (FileNotFoundException ex1) {
74-
// Existing vocabularies are not found.
75-
// Try adding predefined vocabularies...
76-
if ( Util.isDebugMode() ) PredefinedVocabularyManager.logger.info("...missing local, adding remote...");
77-
try {
78-
this.addPredefinedVocabularies();
79-
}
80-
catch (Exception ex2) {
81-
// Predefined vocabularies are not defined properly...
82-
// Ignore the exception, but log it...
83-
if ( Util.isVerbose() ) {
84-
PredefinedVocabularyManager.logger.warn("Loading predefined vocabularies failed: " + ex2.getMessage(), ex2);
85-
if ( Util.isVerbose(2) ) ex2.printStackTrace();
86-
}
87-
}
8886
try {
8987
this.save();
9088
}
9189
catch (Exception ex2) {
9290
// Saving predefined vocabularies failed...
9391
// Ignore the exception, but log it...
9492
if ( Util.isVerbose() ) {
95-
PredefinedVocabularyManager.logger.warn("Saving local Vocabulary failed: ", ex2);
93+
PredefinedVocabularyManager.logger.warn("Saving local Vocabularies failed: ", ex2);
9694
if ( Util.isVerbose(2) ) ex2.printStackTrace();
9795
}
9896
}
@@ -108,9 +106,9 @@ public VocabularyList getPredefinedVocabularies() {
108106
* Private methods
109107
*/
110108
private void reconstructVocabulariesFromFile() throws IOException {
111-
File vocabulariesFile = new File(this.workingDir, SAVED_VOCABS_FILE_NAME);
112-
if (vocabulariesFile.exists() && vocabulariesFile.length() != 0) {
113-
this.load();
109+
File vocabsFile = new File(this.workingDir, SAVED_VOCABS_FILE_NAME);
110+
if (vocabsFile.exists() && vocabsFile.length() != 0) {
111+
this.load(vocabsFile);
114112
}
115113
else {
116114
throw new FileNotFoundException("File " + SAVED_VOCABS_FILE_NAME + " is missing or empty!");
@@ -126,7 +124,7 @@ private void addPredefinedVocabularies() throws IOException {
126124
String strLine;
127125
String strPrefix = null;
128126
String strNamespace = null;
129-
String strLocation = "";
127+
String strLocation = null;
130128

131129
// Read ontology file lines...
132130
// There should be at least 2 entries per line but ideally 3:
@@ -145,6 +143,7 @@ private void addPredefinedVocabularies() throws IOException {
145143
// Organize entries...
146144
strPrefix = astrTokens[0];
147145
strNamespace = astrTokens[1];
146+
strLocation = null;
148147
if (astrTokens.length > 2) strLocation = astrTokens[2];
149148

150149
// Import and Index the ontology...
@@ -172,16 +171,28 @@ protected InputStream getPredefinedVocabularyFile() {
172171
return this.getClass().getResourceAsStream(PREDEFINED_VOCABS_FILE_NAME);
173172
}
174173

175-
protected void load() throws IOException {
176-
File vocabsFile = new File(this.workingDir, SAVED_VOCABS_FILE_NAME);
174+
protected void load(File vocabsFile) throws IOException {
177175
ObjectMapper mapper = new ObjectMapper();
178176
JsonNode jnodeVocabs = mapper.readTree(vocabsFile);
179177
if ( jnodeVocabs != null && jnodeVocabs.has(Util.gstrNamespaces) ) {
180178
JsonNode jnodeNamespaces = jnodeVocabs.get(Util.gstrNamespaces);
181-
jnodeNamespaces.properties().forEach(prefix -> {
182-
Vocabulary vocab = RDFTransform.getVocabFromPrefixNode(prefix);
183-
this.predefinedVocabularies.add(vocab);
184-
});
179+
jnodeNamespaces.properties().forEach(
180+
entryPrefix -> {
181+
if ( this.predefinedVocabularies.containsPrefix( entryPrefix.getKey() ) ) {
182+
// If the loading prefix version is OLD, don't add it--use the NEW predefined version...
183+
if ( entryPrefix.getValue().isValueNode() ) {
184+
PredefinedVocabularyManager.logger.info(" Using existing predefined vocabulary (newer).");
185+
return;
186+
}
187+
// Otherwise, remove predefined vocabulary to replace it with the loaded version...
188+
PredefinedVocabularyManager.logger.info(" Replacing predefined vocabulary...");
189+
this.predefinedVocabularies.removeByPrefix( entryPrefix.getKey() );
190+
}
191+
Vocabulary vocab = RDFTransform.getVocabFromPrefixNode(entryPrefix);
192+
this.predefinedVocabularies.add(vocab);
193+
PredefinedVocabularyManager.logger.info(" Vocabulary loaded.");
194+
}
195+
);
185196
}
186197
}
187198

src/main/java/org/openrefine/rdf/model/vocab/Vocabulary.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
import com.fasterxml.jackson.annotation.JsonIgnoreType;
2424
import com.fasterxml.jackson.core.JsonGenerator;
25+
26+
import org.openrefine.rdf.RDFTransform;
2527
import org.openrefine.rdf.model.Util;
2628
import com.fasterxml.jackson.core.JsonGenerationException;
2729

@@ -67,15 +69,23 @@ public Vocabulary(String strPrefix, String strNamespace)
6769
{
6870
this.strPrefix = strPrefix;
6971
this.strNamespace = strNamespace;
70-
this.strLocation = strNamespace;
71-
this.loctype = LocationType.URL;
72-
if ( strPrefix.equals("xsd") ) {
73-
this.strLocation = "";
74-
this.loctype = LocationType.NONE;
72+
this.strLocation = "";
73+
this.loctype = LocationType.NONE;
74+
75+
IPredefinedVocabularyManager predefinedVocabularyManager = RDFTransform.getGlobalContext().getPredefinedVocabularyManager();
76+
if (predefinedVocabularyManager != null) {
77+
VocabularyList listDefaultVocabs = predefinedVocabularyManager.getPredefinedVocabularies().clone();
78+
if ( listDefaultVocabs.containsPrefix(strPrefix) ) {
79+
Vocabulary vocabFound = listDefaultVocabs.findByPrefix(strPrefix);
80+
this.strNamespace = vocabFound.getNamespace();
81+
this.strLocation = vocabFound.getLocation();
82+
this.loctype = vocabFound.getLocationType();
83+
}
7584
}
85+
7686
if ( Util.isDebugMode() ) {
7787
Vocabulary.logger.info(
78-
"DEBUG: Prefix:[{}] Namespace:[{}] Location:[{}] LocType:[{}]",
88+
"DEBUG: (PN) Prefix:[{}] Namespace:[{}] Location:[{}] LocType:[{}]",
7989
strPrefix, strNamespace, strLocation, loctype.toString()
8090
);
8191
}
@@ -89,7 +99,7 @@ public Vocabulary(String strPrefix, String strNamespace, String strLocation, Loc
8999
this.loctype = loctype;
90100
if ( Util.isDebugMode() ) {
91101
Vocabulary.logger.info(
92-
"DEBUG: Prefix:[{}] Namespace:[{}] Location:[{}] LocType:[{}]",
102+
"DEBUG: (PNLT) Prefix:[{}] Namespace:[{}] Location:[{}] LocType:[{}]",
93103
strPrefix, strNamespace, strLocation, loctype.toString()
94104
);
95105
}

src/main/java/org/openrefine/rdf/model/vocab/VocabularyImporter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private void getDatasetGraph()
112112
}
113113
catch (Exception ex) {
114114
this.m_theDSGraph = null;
115-
throw new VocabularyImportException("Importing vocabulary: " + this.m_strNamespace, ex);
115+
throw new VocabularyImportException("WARNING: Importing vocabulary " + this.m_strNamespace, ex);
116116
}
117117
}
118118

@@ -155,7 +155,7 @@ private void queryClasses(List<RDFTClass> classes, String[] astrLoader)
155155
}
156156
catch (Exception ex) {
157157
VocabularyImporter.logger.error( "ERROR: Query " + ex.getMessage() );
158-
throw new VocabularyImportException("Query " + strMessage + ex.getMessage(), ex);
158+
throw new VocabularyImportException("WARNING: Query " + strMessage + ex.getMessage(), ex);
159159
}
160160
try {
161161
QueryExecution qexec = QueryExecutionFactory.create(query, this.m_theDSGraph);
@@ -209,7 +209,7 @@ private void queryProperties(List<RDFTProperty> properties, String[] astrLoader)
209209
}
210210
catch (Exception ex) {
211211
VocabularyImporter.logger.error( "ERROR: Query " + ex.getMessage() );
212-
throw new VocabularyImportException("Query " + strMessage + ex.getMessage(), ex);
212+
throw new VocabularyImportException("WARNING: Query " + strMessage + ex.getMessage(), ex);
213213
}
214214
try {
215215
QueryExecution qexec = QueryExecutionFactory.create(query, this.m_theDSGraph);

src/main/resources/module/scripts/rdf-data-table-view.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,8 @@ ExpressionPreviewDialog_WidgetCopy.prototype.constructor = ExpressionPreviewDial
530530
this._elmts.expressionPreviewTextarea
531531
.val(this.expression)
532532
.keyup( () => { this._scheduleUpdate(); } )
533-
.select()
534-
.focus();
533+
.trigger("focus")
534+
.trigger("select");
535535

536536
//this._tabContentWidth = this._elmts.expressionPreviewPreviewContainer.width() + "px";
537537

0 commit comments

Comments
 (0)