Revision 50947
Added by Argiro Kokogiannaki about 6 years ago
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claimsDemo/TestClass.java | ||
---|---|---|
150 | 150 |
types.add(ClaimUtils.PUBLICATION); |
151 | 151 |
|
152 | 152 |
|
153 |
claims = fetchClaimHandler.fetchClaimsByUser("argirok_1@hotmail.com",1,0,types, false); |
|
153 |
// claims = fetchClaimHandler.fetchClaimsByUser("argirok_1@hotmail.com",1,0,types, false); |
|
154 |
claims = fetchClaimHandler.fetchClaimsByContext("egi",100,0,null,"claim.claim_date",false,types,false); |
|
155 |
// (String openaireId, Integer limit, Integer offset, String keyword, String orderField, boolean descending, List<String> types, boolean addCurationInfo) throws Exception, SQLStoreException { |
|
154 | 156 |
// claims = fetchClaimHandler.fetchClaimsByUser("argirok@di.uoa.gr",3,0,null,"claim.claim_date",false,types,false); |
155 | 157 |
// |
156 | 158 |
// claims = fetchClaimHandler.fetchClaimsByProject("corda_______::ab9c77ce02967b24fc9c1a74276e4677",5,0); |
... | ... | |
171 | 173 |
// Claim claim = fetchClaimHandler.fetchClaimById("5821"); |
172 | 174 |
// System.out.println(fetchClaimHandler.claim2JSON(claim) ); |
173 | 175 |
// System.out.println("ALL:"+fetchClaimHandler.countClaimsByUser("argirok@di.uoa.gr","EGI", types)); |
174 |
// System.out.println("ALL:"+fetchClaimHandler.countClaimsByContext("egi::country::gr",null,types));
|
|
176 |
System.out.println("ALL:"+fetchClaimHandler.countClaimsByContext("egi",null, new ArrayList<String>()));
|
|
175 | 177 |
// System.out.println("ALL:"+fetchClaimHandler.countClaimsByProject("corda_______::ab9c77ce02967b24fc9c1a74276e4677",null,types)); |
176 | 178 |
|
177 | 179 |
// System.out.println("ALL:"+fetchClaimHandler.countAllClaims("", types)); |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claimsDemo/SearchUtils.java | ||
---|---|---|
128 | 128 |
|
129 | 129 |
return ((production)?apiUrlForResultsProduction:apiUrlForResults)+"/publications?openairePublicationID="+id; |
130 | 130 |
} |
131 |
public static String getSoftwareApiUrl(String id, boolean production) { |
|
131 |
public static String getSoftwareApiUrl(String id, boolean production) {
|
|
132 | 132 |
//TODO change to beta when it's ready |
133 |
// return ((production)?apiUrlForResultsProduction:apiUrlForResults)+"/software/"+id;
|
|
134 |
return "http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/api"+"/software?openaireSoftwareID="+id; |
|
133 |
return ((production)?apiUrlForResultsProduction:apiUrlForResults)+"/software?openaireSoftwareID="+id;
|
|
134 |
// return "http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/api"+"/software?openaireSoftwareID="+id;
|
|
135 | 135 |
} |
136 | 136 |
// public static String getDedupPublicationApiUrl(String id) { |
137 | 137 |
// |
... | ... | |
181 | 181 |
// HTTP GET request |
182 | 182 |
private static String getRequest(String url) throws Exception { |
183 | 183 |
URL obj = new URL(url); |
184 |
// logger.debug(url);
|
|
184 |
logger.debug(url); |
|
185 | 185 |
HttpURLConnection con = (HttpURLConnection) obj.openConnection(); |
186 | 186 |
int responseCode = con.getResponseCode(); |
187 | 187 |
if(responseCode != 200){ |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claimsDemo/QueryGenerator.java | ||
---|---|---|
652 | 652 |
} |
653 | 653 |
public String generateCountByContext(String contextId ,String keyword, List<String> types, ArrayList<Object> params) { |
654 | 654 |
if((keyword == null || keyword.equals(""))&&types.isEmpty()){ |
655 |
params.add(contextId); |
|
656 |
return " select count(*) from claim where "+" claim.source_id =?";
|
|
655 |
params.add(contextId+"%");
|
|
656 |
return " select count(*) from claim where "+" claim.source_id like ?";
|
|
657 | 657 |
} |
658 | 658 |
return " select count(*) from claim where claim.id in ( select claim.id from ("+generateFetchClaimsByContext(contextId, null,null,keyword,null,false, types, params)+")as claim )"; |
659 | 659 |
|
... | ... | |
749 | 749 |
} |
750 | 750 |
|
751 | 751 |
public String generateFetchClaimsByContext(String contextId, Integer limit, Integer offset,String keyword, String orderBy, boolean desc, List<String> types, ArrayList<Object> params) { |
752 |
String clause= "claim.source_id =?";
|
|
752 |
String clause= "claim.source_id like ?";
|
|
753 | 753 |
ArrayList<Object> clauseParams = new ArrayList<>(); |
754 |
clauseParams.add(contextId); |
|
754 |
clauseParams.add(contextId+'%');
|
|
755 | 755 |
String query = " select * from ("+" ( " +generateSelectclaimQuery(ClaimUtils.CONTEXT,ClaimUtils.PUBLICATION,limit, offset, orderBy,desc,clause,clauseParams, keyword, params)+")"+ |
756 | 756 |
") as claim "; |
757 | 757 |
String filterByType = addFilterByType(types, params); |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claimsDemo/SqlStore.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
public void init() throws ClassNotFoundException, SQLException { |
38 | 38 |
Class.forName(dbDriver); |
39 |
this.getConnection(); |
|
39 |
// this.getConnection();
|
|
40 | 40 |
|
41 | 41 |
|
42 | 42 |
} |
... | ... | |
59 | 59 |
*/ |
60 | 60 |
public void getConnectionNoDatabase() throws SQLException { |
61 | 61 |
String parsedUrl = this.parseUrl(dbUrl); |
62 |
log.info("Connecting to " + parsedUrl + dbUser + dbPassword);
|
|
62 |
log.info("Connecting to " + parsedUrl + dbUser ); |
|
63 | 63 |
connection = (Connection) DriverManager.getConnection(parsedUrl, dbUser, dbPassword); |
64 | 64 |
log.info("Connected to " + parsedUrl); |
65 | 65 |
|
... | ... | |
72 | 72 |
*/ |
73 | 73 |
public void getConnection() throws SQLException { |
74 | 74 |
|
75 |
log.info("Attempting connection to : " + this.dbUrl + " for " + this.dbUser + " and " + this.dbPassword);
|
|
75 |
log.info("Attempting connection to : " + this.dbUrl + " for " + this.dbUser ); |
|
76 | 76 |
connection = (Connection) DriverManager.getConnection(this.dbUrl, dbUser, dbPassword); |
77 | 77 |
log.info("Connected to " + this.dbUrl); |
78 | 78 |
|
... | ... | |
150 | 150 |
*/ |
151 | 151 |
public ResultSet executeQuery(String command) throws SQLException, SQLStoreException { |
152 | 152 |
log.debug(" Executing Query ... " + command); |
153 |
try{ |
|
154 |
this.getConnection(); |
|
153 | 155 |
Statement st = connection.createStatement(); |
154 | 156 |
|
155 | 157 |
if (st.execute(command)) { |
... | ... | |
163 | 165 |
|
164 | 166 |
} |
165 | 167 |
|
168 |
} finally { |
|
169 |
this.closeConnection(); |
|
170 |
} |
|
166 | 171 |
|
167 |
|
|
168 | 172 |
} |
169 | 173 |
|
170 | 174 |
/** |
... | ... | |
178 | 182 |
*/ |
179 | 183 |
public ResultSet executeQuery(String command, ArrayList<Object> values) throws SQLException, SQLStoreException { |
180 | 184 |
log.debug(" Executing Query ..." + command); |
181 |
|
|
185 |
try{ |
|
186 |
this.getConnection(); |
|
182 | 187 |
PreparedStatement st = connection.prepareStatement(command); |
183 | 188 |
|
184 | 189 |
int pos = 1; |
... | ... | |
199 | 204 |
throw new SQLStoreException("Fail to execute command " + st.getWarnings()); |
200 | 205 |
} |
201 | 206 |
|
207 |
} finally { |
|
208 |
this.closeConnection(); |
|
209 |
} |
|
202 | 210 |
|
203 |
|
|
204 | 211 |
} |
205 | 212 |
|
206 | 213 |
/** |
... | ... | |
212 | 219 |
*/ |
213 | 220 |
public void executeUpdate(String command) throws SQLException { |
214 | 221 |
log.debug(" Executing Query ..." + command); |
222 |
try{ |
|
223 |
this.getConnection(); |
|
215 | 224 |
Statement st = connection.createStatement(); |
216 | 225 |
st.executeUpdate(command); |
217 | 226 |
//st.close(); |
227 |
} finally { |
|
228 |
this.closeConnection(); |
|
229 |
} |
|
218 | 230 |
} |
219 | 231 |
public void executeUpdateWithRollback(List<String> commandS) throws SQLException{ |
220 | 232 |
log.debug(" Executing Query ..." + commandS); |
modules/uoa-claims/trunk/src/main/resources/eu/dnetlib/data/claims/migration/springContext-claimsDemo.xml | ||
---|---|---|
16 | 16 |
http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd" |
17 | 17 |
default-autowire="byName"> |
18 | 18 |
<!--Un comment in order to run the tests / Comment to deploy--> |
19 |
<!--<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">-->
|
|
20 |
<!--<property name="locations" value="classpath:eu/dnetlib/data/claims/migration/springContext-claimsDemo.properties"/>-->
|
|
21 |
<!--</bean>-->
|
|
19 |
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
|
20 |
<property name="locations" value="classpath:eu/dnetlib/data/claims/migration/springContext-claimsDemo.properties"/>
|
|
21 |
</bean>
|
|
22 | 22 |
<bean id="directIndexHandler" class="eu.dnetlib.data.claims.migration.handler.DirectIndexHandler"> |
23 | 23 |
<property name="directClaimAPIUrl" value="http://beta.services.openaire.eu:8280/is/mvc/api/publications"/> |
24 | 24 |
</bean> |
Also available in: Unified diff
close the db connection per request, in fetch claims by context id use like and wild character in order to get all claims of a community