After finding the slot inconsistency, I looked at slots described as deprecated in the model vs. their usage in the reports and found 36 references to deprecated slots in 17 reports. I am starting the process of building out my model in v3 and would prefer to avoid using items marked as deprecated. Do you have any suggestions or guidelines on the use of deprecated slots?
Here is the script I used to identify the references.
Code: Select all
import edu.stanford.smi.protege.model
import re
from java.util import HashSet
#
# Report on the deprecated classes and slots in the Essential model
# -- depends upon the Documentation to contain the word "DEPRECATED"
#
# reportDeprecations() - prints the name of reports that contain a reference to a deprecated slot
# reportDeprecation(reportFileName) - prints offending slots and lines from the report xsl, returns number of offending lines
# getAllDeprected() - populates the deprecatedClasses and deprecatedSlots global variables for all classes and slots
# getDeprecated(className) - populates the deprecatedClasses with this class name if it has been documented as deprecated
# and the deprecatedSlots with referenced slot names that have been documented as deprecated
#
viewerUrl = "http://localhost:8080/essential_viewer/"
deprecatedClasses = []
deprecatedSlots = []
deprecatedSlotMap = HashSet()
def reportDeprecations() :
global deprecatedSlots
global deprecatedClasses
print "+++++++++++++++++++++++++++++++++++++++++++++++++++++"
print "Reports that reference deprecated slots"
print "+++++++++++++++++++++++++++++++++++++++++++++++++++++"
getAllDeprecated()
if deprecatedSlots == None and deprecatedClasses == None and len(deprecatedSlot) + len(deprecatedClasses) <= 0 :
print "no deprecated classes or slots!"
return
cls = kb.getCls("Report")
instances = cls.getInstances()
fileSlot = kb.getSlot("report_xsl_filename")
n = 0
o = 0
for instance in instances :
fileName = instance.getOwnSlotValue(fileSlot)
if fileName != None :
m = reportDeprecation(fileName)
n += m
if m > 0 : o += 1
print "+++++++++++++++++++++++++++++++++++++++++++++++++++++"
print str(n)+" references to deprecated slots found in "+str(o)+" reports."
print "+++++++++++++++++++++++++++++++++++++++++++++++++++++"
def reportDeprecation(reportFileName) :
global viewerUrl
global deprecatedSlots
global deprecatedClasses
f = urllib.urlopen(viewerUrl+reportFileName)
xslLines = re.split("\n",f.read())
foundSlots = []
offendingLine = []
c = 0
for slot in deprecatedSlots :
slotString = "'"+slot+"'"
i = 0
for line in xslLines :
i += 1
t = re.search(slotString,line)
if t != None :
c += 1
foundSlots.append(slot)
offendingIndex = xslLines.index(line)
offendingLine.append("["+str(i)+"]"+line)
if c > 0 :
print "=============================="
print reportFileName+" has "+str(c)+" references to deprecated slots:"
print "=============================="
i = 0
for slot in foundSlots :
print "Slot: "+slot
print " line"+offendingLine[i]
i += 1
return c
def getAllDeprecated():
global deprecatedSlots
global deprecatedSlotMap
allClses = kb.getClses()
for cls in allClses:
getDeprecated(cls)
deprecatedSlots = deprecatedSlotMap.toArray()
def getDeprecated(aClass) :
global deprecatedSlots
global deprecatedSlotMap
global deprecatedClasses
slts = aClass.getTemplateSlots()
className = aClass.getBrowserText()
if className[0] == ":" :
return
clsDocs = aClass.getDocumentation()
for clsDoc in clsDocs :
if re.search("DEPRECATED",clsDoc) :
deprecatedClasses.append(className)
for slt in slts:
docs = aClass.getTemplateSlotDocumentation(slt)
for doc in docs :
if re.search("DEPRECATED",doc) :
slotName = slt.getBrowserText()
deprecatedSlotMap.add(slotName)