Delete Operation done

This commit is contained in:
Francesco Mangiacrapa 2021-08-05 16:49:04 +02:00
parent bd49bd6f4e
commit 30cedd9376
15 changed files with 868 additions and 534 deletions

View File

@ -8,22 +8,28 @@ import java.util.List;
import java.util.TreeMap; import java.util.TreeMap;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; 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.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.CreateNewProjectEvent;
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEventHandler;
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent; 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.GetListOfRecordsEventHandler;
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent; 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.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.GeonaRecordsPaginatedView;
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.form.GeonaDataEntryMainForm; 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.report.ReportTemplateToHTML;
import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable.DISPLAY_FIELD; 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;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG; 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.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.CommitReport;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
@ -36,6 +42,8 @@ import com.github.gwtbootstrap.client.ui.Modal;
import com.github.gwtbootstrap.client.ui.constants.AlertType; 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.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; 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>. * Entry point classes define <code>onModuleLoad()</code>.
*/ */
public class GeoPortalDataEntryApp implements EntryPoint { public class GeoPortalDataEntryApp implements EntryPoint {
/** /**
* The message displayed to the user when the server cannot be reached or * 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 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 GeonaDataEntryMainForm geoNaMainForm;
private Collection<GeoNaFormCardModel> orderedCards; private Collection<GeoNaFormCardModel> orderedCards;
private GeonaMainPanel mainPanel; private GeonaMainTabPanel mainTabPanel;
private LinkedHashMap<String, List<GeoNaFormDataObject>> savedMap = new LinkedHashMap<String, List<GeoNaFormDataObject>>(); private LinkedHashMap<String, List<GeoNaFormDataObject>> savedMap = new LinkedHashMap<String, List<GeoNaFormDataObject>>();
private boolean projectSavedWithSuccess; private boolean projectSavedWithSuccess;
/** /**
* This is the entry point method. * This is the entry point method.
*/ */
public void onModuleLoad() { public void onModuleLoad() {
mainPanel = new GeonaMainPanel(appManagerBus); mainTabPanel = new GeonaMainTabPanel(appManagerBus);
mainPanel.setLoaderVisible("Loading...", true); mainTabPanel.setLoaderVisible("Loading...", true);
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback<GeonaISConfig>() { GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback<GeonaISConfig>() {
@Override @Override
@ -97,131 +104,137 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override @Override
public void onSuccess(GeonaISConfig result) { public void onSuccess(GeonaISConfig result) {
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);
}
});
bindEvents();
mainPanel.addFormPanel(geoNaMainForm);
RootPanel.get(DIV_PORTLET_ID).add(mainPanel);
}
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) {
}
});
}
private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards) {
projectSavedWithSuccess = false; //resetting state of saving
mainPanel.setFormPanelVisible(true);
mainPanel.setLoaderVisible("Loading...", true);
resetUI();
//ordered values
for (GeoNaFormCardModel geonaForm : orderedCards) {
//TODO TO TEST
//if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE)){
GWT.log("Adding card: "+geonaForm.getFormCardTitle()); if (result != null && result.getgRSecondaryType() != null && result.getScope() != null) {
CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()),appManagerBus); callGetMetadataProfiles(result.getScope(), result.getgRSecondaryType());
geonaForm.setMetadataForm(baseForm); } else
String key = geonaForm.getMetadataProfileBean().getType(); Window.alert(
if(geonaForm.getFormCardTitle()!=null) { ConstantsGeoPortalDataEntryApp.ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT);
key = geonaForm.getFormCardTitle().getTitle();
} }
geoNaMainForm.addForm(key, geonaForm); });
mapForms.put(key, geonaForm);
bindEvents();
//} 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) {
}
});
}
private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards) {
projectSavedWithSuccess = false; // resetting state of saving
mainTabPanel.setLoaderVisible("Loading...", true);
resetUI();
// 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);
// }
} }
geoNaMainForm.enableButtonSave(true); geoNaMainForm.enableButtonSave(true);
mainPanel.setLoaderVisible("", false); mainTabPanel.setLoaderVisible("", false);
} }
private void resetUI() { private void resetUI() {
geoNaMainForm.reset(); geoNaMainForm.reset();
mapForms.clear(); 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>();
List<GeoNaFormCardModel> listUnknownType = new ArrayList<GeoNaFormCardModel>(); List<GeoNaFormCardModel> listUnknownType = new ArrayList<GeoNaFormCardModel>();
for (MetaDataProfileBean metaDataProfileBean : listMetadataProfilesForGeona) { for (MetaDataProfileBean metaDataProfileBean : listMetadataProfilesForGeona) {
String theMetaType = metaDataProfileBean.getType().toLowerCase(); 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); 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); geonaForm.setFormCardTitle(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO);
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getOrder(), geonaForm); treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getOrder(),
}else if(theMetaType.contains(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getKey().toLowerCase())) { geonaForm);
} else if (theMetaType
.contains(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getKey().toLowerCase())) {
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO); geonaForm.setFormCardTitle(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO);
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getOrder(), geonaForm); treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getOrder(),
}else if(theMetaType.contains(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getKey().toLowerCase())) { geonaForm);
} else if (theMetaType.contains(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getKey().toLowerCase())) {
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO); geonaForm.setFormCardTitle(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO);
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getOrder(), geonaForm); 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); geonaForm.setFormCardTitle(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE);
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getOrder(), geonaForm); treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getOrder(),
}else if(theMetaType.contains(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getKey().toLowerCase())) { geonaForm);
} else if (theMetaType
.contains(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getKey().toLowerCase())) {
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE); geonaForm.setFormCardTitle(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE);
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getOrder(), geonaForm); treemapOrderedGeoNaProfiles
}else if(theMetaType.contains(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getKey().toLowerCase())) { .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); geonaForm.setFormCardTitle(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO);
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getOrder(), geonaForm); treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getOrder(), geonaForm);
}else { } else {
//adding to unknown list // adding to unknown list
listUnknownType.add(geonaForm); listUnknownType.add(geonaForm);
} }
} }
//adding unknown types // adding unknown types
for (GeoNaFormCardModel geoNaFormCardModel : listUnknownType) { for (GeoNaFormCardModel geoNaFormCardModel : listUnknownType) {
Integer highestKey = treemapOrderedGeoNaProfiles.lastKey(); Integer highestKey = treemapOrderedGeoNaProfiles.lastKey();
highestKey++; highestKey++;
treemapOrderedGeoNaProfiles.put(highestKey, geoNaFormCardModel); treemapOrderedGeoNaProfiles.put(highestKey, geoNaFormCardModel);
} }
GWT.log("Map size: "+treemapOrderedGeoNaProfiles.size()); GWT.log("Map size: " + treemapOrderedGeoNaProfiles.size());
return treemapOrderedGeoNaProfiles.values(); return treemapOrderedGeoNaProfiles.values();
} }
private void bindEvents() { private void bindEvents() {
appManagerBus.addHandler(SaveGeonaDataFormsEvent.TYPE, new SaveGeonaDataFormsHandler() { appManagerBus.addHandler(SaveGeonaDataFormsEvent.TYPE, new SaveGeonaDataFormsHandler() {
@Override @Override
public void onSave(final SaveGeonaDataFormsEvent saveGeonaDataFormsEvent) { public void onSave(final SaveGeonaDataFormsEvent saveGeonaDataFormsEvent) {
geoNaMainForm.enableButtonSave(false); geoNaMainForm.enableButtonSave(false);
if(saveGeonaDataFormsEvent.getListGeonaDataForms()!=null) { if (saveGeonaDataFormsEvent.getListGeonaDataForms() != null) {
final Modal modal = new Modal(true); final Modal modal = new Modal(true);
modal.setCloseVisible(false); modal.setCloseVisible(false);
modal.setTitle("Saving project..."); modal.setTitle("Saving project...");
@ -234,110 +247,120 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modalContainerPanel.add(loader); modalContainerPanel.add(loader);
modal.add(modalContainerPanel); modal.add(modalContainerPanel);
GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms(saveGeonaDataFormsEvent.getListGeonaDataForms(), new AsyncCallback<CommitReport>() { GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms(
saveGeonaDataFormsEvent.getListGeonaDataForms(), new AsyncCallback<CommitReport>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
modalContainerPanel.clear(); modalContainerPanel.clear();
modal.setCloseVisible(true); modal.setCloseVisible(true);
try { try {
modal.remove(loader); modal.remove(loader);
}catch (Exception e) { } catch (Exception e) {
} }
Alert alert = new Alert(caught.getMessage()); Alert alert = new Alert(caught.getMessage());
alert.setType(AlertType.ERROR); alert.setType(AlertType.ERROR);
alert.setClose(false); alert.setClose(false);
modal.add(alert); modal.add(alert);
//resetUI(); // resetUI();
geoNaMainForm.enableButtonSave(true); 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
} }
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(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
//geoNaMainForm.enableButtonSave(true); public void onSuccess(CommitReport result) {
//resetUI(); modalContainerPanel.clear();
modal.setCloseVisible(true);
if(result.getReport()!=null) { HTML recordPublished = new HTML();
modalContainerPanel.add(new ReportTemplateToHTML(result.getReport())); 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);
}
});
}
// geoNaMainForm.enableButtonSave(true);
// resetUI();
if (result.getReport() != null) {
modalContainerPanel.add(new ReportTemplateToHTML(result.getReport()));
}
}
});
modal.show(); modal.show();
}else } else
geoNaMainForm.enableButtonSave(true); geoNaMainForm.enableButtonSave(true);
} }
}); });
appManagerBus.addHandler(CreateNewProjectEvent.TYPE, new CreateNewProjectEventHandler() { appManagerBus.addHandler(CreateNewProjectEvent.TYPE, new CreateNewProjectEventHandler() {
@Override @Override
public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) { public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) {
// means the form was not submitted // means the form was not submitted
if (savedMap.size() == 0) { if (savedMap.size() == 0) {
boolean confirm = Window.confirm( boolean confirm = Window.confirm(
@ -345,10 +368,10 @@ public class GeoPortalDataEntryApp implements EntryPoint {
if (confirm) if (confirm)
buildNewCards(orderedCards); buildNewCards(orderedCards);
} else if (projectSavedWithSuccess) { } else if (projectSavedWithSuccess) {
//means the project has been saved // means the project has been saved
buildNewCards(orderedCards); buildNewCards(orderedCards);
} else { } 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?"); boolean confirm = Window.confirm("Creating a new project, the web-forms will be cleaned, Confirm?");
if (confirm) if (confirm)
buildNewCards(orderedCards); buildNewCards(orderedCards);
@ -356,37 +379,159 @@ public class GeoPortalDataEntryApp implements EntryPoint {
} }
}); });
appManagerBus.addHandler(GetListOfRecordsEvent.TYPE, new GetListOfRecordsEventHandler() { appManagerBus.addHandler(GetListOfRecordsEvent.TYPE, new GetListOfRecordsEventHandler() {
@Override @Override
public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) { public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) {
GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus,RECORD_TYPE.CONCESSIONE,null, DISPLAY_FIELD.NAME); GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE,
mainPanel.showListOfConcessioniView(grpw); 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() { private void purgeFileUploaded() {
MetadataProfileFormBuilderServiceAsync.Util.getInstance().purgeFilesUploaded(new AsyncCallback<Integer>() { MetadataProfileFormBuilderServiceAsync.Util.getInstance().purgeFilesUploaded(new AsyncCallback<Integer>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
//silent // silent
} }
@Override @Override
public void onSuccess(Integer result) { public void onSuccess(Integer result) {
GWT.log("Purged "+result+" file/s uploaded"); GWT.log("Purged " + result + " file/s uploaded");
} }
}); });
} }
} }

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client;
import java.util.List; import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
@ -16,7 +17,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Aug 4, 2021 * Aug 4, 2021
*/ */
@RemoteServiceRelativePath("geoportaldataentryservice") @RemoteServiceRelativePath("geoportaldataentryservice")
public interface GeoportalDataEntryService extends RemoteService { public interface GeoportalDataEntryService extends RemoteService {
@ -40,21 +41,30 @@ public interface GeoportalDataEntryService extends RemoteService {
/** /**
* Gets the links for. * Gets the links for.
* *
* @param itemId the item id * @param itemId the item id
* @param recordType the record type * @param recordType the record type
* @return the links for * @return the links for
* @throws Exception the exception * @throws Exception the exception
*/ */
GeoNaItemRef getLinksFor(String itemId, String recordType) throws Exception; GeoNaItemRef getLinksFor(String itemId, RECORD_TYPE recordType) throws Exception;
/** /**
* Gets the list concessioni. * Gets the list concessioni.
* *
* @param start the start * @param start the start
* @param offset the offset * @param offset the offset
* @param reloadFromService the reload from service
* @return the list concessioni * @return the list concessioni
* @throws Exception the exception * @throws Exception the exception
*/ */
SearchedData getListConcessioni(Integer start, Integer offset) throws Exception; SearchedData getListConcessioni(Integer start, Integer offset, boolean reloadFromService) throws Exception;
/**
* Delete record.
*
* @param itemId the item id
* @param recordType the record type
* @return true, if successful
*/
boolean deleteRecord(String itemId, RECORD_TYPE recordType) throws Exception;
} }

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client;
import java.util.List; import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
@ -43,8 +44,11 @@ public interface GeoportalDataEntryServiceAsync
void getGeonaInitConfig(AsyncCallback<GeonaISConfig> callback); void getGeonaInitConfig(AsyncCallback<GeonaISConfig> callback);
void getLinksFor(String itemId, String recordType, AsyncCallback<GeoNaItemRef> callback); void getLinksFor(String itemId, RECORD_TYPE recordType, AsyncCallback<GeoNaItemRef> callback);
void getListConcessioni(Integer start, Integer offset, AsyncCallback<SearchedData> callback); void getListConcessioni(Integer start, Integer offset, boolean reloadFromService, AsyncCallback<SearchedData> callback);
void deleteRecord(String itemId, RECORD_TYPE recordType, AsyncCallback<Boolean> callback);
} }

