Project

General

Profile

Revision 5a15b4d9

ID5a15b4d9bc3e9224f4a4fc34555e7c836308aaf7
Parent 98ad8fb7
Child be33baac

Added by Andreas Müller over 3 years ago

ref #6636 further improvements to RIS import

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/reference/ris/in/RisReferenceImport.java
9 9
package eu.etaxonomy.cdm.io.reference.ris.in;
10 10

  
11 11
import java.io.InputStreamReader;
12
import java.net.URI;
12 13
import java.util.ArrayList;
13 14
import java.util.Arrays;
14 15
import java.util.HashSet;
......
143 144
            //TODO
144 145
        }
145 146

  
147
        //ST  (remove as same as TI or T1), not handled otherwise
148
        RisValue st = getSingleValue(state, record, RisReferenceTag.ST, false); //Short title
149
        if (st != null && st.value.equals(ref.getTitle())){
150
            record.remove(RisReferenceTag.ST);
151
        }
146 152

  
147 153
        //Author
148 154
        List<RisValue> list = getListValue(record, RisReferenceTag.AU);
......
185 191
            }
186 192
        }
187 193

  
194
        //UR
195
        RisValue ur = getSingleValue(state, record, RisReferenceTag.UR); //URL
196
        if (ur != null){
197
            URI uri;
198
            try {
199
                String urStr = ur.value;
200
                uri = URI.create(urStr);
201
                ref.setUri(uri);
202
            } catch (Exception e) {
203
                String message = "URL could not be recognized: " + ur.value;
204
                state.getResult().addWarning(message, ur.location);
205
            }
206
        }
207

  
188 208
        //Pages
189 209
        RisValue sp = getSingleValue(state, record, RisReferenceTag.SP);
190 210
        RisValue ep = getSingleValue(state, record, RisReferenceTag.EP);
cdmlib-io/src/test/java/eu/etaxonomy/cdm/io/reference/RisReferenceImportTest.java
18 18
import org.junit.Assert;
19 19
import org.junit.Before;
20 20
import org.junit.Test;
21
import org.unitils.dbunit.annotation.DataSet;
21 22
import org.unitils.spring.annotation.SpringBeanByName;
22 23
import org.unitils.spring.annotation.SpringBeanByType;
23 24

  
......
34 35
import eu.etaxonomy.cdm.model.reference.Reference;
35 36
import eu.etaxonomy.cdm.model.reference.ReferenceType;
36 37
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
38
import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;
37 39

  
38 40
/**
39 41
 * @author andy
......
76 78
//***************************** TESTS *************************************//
77 79

  
78 80
	@Test
79
	public void testShort() {
81
	@DataSet( value="/eu/etaxonomy/cdm/database/BlankDataSet.xml", loadStrategy=CleanSweepInsertLoadStrategy.class)
82
    public void testShort() {
80 83
		ImportResult result = defaultImport.invoke(configurator);
81 84
		String report = result.createReport().toString();
82 85
		Assert.assertTrue(report.length() > 0);
83
//		System.out.println(report);
86
		System.out.println(report);
84 87

  
85 88
		Integer expected = 2;
86 89
		Assert.assertEquals(expected, result.getNewRecords(Reference.class));
87 90

  
88 91
		List<Reference> list = referenceService.list(Reference.class, null, null, null, null);
89
		Assert.assertEquals("There should be 2 references, the article and the journal", 2, list.size());
92
		Assert.assertEquals("There should be 3 references, the article and the journal and the source reference",
93
		        3, list.size());
90 94
		for (Reference ref : list){
95
		    if (ref.equals(configurator.getSourceReference())){
96
		        continue;
97
		    }
91 98
		    Assert.assertTrue(ref.getType() == ReferenceType.Article || ref.getType() == ReferenceType.Journal);
92 99
		    if (ref.getType() == ReferenceType.Article){
93 100
		        //title

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)