task_24166 #11
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,7 +100,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-module deploy-name="geoportal-data-entry-app-3.2.0-SNAPSHOT">
|
<wb-module deploy-name="geoportal-data-entry-app-3.2.0-SNAPSHOT">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,7 +201,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,7 +302,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -399,7 +403,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -451,16 +456,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
<dependent-module archiveName="geoportal-data-mapper-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-mapper/geoportal-data-mapper">
|
|
||||||
<dependency-type>uses</dependency-type>
|
|
||||||
</dependent-module>
|
|
||||||
<dependent-module archiveName="metadata-profile-form-builder-widget-2.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/metadata-profile-form-builder-widget/metadata-profile-form-builder-widget">
|
|
||||||
<dependency-type>uses</dependency-type>
|
|
||||||
</dependent-module>
|
|
||||||
<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>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -560,7 +557,8 @@
|
||||||
|
|
||||||
|
|
||||||
<property name="context-root" value="geoportal-data-entry-app"/>
|
<property name="context-root" value="geoportal-data-entry-app"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -660,7 +658,8 @@
|
||||||
|
|
||||||
|
|
||||||
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
|
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -760,7 +759,8 @@
|
||||||
|
|
||||||
|
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ConstantsGeoPortalDataEntryApp {
|
||||||
|
|
||||||
public static final DateTimeFormat DATE_TIME_FORMAT = DateTimeFormat.getFormat("dd MMMM yyyy");
|
public static final DateTimeFormat DATE_TIME_FORMAT = DateTimeFormat.getFormat("dd MMMM yyyy");
|
||||||
|
|
||||||
public static final String ALERT_MESSAGE_PROJECT_NOT_EDITABLE = "A Project can only be edited/updated in "
|
public static final String ALERT_MESSAGE_PROJECT_NOT_EDITABLE = "A Project can only be updated in "
|
||||||
+ WORKFLOW_PHASE.DRAFT.name()
|
+ WORKFLOW_PHASE.DRAFT.name()
|
||||||
+ " phase. You need to perform the step 'Reject' or 'UnPublish' to take back the project in "
|
+ " phase. You need to perform the step 'Reject' or 'UnPublish' to take back the project in "
|
||||||
+ WORKFLOW_PHASE.DRAFT.name() + " phase.";
|
+ WORKFLOW_PHASE.DRAFT.name() + " phase.";
|
||||||
|
|
|
@ -1869,6 +1869,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
} else {
|
} else {
|
||||||
GWT.log("Instancing CreateMetadataForm with files");
|
GWT.log("Instancing CreateMetadataForm with files");
|
||||||
List<? extends FileUploaded> files = toListFileUploadedRemote(fileset);
|
List<? extends FileUploaded> files = toListFileUploadedRemote(fileset);
|
||||||
|
GWT.log("files are: "+files);
|
||||||
baseForm = new CreateMetadataForm(Arrays.asList(geoNaFormCardModel.getMetadataProfileBean()), appManagerBus,
|
baseForm = new CreateMetadataForm(Arrays.asList(geoNaFormCardModel.getMetadataProfileBean()), appManagerBus,
|
||||||
operation, files);
|
operation, files);
|
||||||
}
|
}
|
||||||
|
@ -1885,21 +1886,20 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
|
|
||||||
List<FileUploadedRemote> fileUploaded = new ArrayList<FileUploadedRemote>();
|
List<FileUploadedRemote> fileUploaded = new ArrayList<FileUploadedRemote>();
|
||||||
|
|
||||||
FilesetDV filesetDV = fileset.get(0);
|
for (FilesetDV filesetDV : fileset) {
|
||||||
|
GWT.log("filesetDV fieldName: "+filesetDV.getFilesetFieldName() + " profile: "+filesetDV.getGcubeProfileFieldName());
|
||||||
GWT.log("listFiles name: "+filesetDV.getGcubeProfileFieldName());
|
|
||||||
|
|
||||||
for (PayloadDV payload : filesetDV.getListPayload()) {
|
for (PayloadDV payload : filesetDV.getListPayload()) {
|
||||||
FileUploadedRemote fu = new FileUploadedRemote();
|
FileUploadedRemote fu = new FileUploadedRemote();
|
||||||
fu.setFileName(payload.getName());
|
fu.setFileName(payload.getName());
|
||||||
fu.setUrl(payload.getLink());
|
fu.setUrl(payload.getLink());
|
||||||
fu.setMimeType(payload.getMimetype());
|
fu.setMimeType(payload.getMimetype());
|
||||||
//adding FilePath according to spefic file registred in the UCD
|
//adding FilePath according to spefic file registred in the UCD
|
||||||
FilePath filePath = new FilePath(filesetDV.getGcubeProfileFieldName(), filesetDV.getFilesetFieldName());
|
FilePath filePath = new FilePath(filesetDV.getGcubeProfileFieldName(), filesetDV.getFilesetFieldName());
|
||||||
fu.setFilePath(filePath);
|
fu.setFilePath(filePath);
|
||||||
fileUploaded.add(fu);
|
fileUploaded.add(fu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fileUploaded;
|
return fileUploaded;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,6 +242,8 @@ public class UpdateRecord extends Composite {
|
||||||
htmlMsg += "<ul>";
|
htmlMsg += "<ul>";
|
||||||
htmlMsg += "<li>id: " + projectID + "</li>";
|
htmlMsg += "<li>id: " + projectID + "</li>";
|
||||||
htmlMsg += "<li>profile: " + profileID + "</li>";
|
htmlMsg += "<li>profile: " + profileID + "</li>";
|
||||||
|
htmlMsg += "<li>" + theDocument.getFirstEntryOfMap().getKey() + ": "
|
||||||
|
+ theDocument.getFirstEntryOfMap().getValue() + "</li>";
|
||||||
htmlMsg += "</ul>";
|
htmlMsg += "</ul>";
|
||||||
htmlMsg += "<br>";
|
htmlMsg += "<br>";
|
||||||
panelContainer.add(new HTML(htmlMsg));
|
panelContainer.add(new HTML(htmlMsg));
|
||||||
|
@ -280,9 +282,11 @@ public class UpdateRecord extends Composite {
|
||||||
htmlMsg += "<ul>";
|
htmlMsg += "<ul>";
|
||||||
htmlMsg += "<li>id: " + projectID + "</li>";
|
htmlMsg += "<li>id: " + projectID + "</li>";
|
||||||
htmlMsg += "<li>profile: " + profileID + "</li>";
|
htmlMsg += "<li>profile: " + profileID + "</li>";
|
||||||
|
htmlMsg += "<li>" + theDocument.getFirstEntryOfMap().getKey() + ": "
|
||||||
|
+ theDocument.getFirstEntryOfMap().getValue() + "</li>";
|
||||||
htmlMsg += "</ul>";
|
htmlMsg += "</ul>";
|
||||||
htmlMsg += "<br>";
|
htmlMsg += "<br>";
|
||||||
htmlMsg += "has been updated correctly!";
|
htmlMsg += "has been updated successfully!";
|
||||||
alert.setHTML(htmlMsg);
|
alert.setHTML(htmlMsg);
|
||||||
|
|
||||||
ReportTemplateToHTML rtth2 = new ReportTemplateToHTML("Project", result.getProjectAsJSON(),
|
ReportTemplateToHTML rtth2 = new ReportTemplateToHTML("Project", result.getProjectAsJSON(),
|
||||||
|
|
|
@ -237,41 +237,65 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
LOG.info("and sectionPath {}", sectionPath);
|
LOG.info("and sectionPath {}", sectionPath);
|
||||||
LOG.info("and listFilePaths {}", listFilePaths);
|
LOG.info("and listFilePaths {}", listFilePaths);
|
||||||
|
|
||||||
|
ProjectsCaller client = null;
|
||||||
|
Project currentProject = null;
|
||||||
|
JSONObject updatedSectionObject = null;
|
||||||
|
Configuration configurationGson = null;
|
||||||
|
GenericDatasetBean sectionBean = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
if (projectID == null)
|
||||||
|
throw new Exception("projectID is null");
|
||||||
|
|
||||||
|
if (profileID == null)
|
||||||
|
throw new Exception("profileID is null");
|
||||||
|
|
||||||
if (section == null || section.getListGDB() == null || section.getListGDB().get(0) == null)
|
if (section == null || section.getListGDB() == null || section.getListGDB().get(0) == null)
|
||||||
throw new Exception("Input error. The section is null");
|
throw new Exception("Input error. The section is null");
|
||||||
|
|
||||||
GenericDatasetBean sectionBean = section.getListGDB().get(0);
|
sectionBean = section.getListGDB().get(0);
|
||||||
|
|
||||||
// Converter
|
// Converter
|
||||||
FormDataObjectToJSON metadataConverter = new FormDataObjectToJSON();
|
FormDataObjectToJSON metadataConverter = new FormDataObjectToJSON();
|
||||||
// JSON Section to update converted as JSONObject
|
// JSON Section to update converted as JSONObject
|
||||||
JSONObject updatedSectionObject = metadataConverter.genericDatasetBeanToJSON(sectionBean);
|
updatedSectionObject = metadataConverter.genericDatasetBeanToJSON(sectionBean);
|
||||||
LOG.info("Input Json Section (to update): {}", updatedSectionObject.toString());
|
LOG.info("Input Json Section (to update): {}", updatedSectionObject.toString());
|
||||||
|
|
||||||
Configuration configurationGson = Configuration.builder().jsonProvider(new GsonJsonProvider()).build();
|
configurationGson = Configuration.builder().jsonProvider(new GsonJsonProvider()).build();
|
||||||
// Type type = new TypeToken<Set<LinkedTreeMap<String, Object>>>() {}.getType();
|
// Type type = new TypeToken<Set<LinkedTreeMap<String, Object>>>() {}.getType();
|
||||||
// Set<LinkedTreeMap<String, Object>> myMap = gson.fromJson(json, type);
|
// Set<LinkedTreeMap<String, Object>> myMap = gson.fromJson(json, type);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Error on converting form data: ", e);
|
||||||
|
throw new Exception(
|
||||||
|
"Error occurred on converting data, try again or contact the support. Error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
Boolean errorOccurred = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
client = GeoportalClientCaller.projects();
|
||||||
|
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||||
|
currentProject = client.getProjectByID(profileID, projectID);
|
||||||
|
Document currentDoc = currentProject.getTheDocument();
|
||||||
|
|
||||||
// Source Project
|
// Source Project
|
||||||
String theDocumentJson = getJSONDocumentInTheProject(profileID, projectID);
|
String theDocumentJson = currentDoc.toJson();
|
||||||
LOG.info("Source document: {}", theDocumentJson);
|
LOG.debug("Source document: {}", theDocumentJson);
|
||||||
|
|
||||||
// If the section path is the Root document, passed as "$.", fixing as "$"
|
// If the section path is the Root document, passed as "$.", fixing as "$"
|
||||||
if (sectionPath.compareTo(FormDataObjectToJSON.JSON_$_POINTER + ".") == 0)
|
if (sectionPath.compareTo(FormDataObjectToJSON.JSON_$_POINTER + ".") == 0)
|
||||||
sectionPath = FormDataObjectToJSON.JSON_$_POINTER;
|
sectionPath = FormDataObjectToJSON.JSON_$_POINTER;
|
||||||
|
|
||||||
ProjectsCaller client = GeoportalClientCaller.projects();
|
|
||||||
|
|
||||||
com.google.gson.JsonObject targetSectionJObject = JsonPath.parse(theDocumentJson, configurationGson)
|
com.google.gson.JsonObject targetSectionJObject = JsonPath.parse(theDocumentJson, configurationGson)
|
||||||
.read(sectionPath);
|
.read(sectionPath);
|
||||||
LOG.info("Current Section path {} in the Document is {}", sectionPath, targetSectionJObject.toString());
|
LOG.debug("Current Section path {} in the Document is {}", sectionPath, targetSectionJObject.toString());
|
||||||
String srcJ = updatedSectionObject.toString();
|
String srcJ = updatedSectionObject.toString();
|
||||||
String trgJ = targetSectionJObject.toString();
|
String trgJ = targetSectionJObject.toString();
|
||||||
LOG.info("Merging src {} in the target: {}", srcJ, trgJ);
|
LOG.debug("Merging src {} in the target: {}", srcJ, trgJ);
|
||||||
String mergedDoc = JsonMerge.merge(srcJ, trgJ, MERGE_OPTION.REPLACE);
|
String mergedDoc = JsonMerge.merge(srcJ, trgJ, MERGE_OPTION.REPLACE);
|
||||||
LOG.info("mergedDoc: {}", mergedDoc);
|
LOG.debug("mergedDoc: {}", mergedDoc);
|
||||||
|
|
||||||
String newDocJson;
|
String newDocJson;
|
||||||
// If Updating path is first level of the root
|
// If Updating path is first level of the root
|
||||||
|
@ -293,9 +317,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
Document updatedDocument = Serialization.read(newDocJson.toString(), Document.class);
|
Document updatedDocument = Serialization.read(newDocJson.toString(), Document.class);
|
||||||
LOG.info("New document is: {}", updatedDocument.toJson());
|
LOG.info("New document is: {}", updatedDocument.toJson());
|
||||||
|
|
||||||
Project project = client.updateProject(profileID, projectID, updatedDocument);
|
Project updatedProject = client.updateProject(profileID, projectID, updatedDocument);
|
||||||
// Project project = client.getProjectByID(profileID, projectID);
|
// Project project = client.getProjectByID(profileID, projectID);
|
||||||
LOG.debug("Medatata Updated with document: {}", project.getTheDocument());
|
LOG.debug("Medatata Updated with document: {}", updatedProject.getTheDocument());
|
||||||
|
|
||||||
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||||
|
|
||||||
|
@ -310,29 +334,44 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
filesetPath = filesetPath.replaceFirst("\\.", "..");
|
filesetPath = filesetPath.replaceFirst("\\.", "..");
|
||||||
LOG.info("Going to delete fileset path: {}", filesetPath);
|
LOG.info("Going to delete fileset path: {}", filesetPath);
|
||||||
try {
|
try {
|
||||||
client.deleteFileset(profileID, projectID, filesetPath, true);
|
client.deleteFileset(profileID, projectID, filesetPath, true, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.warn("Error on into project id {} the fileset path {} ", projectID, filesetPath);
|
LOG.warn("Error deleting the fileset path {} for the project {}", filesetPath, projectID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registering new files
|
// Registering new files
|
||||||
List<? extends FileUploaded> filesUploaded = sectionBean.getFilesUploaded();
|
List<? extends FileUploaded> filesUploaded = sectionBean.getFilesUploaded();
|
||||||
if (filesUploaded != null && !filesUploaded.isEmpty()) {
|
if (filesUploaded != null && !filesUploaded.isEmpty()) {
|
||||||
replaceFiles(project, sectionPath, section.getGcubeProfileDV(), filesUploaded);
|
replaceFiles(currentProject, sectionPath, section.getGcubeProfileDV(), filesUploaded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.info("Project with id " + project.getId() + " updated correclty");
|
LOG.info("Project with id " + currentProject.getId() + " updated correclty");
|
||||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||||
ProjectDV toProjectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
|
// Reading again the project to be sure
|
||||||
|
updatedProject = client.getProjectByID(profileID, projectID);
|
||||||
|
ProjectDV toProjectDV = ConvertToDataValueObjectModel.toProjectDV(updatedProject, projectBuilder);
|
||||||
String newDocumentString = toProjectDV.getTheDocument().getDocumentAsJSON();
|
String newDocumentString = toProjectDV.getTheDocument().getDocumentAsJSON();
|
||||||
LOG.info("Got Document: {} ", newDocumentString);
|
LOG.info("Got Document: {} ", newDocumentString);
|
||||||
return new CommitReport(projectID, profileID, newDocumentString, null);
|
return new CommitReport(projectID, profileID, newDocumentString, null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error on converting form data: ", e);
|
errorOccurred = true;
|
||||||
throw new Exception(
|
LOG.error("Error on updating data: ", e);
|
||||||
"Error occurred on converting data, try again or contact the support. Error: " + e.getMessage());
|
throw new Exception("Error occurred on updating data, try again or contact the support. Error: "
|
||||||
|
+ e.getMessage() + ". Tried to revert the project to the previous version");
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
// If an error occurs on updating, the previous version of the document will be
|
||||||
|
// restored
|
||||||
|
if (errorOccurred && currentProject != null) {
|
||||||
|
Document currentDocument = currentProject.getTheDocument();
|
||||||
|
try {
|
||||||
|
Project updatedProject = client.updateProject(profileID, projectID, currentDocument);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Silent
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class Complex_Tests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
public void testSectionPathRootParse() throws Exception {
|
public void testSectionPathRootParse() throws Exception {
|
||||||
String sectionPath = "$.";
|
String sectionPath = "$.";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue