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() {
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);
@ -431,7 +431,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
final LoaderIcon lc = new LoaderIcon("Just moment getting link...");
hpGetLink.add(lc);
modal.add(hpGetLink);
final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", "");
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(),
@ -464,7 +464,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modal2.setWidth(800);
modal2.setCloseVisible(true);
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 {
BuildValidationReport buildValidationReport = new BuildValidationReport(
concessione.getValidationReport());

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

@ -13,13 +13,16 @@ import java.util.Set;
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
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.ValidationStatus;
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.events.ActionOnItemEvent;
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
import com.github.gwtbootstrap.client.ui.ButtonCell;
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.FieldUpdater;
import com.google.gwt.core.shared.GWT;
@ -306,11 +309,30 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
if (object == null)
return "";
ValidationReportDV vd = ((ConcessioneDV) object).getValidationReport();
if (vd != null)
return vd.getStatus().getLabel();
ValidationReportDV vr = ((ConcessioneDV) object).getValidationReport();
if (vr != null && vr.getStatus() != null)
return vr.getStatus().getLabel();
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);
@ -319,9 +341,13 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
}
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) {
return "Show on Map";
return "";
}
};
@ -333,12 +359,14 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
}
});
sortedCellTable.addColumn(showOnMapColumn);
sortedCellTable.setColumnWidth(showOnMapColumn, 110, Unit.PX);
sortedCellTable.setColumnWidth(showOnMapColumn, 50, Unit.PX);
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) {
return "P. Report";
return "";
}
};
@ -350,12 +378,14 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
}
});
sortedCellTable.addColumn(showReportRecordColumn);
sortedCellTable.setColumnWidth(showReportRecordColumn, 80, Unit.PX);
sortedCellTable.setColumnWidth(showReportRecordColumn, 50, Unit.PX);
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) {
return "Delete";
return "";
}
};
@ -367,7 +397,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
}
});
sortedCellTable.addColumn(deleteRecordColumn);
sortedCellTable.setColumnWidth(deleteRecordColumn, 80, Unit.PX);
sortedCellTable.setColumnWidth(deleteRecordColumn, 50, Unit.PX);
GWT.log("currentSortFilter: " + currentSortFilter);

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

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

@ -7,11 +7,14 @@ import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Comparator;
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.TempFile;
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.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
import org.slf4j.Logger;
@ -83,28 +86,75 @@ public class ServiceUtil {
}
return files;
}
/**
* To JSON.
*
* @param <T> the generic type
* @param report the report
* @param theObj the the obj
* @return the string
*/
public String toJSON(Object theObj) {
LOG.debug("toJSON called");
try {
if(theObj instanceof Serializable) {
if (theObj instanceof Serializable) {
return org.gcube.application.geoportal.client.utils.Serialization.write(theObj);
}
throw new Exception("The input object is not serializable");
} catch (Exception e) {
LOG.warn("Error on deserializing: ", e);
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;
}
.table-glor th {
/*text-align: center !important;*/
.table-glor td:nth-last-child(-n+4) {
background-color: #d9edf7 !important;
}
.table-glor-vertical-middle td, th {

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

Loading…
Cancel
Save