Starting migration to geoportal-data-list configuration for UCD

This commit is contained in:
Francesco Mangiacrapa 2022-08-08 17:43:13 +02:00
parent d62d7c9eec
commit 9e8aede170
14 changed files with 623 additions and 501 deletions

View File

@ -9,10 +9,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
#### Enhancements
- [#22684] Porting to Profiled Document
- [#22684] Migrated to geoportal-data-entry-app configuration for UCD
- [#23587] GUI model viewer passed to tree data structure
- Moved to maven-portal-bom v3.7.0[-SNAPSHOT]
- [#22883] Integrated with (the new) geoportal-client (>= 1.1.0-SNAPSHOT)
- [#22685] Migrated to geoportal-data-list configuration for UCD
## [v2.2.1] - 2022-06-29

View File

@ -1,5 +1,9 @@
package org.gcube.portlets.user.geoportaldataentry.client;
import java.util.Arrays;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.GEOPORTAL_DATA_HANDLER;
import org.gcube.portlets.widgets.mpformbuilder.client.ConstantsMPFormBuilder;
/**
@ -38,4 +42,7 @@ public class ConstantsGeoPortalDataEntryApp {
public enum ACTION_PERFORMED_ON_ITEM {
UPDATED_PROJECT
}
public static final List<String> HANDLERS_IDS = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_list.getId(),
GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId());
}

View File

@ -3,8 +3,10 @@ package org.gcube.portlets.user.geoportaldataentry.client;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
@ -14,13 +16,14 @@ 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.geoportal.ConfigurationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.HandlerDeclarationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.LifecycleInformationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.UseCaseDescriptorDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
@ -108,7 +111,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
private GeonaDataEntryMainForm geoNaMainForm = null;
//private Collection<GeoNaFormCardModel> orderedCards = new ArrayList<GeoNaFormCardModel>();
// private Collection<GeoNaFormCardModel> orderedCards = new
// ArrayList<GeoNaFormCardModel>();
private GeonaMainTabPanel mainTabPanel;
@ -122,14 +126,12 @@ public class GeoPortalDataEntryApp implements EntryPoint {
private LoaderIcon loader = new LoaderIcon("Loading Application... please wait");
private List<ItemFieldDV> displayFields = new ArrayList<ItemFieldDV>();
private List<ItemFieldDV> sortByFields = new ArrayList<ItemFieldDV>();
private List<ItemFieldDV> searchByFields = new ArrayList<ItemFieldDV>();
private GeonaISConfig geonaISConfig;
private TreeMap<String, List<GeoNaFormCardModel>> mapGcubeProfilePerItemType = new TreeMap<String, List<GeoNaFormCardModel>>();
private Map<String, List<ConfigurationDV<?>>> mapHandlersForProfileId = new HashMap<String, List<ConfigurationDV<?>>>();
private int numberOfCards = 0;
private int expectedCards = 0;
@ -233,35 +235,42 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
List<ItemFieldDV> itemFields = gNADataEntryConfig.getListItemFields();
// List<ItemFieldDV> itemFields = gNADataEntryConfig.getListItemFields();
//
// for (ItemFieldDV itemField : itemFields) {
// if (itemField.isDisplayAsResult()) {
// displayFields.add(itemField);
// }
//
// if (itemField.isSearchable()) {
// searchByFields.add(itemField);
// }
//
// if (itemField.isSortable()) {
// sortByFields.add(itemField);
// }
// }
//
// GWT.log("List display fields: " + itemFields);
// SearchingFilter initialSortFilter = new SearchingFilter();
// initialSortFilter.setOrder(ORDER.ASC);
// initialSortFilter.setOrderByFields(
// Arrays.asList(new ItemFieldDV("Name", Arrays.asList("name"), null, true, true, true)));
//
// displayFields = itemFields;
// mainTabPanel = new GeonaMainTabPanel(appManagerBus);
//
// mainTabPanel.setFilteringParameters(displayFields, sortByFields, searchByFields, initialSortFilter);
//
// // TWICE BECAUSE THE MAIN PANEL COULD BE NULL BEFORE
// setListUseCaseDescriptors(listUCDescriptors);
for (ItemFieldDV itemField : itemFields) {
if (itemField.isDisplayAsResult()) {
displayFields.add(itemField);
}
if (itemField.isSearchable()) {
searchByFields.add(itemField);
}
if (itemField.isSortable()) {
sortByFields.add(itemField);
}
}
GWT.log("List display fields: " + itemFields);
SearchingFilter initialSortFilter = new SearchingFilter();
List<ItemFieldDV> defaultItemField = Arrays
.asList(new ItemFieldDV("Name", Arrays.asList("name"), null, true, true, true));
initialSortFilter.setOrder(ORDER.ASC);
initialSortFilter.setOrderByFields(
Arrays.asList(new ItemFieldDV("Name", Arrays.asList("name"), null, true, true, true)));
displayFields = itemFields;
mainTabPanel = new GeonaMainTabPanel(appManagerBus, displayFields, sortByFields, searchByFields,
initialSortFilter);
// TWICE BECAUSE THE MAIN PANEL COULD BE NULL BEFORE
setListUseCaseDescriptors(listUCDescriptors);
initialSortFilter.setOrderByFields(defaultItemField);
mainTabPanel = new GeonaMainTabPanel(appManagerBus, defaultItemField, initialSortFilter);
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
mainTabPanel.addFormPanel(geoNaMainForm);
@ -315,10 +324,10 @@ public class GeoPortalDataEntryApp implements EntryPoint {
private void loadGeoportalConfigs(final String scope) {
GWT.log("loading GeoportalConfigsAndBuildCards in the scope: " + scope);
//orderedCards = new ArrayList<GeoNaFormCardModel>();
// orderedCards = new ArrayList<GeoNaFormCardModel>();
GeoportalDataEntryServiceAsync.Util.getInstance().getListUseCaseDescriptors(null,
new AsyncCallback<List<UseCaseDescriptorDV>>() {
GeoportalDataEntryServiceAsync.Util.getInstance().getListUseCaseDescriptors(
ConstantsGeoPortalDataEntryApp.HANDLERS_IDS, new AsyncCallback<List<UseCaseDescriptorDV>>() {
@Override
public void onFailure(Throwable caught) {
@ -339,6 +348,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
setListUseCaseDescriptors(listUCDescriptors);
}
});
}
@ -352,6 +362,48 @@ public class GeoPortalDataEntryApp implements EntryPoint {
if (mainTabPanel.getListUCDescriptors() == null) {
mainTabPanel.setListUseCaseDescriptors(listUCDescriptors);
}
for (UseCaseDescriptorDV useCaseDescriptorDV : listUCDescriptors) {
List<ConfigurationDV<?>> listConfigurations = mapHandlersForProfileId
.get(useCaseDescriptorDV.getProfileID());
if (listConfigurations == null) {
listConfigurations = new ArrayList<ConfigurationDV<?>>();
}
for (HandlerDeclarationDV handler : useCaseDescriptorDV.getHandlers()) {
ConfigurationDV<?> config = handler.getConfiguration();
listConfigurations.add(config);
}
mapHandlersForProfileId.put(useCaseDescriptorDV.getProfileID(), listConfigurations);
}
// for (ItemFieldDV itemField : itemFields) {
// if (itemField.isDisplayAsResult()) {
// displayFields.add(itemField);
// }
//
// if (itemField.isSearchable()) {
// searchByFields.add(itemField);
// }
//
// if (itemField.isSortable()) {
// sortByFields.add(itemField);
// }
// }
//
// GWT.log("List display fields: " + itemFields);
// SearchingFilter initialSortFilter = new SearchingFilter();
// initialSortFilter.setOrder(ORDER.ASC);
// initialSortFilter.setOrderByFields(
// Arrays.asList(new ItemFieldDV("Name", Arrays.asList("name"), null, true, true, true)));
//
// displayFields = itemFields;
// mainTabPanel = new GeonaMainTabPanel(appManagerBus);
//
// mainTabPanel.setFilteringParameters(displayFields, sortByFields, searchByFields, initialSortFilter);
}
}
}
@ -384,15 +436,15 @@ public class GeoPortalDataEntryApp implements EntryPoint {
List<GcubeProfileDV> listGPs) {
dataEntryProjectCreated = true;
mainTabPanel.setLoaderVisible("Loading...", true);
//orderedCards.clear();
// orderedCards.clear();
resetUI();
List<GeoNaFormCardModel> cardsPerIT = mapGcubeProfilePerItemType.get(handlerDeclarationDV.getItemType());
mainTabPanel.setPageHeader(handlerDeclarationDV);
if (cardsPerIT != null) {
GWT.log("Profiles/Cards per Item Type are: "+cardsPerIT);
//orderedCards.addAll(cardsPerIT);
GWT.log("Profiles/Cards per Item Type are: " + cardsPerIT);
// orderedCards.addAll(cardsPerIT);
buildNewCards(profileID, handlerDeclarationDV.getItemType(), new ArrayList<GeoNaFormCardModel>(cardsPerIT));
return;
}
@ -436,8 +488,9 @@ public class GeoPortalDataEntryApp implements EntryPoint {
GWT.log("TreeMap values: " + gnaCardsModels);
mapGcubeProfilePerItemType.put(handlerDeclarationDV.getItemType(),
new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
//orderedCards.addAll(new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
buildNewCards(profileID, handlerDeclarationDV.getItemType(), new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
// orderedCards.addAll(new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
buildNewCards(profileID, handlerDeclarationDV.getItemType(),
new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
}
}
@ -507,7 +560,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
private void resetUI() {
geoNaMainForm.resetUI();
//geoNaMainForm.remeTree(treeItemPanel);
// geoNaMainForm.remeTree(treeItemPanel);
mapForms.clear();
}
@ -607,8 +660,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modalContainerPanel.add(new HTML("Record id: " + (result.getProjectID())));
try {
savedMap.put(result.getProjectID(),
saveGeonaDataFormsEvent.getTreeNode());
savedMap.put(result.getProjectID(), saveGeonaDataFormsEvent.getTreeNode());
} catch (Exception e) {
// TODO: handle exception
}
@ -676,10 +728,10 @@ public class GeoPortalDataEntryApp implements EntryPoint {
selectedNode = (NodeItem) selectedItem.getWidget();
}
GWT.log("TreeItemEvent selected node is: "+selectedNode);
if(selectedNode.isRoot()) {
GWT.log("TreeItemEvent selected node is: " + selectedNode);
if (selectedNode.isRoot()) {
return;
}
@ -729,15 +781,16 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
TreeItem newSubTree = cloneSubTreeItems(selectedItem);
//TO DEBUG
//TreeVisitUtil.postOrderVisit(newSubTree);
// TO DEBUG
// TreeVisitUtil.postOrderVisit(newSubTree);
TreeItem parentItem = selectedItem.getParentItem();
int nextSiblingIndex = -1;
if (parentItem != null) {
nextSiblingIndex = parentItem.getChildIndex(selectedItem);
nextSiblingIndex++;
}
geoNaMainForm.getTreeItemPanel().addChild(selectedItem.getParentItem(), nextSiblingIndex, newSubTree);
geoNaMainForm.getTreeItemPanel().addChild(selectedItem.getParentItem(), nextSiblingIndex,
newSubTree);
break;
}
@ -770,9 +823,9 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onClick(ClickEvent event) {
confirm.hide();
//TODO QUA
// TODO QUA
createNewDataEntyFor(newProjectEvent.getProfileID(), newProjectEvent.getHandler(),
newProjectEvent.getListGcubeProfiles());
// buildNewCards(orderedCards, OPERATION.NEW);
@ -784,8 +837,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
} else if (projectSavedWithSuccess) {
// means the project has been saved
//TODO HERE
// TODO HERE
createNewDataEntyFor(newProjectEvent.getProfileID(), newProjectEvent.getHandler(),
newProjectEvent.getListGcubeProfiles());
// buildNewCards(orderedCards, OPERATION.NEW);
@ -799,11 +852,11 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onClick(ClickEvent event) {
confirm.hide();
//TODO HERE
//List<GeoNaFormCardModel> cardsPerIT = mapGcubeProfilePerItemType.get(newProjectEvent.getHandler().getItemType());
// TODO HERE
// List<GeoNaFormCardModel> cardsPerIT =
// mapGcubeProfilePerItemType.get(newProjectEvent.getHandler().getItemType());
createNewDataEntyFor(newProjectEvent.getProfileID(), newProjectEvent.getHandler(),
newProjectEvent.getListGcubeProfiles());
@ -821,8 +874,10 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) {
SearchingFilter sortFilter = getListOfRecordsEvent.getSortFilter();
List<ItemFieldDV> displayFields = mainTabPanel.getDisplayFields();
if (sortFilter == null) {
sortFilter = mainTabPanel.getCurrentSortFilter();
}
@ -832,16 +887,53 @@ public class GeoPortalDataEntryApp implements EntryPoint {
return;
}
if (getListOfRecordsEvent.isReloadFilteringParameters()) {
displayFields = new ArrayList<ItemFieldDV>();
List<ItemFieldDV> searchByFields = new ArrayList<ItemFieldDV>();
List<ItemFieldDV> sortByFields = new ArrayList<ItemFieldDV>();
List<ConfigurationDV<?>> config = mapHandlersForProfileId.get(getListOfRecordsEvent.getProfileID());
for (ConfigurationDV<?> configurationDV : config) {
switch (configurationDV.getConfigurationType()) {
case item_fields:
List<ItemFieldDV> listItemFields = (List<ItemFieldDV>) configurationDV.getConfiguration();
for (ItemFieldDV itemField : listItemFields) {
if (itemField.isDisplayAsResult()) {
displayFields.add(itemField);
}
if (itemField.isSearchable()) {
searchByFields.add(itemField);
}
if (itemField.isSortable()) {
sortByFields.add(itemField);
}
}
mainTabPanel.setFilteringParameters(displayFields, sortByFields, sortByFields, sortFilter);
break;
default:
break;
}
}
}
grpw = new GeonaRecordsPaginatedView(appManagerBus, profileID, displayFields, sortFilter);
mainTabPanel.showListOfConcessioniView(grpw);
}
});
appManagerBus.addHandler(ActionPerformedOnItemEvent.TYPE, new ActionPerformedOnItemEventHandler() {
@Override
public <T extends RecordDV> void onDoActionPerformedFired(
public <T extends DocumentDV> void onDoActionPerformedFired(
ActionPerformedOnItemEvent<T> actionPerformedOnItemEvent) {
if (actionPerformedOnItemEvent != null) {
@ -864,14 +956,17 @@ public class GeoPortalDataEntryApp implements EntryPoint {
if (item == null)
return;
if (item instanceof ConcessioneDV) {
final ConcessioneDV concessione = (ConcessioneDV) item;
if (item instanceof DocumentDV) {
final DocumentDV concessione = (DocumentDV) item;
GWT.log("onDoActionPerformedFired item: " + concessione);
switch (action) {
case UPDATED_PROJECT:
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
actionPerformedOnItemEvent.getProfileID(), null,
mainTabPanel.getCurrentSortFilter()));
// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
// actionPerformedOnItemEvent.getProfileID(), null,
// mainTabPanel.getCurrentSortFilter()));
appManagerBus.fireEvent(new GetListOfRecordsEvent(null, grpw.getProfileID(),
mainTabPanel.getCurrentSortFilter(), false));
break;
}
}
@ -883,7 +978,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
appManagerBus.addHandler(ActionOnItemEvent.TYPE, new ActionOnItemEventHandler() {
@Override
public <T extends RecordDV> void onDoActionFired(ActionOnItemEvent<T> showItemEvent) {
public <T extends DocumentDV> void onDoActionFired(ActionOnItemEvent<T> showItemEvent) {
GWT.log("Fired event: " + showItemEvent);
@ -910,182 +1005,192 @@ public class GeoPortalDataEntryApp implements EntryPoint {
if (item == null)
return;
if (item instanceof ConcessioneDV) {
if (item instanceof DocumentDV) {
Window.alert("ACTION MUST BE REVISITED");
final ConcessioneDV concessione = (ConcessioneDV) item;
GWT.log("onDoActionFired item: " + concessione);
// Checking if the user is NOT authorized to perform this action in two ways:
// 1. the map of actions allowed for the user does not contain the action;
RoleRights roleRights = myRights.getRoleRights();
OPERATION_TYPE operationType = roleRights.getListPermessions().get(action);
boolean allowedOperationForUser = operationType != null ? true : false;
if (!allowedOperationForUser) {
String msg = "You are not authorized to perform the action: " + action.getLabel();
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()),
"Forbidden: " + action, msg, AlertType.WARNING);
modalW.show();
return;
}
// 2. the user cannot access to action (e.g. the user cannot write an item of
// another user)
// if so an error is shown
GcubeUserRole userRole = myRights.getRoleRights().getUserRole();
boolean allowedWriteActionOnItem = checkAccessToOperationType(userRole, operationType,
concessione);
if (!allowedWriteActionOnItem) {
String title = "Forbidden: missing write access";
String msg = "You do not have write access to item: " + concessione.getNome();
if (!userRole.isWriteOwn()) {
msg = "You do not have write access to item: " + concessione.getNome();
} else if (!userRole.isWriteAny()) {
title = "Forbidden: missing ownership";
msg = "You are not the creator of: " + concessione.getNome()
+ ". You cannot access to it";
}
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), title, msg,
AlertType.WARNING);
modalW.show();
return;
}
switch (action) {
case VIEW_ON_MAP:
final Modal modal = new Modal(true, true);
modal.setCloseVisible(true);
final HorizontalPanel hpGetLink = new HorizontalPanel();
final LoaderIcon lc = new LoaderIcon("Just moment getting link...");
hpGetLink.add(lc);
modal.add(hpGetLink);
final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", "");
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(),
showItemEvent.getProfileID(), new AsyncCallback<GeoNaItemRef>() {
@Override
public void onFailure(Throwable caught) {
hpGetLink.clear();
Alert alert = new Alert(caught.getMessage(), AlertType.ERROR);
alert.setClose(false);
hpGetLink.add(alert);
newBrowserWindow.close();
}
@Override
public void onSuccess(GeoNaItemRef result) {
String theURL = result.getRestrictedLink().getShortURL() != null
? result.getRestrictedLink().getShortURL()
: result.getRestrictedLink().getCompleteURL();
newBrowserWindow.setUrl(theURL);
modal.hide();
}
});
modal.show();
break;
case VIEW_REPORT:
final Modal modal2 = new Modal(true, true);
modal2.setTitle(
"<span style='font-size:20px;'>Report: <span style='color:#555; font-size:20px;'>"
+ concessione.getNome() + "</span></span>");
modal2.setWidth(800);
modal2.setCloseVisible(true);
if (concessione.getValidationReport() == null) {
modal2.add(new HTML("No report available for: " + concessione.getNome()));
} else {
BuildValidationReport buildValidationReport = new BuildValidationReport(
concessione.getValidationReport());
modal2.add(buildValidationReport);
}
modal2.show();
break;
case EDIT_PROJECT:
final Modal modal3 = new Modal(true, true);
modal3.setTitle(
"<span style='font-size:20px;'>Edit: <span style='color:#555; font-size:20px;'>"
+ concessione.getNome() + "</span></span>");
modal3.setWidth(950);
modal3.setHeight("700px");
modal3.setCloseVisible(true);
((Element) modal3.getElement().getChildNodes().getItem(1))
.addClassName("modal-body-custom");
EditModeRecord emr = new EditModeRecord(appManagerBus, concessione,
RECORD_TYPE.CONCESSIONE);
modal3.add(emr);
modal3.show();
break;
// case UPDATED_PROJECT:
// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
// mainTabPanel.getCurrentSortFilter()));
// final DocumentDV concessione = (DocumentDV) item;
// GWT.log("onDoActionFired item: " + concessione);
//
// // Checking if the user is NOT authorized to perform this action in two ways:
// // 1. the map of actions allowed for the user does not contain the action;
// RoleRights roleRights = myRights.getRoleRights();
// OPERATION_TYPE operationType = roleRights.getListPermessions().get(action);
// boolean allowedOperationForUser = operationType != null ? true : false;
// if (!allowedOperationForUser) {
//
// String msg = "You are not authorized to perform the action: " + action.getLabel();
// ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()),
// "Forbidden: " + action, msg, AlertType.WARNING);
// modalW.show();
// return;
// }
// // 2. the user cannot access to action (e.g. the user cannot write an item of
// // another user)
// // if so an error is shown
// GcubeUserRole userRole = myRights.getRoleRights().getUserRole();
// boolean allowedWriteActionOnItem = checkAccessToOperationType(userRole, operationType,
// concessione);
// if (!allowedWriteActionOnItem) {
// String title = "Forbidden: missing write access";
// String msg = "You do not have write access to item: " + concessione.getNome();
// if (!userRole.isWriteOwn()) {
// msg = "You do not have write access to item: " + concessione.getNome();
// } else if (!userRole.isWriteAny()) {
// title = "Forbidden: missing ownership";
// msg = "You are not the creator of: " + concessione.getNome()
// + ". You cannot access to it";
// }
// ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), title, msg,
// AlertType.WARNING);
// modalW.show();
// return;
// }
//
// switch (action) {
// case VIEW_ON_MAP:
// final Modal modal = new Modal(true, true);
// modal.setCloseVisible(true);
// final HorizontalPanel hpGetLink = new HorizontalPanel();
// final LoaderIcon lc = new LoaderIcon("Just moment getting link...");
// hpGetLink.add(lc);
// modal.add(hpGetLink);
//
// final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", "");
//
// GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(),
// showItemEvent.getProfileID(), new AsyncCallback<GeoNaItemRef>() {
// @Override
// public void onFailure(Throwable caught) {
// hpGetLink.clear();
// Alert alert = new Alert(caught.getMessage(), AlertType.ERROR);
// alert.setClose(false);
// hpGetLink.add(alert);
// newBrowserWindow.close();
// }
//
// @Override
// public void onSuccess(GeoNaItemRef result) {
// String theURL = result.getRestrictedLink().getShortURL() != null
// ? result.getRestrictedLink().getShortURL()
// : result.getRestrictedLink().getCompleteURL();
// newBrowserWindow.setUrl(theURL);
// modal.hide();
// }
// });
//
// modal.show();
//
// break;
case DELETE_PROJECT:
String htmlMsg = "Going to delete the project with:";
htmlMsg += "<ul>";
htmlMsg += "<li>id: " + concessione.getItemId() + "</li>";
htmlMsg += "<li>name: " + concessione.getNome() + "</li>";
htmlMsg += "</ul>";
htmlMsg += "<br>";
htmlMsg += "This operation cannot be undone. Would you like to proceed?";
final DialogConfirm dialog = new DialogConfirm(null, "Delete Confirm?", htmlMsg);
dialog.center();
dialog.getYesButton().addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
dialog.hide();
final Modal modal = new Modal(true, true);
modal.setCloseVisible(true);
final HorizontalPanel hp = new HorizontalPanel();
final LoaderIcon lc = new LoaderIcon("Deleting Project...");
hp.add(lc);
modal.add(hp);
GeoportalDataEntryServiceAsync.Util.getInstance().deleteRecord(
concessione.getItemId(), RECORD_TYPE.CONCESSIONE,
new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
hp.clear();
Alert alert = new Alert(caught.getMessage(), AlertType.ERROR);
alert.setClose(false);
hp.add(alert);
}
@Override
public void onSuccess(Boolean result) {
if (result) {
hp.clear();
Alert alert = new Alert("Project '" + concessione.getNome()
+ "' deleted correclty", AlertType.INFO);
alert.setClose(false);
hp.add(alert);
appManagerBus.fireEvent(new GetListOfRecordsEvent(
RECORD_TYPE.CONCESSIONE, grpw.getProfileID(), null,
mainTabPanel.getCurrentSortFilter()));
}
}
});
modal.show();
}
});
default:
break;
}
//
// case VIEW_REPORT:
//
// final Modal modal2 = new Modal(true, true);
// modal2.setTitle(
// "<span style='font-size:20px;'>Report: <span style='color:#555; font-size:20px;'>"
// + concessione.getNome() + "</span></span>");
// modal2.setWidth(800);
// modal2.setCloseVisible(true);
// if (concessione.getValidationReport() == null) {
// modal2.add(new HTML("No report available for: " + concessione.getNome()));
// } else {
// BuildValidationReport buildValidationReport = new BuildValidationReport(
// concessione.getValidationReport());
// modal2.add(buildValidationReport);
// }
// modal2.show();
//
// break;
//
// case EDIT_PROJECT:
// final Modal modal3 = new Modal(true, true);
// modal3.setTitle(
// "<span style='font-size:20px;'>Edit: <span style='color:#555; font-size:20px;'>"
// + concessione.getNome() + "</span></span>");
// modal3.setWidth(950);
// modal3.setHeight("700px");
// modal3.setCloseVisible(true);
// ((Element) modal3.getElement().getChildNodes().getItem(1))
// .addClassName("modal-body-custom");
// EditModeRecord emr = new EditModeRecord(appManagerBus, concessione,
// RECORD_TYPE.CONCESSIONE);
// modal3.add(emr);
// modal3.show();
// break;
//
//// case UPDATED_PROJECT:
//// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
//// mainTabPanel.getCurrentSortFilter()));
//// break;
// case DELETE_PROJECT:
//
// String htmlMsg = "Going to delete the project with:";
// htmlMsg += "<ul>";
// htmlMsg += "<li>id: " + concessione.getItemId() + "</li>";
// htmlMsg += "<li>name: " + concessione.getNome() + "</li>";
// htmlMsg += "</ul>";
// htmlMsg += "<br>";
// htmlMsg += "This operation cannot be undone. Would you like to proceed?";
//
// final DialogConfirm dialog = new DialogConfirm(null, "Delete Confirm?", htmlMsg);
// dialog.center();
//
// dialog.getYesButton().addClickHandler(new ClickHandler() {
//
// @Override
// public void onClick(ClickEvent event) {
// dialog.hide();
// final Modal modal = new Modal(true, true);
// modal.setCloseVisible(true);
// final HorizontalPanel hp = new HorizontalPanel();
// final LoaderIcon lc = new LoaderIcon("Deleting Project...");
// hp.add(lc);
// modal.add(hp);
//
// GeoportalDataEntryServiceAsync.Util.getInstance().deleteRecord(
// concessione.getItemId(), RECORD_TYPE.CONCESSIONE,
// new AsyncCallback<Boolean>() {
//
// @Override
// public void onFailure(Throwable caught) {
// hp.clear();
// Alert alert = new Alert(caught.getMessage(), AlertType.ERROR);
// alert.setClose(false);
// hp.add(alert);
//
// }
//
// @Override
// public void onSuccess(Boolean result) {
// if (result) {
// hp.clear();
// Alert alert = new Alert("Project '" + concessione.getNome()
// + "' deleted correclty", AlertType.INFO);
// alert.setClose(false);
// hp.add(alert);
//
// appManagerBus.fireEvent(
// new GetListOfRecordsEvent(null, grpw.getProfileID(),
// mainTabPanel.getCurrentSortFilter(), false));
// }
//
// }
// });
// modal.show();
// }
// });
//
// default:
// break;
// }
//
}
}

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.events;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.config.ACTION_ON_ITEM;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import com.google.gwt.event.shared.GwtEvent;
@ -15,7 +16,7 @@ import com.google.gwt.event.shared.GwtEvent;
* Sep 15, 2021
* @param <T> the generic type
*/
public class ActionOnItemEvent<T extends RecordDV> extends GwtEvent<ActionOnItemEventHandler> {
public class ActionOnItemEvent<T extends DocumentDV> extends GwtEvent<ActionOnItemEventHandler> {
public static Type<ActionOnItemEventHandler> TYPE = new Type<ActionOnItemEventHandler>();
private List<T> selectItems;
private ACTION_ON_ITEM action;

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.geoportaldataentry.client.events;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import com.google.gwt.event.shared.EventHandler;
@ -19,5 +19,5 @@ public interface ActionOnItemEventHandler extends EventHandler {
* @param <T> the generic type
* @param showItemEvent the show item event
*/
<T extends RecordDV> void onDoActionFired(ActionOnItemEvent<T> showItemEvent);
<T extends DocumentDV> void onDoActionFired(ActionOnItemEvent<T> showItemEvent);
}

View File

@ -2,7 +2,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.events;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM;
import com.google.gwt.event.shared.GwtEvent;
@ -15,7 +15,7 @@ import com.google.gwt.event.shared.GwtEvent;
* Sep 15, 2021
* @param <T> the generic type
*/
public class ActionPerformedOnItemEvent<T extends RecordDV> extends GwtEvent<ActionPerformedOnItemEventHandler> {
public class ActionPerformedOnItemEvent<T extends DocumentDV> extends GwtEvent<ActionPerformedOnItemEventHandler> {
public static Type<ActionPerformedOnItemEventHandler> TYPE = new Type<ActionPerformedOnItemEventHandler>();
private List<T> selectItems;
private ACTION_PERFORMED_ON_ITEM action;

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.geoportaldataentry.client.events;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import com.google.gwt.event.shared.EventHandler;
@ -20,5 +20,5 @@ public interface ActionPerformedOnItemEventHandler extends EventHandler {
*
* @param actionPerformedOnItemEvent the action performed on item event
*/
<T extends RecordDV> void onDoActionPerformedFired(ActionPerformedOnItemEvent<T> actionPerformedOnItemEvent);
<T extends DocumentDV> void onDoActionPerformedFired(ActionPerformedOnItemEvent<T> actionPerformedOnItemEvent);
}

View File

@ -1,8 +1,6 @@
package org.gcube.portlets.user.geoportaldataentry.client.events;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
import com.google.gwt.event.shared.GwtEvent;
@ -17,24 +15,25 @@ public class GetListOfRecordsEvent extends GwtEvent<GetListOfRecordsEventHandler
/** The type. */
public static Type<GetListOfRecordsEventHandler> TYPE = new Type<GetListOfRecordsEventHandler>();
private RECORD_TYPE recordType;
private SearchingFilter sortFilter;
private String profileID;
private String profileName;
private String projectName;
private Boolean reloadFilteringParameters = false;
/**
* Instantiates a new cancel upload event.
*
* @param recordType the record type
* @param theUseCaseDesc the the use case desc
* @param projectName the project name
* @param profileID the profile ID
* @param sortFilter the sort filter
* @param reloadFilteringParameters the reload filtering parameters
*/
public GetListOfRecordsEvent(ConstantsGeoPortalDataEntryApp.RECORD_TYPE recordType, String profileID,
String profileName, SearchingFilter sortFilter) {
this.recordType = recordType;
public GetListOfRecordsEvent(String projectName, String profileID, SearchingFilter sortFilter,
Boolean reloadFilteringParameters) {
this.sortFilter = sortFilter;
this.profileID = profileID;
this.profileName = profileName;
this.projectName = projectName;
this.reloadFilteringParameters = reloadFilteringParameters;
}
/**
@ -69,15 +68,6 @@ public class GetListOfRecordsEvent extends GwtEvent<GetListOfRecordsEventHandler
handler.onGetList(this);
}
/**
* Gets the record type.
*
* @return the record type
*/
public RECORD_TYPE getRecordType() {
return recordType;
}
/**
* Gets the sort filter.
*
@ -87,12 +77,31 @@ public class GetListOfRecordsEvent extends GwtEvent<GetListOfRecordsEventHandler
return sortFilter;
}
/**
* Gets the profile ID.
*
* @return the profile ID
*/
public String getProfileID() {
return profileID;
}
public String getProfileName() {
return profileName;
/**
* Gets the project name.
*
* @return the project name
*/
public String getProjectName() {
return projectName;
}
/**
* Gets the reload filtering parameters.
*
* @return the reload filtering parameters
*/
public boolean isReloadFilteringParameters() {
return reloadFilteringParameters;
}
}

View File

@ -10,6 +10,7 @@ import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
import org.gcube.application.geoportalcommon.shared.WhereClause;
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.HandlerDeclarationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.UseCaseDescriptorDV;
@ -17,9 +18,11 @@ import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfil
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent;
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent;
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.UCD_Util;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.Button;
@ -144,6 +147,9 @@ public class GeonaMainTabPanel extends Composite {
@UiField
Dropdown ddCreateNewProject;
@UiField
Dropdown ddProjectType;
@UiField
PageHeader pageHeaderDataEntry;
@ -168,35 +174,50 @@ public class GeonaMainTabPanel extends Composite {
* Instantiates a new geona main tab panel.
*
* @param appManagerBus the first name
* @param sortByFields the sort by fields
* @param initialSortFilter
* @param defaultItemField
*/
public GeonaMainTabPanel(HandlerManager appManagerBus, List<ItemFieldDV> displayFields,
List<ItemFieldDV> sortByFields, List<ItemFieldDV> searchForFields, SearchingFilter initialSortFilter) {
public GeonaMainTabPanel(HandlerManager appManagerBus, List<ItemFieldDV> defaultItemField,
SearchingFilter initialSortFilter) {
initWidget(uiBinder.createAndBindUi(this));
this.appManagerBus = appManagerBus;
this.sortByFields = sortByFields;
this.displayFields = displayFields;
this.currentSortFilter = initialSortFilter;
this.searchForFields = searchForFields;
setFilteringParameters(defaultItemField, defaultItemField, defaultItemField, initialSortFilter);
alertSortBy.setType(AlertType.INFO);
alertSortBy.setClose(false);
alertSearchFor.setType(AlertType.INFO);
alertSearchFor.setClose(false);
alertSearchFor.setText(searchForFields.get(0).getDisplayName());
alertSortBy.setText(toLabelFilter((initialSortFilter.getOrderByFields().get(0)), initialSortFilter.getOrder()));
//pageHeaderDataEntry.setHeight("25px");
bindEvents();
resetSearch.setIconSize(IconSize.TWO_TIMES);
resetSearch.setType(ButtonType.LINK);
setLoaderVisible("", false);
}
/**
* Sets the filtering parameters.
*
* @param displayFields the display fields
* @param sortByFields the sort by fields
* @param searchForFields the search for fields
* @param initialSortFilter the initial sort filter
*/
public void setFilteringParameters(List<ItemFieldDV> displayFields, List<ItemFieldDV> sortByFields,
List<ItemFieldDV> searchForFields, SearchingFilter initialSortFilter) {
this.displayFields = displayFields;
this.sortByFields = sortByFields;
this.currentSortFilter = initialSortFilter;
this.searchForFields = searchForFields;
alertSearchFor.setText(searchForFields.get(0).getDisplayName());
alertSortBy.setText(toLabelFilter((initialSortFilter.getOrderByFields().get(0)), initialSortFilter.getOrder()));
}
/**
* Sets the internal height.
*
* @param height the new internal height
*/
public void setInternalHeight(int height) {
contTabNewProject.asWidget().setHeight(height + "px");
contTabGetListOfProjects.asWidget().setHeight(height + "px");
@ -303,7 +324,7 @@ public class GeonaMainTabPanel extends Composite {
@Override
public void onClick(ClickEvent event) {
List<ConcessioneDV> listConcessioni = null;
List<DocumentDV> listConcessioni = null;
if (grpw != null && grpw.getSelectItems() != null) {
listConcessioni = grpw.getSelectItems();
}
@ -322,7 +343,7 @@ public class GeonaMainTabPanel extends Composite {
@Override
public void onClick(ClickEvent event) {
List<ConcessioneDV> listConcessioni = null;
List<DocumentDV> listConcessioni = null;
if (grpw != null && grpw.getSelectItems() != null) {
listConcessioni = grpw.getSelectItems();
}
@ -341,7 +362,7 @@ public class GeonaMainTabPanel extends Composite {
@Override
public void onClick(ClickEvent event) {
List<ConcessioneDV> listConcessioni = null;
List<DocumentDV> listConcessioni = null;
if (grpw != null && grpw.getSelectItems() != null) {
listConcessioni = grpw.getSelectItems();
}
@ -360,7 +381,7 @@ public class GeonaMainTabPanel extends Composite {
@Override
public void onClick(ClickEvent event) {
List<ConcessioneDV> listConcessioni = null;
List<DocumentDV> listConcessioni = null;
if (grpw != null && grpw.getSelectItems() != null) {
listConcessioni = grpw.getSelectItems();
}
@ -402,10 +423,18 @@ public class GeonaMainTabPanel extends Composite {
}
/**
* Sets the role label.
*
* @param msg the new role label
*/
public void setRoleLabel(String msg) {
roleLabel.setText(msg);
}
/**
* Do search event.
*/
private void doSearchEvent() {
String searchText = searchField.getText();
if (searchText.length() < MIN_LENGHT_SERCHING_STRING) {
@ -422,6 +451,13 @@ public class GeonaMainTabPanel extends Composite {
*/
}
/**
* To label filter.
*
* @param itemField the item field
* @param direction the direction
* @return the string
*/
private String toLabelFilter(ItemFieldDV itemField, ORDER direction) {
String labelFilter = itemField.getDisplayName() + LABEL_FILTER_SEPARATOR + direction.name();
return labelFilter;
@ -461,6 +497,12 @@ public class GeonaMainTabPanel extends Composite {
loader.setVisible(visible);
}
/**
* To sort filter.
*
* @param labelFilter the label filter
* @return the searching filter
*/
public SearchingFilter toSortFilter(String labelFilter) {
GWT.log("toSortFilter for label " + labelFilter);
String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR);
@ -484,6 +526,11 @@ public class GeonaMainTabPanel extends Composite {
}
/**
* Built searching filter.
*
* @return the searching filter
*/
private SearchingFilter builtSearchingFilter() {
SearchingFilter searchingFilter = toSortFilter(alertSortBy.getText());
String searchText = searchField.getText();
@ -507,16 +554,31 @@ public class GeonaMainTabPanel extends Composite {
return searchingFilter;
}
/**
* Gets the current sort filter.
*
* @return the current sort filter
*/
public SearchingFilter getCurrentSortFilter() {
currentSortFilter = builtSearchingFilter();
GWT.log("currentSortFilter: " + currentSortFilter);
return currentSortFilter;
}
/**
* Removes the tab.
*
* @param index the index
*/
public void removeTab(int index) {
tabPanel.remove(index);
}
/**
* Sets the tab active.
*
* @param index the new tab active
*/
public void setTabActive(int index) {
tabPanel.selectTab(index);
}
@ -534,6 +596,11 @@ public class GeonaMainTabPanel extends Composite {
*/
}
/**
* Sets the list use case descriptors.
*
* @param listUCDescriptors the new list use case descriptors
*/
public void setListUseCaseDescriptors(List<UseCaseDescriptorDV> listUCDescriptors) {
GWT.log("Setting listUCDescriptors: " + listUCDescriptors);
this.listUCDescriptors = listUCDescriptors;
@ -541,7 +608,8 @@ public class GeonaMainTabPanel extends Composite {
for (final UseCaseDescriptorDV ucd : listUCDescriptors) {
HandlerDeclarationDV dataEntryHandler = getDataEntryHandler(ucd);
HandlerDeclarationDV dataEntryHandler = UCD_Util.getHandlerDeclarationFor(ucd,
GEOPORTAL_DATA_HANDLER.geoportal_data_entry);
if (dataEntryHandler != null) {
ConfigurationDV<?> config = dataEntryHandler.getConfiguration();
@ -568,6 +636,26 @@ public class GeonaMainTabPanel extends Composite {
});
ddCreateNewProject.add(link);
}
// Setting Project type having HANDLER DATA LIST
HandlerDeclarationDV dataListHandler = UCD_Util.getHandlerDeclarationFor(ucd,
GEOPORTAL_DATA_HANDLER.geoportal_data_list);
if (dataListHandler != null) {
NavLink link = new NavLink(ucd.getName());
link.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
appManagerBus.fireEvent(new GetListOfRecordsEvent(ucd.getName(), ucd.getProfileID(),
getCurrentSortFilter(), true));
}
});
ddProjectType.add(link);
}
}
@ -581,7 +669,8 @@ public class GeonaMainTabPanel extends Composite {
public void execute() {
GWT.log("One Config loaded. Firing CreateNewProjectEvent");
UseCaseDescriptorDV useCaseDescriptor = listUCDescriptors.get(0);
HandlerDeclarationDV dataEntryHandler = getDataEntryHandler(useCaseDescriptor);
HandlerDeclarationDV dataEntryHandler = UCD_Util.getHandlerDeclarationFor(useCaseDescriptor,
GEOPORTAL_DATA_HANDLER.geoportal_data_entry);
if (dataEntryHandler != null) {
ConfigurationDV<?> config = dataEntryHandler.getConfiguration();
List<GcubeProfileDV> listGcubeProfiles = toListGcubeProfiles(config);
@ -596,21 +685,12 @@ public class GeonaMainTabPanel extends Composite {
}
}
private HandlerDeclarationDV getDataEntryHandler(UseCaseDescriptorDV useCaseDescriptor) {
for (HandlerDeclarationDV handler : useCaseDescriptor.getHandlers()) {
GEOPORTAL_DATA_HANDLER dataHandlerType = handler.getDataHandlerType();
// Checking if the handler if of geoportal_data_entry type
if (dataHandlerType != null
&& dataHandlerType.getType().equals(GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getType())) {
return handler;
}
}
return null;
}
/**
* To list gcube profiles.
*
* @param config the config
* @return the list
*/
private List<GcubeProfileDV> toListGcubeProfiles(ConfigurationDV<?> config) {
try {
@ -623,6 +703,29 @@ public class GeonaMainTabPanel extends Composite {
return null;
}
/**
* To list item fields.
*
* @param config the config
* @return the list
*/
private List<ItemFieldDV> toListItemFields(ConfigurationDV<?> config) {
try {
return (List<ItemFieldDV>) config.getConfiguration();
} catch (Exception e) {
GWT.log("Error on casting " + ConfigurationDV.class.getName() + " to List of "
+ ItemFieldDV.class.getName());
}
return null;
}
/**
* Sets the page header.
*
* @param hDV the new page header
*/
public void setPageHeader(HandlerDeclarationDV hDV) {
introGNAHero.setVisible(false);
this.pageHeaderDataEntry.setVisible(true);
@ -630,8 +733,17 @@ public class GeonaMainTabPanel extends Composite {
this.pageHeaderDataEntry.setSubtext("New: " + hDV.getItemType());
}
/**
* Gets the list UC descriptors.
*
* @return the list UC descriptors
*/
public List<UseCaseDescriptorDV> getListUCDescriptors() {
return listUCDescriptors;
}
public List<ItemFieldDV> getDisplayFields() {
return displayFields;
}
}

View File

@ -129,6 +129,11 @@
<g:HTMLPanel ui:field="contTabGetListOfProjects">
<b:Navbar addStyleNames="nav-toolbar-style">
<b:Brand>List of Projects</b:Brand>
<b:Nav>
<b:Dropdown text="Project Type"
ui:field="ddProjectType" icon="BUILDING">
</b:Dropdown>
</b:Nav>
<b:Nav>
<b:Dropdown text="Sort by" ui:field="dropdownSortBy">
</b:Dropdown>

View File

@ -4,8 +4,8 @@ import java.util.List;
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable;
import org.gcube.portlets.user.geoportaldataentry.client.ui.table.SortedCellTable;
@ -42,8 +42,8 @@ public class GeonaRecordsPaginatedView {
private VerticalPanel vPanel = new VerticalPanel();
private FlowPanel pagerPanel = new FlowPanel();
private Boolean initClassFirstRangeChanged = false;
private ItemsTable<ConcessioneDV> itemsTable;
private MyCustomDataProvider<ConcessioneDV> dataProvider = new MyCustomDataProvider<ConcessioneDV>();
private ItemsTable<DocumentDV> itemsTable;
private MyCustomDataProvider<DocumentDV> dataProvider = new MyCustomDataProvider<DocumentDV>();
protected Widget orginalLoadingIndicator = null;
private LoaderIcon loadingPanel = new LoaderIcon("Loading data...");
// private int serverStartIndex;
@ -65,7 +65,7 @@ public class GeonaRecordsPaginatedView {
this.currentSortFilter = currentSortFilter;
this.initClassFirstRangeChanged = true;
this.eventBus = eventbus;
itemsTable = new ItemsTable<ConcessioneDV>(eventbus, displayFields);
itemsTable = new ItemsTable<DocumentDV>(eventbus, displayFields);
itemsTable.initTable(null, null, dataProvider);
orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator();
@ -79,8 +79,8 @@ public class GeonaRecordsPaginatedView {
*
* @return the table data provider
*/
public AsyncDataProvider<ConcessioneDV> getTableDataProvider() {
return (AsyncDataProvider<ConcessioneDV>) getCellTable().getDataProvider();
public AsyncDataProvider<DocumentDV> getTableDataProvider() {
return (AsyncDataProvider<DocumentDV>) getCellTable().getDataProvider();
}
/**
@ -88,7 +88,7 @@ public class GeonaRecordsPaginatedView {
*
* @return the cell tale
*/
private SortedCellTable<ConcessioneDV> getCellTable() {
private SortedCellTable<DocumentDV> getCellTable() {
return itemsTable.getCellTable();
}
@ -158,13 +158,13 @@ public class GeonaRecordsPaginatedView {
private void setNewPageResult(ResultSetPaginatedData result) {
GWT.log("setNewPageResult: " + result);
// serverStartIndex = result.getServerEndIndex();
SelectionModel<? super ConcessioneDV> sm = getCellTable().getSelectionModel();
SelectionModel<? super DocumentDV> sm = getCellTable().getSelectionModel();
if (sm instanceof SingleSelectionModel) {
SingleSelectionModel<ConcessioneDV> ssm = (SingleSelectionModel<ConcessioneDV>) sm;
SingleSelectionModel<DocumentDV> ssm = (SingleSelectionModel<DocumentDV>) sm;
ssm.clear();
} else if (sm instanceof MultiSelectionModel) {
MultiSelectionModel<ConcessioneDV> msm = (MultiSelectionModel<ConcessioneDV>) sm;
MultiSelectionModel<DocumentDV> msm = (MultiSelectionModel<DocumentDV>) sm;
msm.clear();
}
@ -235,21 +235,22 @@ public class GeonaRecordsPaginatedView {
* @param limitToPage the limit to page
*/
public void selectItems(boolean select, boolean limitToPage) {
SortedCellTable<ConcessioneDV> table = getCellTable();
SortedCellTable<DocumentDV> table = getCellTable();
int rowSize = table.getVisibleItemCount();
for (int i = 0; i < rowSize; i++) {
ConcessioneDV item = table.getVisibleItem(i);
DocumentDV item = table.getVisibleItem(i);
itemsTable.getSelectionModel().setSelected(item, select);
}
}
/**
* Gets the select items.
* @return
*
* @return the select items
*/
public List<ConcessioneDV> getSelectItems() {
public List<DocumentDV> getSelectItems() {
return itemsTable.getSelectedItems();
}

View File

@ -5,14 +5,12 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.table;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Set;
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV.ValidationStatus;
import com.github.gwtbootstrap.client.ui.ButtonCell;
@ -45,7 +43,7 @@ import com.google.gwt.view.client.SingleSelectionModel;
* Jun 15, 2021
* @param <T> the generic type
*/
public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<T> {
public class ItemsTable<T extends DocumentDV> extends AbstractItemsCellTable<T> {
private static final int ITEMS_PER_PAGE = 10;
private static final String NO_DATA = "No data";
@ -103,7 +101,16 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
if (object == null)
return "";
DocumentDV documentDV = (DocumentDV) object;
try {
return documentDV.getDocumentAsMap().get(itemField.getJsonFields().get(0)).toString();
}catch (Exception e) {
GWT.log("Error e: "+e);
}
/*
if (displayName.equalsIgnoreCase("Name")) {
return ((ConcessioneDV) object).getNome();
} else if (displayName.equalsIgnoreCase("Introduction")) {
@ -153,7 +160,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
ValidationReportDV vr = ((ConcessioneDV) object).getValidationReport();
if (vr != null && vr.getObjectName() != null)
return vr.getObjectName();
}
}*/
return "";
}
@ -199,184 +206,6 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
i++;
}
/*
* if (this.displayFields.contains(RECORD_FIELD.NAME)) {
*
* // NAME name = new TextColumn<T>() {
*
* @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("<div introduction=\"" + ((ConcessioneDV)
* object).getNome() + "\">"); super.render(context, object, sb);
* sb.appendHtmlConstant("</div>"); }; };
*
* sortedCellTable.addColumn(name, RECORD_FIELD.NAME.getDisplayName(), true);
*
* if (!isAsyncronusTable) { Comparator<T> c = new Comparator<T>() {
*
* @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<T>() {
*
* @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<T> c = new Comparator<T>() {
*
* @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<T>() {
*
* @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<T> c = new Comparator<T>() {
*
* @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<T>() {
*
* @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<T,
* Date>(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<T> c = new Comparator<T>() {
*
* @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<T>() {
*
* @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<T> c = new Comparator<T>() {
*
* @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<T>() {
*
* @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("<span style=\"color:" + color + "\";>");
* super.render(context, object, sb); sb.appendHtmlConstant("</span>");
*
* } };
*
* sortedCellTable.addColumn(statusColumn,
* RECORD_FIELD.RECORD_STATUS.getDisplayName(), false);
* sortedCellTable.setColumnWidth(statusColumn, 120, Unit.PX);
*
* }
*/
}
public void enableWriteOperations() {

View File

@ -0,0 +1,50 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui.utils;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.HandlerDeclarationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.UseCaseDescriptorDV;
public class UCD_Util {
public static HandlerDeclarationDV getHandlerDeclarationFor(List<UseCaseDescriptorDV> listUCDescriptors,
String profileID, GEOPORTAL_DATA_HANDLER dataHandler) {
for (UseCaseDescriptorDV useCaseDescriptor : listUCDescriptors) {
if (useCaseDescriptor.getProfileID().compareTo(profileID) == 0) {
for (HandlerDeclarationDV handler : useCaseDescriptor.getHandlers()) {
GEOPORTAL_DATA_HANDLER dataHandlerType = handler.getDataHandlerType();
if (dataHandlerType != null && dataHandlerType.equals(dataHandler)) {
return handler;
}
}
}
}
return null;
}
public static HandlerDeclarationDV getHandlerDeclarationFor(UseCaseDescriptorDV useCaseDescriptor,
GEOPORTAL_DATA_HANDLER dataHandler) {
if (useCaseDescriptor == null)
return null;
for (HandlerDeclarationDV handler : useCaseDescriptor.getHandlers()) {
GEOPORTAL_DATA_HANDLER dataHandlerType = handler.getDataHandlerType();
if (dataHandlerType != null && dataHandlerType.equals(dataHandler)) {
return handler;
}
}
return null;
}
}

View File

@ -702,7 +702,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
LOG.info("Fileset is empty, skipping registerFileSet");
}
LOG.info("Publishings itemId: " + itemId);
LOG.info("Publishing itemId: " + itemId);
concessione = clientMongo.publish(itemId);
LOG.debug("returning concessione: " + concessione);
@ -890,6 +890,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId());
LOG.info("handlersIds is null, so using default: " + handlersIds);
}
//TODO MUST BE USED THE FOLLOWING ONE
// listUseCaseDescriptor = client.getListForHandlerIds(handlersIds);
listUseCaseDescriptor = client.getList();