Fields with @group annotation have also the @tag one.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@133165 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9f71232585
commit
a0a0dd48b5
|
@ -50,13 +50,11 @@ public class Common {
|
|||
private String catchesOrLandings;
|
||||
|
||||
@JsonProperty("database_sources")
|
||||
@CustomField(key="Database sources")
|
||||
@NotNull(message="database_source cannot be null")
|
||||
@Size(min=1, message="database_source cannot be empty")
|
||||
private List<DatabaseSource> databaseSources;
|
||||
|
||||
@JsonProperty("source_of_information")
|
||||
@CustomField(key="Source of information")
|
||||
@NotNull(message="source_of_information cannot be null")
|
||||
@Size(min=1, message="source_of_information cannot be empty")
|
||||
private List<Resource> sourceOfInformation;
|
||||
|
|
|
@ -4,6 +4,7 @@ import javax.validation.constraints.NotNull;
|
|||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Group;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.custom_annotations.Tag;
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Source;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
@ -26,6 +27,7 @@ public class DatabaseSource {
|
|||
|
||||
@JsonProperty("name")
|
||||
@Group
|
||||
@Tag
|
||||
@NotNull(message="'name' attribute of database_source is missing or wrong")
|
||||
private Source name;
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ public class FisheryRecord extends Common{
|
|||
|
||||
@JsonProperty("production_system_type")
|
||||
@Group
|
||||
@Tag
|
||||
@CustomField(key="Production system type")
|
||||
private Production_System_Type productionSystemType;
|
||||
|
||||
|
@ -66,6 +67,7 @@ public class FisheryRecord extends Common{
|
|||
@JsonProperty("status")
|
||||
@CustomField(key="Status")
|
||||
@Group
|
||||
@Tag
|
||||
@NotNull(message="status cannot be null")
|
||||
private Status status;
|
||||
|
||||
|
|
|
@ -59,11 +59,13 @@ public class StockRecord extends Common{
|
|||
@JsonProperty("exploitation_rate")
|
||||
@CustomField(key="Exploitation rate")
|
||||
@Group
|
||||
@Tag
|
||||
private Exploitation_Rate exploitationRate;
|
||||
|
||||
@JsonProperty("abundance_level")
|
||||
@CustomField(key="Abundance level")
|
||||
@Group
|
||||
@Tag
|
||||
private Abundance_Level abundanceLevel;
|
||||
|
||||
@JsonProperty("narrative_state_and_trend")
|
||||
|
|
|
@ -94,6 +94,7 @@ public abstract class HelperMethods {
|
|||
* Retrieve the list of tags for this object
|
||||
*/
|
||||
public static void getTags(List<String> tags, Common record){
|
||||
|
||||
Class<?> current = record.getClass();
|
||||
do{
|
||||
Field[] fields = current.getDeclaredFields();
|
||||
|
@ -103,7 +104,7 @@ public abstract class HelperMethods {
|
|||
Object f = new PropertyDescriptor(field.getName(), current).getReadMethod().invoke(record);
|
||||
if(f != null){
|
||||
|
||||
tags.add(f.toString());
|
||||
tags.add(f.toString().trim());
|
||||
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
@ -113,12 +114,23 @@ public abstract class HelperMethods {
|
|||
}
|
||||
}
|
||||
while((current = current.getSuperclass())!=null);
|
||||
|
||||
// now parse also the Database Sources field
|
||||
List<DatabaseSource> sources = record.getDatabaseSources();
|
||||
for (DatabaseSource databaseSource : sources) {
|
||||
logger.debug("Database source is " + databaseSource);
|
||||
String nameAsTag = databaseSource.getName().toString();
|
||||
if(!tags.contains(nameAsTag))
|
||||
tags.add(nameAsTag);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the list of groups' names for this object
|
||||
*/
|
||||
public static void getGroups(List<String> groups, Common record){
|
||||
|
||||
Class<?> current = record.getClass();
|
||||
do{
|
||||
Field[] fields = current.getDeclaredFields();
|
||||
|
@ -129,7 +141,7 @@ public abstract class HelperMethods {
|
|||
if(f != null){
|
||||
|
||||
// also convert to the group name that should be on ckan
|
||||
String groupName = getGroupNameOnCkan(f.toString());
|
||||
String groupName = getGroupNameOnCkan(f.toString().trim());
|
||||
if(!groups.contains(groupName))
|
||||
groups.add(groupName);
|
||||
|
||||
|
@ -142,13 +154,15 @@ public abstract class HelperMethods {
|
|||
}
|
||||
while((current = current.getSuperclass())!=null);
|
||||
|
||||
logger.debug("Groups is " + groups);
|
||||
|
||||
// now parse also the Database Sources field
|
||||
List<DatabaseSource> sources = record.getDatabaseSources();
|
||||
for (DatabaseSource databaseSource : sources) {
|
||||
|
||||
logger.debug("Database source is " + databaseSource);
|
||||
Source name = databaseSource.getName();
|
||||
String groupName = getGroupNameOnCkan(name.toString());
|
||||
String groupName = getGroupNameOnCkan(name.toString().trim());
|
||||
if(!groups.contains(groupName))
|
||||
groups.add(groupName);
|
||||
|
||||
|
@ -159,6 +173,7 @@ public abstract class HelperMethods {
|
|||
* Retrieve the list of extras for this object
|
||||
*/
|
||||
public static void getExtras(Map<String, String> extras, Common record){
|
||||
|
||||
Class<?> current = record.getClass();
|
||||
do{
|
||||
Field[] fields = current.getDeclaredFields();
|
||||
|
@ -169,7 +184,7 @@ public abstract class HelperMethods {
|
|||
if(f != null){
|
||||
|
||||
// get the key to put into the map first
|
||||
extras.put(field.getAnnotation(CustomField.class).key(), f.toString());
|
||||
extras.put(field.getAnnotation(CustomField.class).key(), f.toString().trim());
|
||||
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
@ -411,7 +426,7 @@ public abstract class HelperMethods {
|
|||
logger.debug("Adding resource " + res);
|
||||
toReturn.add(new ResourceBean(res.getUrl(), res.getName(), res.getDescription(), null, username, null, null));
|
||||
}
|
||||
|
||||
|
||||
logger.debug("Returning resources " + toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue