VIVO-692 Restrict LOD by Publish level, not by Display level

Create a new annotation for properties and classes, HiddenFromPublishBelowRoleLevelAnnot.
Provide the means to initialize these annotations, edit them, and display them in the verbose property display.
Create a Permission and some requested actions so the policies can decide which statements must be filtered out, based on the user's role.
Add unit tests and improve acceptance tests
This commit is contained in:
j2blake 2014-03-10 17:58:26 -04:00
parent 36087a25c0
commit c084a05832
5 changed files with 1338 additions and 23 deletions

View file

@ -0,0 +1,76 @@
=begin
go through the lines of the file.
If you find a line that matches
vitro:hiddenFromDisplayBelowRoleLevelAnnot
and followed by a line that matches
<http://vitro.mannlib.cornell.edu/ns/vitro/role#public> ;
--where "public" may be any string
Insert 2 lines after the second one, replacing Display by Publish on the first, and duplicating the second.
If you find a line that contains
vitro:hiddenFromDisplayBelowRoleLevelAnnot
and does not match it, or is not followed by a line that matches
<http://vitro.mannlib.cornell.edu/ns/vitro/role#public> ;
Issue a warning and continue.
=end
FILE_PATH = "../../rdf/tbox/firsttime/initialTBoxAnnotations.n3"
DISPLAY_URI = "vitro:hiddenFromDisplayBelowRoleLevelAnnot"
DISPLAY_LOCALNAME = "hiddenFromDisplayBelowRoleLevelAnnot"
def read_the_file()
@lines = File.readlines(FILE_PATH);
end
def scan_the_lines()
@lines.each_index do |i|
@line1 = @lines[i]
@line2 = @lines[i+1]
@index = i
if linesContainMatch()
replicateProperty()
else
checkForMismatch()
end
end
end
def linesContainMatch()
return false unless @line1.strip() == DISPLAY_URI
return false unless @line2
return false unless m = @line2.match(/<http:\/\/vitro\.mannlib\.cornell\.edu\/ns\/vitro\/role#(.*)>/)
@role = m[1]
end
def replicateProperty()
newline1 = @line1.gsub(/Display/, "Publish")
newline2 = @line2.gsub(/#.*>/, "##{@role}>")
@lines.insert(@index + 2, newline1, newline2)
end
def checkForMismatch()
return false unless @line1.strip() == DISPLAY_URI
if !@line2
puts "Found display property at end of file"
return
end
if !@line2.match(/^\s*<http:\/\/vitro\.mannlib\.cornell\.edu\/ns\/vitro\/role#(.*)>\s*;\s*$/)
puts "Found bogus clutter in the second line (#{@index}) '#{@line2}'"
return
end
end
def write_the_file()
f = File.new(FILE_PATH+"-modified", "w")
@lines.each() do |line|
f.write(line)
end
f.close()
end
read_the_file()
scan_the_lines()
write_the_file()