minor fixes: added super.toString() to print common fields for fishery and stock. Added more junit tests
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@132959 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d665ab0d5a
commit
0d27ef2e17
|
@ -13,6 +13,6 @@ import java.lang.annotation.Target;
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
public @interface CustomField {
|
public @interface CustomField {
|
||||||
|
|
||||||
public String key() default ""; // this will be the key of the extras on ckan
|
public String key() default ""; // this will be the key of this custom field field on ckan
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class FisheryRecord extends Common{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FisheryRecord [fisheryName=" + fisheryName + ", fisheryId="
|
return "FisheryRecord [" + super.toString() + ", fisheryName=" + fisheryName + ", fisheryId="
|
||||||
+ fisheryId + ", scientificName=" + scientificName
|
+ fisheryId + ", scientificName=" + scientificName
|
||||||
+ ", fishingArea=" + fishingArea + ", exploitingStocks="
|
+ ", fishingArea=" + fishingArea + ", exploitingStocks="
|
||||||
+ exploitingStocks + ", managementEntity=" + managementEntity
|
+ exploitingStocks + ", managementEntity=" + managementEntity
|
||||||
|
@ -183,4 +183,5 @@ public class FisheryRecord extends Common{
|
||||||
+ "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ public class StockRecord extends Common{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "StockRecord [stockName=" + stockName + ", stockID=" + stockID
|
return "StockRecord [" + super.toString() + ", stockName=" + stockName + ", stockID=" + stockID
|
||||||
+ ", speciesScientificName=" + speciesScientificName
|
+ ", speciesScientificName=" + speciesScientificName
|
||||||
+ ", area=" + area + ", exploitingFishery=" + exploitingFishery
|
+ ", area=" + area + ", exploitingFishery=" + exploitingFishery
|
||||||
+ ", managementEntity=" + managementEntity
|
+ ", managementEntity=" + managementEntity
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.data_catalogue.grsf_publish_ws;
|
||||||
|
|
||||||
import java.beans.IntrospectionException;
|
import java.beans.IntrospectionException;
|
||||||
import java.beans.PropertyDescriptor;
|
import java.beans.PropertyDescriptor;
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -18,6 +19,8 @@ import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Source;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Status;
|
||||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type;
|
import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Type;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
public class JTests {
|
public class JTests {
|
||||||
|
|
||||||
//@Test
|
//@Test
|
||||||
|
@ -99,4 +102,29 @@ public class JTests {
|
||||||
System.out.println(res.name());
|
System.out.println(res.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@Test
|
||||||
|
public void testJSONMapping() throws IOException{
|
||||||
|
|
||||||
|
FisheryRecord recordFishery = new FisheryRecord();
|
||||||
|
recordFishery.setType(Type.Fishing_Description);
|
||||||
|
recordFishery.setDatabaseSources(Source.FIRMS);
|
||||||
|
recordFishery.setStatus(Status.Pending);
|
||||||
|
recordFishery.setVersion(new Long(10));
|
||||||
|
HashMap<String, String> extras = new HashMap<String, String>();
|
||||||
|
extras.put("test1", "testValue");
|
||||||
|
extras.put("test2", "test2Value");
|
||||||
|
recordFishery.setProperties(extras);
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
|
//Object to JSON in String
|
||||||
|
String jsonInString = mapper.writeValueAsString(recordFishery);
|
||||||
|
|
||||||
|
System.out.println(jsonInString);
|
||||||
|
|
||||||
|
FisheryRecord converted = mapper.readValue(jsonInString, recordFishery.getClass());
|
||||||
|
|
||||||
|
System.out.println(converted);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue