minor fixes
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@158929 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
10bd220c53
commit
4b62e244cf
|
@ -412,22 +412,22 @@ public class CommonServiceUtils {
|
|||
if(refersTo == null || refersTo.isEmpty())
|
||||
throw new Exception("refers_to is empty for a GRSF record");
|
||||
|
||||
List<String> sourcesList = new ArrayList<String>();
|
||||
Set<String> sourcesList = new HashSet<String>();
|
||||
|
||||
String databaseSource = "";
|
||||
// we have the id within the catalog of this record. This means that we can retrieve the record and its system:type
|
||||
for (RefersToBean refersToBean : refersTo) {
|
||||
String sourceSysType = getSystemTypeValue(refersToBean.getId(), apiKey, context);
|
||||
resources.add(new ResourceBean(refersToBean.getUrl(), sourceSysType , "", null, username, null, null));
|
||||
sourcesList.add(sourceSysType.toLowerCase());
|
||||
databaseSource += sourceSysType + " ";
|
||||
String sourceOrganization = getRecordOrganization(refersToBean.getId(), apiKey, context);
|
||||
resources.add(new ResourceBean(refersToBean.getUrl(), sourceOrganization , "", null, username, null, null));
|
||||
sourcesList.add(sourceOrganization.toLowerCase());
|
||||
databaseSource += sourceOrganization + " ";
|
||||
}
|
||||
|
||||
// create the Database Source information
|
||||
customFields.put(Constants.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);
|
||||
addRecordToGroupSources(groups, new ArrayList(sourcesList), productType, sourceInPath);
|
||||
|
||||
// validate
|
||||
CommonServiceUtils.validateAggregatedRecord(record);
|
||||
|
@ -489,6 +489,18 @@ public class CommonServiceUtils {
|
|||
else
|
||||
return systemTypeValue;
|
||||
|
||||
}
|
||||
|
||||
public static String getRecordOrganization(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);
|
||||
else
|
||||
return dataset.getOrganization().getTitle();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue