integration with service completed
This commit is contained in:
parent
5a09e88604
commit
5e480535db
|
@ -7,4 +7,6 @@ public class ConstantsGeoPortalDataEntryApp {
|
||||||
public static final String DATE_FORMAT = ConstantsMPFormBuilder.DATE_FORMAT;
|
public static final String DATE_FORMAT = ConstantsMPFormBuilder.DATE_FORMAT;
|
||||||
|
|
||||||
public static final String TIME_FORMAT = ConstantsMPFormBuilder.TIME_FORMAT;
|
public static final String TIME_FORMAT = ConstantsMPFormBuilder.TIME_FORMAT;
|
||||||
|
|
||||||
|
public static final String HOURS_MINUTES_SEPARATOR = ConstantsMPFormBuilder.HOURS_MINUTES_SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,14 +109,20 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
resetUI();
|
resetUI();
|
||||||
//ordered values
|
//ordered values
|
||||||
for (GeoNaFormCardModel geonaForm : orderedCards) {
|
for (GeoNaFormCardModel geonaForm : orderedCards) {
|
||||||
CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()),appManagerBus);
|
|
||||||
geonaForm.setMetadataForm(baseForm);
|
//TODO TO TEST
|
||||||
String key = geonaForm.getMetadataProfileBean().getType();
|
//if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO)){
|
||||||
if(geonaForm.getFormCardTitle()!=null) {
|
|
||||||
key = geonaForm.getFormCardTitle().getTitle();
|
CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()),appManagerBus);
|
||||||
}
|
geonaForm.setMetadataForm(baseForm);
|
||||||
geoNaMainForm.addForm(key, geonaForm);
|
String key = geonaForm.getMetadataProfileBean().getType();
|
||||||
mapForms.put(key, geonaForm);
|
if(geonaForm.getFormCardTitle()!=null) {
|
||||||
|
key = geonaForm.getFormCardTitle().getTitle();
|
||||||
|
}
|
||||||
|
geoNaMainForm.addForm(key, geonaForm);
|
||||||
|
mapForms.put(key, geonaForm);
|
||||||
|
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
mainPanel.setLoaderVisible("", false);
|
mainPanel.setLoaderVisible("", false);
|
||||||
}
|
}
|
||||||
|
@ -224,7 +230,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
|
|
||||||
//means the form was not submitted
|
//means the form was not submitted
|
||||||
if(mapForms.size()>0) {
|
if(mapForms.size()>0) {
|
||||||
boolean confirm = Window.confirm("The data are not saved and will be lost, Confirm?");
|
boolean confirm = Window.confirm("Creating a new project, the current project (is not saved) and will be lost, Confirm?");
|
||||||
if(confirm)
|
if(confirm)
|
||||||
buildNewCards(orderedCards);
|
buildNewCards(orderedCards);
|
||||||
}else
|
}else
|
||||||
|
|
|
@ -22,7 +22,6 @@ import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.uibinder.client.UiHandler;
|
import com.google.gwt.uibinder.client.UiHandler;
|
||||||
import com.google.gwt.user.client.Timer;
|
import com.google.gwt.user.client.Timer;
|
||||||
import com.google.gwt.user.client.Window;
|
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
@ -126,7 +125,7 @@ public class GeonaDataEntryMainForm extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Window.alert("I can save: "+listGeonaFormObjects);
|
//Window.alert("I can save: "+listGeonaFormObjects);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.gcube.portlets.user.geoportaldataentry.server;
|
package org.gcube.portlets.user.geoportaldataentry.server;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
@ -8,6 +7,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.gcube.application.geoportal.model.AccessPolicy;
|
||||||
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
||||||
import org.gcube.application.geoportal.model.concessioni.LayerConcessione;
|
import org.gcube.application.geoportal.model.concessioni.LayerConcessione;
|
||||||
import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
|
import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
|
||||||
|
@ -29,9 +29,10 @@ import org.slf4j.LoggerFactory;
|
||||||
*/
|
*/
|
||||||
public class ConvertToServiceModel {
|
public class ConvertToServiceModel {
|
||||||
|
|
||||||
public static final DateFormat dateFormat = new SimpleDateFormat(ConstantsGeoPortalDataEntryApp.DATE_FORMAT+" "+ConstantsGeoPortalDataEntryApp.TIME_FORMAT);
|
/** The Constant LOG. */
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ConvertToServiceModel.class);
|
private static final Logger LOG = LoggerFactory.getLogger(ConvertToServiceModel.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To concessione.
|
* To concessione.
|
||||||
*
|
*
|
||||||
|
@ -155,6 +156,12 @@ public class ConvertToServiceModel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To relazione scavo.
|
||||||
|
*
|
||||||
|
* @param gdb the gdb
|
||||||
|
* @return the relazione scavo
|
||||||
|
*/
|
||||||
public static RelazioneScavo toRelazioneScavo(GenericDatasetBean gdb){
|
public static RelazioneScavo toRelazioneScavo(GenericDatasetBean gdb){
|
||||||
|
|
||||||
Map<String, List<String>> mapFields = gdb.getFormDataEntryFields();
|
Map<String, List<String>> mapFields = gdb.getFormDataEntryFields();
|
||||||
|
@ -187,6 +194,12 @@ public class ConvertToServiceModel {
|
||||||
return relazioneScavo;
|
return relazioneScavo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To immagini rappresentative.
|
||||||
|
*
|
||||||
|
* @param gdb the gdb
|
||||||
|
* @return the uploaded image
|
||||||
|
*/
|
||||||
public static UploadedImage toImmaginiRappresentative(GenericDatasetBean gdb){
|
public static UploadedImage toImmaginiRappresentative(GenericDatasetBean gdb){
|
||||||
|
|
||||||
Map<String, List<String>> mapFields = gdb.getFormDataEntryFields();
|
Map<String, List<String>> mapFields = gdb.getFormDataEntryFields();
|
||||||
|
@ -223,6 +236,12 @@ public class ConvertToServiceModel {
|
||||||
return uplaodedImage;
|
return uplaodedImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To layer concessione.
|
||||||
|
*
|
||||||
|
* @param gdb the gdb
|
||||||
|
* @return the layer concessione
|
||||||
|
*/
|
||||||
public static LayerConcessione toLayerConcessione(GenericDatasetBean gdb){
|
public static LayerConcessione toLayerConcessione(GenericDatasetBean gdb){
|
||||||
|
|
||||||
Map<String, List<String>> mapFields = gdb.getFormDataEntryFields();
|
Map<String, List<String>> mapFields = gdb.getFormDataEntryFields();
|
||||||
|
@ -234,6 +253,16 @@ public class ConvertToServiceModel {
|
||||||
layerConcessione.setTitolo(titoloLst.get(0));
|
layerConcessione.setTitolo(titoloLst.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> politicaDiAccessoLst = mapFields.get("Politica di accesso");
|
||||||
|
if(politicaDiAccessoLst!=null && politicaDiAccessoLst.size()>0) {
|
||||||
|
try {
|
||||||
|
AccessPolicy ap = AccessPolicy.valueOf(politicaDiAccessoLst.get(0));
|
||||||
|
layerConcessione.setPolicy(ap);
|
||||||
|
}catch (Exception e) {
|
||||||
|
LOG.warn("I cannot cast "+politicaDiAccessoLst.get(0) +" to "+AccessPolicy.values(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<String> valutazioneQualitaLst = mapFields.get("Valutazione della qualità");
|
List<String> valutazioneQualitaLst = mapFields.get("Valutazione della qualità");
|
||||||
if(valutazioneQualitaLst!=null && valutazioneQualitaLst.size()>0) {
|
if(valutazioneQualitaLst!=null && valutazioneQualitaLst.size()>0) {
|
||||||
layerConcessione.setValutazioneQualita(valutazioneQualitaLst.get(0));
|
layerConcessione.setValutazioneQualita(valutazioneQualitaLst.get(0));
|
||||||
|
@ -256,13 +285,23 @@ public class ConvertToServiceModel {
|
||||||
|
|
||||||
return layerConcessione;
|
return layerConcessione;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To instant.
|
||||||
|
*
|
||||||
|
* @param date the date
|
||||||
|
* @return the instant
|
||||||
|
*/
|
||||||
public static Instant toInstant(String date) {
|
public static Instant toInstant(String date) {
|
||||||
Instant theInst = null;
|
Instant theInst = null;
|
||||||
try {
|
try {
|
||||||
|
date = date.trim();
|
||||||
|
SimpleDateFormat dateFormat = null;
|
||||||
|
if(date.contains(ConstantsGeoPortalDataEntryApp.HOURS_MINUTES_SEPARATOR)) {
|
||||||
|
dateFormat = new SimpleDateFormat(ConstantsGeoPortalDataEntryApp.DATE_FORMAT+" "+ConstantsGeoPortalDataEntryApp.TIME_FORMAT);
|
||||||
|
}else
|
||||||
|
dateFormat = new SimpleDateFormat(ConstantsGeoPortalDataEntryApp.DATE_FORMAT);
|
||||||
|
|
||||||
Date theDate = dateFormat.parse(date);
|
Date theDate = dateFormat.parse(date);
|
||||||
theInst = theDate.toInstant();
|
theInst = theDate.toInstant();
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
|
|
|
@ -55,6 +55,7 @@ public class GreetingServiceImpl extends RemoteServiceServlet implements Greetin
|
||||||
prettyPrintClientDataEntryMap(toMap);
|
prettyPrintClientDataEntryMap(toMap);
|
||||||
|
|
||||||
LOG.debug("Built map with form data: "+toMap);
|
LOG.debug("Built map with form data: "+toMap);
|
||||||
|
|
||||||
GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest());
|
GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest());
|
||||||
|
|
||||||
//Saving Data
|
//Saving Data
|
||||||
|
@ -179,7 +180,8 @@ public class GreetingServiceImpl extends RemoteServiceServlet implements Greetin
|
||||||
private void prettyPrintClientDataEntryMap(HashMap<ConcessioniFormCardTitle, List<GeoNaFormDataObject>> toMap) {
|
private void prettyPrintClientDataEntryMap(HashMap<ConcessioniFormCardTitle, List<GeoNaFormDataObject>> toMap) {
|
||||||
|
|
||||||
for (ConcessioniFormCardTitle theType : toMap.keySet()) {
|
for (ConcessioniFormCardTitle theType : toMap.keySet()) {
|
||||||
LOG.debug("\n\n"+theType);
|
LOG.debug("\n\n");
|
||||||
|
LOG.debug(theType.toString());
|
||||||
List<GeoNaFormDataObject> list = toMap.get(theType);
|
List<GeoNaFormDataObject> list = toMap.get(theType);
|
||||||
for (GeoNaFormDataObject geoNaFormDataObject : list) {
|
for (GeoNaFormDataObject geoNaFormDataObject : list) {
|
||||||
LOG.debug("\t has "+geoNaFormDataObject.getListGDB().size() +" data bean/s");
|
LOG.debug("\t has "+geoNaFormDataObject.getListGDB().size() +" data bean/s");
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
package org.gcube.portlets.user.geoportaldataentry.client;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.geoportaldataentry.shared.FieldVerifier;
|
|
||||||
import com.google.gwt.core.client.GWT;
|
|
||||||
import com.google.gwt.junit.client.GWTTestCase;
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
||||||
import com.google.gwt.user.client.rpc.ServiceDefTarget;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GWT JUnit <b>integration</b> tests must extend GWTTestCase.
|
|
||||||
* Using <code>"GwtTest*"</code> naming pattern exclude them from running with
|
|
||||||
* surefire during the test phase.
|
|
||||||
*
|
|
||||||
* If you run the tests using the Maven command line, you will have to
|
|
||||||
* navigate with your browser to a specific url given by Maven.
|
|
||||||
* See https://gwt-maven-plugin.github.io/gwt-maven-plugin/user-guide/testing.html
|
|
||||||
* for details.
|
|
||||||
*/
|
|
||||||
public class GwtTestGeoPortalDataEntryApp extends GWTTestCase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Must refer to a valid module that sources this class.
|
|
||||||
*/
|
|
||||||
public String getModuleName() {
|
|
||||||
return "org.gcube.portlets.user.geoportaldataentry.GeoPortalDataEntryAppJUnit";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the FieldVerifier.
|
|
||||||
*/
|
|
||||||
public void testFieldVerifier() {
|
|
||||||
assertFalse(FieldVerifier.isValidName(null));
|
|
||||||
assertFalse(FieldVerifier.isValidName(""));
|
|
||||||
assertFalse(FieldVerifier.isValidName("a"));
|
|
||||||
assertFalse(FieldVerifier.isValidName("ab"));
|
|
||||||
assertFalse(FieldVerifier.isValidName("abc"));
|
|
||||||
assertTrue(FieldVerifier.isValidName("abcd"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This test will send a request to the server using the greetServer method in
|
|
||||||
* GreetingService and verify the response.
|
|
||||||
*/
|
|
||||||
public void testGreetingService() {
|
|
||||||
// Create the service that we will test.
|
|
||||||
GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
|
|
||||||
ServiceDefTarget target = (ServiceDefTarget) greetingService;
|
|
||||||
target.setServiceEntryPoint(GWT.getModuleBaseURL() + "GeoPortalDataEntryApp/greet");
|
|
||||||
|
|
||||||
// Since RPC calls are asynchronous, we will need to wait for a response
|
|
||||||
// after this test method returns. This line tells the test runner to wait
|
|
||||||
// up to 10 seconds before timing out.
|
|
||||||
delayTestFinish(10000);
|
|
||||||
|
|
||||||
// Send a request to the server.
|
|
||||||
greetingService.greetServer("GWT User", new AsyncCallback<String>() {
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
// The request resulted in an unexpected error.
|
|
||||||
fail("Request failure: " + caught.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onSuccess(String result) {
|
|
||||||
// Verify that the response is correct.
|
|
||||||
assertTrue(result.startsWith("Hello, GWT User!"));
|
|
||||||
|
|
||||||
// Now that we have received a response, we need to tell the test runner
|
|
||||||
// that the test is complete. You must call finishTest() after an
|
|
||||||
// asynchronous test finishes successfully, or the test will time out.
|
|
||||||
finishTest();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.gcube.portlets.user.geoportaldataentry.client;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.geoportaldataentry.server.ConvertToServiceModel;
|
||||||
|
|
||||||
|
public class TestClass {
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
Instant instant = ConvertToServiceModel.toInstant("2020-10-01 10:20");
|
||||||
|
System.out.println(instant.toString());
|
||||||
|
|
||||||
|
String latitudine = "-899.2986";
|
||||||
|
System.out.println(latitudine.matches("^[-]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue