added support for sdg flag (managed as for traceability flag)

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@164582 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2018-02-26 16:19:34 +00:00
parent 71a78c9e54
commit 93e4d3480e
5 changed files with 27 additions and 49 deletions

View File

@ -6,7 +6,7 @@
<dependent-module archiveName="grsf-common-library-1.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/grsf-common-library/grsf-common-library"> <dependent-module archiveName="grsf-common-library-1.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/grsf-common-library/grsf-common-library">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module archiveName="ckan-util-library-2.4.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library/ckan-util-library"> <dependent-module archiveName="ckan-util-library-2.4.2-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library/ckan-util-library">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<property name="context-root" value="grsf-publisher-ws"/> <property name="context-root" value="grsf-publisher-ws"/>

View File

@ -21,7 +21,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/ */
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class Base { public abstract class Base {
private static final List<String> FIELDS_TO_IGNORE = Arrays.asList( private static final List<String> FIELDS_TO_IGNORE = Arrays.asList(
Constants.AUTHOR, Constants.AUTHOR_CONTACT, Constants.SYSTEM_TYPE_CUSTOM_KEY, Constants.GRSF_TYPE_JSON_KEY, Constants.AUTHOR, Constants.AUTHOR_CONTACT, Constants.SYSTEM_TYPE_CUSTOM_KEY, Constants.GRSF_TYPE_JSON_KEY,

View File

@ -26,9 +26,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
* Information that both Stock and Fishery records must contain. * Information that both Stock and Fishery records must contain.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/ */
public class Common extends Base{ public abstract class Common extends Base{
// it is added in case of GRSF record
@JsonProperty(Constants.DATA_OWNER_JSON_KEY) @JsonProperty(Constants.DATA_OWNER_JSON_KEY)
@CustomField(key=Constants.DATA_OWNER_CUSTOM_KEY) @CustomField(key=Constants.DATA_OWNER_CUSTOM_KEY)
private List<String> dataOwner; private List<String> dataOwner;
@ -53,9 +52,14 @@ public class Common extends Base{
@JsonProperty(Constants.TRACEABILITY_FLAG_JSON_KEY) @JsonProperty(Constants.TRACEABILITY_FLAG_JSON_KEY)
@CustomField(key=Constants.TRACEABILITY_FLAG_CUSTOM_KEY) @CustomField(key=Constants.TRACEABILITY_FLAG_CUSTOM_KEY)
@Group(condition="true", groupNameOverValue="traceability-flag") // record is added to group traceability-flag if Traceability Flag is true @Group(condition="true", groupNameOverValue=Constants.TRACEABILITY_FLAG_GROUP_NAME) // record is added to group traceability-flag if Traceability Flag is true
private Boolean traceabilityFlag; private Boolean traceabilityFlag;
@JsonProperty(Constants.SDG_FLAG_JSON_KEY)
@CustomField(key=Constants.SDG_FLAG_CUSTOM_KEY)
@Group(condition="true", groupNameOverValue=Constants.SDG_FLAG_GROUP_NAME) // record is added to group sdg-flag if sdg Flag is true
private Boolean sdgFlag;
@JsonProperty(Constants.STATUS_OF_THE_GRSF_RECORD_JSON_KEY) @JsonProperty(Constants.STATUS_OF_THE_GRSF_RECORD_JSON_KEY)
@CustomField(key=Constants.STATUS_OF_THE_GRSF_RECORD_CUSTOM_KEY) @CustomField(key=Constants.STATUS_OF_THE_GRSF_RECORD_CUSTOM_KEY)
//@Tag //@Tag
@ -331,21 +335,28 @@ public class Common extends Base{
this.annotations = annotations; this.annotations = annotations;
} }
public Boolean getSdgFlag() {
return sdgFlag;
}
public void setSdgFlag(Boolean sdgFlag) {
this.sdgFlag = sdgFlag;
}
@Override @Override
public String toString() { public String toString() {
return "Common [dataOwner=" + dataOwner + ", databaseSources=" return "Common [dataOwner=" + dataOwner + ", databaseSources="
+ databaseSources + ", sourceOfInformation=" + databaseSources + ", sourceOfInformation="
+ sourceOfInformation + ", refersTo=" + refersTo + sourceOfInformation + ", refersTo=" + refersTo
+ ", shortName=" + shortName + ", traceabilityFlag=" + ", shortName=" + shortName + ", traceabilityFlag="
+ traceabilityFlag + ", status=" + status + ", systemType=" + traceabilityFlag + ", sdgFlag=" + sdgFlag + ", status="
+ systemType + ", catches=" + catches + ", landings=" + status + ", systemType=" + systemType + ", catches="
+ landings + ", species=" + species + ", similarGRSFRecords=" + catches + ", landings=" + landings + ", species=" + species
+ similarGRSFRecords + ", similarSourceRecords=" + ", similarGRSFRecords=" + similarGRSFRecords
+ similarSourceRecords + ", domain=" + domain + ", uuid=" + ", similarSourceRecords=" + similarSourceRecords
+ uuid + ", managementBodyAuthorities=" + ", domain=" + domain + ", uuid=" + uuid
+ managementBodyAuthorities + ", spatial=" + spatial + ", managementBodyAuthorities=" + managementBodyAuthorities
+ ", connectedBeans=" + connectedBeans + ", annotations=" + ", spatial=" + spatial + ", connectedBeans=" + connectedBeans
+ annotations + "]"; + ", annotations=" + annotations + "]";
} }
} }

View File

@ -173,7 +173,7 @@ public class StockRecord extends Common{
} }
public void setStockId(String stockId) { public void setStockId(String stockId) {
this.stockId = stockId;//super.cleanSemanticId(stockId); this.stockId = stockId;
} }
public List<String> getArea() { public List<String> getArea() {

View File

@ -29,7 +29,6 @@ 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.custom_annotations.Tag;
import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.Resource; import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.Resource;
import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.TimeSeriesBean; import org.gcube.data_catalogue.grsf_publish_ws.json.input.others.TimeSeriesBean;
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.FisheryRecord;
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.StockRecord; import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.StockRecord;
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods; import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
@ -379,38 +378,6 @@ public class JTests {
} }
//@Test
public void fatherGroupAnnotation(){
Common commonRecord = new Common();
commonRecord.setStatus(Status.Approved);
commonRecord.getStatus();
Class<?> current = commonRecord.getClass();
do{
Field[] fields = current.getDeclaredFields();
for (Field field : fields) {
if(field.isAnnotationPresent(Group.class)){
logger.debug("Field is " + field.getType() + " and " + field.getType().isEnum());
// check if the field is an enumerator, and the enum class is also annotated with @Group
if(field.getClass().isEnum() && field.getClass().isAnnotationPresent(Group.class)){
// extract the name from the enum class and add it to the groups
// also convert to the group name that should be on ckan
String groupName = HelperMethods.getGroupNameOnCkan(field.getClass().getSimpleName());
logger.debug("Name is " +groupName );
}
}
}
}
while((current = current.getSuperclass())!=null); // start from the inherited class up to the Object.class
}
//@Test //@Test
public void testHierarchy() throws Exception{ public void testHierarchy() throws Exception{
String name = "low-abundance"; String name = "low-abundance";