View File

@ -1,101 +0,0 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui;
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
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.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class GeonaMainPanel.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 13, 2020
*/
public class GeonaMainPanel extends Composite {
/** The geona main form panel. */
@UiField
HTMLPanel geonaMainFormPanel;
@UiField
HTMLPanel geonaListOfConcessioniPanel;
/** The loader. */
@UiField
LoaderIcon loader;
@UiField
GeonaNavigationBar geonaNavigationBar;
private HandlerManager appManagerBus;
/** The ui binder. */
private static GeonaMainPanelUiBinder uiBinder = GWT.create(GeonaMainPanelUiBinder.class);
/**
* The Interface GeonaMainPanelUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 13, 2020
*/
interface GeonaMainPanelUiBinder extends UiBinder<Widget, GeonaMainPanel> {
}
/**
* Instantiates a new geona main panel.
*
* @param appManagerBus
*/
public GeonaMainPanel(HandlerManager appManagerBus) {
initWidget(uiBinder.createAndBindUi(this));
this.appManagerBus = appManagerBus;
geonaNavigationBar.setAppManagerBus(appManagerBus);
}
/**
* Adds the form panel.
*
* @param formPanel the form panel
*/
public void addFormPanel(GeonaDataEntryMainForm formPanel) {
geonaListOfConcessioniPanel.setVisible(false);
geonaMainFormPanel.add(formPanel);
geonaMainFormPanel.setVisible(true);
}
public void showListOfConcessioniView(GeonaRecordsPaginatedView grpw) {
setFormPanelVisible(false);
geonaListOfConcessioniPanel.clear();
VerticalPanel htmllPanel = new VerticalPanel();
htmllPanel.add(grpw.getCellPanel());
htmllPanel.add(grpw.getPagerPanel());
geonaListOfConcessioniPanel.add(htmllPanel);
}
/**
* Sets the loader visible.
*
* @param txtHTML the txt HTML
* @param visible the visible
*/
public void setLoaderVisible(String txtHTML, boolean visible) {
loader.setText(txtHTML);
loader.setVisible(visible);
}
public void setFormPanelVisible(boolean bool) {
geonaMainFormPanel.setVisible(bool);
geonaListOfConcessioniPanel.setVisible(!bool);
}
}

View File

@ -1,28 +0,0 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
xmlns:m="urn:import:org.gcube.portlets.user.geoportaldataentry.client.ui"
xmlns:r="urn:import:org.gcube.portlets.user.geoportaldataentry.client.ui.utils">
<ui:style>
.important {
font-weight: bold;
}
.custom-page-header {
padding: 10px;
background-color: #f5f5f5;
margin-bottom: 10px;
border: 1px solid #eee;
}
</ui:style>
<g:HTMLPanel ui:field="geonaMainPanel">
<b:PageHeader subtext="data entry facility"
styleName="{style.custom-page-header}">GeoNa</b:PageHeader>
<m:GeonaNavigationBar ui:field="geonaNavigationBar"></m:GeonaNavigationBar>
<r:LoaderIcon ui:field="loader"></r:LoaderIcon>
<g:HTMLPanel ui:field="geonaMainFormPanel"></g:HTMLPanel>
<g:HTMLPanel ui:field="geonaListOfConcessioniPanel" visible="false"></g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -0,0 +1,142 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent;
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent;
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable.DISPLAY_FIELD;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.Tab;
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.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class GeonaMainTabPanel.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Aug 5, 2021
*/
public class GeonaMainTabPanel extends Composite {
private static GeonaMainTabPanelUiBinder uiBinder = GWT.create(GeonaMainTabPanelUiBinder.class);
/**
* The Interface GeonaMainTabPanelUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Aug 5, 2021
*/
interface GeonaMainTabPanelUiBinder extends UiBinder<Widget, GeonaMainTabPanel> {
}
/** The geona main form panel. */
@UiField
HTMLPanel geonaMainFormPanel;
@UiField
HTMLPanel geonaListOfConcessioniPanel;
/** The loader. */
@UiField
LoaderIcon loader;
@UiField
NavLink buttCreateNewProject;
@UiField
NavLink buttonReloadConcessioni;
@UiField
Tab tabNewProject;
@UiField
Tab tabGetListOfProjects;
private HandlerManager appManagerBus;
/**
* Instantiates a new geona main tab panel.
*
* @param appManagerBus the first name
*/
public GeonaMainTabPanel(HandlerManager appManagerBus) {
initWidget(uiBinder.createAndBindUi(this));
this.appManagerBus = appManagerBus;
bindEvents();
}
private void bindEvents() {
buttCreateNewProject.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
appManagerBus.fireEvent(new CreateNewProjectEvent());
}
});
buttonReloadConcessioni.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE));
}
});
tabGetListOfProjects.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE,
null, DISPLAY_FIELD.NAME);
showListOfConcessioniView(grpw);
}
});
}
/**
* Adds the form panel.
*
* @param formPanel the form panel
*/
public void addFormPanel(GeonaDataEntryMainForm formPanel) {
geonaMainFormPanel.add(formPanel);
}
public void showListOfConcessioniView(GeonaRecordsPaginatedView grpw) {
geonaListOfConcessioniPanel.clear();
VerticalPanel htmllPanel = new VerticalPanel();
htmllPanel.add(grpw.getCellPanel());
htmllPanel.add(grpw.getPagerPanel());
geonaListOfConcessioniPanel.add(htmllPanel);
}
/**
* Sets the loader visible.
*
* @param txtHTML the txt HTML
* @param visible the visible
*/
public void setLoaderVisible(String txtHTML, boolean visible) {
loader.setText(txtHTML);
loader.setVisible(visible);
}
}

View File

@ -0,0 +1,52 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
xmlns:m="urn:import:org.gcube.portlets.user.geoportaldataentry.client.ui"
xmlns:r="urn:import:org.gcube.portlets.user.geoportaldataentry.client.ui.utils">
<ui:style>
.important {
font-weight: bold;
}
.custom-page-header {
padding: 10px;
background-color: #f5f5f5;
margin-bottom: 10px;
border: 1px solid #eee;
}
</ui:style>
<g:HTMLPanel>
<b:PageHeader subtext="data entry facility"
styleName="{style.custom-page-header}">GeoNa</b:PageHeader>
<b:TabPanel tabPosition="top" ui:field="tabPanel">
<b:Tab icon="FILE_TEXT" heading="New Project" active="true"
ui:field="tabNewProject">
<b:Navbar>
<b:Brand>New Project</b:Brand>
<b:Nav>
<b:NavLink ui:field="buttCreateNewProject"
title="Create a new Project" icon="FILE">Create New Project</b:NavLink>
</b:Nav>
</b:Navbar>
<b:Divider />
<r:LoaderIcon ui:field="loader"></r:LoaderIcon>
<g:HTMLPanel ui:field="geonaMainFormPanel"></g:HTMLPanel>
</b:Tab>
<b:Tab icon="TABLE" heading="List of Projects"
ui:field="tabGetListOfProjects">
<b:Navbar>
<b:Brand>List of Projects</b:Brand>
<b:Nav>
<b:NavLink ui:field="buttonReloadConcessioni"
title="Create a new Project" icon="ROTATE_RIGHT">Reload Projects</b:NavLink>
</b:Nav>
</b:Navbar>
<b:Divider />
<g:HTMLPanel ui:field="geonaListOfConcessioniPanel"></g:HTMLPanel>
</b:Tab>
</b:TabPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -1,74 +0,0 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent;
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent;
import com.github.gwtbootstrap.client.ui.NavLink;
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.EventBus;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
public class GeonaNavigationBar extends Composite {
private static GeonaNavigationBarUiBinder uiBinder = GWT.create(GeonaNavigationBarUiBinder.class);
interface GeonaNavigationBarUiBinder extends UiBinder<Widget, GeonaNavigationBar> {
}
private EventBus eventBus;
public GeonaNavigationBar() {
initWidget(uiBinder.createAndBindUi(this));
bindEvents();
}
private void bindEvents() {
linkCreateNewProject.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
appManagerBus.fireEvent(new CreateNewProjectEvent());
}
});
linkGetListOfRecords.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE));
}
});
}
@UiField
NavLink linkCreateNewProject;
@UiField
NavLink linkGetListOfRecords;
private HandlerManager appManagerBus;
public GeonaNavigationBar(String firstName) {
initWidget(uiBinder.createAndBindUi(this));
}
/**
* Sets the app manager bus.
*
* @param appManagerBus the new app manager bus
*/
public void setAppManagerBus(HandlerManager appManagerBus) {
this.appManagerBus = appManagerBus;
}
}

