Project

General

Profile

1
package eu.dnetlib.parthenos.catalogue;
2

    
3
import org.apache.commons.lang3.StringUtils;
4

    
5
/**
6
 * Created by Alessia Bardi on 06/04/2018.
7
 *
8
 * @author Alessia Bardi
9
 *
10
 * Enum with a subset of the licenses supported by the CKan catalogue. For the full list, see SERVICE_ENDPOINT/api/licenses/list/
11
 */
12
public enum CatalogueLicense {
13
	NotSpecified("notspecified"),
14
	OtherOpen("other-open"), OtherPublicDomain("other-pd"), OtherAttribution("other-at"), OtherNonCommercial("other-nc"),
15
	CC0("CC0-1.0"), CCBY("CC-BY-4.0"), CCBYSA("CC-BY-SA-4.0"), CCBYNC("CC-BY-NC-4.0"), CCBYND("CC-BY-ND-4.0"), CCBYNCSA("CC-BY-NC-SA-4.0"), CCBYNCND("CC-BY-NC-ND-4.0"),
16
	AFL("AFL-3.0"), APL("APL-1.0"), AGPL("AGPL-3.0"), Apache1_1("Apache-1.1"), Apache2("Apache-2.0"), APSL2("APSL-2.0"), GPL2("GPL-2.0"), GPL3("GPL-3.0"), LGPL2_1("LGPL-2.1"), LGPL3("LGPL-3.0"),
17
	EUDataGrid("EUDatagrid"), EUPL1_1("EUPL-1.1"), Fair("Fair"), MIT("MIT"), MozillaPublic("MPL-1.1");
18

    
19

    
20
	private String id;
21

    
22
	public String getId() {
23
		return id;
24
	}
25

    
26
	 CatalogueLicense(String id) {
27
		this.id = id;
28
	}
29

    
30
	public static CatalogueLicense getCatalogueLicenseFor(final String license){
31
		//TODO: get the best from the data we have, if we are able to clean the string, this method wil be much simpler...
32
		if(StringUtils.isBlank(license)) return NotSpecified;
33
		if(license.equalsIgnoreCase("CC") || license.equalsIgnoreCase("Free/ CC")) return CC0;
34
		if(license.equalsIgnoreCase("CC-BY")) return CCBY;
35
		if(license.equalsIgnoreCase("Open Access")) return OtherOpen;
36
		else return NotSpecified;
37
	}
38

    
39
}
40

    
41

    
42

    
43

    
44

    
45

    
46

    
(3-3/4)