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("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 {
156
//            claims = fetchClaimHandler.fetchClaimsByUser("argirok@di.uoa.gr",3,0,null,"claim.claim_date",false,types,false);
157
//
158
//            claims = fetchClaimHandler.fetchClaimsByProject("corda_______::ab9c77ce02967b24fc9c1a74276e4677",5,0);
159
//            claims = fetchClaimHandler.fetchClaimsByProject("corda__h2020::94c962e736df90a5075a7f660ba3d7f6",12,0,null, "claim.claim_date",false,types,true);
160
            //claims = fetchClaimHandler.fetchClaimsByToken("corda__h2020::94c962e736df90a5075a7f660ba3d7f6","argiro@gmail.com",12,0,null, "claim.claim_date",false,types,false);
161

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

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

    
179
//        System.out.println("ALL:"+fetchClaimHandler.countAllClaims("", types));
180
//                +"\n Project: "+fetchClaimHandler.countClaimsByProject("corda_______::ab9c77ce02967b24fc9c1a74276e4677")+
181
//                " \n Result:"+fetchClaimHandler.countClaimsByResult("dedup_wf_001::541b1cef0d38d519e98a3b7a5b60bc75")+" \n Context:"+fetchClaimHandler.countClaimsByContext("egi::country::de")
182
//        +" \n Date:"+fetchClaimHandler.countClaimsByDate("2014-04-14","2015-04-14")+" \n Funder:"+fetchClaimHandler.countClaimsByFunder("fct_________::FCT"));
183
        } catch (Exception e) {
184
            log.error("",e);
185
        } catch (SQLStoreException e) {
186
            e.printStackTrace();
187
        }
188
    }
189
    @Test
190
    public void testContext(){
191
        System.out.print(DMFContextHandler.fetchContextById("egi::organisation::uom"));
192
    }
193
    @Test
194
    public void testInsert() throws Exception, SQLStoreException {
195
 //acm_________::31e0e5e7cbd6e2556336d7e795f55c49
196
//dedup_wf_001::64ca1e3a4d1590456ad3dd7df8a18cd7
197
 /*
198
claimedBy	argirok_1@hotmail.com
199
sourceId	corda_______::2c37878a0cede85dbbd1081bb9b4a2f8
200
sourceType	project
201
sourceCollectedFrom	openaire
202
sourceAccessRights	OPEN
203
sourceEmbargoEndDate
204
targetId	10.1007/978-3-540-76323-9_4
205
targetType	software
206
targetCollectedFrom	crossref
207
targetAccessRights	EMBARGO
208
targetEmbargoEndDate	2028-11-10T13:55:47.935Z
209
  */
210
        String id=claimHandler.buildAndInsertClaim("argirok_1@hotmail.com", "project", "corda__h2020::94c962e736df90a5075a7f660ba3d7f6", "openaire", "OPEN", null,"software", "10.1007/978-3-540-76323-9_4", "crossref", "EMBARGO","2028-11-10T13:55:47.935Z");
211

    
212

    
213
//        String id=claimHandler.buildAndInsertClaim("argirok@di.uoa.gr", "context", "egi::country::gr",
214
//                "openaire", null, null,"dataset", "10.4225/41/55A111BDE741C", "datacite", "OPEN","2017-05-01");
215
    }
216
    @Test
217
    public void testDelete() throws Exception, SQLStoreException {
218

    
219
//            claimHandler.deleteClaim("argirok@di.uoa.gr","2876");
220
//        claimHandler.deleteClaim("argirok@di.uoa.gr","3101");
221
        }
222

    
223
    @Test
224
	public void testJob() throws Exception, SQLStoreException {
225
        String selectcountDMFClaims =" Select count(*) from claims  where type='dmf2actions' and xml NOT ILIKE '%<oaf:concept%' ";
226
        String selectCountConceptClaims =" Select count(*) from claims  where ( type='dmf2actions' or type='updates2actions' ) and xml LIKE '%<oaf:concept%' ";
227
        String selectCountRelationClaims =" Select count(*) from claims  where type='rels2actions'  ";
228

    
229
        ResultSet rs = sqlDAO.executePreparedQuery(selectCountConceptClaims);
230

    
231
        while(rs.next()) {
232
            log.info("Concept claims: "+rs.getInt(1));
233
        }
234
         rs = sqlDAO.executePreparedQuery(selectCountRelationClaims);
235

    
236
        while(rs.next()) {
237
            log.info("Relation claims: "+rs.getInt(1));
238
        }
239
         rs = sqlDAO.executePreparedQuery("Select count(*) from claim");
240

    
241
        while(rs.next()) {
242
            log.info("Migrated claims: "+rs.getInt(1));
243
        }
244
        rs = sqlDAO.executePreparedQuery("Select count(*) from result");
245

    
246
        while(rs.next()) {
247
            log.info("Results: "+rs.getInt(1));
248
        }
249

    
250
	}
251

    
252
    @Test
253
    public void testHttpRequest() throws Exception {
254
        SearchUtils searchUtils= new SearchUtils();
255
        log.info(searchUtils.fetchPublicationXmlFromIndex("doajarticles::eb8a123eb82b25013b0001d0e2d1842b", false));
256
        log.info(searchUtils.fetchDatasetXmlFromIndex("doajarticles::eb8a123eb82b25013b0001d0e2d1842b", false));
257
    }
258

    
259
    @Test
260
    public void testXpath() throws Exception {
261
            Result r=indexResultHandler.fetchResultById("dedup_wf_001::88a1eedd1ffce63dccf51d8ce2053c85", false);
262
     }
263

    
264
    @Test
265
    public void testSoftwareXpath() throws Exception {
266
//        http://scoobydoo.di.uoa.gr:5000/search/software?softwareId=datacite____%3A%3Aabe9e916b29d028789d7ae3c6f79f254
267
        Result r=indexResultHandler.fetchSoftwareById("datacite____::abe9e916b29d028789d7ae3c6f79f254", false);
268
        if(r!=null){
269
            System.out.println(r.toString());
270
        }
271

    
272
    }
273
    @Test
274
    public void testPublicationXpath() throws Exception {
275
        Result r=indexResultHandler.fetchPublicationById("od________18::5acd89ab4df2b877a7a208ea2a123a87", false);
276
        if(r!=null){
277
            System.out.println(r.toString());
278
        }
279

    
280
    }
281

    
282
    @Test
283
    public void testParsingDMF() throws IOException, SAXException, ParserConfigurationException, XPathExpressionException, TransformerException {
284
        Result r=DMFParser.dmf2Result("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
285
                "<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" +
286
                "  <header xmlns=\"http://namespace.openaire.eu/\">\n" +
287
                "    <dri:objIdentifier>crossref____::47593e13b24bcdd0f3d5573499f1d3a9</dri:objIdentifier>\n" +
288
                "    <dri:recordIdentifier>10.1088/0004-637X/761/1/34</dri:recordIdentifier>\n" +
289
                "    <dri:dateOfCollection></dri:dateOfCollection>\n" +
290
                "    <dri:mdFormat></dri:mdFormat>\n" +
291
                "    <dri:mdFormatInterpretation></dri:mdFormatInterpretation>\n" +
292
                "    <dri:repositoryId></dri:repositoryId>\n" +
293
                "    <dr:objectIdentifier></dr:objectIdentifier>\n" +
294
                "    <dr:dateOfCollection>2014-10-10T14:59:49+00:00</dr:dateOfCollection>\n" +
295
                "    <oaf:datasourceprefix>crossref____</oaf:datasourceprefix>\n" +
296
                "  </header>\n" +
297
                "  <metadata xmlns=\"http://namespace.openaire.eu/\">\n" +
298
                "      <dc:dateAccepted>2012-01-01T00:00:00Z</dc:dateAccepted>\n" +
299
                "             <dc:identifier>http://stacks.iop.org/0004-637X/761/i=1/a=34?key=crossref.d14dae8ac205453af63561a69c108e13</dc:identifier>\n" +
300
                "          <dc:title>A THREE-DIMENSIONAL VIEW OF THE REMNANT OF NOVA PERSEI 1901 (GK Per)</dc:title>\n" +
301
                "             <oaf:collectedDatasourceid>openaire____::crossref</oaf:collectedDatasourceid>\n" +
302
                "       <oaf:accessrights></oaf:accessrights>\n" +
303
                "       <oaf:hostedBy name=\"Unknown Repository\" id=\"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\"/>\n" +
304
                "    <oaf:collectedFrom name=\"Crossref\" id=\"openaire____::crossref\" />\n" +
305
                "\n" +
306
                "     <dc:creator>Liimets, T.</dc:creator>\n" +
307
                "   generateCreateClaimTablesQuery  <dc:creator>Corradi, R. L. M.</dc:creator>\n" +
308
                "     <dc:creator>Santander-Garc&#237;a, M.</dc:creator>\n" +
309
                "     <dc:creator>Villaver, E.</dc:creator>\n" +
310
                "     <dc:creator>Rodr&#237;guez-Gil, P.</dc:creator>\n" +
311
                "     <dc:creator>Verro, K.</dc:creator>\n" +
312
                "     <dc:creator>Kolka, I.</dc:creator>\n" +
313
                "\n" +
314
                "        <dc:identifier identifierType=\"doi\">10.1088/0004-637X/761/1/34</dc:identifier>\n" +
315
                "        <dr:CobjIdentifier>10.1088/0004-637X/761/1/34</dr:CobjIdentifier>\n" +
316
                "  </metadata>\n" +
317
                "</record>");
318
        log.info(r.toString());
319

    
320
    }
321
    @Test
322
    public void dropClaimTables() throws Exception {
323
//        sqlDAO.executeUpdateQuery(queryGenerator.generateDeleteClaimTablesQuery());
324
    }
325
    @Test
326
    public void createClaimTables() throws Exception {
327
//        sqlDAO.executeUpdateQuery(queryGenerator.generateCreateClaimTablesQuery());
328
    }
329

    
330
    @Test
331
    public void validDoiTest() throws Exception {
332
        String doi="10.1523/​JNEUROSCI.2900-11.2012";
333
        doi="10.1523/​JNEUROSCI.2900-11.2012";
334
        String tr_doi=doi=dmfResultHandler.checkDoiValidity(doi);
335
        System.out.println("Initial doi:"+doi+" "+((doi.equals(tr_doi))?"":" Transformed to"+tr_doi));
336

    
337
    }
338

    
339
    @Test
340
    public void buildProject() throws Exception {
341
        String id = "arc_________::089188bbc5db213fb2b00a0d93043fc4";
342
        Project pr = projectHandler.fetchProjectByID(id,false);
343
        log.info(pr.toString());
344
        id="corda_______::404d91e07cd4d32fddd8fc636ad4daf7";
345
        pr = projectHandler.fetchProjectByID(id, false);
346
        log.info(pr.toString());
347

    
348
    }
349
    @Test
350
    public void test() throws Exception {
351
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";
352

    
353
        SearchUtils searchUtils = new SearchUtils();
354
        Integer size=searchUtils.getNumberOfResultsInAPIXML(xml);
355
        log.info(size);
356
        xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
357
                "<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" +
358
                "  <header xmlns=\"http://namespace.openaire.eu/\">\n" +
359
                "    <dri:objIdentifier>orcid_______::4f9638b3f0fecbe3de2f9dde824c36d1</dri:objIdentifier>\n" +
360
                "    <dri:recordIdentifier>0000-0002-3477-3082-5288651</dri:recordIdentifier>\n" +
361
                "    <dri:dateOfCollection></dri:dateOfCollection>\n" +
362
                "    <dri:mdFormat></dri:mdFormat>\n" +
363
                "    <dri:mdFormatInterpretation></dri:mdFormatInterpretation>\n" +
364
                "    <dri:repositoryId></dri:repositoryId>\n" +
365
                "    <dr:objectIdentifier></dr:objectIdentifier>\n" +
366
                "    <dr:dateOfCollection>2015-08-19T14:40:37+00:00</dr:dateOfCollection>\n" +
367
                "    <oaf:datasourceprefix>openaire____</oaf:datasourceprefix>\n" +
368
                "  </header>\n" +
369
                "  <metadata xmlns=\"http://namespace.openaire.eu/\">\n" +
370
                "      <dc:dateAccepted>2012-01-01T00:00:00Z</dc:dateAccepted>\n" +
371
                "             <dc:identifier>http://dx.doi.org/10.1007/978_3_642_27169_4_2</dc:identifier>\n" +
372
                "          <dc:title>A Survey of Context-Aware Cross-Digital Library Personalization</dc:title>\n" +
373
                "             <oaf:collectedDatasourceid>openaire____::orcid</oaf:collectedDatasourceid>\n" +
374
                "       <oaf:accessrights>OPEN</oaf:accessrights>\n" +
375
                "         <oaf:embargoenddate></oaf:embargoenddate>\n" +
376
                "       <oaf:hostedBy name=\"Unknown Repository\" id=\"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\"/>\n" +
377
                "    <oaf:collectedFrom name=\"ORCID\" id=\"openaire____::orcid\" />\n" +
378
                "          \n" +
379
                "     <dc:creator>Manola, Natalia</dc:creator>\n" +
380
                "     <dc:creator>Nika, Ana</dc:creator>\n" +
381
                "     <dc:creator>Catarci, Tiziana</dc:creator>\n" +
382
                "     <dc:creator>Ioannidis, Yannis</dc:creator>\n" +
383
                "     <dc:creator>Katifori, Akrivi</dc:creator>\n" +
384
                "     <dc:creator>Koutrika, Georgia</dc:creator>\n" +
385
                "     <dc:creator>Manola, Natalia</dc:creator>\n" +
386
                "     <dc:creator>N&#252;rnberger, Andreas</dc:creator>\n" +
387
                "     <dc:creator>Thaller, Manfred</dc:creator>\n" +
388
                " \n" +
389
                "\n" +
390
                "        <oaf:identifier identiferType=\"orcidworkid\">0000-0002-3477-3082-5288651</oaf:identifier>\n" +
391
                "\n" +
392
                "  </metadata>\n" +
393
                "</record>";
394
        dmfResultHandler.fetchAccessRights(xml);
395
        dmfResultHandler.fetchDoiByDMF(xml);
396
        dmfResultHandler.fetchEmbargoEndDateByDMF(xml);
397
        dmfResultHandler.fetchOrcidWorkByDMF(xml);
398

    
399

    
400
    }
401

    
402
    @Test
403
    public void buildOpenaireResult() throws Exception {
404

    
405
        Migration migration= new Migration();
406
        Result r=migration.buildOpenaireResult("datacite____::ddbd5c4c76598f27793bccf4a99843f7","");
407
        log.info(r);
408

    
409
    }
410
    @Test
411
    public void buildOpenaireProject() throws Exception {
412
        String projetcId = "corda_______::2c37878a0cede85dbbd1081bb9b4a2f8";
413
        Migration migration= new Migration();
414
        Project r=migration.buildProject(projetcId,"");
415
        log.info(r);
416
//        this.fetchProjectHandler.updateContactEmailsByProjectId(projetcId,r.getContactEmails());
417

    
418
    }
419
    @Test
420
    public void testProject() throws Exception, SQLStoreException {
421
//        List<String> mails = new ArrayList<String>();
422
//        mails.add("test1@mail.com");
423
//        mails.add("test2@mail.com");
424
//        mails.add("test3@mail.com");
425
//        sqlDAO.executePreparedQuery(queryGenerator.generateInsertProjectQuery("123","test project","TEstP","","","",mails));
426
        System.out.println("\n"+this.fetchProjectHandler.fetchContactEmailsByProjectId("corda__h2020::94c962e736df90a5075a7f660ba3d7f6")+"\n");
427
        List<String> mails = new ArrayList<String>();
428
        mails.add("test11111@mail.com");
429
        mails.add("test122222@mail.com");
430
        this.projectHandler.updateContactEmailsByProjectId("123",mails);
431
//        System.out.println("\n"+this.projectHandler.fetchContactEmailsByProjectId("123")+"\n");
432
//        String token = UUID.randomUUID().toString();
433
//        this.projectHandler.updateTokenByProjectId("123",token);
434

    
435

    
436

    
437
    }
438
    @Test
439
    public void testMD5() throws Exception {
440
        String id = "10.1016/j.engstruct.2013.03.014";
441
        String createdId = ExternalRecordParser.createOpenaireId(id);
442
        String openaireId = "userclaim___::07ec9eb2278a11e352e3fa93a621411d";
443
        System.out.println(createdId );
444

    
445
    }
446
    @Test
447
    public void testCuration() throws Exception, SQLStoreException {
448
//        boolean updated = claimHandler.updateClaimCurationInfo("argiro@gmail.com","1",true);
449
//        System.out.println(updated);
450
    }
451

    
452
    @Test
453
    public void testFetchProjectIdByToken() throws Exception, SQLStoreException {
454
        String openaireId = this.fetchProjectHandler.fetchProjectIdByToken("dedc6979-1967-4ea2-a2ad-5135f95285ae", "test11111@mail.com");
455
        System.out.println(openaireId);
456
    }
457

    
458
    @Test
459
    public void directIndexClaim() throws Exception {
460
        System.out.println(this.claimValidation.getPathToSaveReport());
461
        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\"]}";
462
//        System.out.println("\n\nFeed Response is: "+directIndexHandler.insertRecord(json));
463

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

    
467
}
(9-9/9)