setCurrentValues as list (instead of single value)
This commit is contained in:
parent
4106aada7b
commit
0838dabf80
|
@ -232,11 +232,11 @@ public class Geoportal_JSON_Mapper {
|
|||
|
||||
if (access != null) {
|
||||
if (theFieldName.equalsIgnoreCase("policy")) {
|
||||
metadataField.setCurrentValue(access.getPolicy().name());
|
||||
metadataField.setCurrentValues(access.getPolicy().name());
|
||||
duplicatedList.add(metadataField);
|
||||
continue;
|
||||
} else if (theFieldName.equalsIgnoreCase("licenseID")) {
|
||||
metadataField.setCurrentValue(access.getLicense());
|
||||
metadataField.setCurrentValues(access.getLicense());
|
||||
duplicatedList.add(metadataField);
|
||||
continue;
|
||||
}
|
||||
|
@ -257,23 +257,34 @@ public class Geoportal_JSON_Mapper {
|
|||
for (int j = 0; j < dataArray.size(); j++) {
|
||||
List<MetadataFieldWrapper> cloned = cloneList(Arrays.asList(metadataField));
|
||||
MetadataFieldWrapper mfw = cloned.get(0);
|
||||
mfw.setCurrentValue(dataArray.get(j)+"");
|
||||
|
||||
// From the second repeated field settings
|
||||
// mandatory false and one instance
|
||||
// These properties are managed properly with the
|
||||
// first occurrence of the field
|
||||
if (j >= 1) {
|
||||
mfw.setMandatory(false);
|
||||
mfw.setMaxOccurs(1);
|
||||
|
||||
//Duplicating MetadataFieldWrapper for data list with isMultiSelection==false
|
||||
if(!mfw.isMultiSelection()) {
|
||||
mfw.setCurrentValues(dataArray.get(j)+"");
|
||||
// From the second repeated field settings
|
||||
// mandatory false and one instance
|
||||
// These properties are managed properly with the
|
||||
// first occurrence of the field
|
||||
if (j >= 1) {
|
||||
mfw.setMandatory(false);
|
||||
mfw.setMaxOccurs(1);
|
||||
}
|
||||
duplicatedList.add(mfw);
|
||||
}else {
|
||||
//Setting dataArray as list of current values when isMultiSelection is true
|
||||
String[] toArray = (String[]) dataArray.toArray(new String[0]);
|
||||
mfw.setCurrentValues(toArray);
|
||||
duplicatedList.add(mfw);
|
||||
//Exit from for
|
||||
break;
|
||||
}
|
||||
duplicatedList.add(mfw);
|
||||
}
|
||||
//Does not remove this
|
||||
continue;
|
||||
} catch (Exception e) {
|
||||
LOG.debug("It is not an Array");
|
||||
String theValue = theOBJFieldValue + "";
|
||||
metadataField.setCurrentValue(theValue);
|
||||
metadataField.setCurrentValues(theValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,7 +375,10 @@ public class Geoportal_JSON_Mapper {
|
|||
MetadataFieldWrapper newMfw = new MetadataFieldWrapper();
|
||||
newMfw.setAsGroup(mfw.getAsGroup());
|
||||
newMfw.setAsTag(mfw.getAsTag());
|
||||
newMfw.setCurrentValue(mfw.getCurrentValue());
|
||||
List<String> listValues = mfw.getCurrentValues();
|
||||
if(listValues!=null) {
|
||||
newMfw.setCurrentValues(listValues.stream().toArray(String[]::new));
|
||||
}
|
||||
newMfw.setDefaultValue(mfw.getDefaultValue());
|
||||
newMfw.setFieldId(mfw.getFieldId());
|
||||
newMfw.setFieldName(mfw.getFieldName());
|
||||
|
@ -1117,7 +1131,7 @@ public class Geoportal_JSON_Mapper {
|
|||
System.out.println("***** Metadata");
|
||||
// System.out.println(mfw);
|
||||
System.out.println("\tfieldId: " + fieldWrapper.getFieldId() + ", fieldName: "
|
||||
+ fieldWrapper.getFieldName() + ", CurrentValue: " + fieldWrapper.getCurrentValue());
|
||||
+ fieldWrapper.getFieldName() + ", CurrentValue: " + fieldWrapper.getCurrentValues());
|
||||
i++;
|
||||
}
|
||||
i = 1;
|
||||
|
|
|
@ -121,7 +121,10 @@ public class MetaDataProfileBeanExt extends MetaDataProfileBean implements Seria
|
|||
MetadataFieldWrapper newMfw = new MetadataFieldWrapper();
|
||||
newMfw.setAsGroup(mfw.getAsGroup());
|
||||
newMfw.setAsTag(mfw.getAsTag());
|
||||
newMfw.setCurrentValue(mfw.getCurrentValue());
|
||||
List<String> list = mfw.getCurrentValues();
|
||||
if(list!=null) {
|
||||
newMfw.setCurrentValues(list.stream().toArray(String[]::new));
|
||||
}
|
||||
newMfw.setDefaultValue(mfw.getDefaultValue());
|
||||
newMfw.setFieldId(mfw.getFieldId());
|
||||
newMfw.setFieldName(mfw.getFieldName());
|
||||
|
|
|
@ -39,8 +39,9 @@ public class Geoportal_DataMapper_Tests {
|
|||
private UseCaseDescriptorCaller clientUCD;
|
||||
private ProjectsCaller clientProjects;
|
||||
|
||||
private static String PROFILE_ID = "concessioni-estere";
|
||||
private static String PROJECT_ID = "6399de3ca0a4545420373251"; //63d011c4dcac4551b9a6b930
|
||||
//private static String PROFILE_ID = "concessioni-estere";
|
||||
private static String PROFILE_ID = "profiledConcessioni";
|
||||
private static String PROJECT_ID = "6442653ac6a0422d9e9042e0"; //63d011c4dcac4551b9a6b930 //6442653ac6a0422d9e9042e0 //6399de3ca0a4545420373251
|
||||
|
||||
private static String USERNAME = "francesco.mangiacrapa";
|
||||
|
||||
|
@ -85,7 +86,7 @@ public class Geoportal_DataMapper_Tests {
|
|||
/**
|
||||
* Test read project edit.
|
||||
*/
|
||||
@Test
|
||||
//@Test
|
||||
public void testReadProjectEdit() {
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue