--- OSAS/OSA_system/OSAS_archiver.py 2003/12/19 13:58:52 1.2 +++ OSAS/OSA_system/OSAS_archiver.py 2003/12/23 13:43:10 1.3 @@ -10,16 +10,69 @@ from Globals import InitializeClass from Globals import Persistent from Acquisition import Implicit from OSAS_show import * +from OSAS_helpers import * import os.path import os import OSAS_ids import archive #Baustelle +import time + +class OSAS_archiveInbox(SimpleItem,Persistent,Implicit): + """Inbox""" + + meta_type="OSAS_archiveInbox" + pathes=[] + + def __init__(self,id,title): + """init""" + self.id=id + self.title=title + self.pathes=[] + + def addPath(self,path): + today=time.localtime() + self.pathes.append([path,today]) + + def index_html(self): + """main""" + pt=PageTemplateFile('Products/OSA_system/OSAS_archiveInboxIndex.zpt').__of__(self) + return pt() + +def manage_AddOSAS_archiveInboxForm(self): + """interface for adding the OSAS_root""" + pt=PageTemplateFile('Products/OSA_system/AddOSAS_archiveInbox.zpt').__of__(self) + return pt() + + +def manage_AddOSAS_archiveInbox(self,id,title="",RESPONSE=None): + """add the OSAS_root""" + if title=="": + title=id + + newObj=OSAS_archiveInbox(id, title) + self._setObject(id,newObj) + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + class OSAS_metadataOrganizer(SimpleItem,Persistent,Implicit): """Eingabe von Metadaten""" meta_type="OSAS_metadataOrganizer" + mediaTypes=["image","video","text","audio","data"] + acquisitionTypes=["Image-Acquisition"] + mediaToAcquisition={"image":"Image-Acquisition"} + metaDataSets={'Image-Acquisition': [('device','opt'),('image-type','opt'),('production-comment','opt')]} + imgData={'image':[('dpi','req')]} + + bibDataSets={'Book':[('author','opt'),('year','opt'),('title','opt'),('series editor','opt'),('series title','opt'),('series volume','opt'),('number of pages','opt'),('city','opt'),('publisher','opt'),('edition','opt'),('number of volumes','opt'),('translator','opt'),('ISBN ISSN','opt')], + 'Journal Article':[('author','opt'),('year','opt'),('title','opt'),('journal','opt'),('volume','opt'),('issue','opt'),('pages','opt'),('alternate journal','opt'),('call number','opt')], + 'Manuscript':[('author','opt'),('year','opt'),('title','opt'),('location','opt'),('signature','opt'),('pages','opt'),('editorial remarks','opt'),('description','opt'),('keywords','opt')]} + + + referenceTypes=['Book','Journal Article','Manuscript'] def __init__(self,id,title): """init""" @@ -33,9 +86,81 @@ class OSAS_metadataOrganizer(SimpleItem, pt=PageTemplateFile('Products/OSA_system/inputAcquisitionData.zpt').__of__(self) return pt() - def writeAcquisitionMetadata(self,producer,date,path,description=""): + def writeAcquisitionMetadata(self,date,path,media_type,producer="mpiwg",description=""): """Schreibe Acquisiondata in index.meta""" + + #schreibe in index.meta + subnodes={} + subnodes['media-type']=media_type + changeNodesInIndexMeta(path,"",subnodes) + + subnodes={} + subnodes['date']=date + subnodes['description']=description + + changeNodesInIndexMeta(path,"acquisition",subnodes) + #print "HI" + + subnodes={} + subnodes['provider-id']=producer + subnodes['url']=getattr(self.producerFolder,producer).url + subnodes['contact']=getattr(self.producerFolder,producer).contact + subnodes['address']=getattr(self.producerFolder,producer).address + + changeNodesInIndexMeta(path,"provider",subnodes,parent="acquisition") + + + self.metaDataSet=self.metaDataSets[self.mediaToAcquisition[media_type]] + self.media_type=self.mediaToAcquisition[media_type] + + pt=PageTemplateFile('Products/OSA_system/inputDocumentMetadata.zpt').__of__(self) + return pt() + + + def writeDocumentMetadata(self,referenceType): + + """write document metadata""" + form=self.REQUEST.form +#schreibe in index.meta + self.bibDataSet=self.bibDataSets[form['referenceType']] + self.bibdata_type=form['referenceType'] + + subnodes={} + subnodes['device']=form['device'] + subnodes['image-type']=form['image-type'] + subnodes['production-comment']=form['production-comment'] + changeNodesInIndexMeta(self.REQUEST.SESSION['path'],"image-acquisition",subnodes) + + subnodes={} + subnodes['dpi']=form['dpi'] + + + changeNodesInIndexMeta(self.REQUEST.SESSION['path'],"img",subnodes) + + + pt=PageTemplateFile('Products/OSA_system/inputBiblioMetadata.zpt').__of__(self) + return pt() + + def writeBiblioMetadata(self,bibdata_type,RESPONSE=None): + """Write all""" + #to do write metadata + + subnodes={} + form=self.REQUEST.form + #for key in form.keys(): + # subnodes[key]=form['device'] + subnodes=form + changeNodesInIndexMeta(self.REQUEST.SESSION['path'],"bib",subnodes,nodeAttributes={'type':bibdata_type},parent="meta") + self.inbox.addPath(self.REQUEST.SESSION['path']) + RESPONSE.redirect(self.REQUEST['URL2']) + + + + + + + def manage_AddOSAS_metadataOrganizerForm(self): """interface for adding the OSAS_root""" pt=PageTemplateFile('Products/OSA_system/AddOSAS_metadataOrganizer.zpt').__of__(self) @@ -121,6 +246,8 @@ class OSAS_archiver(Folder, Persistent,I #startPath="/mpiwg" ## methoden aus dem alten archive.py + + def archiver(self,path): """archive the documents in path""" tmp=archive.archive(path,self.REQUEST.SESSION) @@ -195,6 +322,10 @@ class OSAS_archiver(Folder, Persistent,I """main page""" pt=PageTemplateFile('Products/OSA_system/archiverIndex.zpt').__of__(self) return pt() + + def getDate(self): + """date""" + return time.strftime("%Y-%m-%d",time.localtime()) def newFolders_html(self): """main page""" @@ -204,7 +335,8 @@ class OSAS_archiver(Folder, Persistent,I def getProducers(self): """Ausgabe der registrierten Benutzer""" ret=[] - #print self.aq_parent.__dict__ + #x=7 + id=self.producerFolder.getId() for list in self.producerFolder.__dict__: obj=getattr(self.producerFolder,list) if (hasattr(obj,"meta_type")): @@ -269,7 +401,7 @@ def manage_AddOSAS_archiver(self,id,star RESPONSE.redirect('manage_main') -class OSAS_producer(Image,Persistent,Implicit): +class OSAS_producer(SimpleItem,Persistent,Implicit): """Klasse fuer Produzenteninformationen Metadaten nach V1.1.1""" @@ -283,7 +415,7 @@ class OSAS_producer(Image,Persistent,Imp self.url=url self.contact=contact - manage_options = Folder.manage_options+( + manage_options = SimpleItem.manage_options+( {'label':'Main Config','action':'changeOSAS_producerForm'}, ) @@ -291,7 +423,13 @@ class OSAS_producer(Image,Persistent,Imp """change""" pt=PageTemplateFile('Products/OSA_system/ChangeOSAS_producer.zpt').__of__(self) return pt() - + + def changeOSAS_producer(self,title,address,contact="",url=""): + """change""" + self.title=fullName + self.address=address + self.url=url + self.contact=contact def manage_AddOSAS_producerForm(self): """interface for adding the OSAS_root"""