gramps/src/RelLib.py

1527 lines
37 KiB
Python
Raw Normal View History

2001-05-13 07:26:57 +05:30
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
from Date import *
class Place:
def __init__(self,source=None):
if source:
self.long = source.log
self.lat = source.lat
self.title = source.title
self.main_loc = Location(source.main_loc)
self.alt_loc = []
if source.source_ref:
self.source_ref = SourceRef(source.source_ref)
else:
self.source_ref = None
if source.note:
self.note = Note(source.note.get())
else:
self.note = None
for loc in source.alt_loc:
self.alt_loc = Location(loc)
self.id = source.id
self.urls = []
for u in source.urls:
self.urls.append(Url(u))
self.photoList = []
for photo in source.photoList:
self.photoList.append(Photo(photo))
else:
self.source_ref = None
self.long = ""
self.lat = ""
self.title = ""
self.note = None
self.main_loc = Location()
self.alt_loc = []
self.id = ""
self.urls = []
self.photoList = []
def getUrlList(self):
return self.urls
def setUrlList(self,list):
self.urls = list
def addUrl(self,url):
self.urls.append(url)
def setSourceRef(self,id) :
self.source_ref = id
def getSourceRef(self) :
if not self.source_ref:
self.source_ref = SourceRef()
return self.source_ref
def setId(self,id):
self.id = id
def getId(self):
return self.id
def set_title(self,name):
self.title = name
def get_title(self):
return self.title
def set_longitude(self,long):
self.long = long
def get_longitude(self):
return self.long
def set_latitude(self,long):
self.lat = long
def get_latitude(self):
return self.lat
def get_main_location(self):
return self.main_loc
def set_main_location(self,loc):
self.main_loc = loc
def get_alternate_locations(self):
return self.alt_loc
def set_alternate_locations(self,list):
self.alt_loc = list
def add_alternate_locations(self,loc):
if loc not in self.alt_loc:
self.alt_loc.append(loc)
def setNote(self,text):
if self.note == None:
self.note = Note()
self.note.set(text)
def getNote(self):
if self.note == None:
return ""
else:
return self.note.get()
def setNoteObj(self,obj):
self.note = obj
def getNoteObj(self):
return self.note
def addPhoto(self,photo):
self.photoList.append(photo)
def getPhotoList(self):
return self.photoList
#-------------------------------------------------------------------------
#
# Researcher
#
#-------------------------------------------------------------------------
class Researcher:
def __init__(self):
self.name = ""
self.addr = ""
self.city = ""
self.state = ""
self.country = ""
self.postal = ""
self.phone = ""
self.email = ""
def getName(self):
return self.name
def getAddress(self):
return self.addr
def getCity(self):
return self.city
def getState(self):
return self.state
def getCountry(self):
return self.country
def getPostalCode(self):
return self.postal
def getPhone(self):
return self.phone
def getEmail(self):
return self.email
def set(self,name,addr,city,state,country,postal,phone,email):
self.name = string.strip(name)
self.addr = string.strip(addr)
self.city = string.strip(city)
self.state = string.strip(state)
self.country = string.strip(country)
self.postal = string.strip(postal)
self.phone = string.strip(phone)
self.email = string.strip(email)
#-------------------------------------------------------------------------
#
# Location
#
#-------------------------------------------------------------------------
class Location:
def __init__(self,source=None):
if source:
self.city = source.city
self.county = source.county
self.state = source.state
self.country = source.country
else:
self.city = ""
self.county = ""
self.state = ""
self.country = ""
def set_city(self,data):
self.city = data
def get_city(self):
return self.city
def set_county(self,data):
self.county = data
def get_county(self):
return self.county
def set_state(self,data):
self.state = data
def get_state(self):
return self.state
def set_country(self,data):
self.country = data
def get_country(self):
return self.country
#-------------------------------------------------------------------------
#
# Note class.
#
#-------------------------------------------------------------------------
class Note:
def __init__(self,text = ""):
self.text = text
def set(self,text):
self.text = text
def get(self):
return self.text
2001-05-13 07:26:57 +05:30
#-------------------------------------------------------------------------
#
# Photo class. Contains information about a photo stored in the database
#
#-------------------------------------------------------------------------
class Photo:
def __init__(self,source=None):
if source:
self.path = source.path
self.desc = source.desc
self.private = source.private
if self.proplist != None:
self.proplist = {}
for p in source.proplist.keys():
self.proplist[k] = source.proplist[k]
else:
self.proplist = None
else:
self.path = ""
self.desc = ""
self.private = 0
self.proplist = None
2001-05-13 07:26:57 +05:30
def setPath(self,path):
self.path = path
def getPath(self):
return self.path
def setPrivate(self,val):
self.private = val
def getPrivate(self):
return self.private
def setDescription(self,text):
self.desc = text
def getDescription(self):
return self.desc
2001-07-16 07:36:31 +05:30
def addProperty(self,key,value):
if self.proplist == None:
self.proplist = { key: value}
else:
self.proplist[key] = value;
def getPropertyList(self):
return self.proplist
2001-05-13 07:26:57 +05:30
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class Attribute:
def __init__(self,source=None):
if source:
self.type = source.type
self.value = source.value
if source.source_ref:
self.source_ref = SourceRef(source.source_ref)
else:
self.source_ref = None
if source.note:
self.note = Note(source.note.get())
else:
self.note = None
self.confidence = 2
self.private = 0
else:
self.type = ""
self.value = ""
self.source_ref = None
self.note = Note()
self.confidence = 2
self.private = 0
def setPrivacy(self,val):
self.private = val
def getPrivacy(self):
return self.private
def setConfidence(self,val):
self.confidence = val
def getConfidence(self):
return self.confidence
def setNote(self,text):
self.note.set(text)
def getNote(self):
return self.note.get()
def setNoteObj(self,obj):
self.note = obj
2001-08-10 10:02:31 +05:30
def getNoteObj(self):
return self.note
def setSourceRef(self,id) :
self.source_ref = id
def getSourceRef(self) :
if not self.source_ref:
self.source_ref = SourceRef()
return self.source_ref
2001-05-13 07:26:57 +05:30
def setType(self,val):
self.type = val
def getType(self):
return self.type
def setValue(self,val):
self.value = val
def getValue(self):
return self.value
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class Address:
def __init__(self,source=None):
if source:
self.street = source.street
self.city = source.city
self.state = source.state
self.country = source.country
self.postal = source.postal
self.date = Date(source.date)
if source.source_ref:
self.source_ref = SourceRef(source.source_ref)
else:
self.source_ref = None
if source.note:
self.note = Note(source.note.get())
else:
self.note = None
self.confidence = source.confidence
self.private = source.private
else:
self.street = ""
self.city = ""
self.state = ""
self.country = ""
self.postal = ""
self.date = Date()
self.note = None
self.source_ref = None
self.confidence = 2
self.private = 0
def setPrivacy(self,val):
self.private = val
def getPrivacy(self):
return self.private
def setConfidence(self,val):
self.confidence = val
def getConfidence(self):
return self.confidence
def setSourceRef(self,id) :
self.source_ref = id
def getSourceRef(self) :
if not self.source_ref:
self.source_ref = SourceRef()
return self.source_ref
def setNote(self,text):
if self.note == None:
self.note = Note()
self.note.set(text)
def getNote(self):
if self.note == None:
return ""
else:
return self.note.get()
def setNoteObj(self,obj):
self.note = obj
2001-08-10 10:02:31 +05:30
def getNoteObj(self):
return self.note
2001-05-13 07:26:57 +05:30
def setDate(self,text):
self.date.set(text)
2001-05-13 07:26:57 +05:30
def getDate(self):
return self.date.getDate()
2001-05-13 07:26:57 +05:30
def getDateObj(self):
return self.date
2001-05-13 07:26:57 +05:30
def setStreet(self,val):
self.street = val
def getStreet(self):
return self.street
def setCity(self,val):
self.city = val
def getCity(self):
return self.city
def setState(self,val):
self.state = val
def getState(self):
return self.state
def setCountry(self,val):
self.country = val
def getCountry(self):
return self.country
def setPostal(self,val):
self.postal = val
def getPostal(self):
return self.postal
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class Name:
def __init__(self,source=None):
if source:
self.FirstName = source.FirstName
self.Surname = source.Surname
self.Suffix = source.Suffix
self.Title = source.Title
if source.source_ref:
self.source_ref = SourceRef(source.source_ref)
else:
self.source_ref = None
if source.note:
self.note = Note(source.note.get())
else:
self.note = None
self.private = 0
self.confidence = 2
else:
self.FirstName = ""
self.Surname = ""
self.Suffix = ""
self.Title = ""
self.source_ref = None
self.note = None
self.private = 0
self.confidence = 2
def setPrivacy(self,val):
self.private = val
def getPrivacy(self):
return self.private
def setConfidence(self,val):
self.confidence = val
def getConfidence(self):
return self.confidence
2001-05-13 07:26:57 +05:30
def setName(self,first,last,suffix):
self.FirstName = first
self.Surname = last
self.Suffix = suffix
def setFirstName(self,name):
self.FirstName = name
def setSurname(self,name):
self.Surname = name
def setSuffix(self,name):
self.Suffix = name
def getFirstName(self):
return self.FirstName
def getSurname(self):
return self.Surname
def getSuffix(self):
return self.Suffix
def setTitle(self,title):
self.Title = title
def getTitle(self):
return self.Title
def getName(self):
if (self.Suffix == ""):
return "%s, %s" % (self.Surname, self.FirstName)
else:
return "%s, %s %s" % (self.Surname, self.FirstName, self.Suffix)
def getRegularName(self):
if (self.Suffix == ""):
return "%s %s" % (self.FirstName, self.Surname)
else:
return "%s %s, %s" % (self.FirstName, self.Surname, self.Suffix)
def setNote(self,note) :
if self.note == None:
self.note = Note()
self.note.set(note)
2001-06-16 08:55:26 +05:30
def getNote(self) :
if self.note == None:
return ""
else:
return self.note.get()
2001-06-16 08:55:26 +05:30
def setNoteObj(self,note) :
self.note = note
2001-06-16 08:55:26 +05:30
def getNoteObj(self):
if self.note == None:
self.note = Note()
2001-06-16 08:55:26 +05:30
return self.note
def setSourceRef(self,id) :
self.source_ref = id
def getSourceRef(self) :
if not self.source_ref:
self.source_ref = SourceRef()
2001-06-16 08:55:26 +05:30
return self.source_ref
def are_equal(self,other):
if self.FirstName != other.FirstName:
return 0
if self.Surname != other.Surname:
return 0
if self.Suffix != other.Suffix:
return 0
if self.Title != other.Title:
return 0
if self.private != other.private:
return 0
if self.confidence != other.confidence:
return 0
if self.getNote() != other.getNote():
return 0
if not self.getSourceRef().are_equal(other.getSourceRef()):
return 0
return 1
2001-05-13 07:26:57 +05:30
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class Url:
def __init__(self,source=None):
if source:
self.path = source.path
self.desc = source.desc
self.private = source.private
else:
self.path = ""
self.desc = ""
self.private = 0
def setPrivacy(self,val):
self.private = val
def getPrivacy(self):
return self.private
2001-05-13 07:26:57 +05:30
def set_path(self,path):
self.path = path
def get_path(self):
return self.path
def set_description(self,description):
self.desc = description
def get_description(self):
return self.desc
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class Person:
male = 1
female = 0
def __init__(self):
self.id = ""
self.PrimaryName = None
2001-05-13 07:26:57 +05:30
self.EventList = []
self.FamilyList = []
self.AltFamilyList = []
self.MainFamily = None
self.photoList = []
self.nickname = ""
self.alternateNames = []
self.gender = 0
self.death = None
self.birth = None
2001-05-13 07:26:57 +05:30
self.addressList = []
self.attributeList = []
self.urls = []
self.note = None
2001-05-13 07:26:57 +05:30
self.paf_uid = ""
2001-08-06 08:30:01 +05:30
self.position = None
2001-05-13 07:26:57 +05:30
def setPrimaryName(self,name) :
self.PrimaryName = name
def getPrimaryName(self) :
if not self.PrimaryName:
self.PrimaryName = Name()
2001-05-13 07:26:57 +05:30
return self.PrimaryName
def setPafUid(self,val) :
self.paf_uid = val
def getPafUid(self) :
return self.paf_uid
def getAlternateNames(self):
return self.alternateNames
def setAlternateNames(self,list):
self.alternateNames = list
2001-05-13 07:26:57 +05:30
def addAlternateName(self,name):
self.alternateNames.append(name)
def getUrlList(self):
return self.urls
def setUrlList(self,list):
self.urls = list
2001-05-13 07:26:57 +05:30
def addUrl(self,url):
self.urls.append(url)
def setId(self,id) :
self.id = str(id)
2001-05-13 07:26:57 +05:30
def getId(self) :
return self.id
def setNickName(self,name) :
self.nickname = name
def getNickName(self) :
return self.nickname
def setGender(self,val) :
self.gender = val
def getGender(self) :
return self.gender
def setBirth(self,event) :
self.birth = event
def setDeath(self,event) :
self.death = event
def getBirth(self) :
if self.birth == None:
self.birth = Event()
self.birth.name = "Birth"
2001-05-13 07:26:57 +05:30
return self.birth
def getDeath(self) :
if self.death == None:
self.death = Event()
self.death.name = "Death"
2001-05-13 07:26:57 +05:30
return self.death
def addPhoto(self,photo):
self.photoList.append(photo)
def getPhotoList(self):
return self.photoList
def addEvent(self,event) :
self.EventList.append(event)
def getEventList(self) :
return self.EventList
def setEventList(self,list) :
self.EventList = list
2001-05-13 07:26:57 +05:30
def addFamily(self,family) :
self.FamilyList.append(family)
def getFamilyList(self) :
return self.FamilyList
def removeFamily(self,family):
index = 0
for fam in self.FamilyList:
if fam == family:
del self.FamilyList[index]
return
index = index + 1
def addAddress(self,address) :
self.addressList.append(address)
def removeAddress(self,address):
index = 0
for addr in self.addressList:
if addr == address:
del self.addressList[index]
return
index = index + 1
def getAddressList(self) :
return self.addressList
def setAddressList(self,list) :
self.addressList = list
2001-05-13 07:26:57 +05:30
def addAttribute(self,attribute) :
self.attributeList.append(attribute)
def removeAttribute(self,attribute):
index = 0
for attr in self.attributeList:
if attr == attribute:
del self.attributeList[index]
return
index = index + 1
def getAttributeList(self) :
return self.attributeList
def setAttributeList(self,list) :
self.attributeList = list
2001-05-13 07:26:57 +05:30
def getAltFamilyList(self) :
return self.AltFamilyList
def addAltFamily(self,family,mrel,frel) :
self.AltFamilyList.append((family,mrel,frel))
2001-05-13 07:26:57 +05:30
def removeAltFamily(self,family):
index = 0
for fam in self.AltFamilyList:
if fam[0] == family:
del self.AltFamilyList[index]
return
index = index + 1
def getFamilyIndex(self,index) :
return self.FamilyList[index]
def setMainFamily(self,family) :
self.MainFamily = family
def getMainFamily(self) :
return self.MainFamily
def setNote(self,note) :
if self.note == None:
self.note = Note()
self.note.set(note)
2001-05-13 07:26:57 +05:30
def getNote(self) :
if self.note == None:
return ""
else:
return self.note.get()
def setNoteObj(self,note) :
self.note = note
def getNoteObj(self):
if self.note == None:
self.note = Note()
2001-05-13 07:26:57 +05:30
return self.note
2001-08-06 08:30:01 +05:30
def setPosition(self,pos):
self.position = pos
def getPosition(self):
return self.position
2001-05-13 07:26:57 +05:30
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class Event:
def __init__(self,source=None):
if source:
self.place = source.place
self.date = Date(source.date)
self.description = source.description
self.name = source.name
if source.source_ref:
self.source_ref = SourceRef(source.source_ref)
else:
self.source_ref = None
if source.note:
self.note = Note(source.note.get())
else:
self.note = None
self.confidence = source.confidence
self.private = source.private
else:
self.place = None
self.date = Date()
self.description = ""
self.name = ""
self.source_ref = None
self.note = None
self.confidence = 2
self.private = 0
def setPrivacy(self,val):
self.private = val
def getPrivacy(self):
return self.private
def setConfidence(self,val):
self.confidence = val
def getConfidence(self):
return self.confidence
2001-05-13 07:26:57 +05:30
def set(self,name,date,place,description):
self.name = name
self.place = place
self.description = description
self.setDate(date)
def are_equal(self,other):
2001-05-13 07:26:57 +05:30
if other == None:
return 0
if self.name != other.name:
return 0
if self.place != other.place:
return 0
if compare_dates(self.date,other.date):
return 0
if self.description != other.description:
return 0
if self.confidence != other.confidence:
return 0
if self.private != other.private:
return 0
if not self.getSourceRef().are_equal(other.getSourceRef()):
return 0
return 1
2001-05-13 07:26:57 +05:30
def setName(self,name) :
self.name = name
def getName(self) :
return self.name
def setSourceRef(self,id) :
self.source_ref = id
2001-05-13 07:26:57 +05:30
def getSourceRef(self) :
if not self.source_ref:
self.source_ref = SourceRef()
return self.source_ref
2001-05-13 07:26:57 +05:30
def setPlace(self,place) :
self.place = place
def getPlace(self) :
return self.place
def getPlaceName(self) :
if self.place:
return self.place.get_title()
else:
return ""
def setNote(self,note) :
if self.note == None:
self.note = Note()
self.note.set(note)
def getNote(self) :
if self.note == None:
return ""
else:
return self.note.get()
def setNoteObj(self,note) :
self.note = note
def getNoteObj(self):
if self.note == None:
self.note = Note()
return self.note
2001-05-13 07:26:57 +05:30
def setDescription(self,description) :
self.description = description
def getDescription(self) :
return self.description
def setDate(self, date) :
self.date.set(date)
def getDate(self) :
return self.date.getDate()
def getQuoteDate(self) :
return self.date.getQuoteDate()
2001-05-13 07:26:57 +05:30
def getDateObj(self) :
return self.date
def getSaveDate(self) :
return self.date.getSaveDate()
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class Family:
def __init__(self):
self.Father = None
self.Mother = None
self.Children = []
self.Marriage = None
self.Divorce = None
self.type = "Married"
2001-05-13 07:26:57 +05:30
self.EventList = []
self.id = ""
2001-05-13 07:26:57 +05:30
self.photoList = []
self.note = Note()
2001-06-03 04:26:04 +05:30
self.attributeList = []
self.position = None
def setPosition(self,pos):
self.position = pos
def getPosition(self):
return self.position
2001-06-03 04:26:04 +05:30
def addAttribute(self,attribute) :
self.attributeList.append(attribute)
def removeAttribute(self,attribute):
index = 0
for attr in self.attributeList:
if attr == attribute:
del self.attributeList[index]
return
index = index + 1
def getAttributeList(self) :
return self.attributeList
def setAttributeList(self,list) :
self.attributeList = list
def getNote(self):
return self.note.get()
def setNote(self,text):
self.note.set(text)
def getNoteObj(self):
return self.note
def setNoteObj(self,obj):
self.note = obj
2001-05-13 07:26:57 +05:30
def setId(self,id) :
self.id = str(id)
2001-05-13 07:26:57 +05:30
def getId(self) :
return self.id
def setRelationship(self,type):
self.type = type
def getRelationship(self):
return self.type
2001-05-13 07:26:57 +05:30
def setFather(self,person):
self.Father = person
def getFather(self):
return self.Father
def setMother(self,person):
self.Mother = person
def getMother(self):
return self.Mother
def addChild(self,person):
if person not in self.Children:
self.Children.append(person)
def removeChild(self,person):
index = 0
for child in self.Children:
if child == person:
del self.Children[index]
return
index = index + 1
def getChildList(self):
return self.Children
def getMarriage(self):
for e in self.EventList:
if e.getName() == "Marriage":
return e
return None
2001-05-13 07:26:57 +05:30
def getDivorce(self):
for e in self.EventList:
if e.getName() == "Divorce":
return e
return None
2001-05-13 07:26:57 +05:30
def addEvent(self,event) :
self.EventList.append(event)
def getEventList(self) :
return self.EventList
def setEventList(self,list) :
self.EventList = list
2001-05-13 07:26:57 +05:30
def addPhoto(self,photo):
self.photoList.append(photo)
def getPhotoList(self):
return self.photoList
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class Source:
2001-05-13 07:26:57 +05:30
def __init__(self):
self.title = ""
self.author = ""
self.pubinfo = ""
self.callno = ""
self.note = Note()
self.photoList = []
self.id = ""
2001-05-13 07:26:57 +05:30
def setId(self,newId):
self.id = str(newId)
2001-05-13 07:26:57 +05:30
def getId(self):
return self.id
def addPhoto(self,photo):
self.photoList.append(photo)
def getPhotoList(self):
return self.photoList
2001-05-13 07:26:57 +05:30
def setTitle(self,title):
self.title = title
def getTitle(self):
return self.title
def setNote(self,text):
self.note.set(text)
def getNote(self):
return self.note.get()
def setNoteObj(self,obj):
self.note = obj
def getNoteObj(self):
return self.note
2001-05-13 07:26:57 +05:30
def setAuthor(self,author):
self.author = author
def getAuthor(self):
return self.author
def setPubInfo(self,text):
self.pubinfo = text
def getPubInfo(self):
return self.pubinfo
def setCallNumber(self,val):
self.callno = val
def getCallNumber(self):
return self.callno
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class SourceRef:
def __init__(self,source=None):
if source:
self.ref = source.ref
self.page = source.page
self.date = Date(source.date)
self.comments = Note(source.comments.get())
self.text = source.text
else:
self.ref = None
self.page = ""
self.date = Date()
self.comments = Note()
self.text = ""
2001-05-13 07:26:57 +05:30
def setBase(self,ref):
self.ref = ref
def getBase(self):
return self.ref
def setDate(self,date):
self.date = date
def getDate(self):
return self.date
def setPage(self,page):
self.page = page
def getPage(self):
return self.page
def setText(self,text):
self.text = text
def getText(self):
return self.text
def setNoteObj(self,note):
self.comments = note
2001-05-13 07:26:57 +05:30
def setComments(self,comments):
self.comments.set(comments)
def getComments(self):
return self.comments.get()
def are_equal(self,other):
if self.ref and other.ref:
if self.page != other.page:
return 0
if compare_dates(self.date,other.date) != 0:
return 0
if self.getText() != other.getText():
return 0
if self.getComments() != other.getComments():
return 0
elif not self.ref and not other.ref:
return 1
else:
return 0
2001-05-13 07:26:57 +05:30
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelDataBase:
def __init__(self):
self.new()
def new(self):
self.personMap = {}
self.familyMap = {}
self.sourceMap = {}
self.placeMap = {}
2001-05-13 07:26:57 +05:30
self.smapIndex = 0
self.pmapIndex = 0
self.fmapIndex = 0
self.lmapIndex = 0
2001-05-13 07:26:57 +05:30
self.default = None
self.owner = Researcher()
self.bookmarks = []
self.path = ""
self.place2title = {}
2001-05-13 07:26:57 +05:30
def getBookmarks(self):
return self.bookmarks
2001-05-13 07:26:57 +05:30
def clean_bookmarks(self):
new_bookmarks = []
for person in self.bookmarks:
new_bookmarks.append(person)
self.bookmarks = new_bookmarks
def setResearcher(self,owner):
self.owner.set(owner.getName(),owner.getAddress(),owner.getCity(),\
owner.getState(),owner.getCountry(),\
owner.getPostalCode(),owner.getPhone(),owner.getEmail())
def getResearcher(self):
return self.owner
def setDefaultPerson(self,person):
self.default = person
def getDefaultPerson(self):
return self.default
def getPersonMap(self):
return self.personMap
def setPersonMap(self,map):
self.personMap = map
def getPlaceFromTitle(self,title):
for val in self.placeMap.keys():
p = self.placeMap[val]
if title == p.title:
return p
return None
def getPlaceMap(self):
return self.placeMap
def setPlaceMap(self,map):
self.placeMap = map
2001-05-13 07:26:57 +05:30
def getFamilyMap(self):
return self.familyMap
def setFamilyMap(self,map):
self.familyMap = map
def getSavePath(self):
return self.path
def setSavePath(self,path):
self.path = path
def getSourceMap(self):
return self.sourceMap
def addPerson(self,person):
2001-07-16 07:36:31 +05:30
index = "I%d" % self.pmapIndex
while self.personMap.has_key(index):
self.pmapIndex = self.pmapIndex + 1
index = "I%d" % self.pmapIndex
2001-05-13 07:26:57 +05:30
person.setId(index)
self.personMap[index] = person
self.pmapIndex = self.pmapIndex + 1
return index
def getPersonEventTypes(self):
map = {}
for person in self.personMap.values():
for event in person.getEventList():
map[event.getName()] = 1
return map.keys()
def getPersonAttributeTypes(self):
map = {}
for person in self.personMap.values():
for attr in person.getAttributeList():
map[attr.getType()] = 1
return map.keys()
2001-06-03 04:26:04 +05:30
def getFamilyAttributeTypes(self):
map = {}
for family in self.familyMap.values():
for attr in family.getAttributeList():
map[attr.getType()] = 1
return map.keys()
2001-07-03 22:44:17 +05:30
def getFamilyEventTypes(self):
map = {}
for family in self.familyMap.values():
for attr in family.getEventList():
map[attr.getName()] = 1
return map.keys()
def getPlaces(self):
map = []
for place in self.placeMap.values():
map.append(place.get_title())
return map[:]
def getFamilyRelationTypes(self):
map = {}
for family in self.familyMap.values():
map[family.getRelationship()] = 1
return map.keys()
2001-05-13 07:26:57 +05:30
def findPerson(self,idVal,map):
idVal = str(idVal)
2001-05-13 07:26:57 +05:30
if map.has_key(idVal):
person = self.personMap[map[idVal]]
else:
person = Person()
map[idVal] = self.addPerson(person)
return person
def addPersonNoMap(self,person,id):
id = str(id)
2001-05-13 07:26:57 +05:30
person.setId(id)
self.personMap[id] = person
2001-07-16 07:36:31 +05:30
self.pmapIndex = self.pmapIndex+1
2001-05-13 07:26:57 +05:30
return id
def findPersonNoMap(self,idVal):
val = str(idVal)
2001-05-13 07:26:57 +05:30
if self.personMap.has_key(val):
person = self.personMap[val]
else:
person = Person()
self.addPersonNoMap(person,val)
return person
def getNextPersonId(self):
return self.pmapIndex
def getNextFamilyId(self):
return self.fmapIndex
def getNextSourceId(self):
return self.smapIndex
def getNextPlaceId(self):
return self.lmapIndex
2001-05-13 07:26:57 +05:30
def addSource(self,source):
2001-07-16 07:36:31 +05:30
index = "S%d" % self.smapIndex
while self.sourceMap.has_key(index):
self.smapIndex = self.smapIndex + 1
index = "S%d" % self.smapIndex
2001-05-13 07:26:57 +05:30
source.setId(index)
self.sourceMap[index] = source
self.smapIndex = self.smapIndex + 1
return index
def addPlace(self,place):
index = "P%d" % self.lmapIndex
while self.placeMap.has_key(index):
self.lmapIndex = self.lmapIndex + 1
index = "P%d" % self.lmapIndex
place.setId(index)
self.placeMap[index] = place
self.lmapIndex = self.lmapIndex + 1
return index
2001-05-13 07:26:57 +05:30
def findSource(self,idVal,map):
idVal = str(idVal)
2001-05-13 07:26:57 +05:30
if map.has_key(idVal):
source = self.sourceMap[map[idVal]]
else:
source = Source()
2001-05-13 07:26:57 +05:30
map[idVal] = self.addSource(source)
return source
def findPlace(self,idVal,map):
idVal = str(idVal)
if map.has_key(idVal):
place = self.placeMap[map[idVal]]
else:
palce = Place()
map[idVal] = self.addPlace(place)
return place
2001-05-13 07:26:57 +05:30
def addSourceNoMap(self,source,index):
index = str(index)
2001-05-13 07:26:57 +05:30
source.setId(index)
self.sourceMap[index] = source
2001-07-16 07:36:31 +05:30
self.smapIndex = self.smapIndex + 1
2001-05-13 07:26:57 +05:30
return index
def addPlaceNoMap(self,place,index):
index = str(index)
place.setId(index)
self.placeMap[index] = place
self.lmapIndex = self.lmapIndex + 1
return index
2001-05-13 07:26:57 +05:30
def findSourceNoMap(self,idVal):
val = str(idVal)
2001-05-13 07:26:57 +05:30
if self.sourceMap.has_key(val):
source = self.sourceMap[val]
else:
source = Source()
2001-05-13 07:26:57 +05:30
self.addSourceNoMap(source,val)
return source
def findPlaceNoMap(self,idVal):
val = str(idVal)
if self.placeMap.has_key(val):
place = self.placeMap[val]
else:
place = Place()
self.addPlaceNoMap(place,val)
return place
2001-05-13 07:26:57 +05:30
def newFamily(self):
2001-07-16 07:36:31 +05:30
index = "F%d" % self.fmapIndex
while self.familyMap.has_key(index):
self.fmapIndex = self.fmapIndex + 1
index = "F%d" % self.fmapIndex
2001-05-13 07:26:57 +05:30
self.fmapIndex = self.fmapIndex + 1
family = Family()
2001-07-16 07:36:31 +05:30
family.setId(index)
self.familyMap[index] = family
2001-05-13 07:26:57 +05:30
return family
def newFamilyNoMap(self,id):
family = Family()
id = str(id)
2001-05-13 07:26:57 +05:30
family.setId(id)
self.familyMap[id] = family
2001-07-16 07:36:31 +05:30
self.fmapIndex = self.fmapIndex + 1
2001-05-13 07:26:57 +05:30
return family
def findFamily(self,idVal,map):
idVal = str(idVal)
2001-05-13 07:26:57 +05:30
if map.has_key(idVal):
family = self.familyMap[map[idVal]]
else:
family = self.newFamily()
map[idVal] = family.getId()
return family
def findFamilyNoMap(self,idVal):
val = str(idVal)
2001-05-13 07:26:57 +05:30
if self.familyMap.has_key(val):
family = self.familyMap[val]
else:
family = self.newFamilyNoMap(val)
return family
def deleteFamily(self,family):
if self.familyMap.has_key(family.getId()):
del self.familyMap[family.getId()]