diff --git a/pom.xml b/pom.xml index c963a75..cfe2c44 100644 --- a/pom.xml +++ b/pom.xml @@ -68,6 +68,14 @@ provided + + + org.ow2.asm + asm + provided + 7.1 + + xml-apis @@ -87,13 +95,6 @@ ${gwtVersion} provided - - - org.ow2.asm - asm - provided - 7.1 - com.google.gwt gwt-servlet diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index 0961642..3e296fb 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -229,9 +229,6 @@ public class GeoPortalDataEntryApp implements EntryPoint { // TWICE BECAUSE THE MAIN PANEL COULD BE NULL BEFORE setListDocumentConfig(listDocumentConfigs); -// if (dataEntryProjectCreated) -// mainTabPanel.setLoaderVisible("Loading...", true); - geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); mainTabPanel.addFormPanel(geoNaMainForm); @@ -311,12 +308,15 @@ public class GeoPortalDataEntryApp implements EntryPoint { }); } - private void setListDocumentConfig(List listDocumentConfigs) { + private synchronized void setListDocumentConfig(List listDocumentConfigs) { GWT.log("Setting setListDocumentConfig: " + listDocumentConfigs); if (listDocumentConfigs != null) { if (mainTabPanel != null) { - mainTabPanel.setListDocumentConfig(listDocumentConfigs); + //Just to be sure that its set once + if(mainTabPanel.getListDocumentConfig()==null) { + mainTabPanel.setListDocumentConfig(listDocumentConfigs); + } } } } @@ -364,7 +364,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { numberOfCards = 0; expectedCards = config.getGcubeProfiles().size(); GWT.log("expectedCards are: " + expectedCards); - TreeMap treemapOrderedGeoNaProfiles = new TreeMap(); + TreeMap treemapOrderedGNAProfiles = new TreeMap(); for (int i = 0; i < expectedCards; i++) { GcubeProfileDV gcubeProfiles = config.getGcubeProfiles().get(i); @@ -394,19 +394,19 @@ public class GeoPortalDataEntryApp implements EntryPoint { maxOccurs = maxOccurs <= 0 ? Integer.MAX_VALUE : maxOccurs; // TODO MUST BE MANAGED MIN_OCCURS - ConcessioniFormCardTitle cct = new ConcessioniFormCardTitle( + ProjectFormCard cct = new ProjectFormCard( gcubeProfiles.getSectionName(), gcubeProfiles.getSectionTitle(), order, maxOccurs > 1, minOccurs, maxOccurs); GeoNaFormCardModel geonaForm = new GeoNaFormCardModel(metaDataProfileBean, null, cct, gcubeProfiles); - treemapOrderedGeoNaProfiles.put(order, geonaForm); + treemapOrderedGNAProfiles.put(order, geonaForm); } if (getNumberOfCards() == expectedCards) { mainTabPanel.setLoaderVisible("Loading...", false); // ordered values - Collection gnaCardsModels = treemapOrderedGeoNaProfiles.values(); + Collection gnaCardsModels = treemapOrderedGNAProfiles.values(); GWT.log("TreMap values: " + gnaCardsModels); orderedCards.addAll(gnaCardsModels); mapGcubeProfilePerItemType.put(dcDV.getItemType(), @@ -434,15 +434,15 @@ public class GeoPortalDataEntryApp implements EntryPoint { for (GeoNaFormCardModel geonaForm : orderedCards) { // TODO TO TEST - // if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE)){ + // if(geonaForm.getFormCardTitle().equals(ProjectFormCard.IMMAGINI_RAPPRESENTATIVE)){ - GWT.log("Adding card: " + geonaForm.getFormCardTitle()); + GWT.log("Adding card: " + geonaForm.getFormCard()); CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()), appManagerBus, operation); geonaForm.setMetadataForm(baseForm); String key = geonaForm.getMetadataProfileBean().getType(); - if (geonaForm.getFormCardTitle() != null) { - key = geonaForm.getFormCardTitle().getTitle(); + if (geonaForm.getFormCard() != null) { + key = geonaForm.getFormCard().getTitle(); } geoNaMainForm.addForm(key, geonaForm); mapForms.put(key, geonaForm); @@ -603,7 +603,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { // means the form was not submitted if (savedMap.size() == 0) { - DialogConfirm confirm = new DialogConfirm(null, "Creating a New Project...", + DialogConfirm confirm = new DialogConfirm(null, "Creating New Project...", "The current project (is not saved) and will be lost. Confirm?"); confirm.getYesButton().addClickHandler(new ClickHandler() { @@ -625,7 +625,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { // buildNewCards(orderedCards, OPERATION.NEW); } else { - DialogConfirm confirm = new DialogConfirm(null, "Creating a New Project...", + DialogConfirm confirm = new DialogConfirm(null, "Creating New Project...", "The data entry form/s will be cleaned. Confirm?"); confirm.getYesButton().addClickHandler(new ClickHandler() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConcessioniFormCardTitle.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ProjectFormCard.java similarity index 72% rename from src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConcessioniFormCardTitle.java rename to src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ProjectFormCard.java index 288cd0a..dc97d71 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConcessioniFormCardTitle.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ProjectFormCard.java @@ -1,37 +1,38 @@ package org.gcube.portlets.user.geoportaldataentry.client; /** - * The Enum ConcessioniFormCardTitle. + * The Class ProjectFormCard. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Nov 30, 2020 + * Mar 4, 2022 */ -public class ConcessioniFormCardTitle { +public class ProjectFormCard { private String key; - private String title; + private String title; //is the profile title (read from geoportal config) private Integer order; private boolean internalRepeatibleForm; private Integer maxFormRepeatability; private Integer minFormRepeatability; /** - * Instantiates a new concessioni form card title. + * Instantiates a new project form card. * * @param key the key * @param title the title * @param order the order * @param internalRepeatibleForm the internal repeatible form + * @param minFormRepeatability the min form repeatability * @param maxFormRepeatability the max form repeatability */ - public ConcessioniFormCardTitle(String key, String title, int order, boolean internalRepeatibleForm, + public ProjectFormCard(String key, String title, int order, boolean internalRepeatibleForm, Integer minFormRepeatability, Integer maxFormRepeatability) { this.key = key; this.title = title; this.order = order; - this.minFormRepeatability = minFormRepeatability; this.internalRepeatibleForm = internalRepeatibleForm; + this.minFormRepeatability = minFormRepeatability; this.maxFormRepeatability = maxFormRepeatability; } @@ -80,10 +81,20 @@ public class ConcessioniFormCardTitle { return maxFormRepeatability; } + /** + * Gets the min form repeatability. + * + * @return the min form repeatability + */ public Integer getMinFormRepeatability() { return minFormRepeatability; } + /** + * Sets the min form repeatability. + * + * @param minFormRepeatability the new min form repeatability + */ public void setMinFormRepeatability(Integer minFormRepeatability) { this.minFormRepeatability = minFormRepeatability; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java index dc990ea..ab17c71 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java @@ -34,6 +34,8 @@ import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.github.gwtbootstrap.client.ui.constants.IconSize; import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyPressEvent; @@ -488,6 +490,7 @@ public class GeonaMainTabPanel extends Composite { } public void setListDocumentConfig(List listDocumentConfig) { + GWT.log("Setting listDocumentConfig: "+listDocumentConfig); this.listDocumentConfig = listDocumentConfig; ddCreateNewProject.clear(); for (DocumentConfigDV documentConfigDV : listDocumentConfig) { @@ -511,11 +514,30 @@ public class GeonaMainTabPanel extends Composite { ddCreateNewProject.add(link); } + + //IF one type of document is available, fire CreateNewProjectEvent(documentConfigDV)); + if(listDocumentConfig.size()==1) { + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + @Override + public void execute() { + GWT.log("One Config loaded. Firing CreateNewProjectEvent"); + appManagerBus.fireEvent(new CreateNewProjectEvent(listDocumentConfig.get(0))); + + } + + }); + + } } public void setPageHeader(DocumentConfigDV dcDV) { this.pageHeaderDataEntry.setText(""); this.pageHeaderDataEntry.setSubtext("New: "+dcDV.getItemType()); } + + public List getListDocumentConfig() { + return listDocumentConfig; + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/GeoNaFormCardModel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/GeoNaFormCardModel.java index c695589..ea0b711 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/GeoNaFormCardModel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/GeoNaFormCardModel.java @@ -1,7 +1,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.card; import org.gcube.application.geoportalcommon.shared.geoportalconfig.GcubeProfileDV; -import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; +import org.gcube.portlets.user.geoportaldataentry.client.ProjectFormCard; import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean; @@ -9,7 +9,7 @@ public class GeoNaFormCardModel { private MetaDataProfileBean metadataProfileBean; private CreateMetadataForm metadataForm; - private ConcessioniFormCardTitle formCardTitle; // matching with metadata profile type + private ProjectFormCard formCard; // matching with metadata profile private GcubeProfileDV gcubeProfile; public GeoNaFormCardModel() { @@ -17,11 +17,11 @@ public class GeoNaFormCardModel { } public GeoNaFormCardModel(MetaDataProfileBean metadataProfileBean, CreateMetadataForm metadataForm, - ConcessioniFormCardTitle formCardTitle, GcubeProfileDV gcubeProfile) { + ProjectFormCard formCard, GcubeProfileDV gcubeProfile) { super(); this.metadataProfileBean = metadataProfileBean; this.metadataForm = metadataForm; - this.formCardTitle = formCardTitle; + this.formCard = formCard; this.gcubeProfile = gcubeProfile; } @@ -41,12 +41,12 @@ public class GeoNaFormCardModel { this.metadataForm = metadataForm; } - public ConcessioniFormCardTitle getFormCardTitle() { - return formCardTitle; + public ProjectFormCard getFormCard() { + return formCard; } - public void setFormCardTitle(ConcessioniFormCardTitle formCardTitle) { - this.formCardTitle = formCardTitle; + public void setFormCard(ProjectFormCard formCard) { + this.formCard = formCard; } public GcubeProfileDV getGcubeProfile() { @@ -64,8 +64,8 @@ public class GeoNaFormCardModel { builder.append(metadataProfileBean); builder.append(", metadataForm="); builder.append(metadataForm); - builder.append(", formCardTitle="); - builder.append(formCardTitle); + builder.append(", formCard="); + builder.append(formCard); builder.append(", gcubeProfile="); builder.append(gcubeProfile); builder.append("]"); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java index b058969..b5d875f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java @@ -3,63 +3,70 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.card; import java.util.ArrayList; import java.util.List; +import org.gcube.portlets.user.geoportaldataentry.client.ProjectFormCard; +import org.gcube.portlets.user.geoportaldataentry.client.resource.Images; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.AlertClosable; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform; import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm; import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.GenericFormEvents.GenericFormEventsListener; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Tab; +import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.IconType; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.shared.HandlerManager; -import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.FlowPanel; - +import com.google.gwt.user.client.ui.Image; /** * The Class MetadataFormCard. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 12, 2020 + * Oct 12, 2020 */ public class MetadataFormCard { - + /** The heading. */ private String heading; - + /** The tab. */ private Tab tab; - + /** The repeatible. */ private boolean repeatible; - + /** The list forms. */ private List listForms = new ArrayList(); - + /** The form card event handler. */ private MetadataFormCardEventHandler formCardEventHandler = new MetadataFormCardEventHandler(); - + /** The geona form model. */ private GeoNaFormCardModel geonaFormModel; private HandlerManager appManagerBus; private Integer maxFormRepeatability; - + private FlowPanel tabContainer = new FlowPanel(); + private int minFormRepeatability; + /** * The Class MetadataFormCardEventHandler. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 12, 2020 + * Oct 12, 2020 */ - private class MetadataFormCardEventHandler implements GenericFormEventsListener{ - + private class MetadataFormCardEventHandler implements GenericFormEventsListener { + /** * On form data valid. * @@ -68,7 +75,7 @@ public class MetadataFormCard { @Override public void onFormDataValid(GenericDatasetBean genericDatasetBean) { setTabStatus(); - + } /** @@ -77,7 +84,7 @@ public class MetadataFormCard { @Override public void onFormDataEdit() { resetTabStatus(); - + } /** @@ -86,38 +93,58 @@ public class MetadataFormCard { @Override public void onFormAborted() { // TODO Auto-generated method stub - + } /** * On validation error. * * @param throwable the throwable - * @param errorMsg the error msg + * @param errorMsg the error msg */ @Override public void onValidationError(Throwable throwable, String errorMsg) { // TODO Auto-generated method stub - + } - + } - + /** * Instantiates a new metadata form card. * - * @param tab the tab + * @param tab the tab * @param geonaFormModel the geona form model - * @param appManagerBus the app manager bus + * @param appManagerBus the app manager bus */ public MetadataFormCard(Tab tab, GeoNaFormCardModel geonaFormModel, HandlerManager appManagerBus) { this.tab = tab; this.geonaFormModel = geonaFormModel; this.appManagerBus = appManagerBus; - this.repeatible = geonaFormModel.getFormCardTitle().isInternalRepeatibleForm(); - this.maxFormRepeatability = geonaFormModel.getFormCardTitle().getMaxFormRepeatability()!=null?geonaFormModel.getFormCardTitle().getMaxFormRepeatability():Integer.MAX_VALUE; - this.buildCard(geonaFormModel.getMetadataForm()); - //geonaFormModel.getMetadataForm().addListener(formCardEventHandler); + ProjectFormCard formCard = geonaFormModel.getFormCard(); + this.repeatible = formCard.isInternalRepeatibleForm(); + this.minFormRepeatability = formCard.getMinFormRepeatability() != null + ? geonaFormModel.getFormCard().getMinFormRepeatability() + : 1; + this.maxFormRepeatability = formCard.getMaxFormRepeatability() != null + ? geonaFormModel.getFormCard().getMaxFormRepeatability() + : Integer.MAX_VALUE; + + boolean repeatibleFormIsRemovable = true; + if (minFormRepeatability > 1) { + repeatibleFormIsRemovable = false; + for (int i = 1; i < minFormRepeatability; i++) { + CreateMetadataForm newForm = new CreateMetadataForm( + geonaFormModel.getMetadataForm().getMetadataProfiles(), appManagerBus, + CreateMetadataForm.OPERATION.UPDATE); + // newForm.addListener(formCardEventHandler); + // here removableForm is false because the min > 1 must be respected + addNewForm(newForm, repeatibleFormIsRemovable); + } + } + + this.buildCard(geonaFormModel.getMetadataForm(), repeatibleFormIsRemovable); + // geonaFormModel.getMetadataForm().addListener(formCardEventHandler); } /** @@ -125,62 +152,74 @@ public class MetadataFormCard { * * @param createMetadataForm the create metadata form */ - private void buildCard(final CreateMetadataForm createMetadataForm) { - - if(repeatible) { + private void buildCard(final CreateMetadataForm createMetadataForm, boolean repeatibleFormIsRemovable) { + + if (repeatible) { Button buttonAddNew = new Button("Add New..."); tab.add(buttonAddNew); - + buttonAddNew.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { - - if(listForms.size() < maxFormRepeatability) { - - CreateMetadataForm newForm = new CreateMetadataForm(createMetadataForm.getMetadataProfiles(),appManagerBus, CreateMetadataForm.OPERATION.UPDATE); - //newForm.addListener(formCardEventHandler); - addNewForm(newForm); - }else - Window.alert("Maximun number of data reached for "+geonaFormModel.getFormCardTitle().getTitle()); - //newForm.getCreateButton().setFocus(true); + + if (listForms.size() < maxFormRepeatability) { + + CreateMetadataForm newForm = new CreateMetadataForm(createMetadataForm.getMetadataProfiles(), + appManagerBus, CreateMetadataForm.OPERATION.UPDATE); + // newForm.addListener(formCardEventHandler); + addNewForm(newForm, true); + } else { + DialogInform di = new DialogInform(new Image(Images.ICONS.accessDenied()), "Maximun reached", + "Maximun number of data reached for " + geonaFormModel.getFormCard().getTitle()); + di.center(); + } } }); } - + tab.add(tabContainer); - addNewForm(createMetadataForm); + addNewForm(createMetadataForm, repeatibleFormIsRemovable); } - + /** * Adds the new form. * * @param newForm the new form */ - private void addNewForm(final CreateMetadataForm newForm) { - tabContainer.insert(newForm,0); + private void addNewForm(final CreateMetadataForm newForm, boolean repeatibleFormIsRemovable) { + tabContainer.insert(newForm, 0); listForms.add(newForm); - - if(listForms.size()>1) { + + if (listForms.size() > 1 && repeatibleFormIsRemovable) { final Button buttonRemoveLatestForm = new Button("Remove"); buttonRemoveLatestForm.setIcon(IconType.TRASH); - tabContainer.insert(buttonRemoveLatestForm,1); - + tabContainer.insert(buttonRemoveLatestForm, 1); + buttonRemoveLatestForm.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { tabContainer.remove(newForm); listForms.remove(newForm); tabContainer.remove(buttonRemoveLatestForm); - + + AlertClosable alertCloasable = new AlertClosable(); + alertCloasable.setHTML("Data Entry form removed"); + alertCloasable.setAnimation(true); + alertCloasable.setType(AlertType.DEFAULT); + alertCloasable.setClose(true); + alertCloasable.closeAfter(3000); + alertCloasable.getElement().getStyle().setMarginTop(5, Unit.PX); + tabContainer.insert(alertCloasable,0); + } }); } - + newForm.addListener(formCardEventHandler); } - + /** * Gets the list forms. * @@ -189,7 +228,7 @@ public class MetadataFormCard { public List getListForms() { return listForms; } - + /** * Gets the heading. * @@ -199,7 +238,6 @@ public class MetadataFormCard { return heading; } - /** * Validate form. * @@ -208,8 +246,8 @@ public class MetadataFormCard { public boolean validateForm() { for (CreateMetadataForm createMetadataForm : listForms) { boolean isFormDataValid = createMetadataForm.isFormDataValid(); - GWT.log("Is form data valid: "+isFormDataValid); - if(!isFormDataValid) { + GWT.log("Is form data valid: " + isFormDataValid); + if (!isFormDataValid) { return false; } } @@ -222,43 +260,41 @@ public class MetadataFormCard { * @param bool the new valid card */ public void setValidCard(boolean bool) { - if(bool) { + if (bool) { tab.setIcon(IconType.OK_SIGN); tab.asWidget().getElement().removeClassName("red-text"); tab.asWidget().getElement().addClassName("green-text"); - } - else { + } else { tab.setIcon(IconType.MINUS_SIGN); tab.asWidget().getElement().removeClassName("green-text"); tab.asWidget().getElement().addClassName("red-text"); } - + } - + /** * Sets the tab status. */ private void setTabStatus() { boolean isValid = validateForm(); - if(isValid) { + if (isValid) { tab.setIcon(IconType.OK_SIGN); tab.asWidget().getElement().removeClassName("red-text"); tab.asWidget().getElement().addClassName("green-text"); - } - else { + } else { tab.setIcon(IconType.MINUS_SIGN); tab.asWidget().getElement().removeClassName("red-text"); tab.asWidget().getElement().addClassName("red-text"); } } - + /** * Reset tab status. */ private void resetTabStatus() { tab.setIcon(null); } - + public GeoNaFormCardModel getGeonaFormModel() { return geonaFormModel; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/form/GeonaDataEntryMainForm.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/form/GeonaDataEntryMainForm.java index 514e267..468503a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/form/GeonaDataEntryMainForm.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/form/GeonaDataEntryMainForm.java @@ -168,7 +168,7 @@ public class GeonaDataEntryMainForm extends Composite { listGDB.add(form.getFormDataBean()); } - listGeonaFormObjects.add(new GeoNaFormDataObject(listGDB, card.getGeonaFormModel().getFormCardTitle())); + listGeonaFormObjects.add(new GeoNaFormDataObject(listGDB, card.getGeonaFormModel().getFormCard())); } appManagerBus.fireEvent(new SaveGeonaDataFormsEvent(listGeonaFormObjects)); } else { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/AlertClosable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/AlertClosable.java new file mode 100644 index 0000000..f81bd8c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/AlertClosable.java @@ -0,0 +1,40 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui.utils; + +import com.github.gwtbootstrap.client.ui.Alert; +import com.google.gwt.user.client.Timer; + +/** + * The Class AlertClosable. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 4, 2022 + */ +public class AlertClosable extends Alert { + + private AlertClosable instance = this; + + /** + * Instantiates a new alert closable. + */ + public AlertClosable() { + } + + /** + * Close after. + * + * @param depayMillis the depay millis + */ + public void closeAfter(int depayMillis) { + Timer timer = new Timer() { + + @Override + public void run() { + instance.close(); + + } + }; + + timer.schedule(depayMillis); + } +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java index e004479..9a1e463 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java @@ -30,9 +30,9 @@ import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceCo import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.common.portal.PortalContext; -import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; +import org.gcube.portlets.user.geoportaldataentry.client.ProjectFormCard; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; @@ -98,11 +98,11 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen public CommitReport saveGeonaDataForms(List listGeonaFormObjects) throws Exception { LOG.info("saveGeonaDataForms called"); - HashMap> toMap = new HashMap>(); + HashMap> toMap = new HashMap>(); for (GeoNaFormDataObject geoNaFormDataObject : listGeonaFormObjects) { - ConcessioniFormCardTitle theType = geoNaFormDataObject.getTheType(); + ProjectFormCard theType = geoNaFormDataObject.getTheType(); List listForm = toMap.get(theType); if (listForm == null) { listForm = new ArrayList(); @@ -130,56 +130,56 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen /* // Saving Data // Informazioni di Progetto - List list = toMap.get(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO); + List list = toMap.get(ProjectFormCard.INFORMAZIONI_DI_PROGETTO); 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()); + "Error: no data found for " + ProjectFormCard.INFORMAZIONI_DI_PROGETTO.getTitle()); List listGDB = list.get(0).getListGDB(); GenericDatasetBean idp = listGDB.get(0); LOG.debug("\n\n"); - LOG.debug(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO + " building with client obj: " + idp); + LOG.debug(ProjectFormCard.INFORMAZIONI_DI_PROGETTO + " building with client obj: " + idp); Concessione concessione = ConvertToServiceModel.toConcessione(idp, user); - LOG.debug("Built " + ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO + " as server obj: " + concessione); + LOG.debug("Built " + ProjectFormCard.INFORMAZIONI_DI_PROGETTO + " as server obj: " + concessione); // Register New Concessione concessioneNew = clientMongo.createNew(concessione); // ABSTRACT_RELAZIONE_DI_SCAVO - list = toMap.get(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO); + list = toMap.get(ProjectFormCard.ABSTRACT_RELAZIONE_DI_SCAVO); if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null) throw new Exception( - "Error: no data found for " + ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getTitle()); + "Error: no data found for " + ProjectFormCard.ABSTRACT_RELAZIONE_DI_SCAVO.getTitle()); listGDB = list.get(0).getListGDB(); GenericDatasetBean ards = listGDB.get(0); LOG.debug("\n\n"); - LOG.debug(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO + " building with client obj: " + ards); + LOG.debug(ProjectFormCard.ABSTRACT_RELAZIONE_DI_SCAVO + " building with client obj: " + ards); AbstractRelazione abstractRelazioneDiScavo = ConvertToServiceModel.toAbstractRelazioneScavo(ards); // Setting Abstract Relazione concessioneNew.setAbstractRelazione(abstractRelazioneDiScavo); // RELAZIONE_DI_SCAVO - list = toMap.get(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO); + list = toMap.get(ProjectFormCard.RELAZIONE_DI_SCAVO); 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()); + "Error: no data found for " + ProjectFormCard.RELAZIONE_DI_SCAVO.getTitle()); listGDB = list.get(0).getListGDB(); GenericDatasetBean rds = listGDB.get(0); LOG.debug("\n\n"); - LOG.debug(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " building with client obj: " + rds); + LOG.debug(ProjectFormCard.RELAZIONE_DI_SCAVO + " building with client obj: " + rds); RelazioneScavo relazioneDiScavo = ConvertToServiceModel.toRelazioneScavo(rds); - LOG.debug("Built " + ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " as server obj: " + relazioneDiScavo); + LOG.debug("Built " + ProjectFormCard.RELAZIONE_DI_SCAVO + " as server obj: " + relazioneDiScavo); // Setting Relazione concessioneNew.setRelazioneScavo(relazioneDiScavo); // IMMAGINI_RAPPRESENTATIVE - list = toMap.get(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE); + list = toMap.get(ProjectFormCard.IMMAGINI_RAPPRESENTATIVE); 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()); + "Error: no data found for " + ProjectFormCard.IMMAGINI_RAPPRESENTATIVE.getTitle()); List imgRaprsLst = list.get(0).getListGDB(); List immaginiRappresentativeService = null; @@ -187,10 +187,10 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen immaginiRappresentativeService = new ArrayList(imgRaprsLst.size()); for (GenericDatasetBean imgRapr : imgRaprsLst) { LOG.debug("\n\n"); - LOG.debug(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE + " building with client obj: " + LOG.debug(ProjectFormCard.IMMAGINI_RAPPRESENTATIVE + " building with client obj: " + imgRapr); UploadedImage img = ConvertToServiceModel.toImmaginiRappresentative(imgRapr); - LOG.debug("Built " + ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE + " as server obj: " + img); + LOG.debug("Built " + ProjectFormCard.IMMAGINI_RAPPRESENTATIVE + " as server obj: " + img); immaginiRappresentativeService.add(img); } } @@ -201,20 +201,20 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } // POSIZIONAMENTO_DELL_AREA_DI_INDAGINE - list = toMap.get(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE); + list = toMap.get(ProjectFormCard.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE); 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()); + + ProjectFormCard.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getTitle()); listGDB = list.get(0).getListGDB(); GenericDatasetBean pad = listGDB.get(0); LayerConcessione layerPad = null; if (pad != null) { LOG.debug("\n\n"); - LOG.debug(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " building with client obj: " + LOG.debug(ProjectFormCard.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " building with client obj: " + pad); layerPad = ConvertToServiceModel.toLayerConcessione(pad); - LOG.debug("Built " + ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " as server obj: " + LOG.debug("Built " + ProjectFormCard.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " as server obj: " + layerPad); } @@ -224,10 +224,10 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } // PIANTA_DI_FINE_SCAVO - list = toMap.get(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO); + list = toMap.get(ProjectFormCard.PIANTA_DI_FINE_SCAVO); 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()); + "Error: no data found for " + ProjectFormCard.PIANTA_DI_FINE_SCAVO.getTitle()); listGDB = list.get(0).getListGDB(); List listPfs = listGDB; @@ -237,9 +237,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen pianteFineScavo = new ArrayList(listPfs.size()); for (GenericDatasetBean pfs : listPfs) { LOG.debug("\n\n"); - LOG.debug(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO + " building with client obj: " + pfs); + LOG.debug(ProjectFormCard.PIANTA_DI_FINE_SCAVO + " building with client obj: " + pfs); LayerConcessione layerPfs = ConvertToServiceModel.toLayerConcessione(pfs); - LOG.debug("Built " + ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO + " as server obj: " + layerPfs); + LOG.debug("Built " + ProjectFormCard.PIANTA_DI_FINE_SCAVO + " as server obj: " + layerPfs); pianteFineScavo.add(layerPfs); } @@ -486,9 +486,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen * * @param toMap the to map */ - private void prettyPrintClientDataEntryMap(HashMap> toMap) { + private void prettyPrintClientDataEntryMap(HashMap> toMap) { - for (ConcessioniFormCardTitle theType : toMap.keySet()) { + for (ProjectFormCard theType : toMap.keySet()) { LOG.debug("\n\n"); LOG.debug(theType.toString()); List list = toMap.get(theType); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GeoNaFormDataObject.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GeoNaFormDataObject.java index 1c5ab19..45479c2 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GeoNaFormDataObject.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/GeoNaFormDataObject.java @@ -3,7 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.shared; import java.io.Serializable; import java.util.List; -import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; +import org.gcube.portlets.user.geoportaldataentry.client.ProjectFormCard; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; public class GeoNaFormDataObject implements Serializable{ @@ -14,13 +14,13 @@ public class GeoNaFormDataObject implements Serializable{ private static final long serialVersionUID = 3620244260086172039L; private List listGDB; - private ConcessioniFormCardTitle theType; + private ProjectFormCard theType; public GeoNaFormDataObject(){ } - public GeoNaFormDataObject(List listGDB, ConcessioniFormCardTitle theType) { + public GeoNaFormDataObject(List listGDB, ProjectFormCard theType) { super(); this.listGDB = listGDB; this.theType = theType; @@ -33,10 +33,10 @@ public class GeoNaFormDataObject implements Serializable{ public void setListGDB(List listGDB) { this.listGDB = listGDB; } - public ConcessioniFormCardTitle getTheType() { + public ProjectFormCard getTheType() { return theType; } - public void setTheType(ConcessioniFormCardTitle theType) { + public void setTheType(ProjectFormCard theType) { this.theType = theType; }