diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java index cd372a8..08e58b4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java @@ -46,32 +46,34 @@ public class ConstantsGeoPortalDataEntryApp { * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Aug 6, 2021 + * Sep 2, 2021 */ public static enum RECORD_FIELD { - NAME, INTRODUCTION, AUTHOR, PROJECT_START, CREATED, CREATED_BY - } + NAME("name", "Name"), INTRODUCTION("introduction", "Introduction"), AUTHOR("author", "Author/s"), + PROJECT_START_END_DATE("", "Project Start/End Date"), CREATED("created", "Created"), + CREATED_BY("createdBy", "Created by"); - /** - * The Enum RECORD_FIELD. - * - * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it - * - * Aug 6, 2021 - */ - public static enum RECORD_DISPLAY_FIELD { - NAME, INTRODUCTION, AUTHOR, PROJECT_START_END_DATE, CREATED, CREATED_BY - } + String jsonFieldName; + String displayName; - /** - * The Enum ORDER. - * - * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it - * - * Aug 6, 2021 - */ - public static enum ORDER { - ASC, DESC + /** + * Instantiates a new record field. + * + * @param jsonFieldName the json field name + * @param displayName the display name + */ + RECORD_FIELD(String jsonFieldName, String displayName) { + this.jsonFieldName = jsonFieldName; + this.displayName = displayName; + } + + public String getJsonFieldName() { + return jsonFieldName; + } + + public String getDisplayName() { + return displayName; + } } } 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 0dde10e..8533789 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 @@ -10,7 +10,6 @@ import java.util.TreeMap; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ORDER; 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.events.ActionOnItemEvent; @@ -35,6 +34,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; +import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter.ORDER; import org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderServiceAsync; import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean; @@ -92,7 +92,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { */ public void onModuleLoad() { - RECORD_FIELD[] sortByOptions = new RECORD_FIELD[] { RECORD_FIELD.NAME, RECORD_FIELD.PROJECT_START, + RECORD_FIELD[] sortByOptions = new RECORD_FIELD[] { RECORD_FIELD.NAME, RECORD_FIELD.PROJECT_START_END_DATE, RECORD_FIELD.CREATED, RECORD_FIELD.CREATED_BY }; SortFilter initialSortFilter = new SortFilter(RECORD_FIELD.NAME, ORDER.ASC); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java index a340890..e2a33b7 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java @@ -1,6 +1,5 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui; -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ORDER; 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.events.CreateNewProjectEvent; @@ -8,6 +7,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecords import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; +import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter.ORDER; import com.github.gwtbootstrap.client.ui.Dropdown; import com.github.gwtbootstrap.client.ui.NavLink; @@ -216,7 +216,7 @@ public class GeonaMainTabPanel extends Composite { */ public String toLabelFilter(SortFilter sortFilter) { - String labelFilter = sortFilter.getOrderByField().name() + LABEL_FILTER_SEPARATOR + String labelFilter = sortFilter.getOrderByField().getDisplayName() + LABEL_FILTER_SEPARATOR + sortFilter.getOrder().name(); GWT.log("Got " + sortFilter); return labelFilter; @@ -228,7 +228,7 @@ public class GeonaMainTabPanel extends Composite { * @param labelFilter the label filter * @return the sort filter */ - public SortFilter toSortFilter(String labelFilter) { + /*public SortFilter toSortFilter(String labelFilter) { String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR); @@ -244,7 +244,7 @@ public class GeonaMainTabPanel extends Composite { GWT.log("Got " + sortFilter); return sortFilter; - } + }*/ public SortFilter getCurrentSortFilter() { return currentSortFilter; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java index 595a51a..a9ec117 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java @@ -3,7 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui; import java.util.List; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_DISPLAY_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.GeoPortalDataEntryApp; import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable; @@ -61,7 +61,7 @@ public class GeonaRecordsPaginatedView { * @param currentSortFilter the sort by field */ public GeonaRecordsPaginatedView(HandlerManager eventbus, RECORD_TYPE recordType, - RECORD_DISPLAY_FIELD[] displayFields, SortFilter currentSortFilter) { + RECORD_FIELD[] displayFields, SortFilter currentSortFilter) { this.recordType = recordType; this.currentSortFilter = currentSortFilter; this.initClassFirstRangeChanged = 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 bdd7649..cb30087 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,7 +13,7 @@ import java.util.Set; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_DISPLAY_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.shared.SortFilter; @@ -60,7 +60,7 @@ public class ItemsTable extends AbstractItemsCellTable< private AbstractDataProvider dataProvider; - private List displayFields; + private List displayFields; private TextColumn startEndProjectColumn; // private Column startProjectDateColumn; // private Column endProjectDateColumn; @@ -76,7 +76,7 @@ public class ItemsTable extends AbstractItemsCellTable< * @param displayFields the display fields * @param startSortByColumn the start sort by column */ - public ItemsTable(HandlerManager eventBus, RECORD_DISPLAY_FIELD[] displayFields, SortFilter currentSortFilter) { + public ItemsTable(HandlerManager eventBus, RECORD_FIELD[] displayFields, SortFilter currentSortFilter) { this.eventBus = eventBus; this.currentSortFilter = currentSortFilter; setDisplayFields(displayFields); @@ -108,7 +108,7 @@ public class ItemsTable extends AbstractItemsCellTable< this.isAsyncronusTable = dataProvider instanceof ListDataProvider ? false : true; setEmptyTableMessage(NO_DATA); - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.NAME)) { + if (this.displayFields.contains(RECORD_FIELD.NAME)) { // NAME name = new TextColumn() { @@ -130,7 +130,7 @@ public class ItemsTable extends AbstractItemsCellTable< }; }; - sortedCellTable.addColumn(name, "Name", true); + sortedCellTable.addColumn(name, RECORD_FIELD.NAME.getDisplayName(), true); if (!isAsyncronusTable) { Comparator c = new Comparator() { @@ -145,7 +145,7 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.INTRODUCTION)) { + if (this.displayFields.contains(RECORD_FIELD.INTRODUCTION)) { introduction = new TextColumn() { @Override @@ -158,7 +158,7 @@ public class ItemsTable extends AbstractItemsCellTable< } }; - sortedCellTable.addColumn(introduction, "Introduction", true); + sortedCellTable.addColumn(introduction, RECORD_FIELD.INTRODUCTION.getDisplayName(), true); if (!isAsyncronusTable) { Comparator c = new Comparator() { @@ -174,7 +174,7 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.AUTHOR)) { + if (this.displayFields.contains(RECORD_FIELD.AUTHOR)) { author = new TextColumn() { @Override @@ -187,7 +187,7 @@ public class ItemsTable extends AbstractItemsCellTable< } }; - sortedCellTable.addColumn(author, "Author/s", true); + sortedCellTable.addColumn(author, RECORD_FIELD.AUTHOR.getDisplayName(), true); if (!isAsyncronusTable) { Comparator c = new Comparator() { @@ -205,7 +205,7 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.PROJECT_START_END_DATE)) { + if (this.displayFields.contains(RECORD_FIELD.PROJECT_START_END_DATE)) { startEndProjectColumn = new TextColumn() { @Override @@ -219,12 +219,12 @@ public class ItemsTable extends AbstractItemsCellTable< } }; - sortedCellTable.addColumn(startEndProjectColumn, "Start/End Date", false); + sortedCellTable.addColumn(startEndProjectColumn, RECORD_FIELD.PROJECT_START_END_DATE.getDisplayName(), false); sortedCellTable.setColumnWidth(startEndProjectColumn, 180, Unit.PX); } - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.CREATED)) { + if (this.displayFields.contains(RECORD_FIELD.CREATED)) { DateCell date = new DateCell(dtformat); createdColumn = new Column(date) { @@ -237,7 +237,7 @@ public class ItemsTable extends AbstractItemsCellTable< return (((ConcessioneDV) object).getCreationTime()); } }; - sortedCellTable.addColumn(createdColumn, "Created", true); + sortedCellTable.addColumn(createdColumn, RECORD_FIELD.CREATED.getDisplayName(), true); if (!isAsyncronusTable) { Comparator c = new Comparator() { @@ -268,7 +268,7 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.CREATED_BY)) { + if (this.displayFields.contains(RECORD_FIELD.CREATED_BY)) { // NAME insertedBy = new TextColumn() { @@ -280,7 +280,7 @@ public class ItemsTable extends AbstractItemsCellTable< } }; - sortedCellTable.addColumn(insertedBy, "Created by", true); + sortedCellTable.addColumn(insertedBy, RECORD_FIELD.CREATED_BY.getDisplayName(), true); if (!isAsyncronusTable) { Comparator c = new Comparator() { @@ -334,17 +334,17 @@ public class ItemsTable extends AbstractItemsCellTable< if (currentSortFilter != null) switch (currentSortFilter.getOrderByField()) { case NAME: - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.NAME)) { + if (this.displayFields.contains(RECORD_FIELD.NAME)) { sortedCellTable.setInitialSortColumn(name); } break; case INTRODUCTION: - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.INTRODUCTION)) { + if (this.displayFields.contains(RECORD_FIELD.INTRODUCTION)) { sortedCellTable.setInitialSortColumn(introduction); } break; case AUTHOR: - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.AUTHOR)) { + if (this.displayFields.contains(RECORD_FIELD.AUTHOR)) { sortedCellTable.setInitialSortColumn(author); } break; @@ -399,9 +399,9 @@ public class ItemsTable extends AbstractItemsCellTable< * * @param fields the new display fields */ - public void setDisplayFields(RECORD_DISPLAY_FIELD[] fields) { + public void setDisplayFields(RECORD_FIELD[] fields) { this.displayFields = fields != null && fields.length > 0 ? Arrays.asList(fields) - : Arrays.asList(RECORD_DISPLAY_FIELD.values()); + : Arrays.asList(RECORD_FIELD.values()); } /** @@ -420,7 +420,7 @@ public class ItemsTable extends AbstractItemsCellTable< * * @return the displayFields */ - public List getDisplayFields() { + public List getDisplayFields() { return displayFields; } 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 445cf01..f13752c 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 @@ -12,7 +12,7 @@ import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo; import org.gcube.application.geoportal.common.model.legacy.UploadedImage; import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport; -import org.gcube.application.geoportal.common.rest.AddSectionToConcessioneRequest; +import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest; import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportal.common.rest.TempFile; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; @@ -21,7 +21,6 @@ import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ORDER; 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; @@ -31,6 +30,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData; import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; +import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter.ORDER; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.gcube.vomanagement.usermanagement.model.GCubeUser; @@ -599,7 +599,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } break; - case PROJECT_START: + //TODO is buggy must be performed by service + case PROJECT_START_END_DATE: if (order.equals(ORDER.ASC)) { comparator = Comparator.comparing(Concessione::getDataInizioProgetto, Comparator.nullsLast(Comparator.naturalOrder())); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java index 549cf8a..03f06c2 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java @@ -147,6 +147,7 @@ public class SessionUtil { SessionUtil.getCurrentContext(httpServletRequest, true); ServiceUtil serviceUtil = new ServiceUtil(); MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); + Iterator concessioni = clientMongo.getList(); if (concessioni != null) { while (concessioni.hasNext()) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SortFilter.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SortFilter.java index aca6e31..5226711 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SortFilter.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SortFilter.java @@ -2,19 +2,38 @@ package org.gcube.portlets.user.geoportaldataentry.shared; import java.io.Serializable; -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ORDER; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; - /** * The Class SortFilter. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Aug 6, 2021 + * Aug 6, 2021 */ public class SortFilter implements Serializable { + /** + * The Enum ORDER. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 6, 2021 + */ + public static enum ORDER { + ASC("ASCENDING"), DESC("DESCENDING"); + + String label; + + ORDER(String label) { + this.label = label; + } + + public String getLabel() { + return label; + } + } + /** * */ @@ -24,7 +43,6 @@ public class SortFilter implements Serializable { private ORDER order; - /** * Instantiates a new sort filter. */ @@ -32,12 +50,11 @@ public class SortFilter implements Serializable { } - /** * Instantiates a new sort filter. * * @param orderByField the order by field - * @param order the order + * @param order the order */ public SortFilter(RECORD_FIELD orderByField, ORDER order) { this.orderByField = orderByField;