comparison MPIWGThesaurus.py @ 49:0610142a2550

closed: small bug in export (https://otrs.mpiwg-berlin.mpg.de/otrs/index.pl?Action=AgentTicketZoom;TicketID=38)
author dwinter
date Thu, 05 Dec 2013 13:21:00 +0100
parents cb20308fe412
children 8bfd713e5d99
comparison
equal deleted inserted replaced
48:cb20308fe412 49:0610142a2550
26 import transaction 26 import transaction
27 import random 27 import random
28 import urllib2 28 import urllib2
29 import urllib 29 import urllib
30 import json 30 import json
31 import md5
31 32
32 from SrvTxtUtils import utf8ify 33 from SrvTxtUtils import utf8ify
33 34
34 class projectHolder: 35 class projectHolder:
35 projectHolder="" 36 projectHolder=""
75 76
76 meta_type="MPIWGThesaurus" 77 meta_type="MPIWGThesaurus"
77 78
78 TMP_PERSON_NS="http://ontologies.mpiwg-berlin.mpg.de/tempObjects/person/" 79 TMP_PERSON_NS="http://ontologies.mpiwg-berlin.mpg.de/tempObjects/person/"
79 ONTOLOGY_NS="http://ontologies.mpiwg-berlin.mpg.de/authorities/namedIdentities/" 80 ONTOLOGY_NS="http://ontologies.mpiwg-berlin.mpg.de/authorities/namedIdentities/"
80 personproviderURL="http://127.0.0.1:8280/MetaDataManagerRestlet/person/" 81 #personproviderURL="http://127.0.0.1:8280/MetaDataManagerRestlet/person/"
81 #personproviderURL="http://virtuoso.mpiwg-berlin.mpg.de:8080/MetaDataManagerRestlet/person/" 82 personproviderURL="http://virtuoso.mpiwg-berlin.mpg.de:8080/MetaDataManagerRestlet/person/"
82 #PERSONS_LOOKUP_URL="http://127.0.0.1:8280/MetaDataManagerRestlet/search/persons" 83 #PERSONS_LOOKUP_URL="http://127.0.0.1:8280/MetaDataManagerRestlet/search/persons"
83 PERSONS_LOOKUP_URL="http://127.0.0.1:8280/MetaDataManagerRestlet/persons" 84 PERSONS_LOOKUP_URL="http://virtuoso.mpiwg-berlin.mpg.de:8080/MetaDataManagerRestlet/persons"
84 EDIT_URL="http://127.0.0.1:8280/MetaDataManagerRestlet/edit?id=" 85 EDIT_URL="http://virtuoso.mpiwg-berlin.mpg.de:8080/MetaDataManagerRestlet/edit?id="
85 #PERSONS_LOOKUP_URL="http://virtuoso.mpiwg-berlin.mpg.de:8080/MetaDataManagerRestlet/person/" 86 #PERSONS_LOOKUP_URL="http://virtuoso.mpiwg-berlin.mpg.de:8080/MetaDataManagerRestlet/person/"
86 87
87 additionalNamesGraphURL="file://newpersonsFromProjects" 88 additionalNamesGraphURL="file://newpersonsFromProjects"
88 89
89 #virtuosoServer="http://ontologies.mpiwg-berlin.mpg.de" 90 #virtuosoServer="http://ontologies.mpiwg-berlin.mpg.de"
284 logging.debug("PROTS"+repr(project.tags)) 285 logging.debug("PROTS"+repr(project.tags))
285 tagsOfType=project.tags.get(tag,OOSet()) 286 tagsOfType=project.tags.get(tag,OOSet())
286 logging.debug(tagsOfType) 287 logging.debug(tagsOfType)
287 tagsOfType.add(subTag.decode('utf-8')) 288 tagsOfType.add(subTag.decode('utf-8'))
288 289
289 #logging.debug("Adding %s to %s"%(subTag,projectID)) 290 logging.debug("Adding %s to %s"%(subTag,projectID))
290 project.tags[tag]=tagsOfType 291 project.tags[tag]=tagsOfType
291 292
292 projectTags[projectID]=project 293 projectTags[projectID]=project
293 logging.debug("Saved %s to %s"%(repr(list(tagsOfType)),projectID)) 294 logging.debug("Saved %s to %s"%(repr(list(tagsOfType)),projectID))
294 logging.debug(projectTags) 295 logging.debug(projectTags)
772 773
773 def getTitle(self,entry): 774 def getTitle(self,entry):
774 return entry.title 775 return entry.title
775 776
776 def thes_quote(self,txt): 777 def thes_quote(self,txt):
777 import md5 778 logging.debug("@*%s*@"%repr(txt))
778 logging.debug("@*%s*@"%txt) 779 return md5.md5(utf8ify(txt.lower())).hexdigest()
779 return md5.md5(txt.lower()).hexdigest()
780 780
781 781
782 def formatTag(self,tag): 782 def formatTag(self,tag):
783 splitted= tag.split("_") 783 splitted= tag.split("_")
784 return splitted[-1] 784 return splitted[-1]
855 855
856 tagCnt=0 856 tagCnt=0
857 for tagType in tagTypes: 857 for tagType in tagTypes:
858 858
859 #retHash[tagType]=[] 859 #retHash[tagType]=[]
860 860
861 861
862 tags =self.getTagsFromDB(projectID, tagType) 862 tags =self.getTagsFromDB(projectID, tagType)
863 if len(tags) !=0: 863 if len(tags) !=0:
864 retHash[tagType] = [self.getLabel(tag,tagType) for tag in tags] 864 retHash[tagType] = [self.getLabel(tag,tagType) for tag in tags]
865 tagCnt+=1 865 tagCnt+=1
866 866
867 867
868 if tagCnt==0: 868 if tagCnt==0:
869 return None 869 return None
870 870
871 return retHash 871 return retHash
872 872
873 873
874 874
875 875