示例#1
0
 def update(self, other):
     cur=get_db_connection().cursor(cursor_factory=psycopg2.extras.NamedTupleCursor)
     data=(other.common_name, other.url, self.sid)
     cur.execute(Publisher.sql_dict["update_publisher"],data)
     cur.close()
     
     get_db_connection().commit()
     
示例#2
0
 def update(self, model_text=None):
     cur = get_db_connection().cursor(
         cursor_factory=psycopg2.extras.NamedTupleCursor)
     data = (
         model_text,
         self.sid,
     )
     cur.execute(ModelText.sql_dict["update"], data)
     cur.close()
     get_db_connection().commit()
 def populate_model(self):
     self.treemodel.clear()                        
     cur=get_db_connection().cursor(cursor_factory=psycopg2.extras.NamedTupleCursor)
     data=(self.forecast.sid,self.forecast.sid,)
     cur.execute("""SELECT 
                     fc_person.sid as sid, fc_person.common_name, fc_originator_person.originator_sid,'person' as origin_type 
                     FROM 
                     fc_forecast_originator, fc_originator_person, fc_person 
                     WHERE
                     fc_forecast_originator.forecast_sid=%s AND 
                     fc_forecast_originator.originator_sid=fc_originator_person.originator_sid AND
                     fc_originator_person.person_sid=fc_person.sid
                     UNION
                     SELECT 
                     fc_organization.sid as sid, fc_organization.common_name, fc_originator_organisation.originator_sid,'organisation'  as origin_type  
                     FROM 
                     fc_forecast_originator, fc_originator_organisation, fc_organization
                     WHERE
                     fc_forecast_originator.forecast_sid=%s AND 
                     fc_forecast_originator.originator_sid=fc_originator_organisation.originator_sid AND
                     fc_originator_organisation.organisation_sid=fc_organization.sid
                     """,data)
     for p in cur.fetchall():
         if p.origin_type=='person':
             self.treemodel.append([ "%s" % p.originator_sid, "%s" % p.sid, None, p.origin_type, p.common_name])
         elif p.origin_type=='organisation':
             self.treemodel.append([ "%s" % p.originator_sid, None,"%s" % p.sid, p.origin_type, p.common_name])
         else:
             raise Exception("unknown type: %s, expected person or organisation" % p.origin_type)
     cur.close()
示例#4
0
 def load(self):
     cur=get_db_connection().cursor(cursor_factory=psycopg2.extras.NamedTupleCursor)
     data=(self.sid,)
     cur.execute(self.sql_dict["load"],data)
     for p in cur.fetchall():
         self.load_object_from_db(p)
     cur.close()
示例#5
0
 def update(self, other):
     cur=get_db_connection().cursor(cursor_factory=psycopg2.extras.NamedTupleCursor)
     data=(other.common_name, other.birth_date, other.birth_place, self.sid)
     cur.execute(Person.sql_dict["update_person"],data)
     cur.close()
     
     # update person_names
     # delete outdated person_names
     for person_name in self.names:
         if person_name not in other.names:
             person_name.delete()
             
     for person_name in other.names:
         if person_name not in self.names:
             person_name.insert()
         
     get_db_connection().commit()
示例#6
0
 def update(self, other):
     cur=get_db_connection().cursor(cursor_factory=psycopg2.extras.NamedTupleCursor)
     data=(other.common_name, self.sid)
     cur.execute(FCObject.sql_dict["update"],data)
     cur.close()
     
     # update object-properties
     # delete outdated object_properties
     for object_property in self.object_properties:
         if object_property not in other.object_properties:
             object_property.delete()
             
     for object_property in other.object_properties:
         if object_property not in self.object_properties:
             object_property.insert()
         
     get_db_connection().commit()
示例#7
0
 def get_all_for_foreign_key(self,foreign_key):
     objectlist=[]
     cur = get_db_connection().cursor(cursor_factory=psycopg2.extras.NamedTupleCursor)
     cur.execute(self.sql_dict["get_all_foreign_key"],(foreign_key,))
     for r in cur.fetchall():
         objectlist.append(self.fabric_method(r))
     cur.close()
     return objectlist
示例#8
0
    def update(self, other):
        cur = get_db_connection().cursor(
            cursor_factory=psycopg2.extras.NamedTupleCursor)
        data = (other.common_name, self.sid)
        cur.execute(FCObject.sql_dict["update"], data)
        cur.close()

        # update object-properties
        # delete outdated object_properties
        for object_property in self.object_properties:
            if object_property not in other.object_properties:
                object_property.delete()

        for object_property in other.object_properties:
            if object_property not in self.object_properties:
                object_property.insert()

        get_db_connection().commit()
