refactoring

pull/4/head
Francesco Mangiacrapa 3 years ago
parent 34a17253a6
commit 2208adec46

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

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

@ -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;

@ -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;

@ -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<T extends ConcessioneDV> extends AbstractItemsCellTable<
private AbstractDataProvider<T> dataProvider;
private List<RECORD_DISPLAY_FIELD> displayFields;
private List<RECORD_FIELD> displayFields;
private TextColumn<T> startEndProjectColumn;
// private Column<T, Date> startProjectDateColumn;
// private Column<T, Date> endProjectDateColumn;
@ -76,7 +76,7 @@ public class ItemsTable<T extends ConcessioneDV> 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<T extends ConcessioneDV> 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<T>() {
@ -130,7 +130,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
};
};
sortedCellTable.addColumn(name, "Name", true);
sortedCellTable.addColumn(name, RECORD_FIELD.NAME.getDisplayName(), true);
if (!isAsyncronusTable) {
Comparator<T> c = new Comparator<T>() {
@ -145,7 +145,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
}
if (this.displayFields.contains(RECORD_DISPLAY_FIELD.INTRODUCTION)) {
if (this.displayFields.contains(RECORD_FIELD.INTRODUCTION)) {
introduction = new TextColumn<T>() {
@Override
@ -158,7 +158,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
}
};
sortedCellTable.addColumn(introduction, "Introduction", true);
sortedCellTable.addColumn(introduction, RECORD_FIELD.INTRODUCTION.getDisplayName(), true);
if (!isAsyncronusTable) {
Comparator<T> c = new Comparator<T>() {
@ -174,7 +174,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
}
if (this.displayFields.contains(RECORD_DISPLAY_FIELD.AUTHOR)) {
if (this.displayFields.contains(RECORD_FIELD.AUTHOR)) {
author = new TextColumn<T>() {
@Override
@ -187,7 +187,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
}
};
sortedCellTable.addColumn(author, "Author/s", true);
sortedCellTable.addColumn(author, RECORD_FIELD.AUTHOR.getDisplayName(), true);
if (!isAsyncronusTable) {
Comparator<T> c = new Comparator<T>() {
@ -205,7 +205,7 @@ public class ItemsTable<T extends ConcessioneDV> 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<T>() {
@Override
@ -219,12 +219,12 @@ public class ItemsTable<T extends ConcessioneDV> 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<T, Date>(date) {
@ -237,7 +237,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
return (((ConcessioneDV) object).getCreationTime());
}
};
sortedCellTable.addColumn(createdColumn, "Created", true);
sortedCellTable.addColumn(createdColumn, RECORD_FIELD.CREATED.getDisplayName(), true);
if (!isAsyncronusTable) {
Comparator<T> c = new Comparator<T>() {
@ -268,7 +268,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
}
if (this.displayFields.contains(RECORD_DISPLAY_FIELD.CREATED_BY)) {
if (this.displayFields.contains(RECORD_FIELD.CREATED_BY)) {
// NAME
insertedBy = new TextColumn<T>() {
@ -280,7 +280,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
}
};
sortedCellTable.addColumn(insertedBy, "Created by", true);
sortedCellTable.addColumn(insertedBy, RECORD_FIELD.CREATED_BY.getDisplayName(), true);
if (!isAsyncronusTable) {
Comparator<T> c = new Comparator<T>() {
@ -334,17 +334,17 @@ public class ItemsTable<T extends ConcessioneDV> 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<T extends ConcessioneDV> 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<T extends ConcessioneDV> extends AbstractItemsCellTable<
*
* @return the displayFields
*/
public List<RECORD_DISPLAY_FIELD> getDisplayFields() {
public List<RECORD_FIELD> getDisplayFields() {
return displayFields;
}

@ -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()));

@ -147,6 +147,7 @@ public class SessionUtil {
SessionUtil.getCurrentContext(httpServletRequest, true);
ServiceUtil serviceUtil = new ServiceUtil();
MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni();
Iterator<Concessione> concessioni = clientMongo.getList();
if (concessioni != null) {
while (concessioni.hasNext()) {

@ -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;

Loading…
Cancel
Save