|
|
|
@ -8,22 +8,28 @@ import java.util.List;
|
|
|
|
|
import java.util.TreeMap;
|
|
|
|
|
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEventHandler;
|
|
|
|
|
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.GetListOfRecordsEvent;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEventHandler;
|
|
|
|
|
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.GeonaMainPanel;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainTabPanel;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginatedView;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.NewBrowserWindow;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
|
|
|
@ -36,6 +42,8 @@ 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.GWT;
|
|
|
|
|
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.rpc.AsyncCallback;
|
|
|
|
@ -48,7 +56,6 @@ import com.google.gwt.user.client.ui.VerticalPanel;
|
|
|
|
|
* Entry point classes define <code>onModuleLoad()</code>.
|
|
|
|
|
*/
|
|
|
|
|
public class GeoPortalDataEntryApp implements EntryPoint {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The message displayed to the user when the server cannot be reached or
|
|
|
|
@ -67,27 +74,27 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|
|
|
|
private final HandlerManager appManagerBus = new HandlerManager(null);
|
|
|
|
|
|
|
|
|
|
private LinkedHashMap<String, GeoNaFormCardModel> mapForms = new LinkedHashMap<String, GeoNaFormCardModel>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private GeonaDataEntryMainForm geoNaMainForm;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Collection<GeoNaFormCardModel> orderedCards;
|
|
|
|
|
|
|
|
|
|
private GeonaMainPanel mainPanel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private GeonaMainTabPanel mainTabPanel;
|
|
|
|
|
|
|
|
|
|
private LinkedHashMap<String, List<GeoNaFormDataObject>> savedMap = new LinkedHashMap<String, List<GeoNaFormDataObject>>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean projectSavedWithSuccess;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is the entry point method.
|
|
|
|
|
*/
|
|
|
|
|
public void onModuleLoad() {
|
|
|
|
|
|
|
|
|
|
mainPanel = new GeonaMainPanel(appManagerBus);
|
|
|
|
|
mainPanel.setLoaderVisible("Loading...", true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mainTabPanel = new GeonaMainTabPanel(appManagerBus);
|
|
|
|
|
mainTabPanel.setLoaderVisible("Loading...", true);
|
|
|
|
|
|
|
|
|
|
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback<GeonaISConfig>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -97,131 +104,137 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(GeonaISConfig result) {
|
|
|
|
|
|
|
|
|
|
if(result!=null && result.getgRSecondaryType()!=null && result.getScope()!=null) {
|
|
|
|
|
|
|
|
|
|
if (result != null && result.getgRSecondaryType() != null && result.getScope() != null) {
|
|
|
|
|
callGetMetadataProfiles(result.getScope(), result.getgRSecondaryType());
|
|
|
|
|
}else
|
|
|
|
|
Window.alert(ConstantsGeoPortalDataEntryApp.ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT);
|
|
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
Window.alert(
|
|
|
|
|
ConstantsGeoPortalDataEntryApp.ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bindEvents();
|
|
|
|
|
mainPanel.addFormPanel(geoNaMainForm);
|
|
|
|
|
RootPanel.get(DIV_PORTLET_ID).add(mainPanel);
|
|
|
|
|
mainTabPanel.addFormPanel(geoNaMainForm);
|
|
|
|
|
RootPanel.get(DIV_PORTLET_ID).add(mainTabPanel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void callGetMetadataProfiles(String scope, String secondaryType) {
|
|
|
|
|
|
|
|
|
|
MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScope(scope, secondaryType, new AsyncCallback<List<MetaDataProfileBean>>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(List<MetaDataProfileBean> result) {
|
|
|
|
|
GWT.log("Returned "+result.size()+ "profile/s");
|
|
|
|
|
orderedCards = setGeoNaFormsOrder(result);
|
|
|
|
|
//ordered values
|
|
|
|
|
buildNewCards(orderedCards);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScope(scope, secondaryType,
|
|
|
|
|
new AsyncCallback<List<MetaDataProfileBean>>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(List<MetaDataProfileBean> result) {
|
|
|
|
|
GWT.log("Returned " + result.size() + "profile/s");
|
|
|
|
|
orderedCards = setGeoNaFormsOrder(result);
|
|
|
|
|
// ordered values
|
|
|
|
|
buildNewCards(orderedCards);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards) {
|
|
|
|
|
projectSavedWithSuccess = false; //resetting state of saving
|
|
|
|
|
mainPanel.setFormPanelVisible(true);
|
|
|
|
|
mainPanel.setLoaderVisible("Loading...", true);
|
|
|
|
|
projectSavedWithSuccess = false; // resetting state of saving
|
|
|
|
|
mainTabPanel.setLoaderVisible("Loading...", true);
|
|
|
|
|
resetUI();
|
|
|
|
|
//ordered values
|
|
|
|
|
// ordered values
|
|
|
|
|
for (GeoNaFormCardModel geonaForm : orderedCards) {
|
|
|
|
|
|
|
|
|
|
//TODO TO TEST
|
|
|
|
|
//if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE)){
|
|
|
|
|
|
|
|
|
|
GWT.log("Adding card: "+geonaForm.getFormCardTitle());
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
// TODO TO TEST
|
|
|
|
|
// if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE)){
|
|
|
|
|
|
|
|
|
|
GWT.log("Adding card: " + geonaForm.getFormCardTitle());
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
geoNaMainForm.enableButtonSave(true);
|
|
|
|
|
mainPanel.setLoaderVisible("", false);
|
|
|
|
|
mainTabPanel.setLoaderVisible("", false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void resetUI() {
|
|
|
|
|
geoNaMainForm.reset();
|
|
|
|
|
mapForms.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Collection<GeoNaFormCardModel> setGeoNaFormsOrder(List<MetaDataProfileBean> listMetadataProfilesForGeona) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TreeMap<Integer, GeoNaFormCardModel> treemapOrderedGeoNaProfiles = new TreeMap<Integer, GeoNaFormCardModel>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<GeoNaFormCardModel> listUnknownType = new ArrayList<GeoNaFormCardModel>();
|
|
|
|
|
|
|
|
|
|
for (MetaDataProfileBean metaDataProfileBean : listMetadataProfilesForGeona) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String theMetaType = metaDataProfileBean.getType().toLowerCase();
|
|
|
|
|
GWT.log("Building form card for type: "+theMetaType);
|
|
|
|
|
GWT.log("Building form card for type: " + theMetaType);
|
|
|
|
|
GeoNaFormCardModel geonaForm = new GeoNaFormCardModel(metaDataProfileBean, null, null);
|
|
|
|
|
|
|
|
|
|
if(theMetaType.contains(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getKey().toLowerCase())) {
|
|
|
|
|
|
|
|
|
|
if (theMetaType.contains(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getKey().toLowerCase())) {
|
|
|
|
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO);
|
|
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getOrder(), geonaForm);
|
|
|
|
|
}else if(theMetaType.contains(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getKey().toLowerCase())) {
|
|
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getOrder(),
|
|
|
|
|
geonaForm);
|
|
|
|
|
} else if (theMetaType
|
|
|
|
|
.contains(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getKey().toLowerCase())) {
|
|
|
|
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO);
|
|
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getOrder(), geonaForm);
|
|
|
|
|
}else if(theMetaType.contains(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getKey().toLowerCase())) {
|
|
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getOrder(),
|
|
|
|
|
geonaForm);
|
|
|
|
|
} else if (theMetaType.contains(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getKey().toLowerCase())) {
|
|
|
|
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO);
|
|
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getOrder(), geonaForm);
|
|
|
|
|
}else if(theMetaType.contains(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getKey().toLowerCase())) {
|
|
|
|
|
} else if (theMetaType.contains(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getKey().toLowerCase())) {
|
|
|
|
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE);
|
|
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getOrder(), geonaForm);
|
|
|
|
|
}else if(theMetaType.contains(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getKey().toLowerCase())) {
|
|
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getOrder(),
|
|
|
|
|
geonaForm);
|
|
|
|
|
} else if (theMetaType
|
|
|
|
|
.contains(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getKey().toLowerCase())) {
|
|
|
|
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE);
|
|
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getOrder(), geonaForm);
|
|
|
|
|
}else if(theMetaType.contains(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getKey().toLowerCase())) {
|
|
|
|
|
treemapOrderedGeoNaProfiles
|
|
|
|
|
.put(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getOrder(), geonaForm);
|
|
|
|
|
} else if (theMetaType.contains(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getKey().toLowerCase())) {
|
|
|
|
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO);
|
|
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getOrder(), geonaForm);
|
|
|
|
|
}else {
|
|
|
|
|
//adding to unknown list
|
|
|
|
|
} else {
|
|
|
|
|
// adding to unknown list
|
|
|
|
|
listUnknownType.add(geonaForm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//adding unknown types
|
|
|
|
|
|
|
|
|
|
// adding unknown types
|
|
|
|
|
for (GeoNaFormCardModel geoNaFormCardModel : listUnknownType) {
|
|
|
|
|
Integer highestKey = treemapOrderedGeoNaProfiles.lastKey();
|
|
|
|
|
highestKey++;
|
|
|
|
|
treemapOrderedGeoNaProfiles.put(highestKey, geoNaFormCardModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GWT.log("Map size: "+treemapOrderedGeoNaProfiles.size());
|
|
|
|
|
|
|
|
|
|
GWT.log("Map size: " + treemapOrderedGeoNaProfiles.size());
|
|
|
|
|
return treemapOrderedGeoNaProfiles.values();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void bindEvents() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
appManagerBus.addHandler(SaveGeonaDataFormsEvent.TYPE, new SaveGeonaDataFormsHandler() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSave(final SaveGeonaDataFormsEvent saveGeonaDataFormsEvent) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
geoNaMainForm.enableButtonSave(false);
|
|
|
|
|
|
|
|
|
|
if(saveGeonaDataFormsEvent.getListGeonaDataForms()!=null) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (saveGeonaDataFormsEvent.getListGeonaDataForms() != null) {
|
|
|
|
|
|
|
|
|
|
final Modal modal = new Modal(true);
|
|
|
|
|
modal.setCloseVisible(false);
|
|
|
|
|
modal.setTitle("Saving project...");
|
|
|
|
@ -234,110 +247,120 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|
|
|
|
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
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
modalContainerPanel.clear();
|
|
|
|
|
modal.setCloseVisible(true);
|
|
|
|
|
try {
|
|
|
|
|
modal.remove(loader);
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
}
|
|
|
|
|
Alert alert = new Alert(caught.getMessage());
|
|
|
|
|
alert.setType(AlertType.ERROR);
|
|
|
|
|
alert.setClose(false);
|
|
|
|
|
modal.add(alert);
|
|
|
|
|
//resetUI();
|
|
|
|
|
geoNaMainForm.enableButtonSave(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(CommitReport result) {
|
|
|
|
|
modalContainerPanel.clear();
|
|
|
|
|
modal.setCloseVisible(true);
|
|
|
|
|
HTML recordPublished = new HTML();
|
|
|
|
|
switch (result.getState()) {
|
|
|
|
|
case OK:
|
|
|
|
|
String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, "SUCCESS");
|
|
|
|
|
recordPublished.setHTML("Record Published with "+success);
|
|
|
|
|
projectSavedWithSuccess = true;
|
|
|
|
|
String msg = result.getMsg()!=null?result.getMsg():"Record published with success";
|
|
|
|
|
geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true);
|
|
|
|
|
purgeFileUploaded();
|
|
|
|
|
break;
|
|
|
|
|
case WARN:
|
|
|
|
|
String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, "WARNING");
|
|
|
|
|
recordPublished.setHTML("Record Published with "+warning);
|
|
|
|
|
geoNaMainForm.enableButtonSave(true);
|
|
|
|
|
break;
|
|
|
|
|
case ERROR:
|
|
|
|
|
String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", "ERROR");
|
|
|
|
|
recordPublished.setHTML(error+" on publishing the Record");
|
|
|
|
|
geoNaMainForm.enableButtonSave(true);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
modalContainerPanel.add(recordPublished);
|
|
|
|
|
|
|
|
|
|
if(result.getMongoId()!=null) {
|
|
|
|
|
modalContainerPanel.add(new HTML("Record id: "+(result.getMongoId())));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
savedMap.put(result.getMongoId(), saveGeonaDataFormsEvent.getListGeonaDataForms());
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
modalContainerPanel.clear();
|
|
|
|
|
modal.setCloseVisible(true);
|
|
|
|
|
try {
|
|
|
|
|
modal.remove(loader);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
}
|
|
|
|
|
Alert alert = new Alert(caught.getMessage());
|
|
|
|
|
alert.setType(AlertType.ERROR);
|
|
|
|
|
alert.setClose(false);
|
|
|
|
|
modal.add(alert);
|
|
|
|
|
// resetUI();
|
|
|
|
|
geoNaMainForm.enableButtonSave(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final HorizontalPanel hpGetLink = new HorizontalPanel();
|
|
|
|
|
final LoaderIcon lc = new LoaderIcon("Get link...");
|
|
|
|
|
hpGetLink.add(lc);
|
|
|
|
|
modalContainerPanel.add(hpGetLink);
|
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(result.getMongoId(), "concessione", new AsyncCallback<GeoNaItemRef>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
hpGetLink.clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(CommitReport result) {
|
|
|
|
|
modalContainerPanel.clear();
|
|
|
|
|
modal.setCloseVisible(true);
|
|
|
|
|
HTML recordPublished = new HTML();
|
|
|
|
|
switch (result.getState()) {
|
|
|
|
|
case OK:
|
|
|
|
|
String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null,
|
|
|
|
|
"SUCCESS");
|
|
|
|
|
recordPublished.setHTML("Record Published with " + success);
|
|
|
|
|
projectSavedWithSuccess = true;
|
|
|
|
|
String msg = result.getMsg() != null ? result.getMsg()
|
|
|
|
|
: "Record published with success";
|
|
|
|
|
geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true);
|
|
|
|
|
purgeFileUploaded();
|
|
|
|
|
break;
|
|
|
|
|
case WARN:
|
|
|
|
|
String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null,
|
|
|
|
|
"WARNING");
|
|
|
|
|
recordPublished.setHTML("Record Published with " + warning);
|
|
|
|
|
geoNaMainForm.enableButtonSave(true);
|
|
|
|
|
break;
|
|
|
|
|
case ERROR:
|
|
|
|
|
String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold",
|
|
|
|
|
"ERROR");
|
|
|
|
|
recordPublished.setHTML(error + " on publishing the Record");
|
|
|
|
|
geoNaMainForm.enableButtonSave(true);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
modalContainerPanel.add(recordPublished);
|
|
|
|
|
|
|
|
|
|
if (result.getMongoId() != null) {
|
|
|
|
|
modalContainerPanel.add(new HTML("Record id: " + (result.getMongoId())));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
savedMap.put(result.getMongoId(),
|
|
|
|
|
saveGeonaDataFormsEvent.getListGeonaDataForms());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final HorizontalPanel hpGetLink = new HorizontalPanel();
|
|
|
|
|
final LoaderIcon lc = new LoaderIcon("Get link...");
|
|
|
|
|
hpGetLink.add(lc);
|
|
|
|
|
modalContainerPanel.add(hpGetLink);
|
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(
|
|
|
|
|
result.getMongoId(), RECORD_TYPE.CONCESSIONE,
|
|
|
|
|
new AsyncCallback<GeoNaItemRef>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
hpGetLink.clear();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(GeoNaItemRef result) {
|
|
|
|
|
hpGetLink.clear();
|
|
|
|
|
String theURL = result.getRestrictedLink().getShortURL() != null
|
|
|
|
|
? result.getRestrictedLink().getShortURL()
|
|
|
|
|
: result.getRestrictedLink().getCompleteURL();
|
|
|
|
|
String htmlLink = "<div>Go to record: <a href=" + theURL
|
|
|
|
|
+ " target=\"_blank\">" + theURL + "</a></div>";
|
|
|
|
|
HTML html = new HTML(htmlLink);
|
|
|
|
|
hpGetLink.add(html);
|
|
|
|
|
// modal.add(html);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(GeoNaItemRef result) {
|
|
|
|
|
hpGetLink.clear();
|
|
|
|
|
String theURL = result.getRestrictedLink().getShortURL()!=null?result.getRestrictedLink().getShortURL():result.getRestrictedLink().getCompleteURL();
|
|
|
|
|
String htmlLink = "<div>Go to record: <a href="+theURL+" target=\"_blank\">"+theURL+"</a></div>";
|
|
|
|
|
HTML html = new HTML(htmlLink);
|
|
|
|
|
hpGetLink.add(html);
|
|
|
|
|
//modal.add(html);
|
|
|
|
|
|
|
|
|
|
// geoNaMainForm.enableButtonSave(true);
|
|
|
|
|
// resetUI();
|
|
|
|
|
|
|
|
|
|
if (result.getReport() != null) {
|
|
|
|
|
modalContainerPanel.add(new ReportTemplateToHTML(result.getReport()));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//geoNaMainForm.enableButtonSave(true);
|
|
|
|
|
//resetUI();
|
|
|
|
|
|
|
|
|
|
if(result.getReport()!=null) {
|
|
|
|
|
modalContainerPanel.add(new ReportTemplateToHTML(result.getReport()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modal.show();
|
|
|
|
|
}else
|
|
|
|
|
} else
|
|
|
|
|
geoNaMainForm.enableButtonSave(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
appManagerBus.addHandler(CreateNewProjectEvent.TYPE, new CreateNewProjectEventHandler() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// means the form was not submitted
|
|
|
|
|
if (savedMap.size() == 0) {
|
|
|
|
|
boolean confirm = Window.confirm(
|
|
|
|
@ -345,10 +368,10 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|
|
|
|
if (confirm)
|
|
|
|
|
buildNewCards(orderedCards);
|
|
|
|
|
} else if (projectSavedWithSuccess) {
|
|
|
|
|
//means the project has been saved
|
|
|
|
|
// means the project has been saved
|
|
|
|
|
buildNewCards(orderedCards);
|
|
|
|
|
} else {
|
|
|
|
|
//means the project reported one ore more errors after the submit
|
|
|
|
|
// 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?");
|
|
|
|
|
if (confirm)
|
|
|
|
|
buildNewCards(orderedCards);
|
|
|
|
@ -356,37 +379,159 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
appManagerBus.addHandler(GetListOfRecordsEvent.TYPE, new GetListOfRecordsEventHandler() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) {
|
|
|
|
|
|
|
|
|
|
GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus,RECORD_TYPE.CONCESSIONE,null, DISPLAY_FIELD.NAME);
|
|
|
|
|
mainPanel.showListOfConcessioniView(grpw);
|
|
|
|
|
|
|
|
|
|
GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE,
|
|
|
|
|
null, DISPLAY_FIELD.NAME);
|
|
|
|
|
mainTabPanel.showListOfConcessioniView(grpw);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
appManagerBus.addHandler(ActionOnItemEvent.TYPE, new ActionOnItemEventHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public <T> void onDoActionFired(ActionOnItemEvent<T> showItemEvent) {
|
|
|
|
|
|
|
|
|
|
if (showItemEvent != null) {
|
|
|
|
|
|
|
|
|
|
ACTION_ON_ITEM action = showItemEvent.getAction();
|
|
|
|
|
List<T> items = showItemEvent.getSelectItems();
|
|
|
|
|
|
|
|
|
|
if (items == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
T item = items.get(0);
|
|
|
|
|
|
|
|
|
|
if (item == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (item instanceof ConcessioneDV) {
|
|
|
|
|
|
|
|
|
|
final ConcessioneDV concessione = (ConcessioneDV) item;
|
|
|
|
|
GWT.log("ActionOnItemEvente item: " + concessione);
|
|
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
|
case SHOW_ON_MAP:
|
|
|
|
|
final Modal modal = new Modal(true, true);
|
|
|
|
|
modal.setCloseVisible(true);
|
|
|
|
|
final HorizontalPanel hpGetLink = new HorizontalPanel();
|
|
|
|
|
final LoaderIcon lc = new LoaderIcon("Get link...");
|
|
|
|
|
hpGetLink.add(lc);
|
|
|
|
|
modal.add(hpGetLink);
|
|
|
|
|
final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", "");
|
|
|
|
|
|
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(),
|
|
|
|
|
RECORD_TYPE.CONCESSIONE, new AsyncCallback<GeoNaItemRef>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
hpGetLink.clear();
|
|
|
|
|
Alert alert = new Alert(caught.getMessage(), AlertType.ERROR);
|
|
|
|
|
alert.setClose(false);
|
|
|
|
|
hpGetLink.add(alert);
|
|
|
|
|
newBrowserWindow.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(GeoNaItemRef result) {
|
|
|
|
|
String theURL = result.getRestrictedLink().getShortURL() != null
|
|
|
|
|
? result.getRestrictedLink().getShortURL()
|
|
|
|
|
: result.getRestrictedLink().getCompleteURL();
|
|
|
|
|
newBrowserWindow.setUrl(theURL);
|
|
|
|
|
modal.hide();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modal.show();
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case REMOVE:
|
|
|
|
|
|
|
|
|
|
String htmlMsg = "Going to delete the project with:";
|
|
|
|
|
htmlMsg += "<ul>";
|
|
|
|
|
htmlMsg += "<li>id: " + concessione.getItemId() + "</li>";
|
|
|
|
|
htmlMsg += "<li>name: " + concessione.getNome() + "</li>";
|
|
|
|
|
htmlMsg += "</ul>";
|
|
|
|
|
htmlMsg += "<br>";
|
|
|
|
|
htmlMsg += "This operation cannot be undone. Would you like to proceed?";
|
|
|
|
|
|
|
|
|
|
final DialogConfirm dialog = new DialogConfirm(null, "Delete Confirm?", htmlMsg);
|
|
|
|
|
dialog.center();
|
|
|
|
|
|
|
|
|
|
dialog.getYesButton().addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
dialog.hide();
|
|
|
|
|
final Modal modal = new Modal(true, true);
|
|
|
|
|
modal.setCloseVisible(true);
|
|
|
|
|
final HorizontalPanel hp = new HorizontalPanel();
|
|
|
|
|
final LoaderIcon lc = new LoaderIcon("Deleting Project...");
|
|
|
|
|
hp.add(lc);
|
|
|
|
|
modal.add(hp);
|
|
|
|
|
|
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().deleteRecord(
|
|
|
|
|
concessione.getItemId(), RECORD_TYPE.CONCESSIONE,
|
|
|
|
|
new AsyncCallback<Boolean>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
hp.clear();
|
|
|
|
|
Alert alert = new Alert(caught.getMessage(), AlertType.ERROR);
|
|
|
|
|
alert.setClose(false);
|
|
|
|
|
hp.add(alert);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Boolean result) {
|
|
|
|
|
if (result) {
|
|
|
|
|
hp.clear();
|
|
|
|
|
Alert alert = new Alert("Project '" + concessione.getNome()
|
|
|
|
|
+ "' deleted correclty", AlertType.INFO);
|
|
|
|
|
alert.setClose(false);
|
|
|
|
|
hp.add(alert);
|
|
|
|
|
|
|
|
|
|
appManagerBus.fireEvent(
|
|
|
|
|
new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
modal.show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void purgeFileUploaded() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MetadataProfileFormBuilderServiceAsync.Util.getInstance().purgeFilesUploaded(new AsyncCallback<Integer>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
//silent
|
|
|
|
|
|
|
|
|
|
// silent
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Integer result) {
|
|
|
|
|
GWT.log("Purged "+result+" file/s uploaded");
|
|
|
|
|
|
|
|
|
|
GWT.log("Purged " + result + " file/s uploaded");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|