File:  [Repository] / OSAS / OSA_system / OSAS_archiver.py
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Tue Dec 23 13:43:10 2003 UTC (20 years, 6 months ago) by dwinter
Branches: MAIN
CVS tags: HEAD
archiver

    1: # Methoden und Klassen fuer den MPIWG Archiver
    2: 
    3: from OFS.Image import Image
    4: from OFS.Folder import Folder
    5: from OFS.SimpleItem import SimpleItem
    6: from Products.PageTemplates.PageTemplateFile import PageTemplateFile
    7: from Products.PageTemplates.PageTemplate import PageTemplate
    8: from AccessControl import ClassSecurityInfo
    9: from Globals import InitializeClass
   10: from Globals import Persistent
   11: from Acquisition import Implicit
   12: from OSAS_show import *
   13: from OSAS_helpers import *
   14: 
   15: import os.path
   16: import os
   17: import OSAS_ids
   18: import archive #Baustelle
   19: import time
   20: 
   21: class OSAS_archiveInbox(SimpleItem,Persistent,Implicit):
   22:     """Inbox"""
   23: 
   24:     meta_type="OSAS_archiveInbox"
   25:     pathes=[]
   26:     
   27:     def __init__(self,id,title):
   28:         """init"""
   29:         self.id=id
   30:         self.title=title
   31:         self.pathes=[]
   32: 
   33:     def addPath(self,path):
   34:         today=time.localtime()
   35:         self.pathes.append([path,today])
   36: 
   37:     def index_html(self):
   38:         """main"""
   39:         pt=PageTemplateFile('Products/OSA_system/OSAS_archiveInboxIndex.zpt').__of__(self)
   40:         return pt()
   41:     
   42: def manage_AddOSAS_archiveInboxForm(self):
   43:     """interface for adding the OSAS_root"""
   44:     pt=PageTemplateFile('Products/OSA_system/AddOSAS_archiveInbox.zpt').__of__(self)
   45:     return pt()
   46: 
   47: 
   48: def manage_AddOSAS_archiveInbox(self,id,title="",RESPONSE=None):
   49:     """add the OSAS_root"""
   50:     if title=="":
   51:         title=id
   52:         
   53:     newObj=OSAS_archiveInbox(id, title)
   54:     self._setObject(id,newObj)
   55:     if RESPONSE is not None:
   56:         RESPONSE.redirect('manage_main')
   57:     
   58: 
   59: 
   60: class OSAS_metadataOrganizer(SimpleItem,Persistent,Implicit):
   61:     """Eingabe von Metadaten"""
   62: 
   63:     meta_type="OSAS_metadataOrganizer"
   64:     mediaTypes=["image","video","text","audio","data"]
   65:     acquisitionTypes=["Image-Acquisition"]
   66:     mediaToAcquisition={"image":"Image-Acquisition"}
   67:     metaDataSets={'Image-Acquisition': [('device','opt'),('image-type','opt'),('production-comment','opt')]}
   68:     imgData={'image':[('dpi','req')]}
   69:     
   70:     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')],
   71:                   'Journal Article':[('author','opt'),('year','opt'),('title','opt'),('journal','opt'),('volume','opt'),('issue','opt'),('pages','opt'),('alternate journal','opt'),('call number','opt')],
   72:                   'Manuscript':[('author','opt'),('year','opt'),('title','opt'),('location','opt'),('signature','opt'),('pages','opt'),('editorial remarks','opt'),('description','opt'),('keywords','opt')]}
   73: 
   74: 
   75:     referenceTypes=['Book','Journal Article','Manuscript']
   76: 
   77:     def __init__(self,id,title):
   78:         """init"""
   79:         self.id=id
   80:         self.title=title
   81:         #self.acquisitionData=['provider_name','provider_address','provider_contact','provider_url','date','description']
   82: 
   83:     def addAcquisition(self,path):
   84:         """Hinzufügen von Acquisition Daten"""
   85:         self.REQUEST.SESSION['path']=path
   86:         pt=PageTemplateFile('Products/OSA_system/inputAcquisitionData.zpt').__of__(self)
   87:         return pt()
   88: 
   89:     def writeAcquisitionMetadata(self,date,path,media_type,producer="mpiwg",description=""):
   90:         """Schreibe Acquisiondata in index.meta"""
   91:         
   92:         
   93:         #schreibe in index.meta
   94:         subnodes={}
   95:         subnodes['media-type']=media_type
   96:         changeNodesInIndexMeta(path,"",subnodes)
   97:         
   98:         subnodes={}
   99:         subnodes['date']=date
  100:         subnodes['description']=description
  101:         
  102:         changeNodesInIndexMeta(path,"acquisition",subnodes)
  103:         #print "HI"
  104: 
  105:         subnodes={}
  106:         subnodes['provider-id']=producer
  107:         subnodes['url']=getattr(self.producerFolder,producer).url
  108:         subnodes['contact']=getattr(self.producerFolder,producer).contact
  109:         subnodes['address']=getattr(self.producerFolder,producer).address
  110:         
  111:         changeNodesInIndexMeta(path,"provider",subnodes,parent="acquisition")
  112: 
  113:         
  114:         self.metaDataSet=self.metaDataSets[self.mediaToAcquisition[media_type]]
  115:         self.media_type=self.mediaToAcquisition[media_type]
  116:         
  117:         pt=PageTemplateFile('Products/OSA_system/inputDocumentMetadata.zpt').__of__(self)
  118:         return pt()
  119: 
  120:         
  121:     def writeDocumentMetadata(self,referenceType):
  122: 
  123:         """write document metadata"""
  124:         form=self.REQUEST.form
  125: #schreibe in index.meta
  126:         self.bibDataSet=self.bibDataSets[form['referenceType']]
  127:         self.bibdata_type=form['referenceType']
  128: 
  129:         subnodes={}
  130:         subnodes['device']=form['device']
  131:         subnodes['image-type']=form['image-type']
  132:         subnodes['production-comment']=form['production-comment']
  133:         changeNodesInIndexMeta(self.REQUEST.SESSION['path'],"image-acquisition",subnodes)
  134: 
  135:         subnodes={}
  136:         subnodes['dpi']=form['dpi']
  137: 
  138:         
  139:         changeNodesInIndexMeta(self.REQUEST.SESSION['path'],"img",subnodes)
  140: 
  141: 
  142:         pt=PageTemplateFile('Products/OSA_system/inputBiblioMetadata.zpt').__of__(self)
  143:         return pt()
  144: 
  145:     def writeBiblioMetadata(self,bibdata_type,RESPONSE=None):
  146:         """Write all"""
  147:         #to do write metadata
  148: 
  149:         subnodes={}
  150:         form=self.REQUEST.form
  151:         #for key in form.keys():
  152:         #    subnodes[key]=form['device']
  153:         subnodes=form
  154:         changeNodesInIndexMeta(self.REQUEST.SESSION['path'],"bib",subnodes,nodeAttributes={'type':bibdata_type},parent="meta")
  155:         self.inbox.addPath(self.REQUEST.SESSION['path'])
  156:         RESPONSE.redirect(self.REQUEST['URL2'])
  157:         
  158: 
  159: 
  160:     
  161:         
  162:     
  163: 
  164: def manage_AddOSAS_metadataOrganizerForm(self):
  165:     """interface for adding the OSAS_root"""
  166:     pt=PageTemplateFile('Products/OSA_system/AddOSAS_metadataOrganizer.zpt').__of__(self)
  167:     return pt()
  168: 
  169: 
  170: def manage_AddOSAS_metadataOrganizer(self,id,title="",RESPONSE=None):
  171:     """add the OSAS_root"""
  172:     if title=="":
  173:         title=id
  174:         
  175:     newObj=OSAS_metadataOrganizer(id, title)
  176:     self._setObject(id,newObj)
  177:     if RESPONSE is not None:
  178:         RESPONSE.redirect('manage_main')
  179:     
  180: 
  181: class OSAS_processViewer(SimpleItem,Persistent,Implicit):
  182:     """Process viewer for archiving"""
  183: 
  184:     meta_type="OSAS_processViewer"
  185: 
  186:     def __init__(self, id, title):
  187:         """init"""
  188:         self.id=id
  189:         self.title=title
  190: 
  191:     def index_html(self):
  192:         """main page"""
  193:         pt=PageTemplateFile('Products/OSA_system/processViewerIndex.zpt').__of__(self)
  194:         return pt()
  195: 
  196:     def storeFile(self,something):
  197:         """store info in session"""
  198:         self.REQUEST.SESSION['something']=something
  199:         return 1
  200: 
  201:     def getFile(self):
  202:         """get info from session"""
  203:         return self.REQUEST.SESSION['something']
  204: 
  205:     def getoverview(self,path):
  206:         """get overview"""
  207:         return archive.overview(path)
  208: 
  209:     def storeerror(self,ret,path,context,i):
  210:         """store an error"""
  211:         session=context.REQUEST.SESSION
  212:         session['error%i'%i]=ret
  213:         session['path%i'%i]=path
  214:      
  215:         return 'error?number=%i'%i
  216: 
  217:     def view(self):
  218:         """view page"""
  219:         pt=PageTemplateFile('Products/OSA_system/processViewerView.zpt').__of__(self)
  220:         return pt()
  221:     
  222: def manage_AddOSAS_processViewerForm(self):
  223:     """interface for adding the OSAS_processViewer"""
  224:     pt=PageTemplateFile('Products/OSA_system/AddOSAS_processViewer.zpt').__of__(self)
  225:     return pt()
  226: 
  227: 
  228: def manage_AddOSAS_processViewer(self,id,title="",RESPONSE=None):
  229:     """add the OSAS_processViewer"""
  230:     if title=="":
  231:         title=id
  232:         
  233:     newObj=OSAS_processViewer(id, title)
  234:     self._setObject(id,newObj)
  235:     if RESPONSE is not None:
  236:         RESPONSE.redirect('manage_main')
  237: 
  238: 
  239: 
  240: class OSAS_archiver(Folder, Persistent,Implicit):
  241:     """Hauptklasse fuer das Archiv"""
  242: 
  243:     meta_type="OSAS_archiver"
  244: 
  245:     # to be deleted later
  246:     #startPath="/mpiwg"
  247:     ## methoden aus dem alten archive.py
  248: 
  249:    
  250: 
  251:     def archiver(self,path):
  252:         """archive the documents in path"""
  253:         tmp=archive.archive(path,self.REQUEST.SESSION)
  254:         pt=PageTemplateFile('Products/OSA_system/archiveStatus.zpt').__of__(self)
  255:         return pt()
  256: 
  257:         
  258: 
  259: 
  260:     def metachecker(self,path):
  261:         """check the metadata the documents in path"""
  262:         self.REQUEST.SESSION['path']=self.REQUEST['path']
  263:         return archive.metacheck(path)
  264: 
  265:     ## methods  from OSAS_show
  266:     def changeName(self,name):
  267:         return changeName(name)
  268: 
  269:     def hasMetafile(self,path):
  270:         return hasMetafile(path)
  271: 
  272:     def getMetafile(self,path):
  273:         return getMetafile(path)
  274: 
  275:     def toggle_view(self,path,file):
  276:         """Oeffnen bzw. schließen der Subfolders"""
  277:         self.tree(path).toggle(path,file)
  278:         return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+"?path="+path)
  279: 
  280: 
  281: 
  282:     def isdigilib2(self,path):
  283:         """check if digilib"""
  284:         return isdigilib2(path)
  285: 
  286:     def path_to_link_view(self,path):
  287:         """generates navigation bar for viewfiles"""
  288:         return path_to_link_view(self.REQUEST['URL'],path)
  289:     
  290: 
  291:     def tree(self,start):
  292: 	"""get the filetree"""
  293: 	k=browse(start)
  294: 	return k
  295: 
  296:     def getfilesystem2(self,start,reload=0):
  297: 	"""load filesystem"""
  298: 
  299: 	k=filesystem2(start,1)
  300: 	return k
  301: 
  302:     def getfilesystem(self,start,reload=0):
  303: 	"""load filesystem"""
  304: 
  305: 	k=filesystem(start,1)
  306: 	return k
  307: 
  308: 
  309:     ##init
  310:     def __init__(self, id, title,startPath):
  311:         """init"""
  312:         self.id=id
  313:         self.title=title
  314:         self.startPath=startPath
  315: 
  316:     def archiver_html(self):
  317:         """archiver"""
  318:         pt=PageTemplateFile('Products/OSA_system/OSAS_Archiver.zpt').__of__(self)
  319:         return pt()
  320: 
  321:     def index_html(self):
  322:         """main page"""
  323:         pt=PageTemplateFile('Products/OSA_system/archiverIndex.zpt').__of__(self)
  324:         return pt()
  325: 
  326:     def getDate(self):
  327:         """date"""
  328:         return time.strftime("%Y-%m-%d",time.localtime())
  329:     
  330:     def newFolders_html(self):
  331:         """main page"""
  332:         pt=PageTemplateFile('Products/OSA_system/newFolders.zpt').__of__(self)
  333:         return pt()
  334: 
  335:     def getProducers(self):
  336:         """Ausgabe der registrierten Benutzer"""
  337:         ret=[]
  338:         #x=7
  339:         id=self.producerFolder.getId()
  340:         for list in self.producerFolder.__dict__:
  341:             obj=getattr(self.producerFolder,list)
  342:             if (hasattr(obj,"meta_type")):
  343:                 if (obj.meta_type=="OSAS_producer"):
  344:                     ret.append(obj.getId())
  345:         return ret
  346: 
  347:     def getProducer(self,id):
  348:         """Gebe ProducerObjekt zurück"""
  349:         obj=getattr(self.aq_parent.producerFolder,id)
  350:         return obj
  351:         
  352:         
  353: 
  354:     def createFoldersForm(self,producer,number):
  355:         """Erzeuge Folder im producer Verzeichnis mit ids"""
  356:         self.REQUEST.SESSION['producer']=producer
  357:         self.REQUEST.SESSION['ids']=self.idGenerator.giveIdsOut(number)
  358:         pt=PageTemplateFile('Products/OSA_system/createFoldersForm.zpt').__of__(self)
  359:         return pt()
  360:     
  361:     def createFolders(self,folderList,producer):
  362:         """Erzeug die entsprechenden Folder"""
  363:         for folder in folderList:
  364:             os.mkdir(self.startPath+"/"+producer+"/"+folder)
  365:         self.REQUEST.SESSION['folderList']=folderList
  366:         pt=PageTemplateFile('Products/OSA_system/createFolders.zpt').__of__(self)
  367:         return pt()
  368: 
  369:     def archiveSelected(self):
  370:         """Archiviere ausgewaehlte files"""
  371:         pt=PageTemplateFile('Products/OSA_system/archiveSelected.zpt').__of__(self)
  372:         return pt()
  373: 
  374:     def enterAcquisitionMetadata(self):
  375:         """Erstelle Metadaten fuer Acquisition"""
  376: 
  377:     def enterPreliminaryBibMeta(self):
  378:         """Erstelle Metadaten fuer Bibliography"""
  379:         
  380:     def showFilesForArchiving(self):
  381:         """Anzeige der noch zu archivieren Files"""
  382: 
  383:         
  384: 
  385:     
  386: 
  387: def manage_AddOSAS_archiverForm(self):
  388:     """interface for adding the OSAS_root"""
  389:     pt=PageTemplateFile('Products/OSA_system/AddOSAS_archiver.zpt').__of__(self)
  390:     return pt()
  391: 
  392: 
  393: def manage_AddOSAS_archiver(self,id,startPath,title="",RESPONSE=None):
  394:     """add the OSAS_root"""
  395:     if title=="":
  396:         title=id
  397:         
  398:     newObj=OSAS_archiver(id, title,startPath)
  399:     self._setObject(id,newObj)
  400:     if RESPONSE is not None:
  401:         RESPONSE.redirect('manage_main')
  402: 
  403: 
  404: class OSAS_producer(SimpleItem,Persistent,Implicit):
  405:     """Klasse fuer Produzenteninformationen
  406:     Metadaten nach  V1.1.1"""
  407: 
  408:     meta_type="OSAS_producer"
  409: 
  410:     def __init__(self,shortName,fullName,address="",url="",contact=""):
  411: 
  412:         self.id=shortName
  413:         self.title=fullName
  414:         self.address=address
  415:         self.url=url
  416:         self.contact=contact
  417: 
  418:     manage_options = SimpleItem.manage_options+(
  419:         {'label':'Main Config','action':'changeOSAS_producerForm'},
  420:         )
  421: 
  422:     def changeOSAS_producerForm(self):
  423:         """change"""
  424:         pt=PageTemplateFile('Products/OSA_system/ChangeOSAS_producer.zpt').__of__(self)
  425:         return pt()
  426: 
  427:     def changeOSAS_producer(self,title,address,contact="",url=""):
  428:         """change"""
  429:         self.title=fullName
  430:         self.address=address
  431:         self.url=url
  432:         self.contact=contact
  433: 
  434: def manage_AddOSAS_producerForm(self):
  435:     """interface for adding the OSAS_root"""
  436:     pt=PageTemplateFile('Products/OSA_system/AddOSAS_producer.zpt').__of__(self)
  437:     return pt()
  438: 
  439: 
  440: def manage_AddOSAS_producer(self,id,title="",contact="",address="",url="",RESPONSE=None):
  441:     """add the OSAS_root"""
  442:     if title=="":
  443:         title=id
  444:         
  445:     newObj=OSAS_producer(id, title,address,contact,url)
  446:     self._setObject(id,newObj)
  447:     if RESPONSE is not None:
  448:         RESPONSE.redirect('manage_main')
  449: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>