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.api.enabling.ISLookUpService;
14
import eu.dnetlib.api.enabling.ISLookUpServiceException;
15
import eu.dnetlib.data.claims.migration.ClaimValidation;
16
import eu.dnetlib.data.claims.migration.JsonldBuilder;
17
import eu.dnetlib.data.claims.migration.Migration;
18
import eu.dnetlib.data.claims.migration.entity.Claim;
19
import eu.dnetlib.data.claims.migration.entity.Project;
20
import eu.dnetlib.data.claims.migration.entity.Result;
21
import eu.dnetlib.data.claims.migration.handler.*;
22
import eu.dnetlib.data.claims.migration.parser.DMFParser;
23
import eu.dnetlib.data.claims.migration.parser.ExternalRecordParser;
24
import gr.uoa.di.driver.util.ServiceLocator;
25
import org.apache.log4j.BasicConfigurator;
26
import org.apache.log4j.Logger;
27
import org.junit.Before;
28
import org.junit.Test;
29
import org.junit.runner.RunWith;
30
import org.springframework.context.ApplicationContext;
31
import org.springframework.context.annotation.PropertySource;
32
import org.springframework.context.support.ClassPathXmlApplicationContext;
33
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
34
import org.springframework.core.io.ClassPathResource;
35
import org.springframework.test.context.ContextConfiguration;
36
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
37
import org.xml.sax.SAXException;
38

    
39
import javax.annotation.Resource;
40
import javax.xml.parsers.ParserConfigurationException;
41
import javax.xml.transform.TransformerException;
42
import javax.xml.xpath.XPathExpressionException;
43
import java.io.File;
44
import java.io.IOException;
45
import java.math.BigInteger;
46
import java.security.MessageDigest;
47
import java.sql.ResultSet;
48
import java.util.*;
49

    
50
import static junit.framework.Assert.assertNotNull;
51

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

    
61

    
62
	private SqlDAO sqlDAO;
63
    private SqlStore sqlStore;
64

    
65
    private QueryGenerator queryGenerator;
66

    
67
    RelationHandler relationHandler = null;
68
    ContextRelationHandler contextRelationHandler = null;
69
    ProjectHandler projectHandler = null;
70
    DirectIndexHandler directIndexHandler = null;
71
    FetchProjectHandler fetchProjectHandler = null;
72
    DMFContextHandler dmfContextHandler = null;
73
    DMFResultHandler dmfResultHandler = null;
74
    IndexResultHandler indexResultHandler = null;
75
    ExternalRecordHandler externalRecordHandler = null;
76
    ResultHandler resultHandler = null;
77

    
78
    FetchClaimHandler fetchClaimHandler = null;
79
    ClaimHandler claimHandler = null;
80
    ClaimValidation claimValidation = null;
81

    
82

    
83
    @Before
84
	public void init() throws Exception {
85
		BasicConfigurator.configure();
86
        ApplicationContext context = new ClassPathXmlApplicationContext("eu/dnetlib/data/claims/migration/springContext-claimsDemo.xml");
87

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

    
105
        assertNotNull(sqlDAO);
106

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

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

    
145
    @Test
146
    public void testFetch() throws Exception {
147

    
148
        try {
149
            List<Claim> claims = null;
150
            List<String> types= new ArrayList<String>();
151
//            types.add(ClaimUtils.CONTEXT);
152
//            types.add(ClaimUtils.PROJECT);
153
//          types.add(ClaimUtils.DATASET);
154
            types.add(ClaimUtils.PUBLICATION);
155

    
156

    
157
//            claims = fetchClaimHandler.fetchClaimsByUser("argirok_1@hotmail.com",1,0,types, false);
158
            claims = fetchClaimHandler.fetchClaimsByContext("egi",100,0,null,"claim.claim_date",false,types,false);
159
//            (String openaireId, Integer limit, Integer offset, String keyword, String orderField, boolean descending, List<String> types, boolean addCurationInfo) throws Exception, SQLStoreException {
160
//            claims = fetchClaimHandler.fetchClaimsByUser("argirok@di.uoa.gr",3,0,null,"claim.claim_date",false,types,false);
161
//
162
//            claims = fetchClaimHandler.fetchClaimsByProject("corda_______::ab9c77ce02967b24fc9c1a74276e4677",5,0);
163
//            claims = fetchClaimHandler.fetchClaimsByProject("corda__h2020::94c962e736df90a5075a7f660ba3d7f6",12,0,null, "claim.claim_date",false,types,true);
164
            //claims = fetchClaimHandler.fetchClaimsByToken("corda__h2020::94c962e736df90a5075a7f660ba3d7f6","argiro@gmail.com",12,0,null, "claim.claim_date",false,types,false);
165

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

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

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

    
217

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

    
224
//            claimHandler.deleteClaim("argirok@di.uoa.gr","2876");
225
//        claimHandler.deleteClaim("argirok@di.uoa.gr","3101");
226
        }
227

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

    
234
        ResultSet rs = sqlDAO.executePreparedQuery(selectCountConceptClaims);
235

    
236
        while(rs.next()) {
237
            log.info("Concept claims: "+rs.getInt(1));
238
        }
239
         rs = sqlDAO.executePreparedQuery(selectCountRelationClaims);
240

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

    
246
        while(rs.next()) {
247
            log.info("Migrated claims: "+rs.getInt(1));
248
        }
249
        rs = sqlDAO.executePreparedQuery("Select count(*) from result");
250

    
251
        while(rs.next()) {
252
            log.info("Results: "+rs.getInt(1));
253
        }
254

    
255
	}
256

    
257
    @Test
258
    public void testHttpRequest() throws Exception {
259
        SearchUtils searchUtils= new SearchUtils();
260
        log.info(searchUtils.fetchPublicationXmlFromIndex("doajarticles::eb8a123eb82b25013b0001d0e2d1842b", false));
261
        log.info(searchUtils.fetchDatasetXmlFromIndex("doajarticles::eb8a123eb82b25013b0001d0e2d1842b", false));
262
    }
263

    
264
    @Test
265
    public void testXpath() throws Exception {
266
            Result r=indexResultHandler.fetchResultById("dedup_wf_001::88a1eedd1ffce63dccf51d8ce2053c85", false);
267
     }
268

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

    
277
    }
278
    @Test
279
    public void testPublicationXpath() throws Exception {
280
        Result r=indexResultHandler.fetchPublicationById("od________18::5acd89ab4df2b877a7a208ea2a123a87", false);
281
        if(r!=null){
282
            System.out.println(r.toString());
283
        }
284

    
285
    }
286

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

    
325
    }
326
    @Test
327
    public void dropClaimTables() throws Exception {
328
//        sqlDAO.executeUpdateQuery(queryGenerator.generateDeleteClaimTablesQuery());
329
    }
330
    @Test
331
    public void createClaimTables() throws Exception {
332
//        sqlDAO.executeUpdateQuery(queryGenerator.generateCreateClaimTablesQuery());
333
    }
334

    
335
    @Test
336
    public void validDoiTest() throws Exception {
337
        String doi="10.1523/​JNEUROSCI.2900-11.2012";
338
        doi="10.1523/​JNEUROSCI.2900-11.2012";
339
        String tr_doi=doi=dmfResultHandler.checkDoiValidity(doi);
340
        System.out.println("Initial doi:"+doi+" "+((doi.equals(tr_doi))?"":" Transformed to"+tr_doi));
341

    
342
    }
343

    
344
    @Test
345
    public void buildProject() throws Exception {
346
        String id = "arc_________::089188bbc5db213fb2b00a0d93043fc4";
347
        Project pr = projectHandler.fetchProjectByID(id,false);
348
        log.info(pr.toString());
349
        id="corda_______::404d91e07cd4d32fddd8fc636ad4daf7";
350
        pr = projectHandler.fetchProjectByID(id, false);
351
        log.info(pr.toString());
352

    
353
    }
354
    @Test
355
    public void test() throws Exception {
356
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";
357

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

    
404

    
405
    }
406

    
407
    @Test
408
    public void buildOpenaireResult() throws Exception {
409

    
410
        Migration migration= new Migration();
411
        Result r=migration.buildOpenaireResult("datacite____::ddbd5c4c76598f27793bccf4a99843f7","");
412
        log.info(r);
413

    
414
    }
415
    @Test
416
    public void buildOpenaireProject() throws Exception {
417
        String projetcId = "corda_______::2c37878a0cede85dbbd1081bb9b4a2f8";
418
        Migration migration= new Migration();
419
        Project r=migration.buildProject(projetcId,"");
420
        log.info(r);
421
//        this.fetchProjectHandler.updateContactEmailsByProjectId(projetcId,r.getContactEmails());
422

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

    
440

    
441

    
442
    }
443
    @Test
444
    public void testMD5() throws Exception {
445
        String id = "10.1016/j.engstruct.2013.03.014";
446
        String createdId = ExternalRecordParser.createOpenaireId(id);
447
        String openaireId = "userclaim___::07ec9eb2278a11e352e3fa93a621411d";
448
        System.out.println(createdId );
449

    
450
    }
451
    @Test
452
    public void testCuration() throws Exception, SQLStoreException {
453
//        boolean updated = claimHandler.updateClaimCurationInfo("argiro@gmail.com","1",true);
454
//        System.out.println(updated);
455
    }
456
/*
457
    @Test
458
    public void testFetchProjectIdByTokenAndEmail() throws Exception, SQLStoreException {
459
        String openaireId = this.fetchProjectHandler.fetchProjectIdByTokenAndEmail("dedc6979-1967-4ea2-a2ad-5135f95285ae", "test11111@mail.com");
460
        System.out.println(openaireId);
461
    }
462

    
463
    @Test
464
    public void testFetchProjectIdByToken() throws Exception, SQLStoreException {
465
        String openaireId = this.fetchProjectHandler.fetchProjectIdByToken("dedc6979-1967-4ea2-a2ad-5135f95285ae");
466
        System.out.println(openaireId);
467
    }
468
*/
469
    @Test
470
    public void directIndexClaim() throws Exception {
471
        System.out.println(this.claimValidation.getPathToSaveReport());
472
        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\"]}";
473
//        System.out.println("\n\nFeed Response is: "+directIndexHandler.insertRecord(json));
474

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

    
478
}
(9-9/9)