publication on SDI. Added commit report
This commit is contained in:
parent
e54ba3b0b6
commit
dd37be47a9
|
@ -15,6 +15,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaDataEntryMainFo
|
|||
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainPanel;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderServiceAsync;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm;
|
||||
|
@ -204,7 +205,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
loader.setText("Trying to save the data, please wait...");
|
||||
modal.add(loader);
|
||||
|
||||
GreetingServiceAsync.Util.getInstance().saveGeonaDataForms(saveGeonaDataFormsEvent.getListGeonaDataForms(), new AsyncCallback<String>() {
|
||||
GreetingServiceAsync.Util.getInstance().saveGeonaDataForms(saveGeonaDataFormsEvent.getListGeonaDataForms(), new AsyncCallback<CommitReport>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -219,10 +220,22 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
public void onSuccess(CommitReport result) {
|
||||
modal.clear();
|
||||
Alert alert = new Alert(result);
|
||||
alert.setType(AlertType.INFO);
|
||||
Alert alert = new Alert(result.getMsg());
|
||||
switch (result.getState()) {
|
||||
case OK:
|
||||
alert.setType(AlertType.SUCCESS);
|
||||
break;
|
||||
case WARN:
|
||||
alert.setType(AlertType.WARNING);
|
||||
break;
|
||||
case ERROR:
|
||||
alert.setType(AlertType.ERROR);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
alert.setClose(false);
|
||||
modal.add(alert);
|
||||
modal.setCloseVisible(true);
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataentry.client;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
|
||||
|
@ -14,7 +15,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
|||
@RemoteServiceRelativePath("greet")
|
||||
public interface GreetingService extends RemoteService {
|
||||
|
||||
String saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception;
|
||||
CommitReport saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception;
|
||||
|
||||
GeonaISConfig getGeonaInitConfig();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataentry.client;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
|
||||
|
@ -34,7 +35,7 @@ public interface GreetingServiceAsync
|
|||
}
|
||||
|
||||
|
||||
void saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects, AsyncCallback<String> callback);
|
||||
void saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects, AsyncCallback<CommitReport> callback);
|
||||
|
||||
|
||||
void getGeonaInitConfig(AsyncCallback<GeonaISConfig> callback);
|
||||
|
|
|
@ -16,6 +16,8 @@ import org.gcube.application.geoportal.model.content.UploadedImage;
|
|||
import org.gcube.application.geoportal.model.content.WorkspaceContent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GreetingService;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport.STATE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
||||
|
@ -36,7 +38,7 @@ public class GreetingServiceImpl extends RemoteServiceServlet implements Greetin
|
|||
private static final Logger LOG = LoggerFactory.getLogger(GreetingServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public String saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception {
|
||||
public CommitReport saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception {
|
||||
LOG.info("saveGeonaDataForms called");
|
||||
|
||||
HashMap<ConcessioniFormCardTitle, List<GeoNaFormDataObject>> toMap =
|
||||
|
@ -164,7 +166,7 @@ public class GreetingServiceImpl extends RemoteServiceServlet implements Greetin
|
|||
try {
|
||||
|
||||
//If true -> data are published into the SDI
|
||||
Boolean publish=false;
|
||||
Boolean publish=true;
|
||||
|
||||
/*Chiedo al manager di salvare il progetto, causando :
|
||||
*scrittura sul WS
|
||||
|
@ -177,16 +179,22 @@ public class GreetingServiceImpl extends RemoteServiceServlet implements Greetin
|
|||
try {
|
||||
link = ((WorkspaceContent)registered.getRelazioneScavo().getActualContent().get(0)).getLink();
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
LOG.warn("Not able to check public link ",e);
|
||||
}
|
||||
|
||||
//String link = "toTest";
|
||||
CommitReport cRep = new CommitReport();
|
||||
cRep.setRecordId(registered.getId());
|
||||
if(link!=null) {
|
||||
cRep.setState(STATE.OK);
|
||||
cRep.setMsg("Project saved successfully");
|
||||
}
|
||||
else {
|
||||
cRep.setState(STATE.WARN);
|
||||
cRep.setMsg("Project saved with errors");
|
||||
}
|
||||
|
||||
if(link!=null)
|
||||
return "Project saved successfully";
|
||||
else
|
||||
return "Project saved with errors";
|
||||
|
||||
return cRep;
|
||||
}catch (Exception e) {
|
||||
LOG.error("Error on commiting data: ",e);
|
||||
throw new Exception("Error occurred on saving data, try again or contact the support");
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* The Class CommitReport.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Oct 21, 2020
|
||||
*/
|
||||
public class CommitReport implements Serializable{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -9519707669761939L;
|
||||
|
||||
|
||||
/**
|
||||
* The Enum STATE.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Oct 21, 2020
|
||||
*/
|
||||
public enum STATE{ERROR, WARN, OK, UNKNOWN}
|
||||
|
||||
public STATE state = STATE.UNKNOWN;
|
||||
public long recordId;
|
||||
public String msg;
|
||||
|
||||
/**
|
||||
* Instantiates a new commit report.
|
||||
*/
|
||||
public CommitReport() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new commit report.
|
||||
*
|
||||
* @param state the state
|
||||
* @param recordId the record id
|
||||
* @param msg the msg
|
||||
*/
|
||||
public CommitReport(STATE state, long recordId, String msg) {
|
||||
super();
|
||||
this.state = state;
|
||||
this.recordId = recordId;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the state.
|
||||
*
|
||||
* @return the state
|
||||
*/
|
||||
public STATE getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state.
|
||||
*
|
||||
* @param state the new state
|
||||
*/
|
||||
public void setState(STATE state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the record id.
|
||||
*
|
||||
* @return the record id
|
||||
*/
|
||||
public long getRecordId() {
|
||||
return recordId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the record id.
|
||||
*
|
||||
* @param recordId the new record id
|
||||
*/
|
||||
public void setRecordId(long recordId) {
|
||||
this.recordId = recordId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the msg.
|
||||
*
|
||||
* @return the msg
|
||||
*/
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the msg.
|
||||
*
|
||||
* @param msg the new msg
|
||||
*/
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CommitReport [state=");
|
||||
builder.append(state);
|
||||
builder.append(", recordId=");
|
||||
builder.append(recordId);
|
||||
builder.append(", msg=");
|
||||
builder.append(msg);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue