Added method getListExtrasAsHashMap - D4Science model compliant
This commit is contained in:
parent
c4629e78be
commit
3d9080ed81
|
@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
**Enhancements**
|
||||
|
||||
- Added method update item [#26640]
|
||||
- Added method getListExtrasAsHashMap - D4Science model compliant
|
||||
|
||||
## [v1.3.0] - 2023-02-06
|
||||
|
||||
|
|
|
@ -30,17 +30,15 @@ import org.gcube.com.fasterxml.jackson.annotation.JsonAnySetter;
|
|||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A Ckan Dataset, which in turn holds Ckan Resources.
|
||||
*
|
||||
* In Ckan terminology it is also known as 'package'.
|
||||
*
|
||||
* {@link CkanDatasetBase} holds fields that can be sent when
|
||||
* <a href="http://docs.ckan.org/en/latest/api/index.html?#ckan.logic.action.create.package_create" target="_blank">creating
|
||||
* a dataset,</a>, while {@link CkanDataset} holds more fields that can be
|
||||
* returned with searches.
|
||||
* {@link CkanDatasetBase} holds fields that can be sent when <a href=
|
||||
* "http://docs.ckan.org/en/latest/api/index.html?#ckan.logic.action.create.package_create"
|
||||
* target="_blank">creating a dataset,</a>, while {@link CkanDataset} holds more
|
||||
* fields that can be returned with searches.
|
||||
*
|
||||
* This class initializes nothing to fully preserve all we get from ckan. In
|
||||
* practice, all fields of retrieved resources can be null except maybe
|
||||
|
@ -75,8 +73,8 @@ public class CkanDatasetBase {
|
|||
private Boolean priv;
|
||||
|
||||
/**
|
||||
* Custom CKAN instances might sometimes gift us with properties that don't
|
||||
* end up in extras. They will end up here.
|
||||
* Custom CKAN instances might sometimes gift us with properties that don't end
|
||||
* up in extras. They will end up here.
|
||||
*/
|
||||
@Nullable
|
||||
private Map<String, Object> others;
|
||||
|
@ -97,12 +95,11 @@ public class CkanDatasetBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* CKAN instances might have
|
||||
* <a href="http://docs.ckan.org/en/latest/extensions/adding-custom-fields.html">
|
||||
* custom data schemas</a> that force presence of custom properties among
|
||||
* 'regular' ones. In this case, they go to 'others' field. Note that to
|
||||
* further complicate things there is also an {@link #getExtras() extras}
|
||||
* field.
|
||||
* CKAN instances might have <a href=
|
||||
* "http://docs.ckan.org/en/latest/extensions/adding-custom-fields.html"> custom
|
||||
* data schemas</a> that force presence of custom properties among 'regular'
|
||||
* ones. In this case, they go to 'others' field. Note that to further
|
||||
* complicate things there is also an {@link #getExtras() extras} field.
|
||||
*
|
||||
* @see #putOthers(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
|
@ -151,9 +148,10 @@ public class CkanDatasetBase {
|
|||
|
||||
/**
|
||||
* Notice that if the dataset was obtained with a
|
||||
* {@link eu.trentorise.opendata.jackan.CkanClient#getDataset(java.lang.String)} call, the returned group
|
||||
* won't have all the params you would get with a
|
||||
* {@link eu.trentorise.opendata.jackan.CkanClient#getGroup(java.lang.String)} call.
|
||||
* {@link eu.trentorise.opendata.jackan.CkanClient#getDataset(java.lang.String)}
|
||||
* call, the returned group won't have all the params you would get with a
|
||||
* {@link eu.trentorise.opendata.jackan.CkanClient#getGroup(java.lang.String)}
|
||||
* call.
|
||||
*/
|
||||
public List<CkanGroup> getGroups() {
|
||||
return groups;
|
||||
|
@ -178,9 +176,8 @@ public class CkanDatasetBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Regular place where to put custom metadata. See also
|
||||
* {@link #getOthers()}. Note also extras can be in CkanDataset but not in
|
||||
* CkanResource.
|
||||
* Regular place where to put custom metadata. See also {@link #getOthers()}.
|
||||
* Note also extras can be in CkanDataset but not in CkanResource.
|
||||
*/
|
||||
public List<CkanPair> getExtras() {
|
||||
return extras;
|
||||
|
@ -193,6 +190,7 @@ public class CkanDatasetBase {
|
|||
this.extras = extras;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Always returns a non-null map (which might be empty)
|
||||
*/
|
||||
|
@ -207,6 +205,30 @@ public class CkanDatasetBase {
|
|||
return hm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns a non-null map (which might be empty)
|
||||
*
|
||||
* updated by Francesco Mangiacrapa at ISTI-CNR
|
||||
*
|
||||
* The D4Science model accepts extra fields with multiple keys
|
||||
*/
|
||||
@JsonIgnore
|
||||
public Map<String, List<String>> getListExtrasAsHashMap() {
|
||||
HashMap<String, List<String>> hm = new HashMap<>();
|
||||
if (extras != null) {
|
||||
for (CkanPair cp : extras) {
|
||||
|
||||
List<String> list = hm.get(cp.getKey());
|
||||
if (list == null)
|
||||
list = new ArrayList<String>();
|
||||
|
||||
list.add(cp.getValue());
|
||||
hm.put(cp.getKey(), list);
|
||||
}
|
||||
}
|
||||
return hm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds CkanExtras
|
||||
*
|
||||
|
@ -222,8 +244,7 @@ public class CkanDatasetBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the alphanumerical id, i.e.
|
||||
* "c4577b8f-5603-4098-917e-da03e8ddf461"
|
||||
* Returns the alphanumerical id, i.e. "c4577b8f-5603-4098-917e-da03e8ddf461"
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
|
@ -275,8 +296,8 @@ public class CkanDatasetBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* The dataset name. Name must not contain spaces and have dashes as
|
||||
* separators, i.e. "limestone-pavement-orders"
|
||||
* The dataset name. Name must not contain spaces and have dashes as separators,
|
||||
* i.e. "limestone-pavement-orders"
|
||||
*
|
||||
*/
|
||||
public void setName(String name) {
|
||||
|
@ -284,18 +305,18 @@ public class CkanDatasetBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* A description of the dataset. See also
|
||||
* {@link CkanDataset#getNotesRendered()} Note CkanResource has instead a
|
||||
* field called {@link CkanResourceBase#getDescription() description}.
|
||||
* A description of the dataset. See also {@link CkanDataset#getNotesRendered()}
|
||||
* Note CkanResource has instead a field called
|
||||
* {@link CkanResourceBase#getDescription() description}.
|
||||
*/
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* A description of the dataset. See also
|
||||
* {@link CkanDataset#getNotesRendered()} Note CkanResource has instead a
|
||||
* field called {@link CkanResourceBase#getDescription() description}.
|
||||
* A description of the dataset. See also {@link CkanDataset#getNotesRendered()}
|
||||
* Note CkanResource has instead a field called
|
||||
* {@link CkanResourceBase#getDescription() description}.
|
||||
*/
|
||||
public void setNotes(String notes) {
|
||||
this.notes = notes;
|
||||
|
@ -358,8 +379,8 @@ public class CkanDatasetBase {
|
|||
/**
|
||||
* The current state of the dataset, e.g. 'active' or 'deleted', only active
|
||||
* datasets show up in search results and other lists of datasets, this
|
||||
* parameter will be ignored if you are not authorized to change the state
|
||||
* of the dataset (optional, default: 'active')
|
||||
* parameter will be ignored if you are not authorized to change the state of
|
||||
* the dataset (optional, default: 'active')
|
||||
*/
|
||||
public CkanState getState() {
|
||||
return state;
|
||||
|
@ -368,8 +389,8 @@ public class CkanDatasetBase {
|
|||
/**
|
||||
* The current state of the dataset, e.g. 'active' or 'deleted', only active
|
||||
* datasets show up in search results and other lists of datasets, this
|
||||
* parameter will be ignored if you are not authorized to change the state
|
||||
* of the dataset (optional, default: 'active')
|
||||
* parameter will be ignored if you are not authorized to change the state of
|
||||
* the dataset (optional, default: 'active')
|
||||
*/
|
||||
public void setState(CkanState state) {
|
||||
this.state = state;
|
||||
|
@ -412,34 +433,34 @@ public class CkanDatasetBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* The type of the dataset (optional), IDatasetForm plugins associate
|
||||
* themselves with different dataset types and provide custom dataset
|
||||
* handling behaviour for these types
|
||||
* The type of the dataset (optional), IDatasetForm plugins associate themselves
|
||||
* with different dataset types and provide custom dataset handling behaviour
|
||||
* for these types
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of the dataset (optional), IDatasetForm plugins associate
|
||||
* themselves with different dataset types and provide custom dataset
|
||||
* handling behaviour for these types
|
||||
* The type of the dataset (optional), IDatasetForm plugins associate themselves
|
||||
* with different dataset types and provide custom dataset handling behaviour
|
||||
* for these types
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be the landing page on original data provider website describing
|
||||
* the dataset.
|
||||
* Should be the landing page on original data provider website describing the
|
||||
* dataset.
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be the landing page on original data provider website describing
|
||||
* the dataset.
|
||||
* Should be the landing page on original data provider website describing the
|
||||
* dataset.
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
|
@ -471,8 +492,7 @@ public class CkanDatasetBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Actually it is named "private" in the CKAN API. Appears in dataset
|
||||
* searches.
|
||||
* Actually it is named "private" in the CKAN API. Appears in dataset searches.
|
||||
*/
|
||||
@JsonProperty("private")
|
||||
public Boolean isPriv() {
|
||||
|
@ -480,8 +500,7 @@ public class CkanDatasetBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Actually it is named "private" in the CKAN API. Appears in dataset
|
||||
* searches.
|
||||
* Actually it is named "private" in the CKAN API. Appears in dataset searches.
|
||||
*/
|
||||
public void setPriv(Boolean priv) {
|
||||
this.priv = priv;
|
||||
|
@ -538,6 +557,4 @@ public class CkanDatasetBase {
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue