integration completed, new UI interactions added

This commit is contained in:
francesco 2020-10-20 09:58:56 +02:00
parent 3533c69d96
commit 28b78c8f04
12 changed files with 306 additions and 40 deletions

View File

@ -7,16 +7,25 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.TreeMap; import java.util.TreeMap;
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.SaveGeonaDataFormsEvent;
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsHandler;
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaDataEntryMainForm; import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaDataEntryMainForm;
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainPanel; import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainPanel;
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel; import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
import org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderServiceAsync; import org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderServiceAsync;
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm; import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.Modal;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
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.shared.HandlerManager; import com.google.gwt.event.shared.HandlerManager;
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.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
@ -38,10 +47,16 @@ public class GeoPortalDataEntryApp implements EntryPoint {
*/ */
private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class); private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
private final HandlerManager eventBus = new HandlerManager(null); private final HandlerManager appManagerBus = new HandlerManager(null);
private LinkedHashMap<String, GeoNaFormCardModel> mapForms = new LinkedHashMap<String, GeoNaFormCardModel>(); private LinkedHashMap<String, GeoNaFormCardModel> mapForms = new LinkedHashMap<String, GeoNaFormCardModel>();
private GeonaDataEntryMainForm geoNaMainForm;
private Collection<GeoNaFormCardModel> orderedCards;
private GeonaMainPanel mainPanel;
//private List<MetaDataProfileBean> orderedListMetadataProfilesForGeona = null; //private List<MetaDataProfileBean> orderedListMetadataProfilesForGeona = null;
/** /**
@ -52,20 +67,21 @@ public class GeoPortalDataEntryApp implements EntryPoint {
String scope = "/gcube/devsec/devVRE"; String scope = "/gcube/devsec/devVRE";
String secondaryType = "GeoNaMetadata"; String secondaryType = "GeoNaMetadata";
final GeonaMainPanel mainPanel = new GeonaMainPanel(); mainPanel = new GeonaMainPanel(appManagerBus);
mainPanel.setLoaderVisible("Loading...", true); mainPanel.setLoaderVisible("Loading...", true);
final GeonaDataEntryMainForm geoNaMainForm = new GeonaDataEntryMainForm(); geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScope(scope, secondaryType, new AsyncCallback<List<MetaDataProfileBean>>() { MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScope(scope, secondaryType, new AsyncCallback<List<MetaDataProfileBean>>() {
@Override @Override
public void onSuccess(List<MetaDataProfileBean> result) { public void onSuccess(List<MetaDataProfileBean> result) {
Collection<GeoNaFormCardModel> orderedCards = setGeoNaFormsOrder(result); orderedCards = setGeoNaFormsOrder(result);
//ordered values //ordered values
for (GeoNaFormCardModel geonaForm : orderedCards) { buildNewCards(orderedCards);
CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean())); /*for (GeoNaFormCardModel geonaForm : orderedCards) {
CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()),appManagerBus);
geonaForm.setMetadataForm(baseForm); geonaForm.setMetadataForm(baseForm);
String key = geonaForm.getMetadataProfileBean().getType(); String key = geonaForm.getMetadataProfileBean().getType();
if(geonaForm.getFormCardTitle()!=null) { if(geonaForm.getFormCardTitle()!=null) {
@ -74,7 +90,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
geoNaMainForm.addForm(key, geonaForm); geoNaMainForm.addForm(key, geonaForm);
mapForms.put(key, geonaForm); mapForms.put(key, geonaForm);
} }
mainPanel.setLoaderVisible("", false); mainPanel.setLoaderVisible("", false);*/
} }
@Override @Override
@ -82,13 +98,34 @@ public class GeoPortalDataEntryApp implements EntryPoint {
} }
}); });
bindEvents();
mainPanel.addFormPanel(geoNaMainForm); mainPanel.addFormPanel(geoNaMainForm);
//
RootPanel.get(DIV_PORTLET_ID).add(mainPanel); RootPanel.get(DIV_PORTLET_ID).add(mainPanel);
} }
private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards) {
mainPanel.setLoaderVisible("Loading...", true);
resetUI();
//ordered values
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);
}
private void resetUI() {
geoNaMainForm.reset();
mapForms.clear();
}
private Collection<GeoNaFormCardModel> setGeoNaFormsOrder(List<MetaDataProfileBean> listMetadataProfilesForGeona) { private Collection<GeoNaFormCardModel> setGeoNaFormsOrder(List<MetaDataProfileBean> listMetadataProfilesForGeona) {
TreeMap<Integer, GeoNaFormCardModel> treemapOrderedGeoNaProfiles = new TreeMap<Integer, GeoNaFormCardModel>(); TreeMap<Integer, GeoNaFormCardModel> treemapOrderedGeoNaProfiles = new TreeMap<Integer, GeoNaFormCardModel>();
@ -133,4 +170,66 @@ public class GeoPortalDataEntryApp implements EntryPoint {
} }
private void bindEvents() {
appManagerBus.addHandler(SaveGeonaDataFormsEvent.TYPE, new SaveGeonaDataFormsHandler() {
@Override
public void onSave(SaveGeonaDataFormsEvent saveGeonaDataFormsEvent) {
if(saveGeonaDataFormsEvent.getListGeonaDataForms()!=null) {
final Modal modal = new Modal(true);
modal.setCloseVisible(false);
final LoaderIcon loader = new LoaderIcon();
loader.setText("Trying to save the data, please wait...");
modal.add(loader);
GreetingServiceAsync.Util.getInstance().saveGeonaDataForms(saveGeonaDataFormsEvent.getListGeonaDataForms(), new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
modal.remove(loader);
Alert alert = new Alert(caught.getMessage());
alert.setType(AlertType.ERROR);
alert.setClose(false);
modal.add(alert);
modal.setCloseVisible(true);
resetUI();
}
@Override
public void onSuccess(String result) {
modal.remove(loader);
Alert alert = new Alert(result);
alert.setType(AlertType.INFO);
alert.setClose(false);
modal.add(alert);
modal.setCloseVisible(true);
resetUI();
}
});
}
}
});
appManagerBus.addHandler(CreateNewProjectEvent.TYPE, new CreateNewProjectEventHandler() {
@Override
public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) {
//means the form was not submitted
if(mapForms.size()>0) {
boolean confirm = Window.confirm("The data are not saved and will be lost, Confirm?");
if(confirm)
buildNewCards(orderedCards);
}else
buildNewCards(orderedCards);
}
});
}
} }

View File

@ -1,5 +1,9 @@
package org.gcube.portlets.user.geoportaldataentry.client; package org.gcube.portlets.user.geoportaldataentry.client;
import java.util.List;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -8,5 +12,6 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
*/ */
@RemoteServiceRelativePath("greet") @RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService { public interface GreetingService extends RemoteService {
String greetServer(String name) throws IllegalArgumentException;
String saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception;
} }

View File

@ -1,18 +1,15 @@
package org.gcube.portlets.user.geoportaldataentry.client; package org.gcube.portlets.user.geoportaldataentry.client;
import java.util.List;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
public interface GreetingServiceAsync public interface GreetingServiceAsync
{ {
/**
* GWT-RPC service asynchronous (client-side) interface
* @see org.gcube.portlets.user.geoportaldataentry.client.GreetingService
*/
void greetServer( java.lang.String name, AsyncCallback<java.lang.String> callback );
/** /**
* Utility class to get the RPC Async interface from client-side code * Utility class to get the RPC Async interface from client-side code
*/ */
@ -34,4 +31,7 @@ public interface GreetingServiceAsync
// Utility class should not be instantiated // Utility class should not be instantiated
} }
} }
void saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects, AsyncCallback<String> callback);
} }

View File

@ -0,0 +1,63 @@
package org.gcube.portlets.user.geoportaldataentry.client.events;
import java.util.List;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import com.google.gwt.event.shared.GwtEvent;
// TODO: Auto-generated Javadoc
/**
* The Class SaveGeonaDataFormsEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 20, 2020
*/
public class SaveGeonaDataFormsEvent extends GwtEvent<SaveGeonaDataFormsHandler> {
/** The type. */
public static Type<SaveGeonaDataFormsHandler> TYPE = new Type<SaveGeonaDataFormsHandler>();
private List<GeoNaFormDataObject> listGeonaDataForms;
/**
* Instantiates a new save geona data forms event.
*
* @param listGeonaDataForms the list geona data forms
*/
public SaveGeonaDataFormsEvent(List<GeoNaFormDataObject> listGeonaDataForms) {
this.listGeonaDataForms = listGeonaDataForms;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/
@Override
public Type<SaveGeonaDataFormsHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
*/
@Override
protected void dispatch(SaveGeonaDataFormsHandler handler) {
handler.onSave(this);
}
public List<GeoNaFormDataObject> getListGeonaDataForms() {
return listGeonaDataForms;
}
}

View File

@ -0,0 +1,22 @@
package org.gcube.portlets.user.geoportaldataentry.client.events;
import com.google.gwt.event.shared.EventHandler;
// TODO: Auto-generated Javadoc
/**
* The Interface SaveGeonaDataFormsHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 20, 2020
*/
public interface SaveGeonaDataFormsHandler extends EventHandler {
/**
* On save.
*
* @param saveGeonaDataFormsEvent the save geona data forms event
*/
void onSave(SaveGeonaDataFormsEvent saveGeonaDataFormsEvent);
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent;
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel; import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.MetadataFormCard; import org.gcube.portlets.user.geoportaldataentry.client.ui.card.MetadataFormCard;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
@ -16,6 +17,7 @@ import com.github.gwtbootstrap.client.ui.TabPanel;
import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.AlertType;
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.dom.client.ClickEvent;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder; 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;
@ -47,8 +49,11 @@ public class GeonaDataEntryMainForm extends Composite {
private List<Tab> listTabs = new ArrayList<Tab>(); private List<Tab> listTabs = new ArrayList<Tab>();
public GeonaDataEntryMainForm() { private HandlerManager appManagerBus;
public GeonaDataEntryMainForm(HandlerManager appManagerBus) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.appManagerBus = appManagerBus;
} }
public void addForm(String tabHeading, GeoNaFormCardModel geonFormModel){ public void addForm(String tabHeading, GeoNaFormCardModel geonFormModel){
@ -61,7 +66,7 @@ public class GeonaDataEntryMainForm extends Composite {
final Tab tab = new Tab(); final Tab tab = new Tab();
tab.setHeading(tabHeading); tab.setHeading(tabHeading);
//MetadataFormCard mfc = new MetadataFormCard(tab, createMetadataForm, repeatible); //MetadataFormCard mfc = new MetadataFormCard(tab, createMetadataForm, repeatible);
MetadataFormCard mfc = new MetadataFormCard(tab,geonFormModel); MetadataFormCard mfc = new MetadataFormCard(tab,geonFormModel,appManagerBus);
listTabs.add(tab); listTabs.add(tab);
mainTabPanel.add(tab); mainTabPanel.add(tab);
@ -73,6 +78,12 @@ public class GeonaDataEntryMainForm extends Composite {
mapForms.put(tabHeading, mfc); mapForms.put(tabHeading, mfc);
} }
public void reset() {
mapForms.clear();
mainTabPanel.clear();
listTabs.clear();
}
public void selectTab(int index){ public void selectTab(int index){
@ -97,7 +108,7 @@ public class GeonaDataEntryMainForm extends Composite {
canSave = false; canSave = false;
} }
List<GeoNaFormDataObject> listGoneFormObjects = new ArrayList<GeoNaFormDataObject>(); List<GeoNaFormDataObject> listGeonaFormObjects = new ArrayList<GeoNaFormDataObject>();
if(canSave) { if(canSave) {
for (String metadataType : mapForms.keySet()) { for (String metadataType : mapForms.keySet()) {
@ -107,14 +118,15 @@ public class GeonaDataEntryMainForm extends Composite {
listGDB.add(form.getFormDataBean()); listGDB.add(form.getFormDataBean());
} }
listGoneFormObjects.add(new GeoNaFormDataObject(listGDB, card.getGeonaFormModel().getFormCardTitle())); listGeonaFormObjects.add(new GeoNaFormDataObject(listGDB, card.getGeonaFormModel().getFormCardTitle()));
} }
appManagerBus.fireEvent(new SaveGeonaDataFormsEvent(listGeonaFormObjects));
}else { }else {
showAlertOnSaveAction("Detected errors, please fix it/them", AlertType.ERROR, true); showAlertOnSaveAction("Detected errors, please fix it/them", AlertType.ERROR, true);
} }
Window.alert("I can save: "+listGoneFormObjects); Window.alert("I can save: "+listGeonaFormObjects);
} }

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder; 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.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
@ -27,6 +28,11 @@ public class GeonaMainPanel extends Composite {
@UiField @UiField
LoaderIcon loader; LoaderIcon loader;
@UiField
GeonaNavigationBar geonaNavigationBar;
private HandlerManager appManagerBus;
/** The ui binder. */ /** The ui binder. */
private static GeonaMainPanelUiBinder uiBinder = GWT.create(GeonaMainPanelUiBinder.class); private static GeonaMainPanelUiBinder uiBinder = GWT.create(GeonaMainPanelUiBinder.class);
@ -42,9 +48,12 @@ public class GeonaMainPanel extends Composite {
/** /**
* Instantiates a new geona main panel. * Instantiates a new geona main panel.
* @param appManagerBus
*/ */
public GeonaMainPanel() { public GeonaMainPanel(HandlerManager appManagerBus) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.appManagerBus = appManagerBus;
geonaNavigationBar.setAppManagerBus(appManagerBus);
} }
/** /**

View File

@ -20,7 +20,7 @@
<g:HTMLPanel ui:field="geonaMainPanel"> <g:HTMLPanel ui:field="geonaMainPanel">
<b:PageHeader subtext="data entry facility" <b:PageHeader subtext="data entry facility"
styleName="{style.custom-page-header}">GeoNa</b:PageHeader> styleName="{style.custom-page-header}">GeoNa</b:PageHeader>
<m:GeonaNavigationBar></m:GeonaNavigationBar> <m:GeonaNavigationBar ui:field="geonaNavigationBar"></m:GeonaNavigationBar>
<r:LoaderIcon ui:field="loader"></r:LoaderIcon> <r:LoaderIcon ui:field="loader"></r:LoaderIcon>
<g:HTMLPanel ui:field="geonaMainFormPanel"></g:HTMLPanel> <g:HTMLPanel ui:field="geonaMainFormPanel"></g:HTMLPanel>
</g:HTMLPanel> </g:HTMLPanel>

View File

@ -1,13 +1,15 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui; package org.gcube.portlets.user.geoportaldataentry.client.ui;
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent;
import com.github.gwtbootstrap.client.ui.NavLink; import com.github.gwtbootstrap.client.ui.NavLink;
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.dom.client.ClickEvent;
import com.google.gwt.event.shared.EventBus; import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder; 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.Window;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
@ -24,12 +26,6 @@ public class GeonaNavigationBar extends Composite {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
} }
public GeonaNavigationBar(EventBus eventBus) {
this();
this.eventBus = eventBus;
bindEvents();
}
private void bindEvents() { private void bindEvents() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -38,13 +34,25 @@ public class GeonaNavigationBar extends Composite {
@UiField @UiField
NavLink linkCreateNewProject; NavLink linkCreateNewProject;
private HandlerManager appManagerBus;
public GeonaNavigationBar(String firstName) { public GeonaNavigationBar(String firstName) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
} }
@UiHandler("linkCreateNewProject") @UiHandler("linkCreateNewProject")
void onClick(ClickEvent e) { void onClick(ClickEvent e) {
Window.alert("Hello!"); appManagerBus.fireEvent(new CreateNewProjectEvent());
}
/**
* Sets the app manager bus.
*
* @param appManagerBus the new app manager bus
*/
public void setAppManagerBus(HandlerManager appManagerBus) {
this.appManagerBus = appManagerBus;
} }
} }

View File

@ -12,6 +12,7 @@ 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.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;
/** /**
@ -41,6 +42,8 @@ public class MetadataFormCard {
/** The geona form model. */ /** The geona form model. */
private GeoNaFormCardModel geonaFormModel; private GeoNaFormCardModel geonaFormModel;
private HandlerManager appManagerBus;
/** /**
* The Class MetadataFormCardEventHandler. * The Class MetadataFormCardEventHandler.
* *
@ -98,10 +101,12 @@ public class MetadataFormCard {
* *
* @param tab the tab * @param tab the tab
* @param geonaFormModel the geona form model * @param geonaFormModel the geona form model
* @param appManagerBus the app manager bus
*/ */
public MetadataFormCard(Tab tab, GeoNaFormCardModel geonaFormModel) { public MetadataFormCard(Tab tab, GeoNaFormCardModel geonaFormModel, HandlerManager appManagerBus) {
this.tab = tab; this.tab = tab;
this.geonaFormModel = geonaFormModel; this.geonaFormModel = geonaFormModel;
this.appManagerBus = appManagerBus;
this.repeatible = geonaFormModel.getFormCardTitle().isInternalRepeatibleForm(); this.repeatible = geonaFormModel.getFormCardTitle().isInternalRepeatibleForm();
this.buildCard(geonaFormModel.getMetadataForm()); this.buildCard(geonaFormModel.getMetadataForm());
geonaFormModel.getMetadataForm().addListener(formCardEventHandler); geonaFormModel.getMetadataForm().addListener(formCardEventHandler);
@ -122,7 +127,7 @@ public class MetadataFormCard {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
CreateMetadataForm newForm = new CreateMetadataForm(createMetadataForm.getMetadataProfiles()); CreateMetadataForm newForm = new CreateMetadataForm(createMetadataForm.getMetadataProfiles(),appManagerBus);
addNewForm(newForm); addNewForm(newForm);
//newForm.getCreateButton().setFocus(true); //newForm.getCreateButton().setFocus(true);
} }

View File

@ -8,13 +8,12 @@ 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.RelazioneScavo; import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
import org.gcube.application.geoportal.model.content.UploadedImage; import org.gcube.application.geoportal.model.content.UploadedImage;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp;
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -102,7 +101,7 @@ public class ConvertToServiceModel {
concessione.setFontiFinanziamento(fontiFinanziamento); concessione.setFontiFinanziamento(fontiFinanziamento);
} }
List<String> licenzaLst = mapFields.get("Licenza"); List<String> licenzaLst = mapFields.get("ID Licenza");
if(licenzaLst!=null && licenzaLst.size()>0) { if(licenzaLst!=null && licenzaLst.size()>0) {
//TODO FABIO //TODO FABIO
//concessione.setLicenza() //concessione.setLicenza()
@ -183,7 +182,7 @@ public class ConvertToServiceModel {
} }
List<String> licenzaIdList = mapFields.get("Licenza"); List<String> licenzaIdList = mapFields.get("ID Licenza");
if(licenzaIdList!=null && licenzaIdList.size()>0) { if(licenzaIdList!=null && licenzaIdList.size()>0) {
relazioneScavo.setLicenseID(licenzaIdList.get(0)); relazioneScavo.setLicenseID(licenzaIdList.get(0));
} }
@ -230,6 +229,41 @@ public class ConvertToServiceModel {
return uplaodedImage; return uplaodedImage;
} }
public static LayerConcessione toLayerConcessione(GenericDatasetBean gdb){
Map<String, List<String>> mapFields = gdb.getFormDataEntryFields();
LayerConcessione layerConcessione = new LayerConcessione();
List<String> titoloLst = mapFields.get("Titolo");
if(titoloLst!=null && titoloLst.size()>0) {
layerConcessione.setTitolo(titoloLst.get(0));
}
List<String> valutazioneQualitaLst = mapFields.get("Valutazione della qualità");
if(valutazioneQualitaLst!=null && valutazioneQualitaLst.size()>0) {
layerConcessione.setValutazioneQualita(valutazioneQualitaLst.get(0));
}
List<String> metodoRaccoltaDatiLst = mapFields.get("Metodo di raccolta dei dati");
if(metodoRaccoltaDatiLst!=null && metodoRaccoltaDatiLst.size()>0) {
layerConcessione.setMetodoRaccoltaDati(metodoRaccoltaDatiLst.get(0));
}
List<String> scalaAcquisizioneLst = mapFields.get("Scala di acquisizione dei dati");
if(scalaAcquisizioneLst!=null && scalaAcquisizioneLst.size()>0) {
layerConcessione.setScalaAcquisizione(scalaAcquisizioneLst.get(0));
}
List<String> autoreLst = mapFields.get("Autore");
if(autoreLst!=null) {
layerConcessione.setAuthors(autoreLst);
}
return layerConcessione;
}

View File

@ -1,7 +1,10 @@
package org.gcube.portlets.user.geoportaldataentry.server; package org.gcube.portlets.user.geoportaldataentry.server;
import java.util.List;
import org.gcube.portlets.user.geoportaldataentry.client.GreetingService; import org.gcube.portlets.user.geoportaldataentry.client.GreetingService;
import org.gcube.portlets.user.geoportaldataentry.shared.FieldVerifier; import org.gcube.portlets.user.geoportaldataentry.shared.FieldVerifier;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@ -46,4 +49,10 @@ public class GreetingServiceImpl extends RemoteServiceServlet implements
return html.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll( return html.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(
">", "&gt;"); ">", "&gt;");
} }
@Override
public String saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception{
return null;
}
} }