diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index dfc3851..7cce3aa 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,6 @@ - + + @@ -75,7 +76,8 @@ - + + @@ -151,7 +153,8 @@ - + + @@ -227,7 +230,8 @@ - + + @@ -303,7 +307,8 @@ - + + @@ -331,7 +336,11 @@ - + + uses + + + @@ -407,7 +416,8 @@ - + + @@ -483,7 +493,8 @@ - + + @@ -559,7 +570,8 @@ - + + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index b8dff5c..42f3787 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -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 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 gnaCardsModels = treemapOrderedGNAProfiles.values(); GWT.log("TreeMap values: " + gnaCardsModels); - List listGNAFormCardModel = new ArrayList(gnaCardsModels); + List listGNAFormCardModel = new ArrayList( + gnaCardsModels); geoportalCaches.putGcubeProfilePerItemType(handlerDeclarationDV.getItemType(), listGNAFormCardModel); // orderedCards.addAll(new ArrayList(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 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() { - @Override - public void onFailure(Throwable caught) { - // TODO Auto-generated method stub - - } + GeoportalDataEntryServiceAsync.Util.getInstance() + .getResultDocumentFoProjectByID(result.getProfileID(), + result.getId(), new AsyncCallback() { - @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( - 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( + 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; + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateRecord.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateRecord.java index b1ba221..b28c7e2 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateRecord.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateRecord.java @@ -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 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(); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateRecord.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateRecord.ui.xml index 42d0d65..1511b3d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateRecord.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateRecord.ui.xml @@ -18,18 +18,18 @@ - + - Select the section of the document you want to update... + Select the section of the document you want to update... - Manage the content of + Manage the content of diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/tree/TreeItemPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/tree/TreeItemPanel.java index 97bfa56..588eb30 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/tree/TreeItemPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/tree/TreeItemPanel.java @@ -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) {