diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.java index 0c2be89..39ef992 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.java @@ -38,7 +38,8 @@ public class ActionListPanel extends Composite { private List listActionDefinition; private HandlerManager appManagerBus; - public ActionListPanel(HandlerManager appManagerBus,String projectName, String profileID, List listActionDef) { + public ActionListPanel(HandlerManager appManagerBus, String projectName, String profileID, + List listActionDef) { initWidget(uiBinder.createAndBindUi(this)); GWT.log("Adding list of actions: " + listActionDef); this.appManagerBus = appManagerBus; @@ -60,7 +61,7 @@ public class ActionListPanel extends Composite { private void initActions(List listActionDef) { if (listActionDef.size() > 0) { - //actionListBasePanel.setVisible(true); + // actionListBasePanel.setVisible(true); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.getElement().addClassName("actions-button-group"); @@ -68,12 +69,13 @@ public class ActionListPanel extends Composite { mapPhaseListButtons = new LinkedHashMap>(); for (ActionDefinitionDV actionDefinitionDV : listActionDef) { - - //skipping the special workflow action - if(actionDefinitionDV.getId().equals(ConstantsGeoPortalDataEntryApp.WORKFLOW_ACTION_POST_CREATION_ACTION_ID)) { + + // skipping the special workflow action + if (actionDefinitionDV.getId() + .equals(ConstantsGeoPortalDataEntryApp.WORKFLOW_ACTION_POST_CREATION_ACTION_ID)) { continue; } - + Button butt = new Button(); butt.setText(actionDefinitionDV.getTitle()); butt.setTitle(actionDefinitionDV.getDescription()); @@ -83,7 +85,8 @@ public class ActionListPanel extends Composite { @Override public void onClick(ClickEvent event) { - appManagerBus.fireEvent(new WorkflowActionOnSelectedItemEvent(actionDefinitionDV)); + appManagerBus + .fireEvent(new WorkflowActionOnSelectedItemEvent(actionDefinitionDV)); } }); @@ -110,9 +113,9 @@ public class ActionListPanel extends Composite { public void showActionsOnSelected(List listSelected, GcubeUserRole userRole) { setAllActionsVisible(false); - + if (listSelected.size() == 1) { - + for (T item : listSelected) { if (item instanceof ResultDocumentDV) { @@ -120,20 +123,25 @@ public class ActionListPanel extends Composite { String itemPhase = ((ResultDocumentDV) item).getLifecycleInfo().getPhase(); List listButtons = mapPhaseListButtons.get(itemPhase); - for (ActionDefButton actionDefButton : listButtons) { - - Set roles = actionDefButton.getActionDefinitionDV().getRoles(); - - //No role/s defined means enable the action by default - if(roles.isEmpty()) { - actionDefButton.getButton().setVisible(true); - actionListBasePanel.setVisible(true); - }else { - //Checking if the userRole is matching the role defined in the ActionDefinition - boolean isRoleIntoActionDef= roles.stream().anyMatch(userRole.getName()::equalsIgnoreCase); - if(isRoleIntoActionDef) { + + if (listButtons != null) { + + for (ActionDefButton actionDefButton : listButtons) { + + Set roles = actionDefButton.getActionDefinitionDV().getRoles(); + + // No role/s defined means enable the action by default + if (roles.isEmpty()) { actionDefButton.getButton().setVisible(true); actionListBasePanel.setVisible(true); + } else { + // Checking if the userRole is matching the role defined in the ActionDefinition + boolean isRoleIntoActionDef = roles.stream() + .anyMatch(userRole.getName()::equalsIgnoreCase); + if (isRoleIntoActionDef) { + actionDefButton.getButton().setVisible(true); + actionListBasePanel.setVisible(true); + } } } } @@ -144,13 +152,19 @@ public class ActionListPanel extends Composite { } private void setAllActionsVisible(boolean bool) { - Iterator> collIterator = mapPhaseListButtons.values().iterator(); - while (collIterator.hasNext()) { - List listButton = collIterator.next(); - for (ActionDefButton actionDefButton : listButton) { - actionDefButton.getButton().setVisible(bool); - } + if (mapPhaseListButtons != null && mapPhaseListButtons.values().size() > 0) { + + Iterator> collIterator = mapPhaseListButtons.values().iterator(); + if (collIterator != null) { + while (collIterator.hasNext()) { + List listButton = collIterator.next(); + for (ActionDefButton actionDefButton : listButton) { + actionDefButton.getButton().setVisible(bool); + } + + } + } } } } 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 8cca170..0317876 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 @@ -143,6 +143,9 @@ public class ItemsTable extends AbstractItemsCellTable String key = itemField.getJsonFields().get(0) .replace(ConstantsGeoPortalDataEntryApp.DEFAULT_DOCUMENT_PROJECTION_NAME + ".", ""); Object value = documentDV.getDocumentAsMap().get(key); + if(value==null) + return ""; + return value.toString(); } catch (Exception e) { GWT.log("Error e: " + e); @@ -164,6 +167,9 @@ public class ItemsTable extends AbstractItemsCellTable .replace(ConstantsGeoPortalDataEntryApp.DEFAULT_DOCUMENT_PROJECTION_NAME + ".", ""); Object value = documentDV.getDocumentAsMap().get(key); // GWT.log("key: "+key+" is instance of: "+value.getClass()); + + if(value==null) + return; if (value instanceof ArrayList) { ArrayList arrayValues = (ArrayList) value;