Moved the isPriv property from CkanDataset to CkanDatasetBase to be
marshalled/unmarshalled
This commit is contained in:
parent
7bb20c9644
commit
2633d8bdac
14
.classpath
14
.classpath
|
@ -6,13 +6,6 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="test" value="true"/>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="test" value="true"/>
|
<attribute name="test" value="true"/>
|
||||||
|
@ -31,5 +24,12 @@
|
||||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
4
.project
4
.project
|
@ -16,12 +16,12 @@
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [v1.0.2-SNAPSHOT] - 2021-06-03
|
||||||
|
|
||||||
|
**Fixes**
|
||||||
|
[#21560] Bug fixing property "visibility" Restricted/Public
|
||||||
|
|
||||||
## [v1.0.1] - 2021-05-11
|
## [v1.0.1] - 2021-05-11
|
||||||
|
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.datacatalogue</groupId>
|
<groupId>org.gcube.datacatalogue</groupId>
|
||||||
<artifactId>catalogue-util-library</artifactId>
|
<artifactId>catalogue-util-library</artifactId>
|
||||||
<version>1.0.1</version>
|
<version>1.0.2-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>Ckan utility library</name>
|
<name>Ckan utility library</name>
|
||||||
<description>
|
<description>
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>maven-portal-bom</artifactId>
|
<artifactId>maven-portal-bom</artifactId>
|
||||||
<version>3.6.2</version>
|
<version>3.6.2-SNAPSHOT</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -998,35 +998,15 @@ public class DataCatalogueImpl implements DataCatalogue {
|
||||||
|
|
||||||
String toPassOrganizationToGcat = null; //Not needed to pass this information to gCat, never.
|
String toPassOrganizationToGcat = null; //Not needed to pass this information to gCat, never.
|
||||||
// String ckanUsername = getUserFromApiKey(apiKey).getName();
|
// String ckanUsername = getUserFromApiKey(apiKey).getName();
|
||||||
|
LOG.debug("The visibility parameter passed is (isPublic): "+setPublic);
|
||||||
CkanDataset dataset = CKANConveter.toCkanDataset(ckanCaller, username, title, name, toPassOrganizationToGcat, author, authorMail,
|
CkanDataset dataset = CKANConveter.toCkanDataset(ckanCaller, username, title, name, toPassOrganizationToGcat, author, authorMail,
|
||||||
maintainer, maintainerMail, version, description, licenseId, tags, null, customFieldsMultiple,
|
maintainer, maintainerMail, version, description, licenseId, tags, null, customFieldsMultiple,
|
||||||
resources, setPublic, setSearchable);
|
resources, setPublic, setSearchable);
|
||||||
|
|
||||||
|
LOG.debug("The visibility into dataset is: "+dataset.isPriv());
|
||||||
// trying to create by gCat
|
// trying to create by gCat
|
||||||
String jsonValueDataset = MarshUnmarshCkanObject.toJsonValueDataset(dataset,METHOD.TO_CREATE);
|
String jsonValueDataset = MarshUnmarshCkanObject.toJsonValueDataset(dataset,METHOD.TO_CREATE);
|
||||||
LOG.info("Serialized dataset is: " + jsonValueDataset);
|
LOG.info("Serialized dataset is: " + jsonValueDataset);
|
||||||
/*JSONObject jsonDataset = null;
|
|
||||||
try {
|
|
||||||
JSONParser parser = new JSONParser();
|
|
||||||
jsonDataset = (JSONObject) parser.parse(jsonValueDataset);
|
|
||||||
|
|
||||||
// Object jsonSpatial = jsonDataset.get("spatial");
|
|
||||||
// if (jsonSpatial != null) {
|
|
||||||
// ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
// objectMapper.configure(Feature.QUOTE_FIELD_NAMES, false);
|
|
||||||
// String spatialUnquoted = objectMapper.writeValueAsString(jsonSpatial);
|
|
||||||
// System.out.println(spatialUnquoted);
|
|
||||||
// jsonDataset.put("spatial", spatialUnquoted);
|
|
||||||
// }
|
|
||||||
|
|
||||||
}catch (Exception e) {
|
|
||||||
LOG.error("Serialized dataset not parsable as JSON: ", e);
|
|
||||||
throw new Exception("Error on reading data, refresh and try again");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(jsonDataset==null)
|
|
||||||
throw new Exception("Error on converting data");*/
|
|
||||||
|
|
||||||
jsonValueDataset = gCatCaller.createDataset(jsonValueDataset,socialPost);
|
jsonValueDataset = gCatCaller.createDataset(jsonValueDataset,socialPost);
|
||||||
LOG.debug("Created dataset is: " + jsonValueDataset);
|
LOG.debug("Created dataset is: " + jsonValueDataset);
|
||||||
|
|
||||||
|
|
|
@ -61,10 +61,7 @@ public class CKANConveter {
|
||||||
Map<String, List<String>> customFieldsMultipleValues, List<ResourceBean> resources, boolean setPublic, boolean setSearchable) {
|
Map<String, List<String>> customFieldsMultipleValues, List<ResourceBean> resources, boolean setPublic, boolean setSearchable) {
|
||||||
|
|
||||||
LOG.info("Called convert data to CkanDataset");
|
LOG.info("Called convert data to CkanDataset");
|
||||||
|
|
||||||
//ExtendCkanClient client = new ExtendCkanClient(CKAN_CATALOGUE_URL, apiKey);
|
|
||||||
|
|
||||||
//String ckanUsername = getUserFromApiKey(apiKey).getName();
|
|
||||||
CkanDataset dataset = new CkanDataset();
|
CkanDataset dataset = new CkanDataset();
|
||||||
|
|
||||||
// in order to avoid errors, the username is always converted
|
// in order to avoid errors, the username is always converted
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package org.gcube.datacatalogue.utillibrary.server.utils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.gcube.com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import org.gcube.com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
|
import org.gcube.com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
|
||||||
|
// TODO: Auto-generated Javadoc
|
||||||
|
/**
|
||||||
|
* The Class SwitchBoolDeserializer.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Jun 3, 2021
|
||||||
|
*/
|
||||||
|
public class SwitchBoolDeserializer extends JsonDeserializer<Object> {
|
||||||
|
|
||||||
|
private final static Set<String> trueStateSet = new HashSet<>(Arrays.asList("yes", "true"));
|
||||||
|
|
||||||
|
private final static Set<String> falseStateSet = new HashSet<>(Arrays.asList("no", "false"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deserialize.
|
||||||
|
*
|
||||||
|
* @param jsonParser the json parser
|
||||||
|
* @param deserializationContext the deserialization context
|
||||||
|
* @return the object
|
||||||
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
|
* @throws JsonProcessingException the json processing exception
|
||||||
|
*/
|
||||||
|
public Object deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
|
||||||
|
throws IOException, JsonProcessingException {
|
||||||
|
String str = jsonParser.getText();
|
||||||
|
if (str == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
str = str.toLowerCase();
|
||||||
|
if (trueStateSet.contains(str)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (falseStateSet.contains(str)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package org.gcube.datacatalogue.utillibrary.server.utils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.gcube.com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import org.gcube.com.fasterxml.jackson.databind.JsonSerializer;
|
||||||
|
import org.gcube.com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class SwitchBoolSerializer.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Jun 3, 2021
|
||||||
|
*/
|
||||||
|
public class SwitchBoolSerializer extends JsonSerializer<Object> {
|
||||||
|
|
||||||
|
private final static String UNIFIED_TRUE_STRING = "true";
|
||||||
|
|
||||||
|
private final static String UNIFIED_FALSE_STRING = "false";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialize.
|
||||||
|
*
|
||||||
|
* @param o the o
|
||||||
|
* @param jsonGenerator the json generator
|
||||||
|
* @param serializerProvider the serializer provider
|
||||||
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
|
*/
|
||||||
|
public void serialize(Object o, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
|
||||||
|
throws IOException {
|
||||||
|
Boolean b = (Boolean) o;
|
||||||
|
jsonGenerator.writeString(b ? UNIFIED_TRUE_STRING : UNIFIED_FALSE_STRING);
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,221 +21,233 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends {@link CkanDatasetBase} with fields found in search operations.
|
* Extends {@link CkanDatasetBase} with fields found in search operations.
|
||||||
*/
|
*/
|
||||||
public class CkanDataset extends CkanDatasetBase {
|
public class CkanDataset extends CkanDatasetBase {
|
||||||
|
|
||||||
private String creatorUserId;
|
private String creatorUserId;
|
||||||
private String licenseUrl;
|
private String licenseUrl;
|
||||||
private String licenseTitle;
|
private String licenseTitle;
|
||||||
private Timestamp metadataCreated;
|
private Timestamp metadataCreated;
|
||||||
private Timestamp metadataModified;
|
private Timestamp metadataModified;
|
||||||
private int numResources;
|
private int numResources;
|
||||||
private CkanTrackingSummary trackingSummary;
|
private CkanTrackingSummary trackingSummary;
|
||||||
private int numTags;
|
private int numTags;
|
||||||
private String notesRendered;
|
private String notesRendered;
|
||||||
private Boolean open;
|
private Boolean open;
|
||||||
|
|
||||||
private CkanOrganization organization;
|
private CkanOrganization organization;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actually it is named 'private' in api. Appears in searches.
|
* Actually it is named 'private' in api. Appears in searches.
|
||||||
*/
|
*/
|
||||||
private Boolean priv;
|
// private Boolean priv;
|
||||||
private String revisionId;
|
private String revisionId;
|
||||||
private Timestamp revisionTimestamp;
|
private Timestamp revisionTimestamp;
|
||||||
|
|
||||||
public CkanDataset() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public CkanDataset() {
|
||||||
* @see CkanDatasetBase#CkanDatasetBase(String)
|
}
|
||||||
*/
|
|
||||||
public CkanDataset(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CkanDatasetBase#CkanDatasetBase(String)
|
||||||
public String getCreatorUserId() {
|
*/
|
||||||
return creatorUserId;
|
public CkanDataset(String name) {
|
||||||
}
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
public void setCreatorUserId(@Nullable String creatorUserId) {
|
public String getCreatorUserId() {
|
||||||
this.creatorUserId = creatorUserId;
|
return creatorUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setCreatorUserId(@Nullable String creatorUserId) {
|
||||||
* <a href="http://docs.ckan.org/en/latest/api/legacy-api.html?highlight=isopen" target="_blank">
|
this.creatorUserId = creatorUserId;
|
||||||
* Legacy api 1/2 docs</a> says: boolean indication of whether dataset is
|
}
|
||||||
* open according to Open Knowledge Definition, based on other fields
|
|
||||||
*/
|
|
||||||
@JsonProperty("isopen")
|
|
||||||
public Boolean isOpen() {
|
|
||||||
return open;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #isOpen()
|
* <a href="http://docs.ckan.org/en/latest/api/legacy-api.html?highlight=isopen"
|
||||||
*/
|
* target="_blank"> Legacy api 1/2 docs</a> says: boolean indication of whether
|
||||||
@JsonProperty("isopen")
|
* dataset is open according to Open Knowledge Definition, based on other fields
|
||||||
public void setOpen(Boolean isOpen) {
|
*/
|
||||||
this.open = isOpen;
|
@JsonProperty("isopen")
|
||||||
}
|
// @JsonSerialize(using = SwitchBoolSerializer.class)
|
||||||
|
// @JsonDeserialize(using = SwitchBoolDeserializer.class)
|
||||||
|
// @JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public Boolean isOpen() {
|
||||||
|
return open;
|
||||||
|
}
|
||||||
|
|
||||||
public String getLicenseTitle() {
|
/**
|
||||||
return licenseTitle;
|
* @see #isOpen()
|
||||||
}
|
*/
|
||||||
|
@JsonProperty("isopen")
|
||||||
|
public void setOpen(Boolean isOpen) {
|
||||||
|
this.open = isOpen;
|
||||||
|
}
|
||||||
|
|
||||||
public void setLicenseTitle(String licenseTitle) {
|
public String getLicenseTitle() {
|
||||||
this.licenseTitle = licenseTitle;
|
return licenseTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLicenseUrl() {
|
public void setLicenseTitle(String licenseTitle) {
|
||||||
return licenseUrl;
|
this.licenseTitle = licenseTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLicenseUrl(String licenseUrl) {
|
public String getLicenseUrl() {
|
||||||
this.licenseUrl = licenseUrl;
|
return licenseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setLicenseUrl(String licenseUrl) {
|
||||||
* CKAN always refer to UTC timezone
|
this.licenseUrl = licenseUrl;
|
||||||
*/
|
}
|
||||||
public Timestamp getMetadataCreated() {
|
|
||||||
return metadataCreated;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CKAN always refer to UTC timezone
|
* CKAN always refer to UTC timezone
|
||||||
*/
|
*/
|
||||||
public void setMetadataCreated(Timestamp metadataCreated) {
|
public Timestamp getMetadataCreated() {
|
||||||
this.metadataCreated = metadataCreated;
|
return metadataCreated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CKAN always refers to UTC timezone
|
* CKAN always refer to UTC timezone
|
||||||
*/
|
*/
|
||||||
public Timestamp getMetadataModified() {
|
public void setMetadataCreated(Timestamp metadataCreated) {
|
||||||
return metadataModified;
|
this.metadataCreated = metadataCreated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CKAN always refers to UTC timezone
|
* CKAN always refers to UTC timezone
|
||||||
*/
|
*/
|
||||||
public void setMetadataModified(Timestamp metadataModified) {
|
public Timestamp getMetadataModified() {
|
||||||
this.metadataModified = metadataModified;
|
return metadataModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNotesRendered() {
|
/**
|
||||||
return notesRendered;
|
* CKAN always refers to UTC timezone
|
||||||
}
|
*/
|
||||||
|
public void setMetadataModified(Timestamp metadataModified) {
|
||||||
|
this.metadataModified = metadataModified;
|
||||||
|
}
|
||||||
|
|
||||||
public void setNotesRendered(String notesRendered) {
|
public String getNotesRendered() {
|
||||||
this.notesRendered = notesRendered;
|
return notesRendered;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumTags() {
|
public void setNotesRendered(String notesRendered) {
|
||||||
return numTags;
|
this.notesRendered = notesRendered;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumTags(int numTags) {
|
public int getNumTags() {
|
||||||
this.numTags = numTags;
|
return numTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
public void setNumTags(int numTags) {
|
||||||
* The organization that owns the dataset.
|
this.numTags = numTags;
|
||||||
*
|
}
|
||||||
* Notice that if the dataset was obtained with a
|
|
||||||
* {@link eu.trentorise.opendata.jackan.CkanClient#getDataset(java.lang.String)} call, the returned
|
|
||||||
* organization won't have all the params you would get with a
|
|
||||||
* {@link eu.trentorise.opendata.jackan.CkanClient#getOrganization(java.lang.String)} call.
|
|
||||||
*/
|
|
||||||
public CkanOrganization getOrganization() {
|
|
||||||
return organization;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the organization that owns the dataset.
|
* The organization that owns the dataset.
|
||||||
*/
|
*
|
||||||
public void setOrganization(CkanOrganization organization) {
|
* Notice that if the dataset was obtained with a
|
||||||
this.organization = organization;
|
* {@link eu.trentorise.opendata.jackan.CkanClient#getDataset(java.lang.String)}
|
||||||
}
|
* call, the returned organization won't have all the params you would get with
|
||||||
|
* a
|
||||||
|
* {@link eu.trentorise.opendata.jackan.CkanClient#getOrganization(java.lang.String)}
|
||||||
|
* call.
|
||||||
|
*/
|
||||||
|
public CkanOrganization getOrganization() {
|
||||||
|
return organization;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actually it is named "private" in the CKAN API. Appears in dataset
|
* Sets the organization that owns the dataset.
|
||||||
* searches.
|
*/
|
||||||
*/
|
public void setOrganization(CkanOrganization organization) {
|
||||||
@JsonProperty("private")
|
this.organization = organization;
|
||||||
public Boolean isPriv() {
|
}
|
||||||
return priv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public int getNumResources() {
|
||||||
* Actually it is named "private" in the CKAN API. Appears in dataset
|
return numResources;
|
||||||
* searches.
|
}
|
||||||
*/
|
|
||||||
public void setPriv(Boolean priv) {
|
|
||||||
this.priv = priv;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNumResources() {
|
public void setNumResources(int numResources) {
|
||||||
return numResources;
|
this.numResources = numResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumResources(int numResources) {
|
/**
|
||||||
this.numResources = numResources;
|
* Returns the alphanumerical id, like "39d94b20-ea72-4c5e-bd8f-967a77e03946"
|
||||||
}
|
*/
|
||||||
|
public String getRevisionId() {
|
||||||
|
return revisionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the alphanumerical id, like "39d94b20-ea72-4c5e-bd8f-967a77e03946"
|
||||||
|
*/
|
||||||
/**
|
public void setRevisionId(String revisionId) {
|
||||||
* Returns the alphanumerical id, like
|
this.revisionId = revisionId;
|
||||||
* "39d94b20-ea72-4c5e-bd8f-967a77e03946"
|
}
|
||||||
*/
|
|
||||||
public String getRevisionId() {
|
|
||||||
return revisionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the alphanumerical id, like "39d94b20-ea72-4c5e-bd8f-967a77e03946"
|
* Returns date in UTC timezone. Probably it is automatically calculated by
|
||||||
*/
|
* CKAN.
|
||||||
public void setRevisionId(String revisionId) {
|
*/
|
||||||
this.revisionId = revisionId;
|
public Timestamp getRevisionTimestamp() {
|
||||||
}
|
return revisionTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns date in UTC timezone. Probably it is automatically calculated by
|
* CKAN always refer to UTC timezone. Probably it is automatically calculated by
|
||||||
* CKAN.
|
* CKAN.
|
||||||
*/
|
*
|
||||||
public Timestamp getRevisionTimestamp() {
|
* @param revisionTimestamp
|
||||||
return revisionTimestamp;
|
*/
|
||||||
}
|
public void setRevisionTimestamp(Timestamp revisionTimestamp) {
|
||||||
|
this.revisionTimestamp = revisionTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public CkanTrackingSummary getTrackingSummary() {
|
||||||
* CKAN always refer to UTC timezone. Probably it is automatically
|
return trackingSummary;
|
||||||
* calculated by CKAN.
|
}
|
||||||
*
|
|
||||||
* @param revisionTimestamp
|
|
||||||
*/
|
|
||||||
public void setRevisionTimestamp(Timestamp revisionTimestamp) {
|
|
||||||
this.revisionTimestamp = revisionTimestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CkanTrackingSummary getTrackingSummary() {
|
public void setTrackingSummary(CkanTrackingSummary trackingSummary) {
|
||||||
return trackingSummary;
|
this.trackingSummary = trackingSummary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("CkanDataset [creatorUserId=");
|
||||||
|
builder.append(creatorUserId);
|
||||||
|
builder.append(", licenseUrl=");
|
||||||
|
builder.append(licenseUrl);
|
||||||
|
builder.append(", licenseTitle=");
|
||||||
|
builder.append(licenseTitle);
|
||||||
|
builder.append(", metadataCreated=");
|
||||||
|
builder.append(metadataCreated);
|
||||||
|
builder.append(", metadataModified=");
|
||||||
|
builder.append(metadataModified);
|
||||||
|
builder.append(", numResources=");
|
||||||
|
builder.append(numResources);
|
||||||
|
builder.append(", trackingSummary=");
|
||||||
|
builder.append(trackingSummary);
|
||||||
|
builder.append(", numTags=");
|
||||||
|
builder.append(numTags);
|
||||||
|
builder.append(", notesRendered=");
|
||||||
|
builder.append(notesRendered);
|
||||||
|
builder.append(", open=");
|
||||||
|
builder.append(open);
|
||||||
|
builder.append(", organization=");
|
||||||
|
builder.append(organization);
|
||||||
|
builder.append(", revisionId=");
|
||||||
|
builder.append(revisionId);
|
||||||
|
builder.append(", revisionTimestamp=");
|
||||||
|
builder.append(revisionTimestamp);
|
||||||
|
builder.append(", toString()=");
|
||||||
|
builder.append(super.toString());
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public void setTrackingSummary(CkanTrackingSummary trackingSummary) {
|
|
||||||
this.trackingSummary = trackingSummary;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import javax.annotation.Nullable;
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonAnyGetter;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonAnySetter;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,6 +71,8 @@ public class CkanDatasetBase {
|
||||||
private String type;
|
private String type;
|
||||||
private String url;
|
private String url;
|
||||||
private String version;
|
private String version;
|
||||||
|
|
||||||
|
private Boolean priv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom CKAN instances might sometimes gift us with properties that don't
|
* Custom CKAN instances might sometimes gift us with properties that don't
|
||||||
|
@ -466,5 +469,75 @@ public class CkanDatasetBase {
|
||||||
|
|
||||||
return isNotEmpty(getName()) ? getName() : getId();
|
return isNotEmpty(getName()) ? getName() : getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actually it is named "private" in the CKAN API. Appears in dataset
|
||||||
|
* searches.
|
||||||
|
*/
|
||||||
|
@JsonProperty("private")
|
||||||
|
public Boolean isPriv() {
|
||||||
|
return priv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actually it is named "private" in the CKAN API. Appears in dataset
|
||||||
|
* searches.
|
||||||
|
*/
|
||||||
|
public void setPriv(Boolean priv) {
|
||||||
|
this.priv = priv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("CkanDatasetBase [author=");
|
||||||
|
builder.append(author);
|
||||||
|
builder.append(", authorEmail=");
|
||||||
|
builder.append(authorEmail);
|
||||||
|
builder.append(", extras=");
|
||||||
|
builder.append(extras);
|
||||||
|
builder.append(", groups=");
|
||||||
|
builder.append(groups);
|
||||||
|
builder.append(", id=");
|
||||||
|
builder.append(id);
|
||||||
|
builder.append(", licenseId=");
|
||||||
|
builder.append(licenseId);
|
||||||
|
builder.append(", maintainer=");
|
||||||
|
builder.append(maintainer);
|
||||||
|
builder.append(", maintainerEmail=");
|
||||||
|
builder.append(maintainerEmail);
|
||||||
|
builder.append(", name=");
|
||||||
|
builder.append(name);
|
||||||
|
builder.append(", notes=");
|
||||||
|
builder.append(notes);
|
||||||
|
builder.append(", ownerOrg=");
|
||||||
|
builder.append(ownerOrg);
|
||||||
|
builder.append(", relationshipsAsObject=");
|
||||||
|
builder.append(relationshipsAsObject);
|
||||||
|
builder.append(", relationshipsAsSubject=");
|
||||||
|
builder.append(relationshipsAsSubject);
|
||||||
|
builder.append(", resources=");
|
||||||
|
builder.append(resources);
|
||||||
|
builder.append(", state=");
|
||||||
|
builder.append(state);
|
||||||
|
builder.append(", tags=");
|
||||||
|
builder.append(tags);
|
||||||
|
builder.append(", title=");
|
||||||
|
builder.append(title);
|
||||||
|
builder.append(", type=");
|
||||||
|
builder.append(type);
|
||||||
|
builder.append(", url=");
|
||||||
|
builder.append(url);
|
||||||
|
builder.append(", version=");
|
||||||
|
builder.append(version);
|
||||||
|
builder.append(", priv=");
|
||||||
|
builder.append(priv);
|
||||||
|
builder.append(", others=");
|
||||||
|
builder.append(others);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,6 +10,8 @@ import java.util.Random;
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.datacatalogue.utillibrary.ckan.MarshUnmarshCkanObject;
|
||||||
|
import org.gcube.datacatalogue.utillibrary.ckan.MarshUnmarshCkanObject.METHOD;
|
||||||
import org.gcube.datacatalogue.utillibrary.server.ApplicationProfileScopePerUrlReader;
|
import org.gcube.datacatalogue.utillibrary.server.ApplicationProfileScopePerUrlReader;
|
||||||
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueFactory;
|
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueFactory;
|
||||||
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueImpl;
|
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueImpl;
|
||||||
|
@ -33,8 +35,8 @@ public class TestDataCatalogueLib {
|
||||||
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(TestDataCatalogueLib.class);
|
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(TestDataCatalogueLib.class);
|
||||||
|
|
||||||
private DataCatalogueFactory factory;
|
private DataCatalogueFactory factory;
|
||||||
//private String scope = "/gcube/devsec/devVRE";
|
private String scope = "/gcube/devsec/devVRE";
|
||||||
private String scope = "/gcube";
|
//private String scope = "/gcube";
|
||||||
//private String scope = "/pred4s/preprod/preVRE";
|
//private String scope = "/pred4s/preprod/preVRE";
|
||||||
//private String scope = "/d4science.research-infrastructures.eu/SoBigData/Catalogue-TerritoriAperti";
|
//private String scope = "/d4science.research-infrastructures.eu/SoBigData/Catalogue-TerritoriAperti";
|
||||||
//private String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab";
|
//private String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab";
|
||||||
|
@ -257,7 +259,7 @@ public class TestDataCatalogueLib {
|
||||||
customFieldsMultiple.put("system:type", Arrays.asList("EmptyProfile"));
|
customFieldsMultiple.put("system:type", Arrays.asList("EmptyProfile"));
|
||||||
|
|
||||||
boolean setSearchable = true;
|
boolean setSearchable = true;
|
||||||
boolean setPublic = false;
|
boolean setPublic = true;
|
||||||
List<ResourceBean> resources = null;
|
List<ResourceBean> resources = null;
|
||||||
|
|
||||||
String orgName = scope.split("/")[3].toLowerCase();
|
String orgName = scope.split("/")[3].toLowerCase();
|
||||||
|
@ -359,5 +361,17 @@ public class TestDataCatalogueLib {
|
||||||
String url = instance.getUnencryptedUrlFromDatasetIdOrName(datasetName);
|
String url = instance.getUnencryptedUrlFromDatasetIdOrName(datasetName);
|
||||||
LOG.debug("url is " + url);
|
LOG.debug("url is " + url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@Test
|
||||||
|
public void marshallingDataset() throws Exception{
|
||||||
|
DataCatalogueImpl instance = factory.getUtilsPerScope(scope);
|
||||||
|
String username = testUser;
|
||||||
|
CkanDataset dataset = instance.getDataset("sarda-sarda", username);
|
||||||
|
LOG.debug("Got dataset: " +dataset.getName() + ", with id: "+dataset.getId() +" is private: "+dataset.isPriv());
|
||||||
|
String jsonValueDataset = MarshUnmarshCkanObject.toJsonValueDataset(dataset,METHOD.TO_CREATE);
|
||||||
|
System.out.println(jsonValueDataset);
|
||||||
|
dataset = MarshUnmarshCkanObject.toCkanDataset(jsonValueDataset, METHOD.TO_READ);
|
||||||
|
System.out.println(dataset);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue