Project

General

Profile

« Previous | Next » 

Revision 53187

Added by Tsampikos Livisianos about 6 years ago

add other research products

View differences:

modules/dnet-openaire-stats-api/src/main/java/eu/dnetlib/statsapi/domain/Community.java
8 8
    private StatsByAccessMode publication;
9 9
    private StatsByAccessMode dataset;
10 10
    private StatsByAccessMode software;
11
    private StatsByAccessMode other;
11 12

  
12 13
    private int total_projects = 0;
13 14
    private int virtual_organizations = 0;
......
15 16
    public Community() {
16 17
    }
17 18

  
18
    public Community(StatsByAccessMode publication, StatsByAccessMode datasets, StatsByAccessMode software, int total_projects, int virtual_organizations) {
19
    public Community(StatsByAccessMode publication, StatsByAccessMode datasets, StatsByAccessMode software, StatsByAccessMode others, int total_projects, int virtual_organizations) {
19 20
        this.publication = publication;
20 21
        this.dataset = datasets;
21 22
        this.software = software;
23
        this.other = others;
22 24
        this.total_projects = total_projects;
23 25
        this.virtual_organizations = virtual_organizations;
24 26
    }
......
47 49
        this.software = software;
48 50
    }
49 51

  
52
    public StatsByAccessMode getOther() {
53
        return other;
54
    }
55

  
56
    public void setOther(StatsByAccessMode other) {
57
        this.other = other;
58
    }
59

  
50 60
    public int getTotal_projects() {
51 61
        return total_projects;
52 62
    }
modules/dnet-openaire-stats-api/src/main/java/eu/dnetlib/statsapi/repositories/CommunityRepository.java
58 58
                return new Result("OK", "200", new ObjectMapper().readValue(redisResponse, Community.class));
59 59
            } else {
60 60
                connection = statsDB.getConnection();
61
                st = connection.prepareStatement("SELECT r.type, COUNT(DISTINCT r.id) AS total, COUNT(DISTINCT CASE WHEN r.bestlicense='Open Access' THEN r.id END) AS open_access, COUNT(DISTINCT CASE WHEN r.bestlicense='Embargo' THEN r.id END) AS embargo, COUNT(DISTINCT CASE WHEN r.bestlicense='Restricted' THEN r.id END) AS restricted, COUNT(DISTINCT CASE WHEN r.bestlicense='Closed Access' THEN r.id END) AS closed_access FROM result_concepts rc, result r WHERE rc.id=r.id AND (rc.concept=? OR rc.concept LIKE ? || '::%') GROUP BY r.type;");
61
                st = connection.prepareStatement("SELECT r.type, COUNT(DISTINCT r.id) AS total, COUNT(DISTINCT CASE WHEN r.bestlicense='Open Access' THEN r.id END) AS open_access, COUNT(DISTINCT CASE WHEN r.bestlicense='Embargo' THEN r.id END) AS embargo, COUNT(DISTINCT CASE WHEN r.bestlicense='Restricted' THEN r.id END) AS restricted, COUNT(DISTINCT CASE WHEN r.bestlicense='Closed Access' THEN r.id END) AS closed_access FROM public.result_concepts rc, public.result r WHERE rc.id=r.id AND (rc.concept=? OR rc.concept LIKE ? || '::%') GROUP BY r.type;");
62 62
                st.setString(1, community_id);
63 63
                st.setString(2, community_id);
64 64

  
65 65
                StatsByAccessMode publications = new StatsByAccessMode();
66 66
                StatsByAccessMode software = new StatsByAccessMode();
67 67
                StatsByAccessMode datasets = new StatsByAccessMode();
68
                StatsByAccessMode others = new StatsByAccessMode();
68 69

  
69 70
                rs = st.executeQuery();
70 71
                while (rs.next()) {
......
78 79
                        case "dataset":
79 80
                            datasets = new StatsByAccessMode(rs.getInt(2), rs.getInt(3), rs.getInt(4), rs.getInt(5), rs.getInt(6));
80 81
                            break;
82
                        case "other":
83
                            others = new StatsByAccessMode(rs.getInt(2), rs.getInt(3), rs.getInt(4), rs.getInt(5), rs.getInt(6));
84
                            break;
81 85
                    }
82 86
                }
83 87
                rs.close();
84 88
                st.close();
85 89

  
86
                st = connection.prepareStatement("SELECT r.type, COUNT(DISTINCT pr.id) FROM result r, result_concepts rc, project_results pr WHERE r.id=rc.id AND r.id=pr.result AND (rc.concept=? OR rc.concept LIKE ? || '::%') GROUP BY r.type;");
90
                st = connection.prepareStatement("SELECT r.type, COUNT(DISTINCT pr.id) FROM public.result r, public.result_concepts rc, public.project_results pr WHERE r.id=rc.id AND r.id=pr.result AND (rc.concept=? OR rc.concept LIKE ? || '::%') GROUP BY r.type;");
87 91
                st.setString(1, community_id);
88 92
                st.setString(2, community_id);
89 93

  
......
101 105
                        case "dataset":
102 106
                            datasets.setProjects(rs.getInt(2));
103 107
                            break;
108
                        case "other":
109
                            others.setProjects(rs.getInt(2));
110
                            break;
104 111
                    }
105 112
                }
106 113
                rs.close();
107 114
                st.close();
108 115

  
109
                st = connection.prepareStatement("SELECT COUNT(DISTINCT c.name) FROM result_concepts rc, concept c, category cat WHERE c.id=rc.concept AND cat.id=c.category AND cat.id=? || '::virtual';");
116
                st = connection.prepareStatement("SELECT COUNT(DISTINCT c.name) FROM public.result_concepts rc, public.concept c, public.category cat WHERE c.id=rc.concept AND cat.id=c.category AND cat.id=? || '::virtual';");
110 117
                st.setString(1, community_id);
111 118

  
112 119
                int virtual_organizations = 0;
......
115 122
                    virtual_organizations = rs.getInt(1);
116 123
                }
117 124

  
118
                Community community = new Community(publications, datasets, software, projects, virtual_organizations);
125
                Community community = new Community(publications, datasets, software, others, projects, virtual_organizations);
119 126
                jedis.put(redisKey, "persistent", "false");
120 127
                jedis.put(redisKey, "result", new ObjectMapper().writeValueAsString(community));
121 128

  

Also available in: Unified diff