fixing List casting from JsonArray
This commit is contained in:
parent
cc0a42b9ab
commit
4106aada7b
|
@ -134,7 +134,7 @@ public class Geoportal_JSON_Mapper {
|
||||||
|
|
||||||
GcubeProfileDV gcubeProfileDV = gcubeProfileMetaForUCD.getGcubeProfile();
|
GcubeProfileDV gcubeProfileDV = gcubeProfileMetaForUCD.getGcubeProfile();
|
||||||
LOG.info("\n\n##### Creating the section: " + gcubeProfileDV.getSectionTitle());
|
LOG.info("\n\n##### Creating the section: " + gcubeProfileDV.getSectionTitle());
|
||||||
LOG.info("\n\nThe profile is: " + gcubeProfileDV);
|
LOG.debug("\n\nThe profile is: " + gcubeProfileDV);
|
||||||
// Building JSON/section full PATH and section name
|
// Building JSON/section full PATH and section name
|
||||||
String sectionJSONPath = "";
|
String sectionJSONPath = "";
|
||||||
String parentPathFromProfile = gcubeProfileDV.getParentName() == null ? "" : gcubeProfileDV.getParentName();
|
String parentPathFromProfile = gcubeProfileDV.getParentName() == null ? "" : gcubeProfileDV.getParentName();
|
||||||
|
@ -248,14 +248,16 @@ public class Geoportal_JSON_Mapper {
|
||||||
// Converting multiple values stored as array (e.g. [a,b,c]) in multiple
|
// Converting multiple values stored as array (e.g. [a,b,c]) in multiple
|
||||||
// MetadataFieldWrapper
|
// MetadataFieldWrapper
|
||||||
// repeatable fields
|
// repeatable fields
|
||||||
LOG.debug("value " + theOBJFieldValue + " is instanceof Array");
|
LOG.trace("converting value " + theOBJFieldValue);
|
||||||
|
LOG.trace("converting class " + theOBJFieldValue.getClass());
|
||||||
try {
|
try {
|
||||||
JSONArray dataArray = new JSONArray(theOBJFieldValue + "");
|
|
||||||
LOG.debug("It is an Array");
|
LOG.debug("It is an Array");
|
||||||
for (int j = 0; j < dataArray.length(); j++) {
|
List dataArray = (List) theOBJFieldValue;
|
||||||
|
//printList(dataArray);
|
||||||
|
for (int j = 0; j < dataArray.size(); j++) {
|
||||||
List<MetadataFieldWrapper> cloned = cloneList(Arrays.asList(metadataField));
|
List<MetadataFieldWrapper> cloned = cloneList(Arrays.asList(metadataField));
|
||||||
MetadataFieldWrapper mfw = cloned.get(0);
|
MetadataFieldWrapper mfw = cloned.get(0);
|
||||||
mfw.setCurrentValue(dataArray.getString(j));
|
mfw.setCurrentValue(dataArray.get(j)+"");
|
||||||
|
|
||||||
// From the second repeated field settings
|
// From the second repeated field settings
|
||||||
// mandatory false and one instance
|
// mandatory false and one instance
|
||||||
|
@ -323,6 +325,30 @@ public class Geoportal_JSON_Mapper {
|
||||||
|
|
||||||
return projectEdit;
|
return projectEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void printArrayValue(JSONArray dataArray) {
|
||||||
|
if(dataArray==null)
|
||||||
|
System.out.println("dataArray is null");
|
||||||
|
|
||||||
|
for (int i =0; i<dataArray.length(); i++) {
|
||||||
|
try {
|
||||||
|
System.out.println("dataArray index "+i+" value "+dataArray.get(i));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printList(List dataArray) {
|
||||||
|
if(dataArray==null)
|
||||||
|
System.out.println("ArrayList is null");
|
||||||
|
|
||||||
|
for (int i =0; i<dataArray.size(); i++) {
|
||||||
|
System.out.println("ArrayList index "+i+" value "+dataArray.get(i));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone list.
|
* Clone list.
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class Geoportal_DataMapper_Tests {
|
||||||
private UseCaseDescriptorCaller clientUCD;
|
private UseCaseDescriptorCaller clientUCD;
|
||||||
private ProjectsCaller clientProjects;
|
private ProjectsCaller clientProjects;
|
||||||
|
|
||||||
private static String PROFILE_ID = "profiledConcessioni";
|
private static String PROFILE_ID = "concessioni-estere";
|
||||||
private static String PROJECT_ID = "642d4c6bc2133270c058eca8"; //63d011c4dcac4551b9a6b930
|
private static String PROJECT_ID = "6399de3ca0a4545420373251"; //63d011c4dcac4551b9a6b930
|
||||||
|
|
||||||
private static String USERNAME = "francesco.mangiacrapa";
|
private static String USERNAME = "francesco.mangiacrapa";
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class Geoportal_DataMapper_Tests {
|
||||||
/**
|
/**
|
||||||
* Test read project edit.
|
* Test read project edit.
|
||||||
*/
|
*/
|
||||||
//@Test
|
@Test
|
||||||
public void testReadProjectEdit() {
|
public void testReadProjectEdit() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue