Added GeonaIsConfig to read initizialiation parameters

This commit is contained in:
Francesco Mangiacrapa 2020-10-21 15:36:50 +02:00
parent 3980df91c6
commit b5512eb7c0
9 changed files with 133 additions and 8 deletions

View File

@ -47,6 +47,9 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="metadata-profile-form-builder-widget-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/metadata-profile-form-builder-widget/metadata-profile-form-builder-widget">
<dependency-type>uses</dependency-type>
</dependent-module>

View File

@ -0,0 +1,7 @@
<root>
<facet id="jst.jaxrs">
<node name="libprov">
<attribute name="provider-id" value="jaxrs-no-op-library-provider"/>
</node>
</facet>
</root>

View File

@ -10,4 +10,6 @@ public class ConstantsGeoPortalDataEntryApp {
public static final String HOURS_MINUTES_SEPARATOR = ConstantsMPFormBuilder.HOURS_MINUTES_SEPARATOR;
public static final String ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT = "Error on inizialization stage, please contact the support!";
}

View File

@ -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.GeonaISConfig;
import org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderServiceAsync;
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
@ -33,6 +34,8 @@ import com.google.gwt.user.client.ui.RootPanel;
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class GeoPortalDataEntryApp implements EntryPoint {
/**
* The message displayed to the user when the server cannot be reached or
* returns an error.
@ -64,14 +67,38 @@ public class GeoPortalDataEntryApp implements EntryPoint {
*/
public void onModuleLoad() {
String scope = "/gcube/devsec/devVRE";
String secondaryType = "GeoNaMetadata";
mainPanel = new GeonaMainPanel(appManagerBus);
mainPanel.setLoaderVisible("Loading...", true);
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
GreetingServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback<GeonaISConfig>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(ConstantsGeoPortalDataEntryApp.ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT);
}
@Override
public void onSuccess(GeonaISConfig result) {
if(result!=null && result.getgRSecondaryType()!=null && result.getScope()!=null) {
callGetMetadataProfiles(result.getScope(), result.getgRSecondaryType());
}else
Window.alert(ConstantsGeoPortalDataEntryApp.ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT);
}
});
bindEvents();
mainPanel.addFormPanel(geoNaMainForm);
RootPanel.get(DIV_PORTLET_ID).add(mainPanel);
}
private void callGetMetadataProfiles(String scope, String secondaryType) {
MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScope(scope, secondaryType, new AsyncCallback<List<MetaDataProfileBean>>() {
@Override
@ -85,11 +112,6 @@ public class GeoPortalDataEntryApp implements EntryPoint {
public void onFailure(Throwable caught) {
}
});
bindEvents();
mainPanel.addFormPanel(geoNaMainForm);
RootPanel.get(DIV_PORTLET_ID).add(mainPanel);
}
private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards) {

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client;
import java.util.List;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -14,4 +15,6 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
public interface GreetingService extends RemoteService {
String saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception;
GeonaISConfig getGeonaInitConfig();
}

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client;
import java.util.List;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -34,4 +35,7 @@ public interface GreetingServiceAsync
void saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects, AsyncCallback<String> callback);
void getGeonaInitConfig(AsyncCallback<GeonaISConfig> callback);
}

View File

@ -17,6 +17,7 @@ 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.GeoNaFormDataObject;
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
@ -31,6 +32,7 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@SuppressWarnings("serial")
public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService {
public static final String GEONA_GENERIC_RESOURCE_SECONDARY_TYPE = "GEONA_GENERIC_RESOURCE_SECONDARY_TYPE";
private static final Logger LOG = LoggerFactory.getLogger(GreetingServiceImpl.class);
@Override
@ -177,6 +179,28 @@ public class GreetingServiceImpl extends RemoteServiceServlet implements Greetin
return "Project saved with errors";
}
@Override
public GeonaISConfig getGeonaInitConfig() {
LOG.info("getConfig called");
String scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), false);
String theSecondaryType;
try {
theSecondaryType = this.getServletContext().getInitParameter(GEONA_GENERIC_RESOURCE_SECONDARY_TYPE);
} catch (Exception e) {
LOG.error("I cannot read the init parameter for: " + GEONA_GENERIC_RESOURCE_SECONDARY_TYPE, e);
theSecondaryType = "GeoNaMetadata";
}
LOG.warn("\n\n\nHARD-CABLING THE SCOPE, PLEASE REMOTE IT!!!!\n\n\n");
scope = "/gcube/devsec/devVRE";
GeonaISConfig configs = new GeonaISConfig(theSecondaryType, scope);
LOG.info("returning config: "+configs);
return configs;
}
private void prettyPrintClientDataEntryMap(HashMap<ConcessioniFormCardTitle, List<GeoNaFormDataObject>> toMap) {

View File

@ -0,0 +1,55 @@
package org.gcube.portlets.user.geoportaldataentry.shared;
import java.io.Serializable;
public class GeonaISConfig implements Serializable{
/**
*
*/
private static final long serialVersionUID = -6700506811708315617L;
String gRSecondaryType;
String scope;
public GeonaISConfig() {
}
public GeonaISConfig(String gRSecondaryType, String scope) {
super();
this.gRSecondaryType = gRSecondaryType;
this.scope = scope;
}
public String getgRSecondaryType() {
return gRSecondaryType;
}
public void setgRSecondaryType(String gRSecondaryType) {
this.gRSecondaryType = gRSecondaryType;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GeonaISConfig [gRSecondaryType=");
builder.append(gRSecondaryType);
builder.append(", scope=");
builder.append(scope);
builder.append("]");
return builder.toString();
}
}

View File

@ -35,6 +35,11 @@
<url-pattern>/GeoPortalDataEntryApp/metadataProfileFormBuilderUploadServlet</url-pattern>
</servlet-mapping>
<context-param>
<param-name>GEONA_GENERIC_RESOURCE_SECONDARY_TYPE</param-name>
<param-value>GeoNaMetadata</param-value>
</context-param>
<!-- Default page to serve -->
<welcome-file-list>