geoportal-data-entry-app/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/BuildValidationReport.java

58 lines
1.8 KiB
Java

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);
}
}