示例#9
0
    def update(self, other):
        cur = get_db_connection().cursor(
            cursor_factory=psycopg2.extras.NamedTupleCursor)
        data = (other.common_name, other.birth_date, other.birth_place,
                self.sid)
        cur.execute(Person.sql_dict["update_person"], data)
        cur.close()

        # update person_names
        # delete outdated person_names
        for person_name in self.names:
            if person_name not in other.names:
                person_name.delete()

        for person_name in other.names:
            if person_name not in self.names:
                person_name.insert()

        get_db_connection().commit()
示例#10
0
 def load_model_text(self):
     self.model_text=None
     cur=get_db_connection().cursor(cursor_factory=psycopg2.extras.NamedTupleCursor)
     data=(self.sid,)
     cur.execute("""SELECT
                     sid, model_text 
                     FROM 
                     fc_model_text
                     WHERE
                     forecast_sid=%s
                     """,data)
     for p in cur.fetchall():
         self.model_text=ModelText(sid=p.sid, model_text=p.model_text, forecast_sid=self.sid)
     cur.close()        
 def populate_model(self):
     self.treemodel.clear()
     cur=get_db_connection().cursor(cursor_factory=psycopg2.extras.NamedTupleCursor)
     data=(self.forecast.sid,)
     cur.execute("""SELECT
                     sid, substring(model_text from 1 for 100) as model_text 
                     FROM 
                     fc_model_text
                     WHERE
                     forecast_sid=%s
                     """,data)
     for p in cur.fetchall():
         self.treemodel.append([ "%s" % p.sid, "%s" % p.model_text])
     cur.close()
 def populate_model(self):
     self.treemodel.clear()
     cur = get_db_connection().cursor(
         cursor_factory=psycopg2.extras.NamedTupleCursor)
     data = (self.forecast.sid, )
     cur.execute(
         """SELECT
                     sid, substring(model_text from 1 for 100) as model_text 
                     FROM 
                     fc_model_text
                     WHERE
                     forecast_sid=%s
                     """, data)
     for p in cur.fetchall():
         self.treemodel.append(["%s" % p.sid, "%s" % p.model_text])
     cur.close()
示例#13
0
 def load_model_text(self):
     self.model_text = None
     cur = get_db_connection().cursor(
         cursor_factory=psycopg2.extras.NamedTupleCursor)
     data = (self.sid, )
     cur.execute(
         """SELECT
                     sid, model_text 
                     FROM 
                     fc_model_text
                     WHERE
                     forecast_sid=%s
                     """, data)
     for p in cur.fetchall():
         self.model_text = ModelText(sid=p.sid,
                                     model_text=p.model_text,
                                     forecast_sid=self.sid)
     cur.close()
示例#14
0
 def populate_model(self):
     self.treemodel.clear()
     cur = get_db_connection().cursor(
         cursor_factory=psycopg2.extras.NamedTupleCursor)
     data = (
         self.forecast.sid,
         self.forecast.sid,
     )
     cur.execute(
         """SELECT 
                     fc_person.sid as sid, fc_person.common_name, fc_originator_person.originator_sid,'person' as origin_type 
                     FROM 
                     fc_forecast_originator, fc_originator_person, fc_person 
                     WHERE
                     fc_forecast_originator.forecast_sid=%s AND 
                     fc_forecast_originator.originator_sid=fc_originator_person.originator_sid AND
                     fc_originator_person.person_sid=fc_person.sid
                     UNION
                     SELECT 
                     fc_organization.sid as sid, fc_organization.common_name, fc_originator_organisation.originator_sid,'organisation'  as origin_type  
                     FROM 
                     fc_forecast_originator, fc_originator_organisation, fc_organization
                     WHERE
                     fc_forecast_originator.forecast_sid=%s AND 
                     fc_forecast_originator.originator_sid=fc_originator_organisation.originator_sid AND
                     fc_originator_organisation.organisation_sid=fc_organization.sid
                     """, data)
     for p in cur.fetchall():
         if p.origin_type == 'person':
             self.treemodel.append([
                 "%s" % p.originator_sid,
                 "%s" % p.sid, None, p.origin_type, p.common_name
             ])
         elif p.origin_type == 'organisation':
             self.treemodel.append([
                 "%s" % p.originator_sid, None,
                 "%s" % p.sid, p.origin_type, p.common_name
             ])
         else:
             raise Exception(
                 "unknown type: %s, expected person or organisation" %
                 p.origin_type)
     cur.close()
示例#15
0
def enum_retrieve_valid_values(enum_type):
    enum_values_list = []
    cur = get_db_connection().cursor(
        cursor_factory=psycopg2.extras.NamedTupleCursor)
    cur.execute(""" 
            select 
                e.enumlabel as enum_value
            from 
                pg_type t 
            join 
                pg_enum e 
            on 
                t.oid = e.enumtypid  
            join 
                pg_catalog.pg_namespace n 
            ON 
                n.oid = t.typnamespace
            where
	            t.typname='%s'
            """ % enum_type)
    for enum_values in cur.fetchall():
        enum_values_list.append(enum_values.enum_value)
    cur.close()
    return enum_values_list
    def populate_model(self):
        self.treemodel.clear()
        cur=get_db_connection().cursor(cursor_factory=psycopg2.extras.NamedTupleCursor)
        data=(self.forecast.sid,)
        cur.execute("""SELECT 
                        fc_publication.sid as publication_sid, 
                        fc_publisher.publisher_common_name, fc_publication.title, fc_publication.publishing_date,
                         fc_publication.publication_url, fc_forecast_publication.sid  as forecast_publication_sid  
                        FROM 
                        fc_forecast_publication, fc_publication, fc_publisher 
                        WHERE
                        fc_forecast_publication.forecast_sid=%s AND
                        fc_forecast_publication.publication_sid=fc_publication.sid AND  
                        fc_publication.publisher_sid=fc_publisher.sid 
                        """,data)
        for p in cur.fetchall():
            self.treemodel.append([ "%s" % p.publication_sid, p.publisher_common_name, p.title, p.publishing_date.strftime('%d.%m.%Y'),p.publication_url, "%s" % p.forecast_publication_sid])
        cur.close()
        
        

        
        
        
 def populate_model(self):
     self.treemodel.clear()
     cur = get_db_connection().cursor(
         cursor_factory=psycopg2.extras.NamedTupleCursor)
     data = (self.forecast.sid, )
     cur.execute(
         """SELECT 
                     fc_publication.sid as publication_sid, 
                     fc_publisher.publisher_common_name, fc_publication.title, fc_publication.publishing_date,
                      fc_publication.publication_url, fc_forecast_publication.sid  as forecast_publication_sid  
                     FROM 
                     fc_forecast_publication, fc_publication, fc_publisher 
                     WHERE
                     fc_forecast_publication.forecast_sid=%s AND
                     fc_forecast_publication.publication_sid=fc_publication.sid AND  
                     fc_publication.publisher_sid=fc_publisher.sid 
                     """, data)
     for p in cur.fetchall():
         self.treemodel.append([
             "%s" % p.publication_sid, p.publisher_common_name, p.title,
             p.publishing_date.strftime('%d.%m.%Y'), p.publication_url,
             "%s" % p.forecast_publication_sid
         ])
     cur.close()
    def populate_model(self):
        self.treemodel.clear()
        cur=get_db_connection().cursor(cursor_factory=psycopg2.extras.NamedTupleCursor)
        data=(self.fcmodel)
        cur.execute("""SELECT 
                        fc_object_property_state.sid as state_sid,
                        fc_object_property_state.object_property_sid as object_property_sid,
                        fc_object_property_state.model_sid as model_sid,
                        fc_object_property.common_name as object_property,
                        fc_object_property_state.point_in_time,
                        fc_object_property_state.object_property_state_value as state_value,
                        fc_object.common_name as object_common_name
                        FROM
                        fc_object_property, fc_object_property_state, fc_object
                        WHERE
                        fc_object_property.sid=fc_object_property_state.object_property_sid AND
                        fc_object_property.object_sid=fc_object.sid AND 
                        fc_object_property_state.model_sid=%s
                        """,data)

        for p in cur.fetchall():
            self.treemodel.append(["%s" % p.state_sid, "%s" % p.object_property_sid, "%s" % self.fcmodel, p.object_common_name, p.object_property, "%s" % p.point_in_time.lower, "%s" % p.point_in_time.upper, p.state_value])
        #self.treemodel.append(['1','1','1','test','12.02.2012','value'])
        cur.close()
示例#19
0
 def delete(self):
     cur = get_db_connection().cursor()
     cur.execute(self.sql_dict["delete"],self.get_delete_data())
     cur.close()
     get_db_connection().commit()
示例#20
0
 def insert(self):
     cur = get_db_connection().cursor()        
     cur.execute(self.sql_dict["insert"],self.get_insert_data())
     self.sid=cur.fetchone()[0]
     cur.close()
     get_db_connection().commit()
示例#21
0
 def insert(self):
     super(FCObject, self).insert()
     for object_property in self.object_properties:
         object_property.object_sid = self.sid
         object_property.insert()
     get_db_connection().commit()
示例#22
0
 def insert(self):
     super(Person, self).insert()
     for name in self.names:
         name.person_sid = self.sid
         name.insert()
     get_db_connection().commit()
示例#23
0
 def insert(self):
     super(Person, self).insert()
     for name in self.names:
         name.person_sid=self.sid
         name.insert()
     get_db_connection().commit()
示例#24
0
 def update(self, model_text=None):
     cur=get_db_connection().cursor(cursor_factory=psycopg2.extras.NamedTupleCursor)
     data=(model_text, self.sid,)
     cur.execute(ModelText.sql_dict["update"], data)
     cur.close()
     get_db_connection().commit()
示例#25
0
 def insert(self):
     super(FCObject, self).insert()
     for object_property in self.object_properties:
         object_property.object_sid=self.sid
         object_property.insert()
     get_db_connection().commit()