View File

@ -1,20 +0,0 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
</ui:style>
<g:HTMLPanel>
<b:Navbar>
<b:Nav>
<b:NavLink ui:field="linkCreateNewProject"
title="Create a new Project">Create new Project</b:NavLink>
<b:NavLink ui:field="linkGetListOfRecords"
title="Get List of Concessioni">Get List of Concessioni</b:NavLink>
</b:Nav>
</b:Navbar>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -69,7 +69,7 @@ public class GeonaRecordsPaginatedView {
orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator(); orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator();
initPagination(ITEMS_PER_PAGE); initPagination(ITEMS_PER_PAGE);
// loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false); // loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false);
loadItemsForStatus(recordType); loadItemsForType(recordType);
} }
/** /**
@ -114,8 +114,10 @@ public class GeonaRecordsPaginatedView {
* @param startIdx the start idx * @param startIdx the start idx
* @param limit the limit * @param limit the limit
* @param resetStore the reset store * @param resetStore the reset store
* @param invalidCache the invalid cache
*/ */
private void loadNewPage(final int startIdx, final int limit, final boolean resetStore) { private void loadNewPage(final int startIdx, final int limit, final boolean resetStore,
final boolean invalidCache) {
// initFirstRangeChanged = resetStore; // initFirstRangeChanged = resetStore;
GWT.log("loadNewPage with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:" GWT.log("loadNewPage with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:"
+ resetStore + "]"); + resetStore + "]");
@ -131,18 +133,18 @@ public class GeonaRecordsPaginatedView {
getTableDataProvider().updateRowCount(ITEMS_PER_PAGE, false); getTableDataProvider().updateRowCount(ITEMS_PER_PAGE, false);
} }
loadItemsForStatus(newStartIndex, limit, serverStartIndex); loadConcessioni(newStartIndex, limit, serverStartIndex, invalidCache);
} }
/** /**
* Load items for status. * Load items for type.
* *
* @param recordType the record type * @param recordType the record type
*/ */
public void loadItemsForStatus(RECORD_TYPE recordType) { public void loadItemsForType(RECORD_TYPE recordType) {
this.recordType = recordType; this.recordType = recordType;
getCellTable().setVisibleRangeAndClearData(new Range(ITEM_START_INDEX, ITEMS_PER_PAGE), false); getCellTable().setVisibleRangeAndClearData(new Range(ITEM_START_INDEX, ITEMS_PER_PAGE), false);
loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, true); loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, true, true);
} }
/** /**
@ -185,20 +187,20 @@ public class GeonaRecordsPaginatedView {
} }
/** /**
* Load items for status. * Load concessioni.
* *
* @param <T> the generic type * @param <T> the generic type
* @param newStartIndex the new start index * @param newStartIndex the new start index
* @param limit the limit * @param limit the limit
* @param serverIndex the server index * @param serverIndex the server index
*/ */
private <T> void loadItemsForStatus(int newStartIndex, int limit, int serverIndex) { private <T> void loadConcessioni(int newStartIndex, int limit, int serverIndex, boolean invalidCache) {
showLoading(true); showLoading(true);
GWT.log("calling loadItemsForStatus with parameters [startIndex: " + newStartIndex + ", limit: " + limit GWT.log("calling loadItemsForStatus with parameters [startIndex: " + newStartIndex + ", limit: " + limit
+ ", serverIndex:" + serverIndex + "]"); + ", serverIndex:" + serverIndex + "]");
GeoPortalDataEntryApp.greetingService.getListConcessioni(newStartIndex, limit, GeoPortalDataEntryApp.greetingService.getListConcessioni(newStartIndex, limit, invalidCache,
new AsyncCallback<SearchedData>() { new AsyncCallback<SearchedData>() {
@Override @Override
@ -242,7 +244,7 @@ public class GeonaRecordsPaginatedView {
public List<ConcessioneDV> getSelectItems() { public List<ConcessioneDV> getSelectItems() {
return itemsTable.getSelectedItems(); return itemsTable.getSelectedItems();
} }
// int latestRangeStart = -1; // int latestRangeStart = -1;
// int latestRangeLenght = -1; // int latestRangeLenght = -1;
@ -269,7 +271,7 @@ public class GeonaRecordsPaginatedView {
int start = range.getStart(); int start = range.getStart();
int length = range.getLength(); int length = range.getLength();
// if(latestRangeStart!=start || latestRangeLenght!=length) { // if(latestRangeStart!=start || latestRangeLenght!=length) {
// GWT.log("ranges really changed"); // GWT.log("ranges really changed");
// latestRangeStart = start; // latestRangeStart = start;
@ -285,7 +287,7 @@ public class GeonaRecordsPaginatedView {
return; return;
} }
GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount()); GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount());
loadNewPage(start, length, false); loadNewPage(start, length, false, false);
// eventBus.fireEvent(new TableRangeViewChangedEvent<T>(start, length)); // eventBus.fireEvent(new TableRangeViewChangedEvent<T>(start, length));
} }

View File

@ -113,25 +113,6 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
this.isAsyncronusTable = dataProvider instanceof ListDataProvider ? false : true; this.isAsyncronusTable = dataProvider instanceof ListDataProvider ? false : true;
setEmptyTableMessage(NO_DATA); setEmptyTableMessage(NO_DATA);
// final CheckboxCell cellCheckBox = new CheckboxCell(true, false);
// Column<T, Boolean> checkColumn = new Column<T, Boolean>(cellCheckBox) {
// @Override
// public Boolean getValue(T object) {
// // Get the value from the selection model.
// return theSelectionModel.isSelected(object);
// }
//
// @Override
// public void render(Context context, T object, SafeHtmlBuilder sb) {
// super.render(context, object, sb);
// GWT.log("added checkbox: " + cellCheckBox + " to object: " + object);
// }
//
// };
//
// sortedCellTable.addColumn(checkColumn, "", false);
// sortedCellTable.setColumnWidth(checkColumn, 40, Unit.PX);
if (this.displayFields.contains(DISPLAY_FIELD.NAME)) { if (this.displayFields.contains(DISPLAY_FIELD.NAME)) {
// NAME // NAME
@ -418,20 +399,6 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
} }
// /**
// * To date format string.
// *
// * @param dateTime the date time
// * @return the string
// */
// public static Date toDisplayDate(Date dateTime) {
//
// if(dateTime==null)
// return null;
//
// return new Date(dtformat.format(dateTime));
// }
private String toDisplayAuthors(List<String> authors) { private String toDisplayAuthors(List<String> authors) {
String toDisplay = ""; String toDisplay = "";
if (authors == null) if (authors == null)

View File

@ -0,0 +1,152 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataentry.client.ui.utils;
import org.gcube.portlets.user.geoportaldataentry.client.resource.Images;
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.resources.client.ImageResource;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class DialogConfirm.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 19, 2015
*/
public class DialogConfirm extends DialogBox implements ClickHandler {
private DockPanel dock = new DockPanel();
private Button yesButton;
private VerticalPanel vpContainer;
private ImageResource loading = Images.ICONS.loading();
private HorizontalPanel hpButtons = new HorizontalPanel();
private Button noButton;
/**
* Instantiates a new dialog confirm.
*
* @param img the img
* @param caption the caption
* @param text the text
*/
public DialogConfirm(Image img, String caption, String text) {
//getElement().setClassName("gwt-DialogBoxNew");
dock.setSpacing(4);
dock.setWidth("100%");
setText(caption);
// setHeading(caption);
yesButton = new Button("Yes");
noButton = new Button("No", this);
noButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
hide();
}
});
vpContainer = new VerticalPanel();
vpContainer.getElement().getStyle().setMargin(20.0, Unit.PX);
vpContainer.add(new HTML(text));
hpButtons = new HorizontalPanel();
hpButtons.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
// hpButtons.getElement().getStyle().setMarginTop(20.0, Unit.PX);
hpButtons.setSpacing(3);
yesButton.getElement().getStyle().setMarginRight(20.0, Unit.PX);
hpButtons.add(yesButton);
hpButtons.add(noButton);
dock.add(hpButtons, DockPanel.SOUTH);
dock.setCellHorizontalAlignment(hpButtons, DockPanel.ALIGN_CENTER);
if (img != null)
dock.add(img, DockPanel.WEST);
dock.add(vpContainer, DockPanel.CENTER);
setWidget(dock);
// add(dock);
}
/*
* (non-Javadoc)
*
* @see
* com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event
* .dom.client.ClickEvent)
*/
@Override
public void onClick(ClickEvent event) {
// hide();
}
/**
* Loader.
*
* @param message the message
*/
public void loader(String message){
try{
dock.remove(hpButtons);
}catch(Exception e){}
vpContainer.clear();
HorizontalPanel hpMask = new HorizontalPanel();
hpMask.add(new Image(loading));
HTML html = new HTML(message);
html.getElement().getStyle().setMarginLeft(5, Unit.PX);
hpMask.add(html);
vpContainer.add(hpMask);
}
/**
* Adds the to center panel.
*
* @param w the w
*/
public void addToCenterPanel(Widget w) {
vpContainer.add(w);
}
/**
* Gets the dock.
*
* @return the dock
*/
public DockPanel getDock() {
return dock;
}
/**
* Gets the yes button.
*
* @return the yes button
*/
public Button getYesButton() {
return yesButton;
}
/**
* Gets the no button.
*
* @return the no button
*/
public Button getNoButton() {
return noButton;
}
}

View File

@ -0,0 +1,30 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui.utils;
import com.google.gwt.core.client.JavaScriptObject;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
* Sep 4, 2013
*
*/
public final class NewBrowserWindow extends JavaScriptObject {
// All types that extend JavaScriptObject must have a protected,
// no-args constructor.
protected NewBrowserWindow() {
}
public static native NewBrowserWindow open(String url, String target,
String options) /*-{
return $wnd.open(url, target, options);
}-*/;
public native void close() /*-{
this.close();
}-*/;
public native void setUrl(String url) /*-{
if (this.location) {
this.location = url;
}
}-*/;
}

View File

@ -16,9 +16,11 @@ import org.gcube.application.geoportal.common.rest.MongoConcessioni;
import org.gcube.application.geoportal.common.rest.TempFile; import org.gcube.application.geoportal.common.rest.TempFile;
import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
import org.gcube.application.geoportalcommon.GeoportalCommon; import org.gcube.application.geoportalcommon.GeoportalCommon;
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; 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.GeoportalDataEntryService;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport.STATE; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport.STATE;
@ -391,12 +393,13 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
* @throws Exception the exception * @throws Exception the exception
*/ */
@Override @Override
public GeoNaItemRef getLinksFor(String itemId, String recordType) throws Exception { public GeoNaItemRef getLinksFor(String itemId, RECORD_TYPE recordType) throws Exception {
LOG.info("getLinksFor called"); LOG.info("getLinksFor called");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoportalCommon gc = new GeoportalCommon(); GeoNaDataViewerProfile grViewerProfile = SessionUtil.getGeportalViewerResourceProfile(getThreadLocalRequest());
GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toLowerCase()); GeoportalCommon gc = new GeoportalCommon(grViewerProfile);
GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toString().toLowerCase());
item = gc.getPublicLinksFor(item); item = gc.getPublicLinksFor(item);
LOG.info("Returning: " + item); LOG.info("Returning: " + item);
return item; return item;
@ -405,17 +408,20 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
/** /**
* Gets the list concessioni. * Gets the list concessioni.
* *
* @param start the start * @param start the start
* @param offset the offset * @param limit the limit
* @param reloadFromService if true, ignore the concessioni saved in session and
* reload them from service
* @return the list concessioni * @return the list concessioni
* @throws Exception the exception * @throws Exception the exception
*/ */
@Override @Override
public SearchedData getListConcessioni(Integer start, Integer limit) throws Exception { public SearchedData getListConcessioni(Integer start, Integer limit, boolean reloadFromService) throws Exception {
LOG.info("getListConcessioni called wit start: "+start + ", limit: "+limit); LOG.info("getListConcessioni called wit start: " + start + ", limit: " + limit);
try { try {
List<Concessione> listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest()); List<Concessione> listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest(),
reloadFromService);
int listConcessioniSize = listOfConcessioni.size(); int listConcessioniSize = listOfConcessioni.size();
List<Concessione> toReturn = new ArrayList<Concessione>(); List<Concessione> toReturn = new ArrayList<Concessione>();
@ -425,27 +431,17 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
toReturn.addAll(listOfConcessioni); toReturn.addAll(listOfConcessioni);
startIndex = 0; startIndex = 0;
limitIndex = listConcessioniSize; limitIndex = listConcessioniSize;
}else { } else {
// if (start < 0)
// start = 0;
//
// if (start > listConcessioniSize)
// start = listConcessioniSize;
//
// if (limit > listConcessioniSize)
// limit = listConcessioniSize;
startIndex = start; startIndex = start;
limitIndex = start + limit; limitIndex = start + limit;
if(limitIndex>listConcessioniSize) { if (limitIndex > listConcessioniSize) {
limitIndex = listConcessioniSize; limitIndex = listConcessioniSize;
} }
} }
SearchedData searchedData = new SearchedData(start, limit, startIndex, false); SearchedData searchedData = new SearchedData(start, limit, startIndex, false);
searchedData.setTotalItems(listConcessioniSize); searchedData.setTotalItems(listConcessioniSize);
toReturn = listOfConcessioni.subList(startIndex, limitIndex); toReturn = listOfConcessioni.subList(startIndex, limitIndex);
List<ConcessioneDV> toReturnList = new ArrayList<ConcessioneDV>(toReturn.size()); List<ConcessioneDV> toReturnList = new ArrayList<ConcessioneDV>(toReturn.size());
@ -456,7 +452,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
} }
searchedData.setData(toReturnList); searchedData.setData(toReturnList);
if (listConcessioniSize == limit || listConcessioniSize == 0) { if (listConcessioniSize == limit || listConcessioniSize == 0) {
LOG.debug("Page completed returning " + listConcessioniSize + " items"); LOG.debug("Page completed returning " + listConcessioniSize + " items");
int newOffset = startIndex + start; int newOffset = startIndex + start;
@ -502,4 +498,28 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
} }
} }
} }
@Override
public boolean deleteRecord(String itemId, RECORD_TYPE recordType) throws Exception {
try {
if (itemId == null)
throw new Exception("Item id is null");
if (recordType.equals(RECORD_TYPE.CONCESSIONE)) {
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
ServiceUtil serviceUtil = new ServiceUtil();
MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni();
clientMongo.deleteById(itemId);
return true;
}
return false;
} catch (Exception e) {
LOG.error("Error on deleting the project with item id: " + itemId, e);
throw new Exception(
"Error occurred on deleting the project with id: " + itemId + ". Error: " + e.getMessage());
}
}
} }

