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 6282481..89b9cce 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 @@ -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()); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java index 47b11e8..53b1659 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java @@ -73,7 +73,7 @@ public abstract class AbstractItemsCellTable { sortedCellTable = new SortedCellTable(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); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java index 40566d0..91b560e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java @@ -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 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(""); + super.render(context, object, sb); + sb.appendHtmlConstant(""); + + } }; sortedCellTable.addColumn(statusColumn, RECORD_FIELD.PUBLISHING_STATUS.getDisplayName(), false); @@ -319,9 +341,13 @@ public class ItemsTable extends AbstractItemsCellTable< } ButtonCell showOnMapButton = new ButtonCell(); - Column showOnMapColumn = new Column(showOnMapButton) { + showOnMapButton.setIcon(IconType.MAP_MARKER); + + MyToolTipColumn showOnMapColumn = new MyToolTipColumn(showOnMapButton, "Show on Map") { + + @Override public String getValue(T object) { - return "Show on Map"; + return ""; } }; @@ -333,12 +359,14 @@ public class ItemsTable extends AbstractItemsCellTable< } }); sortedCellTable.addColumn(showOnMapColumn); - sortedCellTable.setColumnWidth(showOnMapColumn, 110, Unit.PX); + sortedCellTable.setColumnWidth(showOnMapColumn, 50, Unit.PX); ButtonCell showReportRecordButton = new ButtonCell(); - Column showReportRecordColumn = new Column(showReportRecordButton) { + showReportRecordButton.setIcon(IconType.FILE_TEXT_ALT); + MyToolTipColumn showReportRecordColumn = new MyToolTipColumn(showReportRecordButton, + "Show Publication Report") { public String getValue(T object) { - return "P. Report"; + return ""; } }; @@ -350,12 +378,14 @@ public class ItemsTable extends AbstractItemsCellTable< } }); sortedCellTable.addColumn(showReportRecordColumn); - sortedCellTable.setColumnWidth(showReportRecordColumn, 80, Unit.PX); + sortedCellTable.setColumnWidth(showReportRecordColumn, 50, Unit.PX); ButtonCell deleteRecordButton = new ButtonCell(); - Column deleteRecordColumn = new Column(deleteRecordButton) { + deleteRecordButton.setIcon(IconType.TRASH); + MyToolTipColumn deleteRecordColumn = new MyToolTipColumn(deleteRecordButton, + "Delete Project") { public String getValue(T object) { - return "Delete"; + return ""; } }; @@ -367,7 +397,7 @@ public class ItemsTable extends AbstractItemsCellTable< } }); sortedCellTable.addColumn(deleteRecordColumn); - sortedCellTable.setColumnWidth(deleteRecordColumn, 80, Unit.PX); + sortedCellTable.setColumnWidth(deleteRecordColumn, 50, Unit.PX); GWT.log("currentSortFilter: " + currentSortFilter); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/MyToolTipColumn.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/MyToolTipColumn.java index 1de211f..fe99a3c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/MyToolTipColumn.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/MyToolTipColumn.java @@ -39,7 +39,7 @@ public abstract class MyToolTipColumn extends Column { * @param toolTipText the tool tip text * @return the safe html */ - @Template("
") + @Template("") SafeHtml startToolTip(String toolTipText); /** @@ -47,7 +47,7 @@ public abstract class MyToolTipColumn extends Column { * * @return the safe html */ - @Template("
") + @Template("") SafeHtml endToolTip(); } @@ -75,7 +75,6 @@ public abstract class MyToolTipColumn extends Column { */ @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()); 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 8d574ca..b2d5250 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 @@ -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 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) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java index 3160e6b..f0a270b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java @@ -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 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 { + + /** + * 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 { + + /** + * 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()); + } + + } + } diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css index f73fa16..7545a72 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.css +++ b/src/main/webapp/GeoPortalDataEntryApp.css @@ -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 { diff --git a/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp b/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp index 351526b..d9e7da1 100644 --- a/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp +++ b/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp @@ -16,6 +16,13 @@ + + +