diff --git a/CHANGELOG.md b/CHANGELOG.md
index 703fa54..f2ebf7b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-## [v1.2.0] - 2020-12-18
+## [v1.2.0-SNAPSHOT] - 2020-12-18
#### Enhancements
diff --git a/pom.xml b/pom.xml
index 2aa82a1..d42053b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,7 @@
org.gcube.portlets.user
geoportal-data-entry-app
war
- 1.2.0
+ 1.2.0-SNAPSHOT
GeoPortal Data Entry App
The GeoPortal Data Entry App is an application to build the web forms for data entries needed to GeoNa project
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java
index 9d16ab8..1a6ab2a 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java
@@ -15,6 +15,9 @@ import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFor
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaDataEntryMainForm;
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainPanel;
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
+import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML;
+import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil;
+import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
@@ -34,6 +37,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
/**
* Entry point classes define onModuleLoad()
.
@@ -76,7 +80,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
mainPanel = new GeonaMainPanel(appManagerBus);
mainPanel.setLoaderVisible("Loading...", true);
-
+
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback() {
@@ -216,7 +220,9 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modal.setCloseVisible(false);
modal.setTitle("Saving project...");
modal.hide(false);
- final HorizontalPanel modalContainerPanel = new HorizontalPanel();
+ modal.setWidth(600);
+ modal.setMaxHeigth("650px");
+ final VerticalPanel modalContainerPanel = new VerticalPanel();
final LoaderIcon loader = new LoaderIcon();
loader.setText("Trying to save the data, please wait...");
modalContainerPanel.add(loader);
@@ -244,63 +250,73 @@ public class GeoPortalDataEntryApp implements EntryPoint {
public void onSuccess(CommitReport result) {
modalContainerPanel.clear();
modal.setCloseVisible(true);
- Alert alert = new Alert(result.getMsg());
+ HTML recordPublished = new HTML();
switch (result.getState()) {
case OK:
- alert.setType(AlertType.SUCCESS);
+ String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, "SUCCESS");
+ recordPublished.setHTML("Record Published with "+success);
projectSavedWithSuccess = true;
- geoNaMainForm.showAlertOnSaveAction(result.getMsg(), AlertType.SUCCESS, true);
+ String msg = result.getMsg()!=null?result.getMsg():"Record published with success";
+ geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true);
purgeFileUploaded();
break;
case WARN:
- alert.setType(AlertType.WARNING);
+ String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, "WARNING");
+ recordPublished.setHTML("Record Published with "+warning);
geoNaMainForm.enableButtonSave(true);
- if(result.getReport()!=null)
- modal.add(new Alert(result.getReport(), AlertType.INFO));
break;
case ERROR:
- alert.setType(AlertType.ERROR);
+ String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", "ERROR");
+ recordPublished.setHTML(error+" on publishing the Record");
geoNaMainForm.enableButtonSave(true);
- if(result.getReport()!=null)
- modal.add(new Alert(result.getReport(), AlertType.INFO));
break;
default:
break;
}
- alert.setClose(false);
- modal.add(alert);
-
- try {
- savedMap.put(result.getRecordId(), saveGeonaDataFormsEvent.getListGeonaDataForms());
- }catch (Exception e) {
- // TODO: handle exception
+
+ modalContainerPanel.add(recordPublished);
+
+ if(result.getRecordId()!=null) {
+ modalContainerPanel.add(new HTML("Record id: "+(result.getRecordId())));
+
+ try {
+ savedMap.put(result.getRecordId(), saveGeonaDataFormsEvent.getListGeonaDataForms());
+ }catch (Exception e) {
+ // TODO: handle exception
+ }
+
+ final HorizontalPanel hpGetLink = new HorizontalPanel();
+ final LoaderIcon lc = new LoaderIcon("Get link...");
+ hpGetLink.add(lc);
+ modalContainerPanel.add(hpGetLink);
+ GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(result.getRecordId(), "concessione", new AsyncCallback() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ hpGetLink.clear();
+
+ }
+
+ @Override
+ public void onSuccess(GeoNaItemRef result) {
+ hpGetLink.clear();
+ String theURL = result.getRestrictedLink().getShortURL()!=null?result.getRestrictedLink().getShortURL():result.getRestrictedLink().getCompleteURL();
+ String htmlLink = "";
+ HTML html = new HTML(htmlLink);
+ hpGetLink.add(html);
+ //modal.add(html);
+ }
+ });
}
-
- final HorizontalPanel hpLoader = new HorizontalPanel();
- final LoaderIcon lc = new LoaderIcon("Get link...");
- hpLoader.add(lc);
- modal.add(hpLoader);
- GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(result.getRecordId(), "concessione", new AsyncCallback() {
-
- @Override
- public void onFailure(Throwable caught) {
- hpLoader.clear();
-
- }
-
- @Override
- public void onSuccess(GeoNaItemRef result) {
- hpLoader.clear();
- String htmlLink = "";
- HTML html = new HTML(htmlLink);
- modal.add(html);
- }
- });
//geoNaMainForm.enableButtonSave(true);
//resetUI();
+ if(result.getReport()!=null) {
+ modalContainerPanel.add(new ReportTemplateToHTML(result.getReport()));
+ }
+
}
});
@@ -336,6 +352,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
});
}
+
private void purgeFileUploaded() {
MetadataProfileFormBuilderServiceAsync.Util.getInstance().purgeFilesUploaded(new AsyncCallback() {
@@ -354,54 +371,6 @@ public class GeoPortalDataEntryApp implements EntryPoint {
});
}
- public static native String jsonToHTML(String jsonTxt)/*-{
- try
- {
- var jsonObj = JSON.parse(jsonTxt);
- if(jsonObj.length==undefined)
- jsonObj = [jsonObj]
- //console.log(jsonObj.length)
-
- // EXTRACT VALUE FOR HTML HEADER.
- var col = [];
- for (var i = 0; i < jsonObj.length; i++) {
- for (var key in jsonObj[i]) {
- //console.log('key json' +key)
- if (col.indexOf(key) === -1) {
- col.push(key);
- }
- }
- }
-
- // CREATE DYNAMIC TABLE.
- var table = document.createElement("table");
- try{
- table.classList.add("my-html-table");
-
- }catch(e){
- console.log('invalid css add', e);
- }
-
- // ADD JSON DATA TO THE TABLE AS ROWS.
- for (var i = 0; i < col.length; i++) {
- tr = table.insertRow(-1);
- var firstCell = tr.insertCell(-1);
- //firstCell.style.cssText="font-weight: bold; text-align: center; vertical-align: middle;";
- firstCell.innerHTML = col[i];
- for (var j = 0; j < jsonObj.length; j++) {
- var tabCell = tr.insertCell(-1);
- var theValue = jsonObj[j][col[i]];
- tabCell.innerHTML = theValue;
- }
- }
-
- return table;
- }
- catch(e){
- console.log('invalid json', e);
- }
-
- }-*/;
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java
new file mode 100644
index 0000000..fb017d1
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java
@@ -0,0 +1,172 @@
+package org.gcube.portlets.user.geoportaldataentry.client.ui.report;
+
+import com.github.gwtbootstrap.client.ui.Paragraph;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.json.client.JSONArray;
+import com.google.gwt.json.client.JSONObject;
+import com.google.gwt.json.client.JSONParser;
+import com.google.gwt.json.client.JSONValue;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+
+/**
+ * The Class ReportTemplateToHTML.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
+ *
+ * Jan 25, 2021
+ */
+public class ReportTemplateToHTML extends Composite {
+
+ private static ReportTemplateToHTMLUiBinder uiBinder = GWT.create(ReportTemplateToHTMLUiBinder.class);
+
+ /**
+ * The Interface ReportTemplateToHTMLUiBinder.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
+ *
+ * Jan 25, 2021
+ */
+ interface ReportTemplateToHTMLUiBinder extends UiBinder {
+ }
+
+ @UiField
+ VerticalPanel vpContainer;
+
+ @UiField
+ VerticalPanel htmlContainer;
+
+ @UiField
+ Paragraph reportJSON;
+
+ boolean toJSONERROR = false;
+
+ /**
+ * Instantiates a new report template to HTML.
+ *
+ * @param report the report
+ */
+ public ReportTemplateToHTML(String report) {
+ initWidget(uiBinder.createAndBindUi(this));
+ vpContainer.setVisible(false);
+ if (report != null) {
+ GWT.log("report is: " + report);
+ vpContainer.setVisible(true);
+
+ try {
+ JSONValue jsonObj = JSONParser.parse(report);
+ JSONObject json = (JSONObject) jsonObj;
+ JSONValue valueChildren = json.get("children");
+ JSONArray jsonChildren = (JSONArray) valueChildren;
+ /*JSONObject jsonChildrenObject = (JSONObject) jsonChildren.get(0);
+
+ if (jsonChildrenObject.containsKey("objectName")) {
+ JSONValue validationReportON = jsonChildrenObject.get("objectName");
+ String titleValue = HTMLUtil.getHTMLElement(HTML_TAG.div, 14, "000", "bold", validationReportON.toString());
+ htmlContainer.add(new HTML(titleValue));
+ }
+
+ String toTableHTML = jsonToHTML(jsonChildrenObject.get("children").toString());
+ GWT.log("toJSONERROR is: " + toJSONERROR);
+ GWT.log("toTableHTML is: " + toTableHTML);
+
+ Set keySet = jsonChildrenObject.keySet();*/
+
+ String toTableHTML = null;
+ for (int i=0; i";
+ }
+ tabCell.innerHTML = formattedValueArray;
+ }
+ else{
+ tabCell.innerHTML = theValue;
+ }
+ }
+ }
+
+ return table.outerHTML;
+ } catch (e) {
+ console.log('invalid json', e);
+ return jsonTxt;
+ }
+
+ }-*/;
+}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml
new file mode 100644
index 0000000..38beaaa
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml
@@ -0,0 +1,25 @@
+
+
+
+ .important {
+ font-weight: bold;
+ }
+
+ .margin-top-10 {
+ margin-top: 10px;
+ }
+
+
+
+ Publication Report:
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/HTMLUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/HTMLUtil.java
new file mode 100644
index 0000000..c598f98
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/HTMLUtil.java
@@ -0,0 +1,81 @@
+package org.gcube.portlets.user.geoportaldataentry.client.ui.utils;
+
+/**
+ * The Class HTMLUtil.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
+ *
+ * Jan 26, 2021
+ */
+public class HTMLUtil {
+
+ /**
+ * The Enum HTML_TAG.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
+ *
+ * Jan 26, 2021
+ */
+ public static enum HTML_TAG {
+ p, div, span
+ }
+
+ /**
+ * Gets the HTML element.
+ *
+ * @param tag the tag
+ * @param textSize the text size
+ * @param rgb the rgb
+ * @param fontWeight the font weight
+ * @param text the text
+ * @return the HTML element
+ */
+ public static String getHTMLElement(HTML_TAG tag, Integer textSize, String rgb, String fontWeight, String text) {
+ StringBuilder htmlEl = new StringBuilder();
+
+ if (textSize != null || rgb != null || fontWeight != null) {
+ String style = "";
+ if (textSize != null) {
+ style += "font-size:" + textSize + ";";
+ }
+ if (rgb != null) {
+ style += "color:#" + rgb + ";";
+ }
+ if (fontWeight != null) {
+ style += "font-weight:" + fontWeight + ";";
+ }
+ htmlEl.append("<" + tag.name() + " style='" + style + "'>");
+ } else {
+ htmlEl.append(tagOPEN(tag));
+ }
+
+ if (text != null) {
+ htmlEl.append(text);
+ }
+
+ htmlEl.append(tagCLosed(tag));
+
+ return htmlEl.toString();
+ }
+
+ /**
+ * Tag OPEN.
+ *
+ * @param tag the tag
+ * @return the string
+ */
+ public static String tagOPEN(HTML_TAG tag) {
+ return "<" + tag.name() + ">";
+ }
+
+ /**
+ * Tag C losed.
+ *
+ * @param tag the tag
+ * @return the string
+ */
+ public static String tagCLosed(HTML_TAG tag) {
+ return "" + tag.name() + ">";
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java
index 5ccc559..98d4bab 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java
@@ -95,6 +95,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
LOG.debug("Built " + ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO + " as server obj: " + concessione);
// saving into back-end
+ //SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
manager = ManagerFactory.registerNew(concessione);
// ABSTRACT_RELAZIONE_DI_SCAVO
diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css
index 75753a4..9a6b935 100644
--- a/src/main/webapp/GeoPortalDataEntryApp.css
+++ b/src/main/webapp/GeoPortalDataEntryApp.css
@@ -37,4 +37,19 @@ h1 {
.green-text a {
color: green !important;
+}
+
+.my-html-table {
+ padding: 5px;
+ margin-left:10px;
+ margin-bottom: 10px;
+}
+
+.my-html-table td {
+ padding: 5px;
+ border: 1px solid gray;
+}
+
+.my-html-table td:first-child {
+ color: gray;
}
\ No newline at end of file