class RawTextOverviewComponent(AbstractDataOverviewComponent):

    treecolumns = [
        TreeviewColumn("model_text_sid", 0, True),
        TreeviewColumn("model text", 1, False)
    ]

    def __init__(self, forecast):
        self.forecast = forecast
        super(RawTextOverviewComponent,
              self).__init__(RawTextOverviewComponent.treecolumns)

    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()
class TextModelOverviewComponent(AbstractDataOverviewComponent):
    
    treecolumns=[TreeviewColumn("forecast_sid", 0, True), TreeviewColumn("model_sid", 1, True), 
                TreeviewColumn("Date", 2, False), TreeviewColumn("Short desc.", 3, False),
                TreeviewColumn("UUID", 4, False)]
    
    def __init__(self, forecast):
        self.forecast=forecast
        super(TextModelOverviewComponent, self).__init__(TextModelOverviewComponent.treecolumns)
        

    def create_layout(self, parent_layout_grid, row):
        row += 1
        parent_layout_grid.attach(self.treeview,0,row,4,1)
        return row

        
    def populate_model(self):
        self.treemodel.clear()
        for model in FCTextModel().get_all_for_foreign_key(self.forecast.sid):     
            self.treemodel.append(["%s" % model.forecast_sid, "%s" % model.sid, model.textmodel_date, None, model.uuid])
            

    def on_row_select(self,widget,path,data):
        dialog=TextmodelStatementAddDialog(self, self.get_active_textmodel())
        dialog.run()
        dialog.destroy()        
        
        
    def get_active_textmodel(self):
        model,tree_iter=self.treeview.get_selection().get_selected()
        textmodel_sid=model.get(tree_iter, 1)
        return textmodel_sid
Пример #3
0
class OriginatorOverviewComponent(AbstractDataOverviewComponent):

    treecolumns = [
        TreeviewColumn("originator_sid", 0, True),
        TreeviewColumn("person_sid", 1, True),
        TreeviewColumn("organisation_sid", 2, True),
        TreeviewColumn("Typ", 3, False),
        TreeviewColumn("Common name", 4, False)
    ]

    def __init__(self, forecast):
        self.forecast = forecast
        super(OriginatorOverviewComponent,
              self).__init__(OriginatorOverviewComponent.treecolumns)

    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
class TextmodelStatementOverviewComponent(AbstractDataOverviewComponent):
    
    treecolumns=[TreeviewColumn("textmodel_statement_sid", 0, True), TreeviewColumn("textmodel_statement_uuid", 1, True), 
                TreeviewColumn("fc_textmodel_sid", 2, True), 
                TreeviewColumn("State PIT begin", 3, False),  TreeviewColumn("State PIT end", 4, False),
                TreeviewColumn("Statement",5,False)]

    
    def __init__(self, textmodel):
        self.textmodel=textmodel
        super(TextmodelStatementOverviewComponent, self).__init__(TextmodelStatementOverviewComponent.treecolumns)
        

    def create_layout(self, parent_layout_grid, row):
        row += 1
        
        self.treeview.set_size_request(200,150)
        parent_layout_grid.attach(self.treeview,0,row,4,1)
                
        return row

        
    def populate_model(self):
        self.treemodel.clear()
        textmodel_statements=FCTextmodelStatement().get_all_for_foreign_key(self.textmodel)
        for p in textmodel_statements:
            self.treemodel.append(["%s" % p.sid, "%s" % p.uuid, "%s" % self.textmodel, "%s" % p.point_in_time_begin, "%s" % p.point_in_time_end, p.statement_text])
class ModelStateOverviewComponent(AbstractDataOverviewComponent):
    
    treecolumns=[TreeviewColumn("state_sid", 0, True), TreeviewColumn("object_property_sid", 1, True), 
                TreeviewColumn("fc_project_sid", 2, True), TreeviewColumn("Common Name", 3, False),
                TreeviewColumn("Object property", 4, False),
                TreeviewColumn("State PIT begin", 5, False),  TreeviewColumn("State PIT end", 6, False),
                TreeviewColumn("Property Value", 7, False)]

    
    def __init__(self, fcmodel):
        self.fcmodel=fcmodel
        super(ModelStateOverviewComponent, self).__init__(ModelStateOverviewComponent.treecolumns)
        

    def create_layout(self, parent_layout_grid, row):
        row += 1
        
        parent_layout_grid.attach(self.treeview,0,row,4,1)
                
        return row

        
    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()
class PublicationOverviewComponent(AbstractDataOverviewComponent):

    treecolumns = [
        TreeviewColumn("publication_sid", 0, True),
        TreeviewColumn("Publisher", 1, False),
        TreeviewColumn("Title", 2, False, True),
        TreeviewColumn("Date", 3, False),
        TreeviewColumn("URL", 4, False),
        TreeviewColumn("forecast_publication_sid", 5, True),
    ]

    def __init__(self, forecast):
        self.forecast = forecast
        super(PublicationOverviewComponent,
              self).__init__(PublicationOverviewComponent.treecolumns)

    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()