1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.service.data.impl;
20
21 import javax.sql.DataSource;
22
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.jdbc.core.JdbcTemplate;
25 import org.springframework.stereotype.Service;
26 import org.springframework.transaction.annotation.Transactional;
27
28 import com.hack23.cia.service.data.api.ViewDataManager;
29
30
31
32
33 @Service
34 @Transactional(timeout=900)
35 final class ViewDataManagerImpl implements ViewDataManager {
36
37
38 @Autowired
39 private DataSource dataSource;
40
41
42
43
44 public ViewDataManagerImpl() {
45 super();
46 }
47
48 @Override
49 public void refreshViews() {
50 final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
51
52
53
54
55 jdbcTemplate.execute("update vote_data set gender='MAN' where gender='M'");
56 jdbcTemplate.execute("update vote_data set gender='KVINNA' where gender='K'");
57
58 jdbcTemplate.execute("update vote_data set gender='MAN' where gender='man'");
59 jdbcTemplate.execute("update vote_data set gender='KVINNA' where gender='kvinna'");
60
61
62 jdbcTemplate.execute("update vote_data set party='L' where party='FP'");
63
64 jdbcTemplate.execute("update person_data set party='L' where party='FP'");
65 jdbcTemplate.execute("update document_element set org='L' where org='FP' or org='fp'");
66 jdbcTemplate.execute("update document_data set org='L' where org='FP' or org='fp'");
67 jdbcTemplate.execute("update committee_document_data set org='L' where org='FP' or org='fp'");
68 jdbcTemplate.execute("update document_person_reference_da_0 set party_short_code='L' where party_short_code='FP' or party_short_code='fp'");
69
70 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_worldbank_indicator_data_country_summary");
71 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_summary");
72 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_party_summary");
73 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_politician_summary");
74 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_party_summary_daily");
75 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_party_summary_annual");
76 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_party_summary_monthly");
77 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_party_summary_weekly");
78
79 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_summary_daily");
80 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_summary_annual");
81 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_summary_monthly");
82 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_summary_weekly");
83
84 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_politician_summary_daily");
85 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_politician_summary_annual");
86 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_politician_summary_monthly");
87 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_vote_data_ballot_politician_summary_weekly");
88 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_committee_decisions");
89 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_committee_ballot_decision_politician_summary");
90 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_committee_ballot_decision_party_summary");
91
92 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_committee_ballot_decision_summary");
93 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_committee_decision_type_org_summary");
94 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_committee_decision_type_summary");
95
96
97 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_politician_document");
98 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_org_document_daily_summary");
99 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_party_document_daily_summary");
100 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_politician_document_daily_summary");
101 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_riksdagen_document_type_daily_summary");
102
103 jdbcTemplate.execute("REFRESH MATERIALIZED VIEW view_worldbank_indicator_data_country_summary");
104
105 }
106
107 }