#24049 Fixed "Show on Map" changing its behaviour

This commit is contained in:
Francesco Mangiacrapa 2022-12-13 15:30:47 +01:00
parent 1992d2227a
commit f053195d92
2 changed files with 99 additions and 58 deletions

View File

@ -61,7 +61,6 @@ 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.ModalConfirm;
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.GNADataEntryExtendedConfigProfile;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
@ -78,6 +77,7 @@ import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Modal;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.LabelType;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
@ -91,6 +91,7 @@ import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
@ -388,10 +389,10 @@ public class GeoPortalDataEntryApp implements EntryPoint {
resetUI();
mainTabPanel.setPageHeader(handlerDeclarationDV);
//TODO AVOIDING THE CACHE
//TODO I NEED TO CHECK WHY THE BY USING THE CACHE THE WEB-FORM IS FULL (EQUAL TO PREVIOUS ONE) AND NOT RESET PERFORMED
// TODO AVOIDING THE CACHE
// TODO I NEED TO CHECK WHY THE BY USING THE CACHE THE WEB-FORM IS FULL (EQUAL
// TO PREVIOUS ONE) AND NOT RESET PERFORMED
// List<GeoNaFormCardModel> cardsPerIT = geoportalCaches.getGcubeProfilePerItemType(handlerDeclarationDV.getItemType());
// if (cardsPerIT != null) {
// GWT.log("Profiles/Cards per Item Type are: " + cardsPerIT);
@ -437,12 +438,12 @@ public class GeoPortalDataEntryApp implements EntryPoint {
// ordered values
Collection<GeoNaFormCardModel> gnaCardsModels = treemapOrderedGNAProfiles.values();
GWT.log("TreeMap values: " + gnaCardsModels);
List<GeoNaFormCardModel> listGNAFormCardModel = new ArrayList<GeoNaFormCardModel>(gnaCardsModels);
List<GeoNaFormCardModel> listGNAFormCardModel = new ArrayList<GeoNaFormCardModel>(
gnaCardsModels);
geoportalCaches.putGcubeProfilePerItemType(handlerDeclarationDV.getItemType(),
listGNAFormCardModel);
// orderedCards.addAll(new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
buildNewCards(profileID, handlerDeclarationDV.getItemType(),
listGNAFormCardModel);
buildNewCards(profileID, handlerDeclarationDV.getItemType(), listGNAFormCardModel);
}
}
@ -493,8 +494,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
mainTabPanel.setLoaderVisible("Loading...", true);
geoNaMainForm.setVisibleFormActions(true);
resetUI();
//geoNaMainForm.removeTree(treeItemPanel);
// geoNaMainForm.removeTree(treeItemPanel);
geoNaMainForm.enableButtonSave(true);
mainTabPanel.setLoaderVisible("", false);
@ -774,10 +775,10 @@ public class GeoPortalDataEntryApp implements EntryPoint {
public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) {
GWT.log("Fired: " + getListOfRecordsEvent);
SearchingFilter searchingFilter = getListOfRecordsEvent.getSearchingFilter();
CacheSearchingFilterParametersFromConfig seachingFilterParameters =
geoportalCaches.getFilterParametersForProfileId(getListOfRecordsEvent.getProfileID(), GEOPORTAL_DATA_HANDLER.geoportal_data_list);
CacheSearchingFilterParametersFromConfig seachingFilterParameters = geoportalCaches
.getFilterParametersForProfileId(getListOfRecordsEvent.getProfileID(),
GEOPORTAL_DATA_HANDLER.geoportal_data_list);
// CacheSearchingFilterParametersFromConfig seachingFilterParameters = geoportalCaches
// .getFilterParametersForProfileId(getListOfRecordsEvent.getProfileID());
@ -1195,56 +1196,70 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modalContainerPanel.remove(loader);
} catch (Exception e) {
}
String stepString = wActionOnItem.getAction().getCallSteps().length==1?"Step":"Steps";
String stepString = wActionOnItem.getAction().getCallSteps().length == 1
? "Step"
: "Steps";
String stepsToString = "";
for (String step : wActionOnItem.getAction().getCallSteps()) {
stepsToString+=step+", ";
stepsToString += step + ", ";
}
Alert alert = new Alert(
stepString +" "+ stepsToString
+ "performed correclty!");
stepString + " " + stepsToString + "performed correclty!");
alert.setType(AlertType.INFO);
alert.setClose(false);
modal.add(alert);
GeoportalDataEntryServiceAsync.Util.getInstance().getResultDocumentFoProjectByID(result.getProfileID(), result.getId(), new AsyncCallback<ResultDocumentDV>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
GeoportalDataEntryServiceAsync.Util.getInstance()
.getResultDocumentFoProjectByID(result.getProfileID(),
result.getId(), new AsyncCallback<ResultDocumentDV>() {
@Override
public void onSuccess(ResultDocumentDV theResultDocument) {
VerticalPanel vp = new VerticalPanel();
vp.getElement().getStyle().setMarginTop(20, Unit.PX);
vp.add(new Label("Check outcome in the Publication Report"));
Button buttonShowPublicationReport = new Button(
"Show Publication Report");
buttonShowPublicationReport.setType(ButtonType.INFO);
buttonShowPublicationReport.addClickHandler(new ClickHandler() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
@Override
public void onClick(ClickEvent event) {
modal.hide();
appManagerBus.fireEvent(new OperationOnItemEvent<DocumentDV>(
Arrays.asList(theResultDocument),
OPERATION_ON_ITEM.VIEW_REPORT));
}
}
});
buttonShowPublicationReport.getElement().getStyle().setMarginTop(10, Unit.PX);
buttonShowPublicationReport.getElement().getStyle().setMarginBottom(20, Unit.PX);
vp.add(buttonShowPublicationReport);
@Override
public void onSuccess(
ResultDocumentDV theResultDocument) {
VerticalPanel vp = new VerticalPanel();
vp.getElement().getStyle().setMarginTop(20,
Unit.PX);
vp.add(new Label(
"Check outcome in the Publication Report"));
Button buttonShowPublicationReport = new Button(
"Show Publication Report");
buttonShowPublicationReport
.setType(ButtonType.INFO);
buttonShowPublicationReport
.addClickHandler(new ClickHandler() {
modal.add(vp);
}
});
@Override
public void onClick(
ClickEvent event) {
modal.hide();
appManagerBus.fireEvent(
new OperationOnItemEvent<DocumentDV>(
Arrays.asList(
theResultDocument),
OPERATION_ON_ITEM.VIEW_REPORT));
}
});
buttonShowPublicationReport.getElement()
.getStyle().setMarginTop(10, Unit.PX);
buttonShowPublicationReport.getElement()
.getStyle()
.setMarginBottom(20, Unit.PX);
vp.add(buttonShowPublicationReport);
modal.add(vp);
}
});
appManagerBus.fireEvent(new GetListOfRecordsEvent(false,
resultDocumentDV.getProfileID(),
@ -1398,32 +1413,58 @@ public class GeoPortalDataEntryApp implements EntryPoint {
case VIEW_ON_MAP: {
final Modal modal = new Modal(true, true);
modal.setTitle("Show on Map the Project...");
modal.setCloseVisible(true);
final HorizontalPanel hpGetLink = new HorizontalPanel();
final LoaderIcon lc = new LoaderIcon("Just moment getting link...");
hpGetLink.add(lc);
modal.add(hpGetLink);
final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", "");
// final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank",
// "");
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(resultDocumentDV.getId(),
resultDocumentDV.getProfileID(), new AsyncCallback<GeoportalItemReferences>() {
@Override
public void onFailure(Throwable caught) {
hpGetLink.clear();
try {
hpGetLink.setVisible(false);
modal.remove(hpGetLink);
} catch (Exception e) {
// TODO: handle exception
}
Alert alert = new Alert(caught.getMessage(), AlertType.ERROR);
alert.setClose(false);
hpGetLink.add(alert);
newBrowserWindow.close();
// newBrowserWindow.close();
}
@Override
public void onSuccess(GeoportalItemReferences result) {
try {
hpGetLink.setVisible(false);
modal.remove(hpGetLink);
} catch (Exception e) {
// TODO: handle exception
}
String theURL = result.getRestrictedLink().getShortURL() != null
? result.getRestrictedLink().getShortURL()
: result.getRestrictedLink().getCompleteURL();
newBrowserWindow.setUrl(theURL);
modal.hide();
// newBrowserWindow.setUrl(theURL);
Anchor anchor = new Anchor(theURL);
anchor.setHref(theURL);
anchor.setTarget("_blank");
anchor.setTitle(
"Show on Map the project with id: " + resultDocumentDV.getId());
com.github.gwtbootstrap.client.ui.Label label = new com.github.gwtbootstrap.client.ui.Label(
"Go to Map by clicking the link");
label.setType(LabelType.SUCCESS);
modal.add(label);
modal.add(new HTML("<br>"));
modal.add(anchor);
}
});

View File

@ -482,7 +482,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
.getGeportalViewerResourceProfile(getThreadLocalRequest());
GeoportalCommon gc = new GeoportalCommon(grViewerProfile);
GeoportalItemReferences item = new GeoportalItemReferences(itemId, profileID);
item = gc.getPublicLinksFor(item, false);
item = gc.getPublicLinksFor(item, true);
LOG.info("Returning: " + item);
return item;
}