web/ldt/ldt_utils/projectindexer.py
changeset 91 9c83809fda01
parent 62 39b2dab4f939
child 94 9927a619d2b5
equal deleted inserted replaced
80:1e7732f40eee 91:9c83809fda01
    10 import xml.dom.ext
    10 import xml.dom.ext
    11 import xml.xpath
    11 import xml.xpath
    12 import lucene
    12 import lucene
    13 from ldt.ldt_utils import STORE
    13 from ldt.ldt_utils import STORE
    14 from ldt.ldt_utils import ANALYZER
    14 from ldt.ldt_utils import ANALYZER
       
    15 
    15 
    16 
    16 def Property(func):
    17 def Property(func):
    17     return property(**func()) 
    18     return property(**func()) 
    18 
    19 
    19 class ProjectIndexer(object):
    20 class ProjectIndexer(object):
    42     def index_all(self):
    43     def index_all(self):
    43         for project in self.__projectList:
    44         for project in self.__projectList:
    44             self.index_project(project)
    45             self.index_project(project)
    45 
    46 
    46     def index_project(self, project):
    47     def index_project(self, project):
    47         ldt=project.ldt
    48         # ldt.utils.log.debug("Indexing project : "+str(project.ldt_id))
       
    49         
       
    50 	ldt=project.ldt
    48         doc = xml.dom.minidom.parseString(ldt.encode( "utf-8" ))
    51         doc = xml.dom.minidom.parseString(ldt.encode( "utf-8" ))
    49         
    52  
    50         self.__writer.deleteDocuments(lucene.Term("ldt_id", project.ldt_id))
    53         self.__writer.deleteDocuments(lucene.Term("ldt_id", project.ldt_id))
    51             
    54             
    52         con = xml.xpath.Context.Context(doc, 1, 1, None)
    55         con = xml.xpath.Context.Context(doc, 1, 1, None)
    53         res = xml.xpath.Evaluate("/iri/annotations/content", context=con)
    56         res = xml.xpath.Evaluate("/iri/annotations/content", context=con)
       
    57         project.ldt.encode( "utf-8 " )
    54 
    58 
    55         for content in res:
    59         for content in res:
    56             contentId = content.getAttribute("id")
    60             contentId = content.getAttribute("id")
    57             
    61  
    58             res =xml.xpath.Evaluate("ensemble", content)
    62             res =xml.xpath.Evaluate("ensemble", content)
    59             for ensemble in res:
    63             for ensemble in res:
    60                 ensembleId = ensemble.getAttribute("id")
    64                 ensembleId = ensemble.getAttribute("id")
    61                 
    65  
    62                 for decoupageNode in ensemble.childNodes:
    66                 for decoupageNode in ensemble.childNodes:
       
    67                     # ldt.utils.log.debug("Indexing project decoupage : "+ repr(decoupageNode.nodeType) + " in " + repr(self.decoupage_blacklist))
    63                     if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage"  or decoupageNode.getAttribute("id") in self.decoupage_blacklist:
    68                     if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage"  or decoupageNode.getAttribute("id") in self.decoupage_blacklist:
    64                         continue
    69                         continue
    65                 
    70                 
    66                     decoupId = decoupageNode.getAttribute("id")
    71                     decoupId = decoupageNode.getAttribute("id")
    67                     res = xml.xpath.Evaluate("elements/element", decoupageNode)
    72                     res = xml.xpath.Evaluate("elements/element", decoupageNode)
       
    73 
    68                     for elementNode in res:
    74                     for elementNode in res:
    69                         doc = lucene.Document()
    75                         doc = lucene.Document()
    70                         elementId = elementNode.getAttribute("id")
    76                         elementId = elementNode.getAttribute("id")
    71                         tags = elementNode.getAttribute("tags")
    77                         tags = elementNode.getAttribute("tags")
    72                         
    78