Project

General

Profile

Revision 6e1b0ff9

ID6e1b0ff9bdf5c8e20f1df4e5542aa44554252a81
Parent 6119597f
Child 4fb5b361

Added by Andreas Müller almost 2 years ago

fix #8628 add ORCID as person identifier

View differences:

cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/UTF8.java
11 11
 */
12 12
public enum UTF8 {
13 13

  
14

  
14
    HYPHEN("\u2010"),   // hyphen https://www.fileformat.info/info/unicode/char/2010/index.htm
15
    HYPHEN_NO_BREAK("\u2011"),   // non breaking hyphen https://www.fileformat.info/info/unicode/char/2011/index.htm
16
    FIGURE_DASH("\u2012"),    //figure dash https://www.fileformat.info/info/unicode/char/2012/index.htm
15 17
	EN_DASH("\u2013"),   // https://de.wikipedia.org/wiki/Halbgeviertstrich
16 18
	EM_DASH("\u2014"),   // https://de.wikipedia.org/wiki/Geviertstrich
19
	BAR_HORIZON("\u2015"),   // horizontal bar  https://www.fileformat.info/info/unicode/char/2015/index.htm
17 20
	EM_DASH_DOUBLE("\u2E3A"),   //https://de.wikipedia.org/wiki/Doppelgeviertstrich
18 21
	SPATIUM("\u202F"),   //very short non-breaking space
19 22
	EN_DASH_SPATIUM("\u202F\u2013\u202F"),
......
47 50
		this.value = value;
48 51
	}
49 52

  
53
	public static String ANY_DASH_RE(){
54
	    return SPATIUM+"?[\\-"+HYPHEN+HYPHEN_NO_BREAK+FIGURE_DASH+EN_DASH+EM_DASH+BAR_HORIZON+EM_DASH_DOUBLE+"]"+SPATIUM+"?";
55
	}
56

  
50 57
	@Override
