minor fix

This commit is contained in:
Francesco Mangiacrapa 2020-10-21 12:38:57 +02:00
parent 88ff360a99
commit 3980df91c6
8 changed files with 60 additions and 38 deletions

View File

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

View File

@ -47,9 +47,6 @@
<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>

View File

@ -3,4 +3,5 @@
<installed facet="jst.web" version="2.3"/>
<installed facet="com.gwtplugins.gwt.facet" version="1.0"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.jaxrs" version="2.0"/>
</faceted-project>

View File

@ -10,5 +10,4 @@ public class ConstantsGeoPortalDataEntryApp {
public static final String HOURS_MINUTES_SEPARATOR = ConstantsMPFormBuilder.HOURS_MINUTES_SEPARATOR;
public static final String FILE_UPLOADED_SESSION_ATTR = ConstantsMPFormBuilder.FILE_UPLOADED_SESSION_ATTR;
}

View File

@ -77,20 +77,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onSuccess(List<MetaDataProfileBean> result) {
orderedCards = setGeoNaFormsOrder(result);
//ordered values
buildNewCards(orderedCards);
/*for (GeoNaFormCardModel geonaForm : orderedCards) {
CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()),appManagerBus);
geonaForm.setMetadataForm(baseForm);
String key = geonaForm.getMetadataProfileBean().getType();
if(geonaForm.getFormCardTitle()!=null) {
key = geonaForm.getFormCardTitle().getTitle();
}
geoNaMainForm.addForm(key, geonaForm);
mapForms.put(key, geonaForm);
}
mainPanel.setLoaderVisible("", false);*/
}
@Override

View File

@ -2,7 +2,8 @@ package org.gcube.portlets.user.geoportaldataentry.server;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -19,19 +20,30 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// TODO: Auto-generated Javadoc
/**
* The Class ConvertToServiceModel.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 19, 2020
* Oct 21, 2020
*/
public class ConvertToServiceModel {
/** The Constant LOG. */
private static final Logger LOG = LoggerFactory.getLogger(ConvertToServiceModel.class);
public static final String HOURS_MINUTES_SEPARATOR = ConstantsGeoPortalDataEntryApp.HOURS_MINUTES_SEPARATOR;
public static final String DATE_FORMAT = ConstantsGeoPortalDataEntryApp.DATE_FORMAT;
public static final String TIME_FORMAT = ConstantsGeoPortalDataEntryApp.TIME_FORMAT;
// public static final String DATE_FORMAT = "yyyy-MM-dd";
//
// public static final String HOURS_MINUTES_SEPARATOR = ":";
//
// public static final String TIME_FORMAT = "HH"+HOURS_MINUTES_SEPARATOR+"mm";
/**
* To concessione.
@ -64,15 +76,15 @@ public class ConvertToServiceModel {
List<String> dataInizProgettoList = mapFields.get("Data inizio Progetto");
if(dataInizProgettoList!=null && dataInizProgettoList.size()>0) {
String inizioProgetto = dataInizProgettoList.get(0);
Instant theIstant = toInstant(inizioProgetto);
concessione.setDataInizioProgetto(theIstant);
LocalDateTime theLDT = toLocalDateTime(inizioProgetto);
concessione.setDataInizioProgetto(theLDT);
}
List<String> dataFineProgettoList = mapFields.get("Data fine Progetto");
if(dataFineProgettoList!=null && dataFineProgettoList.size()>0) {
String fineProgetto = dataFineProgettoList.get(0);
Instant theIstant = toInstant(fineProgetto);
concessione.setDataFineProgetto(theIstant);
LocalDateTime theLDT = toLocalDateTime(fineProgetto);
concessione.setDataFineProgetto(theLDT);
}
@ -286,28 +298,42 @@ public class ConvertToServiceModel {
return layerConcessione;
}
/**
* To instant.
* To local date time.
*
* @param date the date
* @return the instant
* @return the local date time
*/
public static Instant toInstant(String date) {
Instant theInst = null;
public static LocalDateTime toLocalDateTime(String date) {
LocalDateTime theLocalDT = null;
try {
date = date.trim();
SimpleDateFormat dateFormat = null;
if(date.contains(ConstantsGeoPortalDataEntryApp.HOURS_MINUTES_SEPARATOR)) {
dateFormat = new SimpleDateFormat(ConstantsGeoPortalDataEntryApp.DATE_FORMAT+" "+ConstantsGeoPortalDataEntryApp.TIME_FORMAT);
if(date.contains(HOURS_MINUTES_SEPARATOR)) {
dateFormat = new SimpleDateFormat(DATE_FORMAT+" "+TIME_FORMAT);
}else
dateFormat = new SimpleDateFormat(ConstantsGeoPortalDataEntryApp.DATE_FORMAT);
dateFormat = new SimpleDateFormat(DATE_FORMAT);
Date theDate = dateFormat.parse(date);
theInst = theDate.toInstant();
theLocalDT = convertToLocalDateTimeViaInstant(theDate);
} catch (ParseException e) {
LOG.error("No able to parse: "+date, e);
}
return theInst;
return theLocalDT;
}
/**
* Convert to local date time via instant.
*
* @param dateToConvert the date to convert
* @return the local date time
*/
public static LocalDateTime convertToLocalDateTimeViaInstant(Date dateToConvert) {
return dateToConvert.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
}
}

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.geoportaldataentry.client;
import java.time.Instant;
import java.time.LocalDateTime;
import org.gcube.portlets.user.geoportaldataentry.server.ConvertToServiceModel;
@ -9,11 +9,15 @@ public class TestClass {
public static void main(String[] args) {
Instant instant = ConvertToServiceModel.toInstant("2020-10-01 10:20");
System.out.println(instant.toString());
LocalDateTime ldt = ConvertToServiceModel.toLocalDateTime("2020-10-01 10:20");
System.out.println(ldt.toString());
String latitudine = "-899.2986";
System.out.println(latitudine.matches("^[-]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
//System.out.println(latitudine.matches("^[-]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
String longitude = "0";
System.out.println(longitude.matches("\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
}

View File

@ -6,3 +6,10 @@
/log4j.properties
/pred4s.gcubekey
/preprod.gcubekey
/CNR.it.gcubekey
/EUBrazilOpenBio.gcubekey
/Ecosystem.gcubekey
/FARM.gcubekey
/ISTI.gcubekey
/d4science.research-infrastructures.eu.gcubekey
/howto.txt