in progress on update facility, #24166

This commit is contained in:
Francesco Mangiacrapa 2023-04-20 16:34:52 +02:00
parent 4a643d7423
commit 5c031270a0
6 changed files with 452 additions and 61 deletions

View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -96,7 +99,10 @@
<wb-module deploy-name="geoportal-data-entry-app-3.2.0-SNAPSHOT">
@ -193,7 +199,10 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -290,7 +299,10 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -387,7 +399,10 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -445,10 +460,10 @@
<dependent-module archiveName="geoportal-data-common-2.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="geoportal-client-1.1.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-client/geoportal-client">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -545,7 +560,10 @@
<property name="context-root" value="geoportal-data-entry-app"/>
@ -642,7 +660,10 @@
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
@ -739,7 +760,10 @@
</wb-module>

View File

@ -47,7 +47,7 @@ public class FormDataObjectToJSON {
// the root, instancing new json document
if (tree_Node.isRoot()) {
theRootDocument = JSONObjecOrdered.instance();
theRootDocument = JSONObjectOrdered.instance();
}
Configuration configuration = Configuration.builder().jsonProvider(new JsonOrgJsonProvider()).build();
@ -163,7 +163,7 @@ public class FormDataObjectToJSON {
*/
protected JSONObject genericDatasetBeanToJSON(GenericDatasetBean gdb) throws JSONException {
JSONObject sectJSONObject = JSONObjecOrdered.instance();
JSONObject sectJSONObject = JSONObjectOrdered.instance();
LinkedHashMap<String, List<String>> mapFields = gdb.getFormDataEntryFields();
LOG.debug("Map ordered: " + mapFields);
@ -246,7 +246,7 @@ public class FormDataObjectToJSON {
*
* Mar 10, 2022
*/
public static class JSONObjecOrdered {
public static class JSONObjectOrdered {
/**
* Instance.

View File

@ -5,7 +5,6 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.lang.reflect.Type;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
@ -18,7 +17,6 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
@ -67,7 +65,7 @@ import org.gcube.common.portal.PortalContext;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService;
import org.gcube.portlets.user.geoportaldataentry.client.ProjectFormCard;
import org.gcube.portlets.user.geoportaldataentry.server.FormDataObjectToJSON.JSONObjecOrdered;
import org.gcube.portlets.user.geoportaldataentry.server.json.JsonMerge;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedConfigProfile;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
@ -87,13 +85,13 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.internal.LinkedTreeMap;
import com.google.gson.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.spi.json.GsonJsonProvider;
import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
/**
* The server side implementation of the RPC service.
@ -248,46 +246,57 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
// Converter
FormDataObjectToJSON metadataConverter = new FormDataObjectToJSON();
// JSON Section to update converted as JSONObject
JSONObject jsonSectionObject = metadataConverter.genericDatasetBeanToJSON(sectionBean);
LOG.info("Json Section Object: {}", jsonSectionObject.toString());
Configuration configuration = Configuration.builder().jsonProvider(new GsonJsonProvider()).build();
JSONObject updatedSectionObject = metadataConverter.genericDatasetBeanToJSON(sectionBean);
LOG.info("Input Json Section (to update): {}", updatedSectionObject.toString());
Configuration configurationGson = Configuration.builder().jsonProvider(new GsonJsonProvider()).build();
// Type type = new TypeToken<Set<LinkedTreeMap<String, Object>>>() {}.getType();
// Set<LinkedTreeMap<String, Object>> myMap = gson.fromJson(json, type);
// Source Project
String jsonSourceProject = getJSONDocumentInTheProject(profileID, projectID);
LOG.info("Json source Object: {}", jsonSourceProject);
//If the section path is the Root document, passed as "$.", fixing as "$"
if(sectionPath.compareTo(FormDataObjectToJSON.JSON_$_POINTER+".")==0)
String theDocumentJson = getJSONDocumentInTheProject(profileID, projectID);
LOG.info("Source document: {}", theDocumentJson);
// If the section path is the Root document, passed as "$.", fixing as "$"
if (sectionPath.compareTo(FormDataObjectToJSON.JSON_$_POINTER + ".") == 0)
sectionPath = FormDataObjectToJSON.JSON_$_POINTER;
ProjectsCaller client = GeoportalClientCaller.projects();
JSONObject currentSectionJObject = JsonPath.parse(jsonSourceProject, configuration).read(sectionPath);
LOG.info("currentSectionJObject: {}", currentSectionJObject.toString());
com.google.gson.JsonObject targetSectionJObject = JsonPath.parse(theDocumentJson, configurationGson)
.read(sectionPath);
LOG.info("Current Section path {} in the Document is {}", sectionPath, targetSectionJObject.toString());
String srcJ = updatedSectionObject.toString();
String trgJ = targetSectionJObject.toString();
LOG.info("Merging src {} in the target: {}", srcJ, trgJ);
String mergedDoc = JsonMerge.merge(srcJ, trgJ);
LOG.info("mergedDoc: {}", mergedDoc);
// Merged section between updated and current
JSONObject mergedSection = JSONObjecOrdered.instance();
mergedSection = FormDataObjectToJSON.deepMerge(jsonSectionObject,
currentSectionJObject);
LOG.info("Merged section: {}", mergedSection.toString());
String newDocJson;
// If Updating path is first level of the root
if (sectionPath.equals(FormDataObjectToJSON.JSON_$_POINTER)) {
// The merged DOC is the root Document, no action required
newDocJson = mergedDoc;
} else {
// If the merged DOC is a child of the root Document, setting it as child of the
// Document in the proper section
Gson gson = new Gson();
JsonObject gsonOject = gson.fromJson(mergedDoc, JsonObject.class);
// Putting the merged section into Document
DocumentContext newContextDocJson = JsonPath.parse(theDocumentJson, configurationGson).set(sectionPath,
gsonOject);
newDocJson = newContextDocJson.json().toString();
// Putting the merged section into Document
Object newDocument = JsonPath.parse(jsonSourceProject, configuration).set(sectionPath, mergedSection)
.json();
String newDocumentString = newDocument.toString();
LOG.debug("Going to call updateProject with document: {}", newDocumentString);
}
Document updatedDocument = Serialization.read(newDocJson.toString(), Document.class);
LOG.info("New document is: {}", updatedDocument.toJson());
Document updatedDocument = Serialization.read(newDocumentString, Document.class);
Project project = client.updateProject(profileID, projectID, updatedDocument);
LOG.debug("Medatata Updated with document: {}", project.getTheDocument());
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
//Cleaning all the fileset path of the section (defined in the UCD)
for (FilePathDV filePath: listFilePaths) {
@ -308,7 +317,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
LOG.info("Project with id " + project.getId() + " updated correclty");
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
ProjectDV toProjectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
newDocumentString = toProjectDV.getTheDocument().getDocumentAsJSON();
String newDocumentString = toProjectDV.getTheDocument().getDocumentAsJSON();
LOG.info("Got Document: {} ", newDocumentString);
return new CommitReport(projectID, profileID, newDocumentString, null);
} catch (Exception e) {
@ -526,7 +535,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
input = new File(file.getTempSystemPath());
output = new File(tmpDirPath, file.getFileName());
copyContent(input, output);
LOG.info("Temp file: " + file.getTempSystemPath() + ", copied to new file: " + output.getName());
LOG.info(
"Temp file: " + file.getTempSystemPath() + ", copied to new file: " + output.getName());
}
collFieldDef.addFile(output);
@ -551,10 +561,10 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
File[] fileset = uploadedFileset.getFileset();
FilePathDV filePath = uploadedFileset.getFilePathDV();
Access access = ConvertToDataServiceModel.getAccessFromDocumentSection(theJSONDocument, sectionJSONPath);
LOG.info("Going to registrer files: "+Arrays.asList(fileset).toString());
mongoService.registerFileSet(theProject.getProfileID(), theProject, sectionJSONPath,
filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset);
LOG.info("Going to registrer files: " + Arrays.asList(fileset).toString());
// mongoService.registerFileSet(theProject.getProfileID(), theProject, sectionJSONPath,
// filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset);
}
}

View File

@ -0,0 +1,188 @@
package org.gcube.portlets.user.geoportaldataentry.server.json;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
/**
* This class provides methods to merge two json of any nested level into a single json.
*
* copied from: https://github.com/hemantsonu20/json-merge
*/
public class JsonMerge {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
/**
* Method to merge two json objects into single json object.
*
* <p>It merges two json of any nested level into a single json following below logic.</p>
* <ul>
* <li>When keys are different, both keys with there values will be copied at same level.</li>
* <li>
* <p>When keys are same at some level, following table denotes what value will be used.</p>
* <table border="1" summary="">
* <thead>
* <tr>
* <th align="left">Src / Target</th>
* <th align="left">JSON Value</th>
* <th align="left">JSON Array</th>
* <th align="left">JSON Object</th>
* </tr>
* </thead>
* <tbody>
* <tr>
* <td align="left">JSON Value<sup>1</sup></td>
* <td align="left">Src</td>
* <td align="left">Src</td>
* <td align="left">Src</td>
* </tr>
* <tr>
* <td align="left">JSON Array</td>
* <td align="left">Src<sup>2</sup></td>
* <td align="left">Merge</td>
* <td align="left">Src</td>
* </tr>
* <tr>
* <td align="left">JSON Object</td>
* <td align="left">Src</td>
* <td align="left">Src</td>
* <td align="left">Merge<sup>3</sup></td>
* </tr>
* </tbody>
* </table>
* <ul>
* <li><sup><strong>1</strong></sup> Json Value denotes boolean, number or string value in json.</li>
* <li><sup><strong>2</strong></sup> Src denotes <code>Src</code> value will be copied.</li>
* <li><sup><strong>3</strong></sup> Merge denotes both <code>Src</code> and <code>Target</code> values will be merged.</li>
* </ul>
* </li>
* </ul>
*
* <h2>Examples</h2>
* <h3>Example 1</h3>
* <p><strong>Source Json</strong></p>
* <pre>{@code
* {
* "name": "json-merge-src"
* }
* }</pre>
* <p><strong>Target Json</strong></p>
* <pre>{@code
* {
* "name": "json-merge-target"
* }
* }</pre>
* <p><strong>Output</strong></p>
* <pre>{@code
* {
* "name": "json-merge-src"
* }
* }</pre>
* <h3>Example 2</h3>
* <p><strong>Source Json</strong></p>
* <pre>{@code
* {
* "level1": {
* "key1": "SrcValue1"
* }
* }
* }</pre>
* <p><strong>Target Json</strong></p>
* <pre>{@code
* {
* "level1": {
* "key1": "targetValue1",
* "level2": {
* "key2": "value2"
* }
* }
* }
* }</pre>
* <p><strong>Output</strong></p>
* <pre>{@code
* {
* "level1": {
* "key1": "SrcValue1",
* "level2": {
* "key2": "value2"
* }
* }
* }
* }</pre>
*
* @param srcJsonStr source json string
* @param targetJsonStr target json string
* @return merged json as a string
*/
public static String merge(String srcJsonStr, String targetJsonStr) {
try {
JsonNode srcNode = OBJECT_MAPPER.readTree(srcJsonStr);
JsonNode targetNode = OBJECT_MAPPER.readTree(targetJsonStr);
JsonNode result = merge(srcNode, targetNode);
return OBJECT_MAPPER.writeValueAsString(result);
} catch (IOException e) {
throw new JsonMergeException("Unable to merge json", e);
}
}
public static JsonNode merge(JsonNode srcNode, JsonNode targetNode) {
// if both nodes are object node, merged object node is returned
if (srcNode.isObject() && targetNode.isObject()) {
return merge((ObjectNode) srcNode, (ObjectNode) targetNode);
}
// if both nodes are array node, merged array node is returned
if (srcNode.isArray() && targetNode.isArray()) {
return merge((ArrayNode) srcNode, (ArrayNode) targetNode);
}
// special case when src node is null
if (srcNode.isNull()) {
return targetNode;
}
return srcNode;
}
public static ObjectNode merge(ObjectNode srcNode, ObjectNode targetNode) {
ObjectNode result = OBJECT_MAPPER.createObjectNode();
Iterator<Map.Entry<String, JsonNode>> srcItr = srcNode.fields();
while (srcItr.hasNext()) {
Map.Entry<String, JsonNode> entry = srcItr.next();
// check key in src json exists in target json or not at same level
if (targetNode.has(entry.getKey())) {
result.set(entry.getKey(), merge(entry.getValue(), targetNode.get(entry.getKey())));
} else {
// if key in src json doesn't exist in target json, just copy the same in result
result.set(entry.getKey(), entry.getValue());
}
}
// copy fields from target json into result which were missing in src json
Iterator<Map.Entry<String, JsonNode>> targetItr = targetNode.fields();
while (targetItr.hasNext()) {
Map.Entry<String, JsonNode> entry = targetItr.next();
if (!result.has(entry.getKey())) {
result.set(entry.getKey(), entry.getValue());
}
}
return result;
}
public static ArrayNode merge(ArrayNode srcNode, ArrayNode targetNode) {
ArrayNode result = OBJECT_MAPPER.createArrayNode();
return result.addAll(srcNode).addAll(targetNode);
}
}

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.user.geoportaldataentry.server.json;
/**
* Exception to be thrown in case of any error occured while merging two json.
*
*/
public class JsonMergeException extends RuntimeException {
public JsonMergeException() {
super();
}
public JsonMergeException(String msg) {
super(msg);
}
public JsonMergeException(String msg, Throwable th) {
super(msg, th);
}
}

View File

@ -1,9 +1,16 @@
package org.gcube.portlets.user.geoportaldataentry;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import org.bson.Document;
import org.gcube.application.geoportal.client.utils.Serialization;
@ -31,10 +38,15 @@ import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataentry.server.FormDataObjectToJSON;
import org.gcube.portlets.user.geoportaldataentry.server.FormDataObjectToJSON.JSONObjectOrdered;
import org.gcube.portlets.user.geoportaldataentry.server.json.JsonMerge;
import org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
@ -42,19 +54,29 @@ import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.spi.json.GsonJsonProvider;
import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
public class Complex_Tests {
private static final String GCUBE_CONFIG_PROPERTIES_FILENAME = "gcube_config.properties";
// APP Working Directory + /src/test/resources must be the location of
// gcube_config.properties
private static String gcube_config_path = String.format("%s/%s",
System.getProperty("user.dir") + "/src/test/resources", GCUBE_CONFIG_PROPERTIES_FILENAME);
private static String CONTEXT;
private static String TOKEN;
private UseCaseDescriptorCaller clientUCD = null;
private ProjectsCaller clientPrj = null;
private static String CONTEXT = "/gcube/devsec/devVRE";
private static String TOKEN = ""; // devVRE
private static String PROFILE_ID = "profiledConcessioni";
private static String PROJECT_ID = "632c633155e2947b0278c999";
private static String MY_LOGIN = "francesco.mangiacrapa";
@ -93,14 +115,141 @@ public class Complex_Tests {
}
}
/**
* Read context settings.
*/
public static void readContextSettings() {
//@Before
try (InputStream input = new FileInputStream(gcube_config_path)) {
Properties prop = new Properties();
// load a properties file
prop.load(input);
CONTEXT = prop.getProperty("CONTEXT");
TOKEN = prop.getProperty("TOKEN");
// get the property value and print it out
System.out.println("CONTEXT: " + CONTEXT);
System.out.println("TOKEN: " + TOKEN);
} catch (IOException ex) {
ex.printStackTrace();
}
}
@Before
public void init() {
readContextSettings();
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
clientPrj = GeoportalClientCaller.projects();
clientUCD = GeoportalClientCaller.useCaseDescriptors();
}
//@Test
public void testSectionPathInnerParse() throws Exception {
String sectionPath = "$.abstractRelazione";
String profileID = "profiledConcessioni";
String projectID = "6425598a8593b215a1281e1c";
Configuration configurationGSON = Configuration.builder().jsonProvider(new GsonJsonProvider()).build();
ProjectsCaller client = GeoportalClientCaller.projects();
Project proejct = client.getProjectByID(profileID, projectID);
String jsonSourceProject = proejct.getTheDocument().toJson();
//If the section path is the Root document, passed as "$.", fixing as "$"
if(sectionPath.compareTo(FormDataObjectToJSON.JSON_$_POINTER+".")==0)
sectionPath = FormDataObjectToJSON.JSON_$_POINTER;
LOG.info("theString: {}", jsonSourceProject);
com.google.gson.JsonObject currentSectionJObject = JsonPath.parse(jsonSourceProject, configurationGSON).read(sectionPath);
LOG.info("currentSectionJObject: {}", currentSectionJObject.toString());
LOG.info("sourceSectionObject: {}", currentSectionJObject.toString());
JSONObject targetSectionJObject = new JSONObjectOrdered().instance();
targetSectionJObject.put("abstractIta", "Prova REJECT 1");
targetSectionJObject.put("titolo", "Prova REJECT abstract relazione di scavo 1");
LOG.info("targetSectionJObject: {}", targetSectionJObject.toString());
String mergedDoc = JsonMerge.merge(targetSectionJObject.toString(), currentSectionJObject.toString());
LOG.info("output: {}", mergedDoc);
String newDocJson;
//Updating path is first level of the root
if(sectionPath.equals(FormDataObjectToJSON.JSON_$_POINTER)) {
//The merged DOC is the root Document
newDocJson = mergedDoc;
}else {
//The merged DOC is a child of the root Document
Gson gson = new Gson();
JsonObject gsonOject = gson.fromJson(mergedDoc, JsonObject.class);
// Putting the merged section into Document
DocumentContext newContextDocJson = JsonPath.parse(jsonSourceProject, configurationGSON).set(sectionPath, gsonOject);
newDocJson = newContextDocJson.json().toString();
}
Document updatedDocument = Serialization.read(newDocJson.toString(), Document.class);
LOG.info("New document is: {}", updatedDocument.toJson());
}
@Test
public void testSectionPathRootParse() throws Exception {
String sectionPath = "$.";
String profileID = "profiledConcessioni";
String projectID = "6425598a8593b215a1281e1c";
Configuration configurationGSON = Configuration.builder().jsonProvider(new GsonJsonProvider()).build();
ProjectsCaller client = GeoportalClientCaller.projects();
Project proejct = client.getProjectByID(profileID, projectID);
String jsonSourceProject = proejct.getTheDocument().toJson();
//If the section path is the Root document, passed as "$.", fixing as "$"
if(sectionPath.compareTo(FormDataObjectToJSON.JSON_$_POINTER+".")==0)
sectionPath = FormDataObjectToJSON.JSON_$_POINTER;
LOG.info("theString: {}", jsonSourceProject);
com.google.gson.JsonObject currentSectionJObject = JsonPath.parse(jsonSourceProject, configurationGSON).read(sectionPath);
LOG.info("currentSectionJObject: {}", currentSectionJObject.toString());
LOG.info("sourceSectionObject: {}", currentSectionJObject.toString());
JSONObject targetSectionJObject = new JSONObjectOrdered().instance();
targetSectionJObject.put("nome", proejct.getTheDocument().get("nome")+" 1");
targetSectionJObject.put("titolo", proejct.getTheDocument().get("introduzione")+ " 1");
LOG.info("targetSectionJObject: {}", targetSectionJObject.toString());
// JSONObject mergedSection = FormDataObjectToJSON.deepMerge(sourceSectionObject,
// targetSectionJObject);
String output = JsonMerge.merge(targetSectionJObject.toString(), currentSectionJObject.toString());
LOG.info("output: {}", output);
Gson gson = new Gson();
JsonObject gsonOject = gson.fromJson(output, JsonObject.class);
// Putting the merged section into Document
DocumentContext newContextDocJson = JsonPath.parse(jsonSourceProject, configurationGSON).set(sectionPath, gsonOject);
//DocumentContext newDocument = JsonPath.parse(jsonSourceProject, configurationGSON).set(sectionPath, new JSONObject(output));
//String newDocJson = JsonPath.parse(jsonSourceProject).set(sectionPath, new JSONObject(output)).jsonString();
String newDocJson = newContextDocJson.json().toString();
LOG.info("Going to call updateProject with document: {}", newDocJson);
Document updatedDocument = Serialization.read(newDocJson.toString(), Document.class);
LOG.info("New document is: {}", updatedDocument.toJson());
}
//@Before
public void preloadgCubeProfilesForUCDs() {
@ -295,7 +444,7 @@ public class Complex_Tests {
String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, filePath.getFieldName());
List<Payload> listPayloads = readPayloadsForFileset(filesetJSONPath, fromSectionDocJSON);
FilesetDV filesetDV = new FilesetDV();
filesetDV.setName(filePath.getGcubeProfileFieldName());
filesetDV.setGcubeProfileFieldName(filePath.getGcubeProfileFieldName());
for (Payload payload : listPayloads) {
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
filesetDV.addPayloadDV(payloadDV);
@ -330,7 +479,7 @@ public class Complex_Tests {
System.out.println("***** Files");
if (subDocument.getListFiles() != null) {
for (FilesetDV filesetDV : subDocument.getListFiles()) {
System.out.println("******* File Fileset name: " + filesetDV.getName());
System.out.println("******* File Fileset name: " + filesetDV.getGcubeProfileFieldName());
for (PayloadDV payload : filesetDV.getListPayload()) {
System.out.println("********* Payload: " + payload);
}
@ -339,7 +488,7 @@ public class Complex_Tests {
System.out.println("***** Images");
if (subDocument.getListImages() != null) {
for (FilesetDV filesetDV : subDocument.getListImages()) {
System.out.println("******* Image Fileset name: " + filesetDV.getName());
System.out.println("******* Image Fileset name: " + filesetDV.getGcubeProfileFieldName());
for (PayloadDV payload : filesetDV.getListPayload()) {
System.out.println("********* Payload: " + payload);
}