51 58
    public String toString(){
52 59
		return value;
cdmlib-model/src/main/java/eu/etaxonomy/cdm/hibernate/OrcidUserType.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.cdm.hibernate;
11

  
12
import java.io.Serializable;
13
import java.sql.PreparedStatement;
14
import java.sql.ResultSet;
15
import java.sql.SQLException;
16
import java.sql.Types;
17

  
18
import org.apache.log4j.Logger;
19
import org.hibernate.HibernateException;
20
import org.hibernate.engine.spi.SessionImplementor;
21
import org.hibernate.type.StandardBasicTypes;
22
import org.hibernate.usertype.UserType;
23
import org.jadira.usertype.dateandtime.shared.spi.AbstractUserType;
24

  
25
import eu.etaxonomy.cdm.model.agent.ORCID;
26

  
27
/**
28
 * Hibernate user type for the {@link ORCID} class.
29
 * @author a.mueller
30
 * @since 08.11.2018
31
 */
32
public class OrcidUserType  extends AbstractUserType implements UserType {
33

  
34
    private static final long serialVersionUID = -1274015438727972344L;
35

  
36
    @SuppressWarnings("unused")
37
	private static final Logger logger = Logger.getLogger(OrcidUserType.class);
38

  
39
	private static final int[] SQL_TYPES = { Types.VARCHAR };
40

  
41
	@Override
42
	public Object deepCopy(Object o) throws HibernateException {
43
		if (o == null) {
44
            return null;
45
        }
46
        try {
47
            ORCID orcid = (ORCID) o;
48
			return orcid;
49
		} catch (Exception e) {
50
			throw new HibernateException(e);
51
		}
52
	}
53

  
54
	@Override
55
	public Serializable disassemble(Object value) throws HibernateException {
56
		if(value == null) {
57
			return null;
58
		} else {
59
		    ORCID orcid = (ORCID) value;
60
		    return orcid.asURI();  //TO be on the safe side. We could also use orcid.getDigitsOnly()
61
		}
62
	}
63

  
64
	@Override
65
	public ORCID nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
66
			throws HibernateException, SQLException {
67
        String val = (String) StandardBasicTypes.STRING.nullSafeGet(rs, names, session, owner);
68

  
69
		if(val == null) {
70
			return null;
71
		} else {
72
            try {
73
			    return ORCID.fromString(val);
74
		    } catch (IllegalArgumentException e) {
75
			    throw new HibernateException(e);
76
		    }
77
		}
78
	}
79

  
80
	@Override
81
	public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor session)
82
			throws HibernateException, SQLException {
83
		if (value == null) {
84
            StandardBasicTypes.STRING.nullSafeSet(statement, value, index, session);
85
        } else {
86
            ORCID orcid = (ORCID)value;
87
            StandardBasicTypes.STRING.nullSafeSet(statement, orcid.getDigitsOnly(), index, session);
88
        }
89
	}
90

  
91
	@Override
92
	public Class returnedClass() {
93
		return ORCID.class;
94
	}
95

  
96
	@Override
97
	public int[] sqlTypes() {
98
		return SQL_TYPES;
99
	}
100
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/hibernate/search/OrcidBridge.java
1
/**
2
* Copyright (C) 2012 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.cdm.hibernate.search;
11

  
12
import org.hibernate.search.bridge.StringBridge;
13

  
14
import eu.etaxonomy.cdm.model.agent.ORCID;
15

  
16
/**
17
 * @author a.mueller
18
 * @since Nov 08, 2019
19
 */
20
public class OrcidBridge implements StringBridge {
21

  
22
    @Override
23
    public String objectToString(Object object) {
24
        if(object != null) {
25
            return ((ORCID)object).toString();
26
        }
27
        return null;
28
    }
29

  
30
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/ORCID.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.model.agent;
10

  
11
import java.util.regex.Matcher;
12
import java.util.regex.Pattern;
13

  
14
import org.apache.commons.lang.StringUtils;
15

  
16
import eu.etaxonomy.cdm.common.UTF8;
17

  
18

  
19
/**
20
 * A class for handling ORCIDs (http://https://orcid.org/, https://support.orcid.org/hc/en-us/articles/360006897674).
21
 * It offers parsing and formatting functionality as well as validation.
22
 * A {@link ORCID} object can only be created by syntactic valid input.
23
 * It internally stores 1 strings (length=16).
24
 *
25
 *
26
 * @author a.mueller
27
 * @since 2019-11-08
28
 */
29
public final class ORCID implements java.io.Serializable{
30

  
31
    /**
32
     * Explicit serialVersionUID for interoperability.
33
     */
34
    private static final long serialVersionUID = 4304992020966546747L;
35

  
36
    public static final String ORCID_ORG = "orcid.org/";
37

  
38
	/**
39
	 * The default public ORCID proxy server
40
	 */
41
	public static final String HTTP_ORCID_ORG = "https://" + ORCID_ORG;
42

  
43
    private volatile transient int hashCode = -1;	// Zero ==> undefined
44

  
45

  
46
//********************************* VARIABLES *************************************/
47

  
48
	/**
49
	 * The base digits without prefix, checksum and hyphens("-")
50
	 */
51
	private String baseNumber;
52

  
53
	/**
54
	 * The checksum.
55
	 * @see #checkDigit()
56
	 */
57
	private String checkSum;
58

  
59
// ***************************** FACTORY METHODS ***************************************/
60

  
61
	public static ORCID fromString(String orcid) throws IllegalArgumentException{
62
		return new ORCID(orcid);
63
	}
64

  
65
// ******************************* CONSTRUCTOR ************************************/
66

  
67
	private ORCID(){} //empty constructor required for JAXB
68

  
69
//    /**
70
//     * Creates a doi by its registrantCode and its suffix
71
//     * @param registrantCode the registrant code, the is the part following the directoryIndicator "10."
72
//     * 	and preceding the first forward slash (followed by the suffix)
73
//     * @param suffix the suffix is the part of the DOI following the first forward slash. It is provided
74
//     * by the registrant
75
//     */
76
//    private ORCID(String registrantCode, String suffix) {
77
//    	//preliminary until prefix_registrantCode and suffix validation is implemented
78
//		this("10." + registrantCode + "/" + suffix);
79
//
80
//		//use only after validation of both parts
81
////		this.prefix_registrantCode = registrantCode;
82
////		this.suffix = suffix;
83
//	}
84

  
85
    private ORCID(String doiString) {
86
		parseOrcidString(doiString);
87
	}
88

  
89
//************************************ GETTER ***********************************/
90

  
91

  
92
	/**
93
	 * The pure number representation, including the checksum (this maybe 'X'
94
	 * so it's not only digits
95
	 * @return
96
	 */
97
	public String getDigitsOnly() {
98
		return baseNumber+checkSum;
99
	}
100

  
101

  
102
// ********************************************* PARSER *******************************/
103

  
104
	private static Pattern orcidPattern = Pattern.compile("^(\\d{4}("+UTF8.ANY_DASH_RE()+")?){3}\\d{3}[0-9Xx]?$");
105

  
106
	private void parseOrcidString(String orcid){
107
		if (StringUtils.isBlank(orcid)){
108
			throw new IllegalArgumentException("ORCID string must not be null or blank");
109
		}
110
		orcid = orcid.trim();
111
		if (orcid.startsWith("http:") ){
112
		    orcid = orcid.replaceFirst("http:", "https:").trim();  //https is the current display standard
113
		}
114
//		Matcher matcher = orcidPattern.matcher(orcid);
115
//		if (matcher.find()){
116
//		    orcid = matcher.replaceFirst("").trim();
117
//		}
118

  
119

  
120
		//replace URI prefix
121
		if (orcid.startsWith(HTTP_ORCID_ORG)){
122
			orcid = orcid.replaceFirst(HTTP_ORCID_ORG, "");
123
		}else if (orcid.startsWith(ORCID_ORG)){
124
		    orcid = orcid.replaceFirst(ORCID_ORG, "");
125
        }
126

  
127

  
128
		//now we should have the pure orcid
129
		if (orcid.length() != 15 && orcid.length() != 16 && orcid.length() != 18 && orcid.length() != 19){
130
			//for persistence reason we currently restrict the length of DOIs to 1000
131
			throw new IllegalArgumentException("ORCIDs must have exactly 16 numbers and 3 dashes ('-').");
132
		}
133

  
134
		Matcher matcher = orcidPattern.matcher(orcid);
135
		if (!matcher.find()){
136
            throw new IllegalArgumentException("ORCID can not be parsed. It must have exactly 16 numbers and 3 dashes ('-').");
137
		}
138

  
139
		orcid = orcid.replaceAll(UTF8.ANY_DASH_RE(), "");
140

  
141
		if (orcid.length() == 16){
142
	        this.baseNumber = orcid.substring(0, 15);
143
		    this.checkSum = orcid.substring(15);
144
		    if (!checkDigit(baseNumber).equals(checkSum)){
145
		        throw new IllegalArgumentException("ORCID checksum not correct (last digit is checksum, see https://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier).");
146
		    }
147
		}else{
148
		    this.baseNumber = orcid;
149
		    this.checkSum = checkDigit(baseNumber);
150
		}
151

  
152
	}
153

  
154
	private String makeOrcid(){
155
		return baseNumber.substring(0,4) + "-" + baseNumber.substring(4,8) + "-"
156
		        + baseNumber.substring(8,12) + "-" + baseNumber.substring(12,15) + checkSum;
157
	}
158

  
159
	public String asURI(){
160
		return HTTP_ORCID_ORG + makeOrcid();
161
	}
162

  
163
	/**
164
     * Generates check digit as per ISO 7064 11,2.
165
     * (code from https://support.orcid.org/hc/en-us/articles/360006897674)
166
     */
167
	public String checkDigit(){
168
	    return checkDigit(baseNumber);
169
	}
170

  
171
	/**
172
	  * @see #checkDigit()
173
	  * @param baseDigits the base digits without the checkSum digit
174
	  */
175
	private static String checkDigit(String baseDigits) {
176
	    int total = 0;
177
	    for (int i = 0; i < baseDigits.length(); i++) {
178
	        int digit = Character.getNumericValue(baseDigits.charAt(i));
179
	        total = (total + digit) * 2;
180
	    }
181
	    int remainder = total % 11;
182
	    int result = (12 - remainder) % 11;
183
	    return result == 10 ? "X" : String.valueOf(result);
184
	}
185

  
186
//************************************************* toString/equals /hashCode *********************/
187

  
188
	@Override
189
	public int hashCode() {
190
		if (hashCode == -1) {
191
            hashCode = 31 * baseNumber.hashCode();
192
        }
193
        return hashCode;
194
	}
195

  
196
	@Override
197
	public boolean equals(Object obj) {
198
		if (obj instanceof ORCID){
199
			return this.baseNumber.equals(((ORCID)obj).baseNumber) &&
200
			        this.checkSum.equals(((ORCID)obj).checkSum);
201
		}
202
		return false;
203
	}
204

  
205
	@Override
206
	public String toString(){
207
		return asURI();
208
	}
209
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/Person.java
26 26
import org.apache.log4j.Logger;
27 27
import org.hibernate.annotations.Cascade;
28 28
import org.hibernate.annotations.CascadeType;
29
import org.hibernate.annotations.Type;
29 30
import org.hibernate.envers.Audited;
30 31
import org.hibernate.search.annotations.Field;
32
import org.hibernate.search.annotations.FieldBridge;
31 33
import org.hibernate.search.annotations.IndexedEmbedded;
32 34
import org.joda.time.Partial;
33 35
import org.springframework.beans.factory.annotation.Configurable;
34 36

  
37
import eu.etaxonomy.cdm.hibernate.search.OrcidBridge;
35 38
import eu.etaxonomy.cdm.model.common.TimePeriod;
36 39
import eu.etaxonomy.cdm.strategy.cache.agent.PersonDefaultCacheStrategy;
37 40
import eu.etaxonomy.cdm.strategy.match.Match;
......
66 69
	    "initials",
67 70
	    "suffix",
68 71
	    "lifespan",
72
	    "orcid",
69 73
	    "institutionalMemberships"
70 74
})
71 75
@XmlRootElement(name = "Person")
......
119 123
//    @NotNull
120 124
	private TimePeriod lifespan = TimePeriod.NewInstance();
121 125

  
126
    @XmlElement(name = "Orcid")
127
    @Field
128
    @FieldBridge(impl = OrcidBridge.class)
129
    @Type(type="orcidUserType")
130
    @Column(length=16)
131
    private ORCID orcid;
132

  
122 133
    @XmlElementWrapper(name = "InstitutionalMemberships", nillable = true)
123 134
    @XmlElement(name = "InstitutionalMembership")
124 135
    @OneToMany(fetch=FetchType.LAZY, mappedBy = "person")
......
370 381
		this.lifespan = lifespan;
371 382
	}
372 383

  
384

  
385
    /**
386
     * The {@link ORCID ORCiD} of this person.<BR>
387
     * See https://orcid.org/ for information on ORCiD.
388
     * @return the ORCiD
389
     */
390
    public ORCID getOrcid() {
391
        return orcid;
392
    }
393
    /**
394
     * @see #getOrcid()
395
     */
396
    public void setOrcid(ORCID orcid) {
397
        this.orcid = orcid;
398
    }
399

  
373 400
    @Override
374 401
    public boolean updateCaches(){
375 402
        boolean result = false;
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/package-info.java
104 104
	@org.hibernate.annotations.TypeDef(name="uriUserType", typeClass=eu.etaxonomy.cdm.hibernate.URIUserType.class),
105 105
	@org.hibernate.annotations.TypeDef(name="enumUserType", typeClass=eu.etaxonomy.cdm.hibernate.EnumUserType.class),
106 106
	@org.hibernate.annotations.TypeDef(name="doiUserType", typeClass=eu.etaxonomy.cdm.hibernate.DOIUserType.class),
107
	@org.hibernate.annotations.TypeDef(name="shiftUserType", typeClass=eu.etaxonomy.cdm.hibernate.ShiftUserType.class),
107
	@org.hibernate.annotations.TypeDef(name="orcidUserType", typeClass=eu.etaxonomy.cdm.hibernate.OrcidUserType.class),
108
    @org.hibernate.annotations.TypeDef(name="shiftUserType", typeClass=eu.etaxonomy.cdm.hibernate.ShiftUserType.class),
108 109
})
109 110
@org.hibernate.annotations.AnyMetaDef(name = "CdmBase" ,
110 111
		                              metaType="string",
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/CdmMetaData.java
58 58
	 * be handled by SCHEMA_VALIDATION.UPDATE
59 59
	 * The last number represents the date of change.
60 60
	 */
61
//	private static final String dbSchemaVersion = "5.8.1.0.20190813";
62
  private static final String dbSchemaVersion = "5.11.0.0.20191104";
61
	private static final String dbSchemaVersion = "5.11.1.0.20191108";
62
//  private static final String dbSchemaVersion = "5.11.0.0.20191104";
63 63
//    private static final String dbSchemaVersion = "5.8.2.0.20190815";
64 64

  
65 65

  
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/StrategyBase.java
21 21
import eu.etaxonomy.cdm.common.CdmUtils;
22 22
import eu.etaxonomy.cdm.common.DOI;
23 23
import eu.etaxonomy.cdm.model.agent.Contact;
24
import eu.etaxonomy.cdm.model.agent.ORCID;
24 25
import eu.etaxonomy.cdm.model.common.CdmBase;
25 26
import eu.etaxonomy.cdm.model.common.ExternallyManaged;
26 27
import eu.etaxonomy.cdm.model.common.LSID;
......
88 89
				fieldType == Contact.class ||
89 90
				fieldType == URI.class ||
90 91
				fieldType == DOI.class ||
91
				fieldType == ExternallyManaged.class
92
				fieldType == ORCID.class ||
93
		        fieldType == ExternallyManaged.class
92 94
			){
93 95
				return true;
94 96
		}else{
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/match/DefaultMatchStrategy.java
32 32
import eu.etaxonomy.cdm.common.DoubleResult;
33 33
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
34 34
import eu.etaxonomy.cdm.model.agent.Contact;
35
import eu.etaxonomy.cdm.model.agent.ORCID;
35 36
import eu.etaxonomy.cdm.model.common.CdmBase;
36 37
import eu.etaxonomy.cdm.model.common.LSID;
37 38
import eu.etaxonomy.cdm.model.common.TimePeriod;
......
294 295
            fieldResult = matchPrimitiveField(matchFirst, matchSecond, fieldMatcher, replaceModeList, failAll);
295 296
        }else if(fieldType == DOI.class){
296 297
            fieldResult = matchPrimitiveField(matchFirst, matchSecond, fieldMatcher, replaceModeList, failAll);
298
        }else if(fieldType == ORCID.class){
299
            fieldResult = matchPrimitiveField(matchFirst, matchSecond, fieldMatcher, replaceModeList, failAll);
297 300
        }else if(isSingleCdmBaseObject(fieldType)){
298 301
            matchResult.addPath(fieldMatcher.getPropertyName());
299 302
            fieldResult = matchPrimitiveField(matchFirst, matchSecond, fieldMatcher, replaceModeList, failAll);
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/agent/OrcidTest.java
1
/**
2
* Copyright (C) 2019 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.model.agent;
10

  
11
import org.junit.Assert;
12
import org.junit.Test;
13

  
14
/**
15
 * Test class for testing the {@link ORCID} class.
16
 *
17
 * For ORCID syntax see also https://support.orcid.org/hc/en-us/articles/360006897674
18
 *
19
 * @author a.mueller
20
 * @since 08.11.2019
21
 */
22
public class OrcidTest {
23

  
24
    @Test
25
    public void testValidParser() {
26
        String validOrcid = "0000-0001-5000-0007";
27
        ORCID orcid = ORCID.fromString(validOrcid);
28
        Assert.assertEquals("https://orcid.org/0000-0001-5000-0007", orcid.asURI());
29
        Assert.assertEquals("7", orcid.checkDigit());
30

  
31
        validOrcid = "0000000150000007";
32
        orcid = ORCID.fromString(validOrcid);
33
        Assert.assertEquals("https://orcid.org/0000-0001-5000-0007", orcid.asURI());
34
        Assert.assertEquals("7", orcid.checkDigit());
35

  
36
        validOrcid = "orcid.org/0000-0001-5000-0007";
37
        orcid = ORCID.fromString(validOrcid);
38
        Assert.assertEquals("https://orcid.org/0000-0001-5000-0007", orcid.asURI());
39
        Assert.assertEquals("7", orcid.checkDigit());
40

  
41
        validOrcid = "https://orcid.org/0000-0001-5000-0007";
42
        orcid = ORCID.fromString(validOrcid);
43
        Assert.assertEquals("https://orcid.org/0000-0001-5000-0007", orcid.asURI());
44
        Assert.assertEquals("7", orcid.checkDigit());
45

  
46
        validOrcid = "http://orcid.org/0000-0001-5000-0015";
47
        orcid = ORCID.fromString(validOrcid);
48
        Assert.assertEquals("https://orcid.org/0000-0001-5000-0015", orcid.asURI());
49
        Assert.assertEquals("5", orcid.checkDigit());
50
    }
51

  
52
    @Test
53
    public void testParserFail() {
54
        String invalidOrcid = "a000-0001-5000-0007";  //no letters allowed
55
        testInvalid(invalidOrcid);
56
        invalidOrcid = "0000-0001-5000-0007-9999";  //exactly 4 number blocks needed
57
        testInvalid(invalidOrcid);
58
        invalidOrcid = "0000-0001-5000-0007-0008";  //checksum must be correct, for algorithm see https://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier
59
        testInvalid(invalidOrcid);
60
    }
61

  
62
    @Test
63
    public void testEquals() {
64
        String validOrcid = "0000-0001-5000-000";
65
        ORCID orcid1 = ORCID.fromString(validOrcid);
66
        validOrcid = "0000000150000007";
67
        ORCID orcid2 = ORCID.fromString(validOrcid);
68
        Assert.assertEquals("ORCIDs must be equal. Checksum should not make it different", orcid1, orcid2);
69
        validOrcid = "0000-0001-5000-001";
70
        ORCID orcid3 = ORCID.fromString(validOrcid);
71
        Assert.assertNotEquals("Different ORCIDs must not be equal", orcid1, orcid3);
72
    }
73

  
74
    @Test
75
    public void testAsURI() {
76

  
77
        String validOrcid = "0000-0001-5000-0007";
78
        ORCID orcid1 = ORCID.fromString(validOrcid);
79
        Assert.assertEquals(ORCID.HTTP_ORCID_ORG + validOrcid, orcid1.asURI());
80
    }
81

  
82

  
83
    private void testInvalid(String invalidOrcid) {
84
        try {
85
            ORCID.fromString(invalidOrcid);
86
            Assert.fail("ORCID should not be parsable: " + invalidOrcid);
87
        } catch (IllegalArgumentException e) {
88
            //OK
89
        }
90
    }
91

  
92
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/data/FullCoverageDataGenerator.java
17 17
import eu.etaxonomy.cdm.model.agent.Address;
18 18
import eu.etaxonomy.cdm.model.agent.Contact;
19 19
import eu.etaxonomy.cdm.model.agent.Institution;
20
import eu.etaxonomy.cdm.model.agent.ORCID;
20 21
import eu.etaxonomy.cdm.model.agent.Person;
21 22
import eu.etaxonomy.cdm.model.agent.Team;
22 23
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
......
241 242

  
242 243
	}
243 244

  
244

  
245
	/**
246
	 * @param cdmBases
247
	 */
248 245
	private void createAgents(List<CdmBase> cdmBases) {
249 246
		//Person
250 247
		Person person = Person.NewTitledInstance("Person Title");
......
253 250
		person.setLifespan(TimePeriodParser.parseString("1905-1995"));
254 251
		person.setPrefix("prefix");
255 252
		person.setSuffix("suffix");
253
		person.setOrcid(ORCID.fromString("0000-0001-5000-0007"));
256 254

  
257 255
		handleIdentifiableEntity(person);
258 256

  
......
299 297
		cdmBases.add(institution);
300 298
	}
301 299

  
302

  
303 300
	private void createDescriptions(List<CdmBase> cdmBases) {
304 301

  
305 302
		TermVocabulary<AnnotationType> voc = TermVocabulary.NewInstance(TermType.AnnotationType, AnnotationType.class,
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/CdmUpdater.java
17 17
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
18 18
import eu.etaxonomy.cdm.database.CdmDataSource;
19 19
import eu.etaxonomy.cdm.database.ICdmDataSource;
20
import eu.etaxonomy.cdm.database.update.v58_511.SchemaUpdater_582_511;
20
import eu.etaxonomy.cdm.database.update.v58_511.SchemaUpdater_511_5111;
21 21
import eu.etaxonomy.cdm.model.metadata.CdmMetaData;
22 22

  
23 23
/**
......
73 73
     * @return
74 74
     */
75 75
    private ISchemaUpdater getCurrentSchemaUpdater() {
76
        return SchemaUpdater_582_511.NewInstance();
76
        return SchemaUpdater_511_5111.NewInstance();
77 77
    }
78 78

  
79 79
    /**
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v58_511/SchemaUpdater_511_5111.java
1
/**
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9

  
10
package eu.etaxonomy.cdm.database.update.v58_511;
11

  
12
import java.util.ArrayList;
13
import java.util.List;
14

  
15
import org.apache.log4j.Logger;
16

  
17
import eu.etaxonomy.cdm.database.update.ColumnAdder;
18
import eu.etaxonomy.cdm.database.update.ISchemaUpdater;
19
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep;
20
import eu.etaxonomy.cdm.database.update.SchemaUpdaterBase;
21

  
22
/**
23
 * @author a.mueller
24
 * @date 01.11.2019
25
 */
26
public class SchemaUpdater_511_5111 extends SchemaUpdaterBase {
27

  
28
	@SuppressWarnings("unused")
29
	private static final Logger logger = Logger.getLogger(SchemaUpdater_511_5111.class);
30

  
31
	private static final String startSchemaVersion = "5.11.0.0.20191104";
32
	private static final String endSchemaVersion = "5.11.1.0.20191108";
33

  
34
// ********************** FACTORY METHOD *************************************
35

  
36
	public static SchemaUpdater_511_5111 NewInstance() {
37
		return new SchemaUpdater_511_5111();
38
	}
39

  
40
	protected SchemaUpdater_511_5111() {
41
		super(startSchemaVersion, endSchemaVersion);
42
	}
43

  
44
	@Override
45
	protected List<ISchemaUpdaterStep> getUpdaterList() {
46

  
47
		String stepName;
48
		String tableName;
49
		String newColumnName;
50

  
51
		List<ISchemaUpdaterStep> stepList = new ArrayList<>();
52

  
53
        //#8628 Add ORCID to person class
54
        stepName = "Add ORCID to person class";
55
        tableName = "AgentBase";
56
        newColumnName ="orcid";
57
        int length = 16;
58
        ColumnAdder.NewStringInstance(stepList, stepName, tableName, newColumnName, length, INCLUDE_AUDIT);
59

  
60
        return stepList;
61
    }
62

  
63
    @Override
64
	public ISchemaUpdater getNextUpdater() {
65
		return null;
66
	}
67

  
68
	@Override
69
	public ISchemaUpdater getPreviousUpdater() {
70
		return SchemaUpdater_582_511.NewInstance();
71
	}
72
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v58_511/SchemaUpdater_582_511.java
106 106

  
107 107
    @Override
108 108
	public ISchemaUpdater getNextUpdater() {
109
		return null;
109
		return SchemaUpdater_511_5111.NewInstance();
110 110
	}
111 111

  
112 112
	@Override
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/function/TestModelUpdate.java
46 46

  
47 47
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
48 48

  
49
		String database = (schema == DbSchemaValidation.VALIDATE  ? "cdm58" : "cdm511");
49
		String database = (schema == DbSchemaValidation.VALIDATE  ? "cdm511" : "cdm52");
50 50

  
51 51
		CdmDataSource dataSource = getDatasource(dbType, database);
52 52
 		try {
......
74 74

  
75 75
    		if (schema == DbSchemaValidation.CREATE){
76 76
    		    System.out.println("fillData");
77
//    		    appCtr.getCommonService().createFullSampleData();
77
    		    appCtr.getCommonService().createFullSampleData();
78 78
    		    appCtr.getNameService().list(null, null, null, null, null);
79 79
    		}
80 80

  
......
206 206

  
207 207
	private void test(){
208 208
		System.out.println("Start TestModelUpdate");
209
		testSelectedDb();
209
//		testSelectedDb();
210 210

  
211 211
//		updateRemoteWebappTestH2();
212
//		updateAllTestH2();
213
//      updateEdaphobasePostgres();
212
		updateAllTestH2();
213
//		updateEdaphobasePostgres();
214 214

  
215 215
		System.out.println("\nEnd Datasource");
216 216
	}
cdmlib-test/src/main/resources/dbscripts/001-cdm.h2.sql
75 75
    LIFESPAN_START VARCHAR(255),
76 76
    PREFIX VARCHAR(255),
77 77
    SUFFIX VARCHAR(255),
78
	ORCID VARCHAR(16),
78 79
	HASMOREMEMBERS BOOLEAN,
79 80
    CREATEDBY_ID INTEGER,
80 81
    UPDATEDBY_ID INTEGER,
......
110 111
    PREFIX VARCHAR(255),
111 112
    SUFFIX VARCHAR(255),
112 113
    CODE VARCHAR(255),
113
    NAME VARCHAR(255),	
114
    NAME VARCHAR(255),
115
	ORCID VARCHAR(16),
114 116
	HASMOREMEMBERS BOOLEAN,
115 117
    CREATEDBY_ID INTEGER,
116 118
    UPDATEDBY_ID INTEGER,
cdmlib-test/src/main/resources/eu/etaxonomy/cdm/database/schema/dataset.dtd
393 393
    LIFESPAN_START CDATA #IMPLIED
394 394
    PREFIX CDATA #IMPLIED
395 395
    SUFFIX CDATA #IMPLIED
396
    ORCID CDATA #IMPLIED
396 397
    PROTECTEDNOMENCLATURALTITLECACHE CDATA #IMPLIED
397 398
    CREATEDBY_ID CDATA #IMPLIED
398 399
    UPDATEDBY_ID CDATA #IMPLIED
......
453 454
    LIFESPAN_START CDATA #IMPLIED
454 455
    PREFIX CDATA #IMPLIED
455 456
    SUFFIX CDATA #IMPLIED
457
    ORCID CDATA #IMPLIED
456 458
    CONTACT_ID CDATA #IMPLIED
457 459
    CODE CDATA #IMPLIED
458 460
    NAME CDATA #IMPLIED

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)