Revision 32831
Added by Eri Katsari almost 10 years ago
modules/dnet-openaire-stats/trunk/src/main/resources/eu/dnetlib/data/mapreduce/hbase/statsExport/stats_db_schema.sql | ||
---|---|---|
35 | 35 |
category text |
36 | 36 |
); |
37 | 37 |
|
38 |
|
|
38 | 39 |
|
39 |
ALTER TABLE shadow.concept OWNER TO sqoop; |
|
40 |
|
|
41 | 40 |
-- |
42 | 41 |
-- Name: datasource; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
43 | 42 |
-- |
... | ... | |
58 | 57 |
number integer DEFAULT 1 NOT NULL |
59 | 58 |
); |
60 | 59 |
|
61 |
|
|
62 |
ALTER TABLE shadow.datasource OWNER TO sqoop; |
|
63 |
|
|
60 |
|
|
64 | 61 |
-- |
65 | 62 |
-- Name: datasource_languages; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
66 | 63 |
-- |
67 | 64 |
|
68 |
CREATE TABLE datasource_languages ( |
|
65 |
CREATE TABLE shadow.datasource_languages (
|
|
69 | 66 |
id text NOT NULL, |
70 | 67 |
language text NOT NULL |
71 | 68 |
); |
72 | 69 |
|
73 |
|
|
74 |
ALTER TABLE shadow.datasource_languages OWNER TO sqoop; |
|
75 |
|
|
70 |
|
|
76 | 71 |
-- |
77 | 72 |
-- Name: datasource_organizations; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
78 | 73 |
-- |
... | ... | |
84 | 79 |
); |
85 | 80 |
|
86 | 81 |
|
87 |
ALTER TABLE shadow.datasource_organizations OWNER TO sqoop; |
|
88 |
|
|
82 |
|
|
89 | 83 |
-- |
90 | 84 |
-- Name: result_datasources; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
91 | 85 |
-- |
... | ... | |
96 | 90 |
); |
97 | 91 |
|
98 | 92 |
|
99 |
ALTER TABLE shadow.result_datasources OWNER TO sqoop; |
|
100 |
|
|
93 |
|
|
101 | 94 |
-- |
102 | 95 |
-- Name: datasource_results; Type: VIEW; Schema: shadow; Owner: sqoop |
103 | 96 |
-- |
... | ... | |
106 | 99 |
SELECT result_datasources.datasource AS id, result_datasources.id AS result FROM result_datasources; |
107 | 100 |
|
108 | 101 |
|
109 |
ALTER TABLE shadow.datasource_results OWNER TO sqoop; |
|
110 | 102 |
|
111 | 103 |
-- |
112 | 104 |
-- Name: datasource_topics; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
... | ... | |
131 | 123 |
|
132 | 124 |
|
133 | 125 |
|
134 |
ALTER TABLE shadow.defaults OWNER TO sqoop; |
|
135 |
|
|
136 | 126 |
-- |
137 | 127 |
-- Name: category; Type: TABLE; Schema: public; Owner: dnet; Tablespace: |
138 | 128 |
-- |
... | ... | |
142 | 132 |
context text |
143 | 133 |
); |
144 | 134 |
|
145 |
|
|
146 |
ALTER TABLE shadow.category OWNER TO sqoop; |
|
147 |
|
|
148 |
|
|
149 | 135 |
-- |
150 | 136 |
-- Name: claim; Type: TABLE; Schema: public; Owner: dnet; Tablespace: |
151 | 137 |
-- |
... | ... | |
155 | 141 |
date text , |
156 | 142 |
userid text |
157 | 143 |
); |
158 |
ALTER TABLE shadow.claim OWNER TO sqoop; |
|
159 | 144 |
|
160 | 145 |
|
161 | 146 |
-- |
... | ... | |
166 | 151 |
id text NOT NULL, |
167 | 152 |
name text |
168 | 153 |
); |
169 |
ALTER TABLE shadow.context OWNER TO sqoop; |
|
170 |
|
|
171 | 154 |
|
172 | 155 |
-- |
173 | 156 |
-- Name: organization; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
... | ... | |
183 | 166 |
); |
184 | 167 |
|
185 | 168 |
|
186 |
ALTER TABLE shadow.organization OWNER TO sqoop; |
|
187 | 169 |
|
188 | 170 |
-- |
189 | 171 |
-- Name: organization_datasources; Type: VIEW; Schema: shadow; Owner: sqoop |
... | ... | |
193 | 175 |
SELECT datasource_organizations.organization AS id, datasource_organizations.id AS datasource FROM datasource_organizations; |
194 | 176 |
|
195 | 177 |
|
196 |
ALTER TABLE shadow.organization_datasources OWNER TO sqoop; |
|
197 | 178 |
|
198 | 179 |
-- |
199 | 180 |
-- Name: project_organizations; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
... | ... | |
205 | 186 |
); |
206 | 187 |
|
207 | 188 |
|
208 |
ALTER TABLE shadow.project_organizations OWNER TO sqoop; |
|
209 | 189 |
|
210 | 190 |
-- |
211 | 191 |
-- Name: organization_projects; Type: VIEW; Schema: shadow; Owner: sqoop |
... | ... | |
214 | 194 |
CREATE VIEW shadow.organization_projects AS |
215 | 195 |
SELECT project_organizations.id AS project, project_organizations.organization AS id FROM project_organizations; |
216 | 196 |
|
217 |
|
|
218 |
ALTER TABLE shadow.organization_projects OWNER TO sqoop; |
|
219 | 197 |
|
220 | 198 |
|
221 | 199 |
-- |
... | ... | |
245 | 223 |
); |
246 | 224 |
|
247 | 225 |
|
248 |
ALTER TABLE shadow.project OWNER TO sqoop; |
|
249 |
|
|
250 | 226 |
-- |
251 | 227 |
-- Name: result_projects; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
252 | 228 |
-- |
... | ... | |
267 | 243 |
); |
268 | 244 |
|
269 | 245 |
|
270 |
ALTER TABLE shadow.project_results OWNER TO sqoop; |
|
271 | 246 |
|
272 |
|
|
273 |
|
|
274 | 247 |
-- |
275 | 248 |
-- Name: result; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
276 | 249 |
-- |
... | ... | |
297 | 270 |
); |
298 | 271 |
|
299 | 272 |
|
300 |
ALTER TABLE shadow.result OWNER TO sqoop; |
|
301 | 273 |
|
302 | 274 |
-- |
303 | 275 |
-- Name: result_claims; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
... | ... | |
309 | 281 |
); |
310 | 282 |
|
311 | 283 |
|
312 |
ALTER TABLE shadow.result_claims OWNER TO sqoop; |
|
313 | 284 |
|
314 | 285 |
-- |
315 | 286 |
-- Name: result_classifications; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
... | ... | |
321 | 292 |
); |
322 | 293 |
|
323 | 294 |
|
324 |
ALTER TABLE shadow.result_classifications OWNER TO sqoop; |
|
325 | 295 |
|
326 | 296 |
-- |
327 | 297 |
-- Name: result_concepts; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
... | ... | |
333 | 303 |
); |
334 | 304 |
|
335 | 305 |
|
336 |
ALTER TABLE shadow.result_concepts OWNER TO sqoop; |
|
337 | 306 |
|
338 | 307 |
-- |
339 | 308 |
-- Name: result_languages; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
340 | 309 |
-- |
341 | 310 |
|
342 |
CREATE TABLE result_languages ( |
|
311 |
CREATE TABLE shadow.result_languages (
|
|
343 | 312 |
id text NOT NULL, |
344 | 313 |
language text NOT NULL |
345 | 314 |
); |
346 | 315 |
|
347 | 316 |
|
348 |
ALTER TABLE shadow.result_languages OWNER TO sqoop; |
|
349 |
|
|
350 | 317 |
-- |
351 | 318 |
-- Name: result_results; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
352 | 319 |
-- |
... | ... | |
357 | 324 |
); |
358 | 325 |
|
359 | 326 |
|
360 |
ALTER TABLE shadow.result_results OWNER TO sqoop; |
|
361 | 327 |
|
362 | 328 |
-- |
363 | 329 |
-- Name: result_topics; Type: TABLE; Schema: shadow; Owner: sqoop; Tablespace: |
... | ... | |
369 | 335 |
); |
370 | 336 |
|
371 | 337 |
|
372 |
ALTER TABLE shadow.result_topics OWNER TO sqoop; |
|
373 |
SET search_path = public;; |
|
374 | 338 |
|
375 | 339 |
-- |
376 | 340 |
-- DATASOURCE Extra Inserts |
377 | 341 |
-- |
378 | 342 |
|
379 |
CREATE OR REPLACE FUNCTION shadow.extra_defaults_datasource()
|
|
380 |
RETURNS void AS
|
|
343 |
CREATE OR REPLACE FUNCTION shadow.extra_defaults_datasource() |
|
344 |
RETURNS void AS |
|
381 | 345 |
$BODY$ |
382 | 346 |
BEGIN |
383 | 347 |
INSERT INTO "shadow".datasource (id,datasource_results,datasource_organizations,datasource_languages,datasource_topics,name,type,compatibility,number) (SELECT 'other','other','other','other','other','Other','Repository','unknown',1 WHERE NOT EXISTS (SELECT 1 FROM "shadow".datasource WHERE name='Unknown Repository')); |
... | ... | |
412 | 376 |
$BODY$ |
413 | 377 |
BEGIN |
414 | 378 |
|
415 |
|
|
416 |
--drop table if exists shadow.project_results_publication CASCADE ; |
|
417 |
|
|
418 |
--CREATE table shadow.project_results_publication AS |
|
419 |
--SELECT "shadow".project_results.result AS result, |
|
420 |
--"shadow".project_results.id AS project_results, |
|
421 |
--"shadow"."result"."date" as resultdate, |
|
422 |
--"shadow"."project"."enddate" as projectenddate, |
|
423 |
--to_date("shadow"."result"."date", 'YYYY-MM-DD') - to_date("shadow"."project"."enddate", 'YYYY-MM-DD') as daysfromend |
|
424 |
--FROM "shadow".project_results, "shadow".result, "shadow".project |
|
425 |
--where "shadow".project_results.result="shadow".result.id and "shadow".result.type='publication' and "shadow".project.project_results= "shadow".project_results.id; |
|
426 | 379 |
|
427 | 380 |
CREATE OR REPLACE VIEW shadow.project_results_publication AS |
428 | 381 |
SELECT "shadow".result_projects.id AS result, |
... | ... | |
462 | 415 |
|
463 | 416 |
--HAS PUBS |
464 | 417 |
UPDATE "shadow"."project" SET haspubs='yes' WHERE project_results in (select project_results from shadow.project_results_publication ); |
465 |
|
|
466 |
--view |
|
467 |
--create or replace view shadow.res_pubs as select shadow.result.id from shadow.result where result.type='publication'; |
|
468 |
|
|
469 |
--query with view for has pubs |
|
470 |
--UPDATE "shadow"."project" SET haspubs='yes' |
|
471 |
--WHERE id in ( select id from shadow.project_results |
|
472 |
-- where shadow.project_results.result in ( select id from shadow.res_pubs ) and |
|
473 |
--"shadow"."project_results".id = "shadow"."project".id ) |
|
474 |
--and shadow.project.id in (select id from shadow.project_results); |
|
475 |
|
|
476 | 418 |
|
477 | 419 |
|
478 | 420 |
END |
... | ... | |
678 | 620 |
|
679 | 621 |
END;$$; |
680 | 622 |
|
681 |
DROP type if exists infra_report_rec cascade; |
|
682 | 623 |
|
683 |
CREATE TYPE infra_report_rec as |
|
684 |
(Publications varchar(50), Open_Access_Publications varchar(50), |
|
685 |
FP7_Publications varchar(50), FP7_Closed_Access_Publications varchar(50), |
|
686 |
FP7_Open_Access_Publications varchar(50), |
|
687 |
FP7_Restricted_Access_Publications varchar(50), FP7_Embargo_Publications varchar(50) ); |
|
624 |
--DROP type if exists infra_report_rec cascade; |
|
688 | 625 |
|
689 |
CREATE OR REPLACE FUNCTION shadow.getInfraReports() |
|
690 |
RETURNS infra_report_rec |
|
691 |
AS |
|
692 |
$$ |
|
693 |
DECLARE |
|
694 |
result_record infra_report_rec; |
|
695 |
BEGIN |
|
626 |
--CREATE TYPE infra_report_rec as |
|
627 |
--(Publications varchar(50), Open_Access_Publications varchar(50), |
|
628 |
--FP7_Publications varchar(50), FP7_Closed_Access_Publications varchar(50), |
|
629 |
--FP7_Open_Access_Publications varchar(50), |
|
630 |
--FP7_Restricted_Access_Publications varchar(50), FP7_Embargo_Publications varchar(50) ); |
|
696 | 631 |
|
697 |
SELECT count(*) INTO result_record.Publications FROM shadow.result where type='publication'; |
|
698 |
SELECT count(*) INTO result_record.Open_Access_Publications FROM shadow.result WHERE bestlicense='Open Access' and type='publication'; |
|
632 |
--CREATE OR REPLACE FUNCTION shadow.getInfraReports() |
|
633 |
-- RETURNS infra_report_rec |
|
634 |
--AS |
|
635 |
-- $$ |
|
636 |
--DECLARE |
|
637 |
-- result_record infra_report_rec; |
|
638 |
--BEGIN |
|
639 |
-- |
|
640 |
-- SELECT count(*) INTO result_record.Publications FROM shadow.result where type='publication'; |
|
641 |
-- SELECT count(*) INTO result_record.Open_Access_Publications FROM shadow.result WHERE bestlicense='Open Access' and type='publication'; |
|
642 |
-- |
|
643 |
--SELECT count (distinct result_projects.id) INTO result_record.FP7_Publications FROM shadow.result, shadow.result_projects, shadow.project |
|
644 |
--WHERE result.result_projects = result_projects.id and type='publication' and result_projects.project = project.id and funding_lvl0 = 'FP7'; |
|
645 |
-- |
|
646 |
--SELECT count (distinct shadow.result_projects.id) |
|
647 |
-- INTO result_record.FP7_Closed_Access_Publications |
|
648 |
-- FROM shadow.result, |
|
649 |
-- shadow.result_projects, |
|
650 |
-- shadow.project |
|
651 |
-- WHERE result.result_projects = result_projects.id |
|
652 |
-- AND result_projects.project = project.id |
|
653 |
-- AND funding_lvl0 = 'FP7' |
|
654 |
-- AND bestlicense='Closed Access' |
|
655 |
-- AND type='publication'; |
|
656 |
-- |
|
657 |
-- |
|
658 |
--SELECT count(distinct result_projects.id) INTO result_record.FP7_Open_Access_Publications FROM shadow.result, |
|
659 |
-- shadow.result_projects, shadow.project |
|
660 |
-- WHERE result_projects = result_projects.id AND result_projects.project = project.id and type='publication' and funding_lvl0 = 'FP7' and bestlicense='Open Access'; |
|
661 |
-- |
|
662 |
--SELECT count(distinct result_projects.id) INTO result_record.FP7_Restricted_Access_Publications |
|
663 |
-- FROM shadow.result, shadow.result_projects, shadow.project |
|
664 |
-- WHERE result.result_projects=result_projects.id |
|
665 |
-- AND result_projects.project = project.id and funding_lvl0 = 'FP7' and bestlicense='Restricted' and type='publication'; |
|
666 |
-- |
|
667 |
-- |
|
668 |
--SELECT count(distinct result_projects.id) INTO result_record.FP7_Embargo_Publications FROM shadow.result, shadow.result_projects, shadow.project |
|
669 |
--WHERE result.result_projects = result_projects.id AND result_projects.project = project.id and funding_lvl0 = 'FP7' and bestlicense='Embargo' and type='publication'; |
|
670 |
-- |
|
671 |
--RETURN result_record; |
|
672 |
-- |
|
673 |
--END |
|
674 |
--$$ LANGUAGE plpgsql; |
|
675 |
-- |
|
676 |
--drop type if exists fp7_report_rec cascade; |
|
677 |
-- |
|
678 |
--CREATE TYPE fp7_report_rec as |
|
679 |
--(FP7_Publications varchar(50), |
|
680 |
-- FP7_Projects varchar(50), |
|
681 |
-- FP7_SC39_Projects varchar(50), |
|
682 |
-- FP7_SC39_Publications varchar(50), |
|
683 |
-- FP7_SC39_Open_Access varchar(50)); |
|
684 |
-- |
|
685 |
-- |
|
686 |
--CREATE OR REPLACE FUNCTION shadow.getFp7Reports() |
|
687 |
-- RETURNS fp7_report_rec |
|
688 |
--AS |
|
689 |
-- $$ |
|
690 |
-- |
|
691 |
--DECLARE |
|
692 |
-- result_record fp7_report_rec; |
|
693 |
-- |
|
694 |
--BEGIN |
|
695 |
-- |
|
696 |
----FP7 WITH PUBS |
|
697 |
--SELECT count(distinct project.id) into result_record.FP7_Publications FROM shadow.result, shadow.result_projects, shadow.project |
|
698 |
--WHERE result.result_projects = result_projects.id and type='publication' |
|
699 |
-- and result_projects.project = project.id and funding_lvl0='FP7' ; |
|
700 |
-- |
|
701 |
--SELECT count(id) into result_record.FP7_Projects FROM shadow.project WHERE funding_lvl0 = 'FP7'; |
|
702 |
-- SELECT count(number) into result_record.FP7_SC39_Projects from shadow.project where funding_lvl0='FP7' and sc39='yes'; |
|
703 |
-- |
|
704 |
--SELECT count(distinct project.id) into result_record.FP7_SC39_Publications FROM shadow.result, shadow.result_projects, shadow.project |
|
705 |
-- WHERE result_projects.project=project.id and funding_lvl0 = 'FP7' and sc39='yes' and result.result_projects = result_projects.id and type='publication'; |
|
706 |
-- |
|
707 |
--SELECT count(distinct result_projects.id) into result_record.FP7_SC39_Open_Access FROM shadow.result, shadow.result_projects, shadow.project |
|
708 |
-- WHERE result.result_projects = result_projects.id AND result_projects.project = project.id and funding_lvl0 = 'FP7' and bestlicense='Open Access' and sc39='yes' and type='publication'; |
|
709 |
-- |
|
710 |
--RETURN result_record; |
|
711 |
-- |
|
712 |
--END |
|
713 |
--$$ LANGUAGE plpgsql; |
|
714 |
-- |
|
715 |
-- |
|
716 |
--drop type wt_report_rec cascade; |
|
717 |
-- |
|
718 |
--CREATE TYPE wt_report_rec as |
|
719 |
--(WT_Publications varchar(50), |
|
720 |
-- WT_Projects varchar(50), |
|
721 |
-- WT_Open_Access varchar(50), |
|
722 |
-- WT_Restricted_Access varchar(50), |
|
723 |
-- WT_Embargo varchar(50)); |
|
724 |
-- |
|
725 |
-- |
|
726 |
--CREATE OR REPLACE FUNCTION shadow.getWTReports() |
|
727 |
-- RETURNS wt_report_rec |
|
728 |
--AS |
|
729 |
-- $$ |
|
730 |
-- |
|
731 |
--DECLARE |
|
732 |
-- result_record wt_report_rec; |
|
733 |
-- |
|
734 |
--BEGIN |
|
735 |
-- |
|
736 |
--SELECT count(distinct project.id) into result_record.WT_Publications FROM shadow.result, shadow.project, shadow.result_projects |
|
737 |
--where result_projects.project = project.id and project.funding_lvl0='WT' and result.result_projects = result_projects.id and type='publication'; |
|
738 |
-- |
|
739 |
--SELECT count(id) into result_record.WT_Projects FROM project WHERE funding_lvl0 = 'WT'; |
|
740 |
-- |
|
741 |
--SELECT count(distinct result_projects.id) into result_record.WT_Open_Access FROM shadow.result, shadow.result_projects, shadow.project WHERE result.result_projects= result_projects.id |
|
742 |
--AND result_projects.project = project.id and funding_lvl0 = 'WT' and bestlicense='Open Access' and type='publication'; |
|
743 |
-- |
|
744 |
--SELECT count(distinct result_projects.id) into result_record.WT_Restricted_Access FROM shadow.result, shadow.result_projects, |
|
745 |
--shadow.project WHERE result.result_projects = result_projects.id AND |
|
746 |
--result_projects.project = project.id and funding_lvl0 = 'WT' and |
|
747 |
--bestlicense='Restricted' and type='publication'; |
|
748 |
-- |
|
749 |
--SELECT count(distinct result_projects.id) into result_record.WT_Embargo FROM shadow.result, shadow.result_projects, shadow.project |
|
750 |
--WHERE result.result_projects=result_projects.id AND result_projects.project = project.id and funding_lvl0 = 'WT' |
|
751 |
--and bestlicense='Embargo' and type='publication'; |
|
752 |
-- |
|
753 |
--RETURN result_record; |
|
754 |
-- |
|
755 |
--END |
|
756 |
--$$ LANGUAGE plpgsql; |
|
757 |
-- |
|
758 |
-- |
|
759 |
-- |
|
760 |
--drop type if exists erc_report_rec cascade; |
|
761 |
-- |
|
762 |
--CREATE TYPE erc_report_rec as |
|
763 |
--(ERC_Publications varchar(50), |
|
764 |
-- ERC_Projects varchar(50), |
|
765 |
-- ERC_Open_Access varchar(50), |
|
766 |
-- ERC_Restricted_Access varchar(50), |
|
767 |
-- ERC_Embargo varchar(50)); |
|
768 |
-- |
|
769 |
-- |
|
770 |
-- |
|
771 |
--CREATE OR REPLACE FUNCTION shadow.getERCReports() |
|
772 |
-- RETURNS erc_report_rec |
|
773 |
--AS |
|
774 |
-- $$ |
|
775 |
-- |
|
776 |
--DECLARE |
|
777 |
-- result_record erc_report_rec; |
|
778 |
-- |
|
779 |
--BEGIN |
|
780 |
-- |
|
781 |
--SELECT count(distinct project.id) into result_record.ERC_Publications FROM shadow.result, shadow.project, shadow.result_projects |
|
782 |
--where result_projects.project = project.id and project.funding_lvl2='ERC' and result.result_projects = result_projects.id and type='publication'; |
|
783 |
-- |
|
784 |
--SELECT count(id) into result_record.ERC_Projects FROM shadow.project WHERE funding_lvl2 = 'ERC'; |
|
785 |
-- |
|
786 |
-- |
|
787 |
--SELECT count(distinct result_projects.id) into result_record.ERC_Open_Access FROM shadow.result, |
|
788 |
--shadow.result_projects, shadow.project WHERE result.result_projects= result_projects.id |
|
789 |
--AND result_projects.project = project.id and funding_lvl2 = 'ERC' and bestlicense='Open Access' and type='publication'; |
|
790 |
-- |
|
791 |
-- |
|
792 |
--SELECT count(distinct result_projects.id) into result_record.ERC_Restricted_Access FROM shadow.result, shadow.result_projects, shadow.project WHERE |
|
793 |
-- result.result_projects = result_projects.id AND result_projects.project = project.id and funding_lvl2 = 'ERC' and bestlicense='Restricted' and type='publication'; |
|
794 |
-- |
|
795 |
--SELECT count(distinct result_projects.id) into result_record.ERC_Embargo FROM shadow.result, shadow.result_projects, shadow.project |
|
796 |
-- WHERE result.result_projects=result_projects.id AND result_projects.project = project.id and funding_lvl2 = 'ERC' and bestlicense='Embargo' and type='publication'; |
|
797 |
-- |
|
798 |
-- |
|
799 |
--RETURN result_record; |
|
800 |
-- |
|
801 |
--END |
|
802 |
--$$ LANGUAGE plpgsql; |
|
699 | 803 |
|
700 |
SELECT count (distinct result_projects.id) INTO result_record.FP7_Publications FROM shadow.result, shadow.result_projects, shadow.project |
|
701 |
WHERE result.result_projects = result_projects.id and type='publication' and result_projects.project = project.id and funding_lvl0 = 'FP7'; |
|
702 |
|
|
703 |
SELECT count (distinct shadow.result_projects.id) |
|
704 |
INTO result_record.FP7_Closed_Access_Publications |
|
705 |
FROM shadow.result, |
|
706 |
shadow.result_projects, |
|
707 |
shadow.project |
|
708 |
WHERE result.result_projects = result_projects.id |
|
709 |
AND result_projects.project = project.id |
|
710 |
AND funding_lvl0 = 'FP7' |
|
711 |
AND bestlicense='Closed Access' |
|
712 |
AND type='publication'; |
|
713 |
|
|
714 |
|
|
715 |
SELECT count(distinct result_projects.id) INTO result_record.FP7_Open_Access_Publications FROM shadow.result, |
|
716 |
shadow.result_projects, shadow.project |
|
717 |
WHERE result_projects = result_projects.id AND result_projects.project = project.id and type='publication' and funding_lvl0 = 'FP7' and bestlicense='Open Access'; |
|
718 |
|
|
719 |
SELECT count(distinct result_projects.id) INTO result_record.FP7_Restricted_Access_Publications |
|
720 |
FROM shadow.result, shadow.result_projects, shadow.project |
|
721 |
WHERE result.result_projects=result_projects.id |
|
722 |
AND result_projects.project = project.id and funding_lvl0 = 'FP7' and bestlicense='Restricted' and type='publication'; |
|
723 |
|
|
724 |
|
|
725 |
SELECT count(distinct result_projects.id) INTO result_record.FP7_Embargo_Publications FROM shadow.result, shadow.result_projects, shadow.project |
|
726 |
WHERE result.result_projects = result_projects.id AND result_projects.project = project.id and funding_lvl0 = 'FP7' and bestlicense='Embargo' and type='publication'; |
|
727 |
|
|
728 |
RETURN result_record; |
|
729 |
|
|
730 |
END |
|
731 |
$$ LANGUAGE plpgsql; |
|
732 |
|
|
733 |
drop type if exists fp7_report_rec cascade; |
|
734 |
|
|
735 |
CREATE TYPE fp7_report_rec as |
|
736 |
(FP7_Publications varchar(50), |
|
737 |
FP7_Projects varchar(50), |
|
738 |
FP7_SC39_Projects varchar(50), |
|
739 |
FP7_SC39_Publications varchar(50), |
|
740 |
FP7_SC39_Open_Access varchar(50)); |
|
741 |
|
|
742 |
|
|
743 |
CREATE OR REPLACE FUNCTION shadow.getFp7Reports() |
|
744 |
RETURNS fp7_report_rec |
|
745 |
AS |
|
746 |
$$ |
|
747 |
|
|
748 |
DECLARE |
|
749 |
result_record fp7_report_rec; |
|
750 |
|
|
751 |
BEGIN |
|
752 |
|
|
753 |
--FP7 WITH PUBS |
|
754 |
SELECT count(distinct project.id) into result_record.FP7_Publications FROM shadow.result, shadow.result_projects, shadow.project |
|
755 |
WHERE result.result_projects = result_projects.id and type='publication' |
|
756 |
and result_projects.project = project.id and funding_lvl0='FP7' ; |
|
757 |
|
|
758 |
SELECT count(id) into result_record.FP7_Projects FROM shadow.project WHERE funding_lvl0 = 'FP7'; |
|
759 |
SELECT count(number) into result_record.FP7_SC39_Projects from shadow.project where funding_lvl0='FP7' and sc39='yes'; |
|
760 |
|
|
761 |
SELECT count(distinct project.id) into result_record.FP7_SC39_Publications FROM shadow.result, shadow.result_projects, shadow.project |
|
762 |
WHERE result_projects.project=project.id and funding_lvl0 = 'FP7' and sc39='yes' and result.result_projects = result_projects.id and type='publication'; |
|
763 |
|
|
764 |
SELECT count(distinct result_projects.id) into result_record.FP7_SC39_Open_Access FROM shadow.result, shadow.result_projects, shadow.project |
|
765 |
WHERE result.result_projects = result_projects.id AND result_projects.project = project.id and funding_lvl0 = 'FP7' and bestlicense='Open Access' and sc39='yes' and type='publication'; |
|
766 |
|
|
767 |
RETURN result_record; |
|
768 |
|
|
769 |
END |
|
770 |
$$ LANGUAGE plpgsql; |
|
771 |
|
|
772 |
|
|
773 |
drop type wt_report_rec cascade; |
|
774 |
|
|
775 |
CREATE TYPE wt_report_rec as |
|
776 |
(WT_Publications varchar(50), |
|
777 |
WT_Projects varchar(50), |
|
778 |
WT_Open_Access varchar(50), |
|
779 |
WT_Restricted_Access varchar(50), |
|
780 |
WT_Embargo varchar(50)); |
|
781 |
|
|
782 |
|
|
783 |
CREATE OR REPLACE FUNCTION shadow.getWTReports() |
|
784 |
RETURNS wt_report_rec |
|
785 |
AS |
|
786 |
$$ |
|
787 |
|
|
788 |
DECLARE |
|
789 |
result_record wt_report_rec; |
|
790 |
|
|
791 |
BEGIN |
|
792 |
|
|
793 |
SELECT count(distinct project.id) into result_record.WT_Publications FROM shadow.result, shadow.project, shadow.result_projects |
|
794 |
where result_projects.project = project.id and project.funding_lvl0='WT' and result.result_projects = result_projects.id and type='publication'; |
|
795 |
|
|
796 |
SELECT count(id) into result_record.WT_Projects FROM project WHERE funding_lvl0 = 'WT'; |
|
797 |
|
|
798 |
SELECT count(distinct result_projects.id) into result_record.WT_Open_Access FROM shadow.result, shadow.result_projects, shadow.project WHERE result.result_projects= result_projects.id |
|
799 |
AND result_projects.project = project.id and funding_lvl0 = 'WT' and bestlicense='Open Access' and type='publication'; |
|
800 |
|
|
801 |
SELECT count(distinct result_projects.id) into result_record.WT_Restricted_Access FROM shadow.result, shadow.result_projects, |
|
802 |
shadow.project WHERE result.result_projects = result_projects.id AND |
|
803 |
result_projects.project = project.id and funding_lvl0 = 'WT' and |
|
804 |
bestlicense='Restricted' and type='publication'; |
|
805 |
|
|
806 |
SELECT count(distinct result_projects.id) into result_record.WT_Embargo FROM shadow.result, shadow.result_projects, shadow.project |
|
807 |
WHERE result.result_projects=result_projects.id AND result_projects.project = project.id and funding_lvl0 = 'WT' |
|
808 |
and bestlicense='Embargo' and type='publication'; |
|
809 |
|
|
810 |
RETURN result_record; |
|
811 |
|
|
812 |
END |
|
813 |
$$ LANGUAGE plpgsql; |
|
814 |
|
|
815 |
|
|
816 |
|
|
817 |
drop type if exists erc_report_rec cascade; |
|
818 |
|
|
819 |
CREATE TYPE erc_report_rec as |
|
820 |
(ERC_Publications varchar(50), |
|
821 |
ERC_Projects varchar(50), |
|
822 |
ERC_Open_Access varchar(50), |
|
823 |
ERC_Restricted_Access varchar(50), |
|
824 |
ERC_Embargo varchar(50)); |
|
825 |
|
|
826 |
|
|
827 |
|
|
828 |
CREATE OR REPLACE FUNCTION shadow.getERCReports() |
|
829 |
RETURNS erc_report_rec |
|
830 |
AS |
|
831 |
$$ |
|
832 |
|
|
833 |
DECLARE |
|
834 |
result_record erc_report_rec; |
|
835 |
|
|
836 |
BEGIN |
|
837 |
|
|
838 |
SELECT count(distinct project.id) into result_record.ERC_Publications FROM shadow.result, shadow.project, shadow.result_projects |
|
839 |
where result_projects.project = project.id and project.funding_lvl2='ERC' and result.result_projects = result_projects.id and type='publication'; |
|
840 |
|
|
841 |
SELECT count(id) into result_record.ERC_Projects FROM shadow.project WHERE funding_lvl2 = 'ERC'; |
|
842 |
|
|
843 |
|
|
844 |
SELECT count(distinct result_projects.id) into result_record.ERC_Open_Access FROM shadow.result, |
|
845 |
shadow.result_projects, shadow.project WHERE result.result_projects= result_projects.id |
|
846 |
AND result_projects.project = project.id and funding_lvl2 = 'ERC' and bestlicense='Open Access' and type='publication'; |
|
847 |
|
|
848 |
|
|
849 |
SELECT count(distinct result_projects.id) into result_record.ERC_Restricted_Access FROM shadow.result, shadow.result_projects, shadow.project WHERE |
|
850 |
result.result_projects = result_projects.id AND result_projects.project = project.id and funding_lvl2 = 'ERC' and bestlicense='Restricted' and type='publication'; |
|
851 |
|
|
852 |
SELECT count(distinct result_projects.id) into result_record.ERC_Embargo FROM shadow.result, shadow.result_projects, shadow.project |
|
853 |
WHERE result.result_projects=result_projects.id AND result_projects.project = project.id and funding_lvl2 = 'ERC' and bestlicense='Embargo' and type='publication'; |
|
854 |
|
|
855 |
|
|
856 |
RETURN result_record; |
|
857 |
|
|
858 |
END |
|
859 |
$$ LANGUAGE plpgsql; |
|
860 |
|
|
861 | 804 |
-- sqoopQL database dump complete |
862 | 805 |
-- |
Also available in: Unified diff