2017-02-01 15:47:11 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2018-11-15 12:18:03 +01:00
|
|
|
package org.gcube.datatransfer.resolver.catalogue;
|
2017-02-01 15:47:11 +01:00
|
|
|
|
2023-03-23 15:54:00 +01:00
|
|
|
import java.util.Arrays;
|
2017-02-01 15:47:11 +01:00
|
|
|
import java.util.List;
|
2023-03-23 15:54:00 +01:00
|
|
|
import java.util.stream.Collectors;
|
2017-02-01 15:47:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The Enum ResourceCatalogueCodes.
|
|
|
|
*
|
2023-03-23 15:54:00 +01:00
|
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jan 31, 2017
|
2017-02-01 15:47:11 +01:00
|
|
|
*
|
2023-03-23 15:54:00 +01:00
|
|
|
* see wiki page:
|
|
|
|
* https://wiki.gcube-system.org/gcube/URI_Resolver#CATALOGUE_Resolver
|
2017-02-01 15:47:11 +01:00
|
|
|
*/
|
|
|
|
public enum ResourceCatalogueCodes {
|
|
|
|
|
2023-03-23 15:54:00 +01:00
|
|
|
CTLG("ctlg", "dataset", "Catalogue Product/Dataset"),
|
|
|
|
// CTLGP("ctlg-p","product", "Catalogue Product"),
|
|
|
|
CTLGD("ctlg-d", "dataset", "Catalogue Dataset"), CTLGO("ctlg-o", "organization", "Catalogue Organization"),
|
|
|
|
CTLGG("ctlg-g", "group", "Catalogue Group");
|
2017-02-01 15:47:11 +01:00
|
|
|
|
2023-03-23 15:54:00 +01:00
|
|
|
private String id; // the code id
|
|
|
|
private String value; // the code value
|
2017-02-01 15:47:11 +01:00
|
|
|
private String description;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new resource catalogue codes.
|
|
|
|
*
|
2023-03-23 15:54:00 +01:00
|
|
|
* @param id the id
|
|
|
|
* @param value the value
|
2017-02-01 15:47:11 +01:00
|
|
|
* @param description the description
|
|
|
|
*/
|
|
|
|
private ResourceCatalogueCodes(String id, String value, String description) {
|
|
|
|
this.id = id;
|
|
|
|
this.value = value;
|
|
|
|
this.description = description;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the id.
|
|
|
|
*
|
|
|
|
* @return the id
|
|
|
|
*/
|
|
|
|
public String getId() {
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the value.
|
|
|
|
*
|
|
|
|
* @return the value
|
|
|
|
*/
|
|
|
|
public String getValue() {
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the description.
|
|
|
|
*
|
|
|
|
* @return the description
|
|
|
|
*/
|
|
|
|
public String getDescription() {
|
|
|
|
|
|
|
|
return description;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Codes.
|
|
|
|
*
|
|
|
|
* @return the list
|
|
|
|
*/
|
2023-03-23 15:54:00 +01:00
|
|
|
public static List<String> codes() {
|
2017-02-01 15:47:11 +01:00
|
|
|
|
2023-03-23 15:54:00 +01:00
|
|
|
return Arrays.asList(ResourceCatalogueCodes.values()).stream().map(ResourceCatalogueCodes::getId)
|
|
|
|
.collect(Collectors.toList());
|
2017-02-01 15:47:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Value of code id.
|
|
|
|
*
|
|
|
|
* @param id the id
|
|
|
|
* @return the resource catalogue codes
|
|
|
|
*/
|
2023-03-23 15:54:00 +01:00
|
|
|
public static ResourceCatalogueCodes valueOfCodeId(String id) {
|
|
|
|
if (id == null || id.isEmpty())
|
2017-02-01 15:47:11 +01:00
|
|
|
return null;
|
|
|
|
|
2023-03-23 15:54:00 +01:00
|
|
|
List<ResourceCatalogueCodes> codes = Arrays.asList(ResourceCatalogueCodes.values()).stream()
|
|
|
|
.filter(r -> r.getId().compareTo(id) == 0)
|
|
|
|
.collect(Collectors.toList());
|
2017-02-01 15:47:11 +01:00
|
|
|
|
2023-03-23 15:54:00 +01:00
|
|
|
if (codes == null || codes.isEmpty())
|
|
|
|
return null;
|
|
|
|
|
|
|
|
return codes.get(0);
|
|
|
|
|
|
|
|
}
|
2017-02-01 15:47:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Value of code value.
|
|
|
|
*
|
|
|
|
* @param codeValue the code value
|
|
|
|
* @return the resource catalogue codes
|
|
|
|
*/
|
2023-03-23 15:54:00 +01:00
|
|
|
public static ResourceCatalogueCodes valueOfCodeValue(String codeValue) {
|
|
|
|
if (codeValue == null || codeValue.isEmpty())
|
|
|
|
return null;
|
|
|
|
|
|
|
|
List<ResourceCatalogueCodes> codes = Arrays.asList(ResourceCatalogueCodes.values()).stream()
|
|
|
|
.filter(r -> r.getValue().compareTo(codeValue) == 0)
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
if (codes == null || codes.isEmpty())
|
2017-02-01 15:47:11 +01:00
|
|
|
return null;
|
|
|
|
|
2023-03-23 15:54:00 +01:00
|
|
|
return codes.get(0);
|
2017-02-01 15:47:11 +01:00
|
|
|
}
|
|
|
|
}
|