task_20210 #1

Closed
francesco.mangiacrapa wants to merge 11 commits from task_20210 into master
17 changed files with 441 additions and 323 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/geoportal-data-entry-app-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/geoportal-data-entry-app-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/geoportal-data-entry-app-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources"> <classpathentry excluding="**" kind="src" output="target/geoportal-data-entry-app-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
@ -35,5 +35,5 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/geoportal-data-entry-app-1.0.0-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/geoportal-data-entry-app-1.1.0-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

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

View File

@ -1,132 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="geoportal-data-entry-app-1.0.0-SNAPSHOT">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-module deploy-name="geoportal-data-entry-app-1.0.0-SNAPSHOT">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="metadata-profile-form-builder-widget-1.0.0.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="context-root" value="geoportal-data-entry-app"/> <property name="context-root" value="geoportal-data-entry-app"/>
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.0-SNAPSHOT/WEB-INF/classes"/>
</wb-module>
</wb-module>
</project-modules> </project-modules>

View File

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

View File

@ -4,6 +4,27 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.1.0-SNAPSHOT] - 2020-12-1
#### Enhancements
[#20210] Updating required for data entry facility after the first feedback by domain experts
## [v1.0.2-SNAPSHOT] - 2020-11-09
#### Bug fixes
[#20092] Repeatible form: validate the card after the create event is fired
## [v1.0.1] - 2020-11-04
#### Bug fixes
[#20063] Fixes for data-entry components
## [v1.0.0] - 2020-10-07 ## [v1.0.0] - 2020-10-07
[#19916] First release [#19916] First release

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>geoportal-data-entry-app</artifactId> <artifactId>geoportal-data-entry-app</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>1.0.0</version> <version>1.1.0-SNAPSHOT</version>
<name>GeoPortal Data Entry App</name> <name>GeoPortal Data Entry App</name>
<description>The GeoPortal Data Entry App is an application to build the web forms for data entries needed to GeoNa project</description> <description>The GeoPortal Data Entry App is an application to build the web forms for data entries needed to GeoNa project</description>
<scm> <scm>
@ -114,7 +114,12 @@
<version>[1.0.0, 2.0.0-SNAPSHOT)</version> <version>[1.0.0, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- END FWS --> <dependency>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-data-common</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.gcube.application</groupId> <groupId>org.gcube.application</groupId>
<artifactId>geoportal-logic</artifactId> <artifactId>geoportal-logic</artifactId>

View File

@ -1,29 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module rename-to='GeoPortalDataEntryApp'> <module rename-to='GeoPortalDataEntryApp'>
<!-- Inherit the core Web Toolkit stuff. --> <!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' /> <inherits name='com.google.gwt.user.User' />
<!-- 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.github.gwtbootstrap.Bootstrap" />
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits --> <inherits name="com.google.gwt.json.JSON" />
<!-- Specify the app entry point class. --> <inherits
<entry-point class='org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp' /> name='org.gcube.portlets.widgets.mpformbuilder.MetadataProfileFormBuilder' />
<!-- Specify the paths for translatable code --> <inherits name='org.gcube.application.geoportalcommon.GeoportalDataCommon' />
<source path='client' />
<source path='shared' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point
class='org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
</module> </module>

View File

@ -1,40 +1,88 @@
package org.gcube.portlets.user.geoportaldataentry.client; package org.gcube.portlets.user.geoportaldataentry.client;
/**
* The Enum ConcessioniFormCardTitle.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 30, 2020
*/
public enum ConcessioniFormCardTitle { public enum ConcessioniFormCardTitle {
INFORMAZIONI_DI_PROGETTO("Informazioni", "Informazioni di Progetto", 1, false), INFORMAZIONI_DI_PROGETTO("Informazioni", "Informazioni di Progetto", 1, false, null),
RELAZIONE_DI_SCAVO("Relazione di Scavo", "Relazione di Scavo", 2, false), RELAZIONE_DI_SCAVO("Relazione di Scavo", "Relazione di Scavo", 2, false, null),
IMMAGINI_RAPPRESENTATIVE("Immagini Rappresentative", "Immagini Rappresentative", 3, true), IMMAGINI_RAPPRESENTATIVE("Immagini Rappresentative", "Immagini Rappresentative", 3, true, 8),
POSIZIONAMENTO_DELL_AREA_DI_INDAGINE("Posizionamento", "Posizionamento dell'Area di Indagine", 4, false), POSIZIONAMENTO_DELL_AREA_DI_INDAGINE("Posizionamento", "Posizionamento dell'Area di Indagine", 4, false, null),
PIANTA_DI_FINE_SCAVO("Pianta di Fine Scavo", "Pianta di Fine Scavo", 5, true); PIANTA_DI_FINE_SCAVO("Pianta di Fine Scavo", "Pianta di Fine Scavo", 5, true, null);
private String key; private String key;
private String title; private String title;
private Integer order; private Integer order;
private boolean internalRepeatibleForm; private boolean internalRepeatibleForm;
private Integer maxFormRepeatability;
private ConcessioniFormCardTitle(String key, String title, int order, boolean internalRepeatibleForm) { /**
* Instantiates a new concessioni form card title.
*
* @param key the key
* @param title the title
* @param order the order
* @param internalRepeatibleForm the internal repeatible form
* @param maxFormRepeatability the max form repeatability
*/
private ConcessioniFormCardTitle(String key, String title, int order, boolean internalRepeatibleForm, Integer maxFormRepeatability) {
this.key = key; this.key = key;
this.title = title; this.title = title;
this.order = order; this.order = order;
this.internalRepeatibleForm = internalRepeatibleForm; this.internalRepeatibleForm = internalRepeatibleForm;
this.maxFormRepeatability = maxFormRepeatability;
} }
/**
* Gets the key.
*
* @return the key
*/
public String getKey() { public String getKey() {
return key; return key;
} }
/**
* Gets the title.
*
* @return the title
*/
public String getTitle() { public String getTitle() {
return title; return title;
} }
/**
* Gets the order.
*
* @return the order
*/
public Integer getOrder() { public Integer getOrder() {
return order; return order;
} }
/**
* Checks if is internal repeatible form.
*
* @return true, if is internal repeatible form
*/
public boolean isInternalRepeatibleForm() { public boolean isInternalRepeatibleForm() {
return internalRepeatibleForm; return internalRepeatibleForm;
} }
/**
* Gets the max form repeatability.
*
* @return the max form repeatability
*/
public Integer getMaxFormRepeatability() {
return maxFormRepeatability;
}
} }

View File

@ -7,6 +7,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.TreeMap; import java.util.TreeMap;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent;
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEventHandler;
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent;
@ -30,6 +31,8 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
/** /**
@ -64,7 +67,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
private LinkedHashMap<Long, List<GeoNaFormDataObject>> savedMap = new LinkedHashMap<Long, List<GeoNaFormDataObject>>(); private LinkedHashMap<Long, List<GeoNaFormDataObject>> savedMap = new LinkedHashMap<Long, List<GeoNaFormDataObject>>();
//private List<MetaDataProfileBean> orderedListMetadataProfilesForGeona = null; private boolean projectSavedWithSuccess;
/** /**
* This is the entry point method. * This is the entry point method.
@ -97,7 +100,6 @@ public class GeoPortalDataEntryApp implements EntryPoint {
bindEvents(); bindEvents();
mainPanel.addFormPanel(geoNaMainForm); mainPanel.addFormPanel(geoNaMainForm);
RootPanel.get(DIV_PORTLET_ID).add(mainPanel); RootPanel.get(DIV_PORTLET_ID).add(mainPanel);
} }
@ -119,13 +121,14 @@ public class GeoPortalDataEntryApp implements EntryPoint {
} }
private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards) { private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards) {
projectSavedWithSuccess = false; //resetting state of saving
mainPanel.setLoaderVisible("Loading...", true); mainPanel.setLoaderVisible("Loading...", true);
resetUI(); resetUI();
//ordered values //ordered values
for (GeoNaFormCardModel geonaForm : orderedCards) { for (GeoNaFormCardModel geonaForm : orderedCards) {
//TODO TO TEST //TODO TO TEST
//if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO)){ //if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE)){
CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()),appManagerBus); CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()),appManagerBus);
geonaForm.setMetadataForm(baseForm); geonaForm.setMetadataForm(baseForm);
@ -204,14 +207,20 @@ public class GeoPortalDataEntryApp implements EntryPoint {
final Modal modal = new Modal(true); final Modal modal = new Modal(true);
modal.setCloseVisible(false); modal.setCloseVisible(false);
modal.setTitle("Saving project...");
modal.hide(false);
final HorizontalPanel modalContainerPanel = new HorizontalPanel();
final LoaderIcon loader = new LoaderIcon(); final LoaderIcon loader = new LoaderIcon();
loader.setText("Trying to save the data, please wait..."); loader.setText("Trying to save the data, please wait...");
modal.add(loader); modalContainerPanel.add(loader);
modal.add(modalContainerPanel);
GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms(saveGeonaDataFormsEvent.getListGeonaDataForms(), new AsyncCallback<CommitReport>() { GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms(saveGeonaDataFormsEvent.getListGeonaDataForms(), new AsyncCallback<CommitReport>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
modalContainerPanel.clear();
modal.setCloseVisible(true);
try { try {
modal.remove(loader); modal.remove(loader);
}catch (Exception e) { }catch (Exception e) {
@ -220,21 +229,20 @@ public class GeoPortalDataEntryApp implements EntryPoint {
alert.setType(AlertType.ERROR); alert.setType(AlertType.ERROR);
alert.setClose(false); alert.setClose(false);
modal.add(alert); modal.add(alert);
modal.setCloseVisible(true);
//resetUI(); //resetUI();
geoNaMainForm.enableButtonSave(true); geoNaMainForm.enableButtonSave(true);
} }
@Override @Override
public void onSuccess(CommitReport result) { public void onSuccess(CommitReport result) {
try { modalContainerPanel.clear();
modal.remove(loader); modal.setCloseVisible(true);
}catch (Exception e) {
}
Alert alert = new Alert(result.getMsg()); Alert alert = new Alert(result.getMsg());
switch (result.getState()) { switch (result.getState()) {
case OK: case OK:
alert.setType(AlertType.SUCCESS); alert.setType(AlertType.SUCCESS);
projectSavedWithSuccess = true;
geoNaMainForm.showAlertOnSaveAction(result.getMsg(), AlertType.SUCCESS, true);
purgeFileUploaded(); purgeFileUploaded();
break; break;
case WARN: case WARN:
@ -250,12 +258,35 @@ public class GeoPortalDataEntryApp implements EntryPoint {
} }
alert.setClose(false); alert.setClose(false);
modal.add(alert); modal.add(alert);
modal.setCloseVisible(true);
try { try {
savedMap.put(result.getRecordId(), saveGeonaDataFormsEvent.getListGeonaDataForms()); savedMap.put(result.getRecordId(), saveGeonaDataFormsEvent.getListGeonaDataForms());
}catch (Exception e) { }catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
final HorizontalPanel hpLoader = new HorizontalPanel();
final LoaderIcon lc = new LoaderIcon("Get link...");
hpLoader.add(lc);
modal.add(hpLoader);
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(result.getRecordId(), "concessione", new AsyncCallback<GeoNaItemRef>() {
@Override
public void onFailure(Throwable caught) {
hpLoader.clear();
}
@Override
public void onSuccess(GeoNaItemRef result) {
hpLoader.clear();
String htmlLink = "<div>Go to record: <a href="+result.getRestrictedLink().getShortURL()+" target=\"_blank\">"+result.getRestrictedLink().getShortURL()+"</a></div>";
HTML html = new HTML(htmlLink);
modal.add(html);
}
});
//geoNaMainForm.enableButtonSave(true); //geoNaMainForm.enableButtonSave(true);
//resetUI(); //resetUI();
@ -274,17 +305,22 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override @Override
public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) { public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) {
//means the form was not submitted // means the form was not submitted
if(savedMap.size()==0) { if (savedMap.size() == 0) {
boolean confirm = Window.confirm("Creating a new project, the current project (is not saved) and will be lost, Confirm?"); boolean confirm = Window.confirm(
if(confirm) "Creating a new project, the current project (is not saved) and will be lost, Confirm?");
if (confirm)
buildNewCards(orderedCards); buildNewCards(orderedCards);
}else { } else if (projectSavedWithSuccess) {
//means the project has been saved
buildNewCards(orderedCards);
} else {
//means the project reported one ore more errors after the submit
boolean confirm = Window.confirm("Creating a new project, the web-forms will be cleaned, Confirm?"); boolean confirm = Window.confirm("Creating a new project, the web-forms will be cleaned, Confirm?");
if(confirm) if (confirm)
buildNewCards(orderedCards); buildNewCards(orderedCards);
} }
} }
}); });
} }

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataentry.client;
import java.util.List; import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
@ -18,4 +19,14 @@ public interface GeoportalDataEntryService extends RemoteService {
CommitReport saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception; CommitReport saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception;
GeonaISConfig getGeonaInitConfig(); GeonaISConfig getGeonaInitConfig();
/**
* Gets the links for.
*
* @param itemId the item id
* @param recordType the record type
* @return the links for
* @throws Exception the exception
*/
GeoNaItemRef getLinksFor(Long itemId, String recordType) throws Exception;
} }

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataentry.client;
import java.util.List; import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
@ -39,4 +40,7 @@ public interface GeoportalDataEntryServiceAsync
void getGeonaInitConfig(AsyncCallback<GeonaISConfig> callback); void getGeonaInitConfig(AsyncCallback<GeonaISConfig> callback);
void getLinksFor(Long itemId, String recordType, AsyncCallback<GeoNaItemRef> callback);
} }

View File

@ -133,7 +133,7 @@ public class GeonaDataEntryMainForm extends Composite {
} }
private void showAlertOnSaveAction(String text, AlertType type, boolean hideAfterAWhile){ public void showAlertOnSaveAction(String text, AlertType type, boolean hideAfterAWhile){
//Window.alert("Called alertOnCreate"); //Window.alert("Called alertOnCreate");
alertFormAction.setText(text); alertFormAction.setText(text);

View File

@ -10,9 +10,11 @@ import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Tab; import com.github.gwtbootstrap.client.ui.Tab;
import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window;
/** /**
@ -44,6 +46,8 @@ public class MetadataFormCard {
private HandlerManager appManagerBus; private HandlerManager appManagerBus;
private Integer maxFormRepeatability;
/** /**
* The Class MetadataFormCardEventHandler. * The Class MetadataFormCardEventHandler.
* *
@ -108,8 +112,9 @@ public class MetadataFormCard {
this.geonaFormModel = geonaFormModel; this.geonaFormModel = geonaFormModel;
this.appManagerBus = appManagerBus; this.appManagerBus = appManagerBus;
this.repeatible = geonaFormModel.getFormCardTitle().isInternalRepeatibleForm(); this.repeatible = geonaFormModel.getFormCardTitle().isInternalRepeatibleForm();
this.maxFormRepeatability = geonaFormModel.getFormCardTitle().getMaxFormRepeatability()!=null?geonaFormModel.getFormCardTitle().getMaxFormRepeatability():Integer.MAX_VALUE;
this.buildCard(geonaFormModel.getMetadataForm()); this.buildCard(geonaFormModel.getMetadataForm());
geonaFormModel.getMetadataForm().addListener(formCardEventHandler); //geonaFormModel.getMetadataForm().addListener(formCardEventHandler);
} }
/** /**
@ -127,8 +132,14 @@ public class MetadataFormCard {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
CreateMetadataForm newForm = new CreateMetadataForm(createMetadataForm.getMetadataProfiles(),appManagerBus);
addNewForm(newForm); if(listForms.size() < maxFormRepeatability) {
CreateMetadataForm newForm = new CreateMetadataForm(createMetadataForm.getMetadataProfiles(),appManagerBus);
//newForm.addListener(formCardEventHandler);
addNewForm(newForm);
}else
Window.alert("Maximun number of data reached for "+geonaFormModel.getFormCardTitle().getTitle());
//newForm.getCreateButton().setFocus(true); //newForm.getCreateButton().setFocus(true);
} }
}); });
@ -162,6 +173,8 @@ public class MetadataFormCard {
} }
}); });
} }
newForm.addListener(formCardEventHandler);
} }
/** /**
@ -190,8 +203,11 @@ public class MetadataFormCard {
*/ */
public boolean validateForm() { public boolean validateForm() {
for (CreateMetadataForm createMetadataForm : listForms) { for (CreateMetadataForm createMetadataForm : listForms) {
if(!createMetadataForm.isFormDataValid()) boolean isFormDataValid = createMetadataForm.isFormDataValid();
GWT.log("Is form data valid: "+isFormDataValid);
if(!isFormDataValid) {
return false; return false;
}
} }
return true; return true;
} }
@ -205,9 +221,11 @@ public class MetadataFormCard {
if(bool) { if(bool) {
tab.setIcon(IconType.OK_SIGN); tab.setIcon(IconType.OK_SIGN);
tab.asWidget().getElement().removeClassName("red-text"); tab.asWidget().getElement().removeClassName("red-text");
tab.asWidget().getElement().addClassName("green-text");
} }
else { else {
tab.setIcon(IconType.MINUS_SIGN); tab.setIcon(IconType.MINUS_SIGN);
tab.asWidget().getElement().removeClassName("green-text");
tab.asWidget().getElement().addClassName("red-text"); tab.asWidget().getElement().addClassName("red-text");
} }
@ -225,6 +243,7 @@ public class MetadataFormCard {
} }
else { else {
tab.setIcon(IconType.MINUS_SIGN); tab.setIcon(IconType.MINUS_SIGN);
tab.asWidget().getElement().removeClassName("red-text");
tab.asWidget().getElement().addClassName("red-text"); tab.asWidget().getElement().addClassName("red-text");
} }
} }

