#22002 Integrated with ValidationReport and status

This commit is contained in:
Francesco Mangiacrapa 2021-09-14 13:08:55 +02:00
parent 2208adec46
commit 296703f5fb
11 changed files with 222 additions and 197 deletions

View File

@ -13,6 +13,7 @@ Moved to maven-portal-bom 3.6.3
[#21856] Implementing new user feedback [#21856] Implementing new user feedback
[#21890] Passed to mongoID [#21890] Passed to mongoID
[#20599] Get List of Records [#20599] Get List of Records
[#22002] Integrated with ValidationReport and status
## [v1.2.0] - 2020-12-18 ## [v1.2.0] - 2020-12-18

View File

@ -38,7 +38,7 @@ public class ConstantsGeoPortalDataEntryApp {
* Aug 6, 2021 * Aug 6, 2021
*/ */
public enum ACTION_ON_ITEM { public enum ACTION_ON_ITEM {
SHOW_ON_MAP, SHOW_METADATA, REMOVE SHOW_ON_MAP, SHOW_METADATA, SHOW_REPORT, REMOVE
} }
/** /**
@ -50,7 +50,7 @@ public class ConstantsGeoPortalDataEntryApp {
*/ */
public static enum RECORD_FIELD { public static enum RECORD_FIELD {
NAME("name", "Name"), INTRODUCTION("introduction", "Introduction"), AUTHOR("author", "Author/s"), NAME("name", "Name"), INTRODUCTION("introduction", "Introduction"), AUTHOR("author", "Author/s"),
PROJECT_START_END_DATE("", "Project Start/End Date"), CREATED("created", "Created"), PROJECT_START_END_DATE("", "Project Start/End Date"), PUBLISHING_STATUS("publishingStatus", "Publishing Status"), CREATED("created", "Created"),
CREATED_BY("createdBy", "Created by"); CREATED_BY("createdBy", "Created by");
String jsonFieldName; String jsonFieldName;
@ -60,17 +60,17 @@ public class ConstantsGeoPortalDataEntryApp {
* Instantiates a new record field. * Instantiates a new record field.
* *
* @param jsonFieldName the json field name * @param jsonFieldName the json field name
* @param displayName the display name * @param displayName the display name
*/ */
RECORD_FIELD(String jsonFieldName, String displayName) { RECORD_FIELD(String jsonFieldName, String displayName) {
this.jsonFieldName = jsonFieldName; this.jsonFieldName = jsonFieldName;
this.displayName = displayName; this.displayName = displayName;
} }
public String getJsonFieldName() { public String getJsonFieldName() {
return jsonFieldName; return jsonFieldName;
} }
public String getDisplayName() { public String getDisplayName() {
return displayName; return displayName;
} }

View File

@ -9,6 +9,7 @@ import java.util.TreeMap;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
@ -24,6 +25,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainTabPanel;
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginatedView; import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginatedView;
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel; import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
import org.gcube.portlets.user.geoportaldataentry.client.ui.report.BuildValidationReport;
import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML; import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil;
@ -278,18 +280,18 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modalContainerPanel.clear(); modalContainerPanel.clear();
modal.setCloseVisible(true); modal.setCloseVisible(true);
HTML recordPublished = new HTML(); HTML recordPublished = new HTML();
switch (result.getState()) { ValidationReportDV vr = result.getValidationReportDV();
case OK: switch (vr.getStatus()) {
case PASSED:
String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null,
"SUCCESS"); "SUCCESS");
recordPublished.setHTML("Record Published with " + success); recordPublished.setHTML("Record Published with " + success);
projectSavedWithSuccess = true; projectSavedWithSuccess = true;
String msg = result.getMsg() != null ? result.getMsg() String msg = "Record published with success";
: "Record published with success";
geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true); geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true);
purgeFileUploaded(); purgeFileUploaded();
break; break;
case WARN: case WARNING:
String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null,
"WARNING"); "WARNING");
recordPublished.setHTML("Record Published with " + warning); recordPublished.setHTML("Record Published with " + warning);
@ -349,8 +351,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
// geoNaMainForm.enableButtonSave(true); // geoNaMainForm.enableButtonSave(true);
// resetUI(); // resetUI();
if (result.getReport() != null) { if (vr.getAsJSONString() != null) {
modalContainerPanel.add(new ReportTemplateToHTML(result.getReport())); modalContainerPanel.add(new ReportTemplateToHTML(vr.getAsJSONString()));
} }
} }
@ -426,9 +428,10 @@ public class GeoPortalDataEntryApp implements EntryPoint {
final Modal modal = new Modal(true, true); final Modal modal = new Modal(true, true);
modal.setCloseVisible(true); modal.setCloseVisible(true);
final HorizontalPanel hpGetLink = new HorizontalPanel(); final HorizontalPanel hpGetLink = new HorizontalPanel();
final LoaderIcon lc = new LoaderIcon("Get link..."); final LoaderIcon lc = new LoaderIcon("Just moment getting link...");
hpGetLink.add(lc); hpGetLink.add(lc);
modal.add(hpGetLink); modal.add(hpGetLink);
final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", ""); final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", "");
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(), GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(),
@ -454,6 +457,21 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modal.show(); modal.show();
break;
case SHOW_REPORT:
final Modal modal2 = new Modal(true, true);
modal2.setWidth(800);
modal2.setCloseVisible(true);
if (concessione.getValidationReport() == null) {
modal2.add(new HTML("No report available for: "+concessione.getNome()));
} else {
BuildValidationReport buildValidationReport = new BuildValidationReport(
concessione.getValidationReport());
modal2.add(buildValidationReport);
}
modal2.show();
break; break;
case REMOVE: case REMOVE:

View File

@ -0,0 +1,57 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui.report;
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV.ValidationStatus;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
/**
* The Class BuildValidationReport.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Sep 14, 2021
*/
public class BuildValidationReport extends FlowPanel {
private HTML recordPublished = new HTML();
private ReportTemplateToHTML rTToHTML;
/**
* Instantiates a new builds the validation report.
*
* @param validationReport the validation report
*/
public BuildValidationReport(ValidationReportDV validationReport) {
if(validationReport==null)
return;
ValidationStatus status = validationReport.getStatus();
switch (status) {
case PASSED:
String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, "SUCCESS");
recordPublished.setHTML("Record Published with " + success);
break;
case WARNING:
String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, "WARNING");
recordPublished.setHTML("Record Published with " + warning);
break;
case ERROR:
String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", "ERROR");
recordPublished.setHTML(error + " on publishing the Record");
break;
default:
break;
}
rTToHTML = new ReportTemplateToHTML(validationReport.getAsJSONString());
add(recordPublished);
add(rTToHTML);
}
}

