In progress on Update facility

This commit is contained in:
Francesco Mangiacrapa 2022-12-12 17:28:44 +01:00
parent 1c9fd0abe4
commit 843a9b19b6
5 changed files with 165 additions and 149 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -75,7 +76,8 @@
<wb-module deploy-name="geoportal-data-entry-app-3.1.0-SNAPSHOT">
@ -151,7 +153,8 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -227,7 +230,8 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -303,7 +307,8 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -331,7 +336,11 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="geoportal-data-mapper-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-mapper/geoportal-data-mapper">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -407,7 +416,8 @@
<property name="context-root" value="geoportal-data-entry-app"/>
@ -483,7 +493,8 @@
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
@ -559,7 +570,8 @@
</wb-module>

View File

@ -388,10 +388,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);
@ -427,7 +427,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
GWT.log("Building form card for type: " + theMetaType);
GeoNaFormCardModel geonaForm = buildNewFormCardModelFromProfile(gcubeProfile, order,
metaDataProfileBean, OPERATION.UPDATE);
metaDataProfileBean, OPERATION.UPDATE, appManagerBus);
treemapOrderedGNAProfiles.put(order, geonaForm);
}
@ -437,12 +437,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);
}
}
@ -456,45 +456,14 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
}
/**
* Builds the new form card model from profile.
*
* @param gcubeProfile the gcube profile
* @param order the order
* @param metaDataProfileBean the meta data profile bean
* @param operation the operation
* @return the geo na form card model
*/
private GeoNaFormCardModel buildNewFormCardModelFromProfile(GcubeProfileDV gcubeProfile, int order,
MetaDataProfileBean metaDataProfileBean, OPERATION operation) {
// Managing Forms repeatability
int minOccurs = gcubeProfile.getMinOccurs();
minOccurs = minOccurs <= 0 ? 0 : minOccurs;
int maxOccurs = gcubeProfile.getMaxOccurs();
maxOccurs = maxOccurs <= 0 ? Integer.MAX_VALUE : maxOccurs;
// TODO MUST BE MANAGED MIN_OCCURS
ProjectFormCard cct = new ProjectFormCard(gcubeProfile.getSectionName(), gcubeProfile.getSectionTitle(), order,
maxOccurs > 1, minOccurs, maxOccurs);
GeoNaFormCardModel geoNaFormCardModel = new GeoNaFormCardModel(metaDataProfileBean, null, cct, gcubeProfile);
CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geoNaFormCardModel.getMetadataProfileBean()),
appManagerBus, operation);
geoNaFormCardModel.setMetadataForm(baseForm);
return geoNaFormCardModel;
}
private void buildNewCards(String profileID, String itemTypeTitle, Collection<GeoNaFormCardModel> orderedCards) {
projectSavedWithSuccess = false; // resetting state of saving
mainTabPanel.setLoaderVisible("Loading...", true);
geoNaMainForm.setVisibleFormActions(true);
resetUI();
//geoNaMainForm.removeTree(treeItemPanel);
// geoNaMainForm.removeTree(treeItemPanel);
geoNaMainForm.enableButtonSave(true);
mainTabPanel.setLoaderVisible("", false);
@ -774,10 +743,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 +1164,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(),
@ -1481,11 +1464,15 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modal3.setCloseVisible(true);
((Element) modal3.getElement().getChildNodes().getItem(1))
.addClassName("modal-body-custom");
//EditModeRecord emr = new EditModeRecord(appManagerBus, resultDocumentDV);
UpdateRecord ur = new UpdateRecord(appManagerBus, resultDocumentDV.getProfileID(), resultDocumentDV.getId());
int height = Window.getClientHeight() * 70 / 100;
int width = Window.getClientWidth() * 70 / 100;
modal3.setWidth(width);
modal3.setHeight(height + "px");
UpdateRecord ur = new UpdateRecord(appManagerBus, resultDocumentDV.getProfileID(),
resultDocumentDV.getId());
modal3.add(ur);
modal3.show();
break;
@ -1614,7 +1601,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
NodeItem theRootNode = (NodeItem) root.getWidget();
GeoNaFormCardModel nodeCard = theRootNode.getGeoNaFormCardModel();
GeoNaFormCardModel newNodeFormCard = buildNewFormCardModelFromProfile(nodeCard.getGcubeProfile(), -1,
nodeCard.getMetadataProfileBean(), OPERATION.UPDATE);
nodeCard.getMetadataProfileBean(), OPERATION.UPDATE, appManagerBus);
// create a new node with the same data as the root node
boolean canBeDuplicated = newNodeFormCard.getFormCard().isInternalRepeatibleForm();
@ -1708,4 +1695,36 @@ public class GeoPortalDataEntryApp implements EntryPoint {
});
}
/**
* Builds the new form card model from profile.
*
* @param gcubeProfile the gcube profile
* @param order the order
* @param metaDataProfileBean the meta data profile bean
* @param operation the operation
* @param appManagerBus the app manager bus
* @return the geo na form card model
*/
public static GeoNaFormCardModel buildNewFormCardModelFromProfile(GcubeProfileDV gcubeProfile, int order,
MetaDataProfileBean metaDataProfileBean, OPERATION operation, HandlerManager appManagerBus) {
// Managing Forms Repeatability
int minOccurs = gcubeProfile.getMinOccurs();
minOccurs = minOccurs <= 0 ? 0 : minOccurs;
int maxOccurs = gcubeProfile.getMaxOccurs();
maxOccurs = maxOccurs <= 0 ? Integer.MAX_VALUE : maxOccurs;
// TODO MUST BE MANAGED MIN_OCCURS
ProjectFormCard cct = new ProjectFormCard(gcubeProfile.getSectionName(), gcubeProfile.getSectionTitle(), order,
maxOccurs > 1, minOccurs, maxOccurs);
GeoNaFormCardModel geoNaFormCardModel = new GeoNaFormCardModel(metaDataProfileBean, null, cct, gcubeProfile);
CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geoNaFormCardModel.getMetadataProfileBean()),
appManagerBus, operation);
geoNaFormCardModel.setMetadataForm(baseForm);
return geoNaFormCardModel;
}
}

