annotate MPIWGThesaurus.py @ 13:51ed6ad43383

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