customized rendering of table according to status

pull/4/head
Francesco Mangiacrapa 3 years ago
parent 296703f5fb
commit 8a74c1f0d0

@ -95,7 +95,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
public void onModuleLoad() { public void onModuleLoad() {
RECORD_FIELD[] sortByOptions = new RECORD_FIELD[] { RECORD_FIELD.NAME, RECORD_FIELD.PROJECT_START_END_DATE, RECORD_FIELD[] sortByOptions = new RECORD_FIELD[] { RECORD_FIELD.NAME, RECORD_FIELD.PROJECT_START_END_DATE,
RECORD_FIELD.CREATED, RECORD_FIELD.CREATED_BY }; RECORD_FIELD.CREATED, RECORD_FIELD.CREATED_BY, RECORD_FIELD.PUBLISHING_STATUS };
SortFilter initialSortFilter = new SortFilter(RECORD_FIELD.NAME, ORDER.ASC); SortFilter initialSortFilter = new SortFilter(RECORD_FIELD.NAME, ORDER.ASC);
@ -431,7 +431,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
final LoaderIcon lc = new LoaderIcon("Just moment getting 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(),
@ -464,7 +464,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modal2.setWidth(800); modal2.setWidth(800);
modal2.setCloseVisible(true); modal2.setCloseVisible(true);
if (concessione.getValidationReport() == null) { if (concessione.getValidationReport() == null) {
modal2.add(new HTML("No report available for: "+concessione.getNome())); modal2.add(new HTML("No report available for: " + concessione.getNome()));
} else { } else {
BuildValidationReport buildValidationReport = new BuildValidationReport( BuildValidationReport buildValidationReport = new BuildValidationReport(
concessione.getValidationReport()); concessione.getValidationReport());

@ -73,7 +73,7 @@ public abstract class AbstractItemsCellTable<T> {
sortedCellTable = new SortedCellTable<T>(pageSize, dataProvider); sortedCellTable = new SortedCellTable<T>(pageSize, dataProvider);
sortedCellTable.addStyleName("table-glor"); sortedCellTable.addStyleName("table-glor");
sortedCellTable.addStyleName("table-glor-vertical-middle"); sortedCellTable.addStyleName("table-glor-vertical-middle");
sortedCellTable.setStriped(true); //sortedCellTable.setStriped(true);
sortedCellTable.setCondensed(true); sortedCellTable.setCondensed(true);
sortedCellTable.setWidth("100%", true); sortedCellTable.setWidth("100%", true);
//sortedCellTable.setBordered(true); //sortedCellTable.setBordered(true);

@ -13,13 +13,16 @@ 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.application.geoportalcommon.shared.products.model.ValidationReportDV;
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV.ValidationStatus;
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;
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
import com.github.gwtbootstrap.client.ui.ButtonCell;
import com.github.gwtbootstrap.client.ui.Pagination; import com.github.gwtbootstrap.client.ui.Pagination;
import com.google.gwt.cell.client.ButtonCell; import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.cell.client.Cell.Context;
import com.google.gwt.cell.client.DateCell; import com.google.gwt.cell.client.DateCell;
import com.google.gwt.cell.client.FieldUpdater; import com.google.gwt.cell.client.FieldUpdater;
import com.google.gwt.core.shared.GWT; import com.google.gwt.core.shared.GWT;
@ -306,11 +309,30 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
if (object == null) if (object == null)
return ""; return "";
ValidationReportDV vd = ((ConcessioneDV) object).getValidationReport(); ValidationReportDV vr = ((ConcessioneDV) object).getValidationReport();
if (vd != null) if (vr != null && vr.getStatus() != null)
return vd.getStatus().getLabel(); return vr.getStatus().getLabel();
return ""; return "";
} }
@Override
public void render(Context context, T object, SafeHtmlBuilder sb) {
// TODO Auto-generated method stub
String value = getValue(object);
String color = "#000";
if (value.compareTo(ValidationStatus.PASSED.getLabel()) == 0) {
color = "#32CD32";
} else if (value.compareTo(ValidationStatus.WARNING.getLabel()) == 0) {
color = "#FF8000";
} else if (value.compareTo(ValidationStatus.ERROR.getLabel()) == 0) {
color = "red";
}
sb.appendHtmlConstant("<span style=\"color:" + color + "\";>");
super.render(context, object, sb);
sb.appendHtmlConstant("</span>");
}
}; };
sortedCellTable.addColumn(statusColumn, RECORD_FIELD.PUBLISHING_STATUS.getDisplayName(), false); sortedCellTable.addColumn(statusColumn, RECORD_FIELD.PUBLISHING_STATUS.getDisplayName(), false);
@ -319,9 +341,13 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
} }
ButtonCell showOnMapButton = new ButtonCell(); ButtonCell showOnMapButton = new ButtonCell();
Column<T, String> showOnMapColumn = new Column<T, String>(showOnMapButton) { showOnMapButton.setIcon(IconType.MAP_MARKER);
MyToolTipColumn<T, String> showOnMapColumn = new MyToolTipColumn<T, String>(showOnMapButton, "Show on Map") {
@Override
public String getValue(T object) { public String getValue(T object) {
return "Show on Map"; return "";
} }
}; };
@ -333,12 +359,14 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
} }
}); });
sortedCellTable.addColumn(showOnMapColumn); sortedCellTable.addColumn(showOnMapColumn);
sortedCellTable.setColumnWidth(showOnMapColumn, 110, Unit.PX); sortedCellTable.setColumnWidth(showOnMapColumn, 50, Unit.PX);
ButtonCell showReportRecordButton = new ButtonCell(); ButtonCell showReportRecordButton = new ButtonCell();
Column<T, String> showReportRecordColumn = new Column<T, String>(showReportRecordButton) { showReportRecordButton.setIcon(IconType.FILE_TEXT_ALT);
MyToolTipColumn<T, String> showReportRecordColumn = new MyToolTipColumn<T, String>(showReportRecordButton,
"Show Publication Report") {
public String getValue(T object) { public String getValue(T object) {
return "P. Report"; return "";
} }
}; };
@ -350,12 +378,14 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
} }
}); });
sortedCellTable.addColumn(showReportRecordColumn); sortedCellTable.addColumn(showReportRecordColumn);
sortedCellTable.setColumnWidth(showReportRecordColumn, 80, Unit.PX); sortedCellTable.setColumnWidth(showReportRecordColumn, 50, Unit.PX);
ButtonCell deleteRecordButton = new ButtonCell(); ButtonCell deleteRecordButton = new ButtonCell();
Column<T, String> deleteRecordColumn = new Column<T, String>(deleteRecordButton) { deleteRecordButton.setIcon(IconType.TRASH);
MyToolTipColumn<T, String> deleteRecordColumn = new MyToolTipColumn<T, String>(deleteRecordButton,
"Delete Project") {
public String getValue(T object) { public String getValue(T object) {
return "Delete"; return "";
} }
}; };
@ -367,7 +397,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
} }
}); });
sortedCellTable.addColumn(deleteRecordColumn); sortedCellTable.addColumn(deleteRecordColumn);
sortedCellTable.setColumnWidth(deleteRecordColumn, 80, Unit.PX); sortedCellTable.setColumnWidth(deleteRecordColumn, 50, Unit.PX);
GWT.log("currentSortFilter: " + currentSortFilter); GWT.log("currentSortFilter: " + currentSortFilter);

@ -39,7 +39,7 @@ public abstract class MyToolTipColumn<T, C> extends Column<T, C> {
* @param toolTipText the tool tip text * @param toolTipText the tool tip text
* @return the safe html * @return the safe html
*/ */
@Template("<div title=\"{0}\">") @Template("<span title=\"{0}\">")
SafeHtml startToolTip(String toolTipText); SafeHtml startToolTip(String toolTipText);
/** /**
@ -47,7 +47,7 @@ public abstract class MyToolTipColumn<T, C> extends Column<T, C> {
* *
* @return the safe html * @return the safe html
*/ */
@Template("</div>") @Template("</span>")
SafeHtml endToolTip(); SafeHtml endToolTip();
} }
@ -75,7 +75,6 @@ public abstract class MyToolTipColumn<T, C> extends Column<T, C> {
*/ */
@Override @Override
public void render(final Context context, final T object, final SafeHtmlBuilder sb) { public void render(final Context context, final T object, final SafeHtmlBuilder sb) {
sb.append(TEMPLATES.startToolTip(toolTipText)); sb.append(TEMPLATES.startToolTip(toolTipText));
super.render(context, object, sb); super.render(context, object, sb);
sb.append(TEMPLATES.endToolTip()); sb.append(TEMPLATES.endToolTip());

@ -1,6 +1,7 @@
package org.gcube.portlets.user.geoportaldataentry.server; package org.gcube.portlets.user.geoportaldataentry.server;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -25,6 +26,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitl
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.server.ServiceUtil.ConcessioneDVValidationReportStatusComparator;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
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;
@ -37,7 +39,6 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/** /**
@ -548,13 +549,17 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
ResultSetPaginatedData searchedData = new ResultSetPaginatedData(start, limit, startIndex, false); ResultSetPaginatedData searchedData = new ResultSetPaginatedData(start, limit, startIndex, false);
searchedData.setTotalItems(listConcessioniSize); searchedData.setTotalItems(listConcessioniSize);
RECORD_FIELD orderBy = null;
ORDER order = null;
ConcessioneDVValidationReportStatusComparator statusComparator = null;
if (filter == null) { if (filter == null) {
// unsorted list of records // unsorted list of records
toReturn = listOfConcessioni.subList(startIndex, limitIndex); toReturn = listOfConcessioni.subList(startIndex, limitIndex);
} else { } else {
RECORD_FIELD orderBy = filter.getOrderByField(); orderBy = filter.getOrderByField();
ORDER order = filter.getOrder(); order = filter.getOrder();
if (orderBy == null) if (orderBy == null)
orderBy = RECORD_FIELD.NAME; orderBy = RECORD_FIELD.NAME;
@ -564,6 +569,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
// CASE INSENSITIVE COMPARATOR // CASE INSENSITIVE COMPARATOR
Comparator<Concessione> comparator = null; Comparator<Concessione> comparator = null;
switch (orderBy) { switch (orderBy) {
case NAME: case NAME:
if (order.equals(ORDER.ASC)) { if (order.equals(ORDER.ASC)) {
@ -607,14 +613,17 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
} }
break; break;
case PUBLISHING_STATUS:
statusComparator = new ConcessioneDVValidationReportStatusComparator();
default: default:
break; break;
} }
// sorting with nullsLast // sorting with nullsLast
listOfConcessioni.sort(Comparator.nullsLast(comparator)); if (comparator != null)
Log.debug("sorted list: " + listOfConcessioni); listOfConcessioni.sort(Comparator.nullsLast(comparator));
LOG.debug("sorted list: " + listOfConcessioni);
// pagination // pagination
toReturn = listOfConcessioni.subList(startIndex, limitIndex); toReturn = listOfConcessioni.subList(startIndex, limitIndex);
} }
@ -625,7 +634,14 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
ConcessioneDV concessioneDV = ConvertToDataViewModel.toMetadataConcessione(concessione, true); ConcessioneDV concessioneDV = ConvertToDataViewModel.toMetadataConcessione(concessione, true);
toReturnList.add(concessioneDV); toReturnList.add(concessioneDV);
} }
if(statusComparator!=null) {
toReturnList.sort(statusComparator);
if (order.equals(ORDER.DESC)) {
Collections.sort(toReturnList, Collections.reverseOrder(new ConcessioneDVValidationReportStatusComparator()));
}
}
searchedData.setData(toReturnList); searchedData.setData(toReturnList);
if (listConcessioniSize == limit || listConcessioniSize == 0) { if (listConcessioniSize == limit || listConcessioniSize == 0) {

@ -7,11 +7,14 @@ import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportal.common.rest.MongoConcessioni;
import org.gcube.application.geoportal.common.rest.TempFile; import org.gcube.application.geoportal.common.rest.TempFile;
import org.gcube.application.geoportal.common.utils.StorageUtils; import org.gcube.application.geoportal.common.utils.StorageUtils;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException; import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -83,28 +86,75 @@ public class ServiceUtil {
} }
return files; return files;
} }
/** /**
* To JSON. * To JSON.
* *
* @param <T> the generic type * @param theObj the the obj
* @param report the report
* @return the string * @return the string
*/ */
public String toJSON(Object theObj) { public String toJSON(Object theObj) {
LOG.debug("toJSON called"); LOG.debug("toJSON called");
try { try {
if(theObj instanceof Serializable) { if (theObj instanceof Serializable) {
return org.gcube.application.geoportal.client.utils.Serialization.write(theObj); return org.gcube.application.geoportal.client.utils.Serialization.write(theObj);
} }
throw new Exception("The input object is not serializable"); throw new Exception("The input object is not serializable");
} catch (Exception e) { } catch (Exception e) {
LOG.warn("Error on deserializing: ", e); LOG.warn("Error on deserializing: ", e);
return null; return null;
} }
} }
/**
* The Class ConcessioneValidationReportStatusComparator.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Sep 14, 2021
*/
public static class ConcessioneValidationReportStatusComparator implements Comparator<Concessione> {
/**
* Compare.
*
* @param o1 the o 1
* @param o2 the o 2
* @return the int
*/
@Override
public int compare(Concessione o1, Concessione o2) {
if (o1 == null || o1.getReport() == null || o1.getReport().getStatus() == null)
return 1;
if (o2 == null || o2.getReport() == null || o2.getReport().getStatus() == null)
return -1;
return o1.getReport().getStatus().name().compareTo(o2.getReport().getStatus().name());
}
}
public static class ConcessioneDVValidationReportStatusComparator implements Comparator<ConcessioneDV> {
/**
* Compare.
*
* @param o1 the o 1
* @param o2 the o 2
* @return the int
*/
@Override
public int compare(ConcessioneDV o1, ConcessioneDV o2) {
if (o1 == null || o1.getValidationStatus() == null)
return 1;
if (o2 == null || o2.getValidationStatus() == null)
return -1;
return o1.getValidationStatus().name().compareTo(o2.getValidationStatus().name());
}
}
} }

@ -64,8 +64,8 @@ h1 {
overflow: hidden !important; overflow: hidden !important;
} }
.table-glor th { .table-glor td:nth-last-child(-n+4) {
/*text-align: center !important;*/ background-color: #d9edf7 !important;
} }
.table-glor-vertical-middle td, th { .table-glor-vertical-middle td, th {

@ -16,6 +16,13 @@
<link rel="stylesheet" <link rel="stylesheet"
href="<%=request.getContextPath()%>/GeoPortalDataEntryApp.css" href="<%=request.getContextPath()%>/GeoPortalDataEntryApp.css"
type="text/css"> type="text/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>
<link type="text/css" rel="stylesheet" <link type="text/css" rel="stylesheet"
href="<%=request.getContextPath()%>/GeoPortalDataEntryApp/css/ol.css"> href="<%=request.getContextPath()%>/GeoPortalDataEntryApp/css/ol.css">

Loading…
Cancel
Save