View File

@ -1,13 +1,13 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui.edit;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
import org.gcube.application.geoportaldatamapper.shared.MetaDataProfileBeanExt;
import org.gcube.application.geoportaldatamapper.shared.ProjectEdit;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp;
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync;
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.ControlGroup;
@ -22,9 +22,8 @@ import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
public class UpdateRecord extends Composite {
@ -39,10 +38,13 @@ public class UpdateRecord extends Composite {
@UiField
HTMLPanel htmlSectionContent;
@UiField
ScrollPanel scrollPanelContainer;
@UiField
HTMLPanel alertHTMLPanel;
@UiField
ControlGroup controlsControlGroup;
@ -51,6 +53,8 @@ public class UpdateRecord extends Composite {
public UpdateRecord(HandlerManager editorManagerBus, String profileID, String projectID) {
initWidget(uiBinder.createAndBindUi(this));
scrollPanelContainer.setVisible(false);
alertHTMLPanel.add(loaderProjectSections);
GeoportalDataEntryServiceAsync.Util.getInstance().getProjectEdit(profileID, projectID,
@ -58,6 +62,7 @@ public class UpdateRecord extends Composite {
@Override
public void onSuccess(ProjectEdit result) {
scrollPanelContainer.setVisible(true);
try {
alertHTMLPanel.remove(loaderProjectSections);
@ -65,33 +70,35 @@ public class UpdateRecord extends Composite {
}
listBoxSections.addItem("Select section...", "Select section...");
for (final MetaDataProfileBeanExt profileBean : result.getTheProfileBeans()) {
listBoxSections.addItem(profileBean.getType(), profileBean.getType());
listBoxSections.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
controlsControlGroup.setVisible(true);
htmlSectionContent.clear();
List<MetadataFieldWrapper> listMeta = profileBean.getMetadataFields();
if (listMeta != null && listMeta.size() > 0) {
MetadataFieldWrapper firstMeta = listMeta.get(0);
FlowPanel fp = new FlowPanel();
fp.add(new HTML(firstMeta.getFieldName()));
fp.add(new HTML(firstMeta.getCurrentValue()));
htmlSectionContent.add(fp);
}
}
});
}
listBoxSections.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
MetaDataProfileBeanExt selectedBean = result.getTheProfileBeans()
.get(listBoxSections.getSelectedIndex());
GWT.log("Change handler fired " + selectedBean);
controlsControlGroup.setVisible(true);
htmlSectionContent.clear();
GcubeProfileDV gcubeProfile = selectedBean.getGcubeProfileDV();
GeoNaFormCardModel formcard = GeoPortalDataEntryApp.buildNewFormCardModelFromProfile(gcubeProfile, 1, selectedBean, OPERATION.UPDATE, editorManagerBus);
htmlSectionContent.add(formcard.getMetadataForm());
}
});
}
@Override
public void onFailure(Throwable caught) {
scrollPanelContainer.setVisible(true);
alertHTMLPanel.remove(loaderProjectSections);
String errorMsg = caught.getMessage();

View File

@ -18,18 +18,18 @@
<g:HTMLPanel>
<g:HTMLPanel ui:field="alertHTMLPanel">
</g:HTMLPanel>
<g:ScrollPanel>
<g:ScrollPanel ui:field="scrollPanelContainer">
<b:Form type="INLINE">
<b:Fieldset addStyleNames="form-fieldset-edit">
<b:ControlGroup>
<b:ControlLabel>Select the section of the document you want to update...</b:ControlLabel>
<b:Label type="INFO">Select the section of the document you want to update...</b:Label>
<b:Controls>
<b:ListBox ui:field="listBoxSections"></b:ListBox>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="controlsControlGroup"
visible="false">
<b:ControlLabel>Manage the content of</b:ControlLabel>
<b:Label type="INFO">Manage the content of</b:Label>
<b:Controls>
<g:HTMLPanel ui:field="htmlSectionContent"></g:HTMLPanel>
</b:Controls>

View File

@ -56,28 +56,6 @@ public class TreeItemPanel {
root = new TreeItem(rootNode);
treeItemParents.put(JSON_ROOT_PATH, Arrays.asList(root));
/*
for (GeoNaFormCardModel geoNaFormCardModel : gnaCardsModels) {
GcubeProfileDV profile = geoNaFormCardModel.getGcubeProfile();
String parentName = profile.getParentName();
if (profile.getSectionName().compareTo("relazioneScavo") == 0) {
profile.setParentName(JSON_ROOT_PATH + "abstractRelazione");
}
if (profile.getSectionName().compareTo("posizionamentoScavo") == 0) {
profile.setParentName(JSON_ROOT_PATH + "immaginiRappresentative");
}
if (profile.getSectionName().compareTo("pianteFineScavo") == 0) {
profile.setParentName(JSON_ROOT_PATH + "immaginiRappresentative.posizionamentoScavo");
}
GWT.log(" print tree parentName: " + parentName + " name: " + profile.getSectionName() + " title: "
+ profile.getSectionTitle());
}*/
for (GeoNaFormCardModel geoNaFormCardModel : gnaCardsModels) {