diff --git a/CHANGELOG.md b/CHANGELOG.md index 61dea21..4dab90b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java index 4475190..e53951e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java @@ -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 HANDLERS_IDS = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_list.getId(), + GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId()); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index bb5b2d1..bcc2061 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -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 orderedCards = new ArrayList(); + // private Collection orderedCards = new + // ArrayList(); private GeonaMainTabPanel mainTabPanel; @@ -122,14 +126,12 @@ public class GeoPortalDataEntryApp implements EntryPoint { private LoaderIcon loader = new LoaderIcon("Loading Application... please wait"); - private List displayFields = new ArrayList(); - private List sortByFields = new ArrayList(); - private List searchByFields = new ArrayList(); - private GeonaISConfig geonaISConfig; private TreeMap> mapGcubeProfilePerItemType = new TreeMap>(); + private Map>> mapHandlersForProfileId = new HashMap>>(); + private int numberOfCards = 0; private int expectedCards = 0; @@ -233,35 +235,42 @@ public class GeoPortalDataEntryApp implements EntryPoint { } - List itemFields = gNADataEntryConfig.getListItemFields(); +// List 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 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(); + // orderedCards = new ArrayList(); - GeoportalDataEntryServiceAsync.Util.getInstance().getListUseCaseDescriptors(null, - new AsyncCallback>() { + GeoportalDataEntryServiceAsync.Util.getInstance().getListUseCaseDescriptors( + ConstantsGeoPortalDataEntryApp.HANDLERS_IDS, new AsyncCallback>() { @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> listConfigurations = mapHandlersForProfileId + .get(useCaseDescriptorDV.getProfileID()); + if (listConfigurations == null) { + listConfigurations = new ArrayList>(); + } + + 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 listGPs) { dataEntryProjectCreated = true; mainTabPanel.setLoaderVisible("Loading...", true); - //orderedCards.clear(); + // orderedCards.clear(); resetUI(); List 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(cardsPerIT)); return; } @@ -436,8 +488,9 @@ public class GeoPortalDataEntryApp implements EntryPoint { GWT.log("TreeMap values: " + gnaCardsModels); mapGcubeProfilePerItemType.put(handlerDeclarationDV.getItemType(), new ArrayList(gnaCardsModels)); - //orderedCards.addAll(new ArrayList(gnaCardsModels)); - buildNewCards(profileID, handlerDeclarationDV.getItemType(), new ArrayList(gnaCardsModels)); + // orderedCards.addAll(new ArrayList(gnaCardsModels)); + buildNewCards(profileID, handlerDeclarationDV.getItemType(), + new ArrayList(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 cardsPerIT = mapGcubeProfilePerItemType.get(newProjectEvent.getHandler().getItemType()); - + // TODO HERE + // List 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 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(); + List searchByFields = new ArrayList(); + List sortByFields = new ArrayList(); + List> config = mapHandlersForProfileId.get(getListOfRecordsEvent.getProfileID()); + + for (ConfigurationDV configurationDV : config) { + switch (configurationDV.getConfigurationType()) { + case item_fields: + List listItemFields = (List) 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 void onDoActionPerformedFired( + public void onDoActionPerformedFired( ActionPerformedOnItemEvent 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 void onDoActionFired(ActionOnItemEvent showItemEvent) { + public void onDoActionFired(ActionOnItemEvent 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() { - @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( - "Report: " - + concessione.getNome() + ""); - 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( - "Edit: " - + concessione.getNome() + ""); - 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() { +// @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 += "
    "; - htmlMsg += "
  • id: " + concessione.getItemId() + "
  • "; - htmlMsg += "
  • name: " + concessione.getNome() + "
  • "; - htmlMsg += "
"; - htmlMsg += "
"; - 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() { - - @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( +// "Report: " +// + concessione.getNome() + ""); +// 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( +// "Edit: " +// + concessione.getNome() + ""); +// 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 += "
    "; +// htmlMsg += "
  • id: " + concessione.getItemId() + "
  • "; +// htmlMsg += "
  • name: " + concessione.getNome() + "
  • "; +// htmlMsg += "
"; +// htmlMsg += "
"; +// 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() { +// +// @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; +// } +// + + + + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java index 221f63e..c060645 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java @@ -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 the generic type */ -public class ActionOnItemEvent extends GwtEvent { +public class ActionOnItemEvent extends GwtEvent { public static Type TYPE = new Type(); private List selectItems; private ACTION_ON_ITEM action; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEventHandler.java index b333e0b..fa8a3aa 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEventHandler.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEventHandler.java @@ -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 the generic type * @param showItemEvent the show item event */ - void onDoActionFired(ActionOnItemEvent showItemEvent); + void onDoActionFired(ActionOnItemEvent showItemEvent); } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionPerformedOnItemEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionPerformedOnItemEvent.java index 6cf8302..c6f2803 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionPerformedOnItemEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionPerformedOnItemEvent.java @@ -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 the generic type */ -public class ActionPerformedOnItemEvent extends GwtEvent { +public class ActionPerformedOnItemEvent extends GwtEvent { public static Type TYPE = new Type(); private List selectItems; private ACTION_PERFORMED_ON_ITEM action; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionPerformedOnItemEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionPerformedOnItemEventHandler.java index 0d6ec7b..05976e6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionPerformedOnItemEventHandler.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionPerformedOnItemEventHandler.java @@ -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 */ - void onDoActionPerformedFired(ActionPerformedOnItemEvent actionPerformedOnItemEvent); + void onDoActionPerformedFired(ActionPerformedOnItemEvent actionPerformedOnItemEvent); } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java index 76f8eaa..1252db5 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java @@ -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 TYPE = new Type(); - 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 displayFields, - List sortByFields, List searchForFields, SearchingFilter initialSortFilter) { + public GeonaMainTabPanel(HandlerManager appManagerBus, List 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 displayFields, List sortByFields, + List 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 listConcessioni = null; + List 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 listConcessioni = null; + List 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 listConcessioni = null; + List 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 listConcessioni = null; + List 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 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 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 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 toListItemFields(ConfigurationDV config) { + + try { + return (List) 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 getListUCDescriptors() { return listUCDescriptors; } + public List getDisplayFields() { + return displayFields; + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index 1d32535..1568cfb 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -129,6 +129,11 @@ List of Projects + + + + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java index 9609d9a..36e0716 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java @@ -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 itemsTable; - private MyCustomDataProvider dataProvider = new MyCustomDataProvider(); + private ItemsTable itemsTable; + private MyCustomDataProvider dataProvider = new MyCustomDataProvider(); 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(eventbus, displayFields); + itemsTable = new ItemsTable(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 getTableDataProvider() { - return (AsyncDataProvider) getCellTable().getDataProvider(); + public AsyncDataProvider getTableDataProvider() { + return (AsyncDataProvider) getCellTable().getDataProvider(); } /** @@ -88,7 +88,7 @@ public class GeonaRecordsPaginatedView { * * @return the cell tale */ - private SortedCellTable getCellTable() { + private SortedCellTable getCellTable() { return itemsTable.getCellTable(); } @@ -158,13 +158,13 @@ public class GeonaRecordsPaginatedView { private void setNewPageResult(ResultSetPaginatedData result) { GWT.log("setNewPageResult: " + result); // serverStartIndex = result.getServerEndIndex(); - SelectionModel sm = getCellTable().getSelectionModel(); + SelectionModel sm = getCellTable().getSelectionModel(); if (sm instanceof SingleSelectionModel) { - SingleSelectionModel ssm = (SingleSelectionModel) sm; + SingleSelectionModel ssm = (SingleSelectionModel) sm; ssm.clear(); } else if (sm instanceof MultiSelectionModel) { - MultiSelectionModel msm = (MultiSelectionModel) sm; + MultiSelectionModel msm = (MultiSelectionModel) sm; msm.clear(); } @@ -235,21 +235,22 @@ public class GeonaRecordsPaginatedView { * @param limitToPage the limit to page */ public void selectItems(boolean select, boolean limitToPage) { - SortedCellTable table = getCellTable(); + SortedCellTable 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 getSelectItems() { + public List getSelectItems() { return itemsTable.getSelectedItems(); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java index 9534b07..44005d2 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java @@ -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 the generic type */ -public class ItemsTable extends AbstractItemsCellTable { +public class ItemsTable extends AbstractItemsCellTable { private static final int ITEMS_PER_PAGE = 10; private static final String NO_DATA = "No data"; @@ -103,7 +101,16 @@ public class ItemsTable 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 extends AbstractItemsCellTable< ValidationReportDV vr = ((ConcessioneDV) object).getValidationReport(); if (vr != null && vr.getObjectName() != null) return vr.getObjectName(); - } + }*/ return ""; } @@ -199,184 +206,6 @@ public class ItemsTable extends AbstractItemsCellTable< i++; } - - /* - * 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() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/UCD_Util.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/UCD_Util.java new file mode 100644 index 0000000..262b427 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/UCD_Util.java @@ -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 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; + + } + +} 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 4edf74f..b3d3186 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 @@ -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();