extends AbstractItemsCellTable<
public void render(com.google.gwt.cell.client.Cell.Context context, T object, SafeHtmlBuilder sb) {
if (object == null)
return;
- sb.appendHtmlConstant("");
- super.render(context, object, sb);
- sb.appendHtmlConstant("
");
+
+ if (displayName.equalsIgnoreCase("Published with")) {
+ 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("");
+ } else
+ super.render(context, object, sb);
+
};
};
- sortedCellTable.addColumn(name, RECORD_FIELD.NAME.getDisplayName(), true);
-
- if (!isAsyncronusTable) {
- Comparator c = new Comparator() {
- @Override
- public int compare(T o1, T o2) {
- return ((ConcessioneDV) o1).getNome().compareTo(((ConcessioneDV) o2).getNome());
- }
- };
-
- sortedCellTable.setComparator(name, c);
+ if(i==0) {
+ //name
+ sortedCellTable.setColumnWidth(col, 20, Unit.PCT);
+ }else if (i == 1) {
+ // intro
+ sortedCellTable.setColumnWidth(col, 30, Unit.PCT);
+ } else if (i == 2) {
+ sortedCellTable.setColumnWidth(col, 15, Unit.PCT);
+ }else if(i==displayFields.size()-1) {
+ sortedCellTable.setColumnWidth(col, 120, Unit.PX);
}
+
+ sortedCellTable.addColumn(col, itemField.getDisplayName(), true);
+ i++;
}
- if (this.displayFields.contains(RECORD_FIELD.INTRODUCTION)) {
-
- introduction = new TextColumn() {
- @Override
- public String getValue(T object) {
- if (object == null)
- return "";
- return ((ConcessioneDV) object).getIntroduzione() != null
- ? ((ConcessioneDV) object).getIntroduzione()
- : "";
- }
- };
-
- sortedCellTable.addColumn(introduction, RECORD_FIELD.INTRODUCTION.getDisplayName(), true);
-
- if (!isAsyncronusTable) {
- Comparator c = new Comparator() {
- @Override
- public int compare(T o1, T o2) {
- return ((ConcessioneDV) o1).getIntroduzione().compareTo(((ConcessioneDV) o2).getIntroduzione());
- }
- };
- sortedCellTable.setComparator(introduction, c);
- }
-
- // sortedCellTable.setColumnWidth(introduction, 100, Unit.PCT);
-
- }
-
- if (this.displayFields.contains(RECORD_FIELD.AUTHOR)) {
-
- author = new TextColumn() {
- @Override
- public String getValue(T object) {
- if (object == null)
- return "";
-
- String toDisplay = toDisplayAuthors(((ConcessioneDV) object).getAuthors());
- return toDisplay;
- }
- };
-
- sortedCellTable.addColumn(author, RECORD_FIELD.AUTHOR.getDisplayName(), true);
-
- if (!isAsyncronusTable) {
- Comparator c = new Comparator() {
- @Override
- public int compare(T o1, T o2) {
- String toDisplay1 = toDisplayAuthors(((ConcessioneDV) o1).getAuthors());
- String toDisplay2 = toDisplayAuthors(((ConcessioneDV) o2).getAuthors());
- return toDisplay1.compareTo(toDisplay2);
- }
- };
- sortedCellTable.setComparator(author, c);
- }
-
- sortedCellTable.setColumnWidth(author, 220, Unit.PX);
-
- }
-
- if (this.displayFields.contains(RECORD_FIELD.PROJECT_START_END_DATE)) {
-
- startEndProjectColumn = new TextColumn() {
- @Override
- public String getValue(T object) {
- if (object == null)
- return "";
-
- Date dS = (((ConcessioneDV) object).getDataInizioProgetto());
- Date dE = (((ConcessioneDV) object).getDataFineProgetto());
- return dtformat.format(dS) + " / " + dtformat.format(dE);
- }
- };
-
- sortedCellTable.addColumn(startEndProjectColumn, RECORD_FIELD.PROJECT_START_END_DATE.getDisplayName(),
- false);
- sortedCellTable.setColumnWidth(startEndProjectColumn, 180, Unit.PX);
-
- }
-
- if (this.displayFields.contains(RECORD_FIELD.CREATED)) {
-
- DateCell date = new DateCell(DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT+" "+ConvertToDataViewModel.TIME_FORMAT));
- createdColumn = new Column(date) {
-
- @Override
- public Date getValue(T object) {
- if (object == null)
- return null;
-
- return (((ConcessioneDV) object).getCreationTime());
- }
- };
- sortedCellTable.addColumn(createdColumn, RECORD_FIELD.CREATED.getDisplayName(), true);
-
- if (!isAsyncronusTable) {
- Comparator c = new Comparator() {
- @Override
- public int compare(T o1, T o2) {
- if (o1 == null)
- return -1;
-
- if (o2 == null)
- return 1;
-
- Date d1 = (((ConcessioneDV) o1).getCreationTime());
- Date d2 = (((ConcessioneDV) o2).getCreationTime());
-
- // GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1));
-
- if (d1.after(d2))
- return 1;
- else
- return -1;
- }
- };
- GWT.log("date colum sortable");
- sortedCellTable.setComparator(createdColumn, c);
- }
-
- sortedCellTable.setColumnWidth(createdColumn, 150, Unit.PX);
-
- }
-
- if (this.displayFields.contains(RECORD_FIELD.CREATED_BY)) {
-
- // NAME
- insertedBy = new TextColumn() {
- @Override
- public String getValue(T object) {
- if (object == null)
- return "";
- return ((ConcessioneDV) object).getCreationUser();
- }
- };
-
- sortedCellTable.addColumn(insertedBy, RECORD_FIELD.CREATED_BY.getDisplayName(), true);
-
- if (!isAsyncronusTable) {
- Comparator c = new Comparator() {
- @Override
- public int compare(T o1, T o2) {
- return ((ConcessioneDV) o1).getCreationUser().compareTo(((ConcessioneDV) o2).getCreationUser());
- }
- };
-
- sortedCellTable.setComparator(insertedBy, c);
- }
- sortedCellTable.setColumnWidth(insertedBy, 220, Unit.PX);
- }
-
- if (this.displayFields.contains(RECORD_FIELD.RECORD_STATUS)) {
-
- statusColumn = new TextColumn() {
- @Override
- public String getValue(T object) {
- if (object == null)
- return "";
-
- 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.RECORD_STATUS.getDisplayName(), false);
- sortedCellTable.setColumnWidth(statusColumn, 120, Unit.PX);
-
- }
-
-// ButtonCell showOnMapButton = new ButtonCell();
-// showOnMapButton.setIcon(IconType.MAP_MARKER);
-//
-// MyToolTipColumn showOnMapColumn = new MyToolTipColumn(showOnMapButton, "Show on Map") {
-//
-// @Override
-// public String getValue(T object) {
-// return "";
-// }
-// };
-//
-// showOnMapColumn.setFieldUpdater(new FieldUpdater() {
-// @Override
-// public void update(int index, T object, String value) {
-// GWT.log("clicked show");
-// eventBus.fireEvent(new ActionOnItemEvent(Arrays.asList(object), ACTION_ON_ITEM.SHOW_ON_MAP));
-// }
-// });
-// sortedCellTable.addColumn(showOnMapColumn);
-// sortedCellTable.setColumnWidth(showOnMapColumn, 50, Unit.PX);
-//
-// ButtonCell showReportRecordButton = new ButtonCell();
-// showReportRecordButton.setIcon(IconType.FILE_TEXT_ALT);
-// MyToolTipColumn showReportRecordColumn = new MyToolTipColumn(showReportRecordButton,
-// "Show Publication Report") {
-// public String getValue(T object) {
-// return "";
-// }
-// };
-//
-// showReportRecordColumn.setFieldUpdater(new FieldUpdater() {
-// @Override
-// public void update(int index, T object, String value) {
-//
-// eventBus.fireEvent(new ActionOnItemEvent(Arrays.asList(object), ACTION_ON_ITEM.SHOW_REPORT));
-// }
-// });
-// sortedCellTable.addColumn(showReportRecordColumn);
-// sortedCellTable.setColumnWidth(showReportRecordColumn, 50, Unit.PX);
-//
-// ButtonCell deleteRecordButton = new ButtonCell();
-// deleteRecordButton.setIcon(IconType.TRASH);
-// MyToolTipColumn deleteRecordColumn = new MyToolTipColumn(deleteRecordButton,
-// "Delete Project") {
-// public String getValue(T object) {
-// return "";
-// }
-// };
-//
-// deleteRecordColumn.setFieldUpdater(new FieldUpdater() {
-// @Override
-// public void update(int index, T object, String value) {
-//
-// eventBus.fireEvent(new ActionOnItemEvent(Arrays.asList(object), ACTION_ON_ITEM.DELETE_RECORD));
-// }
-// });
-// sortedCellTable.addColumn(deleteRecordColumn);
-// sortedCellTable.setColumnWidth(deleteRecordColumn, 50, Unit.PX);
-
- GWT.log("currentSortFilter: " + currentSortFilter);
-
- if (currentSortFilter != null)
- switch (currentSortFilter.getOrderByField()) {
- case NAME:
- if (this.displayFields.contains(RECORD_FIELD.NAME)) {
- sortedCellTable.setInitialSortColumn(name);
- }
- break;
- case INTRODUCTION:
- if (this.displayFields.contains(RECORD_FIELD.INTRODUCTION)) {
- sortedCellTable.setInitialSortColumn(introduction);
- }
- break;
- case AUTHOR:
- if (this.displayFields.contains(RECORD_FIELD.AUTHOR)) {
- sortedCellTable.setInitialSortColumn(author);
- }
- break;
- default:
- break;
- }
-
+ /*
+ * if (this.displayFields.contains(RECORD_FIELD.NAME)) {
+ *
+ * // NAME name = new TextColumn() {
+ *
+ * @Override public String getValue(T object) { if (object == null) return "";
+ * return ((ConcessioneDV) object).getNome(); }
+ *
+ * // ADDING TOOLTIP
+ *
+ * @Override public void render(com.google.gwt.cell.client.Cell.Context context,
+ * T object, SafeHtmlBuilder sb) { if (object == null) return;
+ * sb.appendHtmlConstant(""); super.render(context, object, sb);
+ * sb.appendHtmlConstant("
"); }; };
+ *
+ * sortedCellTable.addColumn(name, RECORD_FIELD.NAME.getDisplayName(), true);
+ *
+ * if (!isAsyncronusTable) { Comparator c = new Comparator() {
+ *
+ * @Override public int compare(T o1, T o2) { return ((ConcessioneDV)
+ * o1).getNome().compareTo(((ConcessioneDV) o2).getNome()); } };
+ *
+ * sortedCellTable.setComparator(name, c); }
+ *
+ * }
+ *
+ * if (this.displayFields.contains(RECORD_FIELD.INTRODUCTION)) {
+ *
+ * introduction = new TextColumn() {
+ *
+ * @Override public String getValue(T object) { if (object == null) return "";
+ * return ((ConcessioneDV) object).getIntroduzione() != null ? ((ConcessioneDV)
+ * object).getIntroduzione() : ""; } };
+ *
+ * sortedCellTable.addColumn(introduction,
+ * RECORD_FIELD.INTRODUCTION.getDisplayName(), true);
+ *
+ * if (!isAsyncronusTable) { Comparator c = new Comparator() {
+ *
+ * @Override public int compare(T o1, T o2) { return ((ConcessioneDV)
+ * o1).getIntroduzione().compareTo(((ConcessioneDV) o2).getIntroduzione()); } };
+ * sortedCellTable.setComparator(introduction, c); }
+ *
+ * // sortedCellTable.setColumnWidth(introduction, 100, Unit.PCT);
+ *
+ * }
+ *
+ * if (this.displayFields.contains(RECORD_FIELD.AUTHOR)) {
+ *
+ * author = new TextColumn() {
+ *
+ * @Override public String getValue(T object) { if (object == null) return "";
+ *
+ * String toDisplay = toDisplayAuthors(((ConcessioneDV) object).getAuthors());
+ * return toDisplay; } };
+ *
+ * sortedCellTable.addColumn(author, RECORD_FIELD.AUTHOR.getDisplayName(),
+ * true);
+ *
+ * if (!isAsyncronusTable) { Comparator c = new Comparator() {
+ *
+ * @Override public int compare(T o1, T o2) { String toDisplay1 =
+ * toDisplayAuthors(((ConcessioneDV) o1).getAuthors()); String toDisplay2 =
+ * toDisplayAuthors(((ConcessioneDV) o2).getAuthors()); return
+ * toDisplay1.compareTo(toDisplay2); } }; sortedCellTable.setComparator(author,
+ * c); }
+ *
+ * sortedCellTable.setColumnWidth(author, 220, Unit.PX);
+ *
+ * }
+ *
+ * if (this.displayFields.contains(RECORD_FIELD.PROJECT_START_END_DATE)) {
+ *
+ * startEndProjectColumn = new TextColumn() {
+ *
+ * @Override public String getValue(T object) { if (object == null) return "";
+ *
+ * Date dS = null; Date dE = null; if(object.getDataInizioProgetto()!=null) { dS
+ * = (((ConcessioneDV) object).getDataInizioProgetto()); }
+ *
+ * if(object.getDataFineProgetto()!=null) { dE = (((ConcessioneDV)
+ * object).getDataFineProgetto()); }
+ *
+ * String dateFormat = ""; if(dS!=null) { dateFormat+=dtformat.format(dS); }
+ *
+ * dateFormat+=" / ";
+ *
+ * if(dE!=null) { dateFormat+=dtformat.format(dE); }
+ *
+ * return dateFormat; } };
+ *
+ * sortedCellTable.addColumn(startEndProjectColumn,
+ * RECORD_FIELD.PROJECT_START_END_DATE.getDisplayName(), false);
+ * sortedCellTable.setColumnWidth(startEndProjectColumn, 180, Unit.PX);
+ *
+ * }
+ *
+ * if (this.displayFields.contains(RECORD_FIELD.CREATED)) {
+ *
+ * DateCell date = new
+ * DateCell(DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT+" "
+ * +ConvertToDataViewModel.TIME_FORMAT)); createdColumn = new Column(date) {
+ *
+ * @Override public Date getValue(T object) { if (object == null) return null;
+ *
+ * return (((ConcessioneDV) object).getCreationTime()); } };
+ * sortedCellTable.addColumn(createdColumn,
+ * RECORD_FIELD.CREATED.getDisplayName(), true);
+ *
+ * if (!isAsyncronusTable) { Comparator c = new Comparator() {
+ *
+ * @Override public int compare(T o1, T o2) { if (o1 == null) return -1;
+ *
+ * if (o2 == null) return 1;
+ *
+ * Date d1 = (((ConcessioneDV) o1).getCreationTime()); Date d2 =
+ * (((ConcessioneDV) o2).getCreationTime());
+ *
+ * // GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1));
+ *
+ * if (d1.after(d2)) return 1; else return -1; } };
+ * GWT.log("date colum sortable"); sortedCellTable.setComparator(createdColumn,
+ * c); }
+ *
+ * sortedCellTable.setColumnWidth(createdColumn, 150, Unit.PX);
+ *
+ * }
+ *
+ * if (this.displayFields.contains(RECORD_FIELD.CREATED_BY)) {
+ *
+ * // NAME insertedBy = new TextColumn() {
+ *
+ * @Override public String getValue(T object) { if (object == null) return "";
+ * return ((ConcessioneDV) object).getCreationUser(); } };
+ *
+ * sortedCellTable.addColumn(insertedBy,
+ * RECORD_FIELD.CREATED_BY.getDisplayName(), true);
+ *
+ * if (!isAsyncronusTable) { Comparator c = new Comparator() {
+ *
+ * @Override public int compare(T o1, T o2) { return ((ConcessioneDV)
+ * o1).getCreationUser().compareTo(((ConcessioneDV) o2).getCreationUser()); } };
+ *
+ * sortedCellTable.setComparator(insertedBy, c); }
+ * sortedCellTable.setColumnWidth(insertedBy, 220, Unit.PX); }
+ *
+ * if (this.displayFields.contains(RECORD_FIELD.RECORD_STATUS)) {
+ *
+ * statusColumn = new TextColumn() {
+ *
+ * @Override public String getValue(T object) { if (object == null) return "";
+ *
+ * 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.RECORD_STATUS.getDisplayName(), false);
+ * sortedCellTable.setColumnWidth(statusColumn, 120, Unit.PX);
+ *
+ * }
+ */
}
-
-
+
public void enableWriteOperations() {
-
+
}
/**
@@ -465,15 +419,15 @@ public class ItemsTable extends AbstractItemsCellTable<
}
}
- /**
- * Sets the display fields.
- *
- * @param fields the new display fields
- */
- public void setDisplayFields(RECORD_FIELD[] fields) {
- this.displayFields = fields != null && fields.length > 0 ? Arrays.asList(fields)
- : Arrays.asList(RECORD_FIELD.values());
- }
+// /**
+// * Sets the display fields.
+// *
+// * @param fields the new display fields
+// */
+// public void setDisplayFields(List fields) {
+// this.displayFields = fields != null && fields.size() > 0 ? Arrays.asList(fields)
+// : Arrays.asList(RECORD_FIELD.values());
+// }
/**
* Reset columns table.
@@ -491,7 +445,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 aae3fa7..d6187d5 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,8 +1,6 @@
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;
import java.util.Map;
@@ -19,25 +17,37 @@ import org.gcube.application.geoportal.common.rest.MongoConcessioni;
import org.gcube.application.geoportal.common.rest.TempFile;
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
import org.gcube.application.geoportalcommon.GeoportalCommon;
-import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
+import org.gcube.application.geoportalcommon.MongoServiceCommon;
+import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile;
+import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
+import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
+import org.gcube.application.geoportalcommon.shared.SearchingFilter;
+import org.gcube.application.geoportalcommon.shared.config.ACTION_ON_ITEM;
+import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole;
+import org.gcube.application.geoportalcommon.shared.config.RoleRights;
+import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE;
+import org.gcube.application.geoportalcommon.shared.exception.GNAConfigException;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV;
+import org.gcube.common.portal.PortalContext;
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
-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.MongoServiceUtil.ConcessioneValidationReportStatusComparator;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
+import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile;
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.user.geoportaldataentry.shared.UserRights;
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
+import org.gcube.vomanagement.usermanagement.RoleManager;
+import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
+import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
+import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
+import org.gcube.vomanagement.usermanagement.model.GCubeRole;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,6 +67,29 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
public static final String GEONA_GENERIC_RESOURCE_SECONDARY_TYPE = "GEONA_GENERIC_RESOURCE_SECONDARY_TYPE";
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataEntryServiceImpl.class);
+ /**
+ * Gets the GNA data entry config profile.
+ *
+ * @return the GNA data entry config profile
+ * @throws Exception the exception
+ */
+ private GNADataEntryConfigProfile getGNADataEntryConfigProfile() throws Exception {
+
+ GNADataEntryConfigProfile profile = SessionUtil.getGNADataEntryConfigProfile(getThreadLocalRequest());
+ if (profile == null) {
+ LOG.info(GNADataEntryConfigProfile.class.getSimpleName() + " is null, loading configurations from IS");
+ //to be sure
+ SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
+ GeoportalCommon gCommon = new GeoportalCommon();
+ profile = gCommon.readGNADataEntryConfig();
+ SessionUtil.setGNADataEntryConfigProfile(getThreadLocalRequest(), profile);
+ } else {
+ LOG.info(GNADataEntryConfigProfile.class.getSimpleName() + " read from session");
+ }
+
+ return profile;
+ }
+
/**
* Save geona data forms.
*
@@ -362,8 +395,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
try {
theSecondaryType = this.getServletContext().getInitParameter(GEONA_GENERIC_RESOURCE_SECONDARY_TYPE);
} catch (Exception e) {
- LOG.error("I cannot read the init parameter for: " + GEONA_GENERIC_RESOURCE_SECONDARY_TYPE, e);
+ LOG.warn("I cannot read the init parameter for: " + GEONA_GENERIC_RESOURCE_SECONDARY_TYPE, e);
theSecondaryType = "GeoNaMetadata";
+ LOG.warn("Using default SecondaryType: " + theSecondaryType);
}
// LOG.warn("\n\n\nHARD-CABLING THE SCOPE, PLEASE REMOTE IT!!!!\n\n\n");
@@ -387,7 +421,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
LOG.info("getLinksFor called");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
- GeoNaDataViewerProfile grViewerProfile = SessionUtil.getGeportalViewerResourceProfile(getThreadLocalRequest());
+ GNADataViewerConfigProfile grViewerProfile = SessionUtil
+ .getGeportalViewerResourceProfile(getThreadLocalRequest());
GeoportalCommon gc = new GeoportalCommon(grViewerProfile);
GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toString().toLowerCase());
item = gc.getPublicLinksFor(item, false);
@@ -406,147 +441,26 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
* @throws Exception the exception
*/
@Override
- public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SortFilter filter,
+ public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter,
boolean reloadFromService) throws Exception {
LOG.info("getListConcessioni called wit start: " + start + ", limit: " + limit + ", filter: " + filter);
try {
+
+ SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
+ MongoServiceCommon serviceCommon = new MongoServiceCommon();
+
+ // TODO MUST BE REPLACED BY COUNT
List listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest(),
reloadFromService);
int listConcessioniSize = listOfConcessioni.size();
- List toReturn = new ArrayList();
- int startIndex;
- int limitIndex = 0;
- if (start == null && limit == null) {
- startIndex = 0;
- limitIndex = listConcessioniSize;
- } else {
- startIndex = start;
- limitIndex = start + limit;
- if (limitIndex > listConcessioniSize) {
- limitIndex = listConcessioniSize;
- }
- }
-
- ResultSetPaginatedData searchedData = new ResultSetPaginatedData(start, limit, startIndex, false);
- searchedData.setTotalItems(listConcessioniSize);
-
- RECORD_FIELD orderBy = null;
- ORDER order = null;
- ConcessioneValidationReportStatusComparator statusComparator = null;
-
- if (filter == null) {
- // unsorted list of records
- toReturn = listOfConcessioni.subList(startIndex, limitIndex);
- } else {
-
- orderBy = filter.getOrderByField();
- order = filter.getOrder();
-
- if (orderBy == null)
- orderBy = RECORD_FIELD.NAME;
-
- if (order == null)
- order = ORDER.ASC;
-
- // CASE INSENSITIVE COMPARATOR
- Comparator comparator = null;
-
- switch (orderBy) {
- case NAME:
- if (order.equals(ORDER.ASC)) {
- comparator = Comparator.comparing(Concessione::getNome,
- Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER));
- } else {
- comparator = Comparator
- .comparing(Concessione::getNome, Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER))
- .reversed();
- }
-
- break;
- case CREATED:
- if (order.equals(ORDER.ASC)) {
- comparator = Comparator.comparing(Concessione::getCreationTime,
- Comparator.nullsLast(Comparator.naturalOrder()));
- } else {
- comparator = Comparator.comparing(Concessione::getCreationTime,
- Comparator.nullsLast(Comparator.naturalOrder())).reversed();
- }
- break;
-
- case CREATED_BY:
- if (order.equals(ORDER.ASC)) {
- comparator = Comparator.comparing(Concessione::getCreationUser,
- Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER));
- } else {
- comparator = Comparator.comparing(Concessione::getCreationUser,
- Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)).reversed();
- }
- break;
-
- // 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()));
- } else {
- comparator = Comparator.comparing(Concessione::getDataInizioProgetto,
- Comparator.nullsLast(Comparator.naturalOrder())).reversed();
- }
- break;
-
- case RECORD_STATUS:
- statusComparator = new ConcessioneValidationReportStatusComparator();
- default:
- break;
- }
-
- // sorting with nullsLast
- if (comparator != null)
- listOfConcessioni.sort(Comparator.nullsLast(comparator));
-
- // solution quick&dirty
- try {
- if (statusComparator != null) {
- if (order.equals(ORDER.ASC)) {
- listOfConcessioni.sort(Comparator.nullsLast(statusComparator));
- } else {
- Collections.sort(listOfConcessioni, Comparator.nullsLast(
- Collections.reverseOrder(new ConcessioneValidationReportStatusComparator())));
- }
- }
- } catch (Exception e) {
- LOG.warn("comparator Exception: " + e.getMessage());
- }
-
- LOG.trace("sorted list: " + listOfConcessioni);
- // pagination
- toReturn = listOfConcessioni.subList(startIndex, limitIndex);
- }
-
- List toReturnList = new ArrayList(toReturn.size());
-
- for (Concessione concessione : toReturn) {
- ConcessioneDV concessioneDV = ConvertToDataViewModel.toMetadataConcessione(concessione, true);
- toReturnList.add(concessioneDV);
- }
-
- searchedData.setData(toReturnList);
-
- if (listConcessioniSize == limit || listConcessioniSize == 0) {
- LOG.debug("Page completed returning " + listConcessioniSize + " items");
- int newOffset = startIndex + start;
- searchedData.setServerSearchFinished(newOffset > listConcessioniSize || listConcessioniSize == 0);
- LOG.debug("is Search finished: " + searchedData.isServerSearchFinished());
- return searchedData;
- }
-
- LOG.debug("Returning: " + toReturnList);
- LOG.info("Returning list of concessioni with size: " + toReturnList.size());
+ ResultSetPaginatedData searchedData = serviceCommon.queryOnMongo(listConcessioniSize, start, limit, filter,
+ "concessione");
return searchedData;
+
} catch (Exception e) {
- LOG.error("Error on loading list of concessioni: ", e);
+ LOG.error("Error on loading paginated and filtered list of concessioni: ", e);
throw new Exception("Error occurred on loading list of Concessioni. Error: " + e.getMessage());
}
@@ -760,19 +674,19 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
String toEditPath = null;
AddSectionToConcessioneRequest request = null;
List files = new ArrayList();
-
+
// Managing files already present as current content and kept by user
List keepFiles = serviceUtil.toTemFilesFromWSC(keepCurrentContent);
if (keepFiles != null) {
files.addAll(keepFiles);
- LOG.debug(keepFiles.size() +" current corrent file/s has/have been added to list of files");
+ LOG.debug(keepFiles.size() + " current corrent file/s has/have been added to list of files");
}
// Managing new files uploaded by user
List newFiles = serviceUtil.toTemFiles(gDBean.getFilesUploaded());
if (newFiles != null) {
files.addAll(newFiles);
- LOG.debug(newFiles.size() +" new file/s has/have been added to list of files");
+ LOG.debug(newFiles.size() + " new file/s has/have been added to list of files");
}
// if (files == null || files.isEmpty())
@@ -808,21 +722,21 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
Concessione concessione = clientMongo.cleanFileSet(itemId, toEditPath);
LOG.debug("Sending new Fileset ..");
- if(files.size()>0) {
+ if (files.size() > 0) {
// StorageUtils storage=new StorageUtils();
// Building TempFile
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
- LOG.info("Registering FileSet into recordId " + itemId + " with request path: " + toEditPath + " and: "
- + files.size() + " file/s");
+ LOG.info("Registering FileSet into recordId " + itemId + " with request path: " + toEditPath
+ + " and: " + files.size() + " file/s");
concessione = clientMongo.registerFileSet(itemId, request);
- }else {
+ } else {
LOG.info("Fileset is empty, skipping registerFileSet");
}
-
- LOG.info("Publishings itemId: "+itemId);
+
+ LOG.info("Publishings itemId: " + itemId);
concessione = clientMongo.publish(itemId);
-
- LOG.debug("returning concessione: "+concessione);
+
+ LOG.debug("returning concessione: " + concessione);
return ConvertToDataViewModel.toConcessione(concessione);
}
@@ -834,5 +748,94 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
"Error occurred on updating the project with id: " + itemId + ". Error: " + e.getMessage());
}
}
+
+ @Override
+ public GNADataEntryExtConfigProfile readDataViewerConfig() throws Exception {
+ LOG.info("readDataViewerConfig called");
+ GCubeUser user = null;
+ GNADataEntryExtConfigProfile gnaDEExtConfig = new GNADataEntryExtConfigProfile();
+ try {
+ PortalContext pContext = PortalContext.getConfiguration();
+ user = pContext.getCurrentUser(this.getThreadLocalRequest());
+ String scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
+
+ GNADataEntryConfigProfile config = getGNADataEntryConfigProfile();
+ List listUserRightsForRole = config.getPermissionsForRole();
+ gnaDEExtConfig.setListItemFields(config.getListItemFields());
+ gnaDEExtConfig.setPermissionsForRole(listUserRightsForRole);
+
+ // DEV MODE
+ if (!SessionUtil.isIntoPortal()) {
+ LOG.warn("OUT OF PORTAL - DEV MODE detected");
+ GcubeUserRole myRole = GcubeUserRole.DATA_EDITOR;
+
+ for (RoleRights roleRight : listUserRightsForRole) {
+ if (roleRight.getUserRole().equals(myRole)) {
+ UserRights userRights = new UserRights(user.getUsername(), roleRight);
+ LOG.warn("DEV MODE returning: " + userRights);
+ gnaDEExtConfig.setUserRights(userRights);
+ return gnaDEExtConfig;
+ }
+ }
+ }
+
+ long groupId = pContext.getCurrentGroupId(this.getThreadLocalRequest());
+
+ if (user == null || scope == null) {
+ LOG.warn("called getMyRightsInTheContext with invalid parameter user: " + user + ", in the scope: "
+ + scope, ", returning null");
+ return null;
+ }
+
+ LOG.info("reading GcubeUserRole for user: " + user.getUsername() + ", in the scope: " + scope);
+ // The following snippet should pass in the service-side
+ RoleManager roleManager = new LiferayRoleManager();
+ List roles = roleManager.listRolesByUserAndGroup(user.getUserId(), groupId);
+ List listMyRoles = new ArrayList();
+ for (GCubeRole gCubeRole : roles) {
+ if (gCubeRole.getRoleName().equalsIgnoreCase(GcubeUserRole.DATA_EDITOR.getName())) {
+ listMyRoles.add(GcubeUserRole.DATA_EDITOR);
+ }
+ if (gCubeRole.getRoleName().equalsIgnoreCase(GcubeUserRole.DATA_MANAGER.getName())) {
+ listMyRoles.add(GcubeUserRole.DATA_MANAGER);
+ }
+ }
+
+ // Mapping to roles "known"
+ LOG.info(
+ "For user: " + user.getUsername() + " in the scope: " + scope + " read the role/s: " + listMyRoles);
+
+ GcubeUserRole myRole = null;
+ if (listMyRoles.contains(GcubeUserRole.DATA_MANAGER))
+ myRole = GcubeUserRole.DATA_MANAGER;
+ else if (listMyRoles.contains(GcubeUserRole.DATA_EDITOR))
+ myRole = GcubeUserRole.DATA_EDITOR;
+ else
+ myRole = GcubeUserRole.DATA_MEMBER;
+
+ LOG.info("using highest role: " + myRole);
+
+ RoleRights toRoleRight = null;
+ for (RoleRights roleRight : listUserRightsForRole) {
+ if (roleRight.getUserRole().equals(myRole)) {
+ toRoleRight = roleRight;
+ break;
+ }
+ }
+ UserRights userRights = new UserRights(user.getUsername(), toRoleRight);
+ LOG.info("returning: " + userRights);
+ gnaDEExtConfig.setUserRights(userRights);
+ return gnaDEExtConfig;
+ } catch (UserRetrievalFault | GroupRetrievalFault | GNAConfigException e) {
+ LOG.error("An error occurred during getMyRightsInTheContext: " + user, e);
+
+ Map permissions = new HashMap();
+ RoleRights roleRights = new RoleRights(permissions, GcubeUserRole.DATA_MEMBER);
+ UserRights ur = new UserRights(user.getUsername(), roleRights);
+ LOG.warn("Returning default user rights: " + ur);
+ gnaDEExtConfig.setUserRights(ur);
+ return gnaDEExtConfig;
+ }
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java
index 42bad84..a092374 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java
@@ -23,7 +23,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * The Class MongoServiceUtil.
+ * The Class MongoServiceCommon.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
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 0b6e5eb..80e1177 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
@@ -13,7 +13,8 @@ import javax.servlet.http.HttpSession;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
import org.gcube.application.geoportalcommon.GeoportalCommon;
-import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
+import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile;
+import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
@@ -38,6 +39,8 @@ import com.liferay.portal.service.UserLocalServiceUtil;
*/
public class SessionUtil {
+ private static final String GNA_DATAENTRY_CONFIG_PROFILE = "GNA_DATAENTRY_CONFIG_PROFILE";
+ private static final String LATEST_RESULT_SET_SORTED = "LATEST_RESULT_SET_SORTED";
private static final String GEONA_DATAVIEWER_PROFILE = "GEONA_DATAVIEWER_PROFILE";
private static final String LIST_OF_CONCESSIONI = "LIST_OF_CONCESSIONI";
/** The log. */
@@ -173,15 +176,15 @@ public class SessionUtil {
* @return the geportal viewer resource profile
* @throws Exception the exception
*/
- public static GeoNaDataViewerProfile getGeportalViewerResourceProfile(HttpServletRequest httpServletRequest)
+ public static GNADataViewerConfigProfile getGeportalViewerResourceProfile(HttpServletRequest httpServletRequest)
throws Exception {
HttpSession session = httpServletRequest.getSession();
- GeoNaDataViewerProfile geoNaDataViewerProfile = (GeoNaDataViewerProfile) session
+ GNADataViewerConfigProfile geoNaDataViewerProfile = (GNADataViewerConfigProfile) session
.getAttribute(GEONA_DATAVIEWER_PROFILE);
if (geoNaDataViewerProfile == null) {
GeoportalCommon gc = new GeoportalCommon();
- geoNaDataViewerProfile = gc.getGeoNaDataViewProfile(null);
+ geoNaDataViewerProfile = gc.readGNADataViewerConfig(null);
session.setAttribute(GEONA_DATAVIEWER_PROFILE, geoNaDataViewerProfile);
}
@@ -197,18 +200,41 @@ public class SessionUtil {
*/
public static ResultSetSorted getLatestResultSetSorted(HttpServletRequest httpServletRequest) {
HttpSession session = httpServletRequest.getSession();
- return (ResultSetSorted) session.getAttribute("LATEST_RESULT_SET_SORTED");
+ return (ResultSetSorted) session.getAttribute(LATEST_RESULT_SET_SORTED);
}
/**
* Gets the latest sort filter.
*
* @param httpServletRequest the http servlet request
+ * @param rsSorted the rs sorted
* @return the latest sort filter
*/
public static void setLatestResultSetSorted(HttpServletRequest httpServletRequest, ResultSetSorted rsSorted) {
HttpSession session = httpServletRequest.getSession();
- session.setAttribute("LATEST_RESULT_SET_SORTED", rsSorted);
+ session.setAttribute(LATEST_RESULT_SET_SORTED, rsSorted);
}
+ /**
+ * Gets the GNA data entry config profile.
+ *
+ * @param httpServletRequest the http servlet request
+ * @return the GNA data entry config profile
+ */
+ public static GNADataEntryConfigProfile getGNADataEntryConfigProfile(HttpServletRequest httpServletRequest) {
+ HttpSession session = httpServletRequest.getSession();
+ return (GNADataEntryConfigProfile) session.getAttribute(GNA_DATAENTRY_CONFIG_PROFILE);
+ }
+
+ /**
+ * Sets the GNA data entry config profile.
+ *
+ * @param httpServletRequest the http servlet request
+ * @param gNADEConfigProfile the g NADE config profile
+ */
+ public static void setGNADataEntryConfigProfile(HttpServletRequest httpServletRequest,
+ GNADataEntryConfigProfile gNADEConfigProfile) {
+ HttpSession session = httpServletRequest.getSession();
+ session.setAttribute(GNA_DATAENTRY_CONFIG_PROFILE, gNADEConfigProfile);
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GNADataEntryExtConfigProfile.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GNADataEntryExtConfigProfile.java
new file mode 100644
index 0000000..944d3b7
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GNADataEntryExtConfigProfile.java
@@ -0,0 +1,46 @@
+package org.gcube.portlets.user.geoportaldataentry.shared;
+
+import java.io.Serializable;
+
+import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile;
+
+/**
+ * The Class GNADataEntryExtConfigProfile.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Dec 21, 2021
+ */
+public class GNADataEntryExtConfigProfile extends GNADataEntryConfigProfile implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3185317083819447952L;
+ private UserRights userRights = null;
+
+ /**
+ * Instantiates a new GNA data entry config profile.
+ */
+ public GNADataEntryExtConfigProfile() {
+
+ }
+
+ public UserRights getUserRights() {
+ return userRights;
+ }
+
+ public void setUserRights(UserRights userRights) {
+ this.userRights = userRights;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("GNADataEntryExtConfigProfile [userRights=");
+ builder.append(userRights);
+ builder.append("]");
+ return builder.toString();
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GeonaISConfig.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GeonaISConfig.java
index 4e35d33..1ec007e 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GeonaISConfig.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GeonaISConfig.java
@@ -2,39 +2,73 @@ package org.gcube.portlets.user.geoportaldataentry.shared;
import java.io.Serializable;
-public class GeonaISConfig implements Serializable{
-
-
+/**
+ * The Class GeonaISConfig.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Dec 22, 2021
+ */
+public class GeonaISConfig implements Serializable {
+
+
/**
*
*/
- private static final long serialVersionUID = -6700506811708315617L;
-
- String gRSecondaryType;
- String scope;
-
+ private static final long serialVersionUID = 4187839053354198268L;
+ private String genericResSecondaryType;
+ private String scope;
+
+ /**
+ * Instantiates a new geona IS config.
+ */
public GeonaISConfig() {
}
+ /**
+ * Instantiates a new geona IS config.
+ *
+ * @param gRSecondaryType the g R secondary type
+ * @param scope the scope
+ */
public GeonaISConfig(String gRSecondaryType, String scope) {
super();
- this.gRSecondaryType = gRSecondaryType;
+ this.genericResSecondaryType = gRSecondaryType;
this.scope = scope;
}
-
- public String getgRSecondaryType() {
- return gRSecondaryType;
+ /**
+ * Gets the generic resource secondary type.
+ *
+ * @return the generic resource secondary type
+ */
+ public String getGenericResourceSecondaryType() {
+ return genericResSecondaryType;
}
- public void setgRSecondaryType(String gRSecondaryType) {
- this.gRSecondaryType = gRSecondaryType;
+ /**
+ * Sets the generic resource secondary type.
+ *
+ * @param gRSecondaryType the new generic resource secondary type
+ */
+ public void setGenericResourceSecondaryType(String gRSecondaryType) {
+ this.genericResSecondaryType = gRSecondaryType;
}
+ /**
+ * Gets the scope.
+ *
+ * @return the scope
+ */
public String getScope() {
return scope;
}
+ /**
+ * Sets the scope.
+ *
+ * @param scope the new scope
+ */
public void setScope(String scope) {
this.scope = scope;
}
@@ -42,14 +76,12 @@ public class GeonaISConfig implements Serializable{
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
- builder.append("GeonaISConfig [gRSecondaryType=");
- builder.append(gRSecondaryType);
+ builder.append("GeonaISConfig [genericResSecondaryType=");
+ builder.append(genericResSecondaryType);
builder.append(", scope=");
builder.append(scope);
builder.append("]");
return builder.toString();
}
-
-
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetPaginatedData.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetPaginatedData.java
deleted file mode 100644
index d838915..0000000
--- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetPaginatedData.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/**
- *
- */
-package org.gcube.portlets.user.geoportaldataentry.shared;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
-
-
-/**
- * The Class ResultSetPaginatedData.
- *
- * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
- *
- * Aug 6, 2021
- */
-public class ResultSetPaginatedData implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 6800997954077785719L;
- private List data;
- private int clientStartIndex = 0;
- private int limit;
- private int serverEndIndex = 0;
- private boolean isServerSearchFinished = false;
- private long totalItems;
-
- /**
- * Instantiates a new searched folder.
- */
- public ResultSetPaginatedData() {
- }
-
-
- /**
- * Instantiates a new result set paginated data.
- *
- * @param clientStartIndex the client start index
- * @param limit the limit
- * @param serverEndIndex the server end index
- * @param isServerSearchFinished the is server search finished
- */
- public ResultSetPaginatedData(int clientStartIndex, int limit, int serverEndIndex, boolean isServerSearchFinished) {
-
- this.clientStartIndex = clientStartIndex;
- this.limit = limit;
- this.serverEndIndex = serverEndIndex;
- this.isServerSearchFinished = isServerSearchFinished;
- }
-
- /**
- * Gets the data.
- *
- * @return the data
- */
- public List getData() {
- return data;
- }
-
- /**
- * Gets the client start index.
- *
- * @return the client start index
- */
- public int getClientStartIndex() {
- return clientStartIndex;
- }
-
- /**
- * Gets the limit.
- *
- * @return the limit
- */
- public int getLimit() {
- return limit;
- }
-
- /**
- * Gets the server end index.
- *
- * @return the server end index
- */
- public int getServerEndIndex() {
- return serverEndIndex;
- }
-
- /**
- * Checks if is server search finished.
- *
- * @return true, if is server search finished
- */
- public boolean isServerSearchFinished() {
- return isServerSearchFinished;
- }
-
- /**
- * Sets the data.
- *
- * @param data the new data
- */
- public void setData(List data) {
- this.data = data;
- }
-
- /**
- * Sets the client start index.
- *
- * @param clientStartIndex the new client start index
- */
- public void setClientStartIndex(int clientStartIndex) {
- this.clientStartIndex = clientStartIndex;
- }
-
- /**
- * Sets the limit.
- *
- * @param limit the new limit
- */
- public void setLimit(int limit) {
- this.limit = limit;
- }
-
- /**
- * Sets the server end index.
- *
- * @param serverEndIndex the new server end index
- */
- public void setServerEndIndex(int serverEndIndex) {
- this.serverEndIndex = serverEndIndex;
- }
-
- /**
- * Sets the server search finished.
- *
- * @param isServerSearchFinished the new server search finished
- */
- public void setServerSearchFinished(boolean isServerSearchFinished) {
- this.isServerSearchFinished = isServerSearchFinished;
- }
-
- /**
- * Gets the total items.
- *
- * @return the total items
- */
- public long getTotalItems() {
- return totalItems;
- }
-
- /**
- * Sets the total items.
- *
- * @param totalItems the new total items
- */
- public void setTotalItems(long totalItems) {
- this.totalItems = totalItems;
- }
-
- /**
- * To string.
- *
- * @return the string
- */
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("ResultSetPaginatedData [data=");
- builder.append(data);
- builder.append(", clientStartIndex=");
- builder.append(clientStartIndex);
- builder.append(", limit=");
- builder.append(limit);
- builder.append(", serverEndIndex=");
- builder.append(serverEndIndex);
- builder.append(", isServerSearchFinished=");
- builder.append(isServerSearchFinished);
- builder.append(", totalItems=");
- builder.append(totalItems);
- builder.append("]");
- return builder.toString();
- }
-
-
-
-}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetSorted.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetSorted.java
index 412d1a0..7cc44dc 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetSorted.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetSorted.java
@@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.List;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
+import org.gcube.application.geoportalcommon.shared.SearchingFilter;
public class ResultSetSorted implements Serializable {
@@ -12,7 +13,7 @@ public class ResultSetSorted implements Serializable {
*/
private static final long serialVersionUID = 889420364685643758L;
- private SortFilter searchFilter;
+ private SearchingFilter searchFilter;
private List data;
@@ -20,13 +21,13 @@ public class ResultSetSorted implements Serializable {
}
- public ResultSetSorted(SortFilter searchFilter, List data) {
+ public ResultSetSorted(SearchingFilter searchFilter, List data) {
super();
this.searchFilter = searchFilter;
this.data = data;
}
- public SortFilter getSearchFilter() {
+ public SearchingFilter getSearchFilter() {
return searchFilter;
}
@@ -34,7 +35,7 @@ public class ResultSetSorted implements Serializable {
return data;
}
- public void setSearchFilter(SortFilter searchFilter) {
+ public void setSearchFilter(SearchingFilter searchFilter) {
this.searchFilter = searchFilter;
}
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
deleted file mode 100644
index 5226711..0000000
--- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SortFilter.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.gcube.portlets.user.geoportaldataentry.shared;
-
-import java.io.Serializable;
-
-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
- */
-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;
- }
- }
-
- /**
- *
- */
- private static final long serialVersionUID = -4004094263090373626L;
-
- private RECORD_FIELD orderByField;
-
- private ORDER order;
-
- /**
- * Instantiates a new sort filter.
- */
- public SortFilter() {
-
- }
-
- /**
- * Instantiates a new sort filter.
- *
- * @param orderByField the order by field
- * @param order the order
- */
- public SortFilter(RECORD_FIELD orderByField, ORDER order) {
- this.orderByField = orderByField;
- this.order = order;
- }
-
- /**
- * Gets the order by field.
- *
- * @return the order by field
- */
- public RECORD_FIELD getOrderByField() {
- return orderByField;
- }
-
- /**
- * Gets the order.
- *
- * @return the order
- */
- public ORDER getOrder() {
- return order;
- }
-
- /**
- * Sets the order by field.
- *
- * @param orderByField the new order by field
- */
- public void setOrderByField(RECORD_FIELD orderByField) {
- this.orderByField = orderByField;
- }
-
- /**
- * Sets the order.
- *
- * @param order the new order
- */
- public void setOrder(ORDER order) {
- this.order = order;
- }
-
- /**
- * To string.
- *
- * @return the string
- */
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("SortFilter [orderByField=");
- builder.append(orderByField);
- builder.append(", order=");
- builder.append(order);
- builder.append("]");
- return builder.toString();
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/UserRights.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/UserRights.java
new file mode 100644
index 0000000..2b25960
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/UserRights.java
@@ -0,0 +1,65 @@
+package org.gcube.portlets.user.geoportaldataentry.shared;
+
+import java.io.Serializable;
+
+import org.gcube.application.geoportalcommon.shared.config.RoleRights;
+
+/**
+ * The Class UserRights.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Nov 24, 2021
+ */
+public class UserRights implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -304157165851633221L;
+
+ private String myUsername;
+
+ private RoleRights roleRights;
+
+ /**
+ * Instantiates a new user rights.
+ */
+ public UserRights() {
+ super();
+ }
+
+ public UserRights(String myUsername, RoleRights roleRights) {
+ super();
+ this.myUsername = myUsername;
+ this.roleRights = roleRights;
+ }
+
+ public String getMyUsername() {
+ return myUsername;
+ }
+
+ public RoleRights getRoleRights() {
+ return roleRights;
+ }
+
+ public void setMyUsername(String myUsername) {
+ this.myUsername = myUsername;
+ }
+
+ public void setRoleRights(RoleRights roleRights) {
+ this.roleRights = roleRights;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("UserRights [myUsername=");
+ builder.append(myUsername);
+ builder.append(", roleRights=");
+ builder.append(roleRights);
+ builder.append("]");
+ return builder.toString();
+ }
+
+}
diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css
index 3965771..0f43430 100644
--- a/src/main/webapp/GeoPortalDataEntryApp.css
+++ b/src/main/webapp/GeoPortalDataEntryApp.css
@@ -119,3 +119,30 @@ h1 {
margin-left: 10px;
width: 95%;
}
+
+.nav-toolbar-style {
+ margin-bottom: 5px;
+}
+
+.nav-toolbar-style .container {
+ padding-top: 5px;
+}
+
+.search-textbox {
+ padding: 4px 14px !important;
+ margin-bottom: 0 !important;
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
+ font-size: 13px !important;
+ font-weight: normal !important;
+ -webkit-border-radius: 15px;
+ -moz-border-radius: 15px;
+ border-radius: 15px !important;
+ width: 250px !important;
+ margin-top: 8px !important;
+}
+
+.alert_box_nav {
+ padding: 4px 10px !important;
+ margin-top: 8px !important;
+ margin-bottom: 10px !important;
+}
diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataentry/client/TestClass.java b/src/test/java/org/gcube/portlets/user/geoportaldataentry/client/TestClass.java
index b3d9e17..4119769 100644
--- a/src/test/java/org/gcube/portlets/user/geoportaldataentry/client/TestClass.java
+++ b/src/test/java/org/gcube/portlets/user/geoportaldataentry/client/TestClass.java
@@ -3,42 +3,40 @@ package org.gcube.portlets.user.geoportaldataentry.client;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import org.bson.Document;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
+import org.gcube.application.geoportal.common.model.rest.QueryRequest;
+import org.gcube.application.geoportal.common.model.rest.QueryRequest.OrderedRequest;
+import org.gcube.application.geoportal.common.model.rest.QueryRequest.OrderedRequest.Direction;
+import org.gcube.application.geoportal.common.model.rest.QueryRequest.PagedRequest;
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
+import com.mongodb.BasicDBList;
+import com.mongodb.BasicDBObject;
+import com.mongodb.BasicDBObjectBuilder;
+
public class TestClass {
-
private static String TOKEN = "";
- private static String CONTEXT ="/gcube/devsec/devVRE";
-
-
- public static void main(String[] args) throws Exception {
+ private static String CONTEXT = "/gcube/devsec/devVRE";
+ private static String USERNAME = "francesco.mangiacrapa";
+
+ //@Before
+ public void init() {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
-
-// LocalDateTime ldt = ConvertToServiceModel.toLocalDateTime("2020-10-01 10:20");
-// System.out.println(ldt.toString());
-//
-// String latitudine = "-899.2986";
-// // System.out.println(latitudine.matches("^[-]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
-//
-// String longitude = "0";
-// System.out.println(longitude.matches("\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
-//
-// GeoportalDataEntryServiceImpl g = new GeoportalDataEntryServiceImpl();
-// g.getLinksFor("", ConstantsGeoPortalDataEntryApp.RECORD_TYPE.CONCESSIONE.toString());
-
- getListOfConcessioni();
-
}
- public static void getListOfConcessioni() throws Exception {
+ // @Test
+ public void getListConcessioniTest() throws Exception {
MongoConcessioni clientMongo = mongoConcessioni().build();
Iterator concessioni = clientMongo.getList();
List listOfConcessioni = new ArrayList();
@@ -46,13 +44,138 @@ public class TestClass {
while (concessioni.hasNext()) {
Concessione concessione = (Concessione) concessioni.next();
listOfConcessioni.add(concessione);
-
+
}
}
int i = 0;
for (Concessione concessione : listOfConcessioni) {
- System.out.println(++i+" "+concessione);
+ System.out.println(++i + " " + concessione);
}
}
+ //@Test
+ public void queryConcessioniTest() throws Exception {
+ try {
+ MongoConcessioni clientMongo = mongoConcessioni().build();
+ int offsetIndex = 0;
+ int limitIndex = 25;
+ Direction sDirection = Direction.ASCENDING;
+ List orderByFields = Arrays.asList("nome");
+
+ Map searchFields = new HashMap();
+ searchFields.put("nome", "test");
+ searchFields.put("authors", "fra");
+
+ QueryRequest request = new QueryRequest();
+ PagedRequest paging = new PagedRequest();
+ paging.setOffset(offsetIndex);
+ paging.setLimit(limitIndex);
+ request.setPaging(paging);
+
+ OrderedRequest ordering = new OrderedRequest();
+
+ ordering.setDirection(sDirection);
+
+ ordering.setFields(orderByFields);
+ request.setOrdering(ordering);
+
+ Document query = null;
+
+ if (searchFields != null) {
+
+ BasicDBObjectBuilder builder = BasicDBObjectBuilder.start();
+
+ query = new Document();
+
+ for (String key : searchFields.keySet()) {
+ // builder.append(key, new BasicDBObject("$eq", searchFields.get(key)));
+ BasicDBObject bs = new BasicDBObject();
+ bs.append("$regex", searchFields.get(key));
+ bs.append("$options", "i");
+ builder.append(key, bs);
+ // query.put(key, new BasicDBObject("$eq", searchFields.get(key)));
+ // query = new Document(key, searchFields.get(key));
+ }
+
+// query.putAll(builder.get().toMap());
+// request.setFilter(query);
+
+ BasicDBList list = new BasicDBList();
+ list.add(builder.get().toMap());
+ query.put("$or", list);
+ // or(query);
+ request.setFilter(query);
+
+ // ************************************************ AND
+// query = new Document();
+// for (String key : searchFields.keySet()) {
+// //AND
+// BasicDBObject bs = new BasicDBObject();
+// bs.append("$regex", searchFields.get(key));
+// bs.append("$options", "i");
+// query.put(key, bs);
+//
+// }
+// request.setFilter(query);
+ // ******************************************** END AND
+ }
+
+ // OR
+ /*
+ * query = new Document(); BasicDBObject container = new BasicDBObject();
+ * BsonArray bArray = new BsonArray(); for (String key : searchFields.keySet())
+ * { //AND BasicDBObject bs = new BasicDBObject(); bs.append("$regex",
+ * searchFields.get(key)); bs.append("$options", "i"); query.put(key, bs);
+ *
+ * //container.put(key, bs);
+ *
+ *
+ * // BasicDBObject bs2 = new BasicDBObject(); // bs2.append("$regex",
+ * searchFields.get(key)); // bs2.append("$options", "i"); // BsonDocument bsK =
+ * new BsonDocument(); // bsK.append(key, new BsonString(bs2.toJson())); //
+ * bArray.add(bsK);
+ *
+ * } // query.put("$or", bArray);
+ *
+ * BasicDBList list = new BasicDBList(); list.add(query);
+ *
+ * Document orDocument = new Document(); orDocument.put("$or", list); // query =
+ * orDocument; request.setFilter(query);
+ */
+
+ System.out.println("Paging offset: " + offsetIndex + ", limit: " + limitIndex);
+ System.out.println("Direction: " + sDirection);
+ System.out.println("Order by Fields: " + orderByFields);
+ System.out.println("Search for: " + query);
+ System.out.println("Search for Query to JSON: " + query.toJson());
+
+ Iterator concessioni = clientMongo.query(request);
+
+ if (concessioni.hasNext()) {
+ System.out.println("Found concessioni, printing them...");
+ } else
+ System.out.println("No concessione found");
+
+ if (concessioni != null) {
+ while (concessioni.hasNext()) {
+ Concessione concessione = (Concessione) concessioni.next();
+ System.out.println(concessione.getNome());
+
+ }
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ // @Test
+// public void readUserRights() throws Exception {
+// new GNARoleRitghtsConfigReader();
+// List listUserRights = GNARoleRitghtsConfigReader.readRoleRightsConfig();
+// System.out.println(listUserRights);
+// }
+
+
+
}