in progress

This commit is contained in:
Francesco Mangiacrapa 2022-05-20 12:31:58 +02:00
parent 0cb588a881
commit 0e30076f08
13 changed files with 293 additions and 238 deletions

View File

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -36,7 +41,12 @@
<wb-module deploy-name="geoportal-data-entry-app-3.0.0-SNAPSHOT"> <wb-module deploy-name="geoportal-data-entry-app-3.0.0-SNAPSHOT">
@ -73,7 +83,12 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/> <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -110,7 +125,12 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -156,7 +176,12 @@
<dependent-module archiveName="geoportal-data-common-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common"> <dependent-module archiveName="geoportal-data-common-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
@ -193,7 +218,12 @@
<property name="context-root" value="geoportal-data-entry-app"/> <property name="context-root" value="geoportal-data-entry-app"/>
@ -230,7 +260,12 @@
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/> <property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
@ -267,7 +302,12 @@
</wb-module> </wb-module>

View File

@ -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;
import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE; 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.HandlerDeclarationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.LifecycleInformationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.UseCaseDescriptorDV; 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.GcubeProfileDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; 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.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.ACTION_PERFORMED_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.ActionOnItemEvent;
@ -284,29 +284,6 @@ public class GeoPortalDataEntryApp implements EntryPoint {
private void loadGeoportalConfigs(final String scope) { private void loadGeoportalConfigs(final String scope) {
GWT.log("loading GeoportalConfigsAndBuildCards in the scope: " + scope); GWT.log("loading GeoportalConfigsAndBuildCards in the scope: " + scope);
orderedCards = new ArrayList<GeoNaFormCardModel>(); orderedCards = new ArrayList<GeoNaFormCardModel>();
// // TODO PASS THE RIGHT ID
// GeoportalDataEntryServiceAsync.Util.getInstance().getListDocumentConfigurationForId("id",
// new AsyncCallback<List<DocumentConfigDV>>() {
//
// @Override
// public void onFailure(Throwable caught) {
// GWT.log("caught: " + caught);
// Window.alert(caught.toString());
// }
//
// @Override
// public void onSuccess(List<DocumentConfigDV> result) {
// listUCDescriptors = result;
// GWT.log("List<DocumentConfigDV>: " + 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, GeoportalDataEntryServiceAsync.Util.getInstance().getListUseCaseDescriptors(null,
new AsyncCallback<List<UseCaseDescriptorDV>>() { new AsyncCallback<List<UseCaseDescriptorDV>>() {
@ -372,7 +349,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
} }
private void createNewDataEntyFor(HandlerDeclarationDV handlerDeclarationDV, List<GcubeProfileDV> listGPs) { private void createNewDataEntyFor(String profileID, HandlerDeclarationDV handlerDeclarationDV,
List<GcubeProfileDV> listGPs) {
dataEntryProjectCreated = true; dataEntryProjectCreated = true;
mainTabPanel.setLoaderVisible("Loading...", true); mainTabPanel.setLoaderVisible("Loading...", true);
orderedCards.clear(); orderedCards.clear();
@ -383,7 +361,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
if (cardsPerIT != null) { if (cardsPerIT != null) {
orderedCards.addAll(cardsPerIT); orderedCards.addAll(cardsPerIT);
buildNewCards(orderedCards, OPERATION.NEW); buildNewCards(profileID, orderedCards, OPERATION.NEW);
return; return;
} }
@ -436,7 +414,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
orderedCards.addAll(gnaCardsModels); orderedCards.addAll(gnaCardsModels);
mapGcubeProfilePerItemType.put(handlerDeclarationDV.getItemType(), mapGcubeProfilePerItemType.put(handlerDeclarationDV.getItemType(),
new ArrayList<GeoNaFormCardModel>(gnaCardsModels)); new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
buildNewCards(orderedCards, OPERATION.UPDATE); buildNewCards(profileID, orderedCards, OPERATION.UPDATE);
} }
} }
@ -450,7 +428,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
} }
} }
private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards, OPERATION operation) { private void buildNewCards(String profileID, Collection<GeoNaFormCardModel> orderedCards, OPERATION operation) {
projectSavedWithSuccess = false; // resetting state of saving projectSavedWithSuccess = false; // resetting state of saving
mainTabPanel.setLoaderVisible("Loading...", true); mainTabPanel.setLoaderVisible("Loading...", true);
geoNaMainForm.setVisibleFormActions(true); geoNaMainForm.setVisibleFormActions(true);
@ -469,7 +447,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
if (geonaForm.getFormCard() != null) { if (geonaForm.getFormCard() != null) {
key = geonaForm.getFormCard().getTitle(); 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); mapForms.put(key, geonaForm);
// } // }
@ -507,7 +486,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modal.add(modalContainerPanel); modal.add(modalContainerPanel);
GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms( GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms(
saveGeonaDataFormsEvent.getListGeonaDataForms(), new AsyncCallback<CommitReport>() { saveGeonaDataFormsEvent.getProfileID(), saveGeonaDataFormsEvent.getListGeonaDataForms(),
new AsyncCallback<CommitReport>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -529,41 +509,56 @@ public class GeoPortalDataEntryApp implements EntryPoint {
public void onSuccess(CommitReport result) { public void onSuccess(CommitReport result) {
modalContainerPanel.clear(); modalContainerPanel.clear();
modal.setCloseVisible(true); modal.setCloseVisible(true);
HTML recordPublished = new HTML();
ValidationReportDV vr = result.getValidationReportDV(); LifecycleInformationDV lcDV = result.getLifecycleInformation();
switch (vr.getStatus()) {
case PASSED: HTML htmlPhase = new HTML();
htmlPhase.setHTML("Current phase: <b>" + lcDV.getPhase() + "</b>");
HTML htmlStep = new HTML();
htmlStep.setHTML("Invoked Step: <b>" + lcDV.getLastInvokedStep() + "</b>");
HTML lastOperationStatus = new HTML();
switch (lcDV.getLastOperationStatus()) {
case OK: {
String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null,
"SUCCESS"); "SUCCESS");
recordPublished.setHTML("Record Published with " + success); String msg = lcDV.getLastInvokedStep() + "terminated with: " + success;
lastOperationStatus.setHTML(msg);
projectSavedWithSuccess = true; projectSavedWithSuccess = true;
String msg = "Record published with success";
geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true); geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true);
purgeFileUploaded(); purgeFileUploaded();
break; break;
case WARNING: }
case WARNING: {
String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null,
"WARNING"); "WARNING");
recordPublished.setHTML("Record Published with " + warning); String msg = lcDV.getLastInvokedStep() + "terminated with: " + warning;
lastOperationStatus.setHTML(msg);
geoNaMainForm.enableButtonSave(true); geoNaMainForm.enableButtonSave(true);
break; break;
case ERROR: }
case ERROR: {
String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold",
"ERROR"); "ERROR");
recordPublished.setHTML(error + " on publishing the Record"); String msg = lcDV.getLastInvokedStep() + "terminated with: " + error;
lastOperationStatus.setHTML(msg);
geoNaMainForm.enableButtonSave(true); geoNaMainForm.enableButtonSave(true);
break; break;
}
default: default:
break; break;
} }
modalContainerPanel.add(recordPublished); modalContainerPanel.add(htmlPhase);
modalContainerPanel.add(htmlStep);
modalContainerPanel.add(lastOperationStatus);
if (result.getMongoId() != null) { if (result.getProjectID() != null) {
modalContainerPanel.add(new HTML("Record id: " + (result.getMongoId()))); modalContainerPanel.add(new HTML("Record id: " + (result.getProjectID())));
try { try {
savedMap.put(result.getMongoId(), savedMap.put(result.getProjectID(),
saveGeonaDataFormsEvent.getListGeonaDataForms()); saveGeonaDataFormsEvent.getListGeonaDataForms());
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
@ -574,7 +569,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
hpGetLink.add(lc); hpGetLink.add(lc);
modalContainerPanel.add(hpGetLink); modalContainerPanel.add(hpGetLink);
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor( GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(
result.getMongoId(), RECORD_TYPE.CONCESSIONE, result.getProjectID(), saveGeonaDataFormsEvent.getProfileID(),
new AsyncCallback<GeoNaItemRef>() { new AsyncCallback<GeoNaItemRef>() {
@Override @Override
@ -589,7 +584,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
String theURL = result.getRestrictedLink().getShortURL() != null String theURL = result.getRestrictedLink().getShortURL() != null
? result.getRestrictedLink().getShortURL() ? result.getRestrictedLink().getShortURL()
: result.getRestrictedLink().getCompleteURL(); : result.getRestrictedLink().getCompleteURL();
String htmlLink = "<div>Go to record: <a href=" + theURL String htmlLink = "<div>Go to project: <a href=" + theURL
+ " target=\"_blank\">" + theURL + "</a></div>"; + " target=\"_blank\">" + theURL + "</a></div>";
HTML html = new HTML(htmlLink); HTML html = new HTML(htmlLink);
hpGetLink.add(html); hpGetLink.add(html);
@ -601,8 +596,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
// geoNaMainForm.enableButtonSave(true); // geoNaMainForm.enableButtonSave(true);
// resetUI(); // resetUI();
if (vr.getAsJSONString() != null) { if (lcDV.getAsJSONString() != null) {
modalContainerPanel.add(new ReportTemplateToHTML(vr.getAsJSONString(), false)); modalContainerPanel.add(new ReportTemplateToHTML(lcDV.getAsJSONString(), false));
} }
} }
@ -619,9 +614,10 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override @Override
public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) { public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) {
GWT.log("Crate new project"); GWT.log("Create new project");
if (!dataEntryProjectCreated) { if (!dataEntryProjectCreated) {
createNewDataEntyFor(newProjectEvent.getHandler(), newProjectEvent.getListGcubeProfiles()); createNewDataEntyFor(newProjectEvent.getProfileID(), newProjectEvent.getHandler(),
newProjectEvent.getListGcubeProfiles());
return; return;
} }
@ -636,7 +632,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
confirm.hide(); confirm.hide();
createNewDataEntyFor(newProjectEvent.getHandler(), newProjectEvent.getListGcubeProfiles()); createNewDataEntyFor(newProjectEvent.getProfileID(), newProjectEvent.getHandler(),
newProjectEvent.getListGcubeProfiles());
// buildNewCards(orderedCards, OPERATION.NEW); // buildNewCards(orderedCards, OPERATION.NEW);
} }
@ -646,7 +643,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
} else if (projectSavedWithSuccess) { } else if (projectSavedWithSuccess) {
// means the project has been saved // means the project has been saved
createNewDataEntyFor(newProjectEvent.getHandler(), newProjectEvent.getListGcubeProfiles()); createNewDataEntyFor(newProjectEvent.getProfileID(), newProjectEvent.getHandler(),
newProjectEvent.getListGcubeProfiles());
// buildNewCards(orderedCards, OPERATION.NEW); // buildNewCards(orderedCards, OPERATION.NEW);
} else { } else {
@ -658,7 +656,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
confirm.hide(); 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) { 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; return;
} }
@ -813,7 +814,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", ""); final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", "");
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(), GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(),
RECORD_TYPE.CONCESSIONE, new AsyncCallback<GeoNaItemRef>() { showItemEvent.getProfileID(), new AsyncCallback<GeoNaItemRef>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
hpGetLink.clear(); hpGetLink.clear();
@ -923,9 +924,9 @@ public class GeoPortalDataEntryApp implements EntryPoint {
alert.setClose(false); alert.setClose(false);
hp.add(alert); hp.add(alert);
appManagerBus.fireEvent( appManagerBus.fireEvent(new GetListOfRecordsEvent(
new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,grpw.getProfileID(),null, RECORD_TYPE.CONCESSIONE, grpw.getProfileID(), null,
mainTabPanel.getCurrentSortFilter())); mainTabPanel.getCurrentSortFilter()));
} }
} }

View File

@ -29,14 +29,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("geoportaldataentryservice") @RemoteServiceRelativePath("geoportaldataentryservice")
public interface GeoportalDataEntryService extends RemoteService { public interface GeoportalDataEntryService extends RemoteService {
/** CommitReport saveGeonaDataForms(String profileID, List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception;
* Save geona data forms.
*
* @param listGeonaFormObjects the list geona form objects
* @return the commit report
* @throws Exception the exception
*/
CommitReport saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception;
/** /**
* Gets the geona init config. * Gets the geona init config.
@ -45,15 +38,7 @@ public interface GeoportalDataEntryService extends RemoteService {
*/ */
GeonaISConfig getGeonaInitConfig(); GeonaISConfig getGeonaInitConfig();
/** GeoNaItemRef getLinksFor(String itemId, String profileID) throws Exception;
* 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;
/** /**
* Gets the list projects. * Gets the list projects.

View File

@ -39,14 +39,14 @@ public interface GeoportalDataEntryServiceAsync {
} }
} }
void saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects, AsyncCallback<CommitReport> callback); void saveGeonaDataForms(String profileID, List<GeoNaFormDataObject> listGeonaFormObjects, AsyncCallback<CommitReport> callback);
void getGeonaInitConfig(AsyncCallback<GeonaISConfig> callback); void getGeonaInitConfig(AsyncCallback<GeonaISConfig> callback);
void getLinksFor(String itemId, RECORD_TYPE recordType, AsyncCallback<GeoNaItemRef> callback); void getLinksFor(String itemId, String profileID, AsyncCallback<GeoNaItemRef> callback);
void getListProjects(String theProfileID, Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService, void getListProjects(String theProfileID, Integer start, Integer limit, SearchingFilter filter,
AsyncCallback<ResultSetPaginatedData> callback); boolean reloadFromService, AsyncCallback<ResultSetPaginatedData> callback);
void deleteRecord(String itemId, RECORD_TYPE recordType, AsyncCallback<Boolean> callback); void deleteRecord(String itemId, RECORD_TYPE recordType, AsyncCallback<Boolean> callback);
@ -64,8 +64,6 @@ public interface GeoportalDataEntryServiceAsync {
void readDataViewerConfig(AsyncCallback<GNADataEntryExtConfigProfile> asyncCallback); void readDataViewerConfig(AsyncCallback<GNADataEntryExtConfigProfile> asyncCallback);
// void getListDocumentConfigurationForId(String id, AsyncCallback<List<DocumentConfigDV>> callback);
void getListUseCaseDescriptors(List<String> handlersIds, AsyncCallback<List<UseCaseDescriptorDV>> callback); void getListUseCaseDescriptors(List<String> handlersIds, AsyncCallback<List<UseCaseDescriptorDV>> callback);
} }

View File

@ -19,16 +19,19 @@ public class ActionOnItemEvent<T extends RecordDV> extends GwtEvent<ActionOnItem
public static Type<ActionOnItemEventHandler> TYPE = new Type<ActionOnItemEventHandler>(); public static Type<ActionOnItemEventHandler> TYPE = new Type<ActionOnItemEventHandler>();
private List<T> selectItems; private List<T> selectItems;
private ACTION_ON_ITEM action; private ACTION_ON_ITEM action;
private String profileID;
/** /**
* Instantiates a new action on item event. * Instantiates a new action on item event.
* *
* @param selectItems the select items * @param selectItems the select items
* @param doAction the do action * @param doAction the do action
* @param profileID the profile ID
*/ */
public ActionOnItemEvent(List<T> selectItems, ACTION_ON_ITEM doAction) { public ActionOnItemEvent(List<T> selectItems, ACTION_ON_ITEM doAction, String profileID) {
this.selectItems = selectItems; this.selectItems = selectItems;
this.action = doAction; this.action = doAction;
this.profileID = profileID;
} }
/** /**
@ -81,11 +84,10 @@ public class ActionOnItemEvent<T extends RecordDV> extends GwtEvent<ActionOnItem
return action; return action;
} }
/** public String getProfileID() {
* To string. return profileID;
* }
* @return the string
*/
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -93,6 +95,8 @@ public class ActionOnItemEvent<T extends RecordDV> extends GwtEvent<ActionOnItem
builder.append(selectItems); builder.append(selectItems);
builder.append(", action="); builder.append(", action=");
builder.append(action); builder.append(action);
builder.append(", profileID=");
builder.append(profileID);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }

View File

@ -20,6 +20,7 @@ public class CreateNewProjectEvent extends GwtEvent<CreateNewProjectEventHandler
public static Type<CreateNewProjectEventHandler> TYPE = new Type<CreateNewProjectEventHandler>(); public static Type<CreateNewProjectEventHandler> TYPE = new Type<CreateNewProjectEventHandler>();
private HandlerDeclarationDV handler; private HandlerDeclarationDV handler;
private List<GcubeProfileDV> listGcubeProfiles; private List<GcubeProfileDV> listGcubeProfiles;
private String profileID;
/** /**
* Instantiates a new creates the new project event. * Instantiates a new creates the new project event.
@ -29,7 +30,9 @@ public class CreateNewProjectEvent extends GwtEvent<CreateNewProjectEventHandler
*/ */
// (passing this second argument in order to avoid twice the casting as // (passing this second argument in order to avoid twice the casting as
// List<GcubeProfileDV>) // List<GcubeProfileDV>)
public CreateNewProjectEvent(HandlerDeclarationDV handler, List<GcubeProfileDV> listGcubeProfiles) { public CreateNewProjectEvent(String profileID, HandlerDeclarationDV handler,
List<GcubeProfileDV> listGcubeProfiles) {
this.profileID = profileID;
this.handler = handler; this.handler = handler;
this.listGcubeProfiles = listGcubeProfiles; this.listGcubeProfiles = listGcubeProfiles;
} }
@ -79,4 +82,8 @@ public class CreateNewProjectEvent extends GwtEvent<CreateNewProjectEventHandler
return listGcubeProfiles; return listGcubeProfiles;
} }
public String getProfileID() {
return profileID;
}
} }

View File

@ -19,6 +19,7 @@ public class SaveGeonaDataFormsEvent extends GwtEvent<SaveGeonaDataFormsHandler>
/** The type. */ /** The type. */
public static Type<SaveGeonaDataFormsHandler> TYPE = new Type<SaveGeonaDataFormsHandler>(); public static Type<SaveGeonaDataFormsHandler> TYPE = new Type<SaveGeonaDataFormsHandler>();
private List<GeoNaFormDataObject> listGeonaDataForms; private List<GeoNaFormDataObject> listGeonaDataForms;
private String profileID;
/** /**
@ -26,8 +27,9 @@ public class SaveGeonaDataFormsEvent extends GwtEvent<SaveGeonaDataFormsHandler>
* *
* @param listGeonaDataForms the list geona data forms * @param listGeonaDataForms the list geona data forms
*/ */
public SaveGeonaDataFormsEvent(List<GeoNaFormDataObject> listGeonaDataForms) { public SaveGeonaDataFormsEvent(String profileID, List<GeoNaFormDataObject> listGeonaDataForms) {
this.listGeonaDataForms = listGeonaDataForms; this.listGeonaDataForms = listGeonaDataForms;
this.profileID = profileID;
} }
/** /**
@ -59,5 +61,9 @@ public class SaveGeonaDataFormsEvent extends GwtEvent<SaveGeonaDataFormsHandler>
public List<GeoNaFormDataObject> getListGeonaDataForms() { public List<GeoNaFormDataObject> getListGeonaDataForms() {
return listGeonaDataForms; return listGeonaDataForms;
} }
public String getProfileID() {
return profileID;
}
} }

View File

@ -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.LOGICAL_OP;
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER; import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
import org.gcube.application.geoportalcommon.shared.WhereClause; 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.ConfigurationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.GEOPORTAL_DATA_HANDLER; import org.gcube.application.geoportalcommon.shared.geoportal.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.HandlerDeclarationDV; 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.GcubeProfileDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; 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.events.CreateNewProjectEvent;
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.utils.DialogInform; 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 { 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 = " - "; private static final String LABEL_FILTER_SEPARATOR = " - ";
protected static final int MIN_LENGHT_SERCHING_STRING = 3; protected static final int MIN_LENGHT_SERCHING_STRING = 3;
@ -226,8 +222,9 @@ public class GeonaMainTabPanel extends Composite {
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
Window.alert("buttonReloadConcessioni MUST BE REVISITED"); 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); alertSortBy.setText(labelASC);
Window.alert("ASC MUST BE REVISITED"); 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); alertSortBy.setText(labelDESC);
Window.alert("DESC MUST BE REVISITED"); 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) { if (grpw != null && grpw.getSelectItems() != null) {
listConcessioni = grpw.getSelectItems(); listConcessioni = grpw.getSelectItems();
} }
appManagerBus
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.VIEW_ON_MAP)); Window.alert("ACTION_ON_ITEM.VIEW_ON_MAP must be implemented");
/*
* appManagerBus .fireEvent(new
* ActionOnItemEvent<ConcessioneDV>(listConcessioni,
* ACTION_ON_ITEM.VIEW_ON_MAP));
*/
} }
}); });
@ -322,8 +326,13 @@ public class GeonaMainTabPanel extends Composite {
if (grpw != null && grpw.getSelectItems() != null) { if (grpw != null && grpw.getSelectItems() != null) {
listConcessioni = grpw.getSelectItems(); listConcessioni = grpw.getSelectItems();
} }
appManagerBus
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.VIEW_REPORT)); Window.alert("ACTION_ON_ITEM.VIEW_REPORT must be implemented");
/*
* appManagerBus .fireEvent(new
* ActionOnItemEvent<ConcessioneDV>(listConcessioni,
* ACTION_ON_ITEM.VIEW_REPORT));
*/
} }
}); });
@ -336,8 +345,14 @@ public class GeonaMainTabPanel extends Composite {
if (grpw != null && grpw.getSelectItems() != null) { if (grpw != null && grpw.getSelectItems() != null) {
listConcessioni = grpw.getSelectItems(); listConcessioni = grpw.getSelectItems();
} }
appManagerBus
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.EDIT_PROJECT)); Window.alert("ACTION_ON_ITEM.EDIT_PROJECT must be implemented");
/*
* appManagerBus .fireEvent(new
* ActionOnItemEvent<ConcessioneDV>(listConcessioni,
* ACTION_ON_ITEM.EDIT_PROJECT));
*/
} }
}); });
@ -349,8 +364,13 @@ public class GeonaMainTabPanel extends Composite {
if (grpw != null && grpw.getSelectItems() != null) { if (grpw != null && grpw.getSelectItems() != null) {
listConcessioni = grpw.getSelectItems(); listConcessioni = grpw.getSelectItems();
} }
appManagerBus.fireEvent(
new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.DELETE_PROJECT)); Window.alert("ACTION_ON_ITEM.DELETE_PROJECT must be implemented");
/*
* appManagerBus.fireEvent( new
* ActionOnItemEvent<ConcessioneDV>(listConcessioni,
* ACTION_ON_ITEM.DELETE_PROJECT));
*/
} }
}); });
@ -374,9 +394,9 @@ public class GeonaMainTabPanel extends Composite {
searchField.setText(""); searchField.setText("");
Window.alert("resetSearch MUST BE REVISITED"); Window.alert("resetSearch MUST BE REVISITED");
/* /*
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); * appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
resetSearch.setVisible(false); * getCurrentSortFilter())); resetSearch.setVisible(false);
*/ */
} }
}); });
@ -394,11 +414,12 @@ public class GeonaMainTabPanel extends Composite {
} }
resetSearch.setVisible(true); resetSearch.setVisible(true);
Window.alert("doSearchEvent MUST BE REVISITED"); 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) { private String toLabelFilter(ItemFieldDV itemField, ORDER direction) {
@ -508,9 +529,9 @@ public class GeonaMainTabPanel extends Composite {
public void instanceAndShowListOfConcessioni() { public void instanceAndShowListOfConcessioni() {
Window.alert("instanceAndShowListOfConcessioni MUST BE REVISITED"); Window.alert("instanceAndShowListOfConcessioni MUST BE REVISITED");
/* /*
grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, displayFields, currentSortFilter); * grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE,
showListOfConcessioniView(grpw); * displayFields, currentSortFilter); showListOfConcessioniView(grpw);
*/ */
} }
public void setListUseCaseDescriptors(List<UseCaseDescriptorDV> listUCDescriptors) { public void setListUseCaseDescriptors(List<UseCaseDescriptorDV> listUCDescriptors) {
@ -518,7 +539,7 @@ public class GeonaMainTabPanel extends Composite {
this.listUCDescriptors = listUCDescriptors; this.listUCDescriptors = listUCDescriptors;
ddCreateNewProject.clear(); ddCreateNewProject.clear();
for (UseCaseDescriptorDV ucd : listUCDescriptors) { for (final UseCaseDescriptorDV ucd : listUCDescriptors) {
HandlerDeclarationDV dataEntryHandler = getDataEntryHandler(ucd); HandlerDeclarationDV dataEntryHandler = getDataEntryHandler(ucd);
@ -541,7 +562,8 @@ public class GeonaMainTabPanel extends Composite {
return; 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) { if (dataEntryHandler != null) {
ConfigurationDV<?> config = dataEntryHandler.getConfiguration(); ConfigurationDV<?> config = dataEntryHandler.getConfiguration();
List<GcubeProfileDV> listGcubeProfiles = toListGcubeProfiles(config); List<GcubeProfileDV> listGcubeProfiles = toListGcubeProfiles(config);
appManagerBus.fireEvent(new CreateNewProjectEvent(dataEntryHandler, listGcubeProfiles)); appManagerBus.fireEvent(new CreateNewProjectEvent(useCaseDescriptor.getProfileID(),
dataEntryHandler, listGcubeProfiles));
} }
} }

View File

@ -55,7 +55,7 @@
</ui:style> </ui:style>
<g:HTMLPanel> <g:HTMLPanel>
<b:PageHeader subtext="data entry facility" <b:PageHeader subtext="data entry facility"
styleName="{style.custom-page-header}">GNA</b:PageHeader> styleName="{style.custom-page-header}">GeoPortal</b:PageHeader>
<g:Label ui:field="roleLabel" <g:Label ui:field="roleLabel"
addStyleNames="{style.display-right}"></g:Label> addStyleNames="{style.display-right}"></g:Label>
<b:TabPanel tabPosition="above" ui:field="tabPanel"> <b:TabPanel tabPosition="above" ui:field="tabPanel">

View File

@ -72,6 +72,8 @@ public class GeonaDataEntryMainForm extends Composite {
private HandlerManager appManagerBus; private HandlerManager appManagerBus;
private String profileID;
/** /**
* Instantiates a new geona data entry main form. * Instantiates a new geona data entry main form.
* *
@ -86,11 +88,13 @@ public class GeonaDataEntryMainForm extends Composite {
* Adds the form. * Adds the form.
* *
* @param tabHeading the tab heading * @param tabHeading the tab heading
* @param key
* @param geonFormModel the geon form model * @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); 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 tabHeading the tab heading
* @param geonFormModel the geon form model * @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(); final Tab tab = new Tab();
tab.setHeading(tabHeading); tab.setHeading(tabHeading);
// MetadataFormCard mfc = new MetadataFormCard(tab, createMetadataForm, // MetadataFormCard mfc = new MetadataFormCard(tab, createMetadataForm,
@ -170,7 +174,7 @@ public class GeonaDataEntryMainForm extends Composite {
} }
listGeonaFormObjects.add(new GeoNaFormDataObject(listGDB, card.getGeonaFormModel().getGcubeProfile())); listGeonaFormObjects.add(new GeoNaFormDataObject(listGDB, card.getGeonaFormModel().getGcubeProfile()));
} }
appManagerBus.fireEvent(new SaveGeonaDataFormsEvent(listGeonaFormObjects)); appManagerBus.fireEvent(new SaveGeonaDataFormsEvent(profileID, listGeonaFormObjects));
} else { } else {
showAlertOnSaveAction("Detected errors, please fix it/them", AlertType.ERROR, true); showAlertOnSaveAction("Detected errors, please fix it/them", AlertType.ERROR, true);
} }

View File

@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.gcube.application.geoportal.common.model.document.Project; 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.legacy.Concessione;
import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest; import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest;
import org.gcube.application.geoportal.common.model.rest.TempFile; 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.config.RoleRights.OPERATION_TYPE;
import org.gcube.application.geoportalcommon.shared.exception.GNAConfigException; 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.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.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.UseCaseDescriptorDV; 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.geoportal.config.GcubeProfileDV;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
@ -99,28 +102,45 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
/** /**
* Save geona data forms. * Save geona data forms.
* *
* @param profileID the profile ID
* @param listGeonaFormObjects the list geona form objects * @param listGeonaFormObjects the list geona form objects
* @return the commit report * @return the commit report
* @throws Exception the exception * @throws Exception the exception
*/ */
@Override @Override
public CommitReport saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception { public CommitReport saveGeonaDataForms(String profileID, List<GeoNaFormDataObject> listGeonaFormObjects)
LOG.info("saveGeonaDataForms called"); throws Exception {
LOG.info("saveGeonaDataForms called for profileID {}", profileID);
MongoServiceUtil mongoService = new MongoServiceUtil(); MongoServiceUtil mongoService = new MongoServiceUtil();
String theDocumentString = null;
try { try {
FormDataObjectToJSON metadataConverter = new FormDataObjectToJSON(); FormDataObjectToJSON metadataConverter = new FormDataObjectToJSON();
JSONObject theDocument = metadataConverter.convert(listGeonaFormObjects); JSONObject theDocument = metadataConverter.convert(listGeonaFormObjects);
String theDocumentString = theDocument.toString(); theDocumentString = theDocument.toString();
LOG.info("Got Document: " + theDocumentString); 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); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
LOG.debug("Going to create the project..."); 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()); 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 // Uploading files
LOG.debug("Going to upload the files"); LOG.debug("Going to upload the files");
for (GeoNaFormDataObject geoNaFormDataObject : listGeonaFormObjects) { for (GeoNaFormDataObject geoNaFormDataObject : listGeonaFormObjects) {
@ -128,29 +148,28 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
GcubeProfileDV profile = geoNaFormDataObject.getGcubeProfileDV(); GcubeProfileDV profile = geoNaFormDataObject.getGcubeProfileDV();
LOG.info("The profile is: " + profile); LOG.info("The profile is: " + profile);
String sectionPath = profile.getParentName() + profile.getSectionName();
for (GenericDatasetBean gdb : listGDB) { for (GenericDatasetBean gdb : listGDB) {
List<FileUploaded> files = gdb.getFilesUploaded(); List<FileUploaded> files = gdb.getFilesUploaded();
if (files.size() > 0) { 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++) { for (int i = 0; i < files.size(); i++) {
FileUploaded file = files.get(i); FileUploaded file = files.get(i);
LOG.debug("Uploading file: " + file.getFileName()); String formFieldName = file.getFilePath().getFormFieldLabel();
// As single object LOG.debug(
if (files.size() == 1) { "Uploading file: " + file.getFileName() + ", from formFieldName: " + formFieldName);
String fieldName = profile.getSectionName(); FilePathDV filePath = retrieveFilePathForGcubeProfileFieldName(formFieldName, profile);
LOG.debug("Using field name: " + fieldName); LOG.info("Found {} for the form fieldName {}", filePath, formFieldName);
mongoService.registerFileSet("ProfileID", theProject, if (filePath == null) {
new File(file.getTempSystemPath()), profile.getParentName(), String error = "It is not possible to register the file " + formFieldName
profile.getSectionName(), ""); + ", missing configuration in the filePaths config of: " + profile;
throw new Exception(error);
} 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, "");
} }
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) { } catch (Exception e) {
LOG.error("Error on converting form data: ", e); LOG.error("Error on uploading files: ", e);
throw new Exception( 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 * @throws Exception the exception
*/ */
@Override @Override
public GeoNaItemRef getLinksFor(String itemId, RECORD_TYPE recordType) throws Exception { public GeoNaItemRef getLinksFor(String itemId, String profileID) throws Exception {
LOG.info("getLinksFor called"); LOG.info("getLinksFor called");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GNADataViewerConfigProfile grViewerProfile = SessionUtil GNADataViewerConfigProfile grViewerProfile = SessionUtil
.getGeportalViewerResourceProfile(getThreadLocalRequest()); .getGeportalViewerResourceProfile(getThreadLocalRequest());
GeoportalCommon gc = new GeoportalCommon(grViewerProfile); GeoportalCommon gc = new GeoportalCommon(grViewerProfile);
GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toString().toLowerCase()); GeoNaItemRef item = new GeoNaItemRef(itemId, profileID);
item = gc.getPublicLinksFor(item, false); item = gc.getPublicLinksFor(item, false);
LOG.info("Returning: " + item); LOG.info("Returning: " + item);
return item; return item;
@ -778,17 +779,17 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
try { try {
UseCaseDescriptorCaller client = GeoportalClientCaller.useCaseDescriptors(); UseCaseDescriptorCaller client = GeoportalClientCaller.useCaseDescriptors();
if (handlersIds == null) { if (handlersIds == null) {
handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId()); handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId());
LOG.info("handlersIds is null, so using default: " + handlersIds); LOG.info("handlersIds is null, so using default: " + handlersIds);
} }
//listUseCaseDescriptor = client.getListForHandlerIds(handlersIds); // listUseCaseDescriptor = client.getListForHandlerIds(handlersIds);
listUseCaseDescriptor = client.getList(); listUseCaseDescriptor = client.getList();
} catch (Exception e) { } catch (Exception e) {
String error = "Error on contacting the Geoportal service"; 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( throw new Exception(
"Error when contacting the Geoportal service. Refresh and try again or contact the support"); "Error when contacting the Geoportal service. Refresh and try again or contact the support");
} }

View File

@ -16,6 +16,7 @@ import java.util.List;
import org.bson.Document; import org.bson.Document;
import org.gcube.application.geoportal.client.utils.Serialization; 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.document.Project;
import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest; import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
@ -48,14 +49,17 @@ public class MongoServiceUtil {
UseCaseDescriptorsI client = null; UseCaseDescriptorsI client = null;
public UseCaseDescriptorsI useCaseDescriptorsClient() { public UseCaseDescriptorsI useCaseDescriptorsClient() {
LOG.debug("useCaseDescriptorsClient called");
return useCaseDescriptors().build(); return useCaseDescriptors().build();
} }
public Projects<Project> getProjectsClient(String profileID) { public Projects<Project> getProjectsClient(String profileID) {
LOG.debug("getProjectsClient called for profileID: " + profileID);
return projects(profileID).build(); return projects(profileID).build();
} }
public Project createNew(String profileID, String jsonDocument) throws RemoteException { public Project createNew(String profileID, String jsonDocument) throws RemoteException {
LOG.debug("createNew called for profileID: " + profileID);
Document myDocument = Document.parse(jsonDocument); Document myDocument = Document.parse(jsonDocument);
Projects<Project> client = getProjectsClient(profileID); Projects<Project> client = getProjectsClient(profileID);
// Create project // Create project
@ -64,20 +68,17 @@ public class MongoServiceUtil {
return project; return project;
} }
public void registerFileSet(String profileID, Project project, File theFile, public void registerFileSet(String profileID, Project project, File theFile, String parentPath, String fieldName,
String parentPath, String fieldName, String fieldDefinition) String fieldDefinition) throws RemoteException, FileNotFoundException, JsonProcessingException, InvalidRequestException {
throws RemoteException, FileNotFoundException, JsonProcessingException { LOG.debug("registerFileSet called for profileID: " + profileID);
Projects<Project> client = getProjectsClient(profileID); Projects<Project> client = getProjectsClient(profileID);
// Prepare request // Prepare request
RegisterFileSetRequest fsRequest = FileSets.prepareRequest(new StorageUtils(), parentPath, fieldName, RegisterFileSetRequest fsRequest = FileSets.prepareRequest(new StorageUtils(), parentPath, fieldName,
fieldDefinition, theFile); fieldDefinition, theFile);
project = client.registerFileSet(project.getId(), fsRequest); project = client.registerFileSet(project.getId(), fsRequest);
LOG.trace("Resulting Project : " + project);
System.out.println("Resulting Project : " + project); LOG.debug("Resulting Project as JSON: " + Serialization.write(project));
System.out.println("JSON Reprepsentation : " + Serialization.write(project));
} }
/** /**

View File

@ -2,7 +2,7 @@ package org.gcube.portlets.user.geoportaldataentry.shared;
import java.io.Serializable; import java.io.Serializable;
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; import org.gcube.application.geoportalcommon.shared.geoportal.LifecycleInformationDV;
/** /**
* The Class CommitReport. * The Class CommitReport.
@ -16,11 +16,9 @@ public class CommitReport implements Serializable {
/** /**
* *
*/ */
private static final long serialVersionUID = -9519707669761939L; private static final long serialVersionUID = -3606902201347318287L;
public String projectID;
public Long recordId; private LifecycleInformationDV lifecycleInformation;
public String mongoId;
public ValidationReportDV validationReportDV;
/** /**
* Instantiates a new commit report. * Instantiates a new commit report.
@ -29,46 +27,33 @@ public class CommitReport implements Serializable {
} }
public CommitReport(Long recordId, String mongoId, ValidationReportDV validationReportDV) { public CommitReport(String projectID, LifecycleInformationDV lifecycleInfo) {
super(); this.projectID = projectID;
this.recordId = recordId; this.lifecycleInformation = lifecycleInfo;
this.mongoId = mongoId;
this.validationReportDV = validationReportDV;
} }
public Long getRecordId() { public String getProjectID() {
return recordId; return projectID;
} }
public String getMongoId() { public LifecycleInformationDV getLifecycleInformation() {
return mongoId; return lifecycleInformation;
} }
public ValidationReportDV getValidationReportDV() { public void setProjectID(String projectID) {
return validationReportDV;
} }
public void setRecordId(Long recordId) { public void setLifecycleInformation(LifecycleInformationDV lifecycleInformation) {
this.recordId = recordId; this.lifecycleInformation = lifecycleInformation;
}
public void setMongoId(String mongoId) {
this.mongoId = mongoId;
}
public void setValidationReportDV(ValidationReportDV validationReportDV) {
this.validationReportDV = validationReportDV;
} }
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("CommitReport [recordId="); builder.append("CommitReport [projectID=");
builder.append(recordId); builder.append(projectID);
builder.append(", mongoId="); builder.append(", lifecycleInformation=");
builder.append(mongoId); builder.append(lifecycleInformation);
builder.append(", validationReportDV=");
builder.append(validationReportDV);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }