diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalClientCaches.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalClientCaches.java index 10949a1..e00bdc3 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalClientCaches.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalClientCaches.java @@ -26,11 +26,13 @@ public class GeoPortalClientCaches { private TreeMap> mapGcubeProfilePerItemType; private Map>> mapHandlersConfigurationsForProfileId; - + private Map mapUseCaseDescriptor; private Map mapSearchingFilterParametersForProfileId; + private Map> mapRelationsNamesForProfileId; + /** * Instantiates a new geo portal client caches. */ @@ -39,6 +41,7 @@ public class GeoPortalClientCaches { mapHandlersConfigurationsForProfileId = new HashMap>>(); mapSearchingFilterParametersForProfileId = new HashMap(); mapUseCaseDescriptor = new HashMap(); + mapRelationsNamesForProfileId = new HashMap>(); } /** @@ -51,23 +54,43 @@ public class GeoPortalClientCaches { mapHandlersConfigurationsForProfileId.put(profileId, lsitConfigurations); } + /** + * Put list relation names for profile ID. + * + * @param profileId the profile id + * @param listRealationNames the list realation names + */ + public void putListRelationNamesForProfileID(String profileId, List listRealationNames) { + mapRelationsNamesForProfileId.put(profileId, listRealationNames); + } + + /** + * Gets the list relation names for profile id. + * + * @param profileId the profile id + * @return the list relation names for profile id + */ + public List getListRelationNamesForProfileId(String profileId) { + return mapRelationsNamesForProfileId.get(profileId); + } + /** * Put UCD for profile id. * * @param profileID the profile ID - * @param ucdDV the ucd DV + * @param ucdDV the ucd DV */ public void putUCDForProfileId(String profileID, UseCaseDescriptorDV ucdDV) { mapUseCaseDescriptor.put(profileID, ucdDV); } - + /** * Gets the UCD for profile ID. * * @param profileID the profile ID * @return the UCD for profile ID */ - public UseCaseDescriptorDV getUCDForProfileID(String profileID){ + public UseCaseDescriptorDV getUCDForProfileID(String profileID) { return mapUseCaseDescriptor.get(profileID); } @@ -130,7 +153,7 @@ public class GeoPortalClientCaches { searchingFilterParameters.addDisplayField(itemField); // adding to projection for filtering for (String jsonFieldPath : itemField.getJsonFields()) { - //String mongoProjection = itemField.getProjection() + "." + jsonField; + // String mongoProjection = itemField.getProjection() + "." + jsonField; searchingFilterParameters.putMongoProjection(jsonFieldPath, 1); } } @@ -184,7 +207,7 @@ public class GeoPortalClientCaches { * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Sep 13, 2022 + * Sep 13, 2022 */ public class CacheSearchingFilterParametersFromConfig { @@ -209,7 +232,7 @@ public class GeoPortalClientCaches { * Put mongo projection. * * @param keyField the key field - * @param value the value + * @param value the value */ public void putMongoProjection(String keyField, Object value) { projection.put(keyField, value); 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 04a8aea..c03e6ad 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 @@ -270,6 +270,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { } } }); + } private void initGUI() { @@ -341,7 +342,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { mainTabPanel.initMainAccordingToListUseCaseDescriptors(listUCDescriptors); - for (UseCaseDescriptorDV ucdDV : listUCDescriptors) { + for (final UseCaseDescriptorDV ucdDV : listUCDescriptors) { List> listConfigurations = geoportalCaches .getHandlerConfigurationsForProfileId(ucdDV.getProfileID()); @@ -764,10 +765,39 @@ public class GeoPortalDataEntryApp implements EntryPoint { CacheSearchingFilterParametersFromConfig seachingFilterParameters = geoportalCaches .getFilterParametersForProfileId(getListOfRecordsEvent.getProfileID()); + String profileID = getListOfRecordsEvent.getProfileID(); + if (profileID == null) { + new DialogInform(null, "Error", "No Use Case Descriptor selected").center(); + return; + } + if (searchingFilter == null || getListOfRecordsEvent.isOnApplicationInit() || getListOfRecordsEvent.isReloadFilteringParameters()) { mainTabPanel.setFilteringParameters(seachingFilterParameters); searchingFilter = mainTabPanel.getCurrentProjectsSearchingFilter(); + + //Searching in the cache if the list of relation names is present + List listRelationNames = geoportalCaches.getListRelationNamesForProfileId(profileID); + // Loading list of Relation Names for ProfileID + if (listRelationNames == null || listRelationNames.isEmpty()) { + + GeoPortalDataEntryApp.geoportalDataEntryService.getRelationshipNames(profileID, + new AsyncCallback>() { + + @Override + public void onSuccess(List relationshipNames) { + GWT.log("getRelationshipNames for " + profileID + " are: "+relationshipNames); + geoportalCaches.putListRelationNamesForProfileID(profileID, relationshipNames); + mainTabPanel.setVisibleCreateRelationButton( + relationshipNames != null && !relationshipNames.isEmpty()); + } + + @Override + public void onFailure(Throwable caught) { + + } + }); + } } // TODO MUST MANAGE getListOfRecordsEvent.isReloadFilteringParameters() @@ -776,20 +806,18 @@ public class GeoPortalDataEntryApp implements EntryPoint { List displayFields = seachingFilterParameters.getDisplayFields(); - String profileID = getListOfRecordsEvent.getProfileID(); - if (profileID == null) { - new DialogInform(null, "Error", "No Use Case Descriptor selected").center(); - return; - } - grpw = new GeonaRecordsPaginatedView(appManagerBus, profileID, displayFields, searchingFilter); - mainTabPanel.showListOfConcessioniView(grpw); + mainTabPanel.showListOfProjectsView(grpw); // The Project Type is changed if (getListOfRecordsEvent.isReloadFilteringParameters()) { + // Setting the action panel according to profileID mainTabPanel.initActionListPanel(geoportalCaches.getUCDForProfileID(profileID)); + // Displaying the create relation button only if list of relation names exits + } + } }); @@ -856,21 +884,19 @@ public class GeoPortalDataEntryApp implements EntryPoint { Alert alert = new Alert(); alert.setType(AlertType.SUCCESS); alert.setClose(false); - alert.setText("Relationship "+relName+" created correctly!"); + alert.setText("Relationship " + relName + " created correctly!"); modal.add(alert); String htmlMsg = "In the project with:"; htmlMsg += "
    "; htmlMsg += "
  • id: " + fromProjectID + "
  • "; htmlMsg += "
  • profile: " + fromProfileID + "
  • "; - htmlMsg += "
  • " - + createRelationHE.getFromProject().getFirstEntryOfMap().getKey() - + ": " - + createRelationHE.getFromProject().getFirstEntryOfMap().getValue() + htmlMsg += "
  • " + createRelationHE.getFromProject().getFirstEntryOfMap().getKey() + + ": " + createRelationHE.getFromProject().getFirstEntryOfMap().getValue() + "
  • "; htmlMsg += "
"; - htmlMsg += "has been created the relationship " + relName + " to the project wiht id: " - + toProjectID; + htmlMsg += "has been created the relationship " + relName + + " to the project wiht id: " + toProjectID; modal.add(new HTML(htmlMsg)); ReportTemplateToHTML rtth = new ReportTemplateToHTML("Relationship", result.getAsJSON(), false, false); @@ -1229,10 +1255,13 @@ public class GeoPortalDataEntryApp implements EntryPoint { break; } -// case UPDATED_PROJECT: -// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, -// mainTabPanel.getCurrentSortFilter())); -// break; + case VIEW_RELATIONSHIPS: { + + mainTabPanel.showViewProjectRelationsPanel(true, resultDocumentDV); + + break; + } + case DELETE_PROJECT: { String htmlMsg = "Going to delete the project with:"; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java index b3d453b..72c0cbf 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java @@ -5,6 +5,7 @@ import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.SearchingFilter; +import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ActionDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; @@ -189,15 +190,35 @@ public interface GeoportalDataEntryService extends RemoteService { /** * Creates the relationship. * - * @param fromProfileID the from profile ID - * @param fromProjectID the from project ID + * @param fromProfileID the from profile ID + * @param fromProjectID the from project ID * @param relationshipName the relationship name - * @param toProfileID the to profile ID - * @param toProjectID the to project ID + * @param toProfileID the to profile ID + * @param toProjectID the to project ID * @return the relationship DV * @throws Exception the exception */ RelationshipDV createRelationship(String fromProfileID, String fromProjectID, String relationshipName, String toProfileID, String toProjectID) throws Exception; + /** + * Gets the project by ID. + * + * @param profileID the profile ID + * @param projectID the project ID + * @return the project by ID + * @throws Exception the exception + */ + ProjectDV getProjectByID(String profileID, String projectID) throws Exception; + + /** + * Gets the result document fo project by ID. + * + * @param profileID the profile ID + * @param projectID the project ID + * @return the result document fo project by ID + * @throws Exception the exception + */ + ResultDocumentDV getResultDocumentFoProjectByID(String profileID, String projectID) throws Exception; + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java index edcfee1..aaef08f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java @@ -5,6 +5,7 @@ import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.SearchingFilter; +import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ActionDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; @@ -89,4 +90,8 @@ public interface GeoportalDataEntryServiceAsync { void createRelationship(String fromProfileID, String fromProjectID, String relationshipName, String toProfileID, String toProjectID, AsyncCallback callback); + void getProjectByID(String profileID, String projectID, AsyncCallback callback); + + void getResultDocumentFoProjectByID(String profileID, String projectID, AsyncCallback callback); + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java index b8f734a..44b1d6c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java @@ -21,6 +21,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryM import org.gcube.portlets.user.geoportaldataentry.client.ui.projects.ListOfProjectTablePanel; import org.gcube.portlets.user.geoportaldataentry.client.ui.projects.ListOfProjectWorkflowActionsPanel; import org.gcube.portlets.user.geoportaldataentry.client.ui.relation.CreateRelationProjectsPanel; +import org.gcube.portlets.user.geoportaldataentry.client.ui.relation.ViewRelationshipPanel; 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; @@ -103,6 +104,9 @@ public class GeonaMainTabPanel extends Composite { @UiField NavLink navCreateRelation; + @UiField + NavLink navViewRelations; + @UiField Label roleLabel; @@ -130,6 +134,8 @@ public class GeonaMainTabPanel extends Composite { private CreateRelationProjectsPanel createRelationProjectsPanel; + private ViewRelationshipPanel viewRelationshipPanel; + private ScrollPanel detailsPanel = new ScrollPanel(); private ListOfProjectTablePanel listOfProjectTablePanel; @@ -277,6 +283,23 @@ public class GeonaMainTabPanel extends Composite { } }); + navViewRelations.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + List listDocuments = null; + if (grpw != null && grpw.getSelectItems() != null) { + listDocuments = grpw.getSelectItems(); + } + + OperationOnItemEvent oIE = new OperationOnItemEvent(listDocuments, + OPERATION_ON_ITEM.VIEW_RELATIONSHIPS); + oIE.setSourceElement(navViewRelations.getElement()); + appManagerBus.fireEvent( + new OperationOnItemEvent(listDocuments, OPERATION_ON_ITEM.VIEW_RELATIONSHIPS)); + } + }); + } /** @@ -304,13 +327,13 @@ public class GeonaMainTabPanel extends Composite { } /** - * Show list of concessioni view. + * Show list of projects view. * * @param grpw the grpw */ - public void showListOfConcessioniView(GeonaRecordsPaginatedView grpw) { + public void showListOfProjectsView(GeonaRecordsPaginatedView grpw) { this.grpw = grpw; - listOfProjectTablePanel.showListOfConcessioniView(grpw); + listOfProjectTablePanel.showListOfProjectsView(grpw); } /** @@ -483,6 +506,10 @@ public class GeonaMainTabPanel extends Composite { createRelationProjectsPanel.selectedProject((ResultDocumentDV) selectItems.get(0)); } + if (viewRelationshipPanel != null && viewRelationshipPanel.isVisible()) { + viewRelationshipPanel.showRelationsOf((ResultDocumentDV) selectItems.get(0)); + } + } /** @@ -519,9 +546,9 @@ public class GeonaMainTabPanel extends Composite { * Show create relation panel. * * @param bool the bool - * @param resultDocumentDV the result document DV + * @param selectedDocument the document DV */ - public void showCreateRelationPanel(boolean bool, ResultDocumentDV resultDocumentDV) { + public void showCreateRelationPanel(boolean bool, ResultDocumentDV selectedDocument) { detailsPanel.clear(); // theDetailsPanel.setVisible(bool); theDockLayoutPanel.setWidgetHidden(detailsPanel, !bool); @@ -529,8 +556,35 @@ public class GeonaMainTabPanel extends Composite { if (!bool) { return; } - createRelationProjectsPanel = new CreateRelationProjectsPanel(appManagerBus, resultDocumentDV); + createRelationProjectsPanel = new CreateRelationProjectsPanel(appManagerBus, selectedDocument); detailsPanel.add(createRelationProjectsPanel); } + /** + * Show view project relations panel. + * + * @param bool the bool + * @param resultDocumentDV the result document DV + */ + public void showViewProjectRelationsPanel(boolean bool, ResultDocumentDV selectedDocument) { + detailsPanel.clear(); + // theDetailsPanel.setVisible(bool); + theDockLayoutPanel.setWidgetHidden(detailsPanel, !bool); + // if hiding, returns + if (!bool) { + return; + } + viewRelationshipPanel = new ViewRelationshipPanel(appManagerBus, selectedDocument); + detailsPanel.add(viewRelationshipPanel); + } + + /** + * Sets the visible create relation. + * + * @param bool the new visible create relation + */ + public void setVisibleCreateRelationButton(boolean bool) { + navCreateRelation.setVisible(bool); + } + } 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 89b9d27..c5335fb 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 @@ -39,6 +39,11 @@ position: relative; top: -20px; } + + .divider-border-right { + border-left: 1px solid #ccc !important; + height: 35px !important; + } Edit Delete Project + Create Relation + title="Create Relation between two Projects" icon="LINK">Create + Relation + View + Relations diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.ui.xml index ae15f5a..e2c1b51 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.ui.xml @@ -6,13 +6,21 @@ .important { font-weight: bold; } - .action-panel-style { + + .action-panel { display: flex; margin-left: 30px; } + + .action-title { + color: #777; + font-size: 14px; + text-shadow: 0 1px 0 #eee; + } - - WORKFLOW ACTIONS + + WORKFLOW ACTIONS \ No newline at end of file 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 cf1ce01..f1f6071 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 @@ -19,6 +19,7 @@ import com.github.gwtbootstrap.client.ui.Alert; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Dropdown; import com.github.gwtbootstrap.client.ui.NavLink; +import com.github.gwtbootstrap.client.ui.Paragraph; import com.github.gwtbootstrap.client.ui.TextBox; import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.ButtonType; @@ -78,6 +79,9 @@ public class ListOfProjectTablePanel extends Composite { @UiField Dropdown ddProjectType; + + @UiField + Paragraph noProjectSelectionMessage; private CacheSearchingFilterParametersFromConfig cacheSearchingFilterParameters; @@ -312,7 +316,9 @@ public class ListOfProjectTablePanel extends Composite { this.ucdProjectTypesForListingDataView = ucdProjectTypesForListingDataView; // If the list of UCDProjectType for listing is not empty.. FIRE THE EVENT OF // SELECTION on the first item + noProjectSelectionMessage.setVisible(true); if (ucdProjectTypesForListingDataView.size() > 0) { + noProjectSelectionMessage.setVisible(false); UseCaseDescriptorDV singleUCD = ucdProjectTypesForListingDataView.get(0); alertProjectType.setText(singleUCD.getName()); // setFilteringParameters(displayFields, sortByFields, searchForFields, @@ -425,12 +431,7 @@ public class ListOfProjectTablePanel extends Composite { } } - /** - * Show list of concessioni view. - * - * @param grpw the grpw - */ - public void showListOfConcessioniView(GeonaRecordsPaginatedView grpw) { + public void showListOfProjectsView(GeonaRecordsPaginatedView grpw) { this.grpw = grpw; geonaListOfRecordsPanel.clear(); VerticalPanel htmllPanel = new VerticalPanel(); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/projects/ListOfProjectTablePanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/projects/ListOfProjectTablePanel.ui.xml index 74f418d..af7e5e6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/projects/ListOfProjectTablePanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/projects/ListOfProjectTablePanel.ui.xml @@ -79,6 +79,7 @@ Go to bottom + select "Project Type"
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/CreateRelationProjectsPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/CreateRelationProjectsPanel.java index cea7997..2d9cef5 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/CreateRelationProjectsPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/CreateRelationProjectsPanel.java @@ -37,8 +37,6 @@ public class CreateRelationProjectsPanel extends Composite { interface CreateRelationProjectsPanelUiBinder extends UiBinder { } - private String profileID; - @UiField HTMLPanel firstPanelContainer; @@ -100,11 +98,21 @@ public class CreateRelationProjectsPanel extends Composite { listBoxRelationNames.setWidth("90%"); - GeoPortalDataEntryApp.geoportalDataEntryService.getRelationshipNames(profileID, + GeoPortalDataEntryApp.geoportalDataEntryService.getRelationshipNames(project.getProfileID(), new AsyncCallback>() { @Override public void onSuccess(List relationshipNames) { + + if (relationshipNames == null || relationshipNames.size() == 0) { + buttCreateRelation.setEnabled(false); + alertMessage + .setText("You cannot create a relationship. No configuration found in the UCD for: " + + project.getProfileID()); + alertMessage.setVisible(true); + return; + } + for (String relName : relationshipNames) { listBoxRelationNames.addItem(relName, relName); } @@ -113,7 +121,8 @@ public class CreateRelationProjectsPanel extends Composite { @Override public void onFailure(Throwable caught) { - // TODO Auto-generated method stub + alertMessage.setText("Error on reading the relationship names. Error: " + caught.getMessage()); + return; } }); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/CreateRelationProjectsPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/CreateRelationProjectsPanel.ui.xml index d6aff90..23e0d05 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/CreateRelationProjectsPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/CreateRelationProjectsPanel.ui.xml @@ -36,6 +36,14 @@ border-radius: 5px; padding: 5px; } + + .panel-style table { + margin-top: 0px !important; + } + + .panel-container-style { + padding-left: 10px; + } @@ -52,7 +60,7 @@ Select project from the "List of Projects" Table - + @@ -68,7 +76,7 @@ Select project from the "List of Projects" Table - + { + } + + private String profileID; + + @UiField + HTMLPanel firstPanelContainer; + + @UiField + HTMLPanel panelTitle; + + @UiField + HTMLPanel secondPanelContainer; + + @UiField + FlowPanel firstProjectPanelContainer; + + @UiField + FlowPanel secondProjectPanelContainer; + + @UiField + Button closeButton; + + private HashMap selectedProjects = new HashMap(2); + + private HandlerManager appManagerBus; + + public ViewRelationshipPanel(HandlerManager appManagerBus, ResultDocumentDV fromProject) { + initWidget(uiBinder.createAndBindUi(this)); + this.appManagerBus = appManagerBus; + + closeButton.setType(ButtonType.LINK); + closeButton.setIcon(IconType.REMOVE); + closeButton.setIconSize(IconSize.LARGE); + + closeButton.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + appManagerBus.fireEvent(new CloseCreateRelationGUIEvent()); + } + }); + + showRelationsOf(fromProject); + } + + public void showRelationsOf(ResultDocumentDV project) { + firstProjectPanelContainer.clear(); + secondProjectPanelContainer.clear(); + + String htmlMsg = "" + project.getFirstEntryOfMap().getKey() + ": " + project.getFirstEntryOfMap().getValue() + + " (id: " + project.getId() + ")"; + + firstProjectPanelContainer.add(new HTML(htmlMsg)); + ReportTemplateToHTML rtth = new ReportTemplateToHTML("", project.getDocumentAsJSON(), false, false); + rtth.showAsJSON(false); + firstProjectPanelContainer.add(rtth); + + HTML labelNoRelations = new HTML("No relationship/s found"); + secondProjectPanelContainer.add(labelNoRelations); + + if (project.getListRelationshipDV() != null && project.getListRelationshipDV().size() > 0) { + + secondProjectPanelContainer.clear(); + + for (RelationshipDV relationDV : project.getListRelationshipDV()) { + final FlexTable flexTable = new FlexTable(); + flexTable.getElement().getStyle().setMarginTop(10, Unit.PX); + Label label = new Label(); + label.setType(LabelType.INFO); + label.setText(relationDV.getRelationshipName()); + flexTable.setWidget(0, 0, label); + flexTable.setWidget(1, 0, new LoaderIcon("loading project..")); + GeoportalDataEntryServiceAsync.Util.getInstance().getResultDocumentFoProjectByID(project.getProfileID(), + project.getId(), new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + flexTable.setWidget(1, 0, new HTML(caught.getMessage())); + + } + + @Override + public void onSuccess(ResultDocumentDV result) { + String htmlMsg = "" + project.getFirstEntryOfMap().getValue() + " (id: " + + project.getId() + ")"; + + flexTable.setWidget(1, 0, new HTML(htmlMsg)); + + } + }); + + ReportTemplateToHTML rtth2 = new ReportTemplateToHTML("", project.getDocumentAsJSON(), false, false); + rtth.showAsJSON(false); + + flexTable.setWidget(2, 0, rtth2); + secondProjectPanelContainer.add(flexTable); + } + + } + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.ui.xml new file mode 100644 index 0000000..f7b6c9e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.ui.xml @@ -0,0 +1,63 @@ + + + + .view-rel-title { + font-size: 18px; + font-weight: bold; + text-align: center; + padding: 18px; + background: #eee; + } + + .butt-create { + float: right; + margin-top: 10px; + } + + .to-align-right { + position: absolute; + right: 5px; + } + + .panel-style { + margin-top: 10px; + padding: 5px; + } + + .panel-style table { + margin-top: 0px !important; + } + + .panel-container-style { + padding-left: 10px; + padding-top: 5px; + } + + + + + View Relations + + + From Project + + + + + + + To Project/s + + + + + + \ No newline at end of file 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 21c7b6c..8c30d53 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 @@ -1018,4 +1018,45 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } } + + @Override + public ProjectDV getProjectByID(String profileID, String projectID) throws Exception { + LOG.info("getProjectByID called"); + + try { + ProjectsCaller projects = GeoportalClientCaller.projects(); + Project project = projects.getProjectByID(profileID, projectID); + ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true); + ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder); + LOG.info("returning: " + projectDV.getId()); + return projectDV; + + } catch (Exception e) { + String error = "Error occurred on reading the project with id: " + projectID; + LOG.error(error, e); + throw new Exception( + error + ". Error: " + e.getMessage() + ". Refresh and try again or contact the support"); + } + + } + + @Override + public ResultDocumentDV getResultDocumentFoProjectByID(String profileID, String projectID) throws Exception { + LOG.info("getResultDocumentFoProjectByID called"); + + try { + ProjectsCaller projects = GeoportalClientCaller.projects(); + Project project = projects.getProjectByID(profileID, projectID); + ResultDocumentDV documentDV = ConvertToDataValueObjectModel.toResultDocumentDV(project); + LOG.info("returning: " + documentDV.getId()); + return documentDV; + + } catch (Exception e) { + String error = "Error occurred on reading the project with id: " + projectID; + LOG.error(error, e); + throw new Exception( + error + ". Error: " + e.getMessage() + ". Refresh and try again or contact the support"); + } + + } }