View File

@ -12,6 +12,8 @@ import javax.servlet.http.HttpSession;
import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportal.common.rest.MongoConcessioni;
import org.gcube.application.geoportalcommon.GeoportalCommon;
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
@ -26,16 +28,16 @@ import org.slf4j.LoggerFactory;
import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.service.UserLocalServiceUtil;
/** /**
* The Class SessionUtil. * The Class SessionUtil.
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Oct 20, 2020 * Oct 20, 2020
*/ */
public class SessionUtil { public class SessionUtil {
private static final String GEONA_DATAVIEWER_PROFILE = "GEONA_DATAVIEWER_PROFILE";
private static final String LIST_OF_CONCESSIONI = "LIST_OF_CONCESSIONI"; private static final String LIST_OF_CONCESSIONI = "LIST_OF_CONCESSIONI";
/** The log. */ /** The log. */
private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class); private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class);
@ -49,7 +51,7 @@ public class SessionUtil {
try { try {
UserLocalServiceUtil.getService(); UserLocalServiceUtil.getService();
return true; return true;
}catch (Exception ex) { } catch (Exception ex) {
LOG.debug("Development Mode ON"); LOG.debug("Development Mode ON");
return false; return false;
} }
@ -61,9 +63,9 @@ public class SessionUtil {
* @param request the request * @param request the request
* @return a GcubeUser object * @return a GcubeUser object
*/ */
public static GCubeUser getCurrentUser(HttpServletRequest request){ public static GCubeUser getCurrentUser(HttpServletRequest request) {
if(request == null) if (request == null)
throw new IllegalArgumentException("HttpServletRequest is null!"); throw new IllegalArgumentException("HttpServletRequest is null!");
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
@ -75,26 +77,27 @@ public class SessionUtil {
/** /**
* Retrieve the current scope by using the portal manager. * Retrieve the current scope by using the portal manager.
* *
* @param request the request * @param request the request
* @param setContextsInThread set the scope and the security token into current thread * @param setContextsInThread set the scope and the security token into current
* thread
* @return a GcubeUser object * @return a GcubeUser object
*/ */
public static String getCurrentContext(HttpServletRequest request, boolean setContextsInThread){ public static String getCurrentContext(HttpServletRequest request, boolean setContextsInThread) {
if(request == null) if (request == null)
throw new IllegalArgumentException("HttpServletRequest is null!"); throw new IllegalArgumentException("HttpServletRequest is null!");
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
String context = pContext.getCurrentScope(request); String context = pContext.getCurrentScope(request);
if(setContextsInThread) { if (setContextsInThread) {
GCubeUser user = getCurrentUser(request); GCubeUser user = getCurrentUser(request);
String token = pContext.getCurrentUserToken(context, user.getUsername()); String token = pContext.getCurrentUserToken(context, user.getUsername());
if(context!=null) if (context != null)
ScopeProvider.instance.set(context); ScopeProvider.instance.set(context);
if(token!=null) if (token != null)
SecurityTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
} }
@ -107,11 +110,11 @@ public class SessionUtil {
* @param scope the scope * @param scope the scope
* @return the group from scope * @return the group from scope
* @throws UserManagementSystemException the user management system exception * @throws UserManagementSystemException the user management system exception
* @throws GroupRetrievalFault the group retrieval fault * @throws GroupRetrievalFault the group retrieval fault
*/ */
public static GCubeGroup getGroupFromScope(String scope) throws UserManagementSystemException, GroupRetrievalFault{ public static GCubeGroup getGroupFromScope(String scope) throws UserManagementSystemException, GroupRetrievalFault {
if(scope == null || scope.isEmpty()) if (scope == null || scope.isEmpty())
throw new IllegalArgumentException("Scope is missing here!!"); throw new IllegalArgumentException("Scope is missing here!!");
GroupManager gm = new LiferayGroupManager(); GroupManager gm = new LiferayGroupManager();
@ -119,18 +122,24 @@ public class SessionUtil {
return gm.getGroup(groupId); return gm.getGroup(groupId);
} }
/** /**
* Gets the list of concessioni. * Gets the list of concessioni.
* *
* @param httpServletRequest the http servlet request * @param httpServletRequest the http servlet request
* @param reloadFromService the reload from service
* @return the list of concessioni * @return the list of concessioni
* @throws Exception the exception * @throws Exception the exception
*/ */
public static List<Concessione> getListOfConcessioni(HttpServletRequest httpServletRequest) throws Exception { public static List<Concessione> getListOfConcessioni(HttpServletRequest httpServletRequest,
boolean reloadFromService) throws Exception {
HttpSession session = httpServletRequest.getSession(); HttpSession session = httpServletRequest.getSession();
List<Concessione> listOfConcessioni = (List<Concessione>) session.getAttribute(LIST_OF_CONCESSIONI); List<Concessione> listOfConcessioni = (List<Concessione>) session.getAttribute(LIST_OF_CONCESSIONI);
// setting null to force reloading from service
if (reloadFromService)
listOfConcessioni = null;
if (listOfConcessioni == null) { if (listOfConcessioni == null) {
listOfConcessioni = new ArrayList<Concessione>(); listOfConcessioni = new ArrayList<Concessione>();
LOG.info("Loading list of concessione from client mongo"); LOG.info("Loading list of concessione from client mongo");
@ -142,16 +151,40 @@ public class SessionUtil {
while (concessioni.hasNext()) { while (concessioni.hasNext()) {
Concessione concessione = (Concessione) concessioni.next(); Concessione concessione = (Concessione) concessioni.next();
listOfConcessioni.add(concessione); listOfConcessioni.add(concessione);
} }
} }
LOG.debug("Got list of concessioni from client mongo: "+listOfConcessioni); LOG.debug("Got list of concessioni from client mongo: " + listOfConcessioni);
session.setAttribute(LIST_OF_CONCESSIONI, listOfConcessioni); session.setAttribute(LIST_OF_CONCESSIONI, listOfConcessioni);
LOG.info("Saved in session list of concessioni from client mongo with size: "+listOfConcessioni.size()); LOG.info("Saved in session list of concessioni from client mongo with size: " + listOfConcessioni.size());
}else } else
LOG.info("list of concessioni presents in session"); LOG.info("list of concessioni presents in session");
LOG.info("read list of concessioni with size: "+listOfConcessioni.size()); LOG.info("read list of concessioni with size: " + listOfConcessioni.size());
return listOfConcessioni; return listOfConcessioni;
} }
/**
* Gets the geportal viewer resource profile.
*
* @param httpServletRequest the http servlet request
* @return the geportal viewer resource profile
* @throws Exception the exception
*/
public static GeoNaDataViewerProfile getGeportalViewerResourceProfile(HttpServletRequest httpServletRequest)
throws Exception {
HttpSession session = httpServletRequest.getSession();
GeoNaDataViewerProfile geoNaDataViewerProfile = (GeoNaDataViewerProfile) session
.getAttribute(GEONA_DATAVIEWER_PROFILE);
if (geoNaDataViewerProfile == null) {
GeoportalCommon gc = new GeoportalCommon();
geoNaDataViewerProfile = gc.getGeoNaDataViewProfile(null);
session.setAttribute(GEONA_DATAVIEWER_PROFILE, geoNaDataViewerProfile);
}
return geoNaDataViewerProfile;
}
} }