View File

@ -13,13 +13,12 @@ import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
/** /**
* The Class ReportTemplateToHTML. * The Class ReportTemplateToHTML.
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Jan 25, 2021 * Jan 25, 2021
*/ */
public class ReportTemplateToHTML extends Composite { public class ReportTemplateToHTML extends Composite {
@ -30,7 +29,7 @@ public class ReportTemplateToHTML extends Composite {
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Jan 25, 2021 * Jan 25, 2021
*/ */
interface ReportTemplateToHTMLUiBinder extends UiBinder<Widget, ReportTemplateToHTML> { interface ReportTemplateToHTMLUiBinder extends UiBinder<Widget, ReportTemplateToHTML> {
} }
@ -43,66 +42,54 @@ public class ReportTemplateToHTML extends Composite {
@UiField @UiField
Paragraph reportJSON; Paragraph reportJSON;
boolean toJSONERROR = false; boolean toJSONERROR = false;
/** /**
* Instantiates a new report template to HTML. * Instantiates a new report template to HTML.
* *
* @param report the report * @param reportAsJSON the report as JSON
*/ */
public ReportTemplateToHTML(String report) { public ReportTemplateToHTML(String reportAsJSON) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
vpContainer.setVisible(false); vpContainer.setVisible(false);
if (report != null) { if (reportAsJSON != null) {
GWT.log("report is: " + report); GWT.log("report is: " + reportAsJSON);
vpContainer.setVisible(true); vpContainer.setVisible(true);
try { try {
JSONValue jsonObj = JSONParser.parse(report); JSONValue jsonObj = JSONParser.parse(reportAsJSON);
JSONObject json = (JSONObject) jsonObj; JSONObject json = (JSONObject) jsonObj;
JSONValue valueChildren = json.get("children"); JSONValue valueChildren = json.get("children");
JSONArray jsonChildren = (JSONArray) valueChildren; 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<String> keySet = jsonChildrenObject.keySet();*/
String toTableHTML = null; String toTableHTML = null;
for (int i=0; i<jsonChildren.size(); i++) { for (int i = 0; i < jsonChildren.size(); i++) {
JSONObject jsO = (JSONObject) jsonChildren.get(i); JSONObject jsO = (JSONObject) jsonChildren.get(i);
if (jsO.containsKey("children")) { if (jsO.containsKey("children")) {
/*if (jsO.containsKey("objectName")) {
JSONValue validationReportON = jsO.get("objectName");
String titleValue = HTMLUtil.getHTMLElement(HTML_TAG.div, 14, "000", "bold", validationReportON.toString());
htmlContainer.add(new HTML(titleValue));
}*/
toTableHTML = jsonToHTML(jsO.get("children").toString()); toTableHTML = jsonToHTML(jsO.get("children").toString());
}else { } else {
toTableHTML = jsonToHTML(jsO.toString()); toTableHTML = jsonToHTML(jsO.toString());
} }
htmlContainer.add(new HTML(toTableHTML)); htmlContainer.add(new HTML(toTableHTML));
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
GWT.log("error: " + e.getMessage()); GWT.log("error: " + e.getMessage());
} }
reportJSON.setText(report); reportJSON.add(new HTML("<pre>" + toPrettyPrintJSON(reportAsJSON) + "</pre>"));
} }
} }
public static native String toPrettyPrintJSON(String jsonData)/*-{
console.log(jsonData);
var objJSON = JSON.parse(jsonData);
return $wnd.prettyPrintJson.toHtml(objJSON);
}-*/;
/** /**
* Json to HTML. * Json to HTML.
* *
@ -147,16 +134,15 @@ public class ReportTemplateToHTML extends Composite {
var tabCell = tr.insertCell(-1); var tabCell = tr.insertCell(-1);
var theValue = jsonObj[j][col[i]]; var theValue = jsonObj[j][col[i]];
//console.log("the value: "+theValue); //console.log("the value: "+theValue);
if(Object.prototype.toString.call(theValue) === '[object Array]'){ if (Object.prototype.toString.call(theValue) === '[object Array]') {
var formattedValueArray = ""; var formattedValueArray = "";
for(var k = 0; k < theValue.length; k++) { for (var k = 0; k < theValue.length; k++) {
var theValueArray = theValue[k]; var theValueArray = theValue[k];
//console.log(theValueArray); //console.log(theValueArray);
formattedValueArray += theValueArray+"<br>"; formattedValueArray += theValueArray + "<br>";
} }
tabCell.innerHTML = formattedValueArray; tabCell.innerHTML = formattedValueArray;
} } else {
else{
tabCell.innerHTML = theValue; tabCell.innerHTML = theValue;
} }
} }

View File

@ -15,7 +15,8 @@
<g:VerticalPanel ui:field="vpContainer" <g:VerticalPanel ui:field="vpContainer"
addStyleNames="{style.margin-top-10}"> addStyleNames="{style.margin-top-10}">
<b:Label>Publication Report: </b:Label> <b:Label>Publication Report: </b:Label>
<g:VerticalPanel ui:field="htmlContainer" addStyleNames="{style.margin-top-10}"></g:VerticalPanel> <g:VerticalPanel ui:field="htmlContainer"
addStyleNames="{style.margin-top-10}"></g:VerticalPanel>
<b:AccordionGroup heading="Show Report as JSON"> <b:AccordionGroup heading="Show Report as JSON">
<b:Paragraph ui:field="reportJSON"></b:Paragraph> <b:Paragraph ui:field="reportJSON"></b:Paragraph>
</b:AccordionGroup> </b:AccordionGroup>

View File

@ -12,6 +12,7 @@ import java.util.Set;
import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD;
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
@ -62,6 +63,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
private List<RECORD_FIELD> displayFields; private List<RECORD_FIELD> displayFields;
private TextColumn<T> startEndProjectColumn; private TextColumn<T> startEndProjectColumn;
private TextColumn<T> statusColumn;
// private Column<T, Date> startProjectDateColumn; // private Column<T, Date> startProjectDateColumn;
// private Column<T, Date> endProjectDateColumn; // private Column<T, Date> endProjectDateColumn;
private boolean isAsyncronusTable; private boolean isAsyncronusTable;
@ -219,7 +221,8 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
} }
}; };
sortedCellTable.addColumn(startEndProjectColumn, RECORD_FIELD.PROJECT_START_END_DATE.getDisplayName(), false); sortedCellTable.addColumn(startEndProjectColumn, RECORD_FIELD.PROJECT_START_END_DATE.getDisplayName(),
false);
sortedCellTable.setColumnWidth(startEndProjectColumn, 180, Unit.PX); sortedCellTable.setColumnWidth(startEndProjectColumn, 180, Unit.PX);
} }
@ -295,6 +298,26 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
sortedCellTable.setColumnWidth(insertedBy, 220, Unit.PX); sortedCellTable.setColumnWidth(insertedBy, 220, Unit.PX);
} }
if (this.displayFields.contains(RECORD_FIELD.PUBLISHING_STATUS)) {
statusColumn = new TextColumn<T>() {
@Override
public String getValue(T object) {
if (object == null)
return "";
ValidationReportDV vd = ((ConcessioneDV) object).getValidationReport();
if (vd != null)
return vd.getStatus().getLabel();
return "";
}
};
sortedCellTable.addColumn(statusColumn, RECORD_FIELD.PUBLISHING_STATUS.getDisplayName(), false);
sortedCellTable.setColumnWidth(statusColumn, 120, Unit.PX);
}
ButtonCell showOnMapButton = new ButtonCell(); ButtonCell showOnMapButton = new ButtonCell();
Column<T, String> showOnMapColumn = new Column<T, String>(showOnMapButton) { Column<T, String> showOnMapColumn = new Column<T, String>(showOnMapButton) {
public String getValue(T object) { public String getValue(T object) {
@ -310,7 +333,24 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
} }
}); });
sortedCellTable.addColumn(showOnMapColumn); sortedCellTable.addColumn(showOnMapColumn);
sortedCellTable.setColumnWidth(showOnMapColumn, 120, Unit.PX); sortedCellTable.setColumnWidth(showOnMapColumn, 110, Unit.PX);
ButtonCell showReportRecordButton = new ButtonCell();
Column<T, String> showReportRecordColumn = new Column<T, String>(showReportRecordButton) {
public String getValue(T object) {
return "P. Report";
}
};
showReportRecordColumn.setFieldUpdater(new FieldUpdater<T, String>() {
@Override
public void update(int index, T object, String value) {
eventBus.fireEvent(new ActionOnItemEvent<T>(Arrays.asList(object), ACTION_ON_ITEM.SHOW_REPORT));
}
});
sortedCellTable.addColumn(showReportRecordColumn);
sortedCellTable.setColumnWidth(showReportRecordColumn, 80, Unit.PX);
ButtonCell deleteRecordButton = new ButtonCell(); ButtonCell deleteRecordButton = new ButtonCell();
Column<T, String> deleteRecordColumn = new Column<T, String>(deleteRecordButton) { Column<T, String> deleteRecordColumn = new Column<T, String>(deleteRecordButton) {

View File

@ -4,7 +4,7 @@ import com.google.gwt.core.client.JavaScriptObject;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
* Sep 4, 2013 * Sep 4, 2013
* *
*/ */
public final class NewBrowserWindow extends JavaScriptObject { public final class NewBrowserWindow extends JavaScriptObject {
@ -13,9 +13,8 @@ public final class NewBrowserWindow extends JavaScriptObject {
protected NewBrowserWindow() { protected NewBrowserWindow() {
} }
public static native NewBrowserWindow open(String url, String target, public static native NewBrowserWindow open(String url, String target, String options) /*-{
String options) /*-{ return $wnd.open(url, target, options)
return $wnd.open(url, target, options);
}-*/; }-*/;
public native void close() /*-{ public native void close() /*-{

View File

@ -20,12 +20,12 @@ import org.gcube.application.geoportalcommon.GeoportalCommon;
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport.STATE;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData; import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData;
@ -228,7 +228,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
if (ardsFiles != null && ardsFiles.size() > 0) { if (ardsFiles != null && ardsFiles.size() > 0) {
// saving into back-end // saving into back-end
AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.RELAZIONE, ardsFiles); AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.RELAZIONE, ardsFiles);
clientMongo.registerFile(mongoId, request); clientMongo.registerFileSet(mongoId, request);
LOG.info("Registered the mongoId " + mongoId + " request " + Paths.RELAZIONE + "with " LOG.info("Registered the mongoId " + mongoId + " request " + Paths.RELAZIONE + "with "
+ ardsFiles.size() + " file/s"); + ardsFiles.size() + " file/s");
} }
@ -240,7 +240,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
if (files != null && files.size() > 0) { if (files != null && files.size() > 0) {
// saving into back-end // saving into back-end
AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.RELAZIONE, files); AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.RELAZIONE, files);
clientMongo.registerFile(mongoId, request); clientMongo.registerFileSet(mongoId, request);
LOG.info("Registered the mongoId " + mongoId + " request " + Paths.RELAZIONE + "with " + files.size() LOG.info("Registered the mongoId " + mongoId + " request " + Paths.RELAZIONE + "with " + files.size()
+ " file/s"); + " file/s");
} }
@ -258,7 +258,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
// saving into back-end // saving into back-end
AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.imgByIndex(i), AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.imgByIndex(i),
files); files);
clientMongo.registerFile(mongoId, request); clientMongo.registerFileSet(mongoId, request);
LOG.info("Registered the mongoId " + mongoId + " request " + Paths.IMMAGINI + "with " + files.size() LOG.info("Registered the mongoId " + mongoId + " request " + Paths.IMMAGINI + "with " + files.size()
+ " file/s"); + " file/s");
} }
@ -274,7 +274,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
// saving into back-end // saving into back-end
AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.POSIZIONAMENTO, AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.POSIZIONAMENTO,
files); files);
clientMongo.registerFile(mongoId, request); clientMongo.registerFileSet(mongoId, request);
LOG.info("Registered the mongoId " + mongoId + " request " + Paths.POSIZIONAMENTO + "with " LOG.info("Registered the mongoId " + mongoId + " request " + Paths.POSIZIONAMENTO + "with "
+ files.size() + " file/s"); + files.size() + " file/s");
} }
@ -291,7 +291,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
// saving into back-end // saving into back-end
AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest( AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(
Paths.piantaByIndex(i), files); Paths.piantaByIndex(i), files);
clientMongo.registerFile(mongoId, request); clientMongo.registerFileSet(mongoId, request);
LOG.info("Registered the mongoId " + mongoId + " request " + Paths.PIANTE + "with " LOG.info("Registered the mongoId " + mongoId + " request " + Paths.PIANTE + "with "
+ files.size() + " file/s"); + files.size() + " file/s");
} }
@ -314,34 +314,31 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
// server report // server report
ValidationReport report = concessione.getReport(); ValidationReport report = concessione.getReport();
LOG.info("ValidationReport: " + report); LOG.info("ValidationReport: " + report);
// to client // to client
CommitReport cRep = new CommitReport(); CommitReport cRep = new CommitReport();
// cRep.setRecordId(concessione.getId()); // cRep.setRecordId(concessione.getId());
cRep.setMongoId(concessione.getMongo_id()); cRep.setMongoId(concessione.getMongo_id());
String theJSON = serviceUtil.toJSON(report); ValidationReportDV vr = ConvertToDataViewModel.toValidationReport(report);
cRep.setReport(theJSON); cRep.setValidationReportDV(vr);
// switch (report.getStatus()) {
switch (report.getStatus()) { // case PASSED:
case PASSED: // if (cRep.getMongoId() == null) {
cRep.setState(STATE.OK); // LOG.error("The mongo id is null!!!");
if (cRep.getMongoId() == null) { // throw new Exception("Invalid identifier (mongoId is null) for the concessione");
LOG.error("The mongo id is null!!!"); // }
throw new Exception("Invalid identifier (mongoId is null) for the concessione"); // cRep.setMsg("OK");
} // break;
break; // case WARNING:
case WARNING: // cRep.setMsg(report.getWarningMessages().toString());
cRep.setState(STATE.WARN); // break;
cRep.setMsg(report.getWarningMessages().toString()); // case ERROR:
break; // cRep.setMsg(report.getErrorMessages().toString());
case ERROR: // break;
cRep.setState(STATE.ERROR); //
cRep.setMsg(report.getErrorMessages().toString()); // default:
break; // break;
// }
default:
cRep.setState(STATE.UNKNOWN);
break;
}
return cRep; return cRep;
} else } else
@ -405,7 +402,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
GeoNaDataViewerProfile grViewerProfile = SessionUtil.getGeportalViewerResourceProfile(getThreadLocalRequest()); GeoNaDataViewerProfile grViewerProfile = SessionUtil.getGeportalViewerResourceProfile(getThreadLocalRequest());
GeoportalCommon gc = new GeoportalCommon(grViewerProfile); GeoportalCommon gc = new GeoportalCommon(grViewerProfile);
GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toString().toLowerCase()); GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toString().toLowerCase());
item = gc.getPublicLinksFor(item); item = gc.getPublicLinksFor(item, false);
LOG.info("Returning: " + item); LOG.info("Returning: " + item);
return item; return item;
} }
@ -599,7 +596,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
} }
break; break;
//TODO is buggy must be performed by service // TODO is buggy must be performed by service
case PROJECT_START_END_DATE: case PROJECT_START_END_DATE:
if (order.equals(ORDER.ASC)) { if (order.equals(ORDER.ASC)) {
comparator = Comparator.comparing(Concessione::getDataInizioProgetto, comparator = Comparator.comparing(Concessione::getDataInizioProgetto,
@ -625,7 +622,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
List<ConcessioneDV> toReturnList = new ArrayList<ConcessioneDV>(toReturn.size()); List<ConcessioneDV> toReturnList = new ArrayList<ConcessioneDV>(toReturn.size());
for (Concessione concessione : toReturn) { for (Concessione concessione : toReturn) {
ConcessioneDV concessioneDV = ConvertToDataViewModel.toBaseConcessione(concessione); ConcessioneDV concessioneDV = ConvertToDataViewModel.toMetadataConcessione(concessione, true);
toReturnList.add(concessioneDV); toReturnList.add(concessioneDV);
} }

View File

@ -2,6 +2,8 @@ package org.gcube.portlets.user.geoportaldataentry.shared;
import java.io.Serializable; import java.io.Serializable;
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
/** /**
* The Class CommitReport. * The Class CommitReport.
* *
@ -16,22 +18,9 @@ public class CommitReport implements Serializable {
*/ */
private static final long serialVersionUID = -9519707669761939L; private static final long serialVersionUID = -9519707669761939L;
/**
* The Enum STATE.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 21, 2020
*/
public enum STATE {
ERROR, WARN, OK, UNKNOWN
}
public STATE state = STATE.UNKNOWN;
public Long recordId; public Long recordId;
public String mongoId; public String mongoId;
public String msg; public ValidationReportDV validationReportDV;
public String report;
/** /**
* Instantiates a new commit report. * Instantiates a new commit report.
@ -40,120 +29,48 @@ public class CommitReport implements Serializable {
} }
/** public CommitReport(Long recordId, String mongoId, ValidationReportDV validationReportDV) {
* Instantiates a new commit report.
*
* @param state the state
* @param recordId the record id
* @param mongoId the mongo id
* @param msg the msg
* @param report the report
*/
public CommitReport(STATE state, long recordId, String mongoId, String msg, String report) {
super(); super();
this.state = state; this.recordId = recordId;
this.mongoId = mongoId; this.mongoId = mongoId;
this.msg = msg; this.validationReportDV = validationReportDV;
this.report = report;
} }
/** public Long getRecordId() {
* Gets the state. return recordId;
*
* @return the state
*/
public STATE getState() {
return state;
}
/**
* Sets the state.
*
* @param state the new state
*/
public void setState(STATE state) {
this.state = state;
}
// /**
// * Gets the record id.
// *
// * @return the record id
// */
// public Long getRecordId() {
// return recordId;
// }
/**
* Gets the report.
*
* @return the report
*/
public String getReport() {
return report;
}
/**
* Sets the report.
*
* @param report the new report
*/
public void setReport(String report) {
this.report = report;
}
// /**
// * Sets the record id.
// *
// * @param recordId the new record id
// */
// public void setRecordId(long recordId) {
// this.recordId = recordId;
// }
/**
* Gets the msg.
*
* @return the msg
*/
public String getMsg() {
return msg;
} }
public String getMongoId() { public String getMongoId() {
return mongoId; return mongoId;
} }
public ValidationReportDV getValidationReportDV() {
return validationReportDV;
}
public void setRecordId(Long recordId) {
this.recordId = recordId;
}
public void setMongoId(String mongoId) { public void setMongoId(String mongoId) {
this.mongoId = mongoId; this.mongoId = mongoId;
} }
/** public void setValidationReportDV(ValidationReportDV validationReportDV) {
* Sets the msg. this.validationReportDV = validationReportDV;
*
* @param msg the new msg
*/
public void setMsg(String msg) {
this.msg = msg;
} }
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("CommitReport [state="); builder.append("CommitReport [recordId=");
builder.append(state);
builder.append(", recordId=");
builder.append(recordId); builder.append(recordId);
builder.append(", mongoId="); builder.append(", mongoId=");
builder.append(mongoId); builder.append(mongoId);
builder.append(", msg="); builder.append(", validationReportDV=");
builder.append(msg); builder.append(validationReportDV);
builder.append(", report=");
builder.append(report);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -14,6 +14,15 @@
<!-- --> <!-- -->
<link type="text/css" rel="stylesheet" href="GeoPortalDataEntryApp.css"> <link type="text/css" rel="stylesheet" href="GeoPortalDataEntryApp.css">
<link
href="//cdn.jsdelivr.net/npm/pretty-print-json@1.1/dist/pretty-print-json.css"
rel="stylesheet" type="text/css">
<script
src="//cdn.jsdelivr.net/npm/pretty-print-json@1.1/dist/pretty-print-json.min.js"
type="text/javascript"></script>
<!-- --> <!-- -->
<!-- Any title is fine --> <!-- Any title is fine -->
<!-- --> <!-- -->