source: Solr.py @ 14:0e0f06219896

Revision 14:0e0f06219896, 5.0 KB checked in by hagenbruch@phoibe.ub.rub.de, 7 years ago (diff)

First version of organization RDF

Line 
1#! /usr/bin/env python
2# encoding: utf-8
3
4#  The MIT License
5#
6#  Copyright 2010 Andre Hagenbruch <andre.hagenbruch@ruhr-uni-bochum.de>.
7#
8#  Permission is hereby granted, free of charge, to any person obtaining a copy
9#  of this software and associated documentation files (the "Software"), to deal
10#  in the Software without restriction, including without limitation the rights
11#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12#  copies of the Software, and to permit persons to whom the Software is
13#  furnished to do so, subject to the following conditions:
14#
15#  The above copyright notice and this permission notice shall be included in
16#  all copies or substantial portions of the Software.
17#
18#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24#  THE SOFTWARE.
25
26
27__author__ = "Andre Hagenbruch <andre.hagenbruch@ruhr-uni-bochum.de>"
28__date__ = "$25.01.2010 15:57:59$"
29
30from jinja2 import Template
31
32TEMPLATE = '''
33    <doc>
34        {% for field, value in doc.items() -%}
35            {% if value -%}
36            <field name="{{ field }}">{{ value }}</field>
37            {% endif -%}
38        {% endfor %}
39    </doc>
40    '''
41
42class SolrRecord(object):
43    """
44    Documentation
45    """
46    def __init__(self, title=None, sorttitle=None, parallel_title=None,
47                 titelzusatz=None, creator=[], sperson=[], editor=[],
48                 contributor=[], fperson=None, person=None, institution=None,
49                 subject=[], fsubject=[], stwdesc=[],
50                 stwterm=None, journal_title=None, series_title=None, fjtitle=None,
51                 publisher=None, place=None, issue=None, volume=None, pages=None,
52                 edition=None, volumes=None, location=None, locator=None,
53                 standort=None, date=None, fdate=None, mods=None, dcds=None,
54                 bibtex=None, ris=None, dc=None, json=None, entryID=None,
55                 id=None, disziplin=None, fakultaet=None, zentraleeinheit=None,
56                 fach=None, recordCreationDate=None, recordChangeDate=None,
57                 genrel1=None, genrel2=None, language=None,
58                 bibliographicCitation=None, toc_link=None, toc_text=None,
59                 abstract=None, note=None, issn=None, isbn=None, isxn=None,
60                 doi=None, urn=None, url=None, worldcat_url=None,
61                 google_book_url=None, patent_id=None, pnd=None, tictoc=None,
62                 jcr=None):
63        """Documentation"""
64        self.title = title
65        self.sorttitle = sorttitle
66        self.parallel_title = parallel_title
67        self.titelzusatz = titelzusatz
68        self.creator = creator
69        self.sperson = sperson
70        self.editor = editor
71        self.contributor = contributor
72        self.fperson = fperson
73        self.person = person
74        self.institution = institution
75        self.subject = subject
76        self.fsubject = fsubject
77        self.stwdesc = stwdesc
78        self.stwterm = stwterm
79        self.journal_title = journal_title
80        self.series_title = series_title
81        self.fjtitle = fjtitle
82        self.publisher = publisher
83        self.place = place
84        self.issue = issue
85        self.volume = volume
86        self.pages = pages
87        self.edition = edition
88        self.volumes = volumes
89        self.location = location
90        self.locator = locator
91        self.standort = standort
92        self.date = date
93        self.fdate = fdate
94        self.mods = mods
95        self.dcds = dcds
96        self.bibtex = bibtex
97        self.ris = ris
98        self.dc = dc
99        self.json = json
100        self.entryID = entryID
101        self.id = id
102        self.disziplin = disziplin
103        self.fakultaet = fakultaet
104        self.zentraleeinheit = zentraleeinheit
105        self.fach = fach
106        self.recordCreationDate = recordCreationDate
107        self.recordChangeDate = recordChangeDate
108        self.genrel1 = genrel1
109        self.genrel2 = genrel2
110        self.language = language
111        self.bibliographicCitation = bibliographicCitation
112        self.toc_link = toc_link
113        self.toc_text = toc_text
114        self.abstract = abstract
115        self.note = note
116        self.issn = issn
117        self.isbn = isbn
118        self.isxn = isxn
119        self.doi = doi
120        self.urn = urn
121        self.url = url
122        self.worldcat_url = worldcat_url
123        self.google_book_url = google_book_url
124        self.patent_id = patent_id
125        self.pnd = pnd
126        self.tictoc = tictoc
127        self.jcr = jcr
128
129    def __del__(self):
130        print "jo!"
131
132    def serialize(self):
133        #doc = dict(self.__dict__)
134        #print doc
135        t = Template(TEMPLATE)
136        return t.render(doc = self.__dict__)
137
138def main():
139    pass
140
141if __name__ == '__main__':
142    main()
Note: See TracBrowser for help on using the repository browser.