diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherFisheryService.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherFisheryService.java index ac043a7..315c7fa 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherFisheryService.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherFisheryService.java @@ -551,7 +551,7 @@ public class GrsfPublisherFisheryService { // check system type boolean isGRSF = !record.getExtrasAsHashMap().get(Constants.SYSTEM_TYPE_CUSTOM_KEY) - .equals(Constants.SYSTEM_TYPE_FOR_SOURCES_VALUE); + .equals(Constants.SYSTEM_TYPE_LEGACY_RECORD); if(!isGRSF) throw new Exception("You are trying to modify a Legacy record!"); diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherStockService.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherStockService.java index 897a528..39dcb33 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherStockService.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/services/GrsfPublisherStockService.java @@ -554,7 +554,7 @@ public class GrsfPublisherStockService { // check system type boolean isGRSF = !record.getExtrasAsHashMap().get(Constants.SYSTEM_TYPE_CUSTOM_KEY) - .equals(Constants.SYSTEM_TYPE_FOR_SOURCES_VALUE); + .equals(Constants.SYSTEM_TYPE_LEGACY_RECORD); if(!isGRSF) throw new Exception("You are trying to modify a Legacy record!"); diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/CommonServiceUtils.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/CommonServiceUtils.java index 40e0bf1..7b3a761 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/CommonServiceUtils.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/CommonServiceUtils.java @@ -231,8 +231,8 @@ public class CommonServiceUtils { StringBuffer stringBuffer = new StringBuffer(); if(prependSource) { - stringBuffer.append(source.toString().toLowerCase()); - stringBuffer.append("-"); + stringBuffer.append(source.toString()); + stringBuffer.append(" "); } if(groupNameOverValue.isEmpty()) { @@ -494,8 +494,8 @@ public class CommonServiceUtils { } } - // append to groups: we need to add this record to the correspondent group of the sources - addRecordToGroupSources(groups, new ArrayList(sourcesList), productType, sourceInPath); + addRecordToGroups(groups, sourcesList, productType, sourceInPath); + // validate CommonServiceUtils.validateAggregatedRecord(record, sourceInPath); @@ -508,15 +508,16 @@ public class CommonServiceUtils { sourceInPath.equals(Sources.GRSF) ? productType.equals(Product_Type.FISHERY) ? ((FisheryRecord) record).getType().getOrigName() : ((StockRecord) record).getType().getOrigName() - : Constants.SYSTEM_TYPE_FOR_SOURCES_VALUE); + : Constants.SYSTEM_TYPE_LEGACY_RECORD); logger.debug("Domain is " + productType.getOrigName() + " and system type " + record.getSystemType()); - // evaluate the custom fields/tags, resources and groups - groups.add(productType.getOrigName().toLowerCase()); //i.e. stock or fishery - boolean skipTags = !sourceInPath.equals(Sources.GRSF); // no tags for the Original records - CommonServiceUtils.getTagsGroupsResourcesExtrasByRecord(tags, skipTags, groups, false, resources, false, + /* + * It has been decided to add tags also for legacy records see #23216 + * boolean skipTags = !sourceInPath.equals(Sources.GRSF); // no tags for the Original records + */ + CommonServiceUtils.getTagsGroupsResourcesExtrasByRecord(tags, false, groups, false, resources, false, customFields, record, username, sourceInPath); } @@ -528,38 +529,42 @@ public class CommonServiceUtils { * @param productType * @param sourceInPath */ - private static void addRecordToGroupSources(Set groups, List sourcesList, Product_Type productType, - Sources sourceInPath) { - - Collections.sort(sourcesList); // be sure the name are sorted because the groups have been generated this way - String groupName = sourceInPath.getOrigName().toLowerCase() + "-" + productType.getOrigName().toLowerCase(); - for(String source : sourcesList) { - groupName += "-" + source; + private static void addRecordToGroups(Set groups, Set sourcesList, Product_Type productType, Sources sourceInPath) { + if(sourceInPath == Sources.GRSF) { + groups.add(HelperMethods.getGroupNameOnCkan(Sources.GRSF.getOrigName())); // i.e. grsf + }else { + groups.add(HelperMethods.getGroupNameOnCkan(Constants.SYSTEM_TYPE_LEGACY_RECORD)); // i.e. legacy } - groups.add(groupName); + // evaluate the custom fields/tags, resources and groups + groups.add(HelperMethods.getGroupNameOnCkan(productType.getOrigName())); //i.e. stock or fishery + + for(String source : sourcesList) { + groups.add(HelperMethods.getGroupNameOnCkan(source)); // i.e. FIRMS, FishSource, RAM + } } - /** - * Fetch the system:type property from a record - * @param itemIdOrName - * @param apiKey - * @return null on error - * @throws Exception - */ - public static String getSystemTypeValue(String itemIdOrName, String apiKey, String context) throws Exception { - - DataCatalogue catalog = HelperMethods.getDataCatalogueRunningInstance(context); - CkanDataset dataset = catalog.getDataset(itemIdOrName, apiKey); - if(dataset == null) - throw new Exception("Unable to find record with id or name " + itemIdOrName); - String systemTypeValue = dataset.getExtrasAsHashMap().get(Constants.SYSTEM_TYPE_CUSTOM_KEY); - if(systemTypeValue == null || systemTypeValue.isEmpty()) - throw new Exception(Constants.SYSTEM_TYPE_CUSTOM_KEY + " property not set in record " + itemIdOrName); - else - return systemTypeValue; - - } +// /** +// * Fetch the system:type property from a record +// * @param itemIdOrName +// * @param apiKey +// * @return null on error +// * @throws Exception +// */ +// public static String getSystemTypeValue(String itemIdOrName, String apiKey, String context) throws Exception { +// DataCatalogue catalog = HelperMethods.getDataCatalogueRunningInstance(context); +// CkanDataset dataset = catalog.getDataset(itemIdOrName, apiKey); +// if(dataset == null) { +// throw new Exception("Unable to find record with id or name " + itemIdOrName); +// } +// String systemTypeValue = dataset.getExtrasAsHashMap().get(Constants.SYSTEM_TYPE_CUSTOM_KEY); +// if(systemTypeValue == null || systemTypeValue.isEmpty()) { +// throw new Exception(Constants.SYSTEM_TYPE_CUSTOM_KEY + " property not set in record " + itemIdOrName); +// }else { +// return systemTypeValue; +// } +// +// } public static String getRecordOrganization(String itemIdOrName, String apiKey, String context) throws Exception { DataCatalogue catalog = HelperMethods.getDataCatalogueRunningInstance(context);