Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using properties file for namespace prefixes.
- Loading branch information
1 parent
7277e05
commit 202cff5
Showing
7 changed files
with
85 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/org/fcrepo/migration/foxml11/NamespacePrefixMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.fcrepo.migration.foxml11; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.util.Properties; | ||
|
||
import com.hp.hpl.jena.update.UpdateRequest; | ||
|
||
/** | ||
* Utility bean to set namespace prefixes in a SPARQL update. | ||
* @author danny | ||
* | ||
*/ | ||
public class NamespacePrefixMapper { | ||
|
||
private Properties namespacePrefixes; | ||
|
||
/** | ||
* Constructor. | ||
* @param namespaceFile Namespace properties file that gets injected in via Spring | ||
* @throws IOException | ||
*/ | ||
public NamespacePrefixMapper(final File namespaceFile) throws IOException { | ||
namespacePrefixes = new Properties(); | ||
final FileInputStream namespaceInputStream = new FileInputStream(namespaceFile); | ||
namespacePrefixes.load(namespaceInputStream); | ||
namespaceInputStream.close(); | ||
} | ||
|
||
/** | ||
* Declares all the namespace prefixes provided in the properties file. | ||
* @param updateRequest SPARQL update query that needs declared prefixes | ||
*/ | ||
public void setPrefixes(final UpdateRequest updateRequest) { | ||
namespacePrefixes.forEach((prefix,namespace) -> { | ||
updateRequest.setPrefix((String) prefix, (String) namespace); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#The first time a property is added to the repository belonging to a particular namespace, that namespace | ||
#prefix is registered and will be used from that point on (for all properties using that namespace). Setting values | ||
#here before the first run will allow registration of preferred namespace prefixes, but will have no effect on | ||
#subsequent runs. | ||
dcterms = http://purl.org/dc/terms/ | ||
fedoraaccess = http://fedora.info/definitions/1/0/access/ | ||
fedora3model = info:fedora/fedora-system:def/model# | ||
rels-ext = info:fedora/fedora-system:def/relations-external# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters