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 eu.dnetlib.data.emailSender.EmailSender;
25
import gr.uoa.di.driver.util.ServiceLocator;
26
import org.apache.log4j.BasicConfigurator;
27
import org.apache.log4j.Logger;
28
import org.junit.Before;
29
import org.junit.Test;
30
import org.junit.runner.RunWith;
31
import org.springframework.context.ApplicationContext;
32
import org.springframework.context.annotation.PropertySource;
33
import org.springframework.context.support.ClassPathXmlApplicationContext;
34
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
35
import org.springframework.core.io.ClassPathResource;
36
import org.springframework.test.context.ContextConfiguration;
37
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
38
import org.xml.sax.SAXException;
39

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

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

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

    
62

    
63
	private SqlDAO sqlDAO;
64
    private SqlStore sqlStore;
65

    
66
    private QueryGenerator queryGenerator;
67

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

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

    
83
    EmailSender emailSender = null;
84

    
85

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

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

    
108
        emailSender = context.getBean(EmailSender.class);
109

    
110
        assertNotNull(sqlDAO);
111

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

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

    
150
    @Test
151
    public void testFetch() throws Exception {
152

    
153
        try {
154
            List<Claim> claims = null;
155
            List<String> types= new ArrayList<String>();
156
//            types.add(ClaimUtils.CONTEXT);
157
//            types.add(ClaimUtils.PROJECT);
158
//          types.add(ClaimUtils.DATASET);
159
            types.add(ClaimUtils.PUBLICATION);
160

    
161

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

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

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

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

    
223

    
224
//        String id=claimHandler.buildAndInsertClaim("argirok@di.uoa.gr", "context", "egi::country::gr",
225
//                "openaire", null, null,"dataset", "10.4225/41/55A111BDE741C", "datacite", "OPEN","2017-05-01");
226
    }
227
    @Test
228
    public void testDelete() throws Exception, SQLStoreException {
229

    
230
//            claimHandler.deleteClaim("argirok@di.uoa.gr","2876");
231
//        claimHandler.deleteClaim("argirok@di.uoa.gr","3101");
232
        }
233

    
234
    @Test
235
	public void testJob() throws Exception, SQLStoreException {
236
        String selectcountDMFClaims =" Select count(*) from claims  where type='dmf2actions' and xml NOT ILIKE '%<oaf:concept%' ";
237
        String selectCountConceptClaims =" Select count(*) from claims  where ( type='dmf2actions' or type='updates2actions' ) and xml LIKE '%<oaf:concept%' ";
238
        String selectCountRelationClaims =" Select count(*) from claims  where type='rels2actions'  ";
239

    
240
        ResultSet rs = sqlDAO.executePreparedQuery(selectCountConceptClaims);
241

    
242
        while(rs.next()) {
243
            log.info("Concept claims: "+rs.getInt(1));
244
        }
245
         rs = sqlDAO.executePreparedQuery(selectCountRelationClaims);
246

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

    
252
        while(rs.next()) {
253
            log.info("Migrated claims: "+rs.getInt(1));
254
        }
255
        rs = sqlDAO.executePreparedQuery("Select count(*) from result");
256

    
257
        while(rs.next()) {
258
            log.info("Results: "+rs.getInt(1));
259
        }
260

    
261
	}
262

    
263
    @Test
264
    public void testHttpRequest() throws Exception {
265
        SearchUtils searchUtils= new SearchUtils();
266
        log.info(searchUtils.fetchPublicationXmlFromIndex("doajarticles::eb8a123eb82b25013b0001d0e2d1842b", false));
267
        log.info(searchUtils.fetchDatasetXmlFromIndex("doajarticles::eb8a123eb82b25013b0001d0e2d1842b", false));
268
    }
269

    
270
    @Test
271
    public void testXpath() throws Exception {
272
            Result r=indexResultHandler.fetchResultById("dedup_wf_001::88a1eedd1ffce63dccf51d8ce2053c85", false);
273
     }
274

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

    
283
    }
284
    @Test
285
    public void testPublicationXpath() throws Exception {
286
        Result r=indexResultHandler.fetchPublicationById("od________18::5acd89ab4df2b877a7a208ea2a123a87", false);
287
        if(r!=null){
288
            System.out.println(r.toString());
289
        }
290

    
291
    }
292

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

    
331
    }
332
    @Test
333
    public void dropClaimTables() throws Exception {
334
//        sqlDAO.executeUpdateQuery(queryGenerator.generateDeleteClaimTablesQuery());
335
    }
336
    @Test
337
    public void createClaimTables() throws Exception {
338
//        sqlDAO.executeUpdateQuery(queryGenerator.generateCreateClaimTablesQuery());
339
    }
340

    
341
    @Test
342
    public void validDoiTest() throws Exception {
343
        String doi="10.1523/​JNEUROSCI.2900-11.2012";
344
        doi="10.1523/​JNEUROSCI.2900-11.2012";
345
        String tr_doi=doi=dmfResultHandler.checkDoiValidity(doi);
346
        System.out.println("Initial doi:"+doi+" "+((doi.equals(tr_doi))?"":" Transformed to"+tr_doi));
347

    
348
    }
349

    
350
    @Test
351
    public void buildProject() throws Exception {
352
        String id = "arc_________::089188bbc5db213fb2b00a0d93043fc4";
353
        Project pr = projectHandler.fetchProjectByID(id,false);
354
        log.info(pr.toString());
355
        id="corda_______::404d91e07cd4d32fddd8fc636ad4daf7";
356
        pr = projectHandler.fetchProjectByID(id, false);
357
        log.info(pr.toString());
358

    
359
    }
360
    @Test
361
    public void test() throws Exception {
362
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";
363

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

    
410

    
411
    }
412

    
413
    @Test
414
    public void buildOpenaireResult() throws Exception {
415

    
416
        Migration migration= new Migration();
417
        Result r=migration.buildOpenaireResult("datacite____::ddbd5c4c76598f27793bccf4a99843f7","");
418
        log.info(r);
419

    
420
    }
421
    @Test
422
    public void buildOpenaireProject() throws Exception {
423
        String projetcId = "corda_______::2c37878a0cede85dbbd1081bb9b4a2f8";
424
        Migration migration= new Migration();
425
        Project r=migration.buildProject(projetcId,"");
426
        log.info(r);
427
//        this.fetchProjectHandler.updateContactEmailsByProjectId(projetcId,r.getContactEmails());
428

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

    
446

    
447

    
448
    }
449
    @Test
450
    public void testMD5() throws Exception {
451
        String id = "10.1016/j.engstruct.2013.03.014";
452
        String createdId = ExternalRecordParser.createOpenaireId(id);
453
        String openaireId = "userclaim___::07ec9eb2278a11e352e3fa93a621411d";
454
        System.out.println(createdId );
455

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

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

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

    
484
    // To run following tests about email: claim notifications, set all the properties inside project folder
485
    @Test
486
    public void forceSendEmailNotifications() throws Exception {
487
        //emailSender.run();
488
    }
489

    
490
    @Test
491
    public void testEmail() throws Exception {
492
        ArrayList<String> list = new ArrayList<String>();
493
        list.add("konstantinagalouni@gmail.com");
494
        list.add("argirok@di.uoa.gr");
495
//        emailSender.send("openaire_id_test", "openaire_name_test", "community", list);
496
    }
497

    
498
}
(10-10/10)