annotate MPIWGThesaurus.py @ 17:8e2ddcef1e8d

overviews
author dwinter
date Fri, 27 Jan 2012 14:48:02 +0100
parents f9a65eaaa59c
children 8cbb34593ca9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
1 #Klasse zum Taggen und Anzeigen der Tags von Projekte bzw. allgemein Webseiten des Institutes
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
2 #Tags werden in der Instanz abgespeichert
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
3 #Personenname kommen aus dem Virtuoso-Triplestore , lokal erzeugte zusaetliche Name werden dort abgespeichert
11
dwinter
parents: 9
diff changeset
4 #Fuer die Suche ueber die Personenname wird das MetaDataManagerRestlet benoetigt.
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
5 #TODO: Zur Zeit werden die entsprechenden Server URLs hier in der Klasse definiert.
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
6
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
7
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8 # TODO: generell verwaltung der tags im triple store und nicht in zope.
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
9 # TODO: mache server und namespaces konfigurierbar im project
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
10
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
11
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
12 from OFS.Folder import Folder
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
13 from Globals import package_home
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
14 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
15 from BTrees.OOBTree import OOBTree
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
16 from BTrees.OOBTree import OOSet
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
17 from AccessControl import ClassSecurityInfo
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
18
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
19 #import os
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
20 import os.path
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
21 import logging
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
22 import time
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
23 import email.Utils
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
24 from types import ListType
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
25 import transaction
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
26 import random
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
27 import urllib2
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
28 import urllib
17
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
29 from Ft.Lib.DistExt.ImageHlp import Array
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
30 from aetypes import IsType
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
31
17
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
32
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
33 class projectHolder:
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
34 projectHolder=""
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
35 projectName=""
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
36 projectID=""
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
37 persons=""
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
38 tags={}
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
39
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
40 def __init__(self,ID):
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
41 self.projectID=ID
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
42 self.tags={}
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
43
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
44 #Entry beschreibt jeweils einen Tag mit dem Namen "title", entries enthaelt eine Liste von Subtags (der Klasse Entry), die diesem Tag untergeordnet sind.
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
45 class Entry:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
46 """publicClass"""
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
47
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
48 #===========================================================================
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
49 # __init__
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
50 #===========================================================================
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
51 def __init__(self,title,entries=[]):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
52 self.title=title
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
53 self.entries=entries
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
54
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
55 def getTitle(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
56 """getTitle"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
57 return self.title
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
58
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
59 #Beschriebt einen von einem Benutzer vorgeschlagenen Tag
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
60 class SuggestedTag:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
61 """publicClass"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
62 type=""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
63 userName=""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
64 def __init__(self,name,comment,type,userName):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
65 self.name=name
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
66 self.comment=comment
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
67 self.type=type
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
68 self.userName=userName
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
69
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
70
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
71 class MPIWGThesaurus(Folder):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
72 """MPIWGThesaurus main folder"""
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
73 security=ClassSecurityInfo()
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
74
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
75 meta_type="MPIWGThesaurus"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
76
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
77 TMP_PERSON_NS="http://ontologies.mpiwg-berlin.mpg.de/tempObjects/person/"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
78 ONTOLOGY_NS="http://ontologies.mpiwg-berlin.mpg.de/authorities/namedIdentities/"
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
79 personproviderURL="http://127.0.0.1:8280/MetaDataManagerRestlet/person/"
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
80 #personproviderURL="http://virtuoso.mpiwg-berlin.mpg.de:8080/MetaDataManagerRestlet/person/"
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
81 #PERSONS_LOOKUP_URL="http://127.0.0.1:8280/MetaDataManagerRestlet/search/persons"
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
82 PERSONS_LOOKUP_URL="http://127.0.0.1:8280/MetaDataManagerRestlet/persons"
8
dwinter
parents: 7
diff changeset
83 EDIT_URL="http://127.0.0.1:8280/MetaDataManagerRestlet/edit?id="
dwinter
parents: 7
diff changeset
84 #PERSONS_LOOKUP_URL="http://virtuoso.mpiwg-berlin.mpg.de:8080/MetaDataManagerRestlet/person/"
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
85
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
86 additionalNamesGraphURL="file://newpersonsFromProjects"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
87
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
88 #virtuosoServer="http://ontologies.mpiwg-berlin.mpg.de"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
89 virtuosoServer="http://virtuoso.mpiwg-berlin.mpg.de:8890"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
90 virtuosoDAV="/DAV/home/websiteuser/"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
91 virtuosoDAVUser="websiteuser"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
92 virtuosoDAVPW="w3s45us3"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
93 virtuosoGraph="file://newpersonsFromProjects"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
94
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
95 logpathDefault="/var/tmp/tagchanges.log"
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
96
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
97 #BTrees fuer die Tags
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
98
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
99 projectPersons= OOBTree() #project --> personen IDs
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
100 projectObjects= OOBTree() #project --> objects
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
101 projectHistoricalPlaces= OOBTree()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
102 projectSuggestedTags= OOBTree()
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
103 persons2Projects= OOBTree() #personenID --> projects
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
104 objects2Projects=OOBTree() #objects --> projects
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
105 historicalPlaces2Projects=OOBTree()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
106 suggestedTags2Projects=OOBTree()
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
107 personIDtoNames=OOBTree() # weist den personenIDs Klartextnamen aus dem Triplestore zu
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
108 personsIDForSort=[] # liste personenID sortiert nach dem tupel (nachname,vorname)
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
109 personsIDForSortFull=[] # liste (personenID,(nachname,vorname)) nicht sortiert!
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
110
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
111 suggestedPersons= OOBTree(); #TODO: das sollte die ueberfluessig werde und nur im triple store stehen.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
112
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
113 tagList=[]
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
114
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
115 #default liste fuer tags, wird ueber das Managementinterface ueberschrieben
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
116 approachesTxt="""A
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
117 ---
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
118 ent1
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
119 ---
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
120 B
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
121 ---
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
122 enta
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
123 entb
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
124 entc
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
125 """
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
126
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
127 disciplines=[]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
128 disciplinesTxt="""A
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
129 B
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
130 C
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
131 """
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
132
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
133 periods=[]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
134 periodsTxt="""PA
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
135 PB
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
136 PC
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
137 """
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
138
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
139 spaces=[]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
140 spacesTxt="""SPA
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
141 ---
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
142 sPent1
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
143 ---
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
144 SPB
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
145 ---
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
146 SPenta
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
147 SPentb
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
148 SPentc
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
149 """
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
150 technologies=[]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
151 technologiesTxt="""TPA
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
152 ---
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
153 TPent1
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
154 ---
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
155 TPB
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
156 ---
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
157 TPenta
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
158 TPentb
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
159 TPentc
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
160 """
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
161
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
162 knowledgeTransfers=[]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
163 knowledgeTransfersTxt="""KTPA
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
164 ---
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
165 TPent1
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
166 ---
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
167 TPB
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
168 ---
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
169 TPenta
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
170 TPentb
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
171 TPentc
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
172 """
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
173
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
174
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
175
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
176
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
177
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
178
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
179 manage_options = Folder.manage_options+(
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
180 {'label':'Thesaurus entries','action':'changeMPIWGThesaurusForm'},
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
181 {'label':'Manage Thesaurus','action':'manageMPIWGThesaurus'},
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
182 {'label':'Thesaurus Log','action':'manageMPIWGThesaurusLogs'},
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
183 #{'label':'Change Publications Special','action':'changePublications_specialForm'},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
184 )
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
185
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
186 def __init__(self,id):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
187 """init"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
188 self.id=id
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
189
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
190
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
191 def index_html(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
192 """index file"""
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
193
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
194 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','index.html')).__of__(self)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
195 return pt()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
196
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
197 security.declareProtected('View management screens','changeMPIWGThesaurusForm')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
198 def changeMPIWGThesaurusForm(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
199 """form for changing the project"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
200 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changeMPIWGThesaurusForm.zpt')).__of__(self)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
201 return pt()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
202
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
203 security.declareProtected('View management screens','manageMPIWGThesaurus')
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
204 def manageMPIWGThesaurus(self):
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
205 """form for changing the project"""
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
206 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','manageMPIWGThesaurus.zpt')).__of__(self)
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
207 return pt()
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
208
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
209 security.declareProtected('View management screens','manageMPIWGThesaurusLogs')
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
210 def manageMPIWGThesaurusLogs(self):
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
211 """form for changing the project"""
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
212 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','manageMPIWGThesaurusLog.zpt')).__of__(self)
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
213 return pt()
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
214
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
215 def changeMPIWGThesaurusLog(self,logpath,RESPONSE=None):
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
216 """change log file path"""
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
217 self.logpath=logpath
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
218
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
219 if RESPONSE is not None:
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
220 redirect(RESPONSE,'manage_main')
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
221
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
222
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
223 security.declareProtected('View management screens','changeMPIWGThesaurus')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
224 def changeMPIWGThesaurus(self,approachesTxt,disciplinesTxt,periodsTxt,spacesTxt,technologiesTxt,knowledgeTransfersTxt,RESPONSE=None):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
225 """change it"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
226 self.approachesTxt=approachesTxt
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
227 self.disciplinesTxt=disciplinesTxt
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
228 self.periodsTxt=periodsTxt
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
229 self.spacesTxt=spacesTxt
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
230 self.technologiesTxt=technologiesTxt
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
231 self.knowledgeTransfersTxt=knowledgeTransfersTxt
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
232
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
233 if RESPONSE is not None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
234 redirect(RESPONSE,'manage_main')
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
235
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
236
17
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
237 def getProjectsAndTags(self):
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
238 """projekte und tags"""
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
239
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
240
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
241 projectTags={}
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
242 for tag in self.tags.keys():
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
243 logging.debug("getProjectsAndTags:"+tag)
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
244 # <div class="level1_projects" tal:repeat="proj
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
245 # python:here.getProjectsWithTag('approaches',here.getTitle(level1))"><a tal:attributes="href
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
246 # python:proj[0]"><span tal:content="python:proj[1]">my proj</span><tal:x define="person python:proj[2]"><span
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
247 # class="person_projects" tal:content="person"/></tal:x></a></div>
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
248 #</div>
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
249
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
250 for subTag in self.tags.get(tag):
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
251 projs = self.getProjectsWithTag(tag,subTag)
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
252 if not isinstance(projs, ListType):
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
253 projs=[projs]
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
254
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
255 for proj in projs:
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
256
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
257 projectID=proj[0]
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
258 logging.debug("PTS"+repr(projectTags))
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
259 project=projectTags.get(projectID,projectHolder(projectID))
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
260 project.projectName=proj[1]
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
261 project.persons=proj[2]
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
262 logging.debug(project)
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
263 logging.debug(tag)
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
264 logging.debug("PROTS"+repr(project.tags))
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
265 tagsOfType=project.tags.get(tag,OOSet())
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
266 logging.debug(tagsOfType)
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
267 tagsOfType.add(subTag.decode('utf-8'))
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
268
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
269 logging.debug("Adding %s to %s"%(subTag,projectID))
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
270 project.tags[tag]=tagsOfType
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
271
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
272 projectTags[projectID]=project
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
273 logging.debug("Saved %s to %s"%(repr(list(tagsOfType)),projectID))
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
274 logging.debug(projectTags)
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
275
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
276
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
277
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
278 return projectTags
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
279
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
280 def getProjectsAndTagsTSV(self):
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
281 """get the projects as tab"""
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
282 ret=""
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
283
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
284 #genereate headers
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
285 headers=['date','projectPath','projectName','researchers resp']
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
286 headers.extend(list(self.tags.keys()))
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
287 ret+="\t".join(headers)+"\n"
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
288
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
289 projectTags = self.getProjectsAndTags()
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
290 for projectID in projectTags.keys():
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
291 retarray=[]
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
292 splitted = projectID.split("/") # hiern nur die eingetliche ID ohne den Pfad
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
293 if len(splitted)>0:
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
294 projectIDShort=splitted[-1]
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
295 retarray.append(self.lastChangeInThesaurus.get(projectIDShort,''))
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
296 else:
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
297 retarray.append('')
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
298 retarray.append(projectID)
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
299 project = projectTags.get(projectID)
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
300 retarray.append(project.projectName)
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
301 retarray.append(project.persons)
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
302
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
303
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
304
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
305 for tagType in self.tags.keys():
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
306 tags = project.tags.get(tagType,[''])
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
307 retarray.append(";".join(tags))
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
308
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
309
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
310 ret+="\t".join(retarray)+"\n"
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
311
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
312 return ret
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
313
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
314 def getLogpath(self):
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
315 return getattr(self,"logpath",self.logpathDefault)
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
316
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
317 def getLogfile(self,projectID="",date=""):
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
318
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
319 # logfile format : YYYY-MM-TT HH:mm:ss\tUSER\ttype\tprojectid\CHANGED_TAG_or_OBJECT_or_PERSON
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
320 if not os.path.exists(self.getLogpath()):
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
321 return ""
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
322
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
323 fh = open(self.getLogpath(),"r")
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
324 lines=fh.readlines()
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
325
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
326 if (projectID!=""):
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
327 ret=[]
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
328 for line in lines:
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
329 splitted=line.split("\t")
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
330 if splitted[3]==projectID:
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
331 ret.append(line)
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
332
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
333 lines=ret[0:]
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
334
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
335 if (date!=""):
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
336 ret=[]
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
337 for line in lines:
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
338 splitted=line.split("\t")
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
339 if splitted[0]>=date:
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
340 ret.append(line)
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
341
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
342
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
343 lines=ret[0:]
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
344
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
345 txt= "".join(lines)
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
346 fh.close()
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
347
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
348
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
349
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
350
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
351 return txt
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
352
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
353 #In der Anzeige soll der Name der zitierten Personen in Klartext angezeigt werden, ausserdem die Varianten, wie sie tatsaechlich
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
354 #in den Projekten benutzt werden
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
355
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
356
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
357 def addPersonAndFirstNameFromTripleStore(self, personID):
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
358 mainName, sortName = self.getMainNameFromTripleStore(personID) # hole die hauptbezeichnung aus dem triplestore
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
359 personNames = []
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
360 logging.debug("get person:"+ personID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
361 logging.debug("names:"+repr(mainName)+":"+ repr(sortName))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
362
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
363 projects=self.persons2Projects.get(personID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
364 logging.debug(repr(projects))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
365 if projects is None:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
366 projects=[]
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
367
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
368 for project in projects: #hole die personen aus dem projekte
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
369 logging.debug("Found:project:" + project)
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
370 namesInProject = self.projectPersons.get(project)
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
371 for nameInProjectTuple in namesInProject:
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
372 logging.debug(repr(nameInProjectTuple))
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
373 nameInProject = nameInProjectTuple[1]
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
374 logging.debug(nameInProjectTuple[0] + "??" + personID)
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
375 if nameInProjectTuple[0] == personID:
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
376 logging.debug("changing")
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
377 if mainName == "": # es gibt keinen Eintrag im Triplestore fuer name (sollte eigentlich nicht sein, ist dann ein Fehler dort)
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
378 mainName = nameInProject #nimm dann aber den ersten aus den projekten
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
379 if nameInProject != mainName:
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
380 personNames.append(nameInProject)
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
381
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
382 logging.debug(str(mainName) + "- foundalso :" + ",".join(personNames))
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
383 self.personIDtoNames.update({personID:(mainName, personNames)})
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
384 self.personsIDForSortFull.append((personID, sortName))
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
385
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
386
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
387
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
388 def generateSortingOrderForPersonIDs(self):
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
389 def sort(x,y):
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
390 logging.debug("sort:")
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
391 logging.debug((x[1][0],y[1][0]))
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
392 return cmp(x[1][0],y[1][0])
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
393
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
394 self.personsIDForSortFull.sort(cmp=sort)
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
395
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
396 self.personsIDForSort=[x[0] for x in self.personsIDForSortFull]
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
397
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
398 self.personIDtoNames=self.personIDtoNames # make clear that it has changed #TODO: change this to variablen with names _p
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
399
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
400 security.declareProtected('View management screens','collectPersonNamesToIds')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
401 def collectPersonNamesToIds(self):
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
402 """Ordne Namen aus dem Triplestore bzw. die vergebenenden Label den Personen-Ids zu."""
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
403 #sollte z.B. gemacht werden, wenn im Triplestore editiert wurde.
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
404 self.personIDtoNames=OOBTree() # loesche alle
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
405 self.personsIDForSort=[]
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
406 self.personsIDForSortFull=[]
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
407 for personID in self.persons2Projects:
6
fcab446bca79 minor bug in MPIWG-Thesaurus
dwinter
parents: 5
diff changeset
408 self.addPersonAndFirstNameFromTripleStore(personID)
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
409
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
410
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
411
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
412
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
413 #sortiere personIDs nach erstmal nach Nachnamene TODO: sortiere nach name,vorname
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
414
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
415 self.generateSortingOrderForPersonIDs();
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
416 # def sort(x,y):
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
417 # logging.debug("sort:")
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
418 # logging.debug((x[1][0],y[1][0]))
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
419 # return cmp(x[1][0],y[1][0])
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
420 #
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
421 # self.personsIDForSortFull.sort(cmp=sort)
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
422 #
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
423 # self.personsIDForSort=[x[0] for x in self.personsIDForSortFull]
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
424 #
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
425 # self.personIDtoNames=self.personIDtoNames # make clear that it has changed #TODO: change this to variablen with names _p
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
426 #
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
427 #Hole die Namen, die einer personID zugeordnet sind.
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
428 def getNamesFromID(self,personID):
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
429 personID=personID.rstrip().lstrip() #make sure no spaces
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
430 logging.debug("<"+personID+">")
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
431 retStr=""
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
432
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
433 retStr+=self.personIDtoNames.get(personID,[personID])[0] # hole die Hauptbezeichnung, falls keine angeben ist, wird die ID ausgegeben, das is jedoch ein Felher in den Daten!!
8
dwinter
parents: 7
diff changeset
434 #additionalNames = self.personIDtoNames.get(personID,['',[]])[1]
dwinter
parents: 7
diff changeset
435 #if len(additionalNames)>0:
dwinter
parents: 7
diff changeset
436 # retStr+=" ("+",".join(additionalNames)+","+")"
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
437 return retStr
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
438
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
439
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
440 #Hole die Hauptnamemsansetzung aus dem Triplestore ),falls vorhanden, wenn nicht ist der String leer.
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
441 #ausserdem einen Namen zum sortieren, = Tupel(nachname, vorname)
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
442 def getMainNameFromTripleStore(self,personID):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
443
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
444
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
445 cmdString ="""select * where { <%s> <http://xmlns.com/foaf/0.1/name> ?name}"""%personID
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
446
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
447 names= self.callSparql(cmdString)
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
448
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
449 cmdString ="""select * where { <%s> <http://xmlns.com/foaf/0.1/lastName> ?name}"""%personID
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
450
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
451 lastName= self.callSparql(cmdString)
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
452
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
453 cmdString ="""select * where { <%s> <http://xmlns.com/foaf/0.1/firstName> ?name}"""%personID
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
454
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
455 firstName= self.callSparql(cmdString)
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
456
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
457 return names,(lastName,firstName)
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
458
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
459
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
460 def callSparqlAll(self,cmdString):
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
461 """list of results"""
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
462 auth_handler = urllib2.HTTPBasicAuthHandler()
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
463 auth_handler.add_password(realm='sparql',
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
464 uri=self.virtuosoServer+"/sparql",
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
465 user=self.virtuosoDAVUser,
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
466 passwd=self.virtuosoDAVPW)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
467
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
468 opener = urllib2.build_opener(auth_handler)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
469 opener.addheaders = [('Content-Type','application/sparql-query')]
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
470
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
471 logging.debug(cmdString)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
472 try:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
473 logging.debug(self.virtuosoServer+"/sparql?" + urllib.urlencode({'query':cmdString,'default-graph-uri':self.virtuosoGraph,'named-graph-uri':'','format':'text/csv'}))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
474 #r= opener.open(self.virtuosoServer+"/sparql", urllib.urlencode({'query':cmdString,'default-graph-uri':self.virtuosoGraph,'named-graph-uri':'','format':'text/csv'}))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
475 r= opener.open(self.virtuosoServer+"/sparql", urllib.urlencode({'query':cmdString,'default-graph-uri':'','named-graph-uri':'','format':'text/csv'}))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
476 namesTxt=r.read()
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
477 except urllib2.URLError, e:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
478 logging.error(e.code)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
479 logging.error(e.read())
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
480
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
481
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
482 return
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
483 logging.debug(namesTxt)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
484 names=namesTxt.split("\n")
11
dwinter
parents: 9
diff changeset
485 if len(names) < 2: #in der ersten Zeile stehen bei der Rueckgabe die Spaltennamen, <2 heiss also es gibt keinen Eintrag
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
486 return []
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
487
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
488 ret=[]
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
489 for name in names[1:]:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
490 line=[]
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
491 for entry in name.split("\",\""):
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
492
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
493 line.append(entry.replace('"',''));
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
494 ret.append(line);
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
495 return ret;
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
496
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
497 def callSparql(self,cmdString):
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
498
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
499 auth_handler = urllib2.HTTPBasicAuthHandler()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
500 auth_handler.add_password(realm='sparql',
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
501 uri=self.virtuosoServer+"/sparql",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
502 user=self.virtuosoDAVUser,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
503 passwd=self.virtuosoDAVPW)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
504
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
505 opener = urllib2.build_opener(auth_handler)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
506 opener.addheaders = [('Content-Type','application/sparql-query')]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
507
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
508 logging.debug(cmdString)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
509 try:
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
510 logging.debug(self.virtuosoServer+"/sparql?" + urllib.urlencode({'query':cmdString,'default-graph-uri':self.virtuosoGraph,'named-graph-uri':'','format':'text/csv'}))
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
511 #r= opener.open(self.virtuosoServer+"/sparql", urllib.urlencode({'query':cmdString,'default-graph-uri':self.virtuosoGraph,'named-graph-uri':'','format':'text/csv'}))
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
512 r= opener.open(self.virtuosoServer+"/sparql", urllib.urlencode({'query':cmdString,'default-graph-uri':'','named-graph-uri':'','format':'text/csv'}))
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
513 namesTxt=r.read()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
514 except urllib2.URLError, e:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
515 logging.error(e.code)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
516 logging.error(e.read())
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
517
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
518
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
519 return
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
520 logging.debug(namesTxt)
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
521 names=namesTxt.split("\n")
11
dwinter
parents: 9
diff changeset
522 if len(names) < 2: #in der ersten Zeile stehen bei der Rueckgabe die Spaltennamen, <2 heiss also es gibt keinen Eintrag
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
523 return
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
524
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
525 return names[1].replace('"','') # wir nehmen nur den ersten treffer
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
526
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
527
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
528 security.declareProtected('View management screens','changeTags')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
529 def changeTags(self,projectID,approaches=[],disciplines=[],periods=[],spaces=[],technologies=[],transfers=[],RESPONSE=None):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
530 """change tags"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
531 self.changeTagFromList(projectID,"approaches", approaches)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
532 self.changeTagFromList(projectID,"disciplines", disciplines)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
533 self.changeTagFromList(projectID,"periods", periods)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
534 self.changeTagFromList(projectID,"spaces", spaces)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
535 self.changeTagFromList(projectID,"technologies", technologies)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
536 self.changeTagFromList(projectID,"transfers", transfers)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
537
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
538 self.projectObjects=self.projectObjects #necessesary to make the object persistent after the first call
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
539 self.projectHistoricalPlaces=self.projectHistoricalPlaces #necessesary to make the object persistent after the first call
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
540 self.projectPersons=self.projectPersons #necessesary to make the object persistent after the first call
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
541 self.projectSuggestedTags=self.projectSuggestedTags
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
542
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
543 self.persons2Projects=self.persons2Projects
3
6f4b30846fed Minor changes in deleteAllObjects
dwinter
parents: 2
diff changeset
544 self.objects2Projects=self.objects2Projects
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
545 self.historicalPlaces2Projects=self.historicalPlaces2Projects
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
546 self.suggestedTags2Projects=self.suggestedTags2Projects;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
547
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
548 self.suggestedPersons=self.suggestedPersons;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
549
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
550 security.declareProtected('View management screens','deleteAllTags')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
551 def deleteAllTags(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
552 """deleteAllTags - TODO: take this out!!,"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
553 setattr(self,"tags",None)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
554
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
555 return "DONE!"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
556
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
557 security.declareProtected('View management screens','deleteAllPersons')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
558 def deleteAllPersons(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
559 """deleteAllTags - TODO: take this out!!,"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
560 self.projectPersons= OOBTree()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
561 self.persons2Projects= OOBTree()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
562 self.personIDtoNames=OOBTree()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
563 self.suggestedPersons= OOBTree(); #TODO: das sollte die ueberfluessig werde und nur im triple store stehen.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
564
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
565
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
566 return "DONE!"
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
567
3
6f4b30846fed Minor changes in deleteAllObjects
dwinter
parents: 2
diff changeset
568 security.declareProtected('View management screens','deleteAllObjects')
6f4b30846fed Minor changes in deleteAllObjects
dwinter
parents: 2
diff changeset
569 def deleteAllObjects(self):
6f4b30846fed Minor changes in deleteAllObjects
dwinter
parents: 2
diff changeset
570 """deleteAllTags - TODO: take this out!!,"""
6f4b30846fed Minor changes in deleteAllObjects
dwinter
parents: 2
diff changeset
571 logging.debug("delete all objects")
6f4b30846fed Minor changes in deleteAllObjects
dwinter
parents: 2
diff changeset
572 self.projectObjects= OOBTree()
6f4b30846fed Minor changes in deleteAllObjects
dwinter
parents: 2
diff changeset
573 self.objects2Projects=OOBTree()
6f4b30846fed Minor changes in deleteAllObjects
dwinter
parents: 2
diff changeset
574
6f4b30846fed Minor changes in deleteAllObjects
dwinter
parents: 2
diff changeset
575
6f4b30846fed Minor changes in deleteAllObjects
dwinter
parents: 2
diff changeset
576 return "DONE!"
6f4b30846fed Minor changes in deleteAllObjects
dwinter
parents: 2
diff changeset
577
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
578 def changeTagFromList(self,projectID,tagType,tagList):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
579
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
580 logging.debug("changing:"+projectID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
581 logging.debug("asking tag::"+tagType)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
582 if type(tagList) is not ListType:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
583 tagList=[tagList]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
584
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
585
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
586 tags = getattr(self,"tags",None)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
587 if tags is None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
588 logging.debug("Create new tags")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
589 tags=OOBTree()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
590 setattr(self,"tags",tags)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
591
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
592
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
593 tagsStored=tags.get(tagType,None)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
594 if tagsStored is None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
595 tagsStored=OOBTree();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
596
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
597
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
598
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
599 for tag in tagsStored.keys(): #gehe durch alle gespeichteren tags
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
600 logging.debug("checking:"+tag)
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
601 projectsOfTag = tagsStored.get(tag,None)
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
602 logging.debug(projectsOfTag)
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
603 if projectsOfTag is None:
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
604 projectsOfTag=OOSet()
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
605
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
606 if tag in tagList: #dieser ist getagged
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
607 projectsOfTag.update([projectID]);
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
608 self.storeChange("added",projectID,tag)
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
609 tagList.remove(tag);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
610 else:
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
611 if projectsOfTag.has_key(projectID):
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
612 projectsOfTag.remove(projectID);
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
613 self.storeChange("remove",projectID,tag)
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
614
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
615 tagsStored.update({tag:projectsOfTag});
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
616
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
617 for tag in tagList: # alle Tags, die nicht abgearbeitet worden sind, muessen noch angelegt werden
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
618 logging.debug("adding:"+tag)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
619 newApproach=OOSet()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
620 newApproach.update([projectID]);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
621 tagsStored.insert(tag, newApproach);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
622
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
623 tags.update({tagType:tagsStored})
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
624
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
625 transaction.commit()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
626
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
627 def getTitle(self,entry):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
628 return entry.title
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
629
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
630 def getEntriesFormatted(self,entries,formatType):
12
e7733b6ba343 template for the levels in overview now needed.
dwinter
parents: 11
diff changeset
631 errorString="<H1>template with name <em>levelFormatted</em> does not exist in the thesaurus folder!"
e7733b6ba343 template for the levels in overview now needed.
dwinter
parents: 11
diff changeset
632 if not hasattr(self,'levelFormatted'):
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
633 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','levelFormatted.zpt')).__of__(self)
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
634 return pt(level1_entries=entries,type=formatType)
13
51ed6ad43383 template for the levels in overview added in zpt
dwinter
parents: 12
diff changeset
635
12
e7733b6ba343 template for the levels in overview now needed.
dwinter
parents: 11
diff changeset
636
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
637 return self.levelFormatted(level1_entries=entries,type=formatType)
12
e7733b6ba343 template for the levels in overview now needed.
dwinter
parents: 11
diff changeset
638
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
639 def getEntries(self,entry):
17
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
640 logging.debug("GETENTRY:"+repr(entry))
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
641 return entry.entries
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
642
1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
643 #nimmt ein eine Text der Form
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
644 # TAG1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
645 # ---
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
646 # SUBTAG1_1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
647 # SUBTAG1_2
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
648 # ---
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
649 # TAG2
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
650 # ---
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
651 # SUBTAG2_1
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
652 # SUBTAG2_2
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
653 #....
95e1e37915c6 thesaurus manager added
dwinter
parents: 0
diff changeset
654 # und erzeugt daraus eine entsprechende Liste von Entries
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
655 def getEntriesFromTxt(self,txt):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
656 apps=[]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
657 lines=txt.split("\n");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
658 level=False
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
659 for line in lines:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
660 line=line.rstrip().lstrip()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
661 if line=="":
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
662 continue
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
663 if line=="---":
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
664
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
665 if level:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
666 level=False
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
667 else:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
668 level=True
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
669 else:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
670 if not level:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
671 entry=Entry(line,[])
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
672 apps.append(entry)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
673 else:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
674 entry.entries.append(Entry(line))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
675
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
676 return apps[0:]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
677
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
678 def getApproaches(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
679
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
680 self.tagList=self.getEntriesFromTxt(self.approachesTxt)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
681 return self.tagList
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
682
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
683
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
684 def getTagsJSON(self,projectID,tagType,RESPONSE=None):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
685 """get all selected tagList"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
686 logging.debug("asking:"+projectID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
687 logging.debug("asking tag::"+tagType)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
688 retList=[]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
689 tags = getattr(self,"tags",None)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
690 if tags is None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
691 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
692
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
693 tagsStored=tags.get(tagType,None)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
694 if tagsStored is None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
695 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
696
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
697 for tag in tagsStored.keys(): #gehe durch alle gespeichteren approached
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
698 logging.debug("checking:"+tag)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
699 currentTag = tagsStored.get(tag,None)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
700 if currentTag is None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
701 continue
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
702 if currentTag.has_key(projectID):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
703 retList.append(""" "%s" """%tag)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
704
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
705 if RESPONSE:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
706 RESPONSE.setHeader('Content-Type', "application/json")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
707
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
708 logging.debug(retList)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
709 return "["+",".join(retList)+"]"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
710
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
711 def getDisciplines(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
712
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
713 self.disciplines=self.getEntriesFromTxt(self.disciplinesTxt)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
714 return self.disciplines
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
715
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
716
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
717 def getObjectsJSON(self,term="",RESPONSE=None):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
718 """ get all stored objects as json list starting with term"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
719 term=term.lower();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
720 logging.debug("Asking:"+term)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
721 #objectList=["baus","berg","lurg"]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
722 objects = self.objects2Projects;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
723
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
724 objectList= [x for x in objects.keys()]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
725
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
726 logging.debug("Create:"+repr(objectList))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
727 retList=[]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
728 for object in objectList:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
729 if object.find(term)>-1:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
730 retList.append(""" "%s" """%object)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
731 ret="["
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
732 ret+=",".join(retList)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
733 ret+="]"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
734 logging.debug("Objects:"+ret)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
735 if RESPONSE:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
736 RESPONSE.setHeader('Content-Type', "application/json")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
737 return ret
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
738
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
739
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
740 def getHistoricalPlacesJSON(self,term="",RESPONSE=None):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
741 """ get all stored historicalPlaces as json list starting with term"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
742 term=term.lower();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
743 logging.debug("Asking:"+term)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
744 #historicalPlaceList=["baus","berg","lurg"]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
745 historicalPlaces = self.historicalPlaces2Projects;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
746
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
747 historicalPlaceList= [x for x in historicalPlaces.keys()]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
748
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
749 logging.debug("Create:"+repr(historicalPlaceList))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
750 retList=[]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
751 for historicalPlace in historicalPlaceList:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
752 if historicalPlace.find(term)>-1:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
753 retList.append(""" "%s" """%historicalPlace)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
754 ret="["
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
755 ret+=",".join(retList)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
756 ret+="]"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
757 logging.debug("historicalPlaces:"+ret)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
758 if RESPONSE:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
759 RESPONSE.setHeader('Content-Type', "application/json")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
760 return ret
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
761
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
762
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
763 def getPeriods(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
764
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
765 self.periodes=self.getEntriesFromTxt(self.periodsTxt)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
766 return self.periodes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
767
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
768 def getSpaces(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
769
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
770 self.spaces=self.getEntriesFromTxt(self.spacesTxt)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
771 return self.spaces
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
772
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
773 def getTechnologies(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
774
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
775 self.technologies=self.getEntriesFromTxt(self.technologiesTxt)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
776 return self.technologies
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
777
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
778 def getKnowledgeTransfers(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
779
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
780 self.knowledgeTransfers=self.getEntriesFromTxt(self.knowledgeTransfersTxt)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
781 return self.knowledgeTransfers
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
782
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
783
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
784 def getObjectsFromProject(self,projectID):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
785 return self.getFromProject(self.projectObjects,projectID);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
786
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
787 def getHistoricalPlacesFromProject(self,projectID):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
788 return self.getFromProject(self.projectHistoricalPlaces,projectID);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
789
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
790 def getSuggestedTagsFromProject(self,projectID):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
791 return self.getFromProject(self.projectSuggestedTags,projectID);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
792
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
793
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
794 def getPersonsFromProject(self,projectID):
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
795 #hole alle personenID die zu einem Projekt gehoeren.
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
796 #zurueckgegeben wird ein OOSet()
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
797 return self.getFromProject(self.projectPersons,projectID);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
798
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
799 def getFromProject(self,objects,projectID):
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
800 #holt die zu projectID gehoerigen objekte aus dem objects-set.
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
801 #oder legt einen neuen leeren Satz zu dieser ProjektID an.
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
802 #zuruecgegeben wird ein OOSet()
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
803 if objects.has_key(projectID): #wenn zu der ProjektID schon etwas abgespeichter ist, gieb es zurueck
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
804 logging.debug("key exists:"+projectID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
805 persons=objects.get(projectID);
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
806 else: # andernfalls lege einen neuen Satz an.
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
807 persons=OOSet()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
808 objects.update({projectID:persons})
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
809 logging.debug("key does not exists:"+projectID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
810
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
811
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
812 return persons
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
813
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
814 def getHistoricalPlacesFromProjectAsHTML(self,projectID):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
815 """gertobjects"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
816 return self.getFromProjectAsHTML(self.projectHistoricalPlaces, projectID, "HistoricalPlace");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
817
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
818 def getObjectsFromProjectAsHTML(self,projectID):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
819 """gertobjects"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
820 return self.getFromProjectAsHTML(self.projectObjects, projectID, "Object");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
821
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
822 def getPersonsFromProjectAsHTML(self,projectID):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
823 """getpersons"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
824 return self.getFromProjectAsHTML(self.projectPersons, projectID, "Person");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
825
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
826
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
827 def getFromProjectAsHTML(self,objects,projectID,type):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
828 """getpersons"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
829 ret=""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
830 if objects.has_key(projectID):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
831 persons=objects.get(projectID);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
832 else:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
833 persons=OOSet()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
834
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
835
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
836 for person in persons:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
837 ret+="""<div class="removeButton">
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
838 <span>%s </span><div style="display:inline" class="remove%s"><span style="display:none" class="removeValue">%s</span>remove</div>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
839 </div>"""%(person[1],type,person[0])
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
840
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
841
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
842 # ret+="""<div>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
843 # <input type="checkbox" name="persons_remove"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
844 # value="%s">
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
845 # <span>%s</span>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
846 # </div>"""%(person[0],person[1])
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
847 #
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
848 logging.debug(type+":"+ret)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
849 return ret
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
850
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
851 security.declareProtected('View management screens','removeHistoricalPlaceFromProject')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
852 def removeHistoricalPlaceFromProject(self,projectID,value):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
853 """remove"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
854 logging.debug("removeHP:"+projectID+":"+value);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
855
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
856 HistoricalPlaces = self.getHistoricalPlacesFromProject(projectID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
857 for HistoricalPlace in HistoricalPlaces.keys():
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
858
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
859 logging.debug("trying:"+repr(HistoricalPlace[0])+"::"+repr(value)+"__")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
860 if HistoricalPlace[0]==value:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
861 logging.debug("---removed!")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
862 HistoricalPlaces.remove(HistoricalPlace)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
863
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
864 self.projectHistoricalPlaces.update({projectID:HistoricalPlaces})
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
865 retstring = self.getHistoricalPlacesFromProjectAsHTML(projectID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
866 logging.debug(retstring)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
867 return retstring
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
868
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
869 security.declareProtected('View management screens','removeObjectFromProject')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
870 def removeObjectFromProject(self,projectID,value):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
871 """remove"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
872 logging.debug("remove:"+projectID+":"+value);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
873
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
874
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
875 self.storeChange("removeObject",projectID,value)
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
876
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
877 objects = self.getObjectsFromProject(projectID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
878 for object in objects.keys():
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
879
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
880 logging.debug("trying:"+repr(object[0])+"::"+repr(value)+"__")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
881 if object[0]==value:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
882 logging.debug("---removed!")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
883 objects.remove(object)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
884
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
885 #now also delete the project from the object.
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
886 objectsOfPerson=self.objects2Projects.get(object[0])
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
887
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
888
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
889 if projectID in list(objectsOfPerson):
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
890 objectsOfPerson.remove(projectID)
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
891 #self.persons2Projects.update({person:projectsList})
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
892 if (len(objectsOfPerson)==0): #loesche person aus der liste wenn keine Projekte dazu existieren.
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
893 del self.objects2Projects[object[0]]
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
894
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
895 self.projectObjects.update({projectID:objects})
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
896 retstring = self.getObjectsFromProjectAsHTML(projectID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
897 logging.debug(retstring)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
898 return retstring
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
899
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
900 security.declareProtected('View management screens','removePersonFromProject')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
901 def removePersonFromProject(self,projectID,value):
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
902 """remove a person from the projeckt"""
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
903 logging.debug("remove:"+projectID+":"+value);
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
904 self.storeChange("removePerson",projectID,value)
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
905
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
906 persons = self.getPersonsFromProject(projectID) # hole alle personen die mit dem Projekt verbunden sind.
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
907 for person in persons.keys():
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
908
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
909 logging.debug("trying:"+repr(person[0])+"::"+repr(value)+"__")
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
910 if person[0]==value:#person ist die zuloeschende, dann raus damit
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
911
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
912 logging.debug("---removed!")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
913 persons.remove(person)
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
914
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
915 #now also delete the project from the person.
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
916 projectsOfPerson=self.persons2Projects.get(person[0])
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
917 logging.debug(projectsOfPerson)
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
918 if projectID in list(projectsOfPerson):
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
919 projectsOfPerson.remove(projectID)
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
920 #self.persons2Projects.update({person:projectsList})
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
921 if (len(projectsOfPerson)==0): #loesche person aus der liste wenn keine Projekte dazu existieren.
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
922 del self.persons2Projects[person[0]]
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
923
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
924
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
925 #self.projectPersons.update({projectID:persons})
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
926 retstring = self.getPersonsFromProjectAsHTML(projectID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
927 logging.debug(retstring)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
928 return retstring
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
929
11
dwinter
parents: 9
diff changeset
930
dwinter
parents: 9
diff changeset
931 #fuegt die neue Person zur personIDtoNames hinzu, fuer die spaetere Anzeige in der Personenliste
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
932 def addNameTOPersonIDNames(self,personID,label):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
933 personName = self.personIDtoNames.get(personID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
934 if personName==None: # Anlegen falls noch nicht existent
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
935 personName=(label,[])
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
936 else:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
937 if (not label in personName[1]) and (not label==personName[0]): # hinzufuegen falls der neuen name noch nicht als bezeichnugn fuer personID eingetragen ist
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
938 personName[1].append(label)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
939
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
940 self.personIDtoNames.update({personID:personName})
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
941
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
942 security.declareProtected('View management screens','addPersonToProject')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
943 def addPersonToProject(self,projectID,value,label):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
944 """ add a person so the project"""
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
945 self.storeChange("addPerson",projectID,value+":"+label)
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
946
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
947 persons=self.getPersonsFromProject(projectID);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
948
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
949 logging.debug("adding:"+projectID+":"+value+":"+label);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
950
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
951 persons.insert([value,label])
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
952 self.projectPersons.update({projectID:persons})
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
953
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
954 for personTuple in persons:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
955 #hole die abgespeicherten Projekte zu einer Person
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
956 person=personTuple[0] #hole die ID
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
957
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
958
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
959 if getattr(self,"persons2Projects",None)==None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
960 setattr(self,"persons2Projects",OOBTree())
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
961
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
962 projects = self.persons2Projects.get(person,None)
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
963 logging.debug("found projects:"+ repr(projects))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
964 if projects is None: #person hatte noch keine projekte
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
965 projects=OOSet();
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
966
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
967 projects.insert(projectID )
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
968 logging.debug("update:"+person)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
969 self.persons2Projects.update({person:projects})
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
970
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
971 self.addPersonAndFirstNameFromTripleStore(person)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
972 self.generateSortingOrderForPersonIDs();
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
973
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
974 self.addNameTOPersonIDNames(value,label)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
975 retstring = self.getPersonsFromProjectAsHTML(projectID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
976 logging.debug(retstring)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
977 transaction.commit()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
978 return retstring
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
979
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
980
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
981
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
982 def rearangePersonIDsHTML(self,REQUEST=None):
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
983 """setze neue ID zu personen"""
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
984 ret=[]
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
985 for personID in self.persons2Projects.keys():
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
986 logging.debug(personID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
987
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
988 masterID,name=self.findMasterIDAndName(personID.rstrip().lstrip())
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
989 logging.debug(" masterID -appending")
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
990 logging.debug(repr(name))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
991 if len(name)==0:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
992 name=['']
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
993 ret.append((personID,self.personIDtoNames.get(personID,[''])[0],masterID,self.personIDtoNames.get(masterID,name)[0]))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
994
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
995
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
996 if REQUEST:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
997 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','rearrangePersons.zpt')).__of__(self)
8
dwinter
parents: 7
diff changeset
998 return pt(changeList=ret,lookupUrl=self.PERSONS_LOOKUP_URL,editURL=self.EDIT_URL);
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
999 else:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1000 return ret;
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1001
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1002 def rearangePersonIDs(self,REQUEST):
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1003 """unify a list of persons"""
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1004
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1005 argv=REQUEST.form;
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1006 logging.debug(repr(argv))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1007 changes=argv['changes']
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1008 if isinstance(changes,str):
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1009 changes=[changes]
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1010
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1011 changeList=self.rearangePersonIDsHTML()
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1012 personToMaster={}
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1013 logging.debug("changelist:"+repr(changeList))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1014 #aendere person2project
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1015 for change in changes:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1016 changeItem=changeList[int(change)];
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1017 masterID=argv['newID_'+change].lstrip().rstrip() #make sure no spaces
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1018 personID=changeItem[0]
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1019
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1020 personToMaster[personID]=masterID
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1021 masterIDProjects = self.persons2Projects.get(masterID,None);
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1022 if masterIDProjects==None:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1023 masterIDProjects=OOSet();
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1024 #ret.append((personID,self.personIDtoNames.get(personID,[''])[0],masterID,self.personIDtoNames.get(masterID,[''])[0]))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1025
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1026 oldProjects= self.persons2Projects.get(personID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1027 logging.debug("personID:"+repr(personID))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1028 logging.debug("masterID:"+repr(masterID))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1029 logging.debug("keys:"+repr(self.persons2Projects.keys()))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1030 logging.debug("oldProjects:"+repr(oldProjects))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1031 masterIDProjects.update(oldProjects)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1032 self.persons2Projects.update({masterID:masterIDProjects})
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1033 self.persons2Projects.pop(personID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1034
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1035 self.addPersonAndFirstNameFromTripleStore(masterID) #addpersontotiplestore
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1036
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1037 logging.debug("Change:" +personID+":"+ masterID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1038
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1039 if personID!=masterID:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1040 self.addSameAsRelationToTripleStore(personID,masterID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1041
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1042 #aendere nun projectperson
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1043 logging.debug(personToMaster)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1044 for project in self.projectPersons.keys():
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1045 personsNew=OOSet()
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1046
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1047 persons=self.projectPersons.get(project)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1048 for person in persons:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1049 personsNew.insert([personToMaster.get(person[0],person[0]),person[1]])
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1050 logging.debug("REPLACE in:"+project+":" +repr(person)+" by "+ repr(personToMaster.get(person[0],person[0])))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1051 self.projectPersons.update({project:personsNew})
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1052
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1053 self.generateSortingOrderForPersonIDs(); #now sort the new names
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1054 return personToMaster
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1055 #fuehre personen zusammen die ueber owl:sameAs verbunden sind
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1056 def getUnifyPersonsList(self,REQUEST=None):
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1057 """vereinheitlichung der personen auf eine ID aus der GND, wenn moeglich"""
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1058 ret=[]
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1059 for personID in self.persons2Projects.keys():
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1060 masterID,name=self.findMasterIDAndName(personID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1061 logging.debug("masterID:"+masterID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1062 if (masterID is not None) and (masterID is not "") and (not personID==masterID):
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1063 #masterIDProjects = self.persons2Projects.get(masterID,None);
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1064 ##if masterIDProjects==None:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1065 # masterIDProjects=OOSet();
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1066 logging.debug(" masterID -appending")
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1067 logging.debug(repr(name))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1068
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1069
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1070 ret.append((personID,self.personIDtoNames.get(personID,[''])[0],masterID,self.personIDtoNames.get(masterID,name)[0]))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1071 #masterIDProjects.update(self.persons2Projects.get(personID));
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1072 #self.persons2Projects.update({masterID:masterIDProjects});
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1073
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1074
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1075 if REQUEST:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1076 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','unifyPersons.zpt')).__of__(self)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1077 return pt(changeList=ret);
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1078
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1079 else:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1080 return ret;
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1081
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1082 def unifyPersons(self,changes,REQUEST=None):
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1083 """unify a list of persons"""
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1084
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1085 if isinstance(changes,str):
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1086 changes=[changes]
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1087
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1088 changeList=self.getUnifyPersonsList();
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1089 personToMaster={}
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1090 logging.debug("changelist:"+repr(changeList))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1091 #aendere person2project
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1092 for change in changes:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1093 changeItem=changeList[int(change)];
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1094 masterID=changeItem[2]
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1095 personID=changeItem[0]
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1096
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1097 personToMaster[personID]=masterID
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1098 masterIDProjects = self.persons2Projects.get(masterID,None);
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1099 if masterIDProjects==None:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1100 masterIDProjects=OOSet();
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1101 #ret.append((personID,self.personIDtoNames.get(personID,[''])[0],masterID,self.personIDtoNames.get(masterID,[''])[0]))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1102
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1103 oldProjects= self.persons2Projects.get(personID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1104 logging.debug("personID:"+repr(personID))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1105 logging.debug("masterID:"+repr(masterID))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1106 logging.debug("keys:"+repr(self.persons2Projects.keys()))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1107 logging.debug("oldProjects:"+repr(oldProjects))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1108 masterIDProjects.update(oldProjects)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1109 self.persons2Projects.update({masterID:masterIDProjects})
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1110 self.persons2Projects.pop(personID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1111
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1112 self.addPersonAndFirstNameFromTripleStore(masterID) #addpersontotiplestore
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1113
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1114 logging.debug("Change:" +personID+":"+ masterID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1115
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1116 #aendere nun projectperson
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1117 logging.debug(personToMaster)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1118 for project in self.projectPersons.keys():
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1119 personsNew=OOSet()
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1120
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1121 persons=self.projectPersons.get(project)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1122 for person in persons:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1123 personsNew.insert([personToMaster.get(person[0],person[0]),person[1]])
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1124 logging.debug("REPLACE in:"+project+":" +repr(person)+" by "+ repr(personToMaster.get(person[0],person[0])))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1125 self.projectPersons.update({project:personsNew})
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1126
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1127 self.generateSortingOrderForPersonIDs(); #now sort the new names
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1128 return personToMaster
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1129
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1130
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1131
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1132 def findMasterIDAndName(self,ressourceID):
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1133 queryString="""select *
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1134 FROM <file://mpiwg_persons_dnb.rdf>
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1135 FROM <file://mpiwg_persons_2.rdf>
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1136 FROM <file:///GND.rdf>
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1137 FROM <http://identifiedNames>
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1138 where {
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1139 ?person <http://www.w3.org/2002/07/owl#sameAs> <%s>.
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1140
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1141 ?ident <http://ontologies.mpiwg-berlin.mpg.de/authorities/namedIdentities/identifies_NamedEntity> ?person.
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1142 ?gnd crm:P1_is_identified_by ?ident.
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1143
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1144 ?gnd <http://RDVocab.info/ElementsGr2/dateOfBirth> ?birthDate.
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1145 ?gnd <http://RDVocab.info/ElementsGr2/dateOfDeath> ?deathDate.
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1146 ?person <http://xmlns.com/foaf/0.1/name> ?name.
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1147 ?person <http://xmlns.com/foaf/0.1/lastName> ?lastName.
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1148 ?person <http://xmlns.com/foaf/0.1/firstName> ?firstName.
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1149 }
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1150 """%ressourceID
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1151 entries = self.callSparqlAll(queryString);
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1152 if len(entries)>0:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1153 return entries[0][0],entries[0][5:8] #nur den ersten Treffer und nur die personID
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1154
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1155
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1156 return None,None
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1157
9
dwinter
parents: 8
diff changeset
1158 security.declareProtected('View','getPersonsWithProjectIDs')
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1159 def getPersonsWithProjectIDs(self,check=False):
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1160 """holt die getaggted Personen mit Projekten"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1161 persons = self.persons2Projects;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1162 ret={}
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1163
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1164 logging.debug("Check Person:"+repr(persons.keys()))
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1165 personsList=[x for x in persons.keys()]
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1166
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1167 def sort(x,y):
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1168 try:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1169 sortNrx=self.personsIDForSort.index(x)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1170 except:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1171 logging.warn("couldn't find personsIDForSort:"+x)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1172 sortNrx=0
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1173
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1174 try:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1175 sortNry=self.personsIDForSort.index(y)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1176 except:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1177 logging.warn("couldn't find personsIDForSort:"+y)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1178 sortNry=0
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1179 #logging.debug("INSORT***")
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1180 #logging.debug((sortNrx,sortNry))
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1181 return cmp(sortNrx,sortNry)
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1182
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1183 logging.debug("SORT***")
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1184 logging.debug(self.personsIDForSort)
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1185 logging.debug("SORT.list")
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1186 logging.debug(personsList)
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1187 personsList.sort(cmp=sort)
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1188 #for person in persons.keys():
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1189 logging.debug("AFTERSORT***")
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1190 logging.debug(personsList)
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1191 for person in personsList:
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1192 logging.debug("Check:"+person)
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1193 #TODO: person muss duch den namen von provider geholt werden
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1194 retlist=[]
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1195 projectsList=persons.get(person)
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1196 if projectsList is None:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1197 projectsList=[]
5
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1198 for projectID in list(projectsList): #list notwendig da projectList in der folgenden iteration veraendert wird.
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1199 if check: #teste ob im Projekt noch ein Verweis auf den Namen steht
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1200 #sollte eigentlich nicht sein.
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1201 personsProjects=self.getPersonsFromProject(projectID)
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1202 logging.debug("persons check mode")
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1203 personsProjectsCheck=[x[0] for x in personsProjects]
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1204 if not person in personsProjectsCheck: #falls es so ist korrigiere die Projektliste der Person
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1205 #loesche die person von projectListe
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1206 projectsList.remove(projectID)
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1207 persons.update({person:projectsList})
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1208
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1209 retlist.append(self.getProjectDetails(projectID))
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1210
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1211 if check and (len(projectsList)==0): #loesche person aus der liste wenn keine Projekte dazu existieren.
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1212 del persons[person]
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1213
2773140337ad Mangement der People f?r Tagging: verbessert.
dwinter
parents: 4
diff changeset
1214 ret[person]=retlist[0:]
4
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1215
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1216 logging.debug("AFTERSORT-ret***")
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1217 logging.debug(ret.keys())
fa8d698958f7 sorting by lastname
dwinter
parents: 3
diff changeset
1218 return ret,personsList
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1219
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1220 def getHistoricalPlacesWithProjectIDs(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1221 """holt die getaggted Personen mit Projekten"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1222 HistoricalPlaces = self.HistoricalPlaces2Projects;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1223 ret={}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1224 logging.debug("Check HistoricalPlace:"+repr(HistoricalPlaces.keys()))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1225 for HistoricalPlace in HistoricalPlaces.keys():
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1226 logging.debug("Check:"+HistoricalPlace)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1227 #TODO: HistoricalPlace muss duch den namen von provuder geholt werden
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1228 list=[]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1229 for projectID in HistoricalPlaces.get(HistoricalPlace):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1230 list.append(self.getProjectDetails(projectID))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1231
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1232 ret[HistoricalPlace]=list[0:]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1233 return ret
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1234
12
e7733b6ba343 template for the levels in overview now needed.
dwinter
parents: 11
diff changeset
1235 def getObjectsWithProjectIDsSortedkeys(self):
e7733b6ba343 template for the levels in overview now needed.
dwinter
parents: 11
diff changeset
1236
e7733b6ba343 template for the levels in overview now needed.
dwinter
parents: 11
diff changeset
1237 def sortF(x,y):
e7733b6ba343 template for the levels in overview now needed.
dwinter
parents: 11
diff changeset
1238 return cmp(x.lower(),y.lower())
e7733b6ba343 template for the levels in overview now needed.
dwinter
parents: 11
diff changeset
1239 keys = [x for x in self.getObjectsWithProjectIDs().keys()]
e7733b6ba343 template for the levels in overview now needed.
dwinter
parents: 11
diff changeset
1240 keys.sort(sortF)
e7733b6ba343 template for the levels in overview now needed.
dwinter
parents: 11
diff changeset
1241 return keys
e7733b6ba343 template for the levels in overview now needed.
dwinter
parents: 11
diff changeset
1242
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1243 def getObjectsWithProjectIDs(self):
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1244 """holt die getagten Personen mit Projekten"""
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1245 objects = self.objects2Projects;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1246 ret={}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1247 logging.debug("Check Object:"+repr(objects.keys()))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1248 for object in objects.keys():
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1249 logging.debug("Check:"+object)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1250 #TODO: object muss duch den namen von provuder geholt werden
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1251 list=[]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1252 for projectID in objects.get(object):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1253 list.append(self.getProjectDetails(projectID))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1254
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1255 ret[object]=list[0:]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1256 return ret
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1257
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
1258 security.declareProtected('View management screens','listAllSuggestedTags')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1259 def listAllSuggestedTags(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1260 """list all tags"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1261 ret="<html><body>"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1262 for projectID in self.projectSuggestedTags:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1263 ret+="<h3>"+projectID+"</h3><table>"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1264 for tags in self.projectSuggestedTags.get(projectID):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1265 ret+="<tr><td>"+tags[0]+"</td><td>"+tags[1].type+"</td><td>"+tags[1].comment+"</td><td>"+tags[1].userName+"</td></tr>"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1266 ret+="</table>"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1267 ret+="</body></html>"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1268 logging.debug(ret);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1269 return ret
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
1270
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
1271 security.declareProtected('View management screens','suggestTag')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1272 def suggestTag(self,projectID,tagName,tagComment,tagType,tagUserName):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1273 """suggest a new tag"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1274 """ add a person so the project"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1275 SuggestedTags=self.getSuggestedTagsFromProject(projectID);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1276
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1277 logging.debug("suggested:"+projectID+":"+tagName);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1278
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1279
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1280 #TODO: Im moment noch keine Zuordnung zu einer ID.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1281 newTag = SuggestedTag(tagName,tagComment,tagType,tagUserName)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1282 SuggestedTags.insert([tagName,newTag])
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1283 self.projectSuggestedTags.update({projectID:SuggestedTags})
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1284
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1285
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1286
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1287 for SuggestedTagTuple in SuggestedTags:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1288 #hole die abgespeicherten Projekte zu einer Person
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1289 person=SuggestedTagTuple[0] #hile die ID
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1290
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1291
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1292 if getattr(self,"SuggestedTags2Projects",None)==None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1293 setattr(self,"SuggestedTags2Projects",OOBTree())
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1294
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1295 projects = self.SuggestedTags2Projects.get(person,None)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1296
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1297 if projects==None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1298 projects=OOSet();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1299
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1300 projects.insert(projectID )
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1301 logging.debug("update:"+person)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1302 self.SuggestedTags2Projects.update({person:projects})
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1303
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1304
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1305
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1306 #retstring = self.getSuggestedTagsFromProjectAsHTML(projectID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1307 #logging.debug(retstring)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1308
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1309
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1310
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1311 #return retstring
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1312
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
1313 security.declareProtected('View management screens','addHistoricalPlaceToProject')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1314 def addHistoricalPlaceToProject(self,projectID,value):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1315 """ add a person so the project"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1316 HistoricalPlaces=self.getHistoricalPlacesFromProject(projectID);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1317
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1318 logging.debug("adding:"+projectID+":"+value);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1319
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1320
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1321 #TODO: Im moment noch keine Zuordnung zu einer ID.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1322 HistoricalPlaces.insert([value,value])
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1323 self.projectHistoricalPlaces.update({projectID:HistoricalPlaces})
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1324
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1325
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1326
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1327 for HistoricalPlaceTuple in HistoricalPlaces:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1328 #hole die abgespeicherten Projekte zu einer Person
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1329 person=HistoricalPlaceTuple[0] #hile die ID
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1330
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1331
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1332 if getattr(self,"HistoricalPlaces2Projects",None)==None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1333 setattr(self,"HistoricalPlaces2Projects",OOBTree())
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1334
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1335 projects = self.HistoricalPlaces2Projects.get(person,None)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1336
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1337 if projects==None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1338 projects=OOSet();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1339
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1340 projects.insert(projectID )
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1341 logging.debug("update:"+person)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1342 self.HistoricalPlaces2Projects.update({person:projects})
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1343
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1344
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1345
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1346 retstring = self.getHistoricalPlacesFromProjectAsHTML(projectID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1347 logging.debug(retstring)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1348
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1349
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1350
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1351 return retstring
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1352
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
1353 security.declareProtected('View management screens','addObjectToProject')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1354 def addObjectToProject(self,projectID,value):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1355 """ add a person so the project"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1356 objects=self.getObjectsFromProject(projectID);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1357
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1358 logging.debug("adding:"+projectID+":"+value);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1359
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1360 self.storeChange("addObject",projectID,value)
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1361
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1362 #TODO: Im moment noch keine Zuordnung zu einer ID.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1363 objects.insert([value,value])
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1364 self.projectObjects.update({projectID:objects})
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1365
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1366
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1367
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1368 for objectTuple in objects:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1369 #hole die abgespeicherten Projekte zu einer Person
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1370 person=objectTuple[0] #hile die ID
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1371
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1372
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1373 if getattr(self,"objects2Projects",None)==None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1374 setattr(self,"objects2Projects",OOBTree())
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1375
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1376 projects = self.objects2Projects.get(person,None)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1377
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1378 if projects==None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1379 projects=OOSet();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1380
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1381 projects.insert(projectID )
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1382 logging.debug("update:"+person)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1383 self.objects2Projects.update({person:projects})
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1384
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1385
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1386
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1387 retstring = self.getObjectsFromProjectAsHTML(projectID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1388 logging.debug(retstring)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1389
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1390
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1391
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1392 return retstring
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1393
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1394
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1395 def getProjectsWithTag(self,tagType,tagName):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1396 tags = getattr(self,"tags",None)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1397 if tags is None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1398 logging.debug("can't find Tags")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1399 return []
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1400
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1401
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1402
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1403 tagsStored=tags.get(tagType,None)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1404 if tagsStored is None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1405 logging.debug("can't find Tag:"+tagType)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1406 return []
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1407
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1408 projects = tagsStored.get(tagName,None)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1409 if projects is None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1410 logging.debug("can't find any projects for Tag:"+tagName+"("+tagType+")")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1411 return []
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1412
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1413 ret=[]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1414 for project in projects:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1415 logging.debug("found:"+project)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1416 ret.append(self.getProjectDetails(project))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1417
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1418 return ret
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1419
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1420 def getProjectDetails(self,getID):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1421 project=getattr(self.www_neu.projects,getID,None)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1422 if project is None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1423 logging.debug("no project!! " +getID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1424 return
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1425
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1426 link="/en/research/projects/"+getID
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1427
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1428 title=project.getContent("short_title")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1429 #persons=project.getPersonKeyList()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1430 persons=project.getContent('xdata_01')
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1431 logging.debug("%s %s %s"%(link,title,persons))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1432 return link,title,persons
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1433
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1434 # $.post("addNewPerson",{"projectID":
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1435 # $('#projectID').val(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1436 # "personName":$("#suggest_newPerson").val(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1437 # "personComment":$("#suggest_newPerson_comment").val()}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1438 #
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1439 # );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1440 #
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
1441
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
1442 security.declareProtected('View management screens','addAndCreateNewPerson')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1443 def addAndCreateNewPerson(self,projectID,personName,personComment,personUserName):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1444 """adds anew person to the project which is not in the authority file"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1445
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1446 id = random.randint(0, 1000000);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1447 idstring="http://ontologies.mpiwg-berlin.mpg.de/tempObjects/person/"+str(id)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1448 while self.suggestedPersons.has_key(idstring):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1449 id = random.randint(0, 1000000);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1450 #idstring="http://ontologies.mpiwg-berlin.mpg.de/tempObjects/person/"+str(id);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1451 idstring=self.TEMP_PERSON_NS+str(id);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1452
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1453
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1454 self.suggestedPersons.update({idstring:(personName,personComment,projectID,personUserName)})
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1455 self.createTempPersonInVirtuoso(projectID, idstring, personName, personComment) #TODO: add suername to the triplestore
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1456 return self.addPersonToProject(projectID, idstring, personName);
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
1457
7
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1458 def addSameAsRelationToTripleStore(self,personID,masterID):
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1459 cmdString ="insert in GRAPH <"+self.virtuosoGraph+"> {"
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1460 cmdString +="<%s> <http://www.w3.org/2002/07/owl#sameAs> <%s>."%(personID,masterID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1461 cmdString +="<%s> <http://www.w3.org/2002/07/owl#sameAs> <%s>."%(masterID,personID)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1462 cmdString+="}"
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1463
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1464 auth_handler = urllib2.HTTPBasicAuthHandler()
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1465 auth_handler.add_password(realm='sparql',
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1466 uri=self.virtuosoServer+"/sparql",
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1467 user=self.virtuosoDAVUser,
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1468 passwd=self.virtuosoDAVPW)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1469
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1470 opener = urllib2.build_opener(auth_handler)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1471 opener.addheaders = [('Content-Type','application/sparql-query')]
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1472
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1473 logging.debug(cmdString)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1474 try:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1475 r= opener.open(self.virtuosoServer+"/sparql", urllib.urlencode({'query':cmdString,'default-graph-uri':self.virtuosoGraph,'named-graph-uri':None}))
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1476 logging.debug(r.read())
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1477 except urllib2.URLError, e:
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1478 logging.error(e.code)
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1479 logging.error(e.read())
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1480 return
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1481
e21db3150dae manage persons
dwinter
parents: 6
diff changeset
1482
2
03c4e248b9e2 Access rights added
dwinter
parents: 1
diff changeset
1483 security.declareProtected('View management screens','createTempPersonInVirtuoso')
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1484 def createTempPersonInVirtuoso(self,projectID,personURI, personName,personComment):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1485 """add a new person to the triple store of tempory persons"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1486 triples=[];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1487 personID="<"+personURI+">"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1488 triples.append((personID,"<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>","<http://ontologies.mpiwg-berlin.mpg.de/authorities/namedIdentities/Person>"))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1489 triples.append((personID,"<http://erlangen-crm.org/110404/P3_has_note>",'"'+personComment+'"'))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1490 triples.append((personID,"<http://xmlns.com/foaf/0.1/name>",'"'+personName+'"'))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1491 triples.append((personID,"<http://ontologies.mpiwg-berlin.mpg.de/general/isMentionedOn>","<http://www.mpiwg-berlin.mpg.de/en/research/projects/"+projectID+">"))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1492
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1493 cmdString ="insert in GRAPH <"+self.virtuosoGraph+"> {"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1494 for triple in triples:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1495 cmdString+=" ".join(triple)+"."
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1496
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1497 cmdString+="}"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1498
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1499 auth_handler = urllib2.HTTPBasicAuthHandler()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1500 auth_handler.add_password(realm='sparql',
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1501 uri=self.virtuosoServer+"/sparql",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1502 user=self.virtuosoDAVUser,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1503 passwd=self.virtuosoDAVPW)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1504
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1505 opener = urllib2.build_opener(auth_handler)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1506 opener.addheaders = [('Content-Type','application/sparql-query')]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1507
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1508 logging.debug(cmdString)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1509 try:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1510 r= opener.open(self.virtuosoServer+"/sparql", urllib.urlencode({'query':cmdString,'default-graph-uri':self.virtuosoGraph,'named-graph-uri':None}))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1511 logging.debug(r.read())
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1512 except urllib2.URLError, e:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1513 logging.error(e.code)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1514 logging.error(e.read())
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1515 return
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1516
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1517 opener2 = urllib2.build_opener()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1518
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1519
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1520 personIDencoded=urllib.quote(personURI,safe="")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1521 graphEncoded=urllib.quote(self.additionalNamesGraphURL,safe="")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1522 url = self.personproviderURL+"id/"+personIDencoded+"/"+graphEncoded
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1523
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1524 try:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1525 request = urllib2.Request(url);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1526 request.get_method = lambda : 'PUT'
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1527 r= opener2.open(request);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1528 logging.debug(r.read())
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1529 except urllib2.URLError, e:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1530 logging.error(e.code)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1531 logging.error(e.read())
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1532 return
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1533
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1534
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1535
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1536 return
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1537
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1538 # self.storeChange("removePerson",projectID,value)
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1539 def storeChange(self,typeString,projectID,value):
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1540
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1541 from time import gmtime,strftime
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1542
17
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
1543
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
1544
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
1545
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
1546
15
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1547
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1548 fl = open(self.getLogpath(),"a")
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1549 person = self.REQUEST.AUTHENTICATED_USER.getId()
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1550 date = strftime("%Y-%m-%d %H:%M:%S", gmtime())
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1551 writeString ="\t".join((date,person,typeString,projectID,value))
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1552 fl.write(writeString+"\n")
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1553 fl.flush()
f9a65eaaa59c bug beim L?schen von objekte im Tagger fixed.
dwinter
parents: 13
diff changeset
1554 fl.close()
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1555
17
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
1556 lastChangeInThesaurus = getattr(self,'lastChangeInThesaurus',OOBTree())
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
1557 lastChangeInThesaurus.update({projectID:date})
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
1558 self.lastChangeInThesaurus=lastChangeInThesaurus
8e2ddcef1e8d overviews
dwinter
parents: 15
diff changeset
1559
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1560 def redirect(RESPONSE,url):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1561 """mache ein redirect mit einem angehaengten time stamp um ein reload zu erzwingen"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1562
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1563 timeStamp=time.time()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1564
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1565 if url.find("?")>-1: #giebt es schon parameter
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1566 addStr="&time=%s"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1567 else:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1568 addStr="?time=%s"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1569
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1570 RESPONSE.setHeader('Last-Modified',email.Utils.formatdate().split("-")[0]+'GMT')
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1571 logging.error(email.Utils.formatdate()+' GMT')
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1572 RESPONSE.redirect(url+addStr%timeStamp)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1573
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1574 def manage_addMPIWGThesaurusForm(self):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1575 """form for adding the project"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1576 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMPIWGThesaurusForm.zpt')).__of__(self)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1577 return pt()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1578
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1579
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1580
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1581 def manage_addMPIWGThesaurus(self,id,RESPONSE=None):
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1582 """add it"""
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1583 newObj=MPIWGThesaurus(id)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1584
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1585 self._setObject(id,newObj)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1586
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1587
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1588 if RESPONSE is not None:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1589 redirect(RESPONSE,'manage_main')