Project

General

Profile

1 51706 alessia.ba
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 51816 alessia.ba
	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"),
17
	GPL2("GPL-2.0"), GPL3("GPL-3.0"), LGPL2_1("LGPL-2.1"), LGPL3("LGPL-3.0"),
18 51706 alessia.ba
	EUDataGrid("EUDatagrid"), EUPL1_1("EUPL-1.1"), Fair("Fair"), MIT("MIT"), MozillaPublic("MPL-1.1");
19
20
21
	private String id;
22
23
	public String getId() {
24
		return id;
25
	}
26
27
	 CatalogueLicense(String id) {
28
		this.id = id;
29
	}
30
31
	public static CatalogueLicense getCatalogueLicenseFor(final String license){
32
		//TODO: get the best from the data we have, if we are able to clean the string, this method wil be much simpler...
33 55561 alessia.ba
		//TODO: not specified is not a valid value for the new gcat API and requesting the list of licensing fails, ask Luca.
34 51706 alessia.ba
		if(StringUtils.isBlank(license)) return NotSpecified;
35 55482 alessia.ba
		if(license.equalsIgnoreCase("CC") || license.equalsIgnoreCase("Free/ CC") || license.equalsIgnoreCase("Creative Commons CC0 1.0 Universal Public Domain Dedication")) return CC0;
36 51816 alessia.ba
		if(license.equalsIgnoreCase("CC-BY") || license.equalsIgnoreCase("CC BY")) return CCBY;
37
		if(license.equalsIgnoreCase("CC-BY-SA") || license.equalsIgnoreCase("Attribute-share-alike (CC-BY-SA) license") || license.equalsIgnoreCase("CC BY-SA")) return CCBYSA;
38
		if(license.equalsIgnoreCase("CC-BY-SA-NC") || license.equalsIgnoreCase("Creative Commons BY-NC-SA")) return CCBYNCSA;
39
		if(license.equalsIgnoreCase("Open Access") || license.equalsIgnoreCase("OpenSource")) return OtherOpen;
40
		if(license.equalsIgnoreCase("MIT") || license.equalsIgnoreCase("MIT LICENSE")) return MIT;
41
		if(license.equalsIgnoreCase("APACHE 2.0")|| license.equalsIgnoreCase("Apache License 2.0") || license.equalsIgnoreCase("Apache License, Version 2.0")) return Apache2;
42
		if(license.equalsIgnoreCase("GNU GPL v2")) return GPL2;
43
		if(license.equalsIgnoreCase("GPLv3") || license.equalsIgnoreCase("GPL v3")) return GPL3;
44
		if(license.equalsIgnoreCase("LGPL V3") || license.equalsIgnoreCase("LGPL V3.0")) return LGPL3;
45 51706 alessia.ba
		else return NotSpecified;
46
	}
47
48
}
49
50
51
52
53
54