Managing multiple data-entry types
This commit is contained in:
parent
4a725573c9
commit
3b8883b1fa
|
@ -15,9 +15,9 @@ import org.gcube.application.geoportalcommon.shared.config.ACTION_ON_ITEM;
|
|||
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.geoportalconfig.ConfigurationVO;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.DocumentConfigVO;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.GcubeProfileVO;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.ConfigurationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.DocumentConfigDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.GcubeProfileDV;
|
||||
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;
|
||||
|
@ -99,7 +99,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
private GeonaDataEntryMainForm geoNaMainForm = null;
|
||||
|
||||
private Collection<GeoNaFormCardModel> orderedCards;
|
||||
private Collection<GeoNaFormCardModel> orderedCards = new ArrayList<GeoNaFormCardModel>();
|
||||
|
||||
private GeonaMainTabPanel mainTabPanel;
|
||||
|
||||
|
@ -111,24 +111,32 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
private UserRights myRights = null;
|
||||
|
||||
private LoaderIcon loader = new LoaderIcon("Loading Application...");
|
||||
|
||||
private LoaderIcon loader = new LoaderIcon("Loading Application... please wait");
|
||||
|
||||
private List<ItemField> displayFields = new ArrayList<ItemField>();
|
||||
private List<ItemField> sortByFields = new ArrayList<ItemField>();
|
||||
private List<ItemField> searchByFields = new ArrayList<ItemField>();
|
||||
|
||||
|
||||
private GeonaISConfig geonaISConfig;
|
||||
|
||||
private TreeMap<String, List<GeoNaFormCardModel>> mapGcubeProfilePerItemType = new TreeMap<String, List<GeoNaFormCardModel>>();
|
||||
|
||||
private int numberOfCards = 0;
|
||||
|
||||
|
||||
private int expectedCards = 0;
|
||||
|
||||
|
||||
private synchronized void incrementNumberOfCards() {
|
||||
numberOfCards++;
|
||||
}
|
||||
|
||||
|
||||
private synchronized int getNumberOfCards() {
|
||||
return numberOfCards;
|
||||
}
|
||||
|
||||
private List<DocumentConfigDV> listDocumentConfigs;
|
||||
|
||||
private boolean dataEntryProjectCreated = false;
|
||||
|
||||
/**
|
||||
* This is the entry point method.
|
||||
*/
|
||||
|
@ -154,99 +162,107 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
@Override
|
||||
public void onSuccess(GeonaISConfig result) {
|
||||
geonaISConfig = result;
|
||||
|
||||
if (result!= null && result.getScope() != null) {
|
||||
|
||||
loadGeoportalConfigsAndBuildCards(result.getScope());
|
||||
if (result != null && result.getScope() != null) {
|
||||
|
||||
loadGeoportalConfigs(result.getScope());
|
||||
} else
|
||||
Window.alert(
|
||||
"Sorry, no scope found in the session. Re-login and try again");
|
||||
Window.alert("Sorry, no scope found in the session. Re-login and try again");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance().readDataViewerConfig(new AsyncCallback<GNADataEntryExtConfigProfile>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
String errorMsg = "Sorry, an error occurrend on istancing the application. Please, contact the support";
|
||||
Alert alert = new Alert(errorMsg, AlertType.ERROR);
|
||||
alert.setClose(false);
|
||||
try {
|
||||
RootPanel.get(DIV_PORTLET_ID).remove(loader);
|
||||
} catch (Exception e) {
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance()
|
||||
.readDataViewerConfig(new AsyncCallback<GNADataEntryExtConfigProfile>() {
|
||||
|
||||
}
|
||||
RootPanel.get(DIV_PORTLET_ID).add(alert);
|
||||
Window.alert(errorMsg);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
String errorMsg = "Sorry, an error occurrend on istancing the application. Please, contact the support";
|
||||
Alert alert = new Alert(errorMsg, AlertType.ERROR);
|
||||
alert.setClose(false);
|
||||
try {
|
||||
RootPanel.get(DIV_PORTLET_ID).remove(loader);
|
||||
} catch (Exception e) {
|
||||
|
||||
@Override
|
||||
public void onSuccess(GNADataEntryExtConfigProfile gNADataEntryConfig) {
|
||||
|
||||
try {
|
||||
RootPanel.get(DIV_PORTLET_ID).remove(loader);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
RootPanel.get(DIV_PORTLET_ID).add(alert);
|
||||
Window.alert(errorMsg);
|
||||
|
||||
}
|
||||
|
||||
List<ItemField> itemFields = gNADataEntryConfig.getListItemFields();
|
||||
|
||||
for (ItemField itemField : itemFields) {
|
||||
if(itemField.isDisplayAsResult()) {
|
||||
displayFields.add(itemField);
|
||||
}
|
||||
|
||||
if(itemField.isSearchable()) {
|
||||
searchByFields.add(itemField);
|
||||
}
|
||||
|
||||
if(itemField.isSortable()) {
|
||||
sortByFields.add(itemField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GWT.log("List display fields: "+itemFields);
|
||||
SearchingFilter initialSortFilter = new SearchingFilter();
|
||||
initialSortFilter.setOrder(ORDER.ASC);
|
||||
initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true)));
|
||||
|
||||
displayFields = itemFields;
|
||||
mainTabPanel = new GeonaMainTabPanel(appManagerBus, displayFields, sortByFields, searchByFields, initialSortFilter);
|
||||
mainTabPanel.setLoaderVisible("Loading...", true);
|
||||
|
||||
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
|
||||
mainTabPanel.addFormPanel(geoNaMainForm);
|
||||
|
||||
//PERMISSIONS
|
||||
myRights = gNADataEntryConfig.getUserRights();
|
||||
initGUI();
|
||||
GcubeUserRole userRole = myRights.getRoleRights().getUserRole();
|
||||
String msg = "Logged in as ";
|
||||
if(userRole != null && userRole.getName()!=null) {
|
||||
msg+= userRole.getName().substring(userRole.getName().indexOf("-")+1, userRole.getName().length());
|
||||
}else
|
||||
msg+="Member";
|
||||
|
||||
mainTabPanel.setRoleLabel(msg);
|
||||
|
||||
|
||||
RoleRights roleRights = myRights.getRoleRights();
|
||||
boolean canCreateNewItem = roleRights.getListPermessions().keySet().contains(ACTION_ON_ITEM.CREATE_NEW_PROJECT);
|
||||
@Override
|
||||
public void onSuccess(GNADataEntryExtConfigProfile gNADataEntryConfig) {
|
||||
|
||||
if (!canCreateNewItem) {
|
||||
// removing Tab "Create New Project"
|
||||
mainTabPanel.removeTab(0);
|
||||
// activating Tab "List of Project"
|
||||
mainTabPanel.setTabActive(0);
|
||||
mainTabPanel.instanceAndShowListOfConcessioni();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
try {
|
||||
RootPanel.get(DIV_PORTLET_ID).remove(loader);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
List<ItemField> itemFields = gNADataEntryConfig.getListItemFields();
|
||||
|
||||
for (ItemField itemField : itemFields) {
|
||||
if (itemField.isDisplayAsResult()) {
|
||||
displayFields.add(itemField);
|
||||
}
|
||||
|
||||
if (itemField.isSearchable()) {
|
||||
searchByFields.add(itemField);
|
||||
}
|
||||
|
||||
if (itemField.isSortable()) {
|
||||
sortByFields.add(itemField);
|
||||
}
|
||||
}
|
||||
|
||||
GWT.log("List display fields: " + itemFields);
|
||||
SearchingFilter initialSortFilter = new SearchingFilter();
|
||||
initialSortFilter.setOrder(ORDER.ASC);
|
||||
initialSortFilter.setOrderByFields(
|
||||
Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true)));
|
||||
|
||||
displayFields = itemFields;
|
||||
mainTabPanel = new GeonaMainTabPanel(appManagerBus, displayFields, sortByFields, searchByFields,
|
||||
initialSortFilter);
|
||||
|
||||
// TWICE BECAUSE THE MAIN PANEL COULD BE NULL BEFORE
|
||||
setListDocumentConfig(listDocumentConfigs);
|
||||
|
||||
// if (dataEntryProjectCreated)
|
||||
// mainTabPanel.setLoaderVisible("Loading...", true);
|
||||
|
||||
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
|
||||
mainTabPanel.addFormPanel(geoNaMainForm);
|
||||
|
||||
// PERMISSIONS
|
||||
myRights = gNADataEntryConfig.getUserRights();
|
||||
initGUI();
|
||||
GcubeUserRole userRole = myRights.getRoleRights().getUserRole();
|
||||
String msg = "Logged in as ";
|
||||
if (userRole != null && userRole.getName() != null) {
|
||||
msg += userRole.getName().substring(userRole.getName().indexOf("-") + 1,
|
||||
userRole.getName().length());
|
||||
} else
|
||||
msg += "Member";
|
||||
|
||||
mainTabPanel.setRoleLabel(msg);
|
||||
|
||||
RoleRights roleRights = myRights.getRoleRights();
|
||||
boolean canCreateNewItem = roleRights.getListPermessions().keySet()
|
||||
.contains(ACTION_ON_ITEM.CREATE_NEW_PROJECT);
|
||||
|
||||
if (!canCreateNewItem) {
|
||||
// removing Tab "Create New Project"
|
||||
mainTabPanel.removeTab(0);
|
||||
// activating Tab "List of Project"
|
||||
mainTabPanel.setTabActive(0);
|
||||
mainTabPanel.instanceAndShowListOfConcessioni();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initGUI() {
|
||||
|
@ -267,90 +283,44 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
element.click();
|
||||
}-*/;
|
||||
|
||||
|
||||
private void loadGeoportalConfigsAndBuildCards(final String scope) {
|
||||
GWT.log("loading GeoportalConfigsAndBuildCards in the scope: "+scope);
|
||||
private void loadGeoportalConfigs(final String scope) {
|
||||
GWT.log("loading GeoportalConfigsAndBuildCards in the scope: " + scope);
|
||||
orderedCards = new ArrayList<GeoNaFormCardModel>();
|
||||
//TODO PASS THE RIGHT ID
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance().getDocumentConfigurationForId("id", new AsyncCallback<DocumentConfigVO>() {
|
||||
// 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 onFailure(Throwable caught) {
|
||||
GWT.log("caught: " + caught);
|
||||
Window.alert(caught.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(DocumentConfigVO result) {
|
||||
GWT.log("DocumentConfigVO: "+result);
|
||||
|
||||
ConfigurationVO config = result.getConfiguration();
|
||||
|
||||
if(config==null) {
|
||||
Window.alert("No Configuration found in this scope. Please contact the support");
|
||||
return;
|
||||
}
|
||||
|
||||
if(config.getGcubeProfiles()==null || config.getGcubeProfiles().size()==0) {
|
||||
Window.alert("No GcubeProfiles found in the Configuration. Please contact the support");
|
||||
return;
|
||||
}
|
||||
|
||||
numberOfCards = 0;
|
||||
expectedCards = config.getGcubeProfiles().size();
|
||||
GWT.log("expectedCards are: " + expectedCards);
|
||||
TreeMap<Integer, GeoNaFormCardModel> treemapOrderedGeoNaProfiles = new TreeMap<Integer, GeoNaFormCardModel>();
|
||||
@Override
|
||||
public void onSuccess(List<DocumentConfigDV> result) {
|
||||
listDocumentConfigs = result;
|
||||
GWT.log("List<DocumentConfigDV>: " + result);
|
||||
|
||||
for (int i = 0; i<expectedCards; i++) {
|
||||
GcubeProfileVO gcubeProfiles = config.getGcubeProfiles().get(i);
|
||||
final int order = i;
|
||||
GWT.log("calling getProfilesInTheScope for secondaryType: "+gcubeProfiles.getGcubeSecondaryType()+", name: "+gcubeProfiles.getGcubeName());
|
||||
MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScopeForName(scope, gcubeProfiles.getGcubeSecondaryType(), gcubeProfiles.getGcubeName(),
|
||||
new AsyncCallback<List<MetaDataProfileBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<MetaDataProfileBean> result) {
|
||||
incrementNumberOfCards();
|
||||
GWT.log("loaded "+getNumberOfCards()+" of "+expectedCards+" card/s");
|
||||
GWT.log("Returned " + result.size() + " profile/s");
|
||||
//orderedCards = setGeoNaFormsOrder(result);
|
||||
for (MetaDataProfileBean metaDataProfileBean : result) {
|
||||
|
||||
String theMetaType = metaDataProfileBean.getType().toLowerCase();
|
||||
GWT.log("Building form card for type: " + theMetaType);
|
||||
|
||||
//Managing Forms repeatability
|
||||
int minOccurs = gcubeProfiles.getMinOccurs();
|
||||
minOccurs = minOccurs<=0?0:minOccurs;
|
||||
int maxOccurs = gcubeProfiles.getMaxOccurs();
|
||||
maxOccurs = maxOccurs<=0?Integer.MAX_VALUE:maxOccurs;
|
||||
|
||||
//TODO MUST BE MANAGED MIN_OCCURS
|
||||
ConcessioniFormCardTitle cct = new ConcessioniFormCardTitle(gcubeProfiles.getSectionName(), gcubeProfiles.getSectionTitle(), order, maxOccurs>1, minOccurs, maxOccurs);
|
||||
GeoNaFormCardModel geonaForm = new GeoNaFormCardModel(metaDataProfileBean, null, cct, gcubeProfiles);
|
||||
|
||||
treemapOrderedGeoNaProfiles.put(order, geonaForm);
|
||||
}
|
||||
|
||||
if(getNumberOfCards()==expectedCards) {
|
||||
// ordered values
|
||||
GWT.log("TreMap values: "+treemapOrderedGeoNaProfiles.values());
|
||||
orderedCards.addAll(treemapOrderedGeoNaProfiles.values());
|
||||
buildNewCards(orderedCards, OPERATION.UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if (result == null || result.size() == 0) {
|
||||
Window.alert("No Configuration found in this scope. Please contact the support");
|
||||
return;
|
||||
}
|
||||
|
||||
setListDocumentConfig(listDocumentConfigs);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setListDocumentConfig(List<DocumentConfigDV> listDocumentConfigs) {
|
||||
GWT.log("Setting setListDocumentConfig: " + listDocumentConfigs);
|
||||
if (listDocumentConfigs != null) {
|
||||
|
||||
if (mainTabPanel != null) {
|
||||
mainTabPanel.setListDocumentConfig(listDocumentConfigs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update window size
|
||||
*/
|
||||
|
@ -375,10 +345,90 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
}
|
||||
|
||||
private void createNewDataEntyFor(DocumentConfigDV dcDV) {
|
||||
dataEntryProjectCreated = true;
|
||||
mainTabPanel.setLoaderVisible("Loading...", true);
|
||||
orderedCards.clear();
|
||||
resetUI();
|
||||
ConfigurationDV config = dcDV.getConfiguration();
|
||||
|
||||
List<GeoNaFormCardModel> cardsPerIT = mapGcubeProfilePerItemType.get(dcDV.getItemType());
|
||||
mainTabPanel.setPageHeader(dcDV);
|
||||
|
||||
if (cardsPerIT != null) {
|
||||
orderedCards.addAll(cardsPerIT);
|
||||
buildNewCards(orderedCards, OPERATION.NEW);
|
||||
return;
|
||||
}
|
||||
|
||||
numberOfCards = 0;
|
||||
expectedCards = config.getGcubeProfiles().size();
|
||||
GWT.log("expectedCards are: " + expectedCards);
|
||||
TreeMap<Integer, GeoNaFormCardModel> treemapOrderedGeoNaProfiles = new TreeMap<Integer, GeoNaFormCardModel>();
|
||||
|
||||
for (int i = 0; i < expectedCards; i++) {
|
||||
GcubeProfileDV gcubeProfiles = config.getGcubeProfiles().get(i);
|
||||
final int order = i;
|
||||
GWT.log("calling getProfilesInTheScope for secondaryType: " + gcubeProfiles.getGcubeSecondaryType()
|
||||
+ ", name: " + gcubeProfiles.getGcubeName());
|
||||
MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScopeForName(
|
||||
geonaISConfig.getScope(), gcubeProfiles.getGcubeSecondaryType(), gcubeProfiles.getGcubeName(),
|
||||
new AsyncCallback<List<MetaDataProfileBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<MetaDataProfileBean> result) {
|
||||
|
||||
incrementNumberOfCards();
|
||||
GWT.log("loaded " + getNumberOfCards() + " of " + expectedCards + " card/s");
|
||||
GWT.log("Returned " + result.size() + " profile/s");
|
||||
// orderedCards = setGeoNaFormsOrder(result);
|
||||
for (MetaDataProfileBean metaDataProfileBean : result) {
|
||||
|
||||
String theMetaType = metaDataProfileBean.getType().toLowerCase();
|
||||
GWT.log("Building form card for type: " + theMetaType);
|
||||
|
||||
// Managing Forms repeatability
|
||||
int minOccurs = gcubeProfiles.getMinOccurs();
|
||||
minOccurs = minOccurs <= 0 ? 0 : minOccurs;
|
||||
int maxOccurs = gcubeProfiles.getMaxOccurs();
|
||||
maxOccurs = maxOccurs <= 0 ? Integer.MAX_VALUE : maxOccurs;
|
||||
|
||||
// TODO MUST BE MANAGED MIN_OCCURS
|
||||
ConcessioniFormCardTitle cct = new ConcessioniFormCardTitle(
|
||||
gcubeProfiles.getSectionName(), gcubeProfiles.getSectionTitle(), order,
|
||||
maxOccurs > 1, minOccurs, maxOccurs);
|
||||
GeoNaFormCardModel geonaForm = new GeoNaFormCardModel(metaDataProfileBean, null, cct,
|
||||
gcubeProfiles);
|
||||
|
||||
treemapOrderedGeoNaProfiles.put(order, geonaForm);
|
||||
}
|
||||
|
||||
if (getNumberOfCards() == expectedCards) {
|
||||
mainTabPanel.setLoaderVisible("Loading...", false);
|
||||
// ordered values
|
||||
Collection<GeoNaFormCardModel> gnaCardsModels = treemapOrderedGeoNaProfiles.values();
|
||||
GWT.log("TreMap values: " + gnaCardsModels);
|
||||
orderedCards.addAll(gnaCardsModels);
|
||||
mapGcubeProfilePerItemType.put(dcDV.getItemType(),
|
||||
new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
|
||||
buildNewCards(orderedCards, OPERATION.UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
mainTabPanel.setLoaderVisible("Loading...", false);
|
||||
Window.alert(caught.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards, OPERATION operation) {
|
||||
projectSavedWithSuccess = false; // resetting state of saving
|
||||
mainTabPanel.setLoaderVisible("Loading...", true);
|
||||
geoNaMainForm.setVisibleFormActions(true);
|
||||
resetUI();
|
||||
// ordered values
|
||||
for (GeoNaFormCardModel geonaForm : orderedCards) {
|
||||
|
@ -408,7 +458,6 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
mapForms.clear();
|
||||
}
|
||||
|
||||
|
||||
private void bindEvents() {
|
||||
|
||||
appManagerBus.addHandler(SaveGeonaDataFormsEvent.TYPE, new SaveGeonaDataFormsHandler() {
|
||||
|
@ -545,21 +594,52 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
@Override
|
||||
public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) {
|
||||
GWT.log("Crate new project");
|
||||
if (!dataEntryProjectCreated) {
|
||||
createNewDataEntyFor(newProjectEvent.getDocumentConfiguration());
|
||||
return;
|
||||
}
|
||||
|
||||
// means the form was not submitted
|
||||
if (savedMap.size() == 0) {
|
||||
boolean confirm = Window.confirm(
|
||||
"Creating a new project, the current project (is not saved) and will be lost, Confirm?");
|
||||
if (confirm)
|
||||
buildNewCards(orderedCards, OPERATION.NEW);
|
||||
|
||||
DialogConfirm confirm = new DialogConfirm(null, "Creating a New Project...",
|
||||
"The current project (is not saved) and will be lost. Confirm?");
|
||||
|
||||
confirm.getYesButton().addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
confirm.hide();
|
||||
createNewDataEntyFor(newProjectEvent.getDocumentConfiguration());
|
||||
// buildNewCards(orderedCards, OPERATION.NEW);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
confirm.center();
|
||||
|
||||
} else if (projectSavedWithSuccess) {
|
||||
// means the project has been saved
|
||||
buildNewCards(orderedCards, OPERATION.NEW);
|
||||
createNewDataEntyFor(newProjectEvent.getDocumentConfiguration());
|
||||
// buildNewCards(orderedCards, OPERATION.NEW);
|
||||
} else {
|
||||
// means the project reported one ore more errors after the submit
|
||||
boolean confirm = Window.confirm("Creating a new project, the web-forms will be cleaned, Confirm?");
|
||||
if (confirm)
|
||||
buildNewCards(orderedCards, OPERATION.NEW);
|
||||
|
||||
DialogConfirm confirm = new DialogConfirm(null, "Creating a New Project...",
|
||||
"The data entry form/s will be cleaned. Confirm?");
|
||||
|
||||
confirm.getYesButton().addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
confirm.hide();
|
||||
createNewDataEntyFor(newProjectEvent.getDocumentConfiguration());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
confirm.center();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -578,7 +658,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
mainTabPanel.showListOfConcessioniView(grpw);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
appManagerBus.addHandler(ActionPerformedOnItemEvent.TYPE, new ActionPerformedOnItemEventHandler() {
|
||||
|
||||
@Override
|
||||
|
@ -652,37 +732,41 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
final ConcessioneDV concessione = (ConcessioneDV) item;
|
||||
GWT.log("onDoActionFired item: " + concessione);
|
||||
|
||||
|
||||
// Checking if the user is NOT authorized to perform this action in two ways:
|
||||
// 1. the map of actions allowed for the user does not contain the action;
|
||||
RoleRights roleRights = myRights.getRoleRights();
|
||||
OPERATION_TYPE operationType = roleRights.getListPermessions().get(action);
|
||||
boolean allowedOperationForUser = operationType != null? true:false;
|
||||
boolean allowedOperationForUser = operationType != null ? true : false;
|
||||
if (!allowedOperationForUser) {
|
||||
|
||||
String msg = "You are not authorized to perform the action: "+ action.getLabel();
|
||||
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), "Forbidden: "+action, msg, AlertType.WARNING);
|
||||
|
||||
String msg = "You are not authorized to perform the action: " + action.getLabel();
|
||||
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()),
|
||||
"Forbidden: " + action, msg, AlertType.WARNING);
|
||||
modalW.show();
|
||||
return;
|
||||
}
|
||||
// 2. the user cannot access to action (e.g. the user cannot write an item of another user)
|
||||
// 2. the user cannot access to action (e.g. the user cannot write an item of
|
||||
// another user)
|
||||
// if so an error is shown
|
||||
GcubeUserRole userRole = myRights.getRoleRights().getUserRole();
|
||||
boolean allowedWriteActionOnItem = checkAccessToOperationType(userRole, operationType, concessione);
|
||||
boolean allowedWriteActionOnItem = checkAccessToOperationType(userRole, operationType,
|
||||
concessione);
|
||||
if (!allowedWriteActionOnItem) {
|
||||
String title = "Forbidden: missing write access";
|
||||
String msg = "You do not have write access to item: "+ concessione.getNome();
|
||||
if(!userRole.isWriteOwn()) {
|
||||
msg = "You do not have write access to item: "+ concessione.getNome();
|
||||
}else if (!userRole.isWriteAny()){
|
||||
String msg = "You do not have write access to item: " + concessione.getNome();
|
||||
if (!userRole.isWriteOwn()) {
|
||||
msg = "You do not have write access to item: " + concessione.getNome();
|
||||
} else if (!userRole.isWriteAny()) {
|
||||
title = "Forbidden: missing ownership";
|
||||
msg = "You are not the creator of: "+ concessione.getNome() +". You cannot access to it";
|
||||
msg = "You are not the creator of: " + concessione.getNome()
|
||||
+ ". You cannot access to it";
|
||||
}
|
||||
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), title, msg, AlertType.WARNING);
|
||||
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), title, msg,
|
||||
AlertType.WARNING);
|
||||
modalW.show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (action) {
|
||||
case VIEW_ON_MAP:
|
||||
|
@ -828,8 +912,9 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
});
|
||||
}
|
||||
|
||||
private boolean checkAccessToOperationType(GcubeUserRole userRole, OPERATION_TYPE allowedAction, ConcessioneDV concessione) {
|
||||
|
||||
private boolean checkAccessToOperationType(GcubeUserRole userRole, OPERATION_TYPE allowedAction,
|
||||
ConcessioneDV concessione) {
|
||||
|
||||
boolean writeAnyAPassed = false;
|
||||
boolean writeOwnPassed = false;
|
||||
|
@ -845,37 +930,37 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
String ownerUser = concessione.getCreationUser();
|
||||
if (ownerUser == null || ownerUser.isEmpty()) {
|
||||
writeOwnPassed = false;
|
||||
}else if (ownerUser.compareTo(myRights.getMyUsername()) == 0) {
|
||||
} else if (ownerUser.compareTo(myRights.getMyUsername()) == 0) {
|
||||
// if my username is equal the owner of the concessione
|
||||
writeOwnPassed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean operationAllowed = false;
|
||||
switch (allowedAction) {
|
||||
case READ:
|
||||
//Access to READ operation is allowed to everyone
|
||||
// Access to READ operation is allowed to everyone
|
||||
operationAllowed = true;
|
||||
GWT.log(OPERATION_TYPE.READ+ " ALLOWED? "+operationAllowed);
|
||||
GWT.log(OPERATION_TYPE.READ + " ALLOWED? " + operationAllowed);
|
||||
break;
|
||||
case READ_WRITE:
|
||||
//Access to READ_WRITE operation
|
||||
// Access to READ_WRITE operation
|
||||
operationAllowed = writeAnyAPassed || writeOwnPassed;
|
||||
GWT.log(OPERATION_TYPE.READ_WRITE+ " ALLOWED? "+operationAllowed);
|
||||
GWT.log(OPERATION_TYPE.READ_WRITE + " ALLOWED? " + operationAllowed);
|
||||
break;
|
||||
case WRITE:
|
||||
//Access to WRITE operation
|
||||
// Access to WRITE operation
|
||||
operationAllowed = writeAnyAPassed || writeOwnPassed;
|
||||
GWT.log(OPERATION_TYPE.WRITE+ " ALLOWED? "+operationAllowed);
|
||||
GWT.log(OPERATION_TYPE.WRITE + " ALLOWED? " + operationAllowed);
|
||||
break;
|
||||
case UNKNOWN:
|
||||
operationAllowed = false;
|
||||
GWT.log(OPERATION_TYPE.UNKNOWN+ " ALLOWED? "+operationAllowed);
|
||||
GWT.log(OPERATION_TYPE.UNKNOWN + " ALLOWED? " + operationAllowed);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return operationAllowed;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.DocumentConfigVO;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.DocumentConfigDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV;
|
||||
|
@ -146,6 +146,6 @@ public interface GeoportalDataEntryService extends RemoteService {
|
|||
* @param id the id
|
||||
* @return the document configuration for id
|
||||
*/
|
||||
DocumentConfigVO getDocumentConfigurationForId(String id);
|
||||
List<DocumentConfigDV> getListDocumentConfigurationForId(String id);
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.DocumentConfigVO;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.DocumentConfigDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV;
|
||||
|
@ -64,6 +64,6 @@ public interface GeoportalDataEntryServiceAsync {
|
|||
|
||||
void readDataViewerConfig(AsyncCallback<GNADataEntryExtConfigProfile> asyncCallback);
|
||||
|
||||
void getDocumentConfigurationForId(String id, AsyncCallback<DocumentConfigVO> callback);
|
||||
void getListDocumentConfigurationForId(String id, AsyncCallback<List<DocumentConfigDV>> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.events;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.DocumentConfigDV;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CreateNewProjectEvent.
|
||||
*
|
||||
|
@ -15,11 +15,13 @@ public class CreateNewProjectEvent extends GwtEvent<CreateNewProjectEventHandler
|
|||
|
||||
/** The type. */
|
||||
public static Type<CreateNewProjectEventHandler> TYPE = new Type<CreateNewProjectEventHandler>();
|
||||
private DocumentConfigDV documentConfiguration;
|
||||
|
||||
/**
|
||||
* Instantiates a new cancel upload event.
|
||||
*/
|
||||
public CreateNewProjectEvent() {
|
||||
public CreateNewProjectEvent(DocumentConfigDV documentConfiguration) {
|
||||
this.documentConfiguration = documentConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,5 +49,9 @@ public class CreateNewProjectEvent extends GwtEvent<CreateNewProjectEventHandler
|
|||
protected void dispatch(CreateNewProjectEventHandler handler) {
|
||||
handler.onCreateNewProject(this);
|
||||
}
|
||||
|
||||
public DocumentConfigDV getDocumentConfiguration() {
|
||||
return documentConfiguration;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,18 +11,22 @@ 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.geoportalconfig.ConfigurationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.DocumentConfigDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
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.CreateNewProjectEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent;
|
||||
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.LoaderIcon;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.Dropdown;
|
||||
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||
import com.github.gwtbootstrap.client.ui.PageHeader;
|
||||
import com.github.gwtbootstrap.client.ui.Tab;
|
||||
import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
|
@ -76,7 +80,7 @@ public class GeonaMainTabPanel extends Composite {
|
|||
HTMLPanel geonaMainFormPanel;
|
||||
|
||||
@UiField
|
||||
HTMLPanel geonaListOfConcessioniPanel;
|
||||
HTMLPanel geonaListOfRecordsPanel;
|
||||
|
||||
/** The geona main form panel. */
|
||||
@UiField
|
||||
|
@ -89,8 +93,8 @@ public class GeonaMainTabPanel extends Composite {
|
|||
@UiField
|
||||
LoaderIcon loader;
|
||||
|
||||
@UiField
|
||||
NavLink buttCreateNewProject;
|
||||
// @UiField
|
||||
// NavLink buttCreateNewProject;
|
||||
|
||||
@UiField
|
||||
NavLink buttonReloadConcessioni;
|
||||
|
@ -133,10 +137,16 @@ public class GeonaMainTabPanel extends Composite {
|
|||
|
||||
@UiField
|
||||
Button resetSearch;
|
||||
|
||||
|
||||
@UiField
|
||||
Label roleLabel;
|
||||
|
||||
@UiField
|
||||
Dropdown ddCreateNewProject;
|
||||
|
||||
@UiField
|
||||
PageHeader pageHeaderDataEntry;
|
||||
|
||||
private HandlerManager appManagerBus;
|
||||
|
||||
private List<ItemField> sortByFields;
|
||||
|
@ -149,6 +159,8 @@ public class GeonaMainTabPanel extends Composite {
|
|||
|
||||
private List<ItemField> displayFields;
|
||||
|
||||
private List<DocumentConfigDV> listDocumentConfig;
|
||||
|
||||
/**
|
||||
* Instantiates a new geona main tab panel.
|
||||
*
|
||||
|
@ -173,10 +185,13 @@ public class GeonaMainTabPanel extends Composite {
|
|||
|
||||
alertSearchFor.setText(searchForFields.get(0).getDisplayName());
|
||||
alertSortBy.setText(toLabelFilter((initialSortFilter.getOrderByFields().get(0)), initialSortFilter.getOrder()));
|
||||
|
||||
|
||||
pageHeaderDataEntry.setHeight("25px");
|
||||
bindEvents();
|
||||
resetSearch.setIconSize(IconSize.TWO_TIMES);
|
||||
resetSearch.setType(ButtonType.LINK);
|
||||
|
||||
setLoaderVisible("", false);
|
||||
}
|
||||
|
||||
public void setInternalHeight(int height) {
|
||||
|
@ -189,14 +204,14 @@ public class GeonaMainTabPanel extends Composite {
|
|||
*/
|
||||
private void bindEvents() {
|
||||
|
||||
buttCreateNewProject.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
appManagerBus.fireEvent(new CreateNewProjectEvent());
|
||||
|
||||
}
|
||||
});
|
||||
// buttCreateNewProject.addClickHandler(new ClickHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(ClickEvent event) {
|
||||
// appManagerBus.fireEvent(new CreateNewProjectEvent());
|
||||
//
|
||||
// }
|
||||
// });
|
||||
|
||||
buttonReloadConcessioni.addClickHandler(new ClickHandler() {
|
||||
|
||||
|
@ -347,7 +362,7 @@ public class GeonaMainTabPanel extends Composite {
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setRoleLabel(String msg) {
|
||||
roleLabel.setText(msg);
|
||||
}
|
||||
|
@ -384,11 +399,11 @@ public class GeonaMainTabPanel extends Composite {
|
|||
*/
|
||||
public void showListOfConcessioniView(GeonaRecordsPaginatedView grpw) {
|
||||
this.grpw = grpw;
|
||||
geonaListOfConcessioniPanel.clear();
|
||||
geonaListOfRecordsPanel.clear();
|
||||
VerticalPanel htmllPanel = new VerticalPanel();
|
||||
htmllPanel.add(grpw.getCellPanel());
|
||||
htmllPanel.add(grpw.getPagerPanel());
|
||||
geonaListOfConcessioniPanel.add(htmllPanel);
|
||||
geonaListOfRecordsPanel.add(htmllPanel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -472,4 +487,35 @@ public class GeonaMainTabPanel extends Composite {
|
|||
showListOfConcessioniView(grpw);
|
||||
}
|
||||
|
||||
public void setListDocumentConfig(List<DocumentConfigDV> listDocumentConfig) {
|
||||
this.listDocumentConfig = listDocumentConfig;
|
||||
ddCreateNewProject.clear();
|
||||
for (DocumentConfigDV documentConfigDV : listDocumentConfig) {
|
||||
NavLink link = new NavLink(documentConfigDV.getItemType());
|
||||
link.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
ConfigurationDV config = documentConfigDV.getConfiguration();
|
||||
|
||||
if (config.getGcubeProfiles() == null || config.getGcubeProfiles().size() == 0) {
|
||||
DialogInform di = new DialogInform(null, "No configuration found", "No GcubeProfile found in the Configuration for " + documentConfigDV.getItemType());
|
||||
di.center();
|
||||
return;
|
||||
}
|
||||
|
||||
appManagerBus.fireEvent(new CreateNewProjectEvent(documentConfigDV));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ddCreateNewProject.add(link);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPageHeader(DocumentConfigDV dcDV) {
|
||||
this.pageHeaderDataEntry.setText("");
|
||||
this.pageHeaderDataEntry.setSubtext("New: "+dcDV.getItemType());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -62,16 +62,19 @@
|
|||
<b:Navbar addStyleNames="{style.margin-bottom-5}">
|
||||
<b:Brand addStyleNames="{style.margin-top-5}">New Project</b:Brand>
|
||||
<b:Nav>
|
||||
<b:NavLink ui:field="buttCreateNewProject"
|
||||
title="Create a new Project" icon="FILE">Create New Project</b:NavLink>
|
||||
<b:Dropdown text="Create New Project"
|
||||
ui:field="ddCreateNewProject" icon="FILE">
|
||||
</b:Dropdown>
|
||||
</b:Nav>
|
||||
</b:Navbar>
|
||||
<g:HTMLPanel addStyleNames="{style.float-right}">
|
||||
<div id="topPage"></div>
|
||||
<a href="#bottomPage">Go to bottom</a>
|
||||
</g:HTMLPanel>
|
||||
<b:PageHeader subtext='select "Create New Project"' ui:field="pageHeaderDataEntry">Welcome to GNA Data Entry</b:PageHeader>
|
||||
<r:LoaderIcon ui:field="loader"></r:LoaderIcon>
|
||||
<g:HTMLPanel ui:field="geonaMainFormPanel"></g:HTMLPanel>
|
||||
<g:HTMLPanel ui:field="geonaMainFormPanel">
|
||||
</g:HTMLPanel>
|
||||
<g:HTMLPanel addStyleNames="{style.float-right}">
|
||||
<div id="bottomPage"></div>
|
||||
<a href="#topPage">Go to top</a>
|
||||
|
@ -133,7 +136,8 @@
|
|||
<div id="topPage2"></div>
|
||||
<a href="#bottomPage2">Go to bottom</a>
|
||||
</g:HTMLPanel>
|
||||
<g:HTMLPanel ui:field="geonaListOfConcessioniPanel"></g:HTMLPanel>
|
||||
<g:HTMLPanel ui:field="geonaListOfRecordsPanel">
|
||||
</g:HTMLPanel>
|
||||
<g:HTMLPanel addStyleNames="{style.float-right}">
|
||||
<div id="bottomPage2"></div>
|
||||
<a href="#topPage2">Go to top</a>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.ui.card;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.GcubeProfileVO;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.GcubeProfileDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
|
||||
|
@ -10,14 +10,14 @@ public class GeoNaFormCardModel {
|
|||
private MetaDataProfileBean metadataProfileBean;
|
||||
private CreateMetadataForm metadataForm;
|
||||
private ConcessioniFormCardTitle formCardTitle; // matching with metadata profile type
|
||||
private GcubeProfileVO gcubeProfile;
|
||||
private GcubeProfileDV gcubeProfile;
|
||||
|
||||
public GeoNaFormCardModel() {
|
||||
|
||||
}
|
||||
|
||||
public GeoNaFormCardModel(MetaDataProfileBean metadataProfileBean, CreateMetadataForm metadataForm,
|
||||
ConcessioniFormCardTitle formCardTitle, GcubeProfileVO gcubeProfile) {
|
||||
ConcessioniFormCardTitle formCardTitle, GcubeProfileDV gcubeProfile) {
|
||||
super();
|
||||
this.metadataProfileBean = metadataProfileBean;
|
||||
this.metadataForm = metadataForm;
|
||||
|
@ -49,11 +49,11 @@ public class GeoNaFormCardModel {
|
|||
this.formCardTitle = formCardTitle;
|
||||
}
|
||||
|
||||
public GcubeProfileVO getGcubeProfile() {
|
||||
public GcubeProfileDV getGcubeProfile() {
|
||||
return gcubeProfile;
|
||||
}
|
||||
|
||||
public void setGcubeProfile(GcubeProfileVO gcubeProfile) {
|
||||
public void setGcubeProfile(GcubeProfileDV gcubeProfile) {
|
||||
this.gcubeProfile = gcubeProfile;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
|||
|
||||
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.FormActions;
|
||||
import com.github.gwtbootstrap.client.ui.Tab;
|
||||
import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
|
@ -27,121 +28,173 @@ import com.google.gwt.user.client.ui.Composite;
|
|||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
/**
|
||||
* The Class GeonaDataEntryMainForm.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 4, 2022
|
||||
*/
|
||||
public class GeonaDataEntryMainForm extends Composite {
|
||||
|
||||
private static GeonaDataEntryMainFormUiBinder uiBinder = GWT.create(GeonaDataEntryMainFormUiBinder.class);
|
||||
|
||||
/**
|
||||
* The Interface GeonaDataEntryMainFormUiBinder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 4, 2022
|
||||
*/
|
||||
interface GeonaDataEntryMainFormUiBinder extends UiBinder<Widget, GeonaDataEntryMainForm> {
|
||||
}
|
||||
|
||||
|
||||
private List<GeoNaFormCardModel> listCards = new ArrayList<GeoNaFormCardModel>();
|
||||
|
||||
@UiField
|
||||
HTMLPanel mainHTMLPanel;
|
||||
|
||||
|
||||
@UiField
|
||||
TabPanel mainTabPanel;
|
||||
|
||||
|
||||
@UiField
|
||||
AlertBlock alertFormAction;
|
||||
|
||||
|
||||
@UiField
|
||||
Button buttonSave;
|
||||
|
||||
private LinkedHashMap<String,MetadataFormCard> mapForms = new LinkedHashMap<String,MetadataFormCard>();
|
||||
|
||||
|
||||
@UiField
|
||||
FormActions formActions;
|
||||
|
||||
private LinkedHashMap<String, MetadataFormCard> mapForms = new LinkedHashMap<String, MetadataFormCard>();
|
||||
|
||||
private List<Tab> listTabs = new ArrayList<Tab>();
|
||||
|
||||
private HandlerManager appManagerBus;
|
||||
|
||||
/**
|
||||
* Instantiates a new geona data entry main form.
|
||||
*
|
||||
* @param appManagerBus the app manager bus
|
||||
*/
|
||||
public GeonaDataEntryMainForm(HandlerManager appManagerBus) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.appManagerBus = appManagerBus;
|
||||
}
|
||||
|
||||
public void addForm(String tabHeading, GeoNaFormCardModel geonFormModel){
|
||||
/**
|
||||
* Adds the form.
|
||||
*
|
||||
* @param tabHeading the tab heading
|
||||
* @param geonFormModel the geon form model
|
||||
*/
|
||||
public void addForm(String tabHeading, GeoNaFormCardModel geonFormModel) {
|
||||
listCards.add(geonFormModel);
|
||||
createNewCard(tabHeading, geonFormModel);
|
||||
}
|
||||
|
||||
|
||||
private void createNewCard(String tabHeading, final GeoNaFormCardModel geonFormModel){
|
||||
|
||||
/**
|
||||
* Creates the new card.
|
||||
*
|
||||
* @param tabHeading the tab heading
|
||||
* @param geonFormModel the geon form model
|
||||
*/
|
||||
private void createNewCard(String tabHeading, final GeoNaFormCardModel geonFormModel) {
|
||||
final Tab tab = new Tab();
|
||||
tab.setHeading(tabHeading);
|
||||
//MetadataFormCard mfc = new MetadataFormCard(tab, createMetadataForm, repeatible);
|
||||
MetadataFormCard mfc = new MetadataFormCard(tab,geonFormModel,appManagerBus);
|
||||
// MetadataFormCard mfc = new MetadataFormCard(tab, createMetadataForm,
|
||||
// repeatible);
|
||||
MetadataFormCard mfc = new MetadataFormCard(tab, geonFormModel, appManagerBus);
|
||||
listTabs.add(tab);
|
||||
mainTabPanel.add(tab);
|
||||
|
||||
if(listTabs.size()==1) {
|
||||
|
||||
if (listTabs.size() == 1) {
|
||||
tab.setActive(true);
|
||||
mainTabPanel.selectTab(0);
|
||||
}
|
||||
|
||||
|
||||
mapForms.put(tabHeading, mfc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset.
|
||||
*/
|
||||
public void reset() {
|
||||
mapForms.clear();
|
||||
mainTabPanel.clear();
|
||||
listTabs.clear();
|
||||
}
|
||||
|
||||
|
||||
public void selectTab(int index){
|
||||
|
||||
GWT.log("Selecting tab index: "+ index +" of "+listTabs.size());
|
||||
|
||||
if(listTabs.size()<index) {
|
||||
|
||||
/**
|
||||
* Select tab.
|
||||
*
|
||||
* @param index the index
|
||||
*/
|
||||
public void selectTab(int index) {
|
||||
|
||||
GWT.log("Selecting tab index: " + index + " of " + listTabs.size());
|
||||
|
||||
if (listTabs.size() < index) {
|
||||
mainTabPanel.selectTab(index);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save data.
|
||||
*
|
||||
* @param e the e
|
||||
*/
|
||||
@UiHandler("buttonSave")
|
||||
void saveData(ClickEvent e){
|
||||
|
||||
void saveData(ClickEvent e) {
|
||||
|
||||
boolean canSave = true;
|
||||
|
||||
|
||||
for (String metadataType : mapForms.keySet()) {
|
||||
MetadataFormCard card = mapForms.get(metadataType);
|
||||
boolean isValid = card.validateForm();
|
||||
card.setValidCard(isValid);
|
||||
if(isValid==false)
|
||||
if (isValid == false)
|
||||
canSave = false;
|
||||
}
|
||||
|
||||
|
||||
List<GeoNaFormDataObject> listGeonaFormObjects = new ArrayList<GeoNaFormDataObject>();
|
||||
|
||||
if(canSave) {
|
||||
|
||||
if (canSave) {
|
||||
for (String metadataType : mapForms.keySet()) {
|
||||
MetadataFormCard card = mapForms.get(metadataType);
|
||||
List<GenericDatasetBean> listGDB = new ArrayList<GenericDatasetBean>(card.getListForms().size());
|
||||
for (CreateMetadataForm form : card.getListForms()) {
|
||||
listGDB.add(form.getFormDataBean());
|
||||
|
||||
|
||||
}
|
||||
listGeonaFormObjects.add(new GeoNaFormDataObject(listGDB, card.getGeonaFormModel().getFormCardTitle()));
|
||||
}
|
||||
appManagerBus.fireEvent(new SaveGeonaDataFormsEvent(listGeonaFormObjects));
|
||||
}else {
|
||||
} else {
|
||||
showAlertOnSaveAction("Detected errors, please fix it/them", AlertType.ERROR, true);
|
||||
}
|
||||
|
||||
|
||||
//Window.alert("I can save: "+listGeonaFormObjects);
|
||||
|
||||
|
||||
// Window.alert("I can save: "+listGeonaFormObjects);
|
||||
|
||||
}
|
||||
|
||||
public void showAlertOnSaveAction(String text, AlertType type, boolean hideAfterAWhile){
|
||||
|
||||
//Window.alert("Called alertOnCreate");
|
||||
|
||||
/**
|
||||
* Show alert on save action.
|
||||
*
|
||||
* @param text the text
|
||||
* @param type the type
|
||||
* @param hideAfterAWhile the hide after A while
|
||||
*/
|
||||
public void showAlertOnSaveAction(String text, AlertType type, boolean hideAfterAWhile) {
|
||||
|
||||
// Window.alert("Called alertOnCreate");
|
||||
alertFormAction.setText(text);
|
||||
alertFormAction.setType(type);
|
||||
alertFormAction.setVisible(true);
|
||||
//goBackButtonSecondStep.setEnabled(true);
|
||||
// goBackButtonSecondStep.setEnabled(true);
|
||||
|
||||
if(hideAfterAWhile){
|
||||
if (hideAfterAWhile) {
|
||||
// hide after some seconds
|
||||
Timer t = new Timer() {
|
||||
|
||||
|
@ -155,20 +208,24 @@ public class GeonaDataEntryMainForm extends Composite {
|
|||
t.schedule(10000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable button save.
|
||||
*
|
||||
* @param enabled the enabled
|
||||
*/
|
||||
public void enableButtonSave(boolean enabled) {
|
||||
buttonSave.setEnabled(enabled);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the ative after.
|
||||
*
|
||||
* @param index the index
|
||||
* @param bool the bool
|
||||
* @param bool the bool
|
||||
*/
|
||||
public void setAtiveAfter(int index, boolean bool){
|
||||
|
||||
public void setAtiveAfter(int index, boolean bool) {
|
||||
|
||||
// if(listTabs.size()<index) {
|
||||
// for (int i = index; i < listTabs.size(); i++) {
|
||||
// listTabs.get(i).setEnabled(bool);
|
||||
|
@ -176,4 +233,13 @@ public class GeonaDataEntryMainForm extends Composite {
|
|||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the visible form actions.
|
||||
*
|
||||
* @param bool the new visible form actions
|
||||
*/
|
||||
public void setVisibleFormActions(boolean bool) {
|
||||
formActions.setVisible(bool);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<b:TabPanel ui:field="mainTabPanel" tabPosition="left">
|
||||
</b:TabPanel>
|
||||
<b:AlertBlock type="DEFAULT" visible="false" close="false" ui:field="alertFormAction"></b:AlertBlock>
|
||||
<b:FormActions>
|
||||
<b:FormActions ui:field="formActions" visible="false">
|
||||
<b:Button type="PRIMARY" icon="SAVE" ui:field="buttonSave">Save</b:Button>
|
||||
</b:FormActions>
|
||||
<!-- </b:AlertBlock> -->
|
||||
|
|
|
@ -24,7 +24,7 @@ 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.exception.GNAConfigException;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.DocumentConfigVO;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportalconfig.DocumentConfigDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
|
||||
|
@ -859,9 +859,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocumentConfigVO getDocumentConfigurationForId(String id){
|
||||
public List<DocumentConfigDV> getListDocumentConfigurationForId(String id){
|
||||
MockDocumentConfigurationReader mock = new MockDocumentConfigurationReader();
|
||||
return mock.getDocumentConfigVO();
|
||||
return mock.getListDocumentConfig();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue