Configured to call the metadata-profile-form-builder widget

This commit is contained in:
Francesco Mangiacrapa 2020-10-08 15:09:25 +02:00
parent be65092445
commit b0c95d161a
18 changed files with 264 additions and 216 deletions

View File

@ -1,4 +1,5 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
lastWarOutDir=/home/francesco/git/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.0-SNAPSHOT jarsExcludedFromWebInfLib=
lastWarOutDir=/home/francesco-mangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.0-SNAPSHOT
warSrcDir=src/main/webapp warSrcDir=src/main/webapp
warSrcDirIsOutput=false warSrcDirIsOutput=false

View File

@ -0,0 +1,3 @@
eclipse.preferences.version=1
entryPointModules=
gwtSyncCodeServer=true

View File

@ -17,6 +17,9 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="metadata-profile-form-builder-widget-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/metadata-profile-form-builder-widget/metadata-profile-form-builder-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.0-SNAPSHOT/WEB-INF/classes"/> <property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.0-SNAPSHOT/WEB-INF/classes"/>

11
pom.xml
View File

@ -77,6 +77,11 @@
<version>2.3.2.0</version> <version>2.3.2.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>metadata-profile-form-builder-widget</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency> <dependency>
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>openlayer-basic-widgets</artifactId> <artifactId>openlayer-basic-widgets</artifactId>
@ -106,11 +111,6 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- END FWS --> <!-- END FWS -->
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>metadata-profile-discovery</artifactId>
<version>[0.0.1, 1.0.0-SNAPSHOT)</version>
</dependency>
<dependency> <dependency>
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-widgets</artifactId> <artifactId>gcube-widgets</artifactId>
@ -256,5 +256,4 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -6,7 +6,14 @@
<!-- Inherit the default GWT style sheet. You can change --> <!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting --> <!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. --> <!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' /> <!--<inherits name='com.google.gwt.user.theme.standard.Standard' /> -->
<inherits name="com.github.gwtbootstrap.Bootstrap" />
<inherits name="com.google.gwt.json.JSON" />
<inherits name='org.gcube.portlets.widgets.mpformbuilder.MetadataProfileFormBuilder' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> --> <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> --> <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->

View File

@ -1,22 +1,11 @@
package org.gcube.portlets.user.geoportaldataentry.client; package org.gcube.portlets.user.geoportaldataentry.client;
import org.gcube.portlets.user.geoportaldataentry.shared.FieldVerifier; import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm;
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
/** /**
* Entry point classes define <code>onModuleLoad()</code>. * Entry point classes define <code>onModuleLoad()</code>.
@ -27,8 +16,9 @@ public class GeoPortalDataEntryApp implements EntryPoint {
* returns an error. * returns an error.
*/ */
private static final String SERVER_ERROR = "An error occurred while " private static final String SERVER_ERROR = "An error occurred while "
+ "attempting to contact the server. Please check your network " + "attempting to contact the server. Please check your network " + "connection and try again.";
+ "connection and try again.";
private static final String DIV_PORTLET_ID = "geoportal-data-entry";
/** /**
* Create a remote service proxy to talk to the server-side Greeting service. * Create a remote service proxy to talk to the server-side Greeting service.
@ -41,110 +31,12 @@ public class GeoPortalDataEntryApp implements EntryPoint {
* This is the entry point method. * This is the entry point method.
*/ */
public void onModuleLoad() { public void onModuleLoad() {
final Button sendButton = new Button( messages.sendButton() );
final TextBox nameField = new TextBox();
nameField.setText( messages.nameField() );
final Label errorLabel = new Label();
// We can add style names to widgets String scope = "/gcube/devsec/devVRE";
sendButton.addStyleName("sendButton"); String secondaryType = "GeoNaMetadata";
HandlerManager eventBus = new HandlerManager(null);
CreateMetadataForm baseForm = new CreateMetadataForm(scope, secondaryType, eventBus);
RootPanel.get(DIV_PORTLET_ID).add(baseForm);
// Add the nameField and sendButton to the RootPanel
// Use RootPanel.get() to get the entire body element
RootPanel.get("nameFieldContainer").add(nameField);
RootPanel.get("sendButtonContainer").add(sendButton);
RootPanel.get("errorLabelContainer").add(errorLabel);
// Focus the cursor on the name field when the app loads
nameField.setFocus(true);
nameField.selectAll();
// Create the popup dialog box
final DialogBox dialogBox = new DialogBox();
dialogBox.setText("Remote Procedure Call");
dialogBox.setAnimationEnabled(true);
final Button closeButton = new Button("Close");
// We can set the id of a widget by accessing its Element
closeButton.getElement().setId("closeButton");
final Label textToServerLabel = new Label();
final HTML serverResponseLabel = new HTML();
VerticalPanel dialogVPanel = new VerticalPanel();
dialogVPanel.addStyleName("dialogVPanel");
dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
dialogVPanel.add(textToServerLabel);
dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
dialogVPanel.add(serverResponseLabel);
dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
dialogVPanel.add(closeButton);
dialogBox.setWidget(dialogVPanel);
// Add a handler to close the DialogBox
closeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
dialogBox.hide();
sendButton.setEnabled(true);
sendButton.setFocus(true);
}
});
// Create a handler for the sendButton and nameField
class MyHandler implements ClickHandler, KeyUpHandler {
/**
* Fired when the user clicks on the sendButton.
*/
public void onClick(ClickEvent event) {
sendNameToServer();
}
/**
* Fired when the user types in the nameField.
*/
public void onKeyUp(KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
sendNameToServer();
}
}
/**
* Send the name from the nameField to the server and wait for a response.
*/
private void sendNameToServer() {
// First, we validate the input.
errorLabel.setText("");
String textToServer = nameField.getText();
if (!FieldVerifier.isValidName(textToServer)) {
errorLabel.setText("Please enter at least four characters");
return;
}
// Then, we send the input to the server.
sendButton.setEnabled(false);
textToServerLabel.setText(textToServer);
serverResponseLabel.setText("");
greetingService.greetServer(textToServer, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
// Show the RPC error message to the user
dialogBox.setText("Remote Procedure Call - Failure");
serverResponseLabel.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(SERVER_ERROR);
dialogBox.center();
closeButton.setFocus(true);
}
public void onSuccess(String result) {
dialogBox.setText("Remote Procedure Call");
serverResponseLabel.removeStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(result);
dialogBox.center();
closeButton.setFocus(true);
}
});
}
}
// Add a handler to send the name to the server
MyHandler handler = new MyHandler();
sendButton.addClickHandler(handler);
nameField.addKeyUpHandler(handler);
} }
} }

View File

@ -0,0 +1,44 @@
package org.gcube.portlets.user.geoportaldataentry.portlet;
import java.io.IOException;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
/**
* The Class GeoPortalDataEntryApp.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 8, 2020
*/
public class GeoPortalDataEntryApp extends GenericPortlet{
/**
* JSP folder name
*/
public static final String JSP_FOLDER = "/WEB-INF/jsp/";
/**
*
*/
public static final String VIEW_JSP = JSP_FOLDER + "GeoPortalDataEntryApp_view.jsp";
/**
* Do view.
*
* @param request .
* @param response .
* @throws PortletException .
* @throws IOException .
*/
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
//System.out.println("LOADING ********* FROM "+VIEW_JSP);
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP);
rd.include(request,response);
}
}

View File

@ -6,7 +6,10 @@
<!-- Inherit the default GWT style sheet. You can change --> <!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting --> <!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. --> <!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' /> <!--<inherits name='com.google.gwt.user.theme.standard.Standard' /> -->
<inherits name='org.gcube.portlets.widgets.mpformbuilder.MetadataProfileFormBuilder' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> --> <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> --> <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->

View File

@ -1,2 +0,0 @@
sendButton = Envoyer
nameField = Entrez votre nom

View File

@ -17,14 +17,15 @@
<!-- --> <!-- -->
<!-- Any title is fine --> <!-- Any title is fine -->
<!-- --> <!-- -->
<title>Web Application Starter Project</title> <title>GeoPortal Data Entry App</title>
<!-- --> <!-- -->
<!-- This script loads your compiled module. --> <!-- This script loads your compiled module. -->
<!-- If you add any GWT meta tags, they must --> <!-- If you add any GWT meta tags, they must -->
<!-- be added before this line. --> <!-- be added before this line. -->
<!-- --> <!-- -->
<script type="text/javascript" language="javascript" src="GeoPortalDataEntryApp/GeoPortalDataEntryApp.nocache.js"></script> <script type="text/javascript" language="javascript"
src="GeoPortalDataEntryApp/GeoPortalDataEntryApp.nocache.js"></script>
</head> </head>
<!-- --> <!-- -->
@ -35,29 +36,16 @@
<body> <body>
<!-- OPTIONAL: include this if you want history support --> <!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1'
style="position: absolute; width: 0; height: 0; border: 0"></iframe>
<!-- RECOMMENDED if your web app will not function without JavaScript enabled --> <!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
<noscript> <noscript>
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif"> <div
Your web browser must have JavaScript enabled style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
in order for this application to display correctly. Your web browser must have JavaScript enabled in order for this
</div> application to display correctly.</div>
</noscript> </noscript>
<div id="geoportal-data-entry"></div>
<h1>Web Application Starter Project</h1>
<table align="center">
<tr>
<td colspan="2" style="font-weight:bold;">Please enter your name:</td>
</tr>
<tr>
<td id="nameFieldContainer"></td>
<td id="sendButtonContainer"></td>
</tr>
<tr>
<td colspan="2" style="color:red;" id="errorLabelContainer"></td>
</tr>
</table>
</body> </body>
</html> </html>

View File

@ -0,0 +1,38 @@
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%-- Uncomment below lines to add portlet taglibs to jsp
<%@ page import="javax.portlet.*"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<portlet:defineObjects />
--%>
<script
src='<%=request.getContextPath()%>/GeoPortalDataEntryApp/js/jquery-1.10.1.min.js'></script>
<script
src='<%=request.getContextPath()%>/GeoPortalDataEntryApp/js/bootstrap.min.js'></script>
<link rel="stylesheet"
href="<%=request.getContextPath()%>/GeoPortalDataEntryApp.css"
type="text/css">
<link type="text/css" rel="stylesheet"
href="<%=request.getContextPath()%>/GeoPortalDataEntryApp/css/ol.css">
<script type="text/javascript"
src="<%=request.getContextPath()%>/GeoPortalDataEntryApp/js/ol.js"></script>
<script type="text/javascript"
src="GeoPortalDataEntryApp/GeoPortalDataEntryApp.nocache.js"></script>
</head>
<!-- <script type="text/javascript" -->
<%-- src='<%=request.getContextPath()%>/js/jquery.min.js'></script> --%>
<script type="text/javascript"
src='<%=request.getContextPath()%>/js/jquery.autosize.js'></script>
<div id="geoportal-data-entry"></div>

View File

@ -0,0 +1,5 @@
<display>
<category name="gCube Applications">
<portlet id="GeoPortalDataEntryApp" />
</category>
</display>

View File

@ -0,0 +1,9 @@
name=GeoPortalDataEntryApp
module-group-id=liferay
module-incremental-version=2
tags=
short-description=
change-log=
page-url=http://www.gcube-system.org
author=gCube
licenses=EUPL

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 5.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_5_2_0.dtd">
<liferay-portlet-app>
<portlet>
<portlet-name>GeoPortalDataEntryApp</portlet-name>
<layout-cacheable>false</layout-cacheable>
<instanceable>false</instanceable>
<ajaxable>false</ajaxable>
</portlet>
</liferay-portlet-app>

View File

@ -0,0 +1,25 @@
<?xml version='1.0' encoding='UTF-8' ?>
<portlet-app>
<portlet>
<description>GeoPortalDataEntryApp Portlet</description>
<portlet-name>GeoPortalDataEntryApp</portlet-name>
<display-name>GeoPortal Data Entry Portlet</display-name>
<portlet-class>org.gcube.portlets.user.geoportaldataentry.portlet.GeoPortalDataEntryApp
</portlet-class>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
</supports>
<portlet-info>
<title>GeoPortal Data Entry Portlet</title>
<short-title>GeoPortal Data Entry Portlet</short-title>
</portlet-info>
<portlet-preferences>
<preference>
<name>portletSetupShowBorders</name>
<value>false</value>
</preference>
</portlet-preferences>
</portlet>
</portlet-app>

View File

@ -11,11 +11,34 @@
<servlet-class>org.gcube.portlets.user.geoportaldataentry.server.GreetingServiceImpl</servlet-class> <servlet-class>org.gcube.portlets.user.geoportaldataentry.server.GreetingServiceImpl</servlet-class>
</servlet> </servlet>
<!-- Servlets -->
<servlet>
<servlet-name>mpformbuilderServlet</servlet-name>
<servlet-class>org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl</servlet-class>
</servlet>
<!-- Servlets -->
<servlet>
<servlet-name>metadataProfileFormBuilderUploadServlet</servlet-name>
<servlet-class>org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderUploadServlet</servlet-class>
</servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>greetServlet</servlet-name> <servlet-name>greetServlet</servlet-name>
<url-pattern>/GeoPortalDataEntryApp/greet</url-pattern> <url-pattern>/GeoPortalDataEntryApp/greet</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet-mapping>
<servlet-name>mpformbuilderServlet</servlet-name>
<url-pattern>/GeoPortalDataEntryApp/mpformbuilderservice</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>metadataProfileFormBuilderUploadServlet</servlet-name>
<url-pattern>/GeoPortalDataEntryApp/metadataProfileFormBuilderUploadServlet</url-pattern>
</servlet-mapping>
<!-- Default page to serve --> <!-- Default page to serve -->
<welcome-file-list> <welcome-file-list>
<welcome-file>GeoPortalDataEntryApp.html</welcome-file> <welcome-file>GeoPortalDataEntryApp.html</welcome-file>

8
src/test/resources/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
/devNext.gcubekey
/devVRE.gcubekey
/devsec.gcubekey
/gCubeApps.gcubekey
/gcube.gcubekey
/log4j.properties
/pred4s.gcubekey
/preprod.gcubekey

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to="GeoPortalDataEntryApp">
<!-- Inherit our applications main module. -->
<inherits name='org.gcube.portlets.user.geoportaldataentry.GeoPortalDataEntryApp' />
<!-- Specify the path to any remote services. -->
<servlet path="/GeoPortalDataEntryApp/greet" class="org.gcube.portlets.user.geoportaldataentry.server.GreetingServiceImpl" />
</module>