Exemplo n.º 1
0
 def create_event(self,type,desc=None,date=None,place=None,source=None):
     event = Event()
     if type:
         event.set_type(EventType(type))
     if desc:
         event.set_description(desc)
     if date:
         event.set_date_object(date)
     if place:
         event.set_place_handle(place.get_handle())
     if source:
         event.add_citation(source.get_handle())
     self.db.add_event(event,self.trans)
     self.db.commit_event(event,self.trans)
     return event
Exemplo n.º 2
0
 def create_event(self,type,desc=None,date=None,place=None,source=None):
     event = Event()
     if type:
         event.set_type(EventType(type))
     if desc:
         event.set_description(desc)
     if date:
         event.set_date_object(date)
     if place:
         event.set_place_handle(place.get_handle())
     if source:
         event.add_citation(source.get_handle())
     self.db.add_event(event,self.trans)
     self.db.commit_event(event,self.trans)
     return event
Exemplo n.º 3
0
    def __add_resi_event(self, person, placename, date_object):
        pn = PlaceName()
        pn.set_value(placename)
        place = Place()
        place.set_name(pn)
        placehandle = self.dbstate.db.add_place(place, self.trans)

        e = Event()
        e.set_type(EventType.RESIDENCE)
        e.set_date_object(date_object)
        e.set_place_handle(placehandle)
        e.set_description("marriage")
        eventhandle = self.dbstate.db.add_event(e, self.trans)

        eref = EventRef()
        eref.ref = eventhandle
        person.add_event_ref(eref)
        self.dbstate.db.commit_person(person, self.trans)
Exemplo n.º 4
0
 def get_or_create_event(self,
                         object_,
                         type_,
                         date=None,
                         place=None,
                         source=None):
     """ Add or find a type event on object """
     # first, see if it exists
     LOG.debug("get_or_create_event")
     ref_list = object_.get_event_ref_list()
     LOG.debug("refs: %s", ref_list)
     # look for a match, and possible correction
     for ref in ref_list:
         event = self.db.get_event_from_handle(ref.ref)
         LOG.debug("   compare event type %s == %s", int(event.get_type()),
                   type_)
         if int(event.get_type()) == type_:
             # Match! Let's update
             if date:
                 event.set_date_object(date)
             if place:
                 event.set_place_handle(place.get_handle())
             if source:
                 self.find_and_set_citation(event, source)
             self.db.commit_event(event, self.trans)
             LOG.debug("   returning existing event")
             return (0, event)
     # else create it:
     LOG.debug("   creating event")
     event = Event()
     if type_:
         event.set_type(EventType(type_))
     if date:
         event.set_date_object(date)
     if place:
         event.set_place_handle(place.get_handle())
     if source:
         self.find_and_set_citation(event, source)
     self.db.add_event(event, self.trans)
     return (1, event)
Exemplo n.º 5
0
 def get_or_create_event(self, object_, type_, date=None, place=None,
                         source=None):
     """ Add or find a type event on object """
     # first, see if it exists
     LOG.debug("get_or_create_event")
     ref_list = object_.get_event_ref_list()
     LOG.debug("refs: %s", ref_list)
     # look for a match, and possible correction
     for ref in ref_list:
         event = self.db.get_event_from_handle(ref.ref)
         LOG.debug("   compare event type %s == %s", int(event.get_type()),
                   type_)
         if int(event.get_type()) == type_:
             # Match! Let's update
             if date:
                 event.set_date_object(date)
             if place:
                 event.set_place_handle(place.get_handle())
             if source:
                 self.find_and_set_citation(event, source)
             self.db.commit_event(event, self.trans)
             LOG.debug("   returning existing event")
             return (0, event)
     # else create it:
     LOG.debug("   creating event")
     event = Event()
     if type_:
         event.set_type(EventType(type_))
     if date:
         event.set_date_object(date)
     if place:
         event.set_place_handle(place.get_handle())
     if source:
         self.find_and_set_citation(event, source)
     self.db.add_event(event, self.trans)
     return (1, event)