minor model fix and other improvements
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@154873 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1393967788
commit
3252991797
|
@ -22,7 +22,7 @@ public class ApplicationException implements ExceptionMapper<Exception> {
|
|||
return Response
|
||||
.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.entity(new ResponseBean(false, e.getMessage(), null))
|
||||
.entity(new ResponseBean(false, e.toString(), null))
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -6,10 +6,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.CustomField;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.ResourceBean;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -24,11 +20,12 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
*/
|
||||
public class Base {
|
||||
|
||||
private static final List<String> FIELDS_TO_IGNORE = Arrays.asList("author", "author_contact", "stock_uri", "fishery_uri", "reference_year", "reporting_year", "water_area",
|
||||
"environment", "state_of_marine_resource");
|
||||
private static final List<String> FIELDS_TO_IGNORE = Arrays.asList(
|
||||
"author", "author_contact", "stock_uri",
|
||||
"fishery_uri", "reference_year", "reporting_year", "water_area",
|
||||
"environment", "state_of_marine_resource", "system:type");
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(Base.class);
|
||||
public static final String UUID_KB_KEY = "GRSF UUID";
|
||||
|
||||
@JsonProperty("catalog_id") //used on patch/update product call
|
||||
private String catalogId;
|
||||
|
@ -62,18 +59,12 @@ public class Base {
|
|||
@JsonProperty("extras_resources")
|
||||
private List<ResourceBean> extrasResources = new ArrayList<ResourceBean>();
|
||||
|
||||
@JsonProperty("grsf_uuid")
|
||||
@CustomField(key=UUID_KB_KEY)
|
||||
@NotNull(message="grsf_uuid cannot be null")
|
||||
@Size(min=1, message="grsf_uuid cannot be empty")
|
||||
private String uuid;
|
||||
|
||||
public Base() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param catalogId
|
||||
* @param description
|
||||
* @param license
|
||||
* @param author
|
||||
|
@ -83,14 +74,14 @@ public class Base {
|
|||
* @param maintainerContact
|
||||
* @param extrasFields
|
||||
* @param extrasResources
|
||||
* @param uuid
|
||||
*/
|
||||
public Base(String id, String description, String license, String author,
|
||||
String authorContact, Long version, String maintainer,
|
||||
String maintainerContact, Map<String, List<String>> extrasFields,
|
||||
List<ResourceBean> extrasResources, String uuid) {
|
||||
public Base(String catalogId, String description, String license,
|
||||
String author, String authorContact, Long version,
|
||||
String maintainer, String maintainerContact,
|
||||
Map<String, List<String>> extrasFields,
|
||||
List<ResourceBean> extrasResources) {
|
||||
super();
|
||||
this.catalogId = id;
|
||||
this.catalogId = catalogId;
|
||||
this.description = description;
|
||||
this.license = license;
|
||||
this.author = author;
|
||||
|
@ -100,7 +91,6 @@ public class Base {
|
|||
this.maintainerContact = maintainerContact;
|
||||
this.extrasFields = extrasFields;
|
||||
this.extrasResources = extrasResources;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getCatalogId() {
|
||||
|
@ -183,14 +173,6 @@ public class Base {
|
|||
this.extrasResources = extrasResources;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use for generics object (unrecognized from Jackson) to be put into the map
|
||||
* @param key
|
||||
|
@ -218,12 +200,12 @@ public class Base {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Base [catalogId=" + catalogId + ", description=" + description + ", license="
|
||||
+ license + ", author=" + author + ", authorContact="
|
||||
+ authorContact + ", version=" + version + ", maintainer="
|
||||
+ maintainer + ", maintainerContact=" + maintainerContact
|
||||
+ ", extrasFields=" + extrasFields + ", extrasResources="
|
||||
+ extrasResources + ", uuid=" + uuid + "]";
|
||||
return "Base [catalogId=" + catalogId + ", description=" + description
|
||||
+ ", license=" + license + ", author=" + author
|
||||
+ ", authorContact=" + authorContact + ", version=" + version
|
||||
+ ", maintainer=" + maintainer + ", maintainerContact="
|
||||
+ maintainerContact + ", extrasFields=" + extrasFields
|
||||
+ ", extrasResources=" + extrasResources + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,8 @@ package org.gcube.data_catalogue.grsf_publish_ws.json.input.record;
|
|||
import java.util.List;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.CkanResource;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.CustomField;
|
||||
|
@ -26,8 +28,9 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
*/
|
||||
@JsonIgnoreProperties(value = {"grsf_type", "source"})
|
||||
public class Common extends Base{
|
||||
|
||||
public static final String GRSF_DATABASE_SOURCE = "Database Source";
|
||||
|
||||
public static final String UUID_KB_KEY = "GRSF UUID";
|
||||
public static final String DOMAIN = "Domain";
|
||||
|
||||
// it is added in case of GRSF record
|
||||
@JsonProperty("data_owner")
|
||||
|
@ -89,6 +92,16 @@ public class Common extends Base{
|
|||
@JsonProperty("similar_source_records")
|
||||
@CustomField(key="Similar Source Records")
|
||||
private List<SimilarRecordBean> similarSourceRecords;
|
||||
|
||||
// automatically set
|
||||
@CustomField(key=DOMAIN)
|
||||
private String domain;
|
||||
|
||||
@JsonProperty("grsf_uuid")
|
||||
@CustomField(key=UUID_KB_KEY)
|
||||
@NotNull(message="grsf_uuid cannot be null")
|
||||
@Size(min=1, message="grsf_uuid cannot be empty")
|
||||
private String uuid;
|
||||
|
||||
public Common() {
|
||||
super();
|
||||
|
@ -102,12 +115,14 @@ public class Common extends Base{
|
|||
* @param shortName
|
||||
* @param traceabilityFlag
|
||||
* @param status
|
||||
* @param grsfType
|
||||
* @param systemType
|
||||
* @param catches
|
||||
* @param landings
|
||||
* @param species
|
||||
* @param similarGRSFRecords
|
||||
* @param similarSourceRecords
|
||||
* @param domain
|
||||
* @param uuid
|
||||
*/
|
||||
public Common(List<String> dataOwner,
|
||||
List<Resource<Sources>> databaseSources,
|
||||
|
@ -117,7 +132,8 @@ public class Common extends Base{
|
|||
List<TimeSeriesBean<String, String>> catches,
|
||||
List<TimeSeriesBean<String, String>> landings,
|
||||
List<String> species, List<SimilarRecordBean> similarGRSFRecords,
|
||||
List<SimilarRecordBean> similarSourceRecords) {
|
||||
List<SimilarRecordBean> similarSourceRecords, String domain,
|
||||
String uuid) {
|
||||
super();
|
||||
this.dataOwner = dataOwner;
|
||||
this.databaseSources = databaseSources;
|
||||
|
@ -132,6 +148,24 @@ public class Common extends Base{
|
|||
this.species = species;
|
||||
this.similarGRSFRecords = similarGRSFRecords;
|
||||
this.similarSourceRecords = similarSourceRecords;
|
||||
this.domain = domain;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getSystemType() {
|
||||
|
@ -279,7 +313,8 @@ public class Common extends Base{
|
|||
+ systemType + ", catches=" + catches + ", landings="
|
||||
+ landings + ", species=" + species + ", similarGRSFRecords="
|
||||
+ similarGRSFRecords + ", similarSourceRecords="
|
||||
+ similarSourceRecords + "]";
|
||||
+ similarSourceRecords + ", domain=" + domain + ", uuid="
|
||||
+ uuid + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -15,7 +15,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A record bean
|
||||
* A fishery record bean.
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
|
|
|
@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A stock record bean
|
||||
* A stock record bean.
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
|
|
|
@ -11,14 +11,14 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true) // ignore in serialization/deserialization
|
||||
public class DeleteProductBean {
|
||||
public class DeleteRecord {
|
||||
|
||||
@JsonProperty("id")
|
||||
@NotNull(message="id cannot be null")
|
||||
@Size(min=1, message="id cannot be empty")
|
||||
private String id;
|
||||
|
||||
public DeleteProductBean() {
|
||||
public DeleteRecord() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class DeleteProductBean {
|
|||
* Create a product deleted bean for the product that had the id 'id'
|
||||
* @param id
|
||||
*/
|
||||
public DeleteProductBean(String id) {
|
||||
public DeleteRecord(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
package org.gcube.data_catalogue.grsf_publish_ws.json.input.utils;
|
||||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.Common;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
|
@ -59,11 +62,18 @@ public class SimilarRecordBean {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
String toReturn = "";
|
||||
toReturn += url != null ? "url = " + url + ", " : "";
|
||||
toReturn += id != null ? "id = " + id + ", " : "";
|
||||
toReturn += description != null ? "description = " + description : "";
|
||||
toReturn = toReturn.endsWith(", ") ? toReturn.substring(0, toReturn.length() - 2) : toReturn;
|
||||
return toReturn;
|
||||
// in json format
|
||||
JSONObject obj = new JSONObject();
|
||||
|
||||
if(url != null && !url.isEmpty())
|
||||
obj.put("url", url);
|
||||
|
||||
if(description != null && !description.isEmpty())
|
||||
obj.put("description", description);
|
||||
|
||||
if(id != null && !id.isEmpty())
|
||||
obj.put("id", Common.cleanSemanticId(id));
|
||||
|
||||
return obj.toJSONString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public class ResponseCreationBean {
|
|||
private String kbUuid; // the original uuid given by the KB
|
||||
|
||||
@JsonProperty("product_url")
|
||||
String itemUrl;
|
||||
private String itemUrl;
|
||||
|
||||
@JsonProperty("error")
|
||||
private String error; // in case of error
|
||||
|
|
|
@ -29,8 +29,9 @@ import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
|||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.authorization.library.utils.Caller;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.Common;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.FisheryRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.utils.DeleteProductBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.utils.DeleteRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseCreationBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.CommonServiceUtils;
|
||||
|
@ -157,7 +158,7 @@ public class GrsfPublisherFisheryService {
|
|||
if(namespaces == null)
|
||||
throw new Exception("Failed to retrieve the namespaces for the key fields!");
|
||||
|
||||
customFields = HelperMethods.replaceFieldsKey(customFields, namespaces);
|
||||
customFields = HelperMethods.replaceFieldsKey(customFields, namespaces, !sourceInPath.equals(Sources.GRSF));
|
||||
|
||||
String publishInOrganization = CommonServiceUtils.evaluateOrganization(organization, sourceInPath);
|
||||
|
||||
|
@ -215,7 +216,7 @@ public class GrsfPublisherFisheryService {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response deleteFishery(
|
||||
@NotNull(message="input value is missing")
|
||||
@Valid DeleteProductBean recordToDelete,
|
||||
@Valid DeleteRecord recordToDelete,
|
||||
@PathParam("source") String source) throws ValidationException{
|
||||
|
||||
// retrieve context and username
|
||||
|
@ -246,10 +247,10 @@ public class GrsfPublisherFisheryService {
|
|||
}
|
||||
|
||||
// check it is in the right source and it is a fishery
|
||||
String systemType = fisheryInCkan.getExtrasAsHashMap().get(CommonServiceUtils.SYSTEM_TYPE);
|
||||
String type = fisheryInCkan.getExtrasAsHashMap().get(Common.DOMAIN);
|
||||
|
||||
if(fisheryInCkan.getOrganization().getName().equalsIgnoreCase(source) &&
|
||||
CommonServiceUtils.SYSTEM_TYPE_FISHERY.equals(systemType)){
|
||||
Product_Type.FISHERY.getOrigName().equals(type)){
|
||||
|
||||
logger.debug("Ok, this is a fishery of the right source, removing it");
|
||||
boolean deleted = catalogue.deleteProduct(fisheryInCkan.getId(), apiKey, true);
|
||||
|
@ -310,8 +311,8 @@ public class GrsfPublisherFisheryService {
|
|||
for (String id : fullGroupListIds) {
|
||||
CkanDataset dataset = catalogue.getDataset(id, apiKey);
|
||||
if(dataset != null){
|
||||
String type = dataset.getExtrasAsHashMap().get(CommonServiceUtils.SYSTEM_TYPE);
|
||||
if(CommonServiceUtils.SYSTEM_TYPE_FISHERY.equals(type))
|
||||
String type = dataset.getExtrasAsHashMap().get(Common.DOMAIN);
|
||||
if(Product_Type.FISHERY.getOrigName().equals(type))
|
||||
datasetsIds.add(id);
|
||||
}
|
||||
}
|
||||
|
@ -480,7 +481,7 @@ public class GrsfPublisherFisheryService {
|
|||
customFields.put(CommonServiceUtils.ITEM_URL_FIELD, Arrays.asList(itemUrl));
|
||||
|
||||
// replace fields
|
||||
customFields = HelperMethods.replaceFieldsKey(customFields, namespaces);
|
||||
customFields = HelperMethods.replaceFieldsKey(customFields, namespaces, !sourceInPath.equals(Sources.GRSF));
|
||||
|
||||
String publishInOrganization = CommonServiceUtils.evaluateOrganization(organization, sourceInPath);
|
||||
|
||||
|
|
|
@ -29,8 +29,9 @@ import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
|||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.authorization.library.utils.Caller;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.Common;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.StockRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.utils.DeleteProductBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.utils.DeleteRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.output.ResponseCreationBean;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.CommonServiceUtils;
|
||||
|
@ -111,7 +112,7 @@ public class GrsfPublisherStockService {
|
|||
|
||||
// check it has admin role or throw exception
|
||||
CommonServiceUtils.hasAdminRole(username, catalogue, apiKey, organization);
|
||||
|
||||
|
||||
// extend this role to the other organizations in this context
|
||||
CommonServiceUtils.extendRoleToOtherOrganizations(username, catalogue, organization, RolesCkanGroupOrOrg.ADMIN);
|
||||
|
||||
|
@ -172,8 +173,8 @@ public class GrsfPublisherStockService {
|
|||
if(namespaces == null)
|
||||
throw new Exception("Failed to retrieve the namespaces for the key fields!");
|
||||
|
||||
customFields = HelperMethods.replaceFieldsKey(customFields, namespaces);
|
||||
|
||||
customFields = HelperMethods.replaceFieldsKey(customFields, namespaces, !sourceInPath.equals(Sources.GRSF));
|
||||
|
||||
String publishInOrganization = CommonServiceUtils.evaluateOrganization(organization, sourceInPath);
|
||||
|
||||
logger.info("Invoking create method..");
|
||||
|
@ -200,10 +201,10 @@ public class GrsfPublisherStockService {
|
|||
|
||||
logger.info("Product created! Id is " + id);
|
||||
String description = "Short Name: " + record.getShortName();
|
||||
|
||||
|
||||
if(sourceInPath.equals(Sources.GRSF))
|
||||
description += ", GRSF Semantic Identifier: " + record.getStockId();
|
||||
|
||||
|
||||
CommonServiceUtils.actionsPostCreateOrUpdate(
|
||||
id, futureName, record, apiKey, username, organization, null,
|
||||
responseBean, catalogue, namespaces, groups, context, token,
|
||||
|
@ -226,7 +227,7 @@ public class GrsfPublisherStockService {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response deleteStock(
|
||||
@NotNull(message="missing input value")
|
||||
@Valid DeleteProductBean recordToDelete,
|
||||
@Valid DeleteRecord recordToDelete,
|
||||
@PathParam("source") String source) throws ValidationException{
|
||||
|
||||
// retrieve context and username
|
||||
|
@ -261,10 +262,9 @@ public class GrsfPublisherStockService {
|
|||
}
|
||||
|
||||
// check it is in the right source and it is a stock
|
||||
String systemType = stockInCkan.getExtrasAsHashMap().get(CommonServiceUtils.SYSTEM_TYPE);
|
||||
|
||||
String type = stockInCkan.getExtrasAsHashMap().get(Common.DOMAIN);
|
||||
if(stockInCkan.getOrganization().getName().equalsIgnoreCase(source) &&
|
||||
CommonServiceUtils.SYSTEM_TYPE_STOCK.equals(systemType)){
|
||||
Product_Type.STOCK.getOrigName().equals(type)){
|
||||
|
||||
logger.debug("Ok, this is a stock of the right type, removing it");
|
||||
boolean deleted = catalogue.deleteProduct(stockInCkan.getId(), apiKey, true);
|
||||
|
@ -323,8 +323,9 @@ public class GrsfPublisherStockService {
|
|||
for (String id : fullGroupListIds) {
|
||||
CkanDataset dataset = catalogue.getDataset(id, catalogue.getApiKeyFromUsername(username));
|
||||
if(dataset != null){
|
||||
String type = dataset.getExtrasAsHashMap().get(CommonServiceUtils.SYSTEM_TYPE);
|
||||
if(CommonServiceUtils.SYSTEM_TYPE_STOCK.equals(type))
|
||||
|
||||
String type = dataset.getExtrasAsHashMap().get(Common.DOMAIN);
|
||||
if(Product_Type.STOCK.getOrigName().equals(type))
|
||||
datasetsIds.add(id);
|
||||
}
|
||||
}
|
||||
|
@ -488,8 +489,8 @@ public class GrsfPublisherStockService {
|
|||
customFields.put(CommonServiceUtils.ITEM_URL_FIELD, Arrays.asList(itemUrl));
|
||||
|
||||
// replace fields
|
||||
customFields = HelperMethods.replaceFieldsKey(customFields, namespaces);
|
||||
|
||||
customFields = HelperMethods.replaceFieldsKey(customFields, namespaces,!sourceInPath.equals(Sources.GRSF));
|
||||
|
||||
String publishInOrganization = CommonServiceUtils.evaluateOrganization(organization, sourceInPath);
|
||||
|
||||
logger.info("Invoking update method..");
|
||||
|
|
|
@ -53,9 +53,9 @@ public class CommonServiceUtils {
|
|||
private static final int TIME_SERIES_TAKE_LAST_VALUES = 5;
|
||||
private static final String REGEX_TAGS = "[^\\s\\w-_.]";
|
||||
public static final String SYSTEM_TYPE = "system:type";
|
||||
public static final String SYSTEM_TYPE_STOCK = "GRSF Stock";
|
||||
public static final String SYSTEM_TYPE_FISHERY = "GRSF Fishery";
|
||||
|
||||
public static final String SYSTEM_TYPE_FOR_SOURCES = "Source";
|
||||
public static final String GRSF_DATABASE_SOURCE = "Database Source";
|
||||
|
||||
// item url property
|
||||
public static final String ITEM_URL_FIELD = "GRSF Record URL";
|
||||
private static final String GRSF_ADMIN_ORGANIZATION_NAME = "grsf_admin";
|
||||
|
@ -450,7 +450,7 @@ public class CommonServiceUtils {
|
|||
}
|
||||
|
||||
// create the Database Source information
|
||||
customFields.put(Common.GRSF_DATABASE_SOURCE, Arrays.asList(databaseSource.trim()));
|
||||
customFields.put(GRSF_DATABASE_SOURCE, Arrays.asList(databaseSource.trim()));
|
||||
|
||||
// append to groups: we need to add this record to the correspondent group of the sources
|
||||
addRecordToGroupSources(groups, sourcesList, productType, sourceInPath);
|
||||
|
@ -465,9 +465,14 @@ public class CommonServiceUtils {
|
|||
boolean skipTags = !sourceInPath.equals(Sources.GRSF); // no tags for the Original records
|
||||
CommonServiceUtils.getTagsGroupsResourcesExtrasByRecord(tags, skipTags, groups, false, resources, false, customFields, record, username, sourceInPath);
|
||||
|
||||
// set the system type type: fishery or stock
|
||||
record.setSystemType(productType.equals(Product_Type.STOCK)? SYSTEM_TYPE_STOCK : SYSTEM_TYPE_FISHERY);
|
||||
|
||||
// set the domain
|
||||
record.setDomain(productType.getOrigName());
|
||||
|
||||
// set system type (it is equal to the GRSF Type for GRSF records, "Source" for source records)
|
||||
record.setSystemType(sourceInPath.equals(Sources.GRSF) ?
|
||||
productType.equals(Product_Type.FISHERY) ? ((FisheryRecord)record).getType().getOrigName() : ((StockRecord)record).getType().getOrigName()
|
||||
: SYSTEM_TYPE_FOR_SOURCES);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -499,7 +499,7 @@ public abstract class HelperMethods {
|
|||
return catalogue.getProductsIdsInGroupOrOrg(groupName, true, 0, Integer.MAX_VALUE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the identifiers of the products in a given organization. It doesn't use CKAN API because they would return at most 1000 ids.
|
||||
* @param string
|
||||
|
@ -573,7 +573,7 @@ public abstract class HelperMethods {
|
|||
* @return
|
||||
*/
|
||||
public static Map<String, List<String>> replaceFieldsKey(Map<String, List<String>> customFields,
|
||||
Map<String, String> namespaces) {
|
||||
Map<String, String> namespaces, boolean isSourceRecord) {
|
||||
|
||||
Map<String, List<String>> toReturn = new HashMap<String, List<String>>();
|
||||
|
||||
|
@ -582,10 +582,20 @@ public abstract class HelperMethods {
|
|||
while (iterator.hasNext()) {
|
||||
Map.Entry<java.lang.String, java.util.List<java.lang.String>> entry = (Map.Entry<java.lang.String, java.util.List<java.lang.String>>) iterator
|
||||
.next();
|
||||
if(namespaces.containsKey(entry.getKey()))
|
||||
|
||||
String usedKey = "";
|
||||
|
||||
if(namespaces.containsKey(entry.getKey())){
|
||||
toReturn.put(namespaces.get(entry.getKey()), entry.getValue());
|
||||
else
|
||||
usedKey = namespaces.get(entry.getKey());
|
||||
}
|
||||
else{
|
||||
toReturn.put(entry.getKey(), entry.getValue());
|
||||
usedKey = entry.getKey();
|
||||
}
|
||||
|
||||
if(isSourceRecord)
|
||||
toReturn.put(usedKey.replace("GRSF", "").trim(), entry.getValue());
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.Common;
|
|||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.FisheryRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.StockRecord;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.CSVUtils;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.CommonServiceUtils;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.cache.CacheImpl;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.cache.CacheInterface;
|
||||
|
@ -157,7 +156,7 @@ public class ManageTimeSeriesThread extends Thread{
|
|||
// - type of files (e.g., csv)
|
||||
// -files (e.g, kbuuid.csv)
|
||||
|
||||
String recordTypeFolderName = record.getSystemType().equals(CommonServiceUtils.SYSTEM_TYPE_STOCK)? "stock" :"fishery";
|
||||
String recordTypeFolderName = record.getDomain().toLowerCase();
|
||||
String productName = record.getClass().equals(StockRecord.class) ? ((StockRecord)record).getStockName() : ((FisheryRecord)record).getFisheryName();
|
||||
String csvFileName = replaceIllegalChars(productName, " ");
|
||||
csvFileName = generateCSVFileName(csvFileName);
|
||||
|
|
Loading…
Reference in New Issue