View File

@ -140,13 +140,13 @@ public class ConvertToServiceModel {
} }
List<String> titolareCopyrightLst = mapFields.get("Titolare Copyright"); List<String> titolareCopyrightLst = mapFields.get("Titolare Copyright");
if(titolareCopyrightLst!=null && titolareCopyrightLst.size()>0){ if(titolareCopyrightLst!=null){
concessione.setTitolareCopyright(titolareCopyrightLst.get(0)); concessione.setTitolareCopyright(titolareCopyrightLst);
} }
List<String> titolareLicenzaLst = mapFields.get("Titolare Licenza"); List<String> titolareLicenzaLst = mapFields.get("Titolare Licenza");
if(titolareLicenzaLst!=null && titolareLicenzaLst.size()>0){ if(titolareLicenzaLst!=null){
concessione.setTitolareLicenza(titolareLicenzaLst.get(0)); concessione.setTitolareLicenza(titolareLicenzaLst);
} }
List<String> titolareDatiLst = mapFields.get("Titolare dei dati"); List<String> titolareDatiLst = mapFields.get("Titolare dei dati");
@ -256,6 +256,16 @@ public class ConvertToServiceModel {
//TODO //TODO
} }
List<String> politicaDiAccessoLst = mapFields.get("Politica di accesso");
if(politicaDiAccessoLst!=null && politicaDiAccessoLst.size()>0) {
try {
AccessPolicy ap = AccessPolicy.valueOf(politicaDiAccessoLst.get(0));
uplaodedImage.setPolicy(ap);
}catch (Exception e) {
LOG.warn("I cannot cast "+politicaDiAccessoLst.get(0) +" to "+AccessPolicy.values(),e);
}
}
List<String> licenzaIdList = mapFields.get("ID Licenza"); List<String> licenzaIdList = mapFields.get("ID Licenza");
if(licenzaIdList!=null && licenzaIdList.size()>0) { if(licenzaIdList!=null && licenzaIdList.size()>0) {
uplaodedImage.setLicenseID(licenzaIdList.get(0)); uplaodedImage.setLicenseID(licenzaIdList.get(0));
@ -312,6 +322,11 @@ public class ConvertToServiceModel {
layerConcessione.setScalaAcquisizione(scalaAcquisizioneLst.get(0)); layerConcessione.setScalaAcquisizione(scalaAcquisizioneLst.get(0));
} }
List<String> licenzaIdList = mapFields.get("ID Licenza");
if(licenzaIdList!=null && licenzaIdList.size()>0) {
layerConcessione.setLicenseID(licenzaIdList.get(0));
}
List<String> autoreLst = mapFields.get("Autore"); List<String> autoreLst = mapFields.get("Autore");
if(autoreLst!=null) { if(autoreLst!=null) {
layerConcessione.setAuthors(autoreLst); layerConcessione.setAuthors(autoreLst);

View File

@ -17,6 +17,8 @@ import org.gcube.application.geoportal.model.content.WorkspaceContent;
import org.gcube.application.geoportal.model.fault.PublishException; import org.gcube.application.geoportal.model.fault.PublishException;
import org.gcube.application.geoportal.model.fault.ValidationException; import org.gcube.application.geoportal.model.fault.ValidationException;
import org.gcube.application.geoportal.utils.Serialization; import org.gcube.application.geoportal.utils.Serialization;
import org.gcube.application.geoportalcommon.GeoportalCommon;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
@ -33,19 +35,29 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/** /**
* The server side implementation of the RPC service. * The server side implementation of the RPC service.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Dec 1, 2020
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implements GeoportalDataEntryService { public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implements GeoportalDataEntryService {
public static final String GEONA_GENERIC_RESOURCE_SECONDARY_TYPE = "GEONA_GENERIC_RESOURCE_SECONDARY_TYPE"; public static final String GEONA_GENERIC_RESOURCE_SECONDARY_TYPE = "GEONA_GENERIC_RESOURCE_SECONDARY_TYPE";
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataEntryServiceImpl.class); private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataEntryServiceImpl.class);
/**
* Save geona data forms.
*
* @param listGeonaFormObjects the list geona form objects
* @return the commit report
* @throws Exception the exception
*/
@Override @Override
public CommitReport saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception { public CommitReport saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception {
LOG.info("saveGeonaDataForms called"); LOG.info("saveGeonaDataForms called");
HashMap<ConcessioniFormCardTitle, List<GeoNaFormDataObject>> toMap = HashMap<ConcessioniFormCardTitle, List<GeoNaFormDataObject>> toMap = new HashMap<ConcessioniFormCardTitle, List<GeoNaFormDataObject>>();
new HashMap<ConcessioniFormCardTitle, List<GeoNaFormDataObject>>();
for (GeoNaFormDataObject geoNaFormDataObject : listGeonaFormObjects) { for (GeoNaFormDataObject geoNaFormDataObject : listGeonaFormObjects) {
@ -59,150 +71,158 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
listForm.add(geoNaFormDataObject); listForm.add(geoNaFormDataObject);
toMap.put(theType, listForm); toMap.put(theType, listForm);
} }
if(LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
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());
ConcessioneManager manager; ConcessioneManager manager;
try { try {
//Saving Data // Saving Data
//Informazioni di Progetto // Informazioni di Progetto
List<GeoNaFormDataObject> list = toMap.get(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO); List<GeoNaFormDataObject> list = toMap.get(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO);
if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null) if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null)
throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getTitle()); throw new Exception(
"Error: no data found for " + ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getTitle());
List<GenericDatasetBean> listGDB = list.get(0).getListGDB(); List<GenericDatasetBean> listGDB = list.get(0).getListGDB();
GenericDatasetBean idp = listGDB.get(0); GenericDatasetBean idp = listGDB.get(0);
LOG.debug("\n\n"); LOG.debug("\n\n");
LOG.debug(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO+" building with client obj: "+idp); LOG.debug(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO + " building with client obj: " + idp);
Concessione concessione = ConvertToServiceModel.toConcessione(idp, user); Concessione concessione = ConvertToServiceModel.toConcessione(idp, user);
LOG.debug("Built "+ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO+" as server obj: "+concessione); LOG.debug("Built " + ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO + " as server obj: " + concessione);
//saving into back-end // saving into back-end
manager = ManagerFactory.registerNew(concessione); manager = ManagerFactory.registerNew(concessione);
//RELAZIONE_DI_SCAVO // RELAZIONE_DI_SCAVO
list = toMap.get(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO); list = toMap.get(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO);
if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null) if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null)
throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getTitle()); throw new Exception(
"Error: no data found for " + ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getTitle());
listGDB = list.get(0).getListGDB(); listGDB = list.get(0).getListGDB();
GenericDatasetBean rds = listGDB.get(0); GenericDatasetBean rds = listGDB.get(0);
LOG.debug("\n\n"); LOG.debug("\n\n");
LOG.debug(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO+" building with client obj: "+rds); LOG.debug(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " building with client obj: " + rds);
RelazioneScavo relazioneDiScavo = ConvertToServiceModel.toRelazioneScavo(rds); RelazioneScavo relazioneDiScavo = ConvertToServiceModel.toRelazioneScavo(rds);
LOG.debug("Built "+ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO+" as server obj: "+relazioneDiScavo); LOG.debug("Built " + ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " as server obj: " + relazioneDiScavo);
//Should be only one // Should be only one
for (FileUploaded fileUploaded : rds.getFilesUploaded()) { for (FileUploaded fileUploaded : rds.getFilesUploaded()) {
FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath()); FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath());
InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName()); InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName());
//saving into back-end // saving into back-end
manager.setRelazioneScavo(relazioneDiScavo, isd); manager.setRelazioneScavo(relazioneDiScavo, isd);
} }
// IMMAGINI_RAPPRESENTATIVE
//IMMAGINI_RAPPRESENTATIVE
list = toMap.get(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE); list = toMap.get(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE);
if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null) if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null)
throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getTitle()); throw new Exception(
"Error: no data found for " + ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getTitle());
List<GenericDatasetBean> imgRaprsLst = list.get(0).getListGDB(); List<GenericDatasetBean> imgRaprsLst = list.get(0).getListGDB();
for (GenericDatasetBean imgRapr : imgRaprsLst) { for (GenericDatasetBean imgRapr : imgRaprsLst) {
LOG.debug("\n\n"); LOG.debug("\n\n");
LOG.debug(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE+" building with client obj: "+imgRapr); LOG.debug(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE + " building with client obj: " + imgRapr);
UploadedImage img = ConvertToServiceModel.toImmaginiRappresentative(imgRapr); UploadedImage img = ConvertToServiceModel.toImmaginiRappresentative(imgRapr);
LOG.debug("Built "+ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE+" as server obj: "+img); LOG.debug("Built " + ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE + " as server obj: " + img);
for (FileUploaded fileUploaded : imgRapr.getFilesUploaded()) { for (FileUploaded fileUploaded : imgRapr.getFilesUploaded()) {
LOG.debug("Adding uploaded file: "+fileUploaded.getFileName() + " to "+img); LOG.debug("Adding uploaded file: " + fileUploaded.getFileName() + " to " + img);
FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath()); FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath());
InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName()); InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName());
//saving into back-end // saving into back-end
manager.addImmagineRappresentativa(img,isd); manager.addImmagineRappresentativa(img, isd);
} }
} }
//POSIZIONAMENTO_DELL_AREA_DI_INDAGINE // POSIZIONAMENTO_DELL_AREA_DI_INDAGINE
list = toMap.get(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE); list = toMap.get(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE);
if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null) if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null)
throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getTitle()); throw new Exception("Error: no data found for "
+ ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getTitle());
listGDB = list.get(0).getListGDB(); listGDB = list.get(0).getListGDB();
GenericDatasetBean pad = listGDB.get(0); GenericDatasetBean pad = listGDB.get(0);
LOG.debug("\n\n"); LOG.debug("\n\n");
LOG.debug(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE+" building with client obj: "+pad); LOG.debug(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " building with client obj: "
+ pad);
LayerConcessione layerPad = ConvertToServiceModel.toLayerConcessione(pad); LayerConcessione layerPad = ConvertToServiceModel.toLayerConcessione(pad);
LOG.debug("Built "+ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE+" as server obj: "+layerPad); LOG.debug("Built " + ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " as server obj: "
+ layerPad);
for (FileUploaded fileUploaded : pad.getFilesUploaded()) { for (FileUploaded fileUploaded : pad.getFilesUploaded()) {
LOG.debug("Adding uploaded file: "+fileUploaded.getFileName() + " to "+layerPad); LOG.debug("Adding uploaded file: " + fileUploaded.getFileName() + " to " + layerPad);
FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath()); FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath());
InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName()); InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName());
//saving into back-end // saving into back-end
manager.setPosizionamento(layerPad, isd); manager.setPosizionamento(layerPad, isd);
} }
//PIANTA_DI_FINE_SCAVO // PIANTA_DI_FINE_SCAVO
list = toMap.get(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO); list = toMap.get(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO);
if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null) if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null)
throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getTitle()); throw new Exception(
"Error: no data found for " + ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getTitle());
listGDB = list.get(0).getListGDB(); listGDB = list.get(0).getListGDB();
GenericDatasetBean pfs = listGDB.get(0); GenericDatasetBean pfs = listGDB.get(0);
LOG.debug("\n\n"); LOG.debug("\n\n");
LOG.debug(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO+" building with client obj: "+pfs); LOG.debug(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO + " building with client obj: " + pfs);
LayerConcessione layerPfs = ConvertToServiceModel.toLayerConcessione(pfs); LayerConcessione layerPfs = ConvertToServiceModel.toLayerConcessione(pfs);
LOG.debug("Built "+ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO+" as server obj: "+layerPfs); LOG.debug("Built " + ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO + " as server obj: " + layerPfs);
for (FileUploaded fileUploaded : pfs.getFilesUploaded()) { for (FileUploaded fileUploaded : pfs.getFilesUploaded()) {
LOG.debug("Adding uploaded file: "+fileUploaded.getFileName() + " to "+layerPfs); LOG.debug("Adding uploaded file: " + fileUploaded.getFileName() + " to " + layerPfs);
FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath()); FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath());
InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName()); InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName());
//saving into back-end // saving into back-end
manager.addPiantaFineScavo(layerPfs, isd); manager.addPiantaFineScavo(layerPfs, isd);
} }
}catch (Exception e) { } catch (Exception e) {
LOG.error("Error on converting form data: ",e); LOG.error("Error on converting form data: ", e);
throw new Exception("Error occurred on saving data, try again or contact the support. Error: "+e.getMessage()); throw new Exception(
"Error occurred on saving data, try again or contact the support. Error: " + e.getMessage());
} }
try { try {
//If true -> data are published into the SDI // If true -> data are published into the SDI
Boolean publish=true; Boolean publish = true;
Concessione registered=manager.commit(publish); Concessione registered = manager.commit(publish);
LOG.info("Registered: "+registered); LOG.info("Registered: " + registered);
String link = null; String link = null;
try { try {
link = ((WorkspaceContent)registered.getRelazioneScavo().getActualContent().get(0)).getLink(); link = ((WorkspaceContent) registered.getRelazioneScavo().getActualContent().get(0)).getLink();
}catch (Exception e) { } catch (Exception e) {
LOG.warn("Not able to check public link ",e); LOG.warn("Not able to check public link ", e);
} }
//String link = "toTest"; // String link = "toTest";
CommitReport cRep = new CommitReport(); CommitReport cRep = new CommitReport();
cRep.setRecordId(registered.getId()); cRep.setRecordId(registered.getId());
if(link!=null) { if (link != null) {
cRep.setState(STATE.OK); cRep.setState(STATE.OK);
cRep.setMsg("Project saved successfully"); cRep.setMsg("Project saved successfully");
} } else {
else {
cRep.setState(STATE.WARN); cRep.setState(STATE.WARN);
cRep.setMsg("Project saved with errors"); cRep.setMsg("Project saved with errors");
} }
return cRep; return cRep;
}catch (ValidationException e1){ } catch (ValidationException e1) {
LOG.error("Error on validating data: ",e1); LOG.error("Error on validating data: ", e1);
throw new Exception("Error on validating data: "+Serialization.prettyPrint(e1.getReport())); throw new Exception("Error on validating data: " + Serialization.prettyPrint(e1.getReport()));
}catch (PublishException e2) { } catch (PublishException e2) {
LOG.error("Error on publishing data: ",e2); LOG.error("Error on publishing data: ", e2);
throw new Exception("Error on publishing data: "+e2.getMessage()); throw new Exception("Error on publishing data: " + e2.getMessage());
}catch (Exception e) { } catch (Exception e) {
LOG.error("Error on commiting data: ",e); LOG.error("Error on commiting data: ", e);
throw new Exception("Error occurred on saving data, try again or contact the support. Error: "+e.getMessage()); throw new Exception(
}finally { "Error occurred on saving data, try again or contact the support. Error: " + e.getMessage());
} finally {
// if(manager!=null) { // if(manager!=null) {
// try { // try {
// manager.shutdown(); // manager.shutdown();
@ -212,12 +232,18 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
// //
// } // }
} }
} }
/**
* Gets the geona init config.
*
* @return the geona init config
*/
@Override @Override
public GeonaISConfig getGeonaInitConfig() { public GeonaISConfig getGeonaInitConfig() {
LOG.info("getConfig called"); LOG.info("getConfig called");
String scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), false); String scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), false);
String theSecondaryType; String theSecondaryType;
try { try {
@ -229,31 +255,54 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
// LOG.warn("\n\n\nHARD-CABLING THE SCOPE, PLEASE REMOTE IT!!!!\n\n\n"); // LOG.warn("\n\n\nHARD-CABLING THE SCOPE, PLEASE REMOTE IT!!!!\n\n\n");
// scope = "/gcube/devsec/devVRE"; // scope = "/gcube/devsec/devVRE";
GeonaISConfig configs = new GeonaISConfig(theSecondaryType, scope); GeonaISConfig configs = new GeonaISConfig(theSecondaryType, scope);
LOG.info("returning config: "+configs); LOG.info("returning config: " + configs);
return configs; return configs;
} }
/**
* Gets the links for.
*
* @param itemId the item id
* @param recordType the record type
* @return the links for
* @throws Exception the exception
*/
@Override
public GeoNaItemRef getLinksFor(Long itemId, String recordType) throws Exception {
LOG.info("getLinksFor called");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoportalCommon gc = new GeoportalCommon();
GeoNaItemRef item = new GeoNaItemRef(itemId, recordType);
item = gc.getPublicLinksFor(item);
LOG.info("Returning: " + item);
return item;
}
/**
* Pretty print client data entry map.
*
* @param toMap the to map
*/
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"); LOG.debug("\n\n");
LOG.debug(theType.toString()); 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");
int i = 0; int i = 0;
for (GenericDatasetBean gbd : geoNaFormDataObject.getListGDB()) { for (GenericDatasetBean gbd : geoNaFormDataObject.getListGDB()) {
LOG.debug("\t "+ ++i +") "+GenericDatasetBean.class.getSimpleName()+" entries:"); LOG.debug("\t " + ++i + ") " + GenericDatasetBean.class.getSimpleName() + " entries:");
Map<String, List<String>> map = gbd.getFormDataEntryFields(); Map<String, List<String>> map = gbd.getFormDataEntryFields();
for (String keyEntry : map.keySet()) { for (String keyEntry : map.keySet()) {
LOG.debug("\t "+keyEntry + ": "+map.get(keyEntry)); LOG.debug("\t " + keyEntry + ": " + map.get(keyEntry));
} }
for (FileUploaded fup : gbd.getFilesUploaded()) { for (FileUploaded fup : gbd.getFilesUploaded()) {
LOG.debug("\t "+fup); LOG.debug("\t " + fup);
} }
} }
} }

View File

@ -8,53 +8,54 @@ import java.io.Serializable;
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Oct 21, 2020 * Nov 30, 2020
*/ */
public class CommitReport implements Serializable{ public class CommitReport implements Serializable {
/** /**
* *
*/ */
private static final long serialVersionUID = -9519707669761939L; private static final long serialVersionUID = -9519707669761939L;
/** /**
* The Enum STATE. * The Enum STATE.
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Oct 21, 2020 * Oct 21, 2020
*/ */
public enum STATE{ERROR, WARN, OK, UNKNOWN} public enum STATE {
ERROR, WARN, OK, UNKNOWN
}
public STATE state = STATE.UNKNOWN; public STATE state = STATE.UNKNOWN;
public long recordId; public long recordId;
public String msg; public String msg;
public String report;
/** /**
* Instantiates a new commit report. * Instantiates a new commit report.
*/ */
public CommitReport() { public CommitReport() {
} }
/** /**
* Instantiates a new commit report. * Instantiates a new commit report.
* *
* @param state the state * @param state the state
* @param recordId the record id * @param recordId the record id
* @param msg the msg * @param msg the msg
* @param report the report
*/ */
public CommitReport(STATE state, long recordId, String msg) { public CommitReport(STATE state, long recordId, String msg, String report) {
super(); super();
this.state = state; this.state = state;
this.recordId = recordId; this.recordId = recordId;
this.msg = msg; this.msg = msg;
this.report = report;
} }
/** /**
* Gets the state. * Gets the state.
* *
@ -82,6 +83,24 @@ public class CommitReport implements Serializable{
return recordId; return recordId;
} }
/**
* Gets the report.
*
* @return the report
*/
public String getReport() {
return report;
}
/**
* Sets the report.
*
* @param report the new report
*/
public void setReport(String report) {
this.report = report;
}
/** /**
* Sets the record id. * Sets the record id.
* *
@ -109,10 +128,10 @@ public class CommitReport implements Serializable{
this.msg = msg; this.msg = msg;
} }
/**
* To string.
/* (non-Javadoc) *
* @see java.lang.Object#toString() * @return the string
*/ */
@Override @Override
public String toString() { public String toString() {
@ -123,8 +142,11 @@ public class CommitReport implements Serializable{
builder.append(recordId); builder.append(recordId);
builder.append(", msg="); builder.append(", msg=");
builder.append(msg); builder.append(msg);
builder.append(", report=");
builder.append(report);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -1,29 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module rename-to='GeoPortalDataEntryApp'> <module rename-to='GeoPortalDataEntryApp'>
<!-- Inherit the core Web Toolkit stuff. --> <!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' /> <inherits name='com.google.gwt.user.User' />
<!-- 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.github.gwtbootstrap.Bootstrap" />
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits --> <inherits name="com.google.gwt.json.JSON" />
<!-- Specify the app entry point class. --> <inherits
<entry-point class='org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp' /> name='org.gcube.portlets.widgets.mpformbuilder.MetadataProfileFormBuilder' />
<!-- Specify the paths for translatable code --> <inherits name='org.gcube.application.geoportalcommon.GeoportalDataCommon' />
<source path='client' />
<source path='shared' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point
class='org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
</module> </module>