diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index c10e08c..ef32b37 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,10 @@ - + + + + + + @@ -36,7 +41,12 @@ - + + + + + + @@ -73,7 +83,12 @@ - + + + + + + @@ -110,7 +125,12 @@ - + + + + + + @@ -156,7 +176,12 @@ uses - + + + + + + @@ -193,7 +218,12 @@ - + + + + + + @@ -230,7 +260,12 @@ - + + + + + + @@ -267,7 +302,12 @@ - + + + + + + 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 c2a38f2..f30a25f 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 @@ -15,12 +15,12 @@ import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole; import org.gcube.application.geoportalcommon.shared.config.RoleRights; import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE; import org.gcube.application.geoportalcommon.shared.geoportal.HandlerDeclarationDV; +import org.gcube.application.geoportalcommon.shared.geoportal.LifecycleInformationDV; import org.gcube.application.geoportalcommon.shared.geoportal.UseCaseDescriptorDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; -import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; @@ -284,29 +284,6 @@ public class GeoPortalDataEntryApp implements EntryPoint { private void loadGeoportalConfigs(final String scope) { GWT.log("loading GeoportalConfigsAndBuildCards in the scope: " + scope); orderedCards = new ArrayList(); -// // TODO PASS THE RIGHT ID -// GeoportalDataEntryServiceAsync.Util.getInstance().getListDocumentConfigurationForId("id", -// new AsyncCallback>() { -// -// @Override -// public void onFailure(Throwable caught) { -// GWT.log("caught: " + caught); -// Window.alert(caught.toString()); -// } -// -// @Override -// public void onSuccess(List result) { -// listUCDescriptors = result; -// GWT.log("List: " + result); -// -// if (result == null || result.size() == 0) { -// Window.alert("No Configuration found in this scope. Please contact the support"); -// return; -// } -// -// setListDocumentConfig(listUCDescriptors); -// } -// }); GeoportalDataEntryServiceAsync.Util.getInstance().getListUseCaseDescriptors(null, new AsyncCallback>() { @@ -372,7 +349,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { } - private void createNewDataEntyFor(HandlerDeclarationDV handlerDeclarationDV, List listGPs) { + private void createNewDataEntyFor(String profileID, HandlerDeclarationDV handlerDeclarationDV, + List listGPs) { dataEntryProjectCreated = true; mainTabPanel.setLoaderVisible("Loading...", true); orderedCards.clear(); @@ -383,7 +361,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { if (cardsPerIT != null) { orderedCards.addAll(cardsPerIT); - buildNewCards(orderedCards, OPERATION.NEW); + buildNewCards(profileID, orderedCards, OPERATION.NEW); return; } @@ -436,7 +414,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { orderedCards.addAll(gnaCardsModels); mapGcubeProfilePerItemType.put(handlerDeclarationDV.getItemType(), new ArrayList(gnaCardsModels)); - buildNewCards(orderedCards, OPERATION.UPDATE); + buildNewCards(profileID, orderedCards, OPERATION.UPDATE); } } @@ -450,7 +428,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { } } - private void buildNewCards(Collection orderedCards, OPERATION operation) { + private void buildNewCards(String profileID, Collection orderedCards, OPERATION operation) { projectSavedWithSuccess = false; // resetting state of saving mainTabPanel.setLoaderVisible("Loading...", true); geoNaMainForm.setVisibleFormActions(true); @@ -469,7 +447,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { if (geonaForm.getFormCard() != null) { key = geonaForm.getFormCard().getTitle(); } - geoNaMainForm.addForm(key, geonaForm); + // profileID is unique for all the cards/forms + geoNaMainForm.addForm(profileID, key, geonaForm); mapForms.put(key, geonaForm); // } @@ -507,7 +486,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal.add(modalContainerPanel); GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms( - saveGeonaDataFormsEvent.getListGeonaDataForms(), new AsyncCallback() { + saveGeonaDataFormsEvent.getProfileID(), saveGeonaDataFormsEvent.getListGeonaDataForms(), + new AsyncCallback() { @Override public void onFailure(Throwable caught) { @@ -529,41 +509,56 @@ public class GeoPortalDataEntryApp implements EntryPoint { public void onSuccess(CommitReport result) { modalContainerPanel.clear(); modal.setCloseVisible(true); - HTML recordPublished = new HTML(); - ValidationReportDV vr = result.getValidationReportDV(); - switch (vr.getStatus()) { - case PASSED: + + LifecycleInformationDV lcDV = result.getLifecycleInformation(); + + HTML htmlPhase = new HTML(); + htmlPhase.setHTML("Current phase: " + lcDV.getPhase() + ""); + + HTML htmlStep = new HTML(); + htmlStep.setHTML("Invoked Step: " + lcDV.getLastInvokedStep() + ""); + + HTML lastOperationStatus = new HTML(); + switch (lcDV.getLastOperationStatus()) { + case OK: { String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, "SUCCESS"); - recordPublished.setHTML("Record Published with " + success); + String msg = lcDV.getLastInvokedStep() + "terminated with: " + success; + lastOperationStatus.setHTML(msg); projectSavedWithSuccess = true; - String msg = "Record published with success"; geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true); purgeFileUploaded(); break; - case WARNING: + } + case WARNING: { String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, "WARNING"); - recordPublished.setHTML("Record Published with " + warning); + String msg = lcDV.getLastInvokedStep() + "terminated with: " + warning; + lastOperationStatus.setHTML(msg); geoNaMainForm.enableButtonSave(true); break; - case ERROR: + } + case ERROR: { String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", "ERROR"); - recordPublished.setHTML(error + " on publishing the Record"); + String msg = lcDV.getLastInvokedStep() + "terminated with: " + error; + lastOperationStatus.setHTML(msg); geoNaMainForm.enableButtonSave(true); break; + } default: break; } - modalContainerPanel.add(recordPublished); + modalContainerPanel.add(htmlPhase); + modalContainerPanel.add(htmlStep); + modalContainerPanel.add(lastOperationStatus); - if (result.getMongoId() != null) { - modalContainerPanel.add(new HTML("Record id: " + (result.getMongoId()))); + if (result.getProjectID() != null) { + modalContainerPanel.add(new HTML("Record id: " + (result.getProjectID()))); try { - savedMap.put(result.getMongoId(), + savedMap.put(result.getProjectID(), saveGeonaDataFormsEvent.getListGeonaDataForms()); } catch (Exception e) { // TODO: handle exception @@ -574,7 +569,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { hpGetLink.add(lc); modalContainerPanel.add(hpGetLink); GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor( - result.getMongoId(), RECORD_TYPE.CONCESSIONE, + result.getProjectID(), saveGeonaDataFormsEvent.getProfileID(), new AsyncCallback() { @Override @@ -589,7 +584,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { String theURL = result.getRestrictedLink().getShortURL() != null ? result.getRestrictedLink().getShortURL() : result.getRestrictedLink().getCompleteURL(); - String htmlLink = ""; HTML html = new HTML(htmlLink); hpGetLink.add(html); @@ -601,8 +596,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { // geoNaMainForm.enableButtonSave(true); // resetUI(); - if (vr.getAsJSONString() != null) { - modalContainerPanel.add(new ReportTemplateToHTML(vr.getAsJSONString(), false)); + if (lcDV.getAsJSONString() != null) { + modalContainerPanel.add(new ReportTemplateToHTML(lcDV.getAsJSONString(), false)); } } @@ -619,9 +614,10 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) { - GWT.log("Crate new project"); + GWT.log("Create new project"); if (!dataEntryProjectCreated) { - createNewDataEntyFor(newProjectEvent.getHandler(), newProjectEvent.getListGcubeProfiles()); + createNewDataEntyFor(newProjectEvent.getProfileID(), newProjectEvent.getHandler(), + newProjectEvent.getListGcubeProfiles()); return; } @@ -636,7 +632,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onClick(ClickEvent event) { confirm.hide(); - createNewDataEntyFor(newProjectEvent.getHandler(), newProjectEvent.getListGcubeProfiles()); + createNewDataEntyFor(newProjectEvent.getProfileID(), newProjectEvent.getHandler(), + newProjectEvent.getListGcubeProfiles()); // buildNewCards(orderedCards, OPERATION.NEW); } @@ -646,7 +643,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { } else if (projectSavedWithSuccess) { // means the project has been saved - createNewDataEntyFor(newProjectEvent.getHandler(), newProjectEvent.getListGcubeProfiles()); + createNewDataEntyFor(newProjectEvent.getProfileID(), newProjectEvent.getHandler(), + newProjectEvent.getListGcubeProfiles()); // buildNewCards(orderedCards, OPERATION.NEW); } else { @@ -658,7 +656,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onClick(ClickEvent event) { confirm.hide(); - createNewDataEntyFor(newProjectEvent.getHandler(), newProjectEvent.getListGcubeProfiles()); + createNewDataEntyFor(newProjectEvent.getProfileID(), newProjectEvent.getHandler(), + newProjectEvent.getListGcubeProfiles()); } @@ -752,7 +751,9 @@ public class GeoPortalDataEntryApp implements EntryPoint { } if (items == null || items.size() == 0) { - Window.alert("You must select a record in the table"); + DialogInform di = new DialogInform(null, "No selection", + "You must select a record in the table"); + di.center(); return; } @@ -813,7 +814,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", ""); GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(), - RECORD_TYPE.CONCESSIONE, new AsyncCallback() { + showItemEvent.getProfileID(), new AsyncCallback() { @Override public void onFailure(Throwable caught) { hpGetLink.clear(); @@ -923,9 +924,9 @@ public class GeoPortalDataEntryApp implements EntryPoint { alert.setClose(false); hp.add(alert); - appManagerBus.fireEvent( - new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,grpw.getProfileID(),null, - mainTabPanel.getCurrentSortFilter())); + appManagerBus.fireEvent(new GetListOfRecordsEvent( + RECORD_TYPE.CONCESSIONE, grpw.getProfileID(), null, + mainTabPanel.getCurrentSortFilter())); } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java index 8703ebc..b0cf623 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java @@ -29,14 +29,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @RemoteServiceRelativePath("geoportaldataentryservice") public interface GeoportalDataEntryService extends RemoteService { - /** - * Save geona data forms. - * - * @param listGeonaFormObjects the list geona form objects - * @return the commit report - * @throws Exception the exception - */ - CommitReport saveGeonaDataForms(List listGeonaFormObjects) throws Exception; + CommitReport saveGeonaDataForms(String profileID, List listGeonaFormObjects) throws Exception; /** * Gets the geona init config. @@ -45,15 +38,7 @@ public interface GeoportalDataEntryService extends RemoteService { */ GeonaISConfig getGeonaInitConfig(); - /** - * Gets the links for. - * - * @param itemId the item id - * @param recordType the record type - * @return the links for - * @throws Exception the exception - */ - GeoNaItemRef getLinksFor(String itemId, RECORD_TYPE recordType) throws Exception; + GeoNaItemRef getLinksFor(String itemId, String profileID) throws Exception; /** * Gets the list projects. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java index 20892eb..26d6f6a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java @@ -39,14 +39,14 @@ public interface GeoportalDataEntryServiceAsync { } } - void saveGeonaDataForms(List listGeonaFormObjects, AsyncCallback callback); + void saveGeonaDataForms(String profileID, List listGeonaFormObjects, AsyncCallback callback); void getGeonaInitConfig(AsyncCallback callback); - void getLinksFor(String itemId, RECORD_TYPE recordType, AsyncCallback callback); + void getLinksFor(String itemId, String profileID, AsyncCallback callback); - void getListProjects(String theProfileID, Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService, - AsyncCallback callback); + void getListProjects(String theProfileID, Integer start, Integer limit, SearchingFilter filter, + boolean reloadFromService, AsyncCallback callback); void deleteRecord(String itemId, RECORD_TYPE recordType, AsyncCallback callback); @@ -64,8 +64,6 @@ public interface GeoportalDataEntryServiceAsync { void readDataViewerConfig(AsyncCallback asyncCallback); -// void getListDocumentConfigurationForId(String id, AsyncCallback> callback); - void getListUseCaseDescriptors(List handlersIds, AsyncCallback> callback); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java index 1def9fc..221f63e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java @@ -19,16 +19,19 @@ public class ActionOnItemEvent extends GwtEvent TYPE = new Type(); private List selectItems; private ACTION_ON_ITEM action; + private String profileID; /** * Instantiates a new action on item event. * * @param selectItems the select items * @param doAction the do action + * @param profileID the profile ID */ - public ActionOnItemEvent(List selectItems, ACTION_ON_ITEM doAction) { + public ActionOnItemEvent(List selectItems, ACTION_ON_ITEM doAction, String profileID) { this.selectItems = selectItems; this.action = doAction; + this.profileID = profileID; } /** @@ -81,11 +84,10 @@ public class ActionOnItemEvent extends GwtEvent extends GwtEvent TYPE = new Type(); private HandlerDeclarationDV handler; private List listGcubeProfiles; + private String profileID; /** * Instantiates a new creates the new project event. @@ -29,7 +30,9 @@ public class CreateNewProjectEvent extends GwtEvent) - public CreateNewProjectEvent(HandlerDeclarationDV handler, List listGcubeProfiles) { + public CreateNewProjectEvent(String profileID, HandlerDeclarationDV handler, + List listGcubeProfiles) { + this.profileID = profileID; this.handler = handler; this.listGcubeProfiles = listGcubeProfiles; } @@ -79,4 +82,8 @@ public class CreateNewProjectEvent extends GwtEvent /** The type. */ public static Type TYPE = new Type(); private List listGeonaDataForms; + private String profileID; /** @@ -26,8 +27,9 @@ public class SaveGeonaDataFormsEvent extends GwtEvent * * @param listGeonaDataForms the list geona data forms */ - public SaveGeonaDataFormsEvent(List listGeonaDataForms) { + public SaveGeonaDataFormsEvent(String profileID, List listGeonaDataForms) { this.listGeonaDataForms = listGeonaDataForms; + this.profileID = profileID; } /** @@ -59,5 +61,9 @@ public class SaveGeonaDataFormsEvent extends GwtEvent public List getListGeonaDataForms() { return listGeonaDataForms; } + + public String getProfileID() { + return profileID; + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java index 4d73eb7..ffc179e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java @@ -9,7 +9,6 @@ import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP; import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER; import org.gcube.application.geoportalcommon.shared.WhereClause; -import org.gcube.application.geoportalcommon.shared.config.ACTION_ON_ITEM; import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV; import org.gcube.application.geoportalcommon.shared.geoportal.GEOPORTAL_DATA_HANDLER; import org.gcube.application.geoportalcommon.shared.geoportal.HandlerDeclarationDV; @@ -17,7 +16,6 @@ import org.gcube.application.geoportalcommon.shared.geoportal.UseCaseDescriptorD import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent; import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform; @@ -61,8 +59,6 @@ import com.google.gwt.user.client.ui.Widget; */ public class GeonaMainTabPanel extends Composite { - private static final String YOU_MUST_TO_SELECT_A_PROJECT_IN_THE_TABLE = "You must to select a Project in the table"; - private static final String LABEL_FILTER_SEPARATOR = " - "; protected static final int MIN_LENGHT_SERCHING_STRING = 3; @@ -226,8 +222,9 @@ public class GeonaMainTabPanel extends Composite { public void onClick(ClickEvent event) { Window.alert("buttonReloadConcessioni MUST BE REVISITED"); /* - appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); - */ + * appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, + * getCurrentSortFilter())); + */ } }); @@ -258,8 +255,9 @@ public class GeonaMainTabPanel extends Composite { alertSortBy.setText(labelASC); Window.alert("ASC MUST BE REVISITED"); /* - appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); - */ + * appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, + * getCurrentSortFilter())); + */ } }); @@ -275,8 +273,9 @@ public class GeonaMainTabPanel extends Composite { alertSortBy.setText(labelDESC); Window.alert("DESC MUST BE REVISITED"); /* - appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); - */ + * appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, + * getCurrentSortFilter())); + */ } }); } @@ -308,8 +307,13 @@ public class GeonaMainTabPanel extends Composite { if (grpw != null && grpw.getSelectItems() != null) { listConcessioni = grpw.getSelectItems(); } - appManagerBus - .fireEvent(new ActionOnItemEvent(listConcessioni, ACTION_ON_ITEM.VIEW_ON_MAP)); + + Window.alert("ACTION_ON_ITEM.VIEW_ON_MAP must be implemented"); + /* + * appManagerBus .fireEvent(new + * ActionOnItemEvent(listConcessioni, + * ACTION_ON_ITEM.VIEW_ON_MAP)); + */ } }); @@ -322,8 +326,13 @@ public class GeonaMainTabPanel extends Composite { if (grpw != null && grpw.getSelectItems() != null) { listConcessioni = grpw.getSelectItems(); } - appManagerBus - .fireEvent(new ActionOnItemEvent(listConcessioni, ACTION_ON_ITEM.VIEW_REPORT)); + + Window.alert("ACTION_ON_ITEM.VIEW_REPORT must be implemented"); + /* + * appManagerBus .fireEvent(new + * ActionOnItemEvent(listConcessioni, + * ACTION_ON_ITEM.VIEW_REPORT)); + */ } }); @@ -336,8 +345,14 @@ public class GeonaMainTabPanel extends Composite { if (grpw != null && grpw.getSelectItems() != null) { listConcessioni = grpw.getSelectItems(); } - appManagerBus - .fireEvent(new ActionOnItemEvent(listConcessioni, ACTION_ON_ITEM.EDIT_PROJECT)); + + Window.alert("ACTION_ON_ITEM.EDIT_PROJECT must be implemented"); + + /* + * appManagerBus .fireEvent(new + * ActionOnItemEvent(listConcessioni, + * ACTION_ON_ITEM.EDIT_PROJECT)); + */ } }); @@ -349,8 +364,13 @@ public class GeonaMainTabPanel extends Composite { if (grpw != null && grpw.getSelectItems() != null) { listConcessioni = grpw.getSelectItems(); } - appManagerBus.fireEvent( - new ActionOnItemEvent(listConcessioni, ACTION_ON_ITEM.DELETE_PROJECT)); + + Window.alert("ACTION_ON_ITEM.DELETE_PROJECT must be implemented"); + /* + * appManagerBus.fireEvent( new + * ActionOnItemEvent(listConcessioni, + * ACTION_ON_ITEM.DELETE_PROJECT)); + */ } }); @@ -374,9 +394,9 @@ public class GeonaMainTabPanel extends Composite { searchField.setText(""); Window.alert("resetSearch MUST BE REVISITED"); /* - appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); - resetSearch.setVisible(false); - */ + * appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, + * getCurrentSortFilter())); resetSearch.setVisible(false); + */ } }); @@ -394,11 +414,12 @@ public class GeonaMainTabPanel extends Composite { } resetSearch.setVisible(true); - + Window.alert("doSearchEvent MUST BE REVISITED"); /* - appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); - */ + * appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, + * getCurrentSortFilter())); + */ } private String toLabelFilter(ItemFieldDV itemField, ORDER direction) { @@ -508,9 +529,9 @@ public class GeonaMainTabPanel extends Composite { public void instanceAndShowListOfConcessioni() { Window.alert("instanceAndShowListOfConcessioni MUST BE REVISITED"); /* - grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, displayFields, currentSortFilter); - showListOfConcessioniView(grpw); - */ + * grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, + * displayFields, currentSortFilter); showListOfConcessioniView(grpw); + */ } public void setListUseCaseDescriptors(List listUCDescriptors) { @@ -518,7 +539,7 @@ public class GeonaMainTabPanel extends Composite { this.listUCDescriptors = listUCDescriptors; ddCreateNewProject.clear(); - for (UseCaseDescriptorDV ucd : listUCDescriptors) { + for (final UseCaseDescriptorDV ucd : listUCDescriptors) { HandlerDeclarationDV dataEntryHandler = getDataEntryHandler(ucd); @@ -541,7 +562,8 @@ public class GeonaMainTabPanel extends Composite { return; } - appManagerBus.fireEvent(new CreateNewProjectEvent(dataEntryHandler, listProfiles)); + appManagerBus.fireEvent( + new CreateNewProjectEvent(ucd.getProfileID(), dataEntryHandler, listProfiles)); } }); @@ -564,7 +586,8 @@ public class GeonaMainTabPanel extends Composite { if (dataEntryHandler != null) { ConfigurationDV config = dataEntryHandler.getConfiguration(); List listGcubeProfiles = toListGcubeProfiles(config); - appManagerBus.fireEvent(new CreateNewProjectEvent(dataEntryHandler, listGcubeProfiles)); + appManagerBus.fireEvent(new CreateNewProjectEvent(useCaseDescriptor.getProfileID(), + dataEntryHandler, listGcubeProfiles)); } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index fe1f4b4..9a21a62 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -55,7 +55,7 @@ GNA + styleName="{style.custom-page-header}">GeoPortal diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/form/GeonaDataEntryMainForm.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/form/GeonaDataEntryMainForm.java index 50448d8..550b059 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/form/GeonaDataEntryMainForm.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/form/GeonaDataEntryMainForm.java @@ -72,6 +72,8 @@ public class GeonaDataEntryMainForm extends Composite { private HandlerManager appManagerBus; + private String profileID; + /** * Instantiates a new geona data entry main form. * @@ -86,11 +88,13 @@ public class GeonaDataEntryMainForm extends Composite { * Adds the form. * * @param tabHeading the tab heading + * @param key * @param geonFormModel the geon form model */ - public void addForm(String tabHeading, GeoNaFormCardModel geonFormModel) { + public void addForm(String profileID, String tabHeading, GeoNaFormCardModel geonFormModel) { + this.profileID = profileID; listCards.add(geonFormModel); - createNewCard(tabHeading, geonFormModel); + createNewCard(profileID, tabHeading, geonFormModel); } /** @@ -99,7 +103,7 @@ public class GeonaDataEntryMainForm extends Composite { * @param tabHeading the tab heading * @param geonFormModel the geon form model */ - private void createNewCard(String tabHeading, final GeoNaFormCardModel geonFormModel) { + private void createNewCard(String profileID, String tabHeading, final GeoNaFormCardModel geonFormModel) { final Tab tab = new Tab(); tab.setHeading(tabHeading); // MetadataFormCard mfc = new MetadataFormCard(tab, createMetadataForm, @@ -170,7 +174,7 @@ public class GeonaDataEntryMainForm extends Composite { } listGeonaFormObjects.add(new GeoNaFormDataObject(listGDB, card.getGeonaFormModel().getGcubeProfile())); } - appManagerBus.fireEvent(new SaveGeonaDataFormsEvent(listGeonaFormObjects)); + appManagerBus.fireEvent(new SaveGeonaDataFormsEvent(profileID, listGeonaFormObjects)); } else { showAlertOnSaveAction("Detected errors, please fix it/them", AlertType.ERROR, true); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java index 13d5ceb..61d5398 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import org.gcube.application.geoportal.common.model.document.Project; +import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest; import org.gcube.application.geoportal.common.model.rest.TempFile; @@ -31,8 +32,10 @@ import org.gcube.application.geoportalcommon.shared.config.RoleRights; import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE; import org.gcube.application.geoportalcommon.shared.exception.GNAConfigException; import org.gcube.application.geoportalcommon.shared.geoportal.GEOPORTAL_DATA_HANDLER; +import org.gcube.application.geoportalcommon.shared.geoportal.LifecycleInformationDV; import org.gcube.application.geoportalcommon.shared.geoportal.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.UseCaseDescriptorDV; +import org.gcube.application.geoportalcommon.shared.geoportal.config.FilePathDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; @@ -99,28 +102,45 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen /** * Save geona data forms. * + * @param profileID the profile ID * @param listGeonaFormObjects the list geona form objects * @return the commit report * @throws Exception the exception */ @Override - public CommitReport saveGeonaDataForms(List listGeonaFormObjects) throws Exception { - LOG.info("saveGeonaDataForms called"); + public CommitReport saveGeonaDataForms(String profileID, List listGeonaFormObjects) + throws Exception { + LOG.info("saveGeonaDataForms called for profileID {}", profileID); MongoServiceUtil mongoService = new MongoServiceUtil(); - + String theDocumentString = null; try { FormDataObjectToJSON metadataConverter = new FormDataObjectToJSON(); JSONObject theDocument = metadataConverter.convert(listGeonaFormObjects); - String theDocumentString = theDocument.toString(); + theDocumentString = theDocument.toString(); LOG.info("Got Document: " + theDocumentString); + } catch (Exception e) { + LOG.error("Error on converting form data: ", e); + throw new Exception( + "Error occurred on converting data, try again or contact the support. Error: " + e.getMessage()); + } + + Project theProject = null; + try { SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); LOG.debug("Going to create the project..."); - Project theProject = mongoService.createNew("ProfileID", theDocumentString); + theProject = mongoService.createNew(profileID, theDocumentString); LOG.info("Project created with id: " + theProject.getId() + " and profileID: " + theProject.getProfileID()); + } catch (Exception e) { + LOG.error("Error on creating the project: ", e); + throw new Exception("Error occurred on creating new project, try again or contact the support. Error: " + + e.getMessage()); + } + + try { // Uploading files LOG.debug("Going to upload the files"); for (GeoNaFormDataObject geoNaFormDataObject : listGeonaFormObjects) { @@ -128,29 +148,28 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen GcubeProfileDV profile = geoNaFormDataObject.getGcubeProfileDV(); LOG.info("The profile is: " + profile); - String sectionPath = profile.getParentName() + profile.getSectionName(); for (GenericDatasetBean gdb : listGDB) { List files = gdb.getFilesUploaded(); + if (files.size() > 0) { - LOG.info("Uploading files in the section path: " + sectionPath); + String parentPath = profile.getParentName(); + LOG.info("Uploading file/s in the parentPath: " + parentPath); for (int i = 0; i < files.size(); i++) { FileUploaded file = files.get(i); - LOG.debug("Uploading file: " + file.getFileName()); - // As single object - if (files.size() == 1) { - String fieldName = profile.getSectionName(); - LOG.debug("Using field name: " + fieldName); - mongoService.registerFileSet("ProfileID", theProject, - new File(file.getTempSystemPath()), profile.getParentName(), - profile.getSectionName(), ""); - - } else { - // As Array of objects - String fieldName = profile.getSectionName() + "[" + i + "]"; - LOG.debug("Using field name: " + fieldName); - mongoService.registerFileSet("ProfileID", theProject, - new File(file.getTempSystemPath()), profile.getParentName(), fieldName, ""); + String formFieldName = file.getFilePath().getFormFieldLabel(); + LOG.debug( + "Uploading file: " + file.getFileName() + ", from formFieldName: " + formFieldName); + FilePathDV filePath = retrieveFilePathForGcubeProfileFieldName(formFieldName, profile); + LOG.info("Found {} for the form fieldName {}", filePath, formFieldName); + if (filePath == null) { + String error = "It is not possible to register the file " + formFieldName + + ", missing configuration in the filePaths config of: " + profile; + throw new Exception(error); } + + mongoService.registerFileSet(profileID, theProject, new File(file.getTempSystemPath()), + parentPath, filePath.getFieldName(), filePath.getFieldDefinition()); + } } @@ -158,49 +177,31 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } } - return null; + LifecycleInformation lifecycleInfo = theProject.getLifecycleInformation(); + LifecycleInformationDV liDV = ConvertToDataValueObjectModel.toLifecycleInformationDV(lifecycleInfo); + return new CommitReport(theProject.getId(), liDV); } catch (Exception e) { - LOG.error("Error on converting form data: ", e); + LOG.error("Error on uploading files: ", e); throw new Exception( - "Error occurred on saving data, try again or contact the support. Error: " + e.getMessage()); + "Error occurred on uploading files, try again or contact the support. Error: " + e.getMessage()); } -// try { -// -// Concessione concessione; -// if (clientMongo != null && mongoId != null) { -// SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); -// concessione = clientMongo.publish(mongoId); -// // server report -// ValidationReport report = concessione.getReport(); -// LOG.info("ValidationReport: " + report); -// -// // to client -// CommitReport cRep = new CommitReport(); -// // cRep.setRecordId(concessione.getId()); -// cRep.setMongoId(concessione.getMongo_id()); -// ValidationReportDV vr = ConvertToDataViewModel.toValidationReport(report); -// cRep.setValidationReportDV(vr); -// -// return cRep; -// } else -// throw new Exception("MongoId or Client not found"); -// -// } catch (Exception e) { -// LOG.error("Error on commiting data: ", e); -// throw new Exception("Error occurred on saving data. Error: " + e.getMessage()); -// } finally { -//// if(manager!=null) { -//// try { -//// manager.shutdown(); -//// }catch (Exception e) { -//// //silent -//// } -//// -//// } -// } + } + public static FilePathDV retrieveFilePathForGcubeProfileFieldName(String fieldName, GcubeProfileDV profile) { + LOG.debug("Searching fieldDefinition for fieldName {} in the FilePaths {}", fieldName, profile.getFilePaths()); + + if (fieldName == null) + return null; + + for (FilePathDV path : profile.getFilePaths()) { + if (path.getGcubeProfileFieldName().equals(fieldName)) { + return path; + } + } + + return null; } /** @@ -239,14 +240,14 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen * @throws Exception the exception */ @Override - public GeoNaItemRef getLinksFor(String itemId, RECORD_TYPE recordType) throws Exception { + public GeoNaItemRef getLinksFor(String itemId, String profileID) throws Exception { LOG.info("getLinksFor called"); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); GNADataViewerConfigProfile grViewerProfile = SessionUtil .getGeportalViewerResourceProfile(getThreadLocalRequest()); GeoportalCommon gc = new GeoportalCommon(grViewerProfile); - GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toString().toLowerCase()); + GeoNaItemRef item = new GeoNaItemRef(itemId, profileID); item = gc.getPublicLinksFor(item, false); LOG.info("Returning: " + item); return item; @@ -778,17 +779,17 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); try { UseCaseDescriptorCaller client = GeoportalClientCaller.useCaseDescriptors(); - + if (handlersIds == null) { handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId()); LOG.info("handlersIds is null, so using default: " + handlersIds); } - //listUseCaseDescriptor = client.getListForHandlerIds(handlersIds); - + // listUseCaseDescriptor = client.getListForHandlerIds(handlersIds); + listUseCaseDescriptor = client.getList(); } catch (Exception e) { String error = "Error on contacting the Geoportal service"; - LOG.error(error+ " for handlers: " + handlersIds, e); + LOG.error(error + " for handlers: " + handlersIds, e); throw new Exception( "Error when contacting the Geoportal service. Refresh and try again or contact the support"); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java index 7268043..bf69687 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java @@ -16,6 +16,7 @@ import java.util.List; import org.bson.Document; import org.gcube.application.geoportal.client.utils.Serialization; +import org.gcube.application.geoportal.common.faults.InvalidRequestException; import org.gcube.application.geoportal.common.model.document.Project; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest; @@ -48,14 +49,17 @@ public class MongoServiceUtil { UseCaseDescriptorsI client = null; public UseCaseDescriptorsI useCaseDescriptorsClient() { + LOG.debug("useCaseDescriptorsClient called"); return useCaseDescriptors().build(); } public Projects getProjectsClient(String profileID) { + LOG.debug("getProjectsClient called for profileID: " + profileID); return projects(profileID).build(); } public Project createNew(String profileID, String jsonDocument) throws RemoteException { + LOG.debug("createNew called for profileID: " + profileID); Document myDocument = Document.parse(jsonDocument); Projects client = getProjectsClient(profileID); // Create project @@ -64,20 +68,17 @@ public class MongoServiceUtil { return project; } - public void registerFileSet(String profileID, Project project, File theFile, - String parentPath, String fieldName, String fieldDefinition) - throws RemoteException, FileNotFoundException, JsonProcessingException { + public void registerFileSet(String profileID, Project project, File theFile, String parentPath, String fieldName, + String fieldDefinition) throws RemoteException, FileNotFoundException, JsonProcessingException, InvalidRequestException { + LOG.debug("registerFileSet called for profileID: " + profileID); Projects client = getProjectsClient(profileID); - // Prepare request RegisterFileSetRequest fsRequest = FileSets.prepareRequest(new StorageUtils(), parentPath, fieldName, fieldDefinition, theFile); - project = client.registerFileSet(project.getId(), fsRequest); - - System.out.println("Resulting Project : " + project); - System.out.println("JSON Reprepsentation : " + Serialization.write(project)); + LOG.trace("Resulting Project : " + project); + LOG.debug("Resulting Project as JSON: " + Serialization.write(project)); } /** diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java index 0750f2f..f32afd5 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java @@ -2,7 +2,7 @@ package org.gcube.portlets.user.geoportaldataentry.shared; import java.io.Serializable; -import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; +import org.gcube.application.geoportalcommon.shared.geoportal.LifecycleInformationDV; /** * The Class CommitReport. @@ -16,11 +16,9 @@ public class CommitReport implements Serializable { /** * */ - private static final long serialVersionUID = -9519707669761939L; - - public Long recordId; - public String mongoId; - public ValidationReportDV validationReportDV; + private static final long serialVersionUID = -3606902201347318287L; + public String projectID; + private LifecycleInformationDV lifecycleInformation; /** * Instantiates a new commit report. @@ -29,46 +27,33 @@ public class CommitReport implements Serializable { } - public CommitReport(Long recordId, String mongoId, ValidationReportDV validationReportDV) { - super(); - this.recordId = recordId; - this.mongoId = mongoId; - this.validationReportDV = validationReportDV; + public CommitReport(String projectID, LifecycleInformationDV lifecycleInfo) { + this.projectID = projectID; + this.lifecycleInformation = lifecycleInfo; } - public Long getRecordId() { - return recordId; + public String getProjectID() { + return projectID; } - public String getMongoId() { - return mongoId; + public LifecycleInformationDV getLifecycleInformation() { + return lifecycleInformation; } - public ValidationReportDV getValidationReportDV() { - return validationReportDV; + public void setProjectID(String projectID) { } - public void setRecordId(Long recordId) { - this.recordId = recordId; - } - - public void setMongoId(String mongoId) { - this.mongoId = mongoId; - } - - public void setValidationReportDV(ValidationReportDV validationReportDV) { - this.validationReportDV = validationReportDV; + public void setLifecycleInformation(LifecycleInformationDV lifecycleInformation) { + this.lifecycleInformation = lifecycleInformation; } @Override public String toString() { StringBuilder builder = new StringBuilder(); - builder.append("CommitReport [recordId="); - builder.append(recordId); - builder.append(", mongoId="); - builder.append(mongoId); - builder.append(", validationReportDV="); - builder.append(validationReportDV); + builder.append("CommitReport [projectID="); + builder.append(projectID); + builder.append(", lifecycleInformation="); + builder.append(lifecycleInformation); builder.append("]"); return builder.toString(); }