Project

General

Profile

1
package eu.dnetlib.data.claimsDemo;
2

    
3
/**
4
 * Created by Eri on 18/11/2015.
5
 */
6

    
7

    
8

    
9

    
10
import com.google.gson.Gson;
11
import com.google.gson.GsonBuilder;
12
import com.sun.org.apache.xerces.internal.xs.StringList;
13
import eu.dnetlib.data.claims.migration.ClaimValidation;
14
import eu.dnetlib.data.claims.migration.JsonldBuilder;
15
import eu.dnetlib.data.claims.migration.Migration;
16
import eu.dnetlib.data.claims.migration.entity.Claim;
17
import eu.dnetlib.data.claims.migration.entity.Project;
18
import eu.dnetlib.data.claims.migration.entity.Result;
19
import eu.dnetlib.data.claims.migration.handler.*;
20
import eu.dnetlib.data.claims.migration.parser.DMFParser;
21
import eu.dnetlib.data.claims.migration.parser.ExternalRecordParser;
22
import org.apache.log4j.BasicConfigurator;
23
import org.apache.log4j.Logger;
24
import org.junit.Before;
25
import org.junit.Test;
26
import org.junit.runner.RunWith;
27
import org.springframework.context.ApplicationContext;
28
import org.springframework.context.annotation.PropertySource;
29
import org.springframework.context.support.ClassPathXmlApplicationContext;
30
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
31
import org.springframework.core.io.ClassPathResource;
32
import org.springframework.test.context.ContextConfiguration;
33
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
34
import org.xml.sax.SAXException;
35

    
36
import javax.xml.parsers.ParserConfigurationException;
37
import javax.xml.transform.TransformerException;
38
import javax.xml.xpath.XPathExpressionException;
39
import java.io.File;
40
import java.io.IOException;
41
import java.math.BigInteger;
42
import java.security.MessageDigest;
43
import java.sql.ResultSet;
44
import java.util.*;
45

    
46
import static junit.framework.Assert.assertNotNull;
47

    
48
/**
49
 * @author eri
50
 */
51
@RunWith(SpringJUnit4ClassRunner.class)
52
@ContextConfiguration(locations = {"../claims/migration/springContext-claimsDemo.xml"})
53
@PropertySource("../claims/migration/springContext-claimsDemo.properties")
54
public class TestClass {
55
	private Logger log = Logger.getLogger(this.getClass());
56

    
57

    
58
	private SqlDAO sqlDAO;
59
    private SqlStore sqlStore;
60

    
61
    private QueryGenerator queryGenerator;
62

    
63
    RelationHandler relationHandler = null;
64
    ContextRelationHandler contextRelationHandler = null;
65
    ProjectHandler projectHandler = null;
66
    DirectIndexHandler directIndexHandler = null;
67
    FetchProjectHandler fetchProjectHandler = null;
68
    DMFContextHandler dmfContextHandler = null;
69
    DMFResultHandler dmfResultHandler = null;
70
    IndexResultHandler indexResultHandler = null;
71
    ExternalRecordHandler externalRecordHandler = null;
72
    ResultHandler resultHandler = null;
73

    
74
    FetchClaimHandler fetchClaimHandler = null;
75
    ClaimHandler claimHandler = null;
76
    ClaimValidation claimValidation = null;
77

    
78

    
79
    @Before
80
	public void init() throws Exception {
81
		BasicConfigurator.configure();
82
        ApplicationContext context = new ClassPathXmlApplicationContext("eu/dnetlib/data/claims/migration/springContext-claimsDemo.xml");
83

    
84
        relationHandler = context.getBean(RelationHandler.class);
85
        directIndexHandler = context.getBean(DirectIndexHandler.class);
86
        contextRelationHandler = context.getBean(ContextRelationHandler.class);
87
        projectHandler = context.getBean(ProjectHandler.class);
88
        fetchProjectHandler = context.getBean(FetchProjectHandler.class);
89
        dmfContextHandler = context.getBean(DMFContextHandler.class);
90
        dmfResultHandler = context.getBean(DMFResultHandler.class);
91
        externalRecordHandler = context.getBean(ExternalRecordHandler.class);
92
        indexResultHandler = context.getBean(IndexResultHandler.class);
93
        resultHandler = context.getBean(ResultHandler.class);
94
        claimHandler = context.getBean(ClaimHandler.class);
95
        sqlDAO = context.getBean(SqlDAO.class);
96
        sqlStore = context.getBean(SqlStore.class);
97
        queryGenerator = context.getBean(QueryGenerator.class);
98
        fetchClaimHandler = context.getBean(FetchClaimHandler.class);
99
        claimValidation = context.getBean(ClaimValidation.class);
100

    
101
        assertNotNull(sqlDAO);
102

    
103
	}
104
    @Test
105
    public void testRollback(){
106
        List <String> commands = new ArrayList<String>();
107
        commands.add("UPDATE claim SET claimedBy = 'argirok1' WHERE  id = 93");
108
        commands.add("EXCEPTION");
109
        commands.add("UPDATE claim SET claimedBy = 'argirok2' WHERE  id = 95");
110
        try {
111
            sqlStore.executeUpdateWithRollback(commands);
112
        } catch (Exception e) {
113
            log.error("",e);
114
        }
115
    }
116
    @Test
117
    public void testJson(){
118
        Claim claim = new Claim();
119
        Project project= new Project();
120
        claim.setDate(Calendar.getInstance().getTime());
121
        claim.setId("claimId");
122
        claim.setUserMail("claim mail");
123

    
124
        project.setFunderName("EC");
125
        project.setOpenaireId("openaireID1234");
126
        project.setName("PrTitle");
127
        claim.setSource(project);
128
        Result result = new Result();
129
        result.setAccessRights("accessRights");
130
        result.setCollectedFrom("collectedFrom");
131
        result.setExternalUrl("external_url");
132
        result.setOpenaireId("openaire_id");
133
        result.setTitle("title");
134
        result.setResultType("type");
135
        result.setMetadataRecord("xmlString");
136
        claim.setTarget(result);
137
        System.out.println("test");
138
        System.out.println(JsonldBuilder.toJsonld(claim));
139
    }
140

    
141
    @Test
142
    public void testFetch() throws Exception {
143

    
144
        try {
145
            List<Claim> claims = null;
146
            List<String> types= new ArrayList<String>();
147
//            types.add(ClaimUtils.CONTEXT);
148
            types.add(ClaimUtils.PROJECT);
149
          types.add(ClaimUtils.DATASET);
150
            types.add(ClaimUtils.PUBLICATION);
151

    
152

    
153
//            claims = fetchClaimHandler.fetchClaimsByUser("i.fava@cineca.it",30,0,types);
154
//            claims = fetchClaimHandler.fetchClaimsByUser("argirok@di.uoa.gr",3,0,null,"claim.claim_date",false,types,false);
155
//
156
//            claims = fetchClaimHandler.fetchClaimsByProject("corda_______::ab9c77ce02967b24fc9c1a74276e4677",5,0);
157
            claims = fetchClaimHandler.fetchClaimsByProject("corda__h2020::94c962e736df90a5075a7f660ba3d7f6",12,0,null, "claim.claim_date",false,types,true);
158
            //claims = fetchClaimHandler.fetchClaimsByToken("corda__h2020::94c962e736df90a5075a7f660ba3d7f6","argiro@gmail.com",12,0,null, "claim.claim_date",false,types,false);
159

    
160
//            claims = fetchClaimHandler.fetchClaimsByDate("2016-01-14 14:53:50","2016-04-21",10,0);
161
//            claims = fetchClaimHandler.fetchClaimsByDate("2016-01-14 14:53:50","2017-04-21",10,0,"", "source",true,types, false);
162
//            // 2016-04-20 14:53:50.276
163
//            claims = fetchClaimHandler.fetchClaimsByContext("egi::country::gr",5,0,null,"claim.claim_date",false,types);
164
//            claims = fetchClaimHandler.fetchAllClaims(5,3);
165
//            claims = fetchClaimHandler.fetchClaimsByResult("od_______233::235960bb401207cb9595a79a1bc8e867",5,0,null, "claim.claim_date",false,types);
166
//            claims = fetchClaimHandler.fetchClaimsByFunder("fct_________::FCT",5,0);
167
//            claims= fetchClaimHandler.fetchClaimsByUser("kiatrop@di.uoa.gr",20,0,types);
168
//            claims = fetchClaimHandler.fetchAllClaims(10,0,"","date",true,types);
169

    
170
            System.out.println(fetchClaimHandler.claims2JSON(claims)+"\n\n\n "+claims.size());
171
//          Claim claim = fetchClaimHandler.fetchClaimById("5821");
172
//          System.out.println(fetchClaimHandler.claim2JSON(claim) );
173
//          System.out.println("ALL:"+fetchClaimHandler.countClaimsByUser("argirok@di.uoa.gr","EGI", types));
174
//          System.out.println("ALL:"+fetchClaimHandler.countClaimsByContext("egi::country::gr",null,types));
175
//            System.out.println("ALL:"+fetchClaimHandler.countClaimsByProject("corda_______::ab9c77ce02967b24fc9c1a74276e4677",null,types));
176

    
177
//        System.out.println("ALL:"+fetchClaimHandler.countAllClaims("", types));
178
//                +"\n Project: "+fetchClaimHandler.countClaimsByProject("corda_______::ab9c77ce02967b24fc9c1a74276e4677")+
179
//                " \n Result:"+fetchClaimHandler.countClaimsByResult("dedup_wf_001::541b1cef0d38d519e98a3b7a5b60bc75")+" \n Context:"+fetchClaimHandler.countClaimsByContext("egi::country::de")
180
//        +" \n Date:"+fetchClaimHandler.countClaimsByDate("2014-04-14","2015-04-14")+" \n Funder:"+fetchClaimHandler.countClaimsByFunder("fct_________::FCT"));
181
        } catch (Exception e) {
182
            log.error("",e);
183
        } catch (SQLStoreException e) {
184
            e.printStackTrace();
185
        }
186
    }
187
    @Test
188
    public void testContext(){
189
        System.out.print(DMFContextHandler.fetchContextById("egi::organisation::uom"));
190
    }
191
    @Test
192
    public void testInsert() throws Exception, SQLStoreException {
193
 //acm_________::31e0e5e7cbd6e2556336d7e795f55c49
194
//dedup_wf_001::64ca1e3a4d1590456ad3dd7df8a18cd7
195
 
196
//        String id=claimHandler.buildAndInsertClaim("argirok@di.uoa.gr", "project", "corda_______::2c37878a0cede85dbbd1081bb9b4a2f8", "openaire", "OPEN", null,"dataset", "10.5281/ZENODO.154647", "datacite", "EMBARGO","2017-05-01");
197

    
198

    
199
//        String id=claimHandler.buildAndInsertClaim("argirok@di.uoa.gr", "context", "egi::country::gr",
200
//                "openaire", null, null,"dataset", "10.4225/41/55A111BDE741C", "datacite", "OPEN","2017-05-01");
201
    }
202
    @Test
203
    public void testDelete() throws Exception, SQLStoreException {
204

    
205
//            claimHandler.deleteClaim("argirok@di.uoa.gr","2876");
206
//        claimHandler.deleteClaim("argirok@di.uoa.gr","3101");
207
        }
208

    
209
    @Test
210
	public void testJob() throws Exception, SQLStoreException {
211
        String selectcountDMFClaims =" Select count(*) from claims  where type='dmf2actions' and xml NOT ILIKE '%<oaf:concept%' ";
212
        String selectCountConceptClaims =" Select count(*) from claims  where ( type='dmf2actions' or type='updates2actions' ) and xml LIKE '%<oaf:concept%' ";
213
        String selectCountRelationClaims =" Select count(*) from claims  where type='rels2actions'  ";
214

    
215
        ResultSet rs = sqlDAO.executePreparedQuery(selectCountConceptClaims);
216

    
217
        while(rs.next()) {
218
            log.info("Concept claims: "+rs.getInt(1));
219
        }
220
         rs = sqlDAO.executePreparedQuery(selectCountRelationClaims);
221

    
222
        while(rs.next()) {
223
            log.info("Relation claims: "+rs.getInt(1));
224
        }
225
         rs = sqlDAO.executePreparedQuery("Select count(*) from claim");
226

    
227
        while(rs.next()) {
228
            log.info("Migrated claims: "+rs.getInt(1));
229
        }
230
        rs = sqlDAO.executePreparedQuery("Select count(*) from result");
231

    
232
        while(rs.next()) {
233
            log.info("Results: "+rs.getInt(1));
234
        }
235

    
236
	}
237

    
238
    @Test
239
    public void testHttpRequest() throws Exception {
240
        SearchUtils searchUtils= new SearchUtils();
241
        log.info(searchUtils.fetchPublicationXmlFromIndex("doajarticles::eb8a123eb82b25013b0001d0e2d1842b"));
242
        log.info(searchUtils.fetchDatasetXmlFromIndex("doajarticles::eb8a123eb82b25013b0001d0e2d1842b"));
243
    }
244

    
245
    @Test
246
    public void testXpath() throws Exception {
247
            Result r=indexResultHandler.fetchResultById("dedup_wf_001::88a1eedd1ffce63dccf51d8ce2053c85");
248
     }
249

    
250
    @Test
251
    public void testParsingDMF() throws IOException, SAXException, ParserConfigurationException, XPathExpressionException, TransformerException {
252
        Result r=DMFParser.dmf2Result("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
253
                "<record xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:prov=\"http://www.openarchives.org/OAI/2.0/provenance\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:dri=\"http://www.driver-repository.eu/namespace/dri\" xmlns:dr=\"http://www.driver-repository.eu/namespace/dr\" xmlns:oaf=\"http://namespace.openaire.eu/oaf\">\n" +
254
                "  <header xmlns=\"http://namespace.openaire.eu/\">\n" +
255
                "    <dri:objIdentifier>crossref____::47593e13b24bcdd0f3d5573499f1d3a9</dri:objIdentifier>\n" +
256
                "    <dri:recordIdentifier>10.1088/0004-637X/761/1/34</dri:recordIdentifier>\n" +
257
                "    <dri:dateOfCollection></dri:dateOfCollection>\n" +
258
                "    <dri:mdFormat></dri:mdFormat>\n" +
259
                "    <dri:mdFormatInterpretation></dri:mdFormatInterpretation>\n" +
260
                "    <dri:repositoryId></dri:repositoryId>\n" +
261
                "    <dr:objectIdentifier></dr:objectIdentifier>\n" +
262
                "    <dr:dateOfCollection>2014-10-10T14:59:49+00:00</dr:dateOfCollection>\n" +
263
                "    <oaf:datasourceprefix>crossref____</oaf:datasourceprefix>\n" +
264
                "  </header>\n" +
265
                "  <metadata xmlns=\"http://namespace.openaire.eu/\">\n" +
266
                "      <dc:dateAccepted>2012-01-01T00:00:00Z</dc:dateAccepted>\n" +
267
                "             <dc:identifier>http://stacks.iop.org/0004-637X/761/i=1/a=34?key=crossref.d14dae8ac205453af63561a69c108e13</dc:identifier>\n" +
268
                "          <dc:title>A THREE-DIMENSIONAL VIEW OF THE REMNANT OF NOVA PERSEI 1901 (GK Per)</dc:title>\n" +
269
                "             <oaf:collectedDatasourceid>openaire____::crossref</oaf:collectedDatasourceid>\n" +
270
                "       <oaf:accessrights></oaf:accessrights>\n" +
271
                "       <oaf:hostedBy name=\"Unknown Repository\" id=\"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\"/>\n" +
272
                "    <oaf:collectedFrom name=\"Crossref\" id=\"openaire____::crossref\" />\n" +
273
                "\n" +
274
                "     <dc:creator>Liimets, T.</dc:creator>\n" +
275
                "   generateCreateClaimTablesQuery  <dc:creator>Corradi, R. L. M.</dc:creator>\n" +
276
                "     <dc:creator>Santander-Garc&#237;a, M.</dc:creator>\n" +
277
                "     <dc:creator>Villaver, E.</dc:creator>\n" +
278
                "     <dc:creator>Rodr&#237;guez-Gil, P.</dc:creator>\n" +
279
                "     <dc:creator>Verro, K.</dc:creator>\n" +
280
                "     <dc:creator>Kolka, I.</dc:creator>\n" +
281
                "\n" +
282
                "        <dc:identifier identifierType=\"doi\">10.1088/0004-637X/761/1/34</dc:identifier>\n" +
283
                "        <dr:CobjIdentifier>10.1088/0004-637X/761/1/34</dr:CobjIdentifier>\n" +
284
                "  </metadata>\n" +
285
                "</record>");
286
        log.info(r.toString());
287

    
288
    }
289
    @Test
290
    public void dropClaimTables() throws Exception {
291
//        sqlDAO.executeUpdateQuery(queryGenerator.generateDeleteClaimTablesQuery());
292
    }
293
    @Test
294
    public void createClaimTables() throws Exception {
295
//        sqlDAO.executeUpdateQuery(queryGenerator.generateCreateClaimTablesQuery());
296
    }
297

    
298
    @Test
299
    public void validDoiTest() throws Exception {
300
        String doi="10.1523/​JNEUROSCI.2900-11.2012";
301
        doi="10.1523/​JNEUROSCI.2900-11.2012";
302
        String tr_doi=doi=dmfResultHandler.checkDoiValidity(doi);
303
        System.out.println("Initial doi:"+doi+" "+((doi.equals(tr_doi))?"":" Transformed to"+tr_doi));
304

    
305
    }
306

    
307
    @Test
308
    public void buildProject() throws Exception {
309
        String id = "arc_________::089188bbc5db213fb2b00a0d93043fc4";
310
        Project pr = projectHandler.fetchProjectByID(id);
311
        log.info(pr.toString());
312
        id="corda_______::404d91e07cd4d32fddd8fc636ad4daf7";
313
        pr = projectHandler.fetchProjectByID(id);
314
        log.info(pr.toString());
315

    
316
    }
317
    @Test
318
    public void test() throws Exception {
319
String xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?><response>\t  <header>\t\t    <query>(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (objidentifier exact od______1266::af81022e9c489007a8f9ab27c2c725cb)</query>\t\t\t\t  <locale>en_GB</locale>\t\t\t\t\t\t<size>10</size>\t\t\t   <page>1</page>\t\t\t   <total>1</total>\t\t\t\t\t</header>\t  <results>\t\t\t\t\t\t\t\t\t<result xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"              xmlns:dri=\"http://www.driver-repository.eu/namespace/dri\"              xmlns:oaf=\"http://namespace.openaire.eu/oaf\">         <header>            <dri:objIdentifier>od______1266::af81022e9c489007a8f9ab27c2c725cb</dri:objIdentifier>            <dri:dateOfCollection>2015-08-14T07:08:53.549Z</dri:dateOfCollection>            <counters>\t              <counter_authorship value=\"2\"/>               <counter_outcome value=\"1\"/>\t           </counters>         </header>         <metadata>            <oaf:entity xsi:schemaLocation=\"http://namespace.openaire.eu/oaf https://www.openaire.eu/schema/0.3/oaf-0.3.xsd\">\t\t             <oaf:result>\t\t\t               <subject classid=\"keyword\" classname=\"keyword\" schemeid=\"dnet:result_subject\"                           schemename=\"dnet:result_subject\">MATLAB</subject>                  <subject classid=\"keyword\" classname=\"keyword\" schemeid=\"dnet:result_subject\"                           schemename=\"dnet:result_subject\">Lecture</subject>                  <subject classid=\"keyword\" classname=\"keyword\" schemeid=\"dnet:result_subject\"                           schemename=\"dnet:result_subject\">Exercises</subject>                  <subject classid=\"keyword\" classname=\"keyword\" schemeid=\"dnet:result_subject\"                           schemename=\"dnet:result_subject\">Exercises in Linear Vibration Theory</subject>                  <subject classid=\"keyword\" classname=\"keyword\" schemeid=\"dnet:result_subject\"                           schemename=\"dnet:result_subject\">System Conditions</subject>                  <subject classid=\"keyword\" classname=\"keyword\" schemeid=\"dnet:result_subject\"                           schemename=\"dnet:result_subject\">MATLAB</subject>                  <subject classid=\"keyword\" classname=\"keyword\" schemeid=\"dnet:result_subject\"                           schemename=\"dnet:result_subject\">Exercises</subject>                  <subject classid=\"keyword\" classname=\"keyword\" schemeid=\"dnet:result_subject\"                           schemename=\"dnet:result_subject\">Exercises in Linear Vibration Theory</subject>                  <subject classid=\"keyword\" classname=\"keyword\" schemeid=\"dnet:result_subject\"                           schemename=\"dnet:result_subject\">System Conditions</subject>                  <subject classid=\"keyword\" classname=\"keyword\" schemeid=\"dnet:result_subject\"                           schemename=\"dnet:result_subject\">Damping Coefficient</subject>                  <subject classid=\"keyword\" classname=\"keyword\" schemeid=\"dnet:result_subject\"                           schemename=\"dnet:result_subject\">Lecture</subject>                  <title classid=\"main title\" classname=\"main title\" schemeid=\"dnet:dataCite_title\"                         schemename=\"dnet:dataCite_title\">Vibration Theory, Vol. 1B:linear vibration theory, MATLAB exercises</title>                  <dateofacceptance>1996-02-01</dateofacceptance>                  <publisher>Department of Mechanical Engineering, Aalborg University</publisher>                  <resulttype classid=\"publication\" classname=\"publication\" schemeid=\"dnet:result_typologies\"                              schemename=\"dnet:result_typologies\"/>                  <language classid=\"eng\" classname=\"English\" schemeid=\"dnet:languages\"                            schemename=\"dnet:languages\"/>                  <format>application/pdf</format>                  <description>The present collection of MATLAB exercises has been published as a supplement to the textbook, Svingningsteori, Bind 1 and the collection of exercises in Vibration theory, Vol. 1A, Solved Problems. Throughout the exercise references are made to these books.&lt;br/&gt;&lt;br/&gt;The purpose of the MATLAB exercises is to give a better understanding of the physical problems in linear vibration theory and to surpress the mathematical analysis used to solve the problems. For this purpose the MATLAB environment is excellent.</description>                  <description>The present collection of MATLAB exercises has been published as a supplement to the textbook, Svingningsteori, Bind 1 and the collection of exercises in Vibration theory, Vol. 1A, Solved Problems. Throughout the exercise references are made to these books.&lt;br/&gt;&lt;br/&gt;The purpose of the MATLAB exercises is to give a better understanding of the physical problems in linear vibration theory and to surpress the mathematical analysis used to solve the problems. For this purpose the MATLAB environment is excellent.</description>                  <source>Asmussen , J C &amp; Nielsen , S R K 1996 , Vibration Theory, Vol. 1B : linear vibration theory, MATLAB exercises . Department of Mechanical Engineering, Aalborg University , Aalborg . U/ , no. 9601</source>                  <country classid=\"\" classname=\"\" schemeid=\"\" schemename=\"\"/>                  <relevantdate classid=\"\" classname=\"\" schemeid=\"\" schemename=\"\"/>                  <embargoenddate/>                  <fulltext/>                  <storagedate/>                  <resourcetype classid=\"\" classname=\"\" schemeid=\"\" schemename=\"\"/>                  <device/>                  <size/>                  <version/>                  <lastmetadataupdate/>                  <metadataversionnumber/>                  <originalId>oai:pure.atira.dk:publications/0b993280-a86a-11da-8341-000ea68e967b</originalId>                  <collectedfrom name=\"VBN\" id=\"opendoar____::8e2cfdc275761edc592f73a076197c33\"/>                  <pid classid=\"oai\" classname=\"oai\" schemeid=\"dnet:pid_types\"                       schemename=\"dnet:pid_types\">oai:pure.atira.dk:publications/0b993280-a86a-11da-8341-000ea68e967b</pid>                  <bestlicense classid=\"OPEN\" classname=\"Open Access\" schemeid=\"dnet:access_modes\"                               schemename=\"dnet:access_modes\"/>                  <context id=\"FCT\" label=\"Fundação para a Ciência e a Tecnologia, I.P.\" type=\"funding\">                     <category id=\"FCT::3599-PPCDT\" label=\"3599-PPCDT\"/>                  </context>                  <datainfo>                     <inferred>false</inferred>                     <deletedbyinference>false</deletedbyinference>                     <trust>0.9</trust>                     <inferenceprovenance/>                     <provenanceaction classid=\"sysimport:crosswalk:repository\"                                       classname=\"sysimport:crosswalk:repository\"                                       schemeid=\"dnet:provenanceActions\"                                       schemename=\"dnet:provenanceActions\"/>                  </datainfo>\t\t                <rels>\t\t                   <rel inferred=\"false\" trust=\"0.9\" inferenceprovenance=\"\"                          provenanceaction=\"user:claim:search\">\t\t                      <to class=\"isProducedBy\" scheme=\"dnet:result_project_relations\" type=\"project\">fct_________::0432268334291febec6d0dbc1f8bae5d</to>\t\t                      <websiteurl>http://www.fct.pt/apoios/projectos/consulta/vglobal_projecto.phtml.en?idProjecto=83907&amp;idElemConcurso=2612</websiteurl>                        <code>83907</code>                        <acronym>MIT-Pt/BS-CTRM/0051/2008</acronym>                        <title>Smart small-scale devices: systems for controlled delivery of bioactive molecules, cell expansion and for sensing cell environment.</title>                        <contracttype classid=\"UNKNOWN\" classname=\"UNKNOWN\" schemeid=\"fct:contractTypes\"                                      schemename=\"fct:contractTypes\"/>                        <funding>                           <funder id=\"fct_________::FCT\" shortname=\"FCT\"                                   name=\"Fundação para a Ciência e a Tecnologia, I.P.\"                                   jurisdiction=\"PT\"/>                           <funding_level_0 name=\"3599-PPCDT\">fct_________::FCT::3599-PPCDT</funding_level_0>                        </funding>\t\t                   </rel>                     <rel inferred=\"true\" trust=\"0.9\" inferenceprovenance=\"\"                          provenanceaction=\"sysimport:crosswalk:repository\">\t\t                      <to class=\"hasAuthor\" scheme=\"dnet:personroles\" type=\"person\">dedup_wf_001::b3bccc606f9dfe608199defb1f89b4d2</to>\t\t                      <ranking>1</ranking>                        <fullname>Asmussen, J.C.</fullname>\t\t                   </rel>                     <rel inferred=\"true\" trust=\"0.9\" inferenceprovenance=\"\"                          provenanceaction=\"sysimport:crosswalk:repository\">\t\t                      <to class=\"hasAuthor\" scheme=\"dnet:personroles\" type=\"person\">dedup_wf_001::facd63932e76860852cdd2ca9d33f45c</to>\t\t                      <ranking>2</ranking>                        <fullname>Søren R. K. Nielsen</fullname>\t\t                   </rel>\t\t                </rels>\t\t                <children>\t\t\t                  <instance id=\"opendoar____::8e2cfdc275761edc592f73a076197c33\">\t\t\t                     <licence classid=\"OPEN\" classname=\"Open Access\" schemeid=\"dnet:access_modes\"                                 schemename=\"dnet:access_modes\"/>                        <instancetype classid=\"0002\" classname=\"Book\" schemeid=\"dnet:publication_resource\"                                      schemename=\"dnet:publication_resource\"/>                        <hostedby name=\"VBN\" id=\"opendoar____::8e2cfdc275761edc592f73a076197c33\"/>\t\t\t\t                    <webresource>\t\t\t\t                       <url>http://vbn.aau.dk/da/publications/vibration-theory-vol-1b(0b993280-a86a-11da-8341-000ea68e967b).html</url>\t\t\t\t                    </webresource>\t\t\t\t                    <webresource>\t\t\t\t                       <url>http://vbn.aau.dk/ws/files/57794257/vibration_theory_vol._1b_linear_vibration_theory_MATLAB_exercises.pdf</url>\t\t\t\t                    </webresource>\t\t\t                  </instance>\t\t                </children>\t\t             </oaf:result>            </oaf:entity>         </metadata>      </result>\t\t\t\t\t\t</results>\t  <browseResults>\t\t\t</browseResults></response>\n";
320

    
321
        SearchUtils searchUtils = new SearchUtils();
322
        Integer size=searchUtils.getNumberOfResultsInAPIXML(xml);
323
        log.info(size);
324
        xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
325
                "<record xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:prov=\"http://www.openarchives.org/OAI/2.0/provenance\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:dri=\"http://www.driver-repository.eu/namespace/dri\" xmlns:dr=\"http://www.driver-repository.eu/namespace/dr\" xmlns:oaf=\"http://namespace.openaire.eu/oaf\">\n" +
326
                "  <header xmlns=\"http://namespace.openaire.eu/\">\n" +
327
                "    <dri:objIdentifier>orcid_______::4f9638b3f0fecbe3de2f9dde824c36d1</dri:objIdentifier>\n" +
328
                "    <dri:recordIdentifier>0000-0002-3477-3082-5288651</dri:recordIdentifier>\n" +
329
                "    <dri:dateOfCollection></dri:dateOfCollection>\n" +
330
                "    <dri:mdFormat></dri:mdFormat>\n" +
331
                "    <dri:mdFormatInterpretation></dri:mdFormatInterpretation>\n" +
332
                "    <dri:repositoryId></dri:repositoryId>\n" +
333
                "    <dr:objectIdentifier></dr:objectIdentifier>\n" +
334
                "    <dr:dateOfCollection>2015-08-19T14:40:37+00:00</dr:dateOfCollection>\n" +
335
                "    <oaf:datasourceprefix>openaire____</oaf:datasourceprefix>\n" +
336
                "  </header>\n" +
337
                "  <metadata xmlns=\"http://namespace.openaire.eu/\">\n" +
338
                "      <dc:dateAccepted>2012-01-01T00:00:00Z</dc:dateAccepted>\n" +
339
                "             <dc:identifier>http://dx.doi.org/10.1007/978_3_642_27169_4_2</dc:identifier>\n" +
340
                "          <dc:title>A Survey of Context-Aware Cross-Digital Library Personalization</dc:title>\n" +
341
                "             <oaf:collectedDatasourceid>openaire____::orcid</oaf:collectedDatasourceid>\n" +
342
                "       <oaf:accessrights>OPEN</oaf:accessrights>\n" +
343
                "         <oaf:embargoenddate></oaf:embargoenddate>\n" +
344
                "       <oaf:hostedBy name=\"Unknown Repository\" id=\"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\"/>\n" +
345
                "    <oaf:collectedFrom name=\"ORCID\" id=\"openaire____::orcid\" />\n" +
346
                "          \n" +
347
                "     <dc:creator>Manola, Natalia</dc:creator>\n" +
348
                "     <dc:creator>Nika, Ana</dc:creator>\n" +
349
                "     <dc:creator>Catarci, Tiziana</dc:creator>\n" +
350
                "     <dc:creator>Ioannidis, Yannis</dc:creator>\n" +
351
                "     <dc:creator>Katifori, Akrivi</dc:creator>\n" +
352
                "     <dc:creator>Koutrika, Georgia</dc:creator>\n" +
353
                "     <dc:creator>Manola, Natalia</dc:creator>\n" +
354
                "     <dc:creator>N&#252;rnberger, Andreas</dc:creator>\n" +
355
                "     <dc:creator>Thaller, Manfred</dc:creator>\n" +
356
                " \n" +
357
                "\n" +
358
                "        <oaf:identifier identiferType=\"orcidworkid\">0000-0002-3477-3082-5288651</oaf:identifier>\n" +
359
                "\n" +
360
                "  </metadata>\n" +
361
                "</record>";
362
        dmfResultHandler.fetchAccessRights(xml);
363
        dmfResultHandler.fetchDoiByDMF(xml);
364
        dmfResultHandler.fetchEmbargoEndDateByDMF(xml);
365
        dmfResultHandler.fetchOrcidWorkByDMF(xml);
366

    
367

    
368
    }
369

    
370
    @Test
371
    public void buildOpenaireResult() throws Exception {
372

    
373
        Migration migration= new Migration();
374
        Result r=migration.buildOpenaireResult("datacite____::ddbd5c4c76598f27793bccf4a99843f7","");
375
        log.info(r);
376

    
377
    }
378
    @Test
379
    public void buildOpenaireProject() throws Exception {
380
        String projetcId = "corda_______::2c37878a0cede85dbbd1081bb9b4a2f8";
381
        Migration migration= new Migration();
382
        Project r=migration.buildProject(projetcId,"");
383
        log.info(r);
384
//        this.fetchProjectHandler.updateContactEmailsByProjectId(projetcId,r.getContactEmails());
385

    
386
    }
387
    @Test
388
    public void testProject() throws Exception, SQLStoreException {
389
//        List<String> mails = new ArrayList<String>();
390
//        mails.add("test1@mail.com");
391
//        mails.add("test2@mail.com");
392
//        mails.add("test3@mail.com");
393
//        sqlDAO.executePreparedQuery(queryGenerator.generateInsertProjectQuery("123","test project","TEstP","","","",mails));
394
        System.out.println("\n"+this.fetchProjectHandler.fetchContactEmailsByProjectId("corda__h2020::94c962e736df90a5075a7f660ba3d7f6")+"\n");
395
        List<String> mails = new ArrayList<String>();
396
        mails.add("test11111@mail.com");
397
        mails.add("test122222@mail.com");
398
        this.projectHandler.updateContactEmailsByProjectId("123",mails);
399
//        System.out.println("\n"+this.projectHandler.fetchContactEmailsByProjectId("123")+"\n");
400
//        String token = UUID.randomUUID().toString();
401
//        this.projectHandler.updateTokenByProjectId("123",token);
402

    
403

    
404

    
405
    }
406
    @Test
407
    public void testMD5() throws Exception {
408
        String id = "10.1016/j.engstruct.2013.03.014";
409
        String createdId = ExternalRecordParser.createOpenaireId(id);
410
        String openaireId = "userclaim___::07ec9eb2278a11e352e3fa93a621411d";
411
        System.out.println(createdId );
412

    
413
    }
414
    @Test
415
    public void testCuration() throws Exception, SQLStoreException {
416
//        boolean updated = claimHandler.updateClaimCurationInfo("argiro@gmail.com","1",true);
417
//        System.out.println(updated);
418
    }
419

    
420
    @Test
421
    public void testFetchProjectIdByToken() throws Exception, SQLStoreException {
422
        String openaireId = this.fetchProjectHandler.fetchProjectIdByToken("dedc6979-1967-4ea2-a2ad-5135f95285ae", "test11111@mail.com");
423
        System.out.println(openaireId);
424
    }
425

    
426
    @Test
427
    public void directIndexClaim() throws Exception {
428
        System.out.println(this.claimValidation.getPathToSaveReport());
429
        String json = "{\"originalId\":\"userclaim____::d1e668dc81fa714aa98a558d9ce515fa\",\"title\":\"Expression of Ik6 and Ik8 Isoforms and Their Association with Relapse and Death in Mexican Children with Acute Lymphoblastic Leukemia\",\"authors\":[\"Reyes-León Adriana\",\"Juárez-Velázquez Rocío\",\"Medrano-Hernández Alma\",\"Cuenca-Roldán Teresa\",\"Salas-Labadía Consuelo\",\"del Pilar Navarrete-Meneses María\",\"Rivera-Luna Roberto\",\"López-Hernández Gerardo\",\"Paredes-Aguilera Rogelio\",\"Pérez-Vera Patricia\"],\"publisher\":\"Public Library of Science (PLoS)\",\"type\":\"publication\",\"pids\":[{\"type\":\"doi\",\"value\":\"10.1371/journal.pone.0130756\"}],\"licenseCode\":\"OPEN\",\"resourceType\":\"0001\",\"url\":\"http://dx.doi.org/10.1371/journal.pone.0130756\",\"hostedById\":\"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\",\"collectedFromId\":\"openaire____::crossref\",\"contexts\":[\"egi::country::gr\"]}";
430
//        System.out.println("\n\nFeed Response is: "+directIndexHandler.insertRecord(json));
431

    
432
//        System.out.println("\n\nDelete Response is: "+directIndexHandler.deleteRecord("userclaim___::d1e668dc81fa714aa98a558d9ce515fa","openaire____::crossref"));
433
    }
434

    
435
}
(9-9/9)