202 lines
4.9 KiB
Java
202 lines
4.9 KiB
Java
package org.gcube.common.software.model;
|
|
|
|
import java.net.URL;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
import org.gcube.com.fasterxml.jackson.annotation.JsonFormat;
|
|
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
|
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
|
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
|
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
|
import org.gcube.common.software.utils.Utils;
|
|
|
|
/**
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
*/
|
|
public class SoftwareVersionConfig extends SoftwareConfig {
|
|
|
|
public static final String NAME_PROPERTY_NAME = "name";
|
|
public static final String VERSION_PROPERTY_NAME = "version";
|
|
public static final String TITLE_PROPERTY_NAME = "title";
|
|
public static final String DATE_PROPERTY_NAME = "date";
|
|
public static final String LICENSE_PROPERTY_NAME = "license";
|
|
public static final String KEYWORDS_PROPERTY_NAME = "keywords";
|
|
public static final String DESCRIPTION_PROPERTY_NAME = "description";
|
|
public static final String AUTHORS_PROPERTY_NAME = "authors";
|
|
public static final String FILES_PROPERTY_NAME = "files";
|
|
public static final String CODE_LOCATION_PROPERTY_NAME = "code_location";
|
|
public static final String DOI_URL_PROPERTY_NAME = "doi_url";
|
|
public static final String VERSION_DOI_URL_PROPERTY_NAME = "version_doi_url";
|
|
public static final String GRANTS_PROPERTY_NAME = "grants";
|
|
public static final String PUBLISHERS_PROPERTY_NAME = "publishers";
|
|
public static final String EXPORTERS_PROPERTY_NAME = "exporters";
|
|
|
|
@JsonIgnore
|
|
protected SoftwareVersionConfig previous;
|
|
|
|
@JsonIgnore
|
|
protected SoftwareVersionConfig next;
|
|
|
|
@JsonIgnore
|
|
protected Boolean newDeposition;
|
|
|
|
@JsonProperty(NAME_PROPERTY_NAME)
|
|
protected String name;
|
|
|
|
@JsonProperty(VERSION_PROPERTY_NAME)
|
|
protected String version;
|
|
|
|
@JsonProperty(DATE_PROPERTY_NAME)
|
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Utils.DATETIME_PATTERN)
|
|
protected Date date;
|
|
|
|
@JsonProperty(TITLE_PROPERTY_NAME)
|
|
protected String title;
|
|
|
|
@JsonProperty(LICENSE_PROPERTY_NAME)
|
|
protected JsonNode license;
|
|
|
|
@JsonProperty(KEYWORDS_PROPERTY_NAME)
|
|
protected Set<String> keywords;
|
|
|
|
@JsonProperty(AUTHORS_PROPERTY_NAME)
|
|
protected ArrayNode authors;
|
|
|
|
@JsonProperty(FILES_PROPERTY_NAME)
|
|
protected List<SoftwareVersionFile> files;
|
|
|
|
@JsonProperty(CODE_LOCATION_PROPERTY_NAME)
|
|
protected String codeLocation;
|
|
|
|
@JsonProperty(DOI_URL_PROPERTY_NAME)
|
|
protected URL doiURL;
|
|
|
|
@JsonProperty(VERSION_DOI_URL_PROPERTY_NAME)
|
|
protected URL versionDOIURL;
|
|
|
|
@JsonProperty(GRANTS_PROPERTY_NAME)
|
|
protected JsonNode grants;
|
|
|
|
@JsonProperty(PUBLISHERS_PROPERTY_NAME)
|
|
protected Map<String,ProcessorConfig> publishers;
|
|
|
|
@JsonProperty(EXPORTERS_PROPERTY_NAME)
|
|
protected Map<String,ProcessorConfig> exporters;
|
|
|
|
public SoftwareVersionConfig() {
|
|
this.newDeposition = false;
|
|
}
|
|
|
|
@JsonIgnore
|
|
public SoftwareVersionConfig getPrevious() {
|
|
return previous;
|
|
}
|
|
|
|
@JsonIgnore
|
|
public void setPrevious(SoftwareVersionConfig previous) {
|
|
this.previous = previous;
|
|
}
|
|
|
|
@JsonIgnore
|
|
public SoftwareVersionConfig getNext() {
|
|
return next;
|
|
}
|
|
|
|
@JsonIgnore
|
|
public void setNext(SoftwareVersionConfig next) {
|
|
this.next = next;
|
|
}
|
|
|
|
@JsonIgnore
|
|
public Boolean isNewDeposition() {
|
|
return newDeposition;
|
|
}
|
|
|
|
@JsonIgnore
|
|
public void setNewDeposition(Boolean newVersion) {
|
|
this.newDeposition = newVersion;
|
|
}
|
|
|
|
@JsonIgnore
|
|
public Variables getVariables() throws Exception {
|
|
ObjectMapper objectMapper = Utils.getObjectMapper();
|
|
JsonNode jsonNode = objectMapper.valueToTree(this);
|
|
Variables variables = objectMapper.treeToValue(jsonNode, Variables.class);
|
|
Set<String> missingVariables = variables.parse();
|
|
int size = missingVariables.size();
|
|
if(size>0) {
|
|
throw new Exception("The following variables has been used but not defined or cannot be actualised" +
|
|
missingVariables.toArray(new String[size]).toString());
|
|
}
|
|
return variables;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public String getVersion() {
|
|
return version;
|
|
}
|
|
|
|
public Date getDate() {
|
|
return date;
|
|
}
|
|
|
|
public String getTitle() {
|
|
return title;
|
|
}
|
|
|
|
public JsonNode getLicense() {
|
|
return license;
|
|
}
|
|
|
|
public Set<String> getKeywords() {
|
|
return keywords;
|
|
}
|
|
|
|
public ArrayNode getAuthors() {
|
|
return authors;
|
|
}
|
|
|
|
public List<SoftwareVersionFile> getFiles() {
|
|
return files;
|
|
}
|
|
|
|
public String getCodeLocation() {
|
|
return codeLocation;
|
|
}
|
|
|
|
public URL getDOIURL() {
|
|
return doiURL;
|
|
}
|
|
|
|
public void setDOIURL(URL doiURL) {
|
|
this.doiURL = doiURL;
|
|
}
|
|
|
|
public URL getVersionDOIURL() {
|
|
return versionDOIURL;
|
|
}
|
|
|
|
public void setVersionDOIURL(URL versionDOIURL) {
|
|
this.versionDOIURL = versionDOIURL;
|
|
}
|
|
|
|
public JsonNode getGrants() {
|
|
return grants;
|
|
}
|
|
|
|
public Map<String,ProcessorConfig> getPublishers() {
|
|
return publishers;
|
|
}
|
|
|
|
public Map<String,ProcessorConfig> getExporters() {
|
|
return exporters;
|
|
}
|
|
|
|
} |