added No connections and No Similar Records temporary fields when none of them is currently available
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@162590 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
44055ded61
commit
2f987757c3
|
@ -148,7 +148,7 @@ public class CommonServiceUtils {
|
|||
if(!skipGroups)
|
||||
getGroupsByField(field, current, record, groups, source);
|
||||
|
||||
getExtrasByField(field, current, record, extras);
|
||||
getExtrasByField(field, current, record, extras, source);
|
||||
|
||||
if(!skipResources)
|
||||
getResourcesByField(field, current, record, username, resources);
|
||||
|
@ -263,12 +263,32 @@ public class CommonServiceUtils {
|
|||
|
||||
/**
|
||||
* Retrieve the list of extras for this object
|
||||
* @param source
|
||||
*/
|
||||
private static void getExtrasByField(Field field, Class<?> current, Base record, Map<String,List<String>> extras){
|
||||
private static void getExtrasByField(Field field, Class<?> current, Base record, Map<String, List<String>> extras, Sources source){
|
||||
if(field.isAnnotationPresent(CustomField.class)){
|
||||
try{
|
||||
Object f = new PropertyDescriptor(field.getName(), current).getReadMethod().invoke(record);
|
||||
String keyField = field.getAnnotation(CustomField.class).key();
|
||||
|
||||
// manage no connections nor similar grsf records here for GRSF records only
|
||||
if(source.equals(Sources.GRSF) && keyField.equals(Constants.SIMILAR_GRSF_RECORDS_CUSTOM_KEY)){
|
||||
List asList = (List)f;
|
||||
if(asList == null || asList.isEmpty()){
|
||||
extras.put(keyField, Arrays.asList(Constants.NO_SIMILAR_GRSF_RECORDS));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(source.equals(Sources.GRSF) && keyField.equals(Constants.CONNECTED_JSON_KEY)){
|
||||
List asList = (List)f;
|
||||
if(asList == null || asList.isEmpty()){
|
||||
extras.put(keyField, Arrays.asList(Constants.NO_CONNECTED_RECORDS));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(f != null){
|
||||
Set<String> valuesForKey = null;
|
||||
|
||||
|
|
Loading…
Reference in New Issue