Revision 51706
Added by Alessia Bardi about 6 years ago
modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/catalogue/CatalogueLicense.java | ||
---|---|---|
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 |
|
modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/catalogue/CatalogueRegistrator.java | ||
---|---|---|
314 | 314 |
//end of URI |
315 | 315 |
jg.writeStringField("name", resNameForCatalogue); |
316 | 316 |
//default license |
317 |
jg.writeStringField("license_id", "notspecified");
|
|
317 |
jg.writeStringField("license_id", resourceReader.getCatalogueLicense(res).getId());
|
|
318 | 318 |
String title = resourceReader.getTitle(res); |
319 | 319 |
if (StringUtils.isBlank(title)) |
320 | 320 |
title = resNameForCatalogue; |
modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/rdf/ResourceReader.java | ||
---|---|---|
8 | 8 |
import com.google.common.collect.Lists; |
9 | 9 |
import eu.dnetlib.parthenos.CRM; |
10 | 10 |
import eu.dnetlib.parthenos.CRMpe; |
11 |
import eu.dnetlib.parthenos.catalogue.CatalogueLicense; |
|
11 | 12 |
import org.apache.commons.logging.Log; |
12 | 13 |
import org.apache.commons.logging.LogFactory; |
13 | 14 |
import org.apache.jena.assembler.AssemblerHelp; |
... | ... | |
90 | 91 |
return ""; |
91 | 92 |
} |
92 | 93 |
|
94 |
public CatalogueLicense getCatalogueLicense(final Resource resource){ |
|
95 |
if(resource.hasProperty(CRM.P16_used_specific_object)) { |
|
96 |
Resource obj = resource.getPropertyResourceValue(CRM.P16_used_specific_object); |
|
97 |
if (obj.hasProperty(CRM.P2_has_type)) { |
|
98 |
String license = getLabel(obj.getPropertyResourceValue(CRM.P2_has_type)); |
|
99 |
return CatalogueLicense.getCatalogueLicenseFor(license); |
|
100 |
} |
|
101 |
} |
|
102 |
return CatalogueLicense.NotSpecified; |
|
103 |
} |
|
104 |
|
|
93 | 105 |
public Iterator<String> getRDFClassNames(final Resource resource){ |
94 | 106 |
StmtIterator it = resource.listProperties(RDF.type); |
95 | 107 |
return Iterators.transform(it, f -> f.getResource().getLocalName()); |
Also available in: Unified diff
Trying to map to ckan licenses