From fb7a80bb2f4717b29929a375cf117e0855f2754d Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 26 Mar 2024 17:00:37 +0100 Subject: [PATCH] Implementing the init facility to resolve a public link on an item #27120 --- .classpath | 4 +- .../com.gwtplugins.gdt.eclipse.core.prefs | 2 +- .settings/org.eclipse.wst.common.component | 230 +++++++++++- CHANGELOG.md | 4 + pom.xml | 7 +- .../ConstantsGeoPortalDataEntryApp.java | 4 + .../client/GeoPortalDataEntryApp.java | 327 ++++++++++++------ .../client/InitExecutor.java | 43 +++ .../client/events/GetListOfRecordsEvent.java | 7 +- .../client/events/OperationOnItemEvent.java | 5 + .../client/ui/GeonaMainTabPanel.java | 9 + .../ui/projects/ListOfProjectTablePanel.java | 23 +- .../server/GeoportalDataEntryServiceImpl.java | 16 +- 13 files changed, 552 insertions(+), 129 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/InitExecutor.java diff --git a/.classpath b/.classpath index 59c98da..d0dee6a 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -31,5 +31,5 @@ - + diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index a6efe72..2533716 100644 --- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs @@ -1,5 +1,5 @@ eclipse.preferences.version=1 jarsExcludedFromWebInfLib= -lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-3.2.0 +lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-3.3.0-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 35cb89c..d10a6f1 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,5 @@ - + @@ -114,8 +114,54 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -231,7 +277,30 @@ - + + + + + + + + + + + + + + + + + + + + + + + + @@ -347,7 +416,30 @@ - + + + + + + + + + + + + + + + + + + + + + + + + @@ -463,7 +555,30 @@ - + + + + + + + + + + + + + + + + + + + + + + + + @@ -531,7 +646,33 @@ - + + uses + + + + + + + + + + + + + + + + + + + + + + + + + @@ -647,7 +788,30 @@ - + + + + + + + + + + + + + + + + + + + + + + + + @@ -763,7 +927,30 @@ - + + + + + + + + + + + + + + + + + + + + + + + + @@ -879,7 +1066,30 @@ - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bd1678..66d1c23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v3.3.0-SNAPSHOT] - 2024-03-26 + +- Implemented the init facility to resolve a public link on an item [#27120] + ## [v3.2.2] - 2024-01-11 - Improved display of results on multiple fields (in the table) [#26372] diff --git a/pom.xml b/pom.xml index 5dbdb43..62460d1 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-entry-app war - 3.2.2 + 3.3.0-SNAPSHOT GeoPortal Data Entry App The GeoPortal Data Entry App is an application to build the web forms for data entries needed to create projects/documents (based on UCD) in the D4Science Geoportal service @@ -25,11 +25,12 @@ - 2.9.0 + 2.10.0 ${project.build.directory}/${project.build.finalName} UTF-8 UTF-8 + 1.8 1.8 @@ -224,7 +225,7 @@ slf4j-api provided - + junit 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 e175e9b..82e046d 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 @@ -25,6 +25,10 @@ public class ConstantsGeoPortalDataEntryApp { public static final String DIV_PORTLET_ID = "geoportal-data-entry"; public static final String DIV_LOADERS_ID = "geoportal-loaders"; + + public static final String GET_GEONA_ITEM_TYPE = "git"; + + public static final String GET_GEONA_ITEM_ID = "gid"; public static final String DATE_FORMAT = ConstantsMPFormBuilder.DATE_FORMAT; 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 2d5e469..968cc86 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 @@ -6,6 +6,7 @@ import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.TreeMap; +import java.util.stream.Collectors; import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences; import org.gcube.application.geoportalcommon.shared.SearchingFilter; @@ -59,6 +60,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardMo import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.EditModeRecord; import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.UpdateRecord; import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; +import org.gcube.portlets.user.geoportaldataentry.client.ui.projects.ListOfProjectTablePanel; import org.gcube.portlets.user.geoportaldataentry.client.ui.report.LifecycleInformationPanel; import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML; import org.gcube.portlets.user.geoportaldataentry.client.ui.tree.NodeItem; @@ -103,6 +105,8 @@ import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerManager; +import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Anchor; @@ -162,32 +166,19 @@ public class GeoPortalDataEntryApp implements EntryPoint { private GeoPortalClientCaches geoportalCaches; + private String paramGeonaItemType; + + private String paramGeonaItemID; + + private boolean canCreateNewItem = false; + /** * This is the entry point method. */ public void onModuleLoad() { - /* - * ArrayList gnaCardsModels = new - * ArrayList(10); GcubeProfileDV gprofile = new - * GcubeProfileDV(); gprofile.setParentName("$."); - * gprofile.setSectionTitle("Istruzione"); GeoNaFormCardModel fcm = new - * GeoNaFormCardModel(); fcm.setGcubeProfile(gprofile); gnaCardsModels.add(fcm); - * - * for (int i = 0; i < 2; i++) { GcubeProfileDV gprofile1 = new - * GcubeProfileDV(); gprofile1.setParentName("$.livello1"); - * gprofile1.setSectionTitle("Secondaria Superiore "+i); GeoNaFormCardModel fcm1 - * = new GeoNaFormCardModel(); fcm1.setGcubeProfile(gprofile1); - * gnaCardsModels.add(fcm1); } - * - * for (int i = 0; i < 3; i++) { GcubeProfileDV gprofile2 = new - * GcubeProfileDV(); gprofile2.setParentName("$.livello1.livello2"); - * gprofile2.setSectionTitle("Alberghiero di Pisa "+i); GeoNaFormCardModel fcm2 - * = new GeoNaFormCardModel(); fcm2.setGcubeProfile(gprofile2); - * gnaCardsModels.add(fcm2); } - * - * TreeItemPanel tip = new TreeItemPanel("Concessione", gnaCardsModels); - * RootPanel.get(GeoPortalDataEntryApp.DIV_PORTLET_ID).add(tip.getTree()); - */ + + final InitExecutor initExecutor = new InitExecutor(); + geoportalCaches = new GeoPortalClientCaches(); ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_LOADERS.getElement() @@ -198,94 +189,224 @@ public class GeoPortalDataEntryApp implements EntryPoint { geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); mainTabPanel.addFormPanel(geoNaMainForm); + paramGeonaItemType = Window.Location.getParameter(ConstantsGeoPortalDataEntryApp.GET_GEONA_ITEM_TYPE); + paramGeonaItemID = Window.Location.getParameter(ConstantsGeoPortalDataEntryApp.GET_GEONA_ITEM_ID); + ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_PORTLET.add(mainTabPanel); // ROOT_PANEL_DIV_PORTLET.getElement().getStyle().setOpacity(0.3); ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_PORTLET.getElement() .addClassName(ConstantsGeoPortalDataEntryApp.CSS_CLASS_ANIMATE_FADE_IN_OUT); - GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback() { + Command commandGeonaInitConfig = new Command() { @Override - public void onFailure(Throwable caught) { - String errorMsg = "Sorry, an error occurred when loading configurations. Please, contact the support"; - Alert alert = new Alert(errorMsg, AlertType.ERROR); - alert.setClose(false); - try { - ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_LOADERS.remove(loaderApplication); - } catch (Exception e) { + public void execute() { + GWT.log("Execute commandGeonaInitConfig..."); + GeoportalDataEntryServiceAsync.Util.getInstance() + .getGeonaInitConfig(new AsyncCallback() { + @Override + public void onFailure(Throwable caught) { + String errorMsg = "Sorry, an error occurred when loading configurations. Please, contact the support"; + Alert alert = new Alert(errorMsg, AlertType.ERROR); + alert.setClose(false); + try { + ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_LOADERS.remove(loaderApplication); + } catch (Exception e) { + + } + ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_PORTLET.add(alert); + Window.alert(errorMsg); + initExecutor.execute(); + } + + @Override + public void onSuccess(GeoportalISConfig geoportalISConfig) { + geoportalISConfigs = geoportalISConfig; + + if (geoportalISConfig != null && geoportalISConfig.getScope() != null) { + + loadGeoportalConfigs(geoportalISConfig.getScope()); + } else + Window.alert("Sorry, no scope found in the session. Re-login and try again"); + + initExecutor.execute(); + + } + }); + + } + }; + + Command commandReadDataViewerConfig = new Command() { + + @Override + public void execute() { + GWT.log("Execute commandReadDataViewerConfig..."); + // Loading Geoportal Configurations from IS + GeoportalDataEntryServiceAsync.Util.getInstance() + .readDataViewerConfig(new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + String errorMsg = "Sorry, an error occurred on istancing the application. Please, contact the support"; + Alert alert = new Alert(errorMsg, AlertType.ERROR); + alert.setClose(false); + try { + ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_LOADERS.remove(loaderApplication); + ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_PORTLET.getElement().removeClassName( + ConstantsGeoPortalDataEntryApp.CSS_CLASS_ANIMATE_FADE_IN_OUT); + } catch (Exception e) { + + } + ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_LOADERS.add(alert); + Window.alert(errorMsg); + + initExecutor.execute(); + + } + + @Override + public void onSuccess(GNADataEntryExtendedConfigProfile gNADataEntryConfig) { + GWT.log(GNADataEntryExtendedConfigProfile.class.getSimpleName() + " loaded: " + + gNADataEntryConfig); + + try { + ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_LOADERS.remove(loaderApplication); + } catch (Exception e) { + + } + + // PERMISSIONS + myRights = gNADataEntryConfig.getUserRights(); + initGUI(); + GcubeUserRole userRole = myRights.getRoleRights().getUserRole(); + mainTabPanel.setRole(userRole); + // GUI Presentation + mainTabPanel.setGUIPresentation(gNADataEntryConfig.getDataEntryGUIPresentation()); + + RoleRights roleRights = myRights.getRoleRights(); + canCreateNewItem = roleRights.getListPermessions().keySet() + .contains(OPERATION_ON_ITEM.CREATE_NEW_PROJECT); + + if (!canCreateNewItem) { + // removing Tab "Create New Project" + mainTabPanel.removeTab(0); + // activating Tab "List of Project" + mainTabPanel.setTabActive(0); + // mainTabPanel.instanceAndShowListOfProjects(); + } + + initExecutor.execute(); + } + }); + + } + }; + + Command commandInitOnItem = null; + + if (paramGeonaItemType != null && paramGeonaItemID != null) { + + commandInitOnItem = new Command() { + + @Override + public void execute() { + GWT.log("Execute commandInitOnItem..."); + GeoportalDataEntryServiceAsync.Util.getInstance().getResultDocumentFoProjectByID(paramGeonaItemType, + paramGeonaItemID, new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + Window.alert("Error " + caught.getMessage()); + initExecutor.execute(); + + } + + @Override + public void onSuccess(final ResultDocumentDV result) { + GWT.log("commandInitOnItem success: " + result); + Integer attempts = 0; + + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + @Override + public void execute() { + appManagerBus.fireEvent(new OperationOnItemEvent( + Arrays.asList(result), OPERATION_ON_ITEM.VIEW_PROJECT_AS_DOCUMENT)); + + + Timer timer = new Timer() { + int attempts = 0; + + @Override + public void run() { + attempts++; + GWT.log("commandInitOnItem run timer..."); + List list = mainTabPanel + .getUcdProjectTypesForListingDataView(); + if (list.size() > 0) { + this.cancel(); + + List filterUCD = mainTabPanel + .getUcdProjectTypesForListingDataView().stream() + .filter(u -> u.getId() + .contentEquals(paramGeonaItemType)) + .collect(Collectors.toList()); + + if (filterUCD.size() == 1) { + GWT.log("FilterUCD"); + + UseCaseDescriptorDV ucd = filterUCD.get(0); + + ListOfProjectTablePanel listProjectPanel = mainTabPanel.getListOfProjectTablePanel(); + SearchingFilter searchingFilter = new SearchingFilter(); + searchingFilter.setGetForIDs(result.getProfileID(), result.getProjectID()); + //searchFilter.setConditions(null); + //searchFilter.setGetForIDs(result.getProfileID(), result.getProjectID()); + + GetListOfRecordsEvent event = new GetListOfRecordsEvent(true, ucd.getProfileID(), + searchingFilter, true); + + listProjectPanel.setSearchTypeAndFire(filterUCD.get(0).getName(), event); + } + + if(attempts>30) { + this.cancel(); + } + } + + } + }; + timer.schedule(500); + initExecutor.execute(); + } + }); + + if (canCreateNewItem) { + mainTabPanel.setTabActive(1); + } else + mainTabPanel.setTabActive(0); + } + }); } - ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_PORTLET.add(alert); - Window.alert(errorMsg); + + }; + + } + + try { + initExecutor.putCommand(commandGeonaInitConfig); + initExecutor.putCommand(commandReadDataViewerConfig); + if (commandInitOnItem != null) { + initExecutor.putCommand(commandInitOnItem); } - - @Override - public void onSuccess(GeoportalISConfig geoportalISConfig) { - geoportalISConfigs = geoportalISConfig; - - if (geoportalISConfig != null && geoportalISConfig.getScope() != null) { - - loadGeoportalConfigs(geoportalISConfig.getScope()); - } else - Window.alert("Sorry, no scope found in the session. Re-login and try again"); - - } - }); - - // Loading Geoportal Configurations from IS - GeoportalDataEntryServiceAsync.Util.getInstance() - .readDataViewerConfig(new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - String errorMsg = "Sorry, an error occurred on istancing the application. Please, contact the support"; - Alert alert = new Alert(errorMsg, AlertType.ERROR); - alert.setClose(false); - try { - ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_LOADERS.remove(loaderApplication); - ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_PORTLET.getElement() - .removeClassName(ConstantsGeoPortalDataEntryApp.CSS_CLASS_ANIMATE_FADE_IN_OUT); - } catch (Exception e) { - - } - ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_LOADERS.add(alert); - Window.alert(errorMsg); - - } - - @Override - public void onSuccess(GNADataEntryExtendedConfigProfile gNADataEntryConfig) { - GWT.log(GNADataEntryExtendedConfigProfile.class.getSimpleName() + " loaded: " - + gNADataEntryConfig); - - try { - ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_LOADERS.remove(loaderApplication); - } catch (Exception e) { - - } - - // PERMISSIONS - myRights = gNADataEntryConfig.getUserRights(); - initGUI(); - GcubeUserRole userRole = myRights.getRoleRights().getUserRole(); - mainTabPanel.setRole(userRole); - // GUI Presentation - mainTabPanel.setGUIPresentation(gNADataEntryConfig.getDataEntryGUIPresentation()); - - RoleRights roleRights = myRights.getRoleRights(); - boolean canCreateNewItem = roleRights.getListPermessions().keySet() - .contains(OPERATION_ON_ITEM.CREATE_NEW_PROJECT); - - if (!canCreateNewItem) { - // removing Tab "Create New Project" - mainTabPanel.removeTab(0); - // activating Tab "List of Project" - mainTabPanel.setTabActive(0); - // mainTabPanel.instanceAndShowListOfProjects(); - } - } - }); + initExecutor.execute(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } @@ -790,7 +911,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) { - GWT.log("Fired: " + getListOfRecordsEvent); + GWT.log("Fired onGetList: " + getListOfRecordsEvent); SearchingFilter searchingFilter = getListOfRecordsEvent.getSearchingFilter(); CacheSearchingFilterParametersFromConfig seachingFilterParameters = geoportalCaches @@ -809,7 +930,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { if (searchingFilter == null || getListOfRecordsEvent.isOnApplicationInit() || getListOfRecordsEvent.isReloadFilteringParameters()) { mainTabPanel.setFilteringParameters(seachingFilterParameters); - searchingFilter = mainTabPanel.getCurrentProjectsSearchingFilter(); + // Searching in the cache if the list of relationship definition is present List listRelationshipsDef = geoportalCaches @@ -835,6 +956,10 @@ public class GeoPortalDataEntryApp implements EntryPoint { } }); } + + if(searchingFilter == null ) { + searchingFilter = mainTabPanel.getCurrentProjectsSearchingFilter(); + } } searchingFilter.setProjection(seachingFilterParameters.getProjection()); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/InitExecutor.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/InitExecutor.java new file mode 100644 index 0000000..13896ae --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/InitExecutor.java @@ -0,0 +1,43 @@ +package org.gcube.portlets.user.geoportaldataentry.client; + +import java.util.LinkedHashMap; + +import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.Window; + +public class InitExecutor { + + private LinkedHashMap queueInitStage = new LinkedHashMap<>(); + + public InitExecutor() { + + } + + public synchronized void putCommand(Command command) throws InterruptedException { + queueInitStage.put(queueInitStage.size(), command); + } + + private synchronized Command pollCommand() throws InterruptedException { + for (Integer key : queueInitStage.keySet()) { + Command command = queueInitStage.get(key); + if(command!=null) { + queueInitStage.put(key, null); + return command; + } + } + + return null; + } + + protected void execute() { + try { + Command command = pollCommand(); + if (command != null) + command.execute(); + } catch (InterruptedException e) { + Window.alert("An error occurred while initializing the application. Please contact the support. Error is: " + + e.getMessage()); + } + } + +} 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 3659853..383942c 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 @@ -105,11 +105,6 @@ public class GetListOfRecordsEvent extends GwtEvent extends GwtEvent selectItems; private OPERATION_ON_ITEM action; private Element sourceElement; + private String ucdName; /** * Instantiates a new action on item event. @@ -65,6 +66,10 @@ public class OperationOnItemEvent extends GwtEvent getUcdProjectTypesForListingDataView() { + return ucdProjectTypesForListingDataView; + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/projects/ListOfProjectTablePanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/projects/ListOfProjectTablePanel.java index 9747596..112f053 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/projects/ListOfProjectTablePanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/projects/ListOfProjectTablePanel.java @@ -324,17 +324,25 @@ public class ListOfProjectTablePanel extends Composite { if (ucdProjectTypesForListingDataView.size() == 1) { // noProjectSelectionMessage.setVisible(false); UseCaseDescriptorDV singleUCD = ucdProjectTypesForListingDataView.get(0); - alertProjectType.setText(singleUCD.getName()); - // setFilteringParameters(displayFields, sortByFields, searchForFields, - // currentSearchingFilter); - appManagerBus.fireEvent(new GetListOfRecordsEvent(true, singleUCD.getProfileID(), - getCurrentSearchingFilter(), true)); + GetListOfRecordsEvent event = new GetListOfRecordsEvent(true, singleUCD.getProfileID(), + getCurrentSearchingFilter(), true); + setSearchTypeAndFire(singleUCD.getName(), event); } } }); } + + public void setSearchTypeAndFire(String ucdName, GetListOfRecordsEvent event) { + alertProjectType.setText(ucdName); + +// if(event.getSearchingFilter().getProfileID()!=null && event.getSearchingFilter().getProjectID()) { +// +// } +// + appManagerBus.fireEvent(event); + } /** * Built searching filter. @@ -471,5 +479,10 @@ public class ListOfProjectTablePanel extends Composite { ddProjectType.add(link); } + + + public String getSelectedProjectType() { + return alertProjectType.getText(); + } } 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 a9b2eed..6e75d23 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 @@ -902,6 +902,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen searchedData.setTotalItems(totalProjectForProfile); LOG.info("Total Docs read from config: " + totalProjectForProfile); + + boolean isSearchForIds = filter.getProfileID()!=null && filter.getProjectID()!=null; // Saving client PROJECTION LinkedHashMap originalProjection = filter.getProjection(); @@ -928,13 +930,23 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen totalItems = listProjectIDs.size(); searchedData.setTotalItems(totalItems); LOG.info("Total Docs read from query per ID: " + totalItems); + }else if(isSearchForIds) { + //searching one item for IDs + searchedData.setTotalItems(1); } // NOW PERFORMING THE (REAL) SECOND QUERY FROM CLIENT // SETTING ORIGINAL PROJECTION FROM CLIENT filter.setProjection(originalProjection); // LIMIT IS FROM CLIENT - Iterator projects = client.queryOnMongo(theProfileID, totalItems, start, limit, filter); + + Iterator projects = null; + if(!isSearchForIds) { + projects = client.queryOnMongo(theProfileID, totalItems, start, limit, filter); + }else { + Project project = client.getProjectByID(filter.getProfileID(), filter.getProjectID()); + projects = Arrays.asList(project).iterator(); + } searchedData.setClientStartIndex(start); searchedData.setLimit(limit); @@ -1406,7 +1418,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen Project project = projects.getProjectByID(profileID, projectID); ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true); ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder); - LOG.info("returning: " + projectDV.getId()); + LOG.info("returning ProjectByID: " + projectDV.getId()); return projectDV; } catch (Exception e) {