edit_facility_26115 #3

Merged
francesco.mangiacrapa merged 37 commits from edit_facility_26115 into master 2024-03-19 10:21:22 +01:00
2 changed files with 91 additions and 61 deletions
Showing only changes of commit 9dca67e00f - Show all commits

View File

@ -32,6 +32,7 @@ import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetada
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CategoryPanel; import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CategoryPanel;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton; import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.tags.TagsPanel; import org.gcube.portlets.widgets.mpformbuilder.client.ui.tags.TagsPanel;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.utils.LoaderIcon;
import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean; import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
@ -68,7 +69,9 @@ import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Anchor; import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.FocusPanel; import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.SimplePanel;
@ -266,12 +269,6 @@ public class CreateDatasetForm extends Composite {
private static final String TRYING_TO_CREATE_PRODUCT = "Trying to publish the item, please wait..."; private static final String TRYING_TO_CREATE_PRODUCT = "Trying to publish the item, please wait...";
protected static final String MISSING_PUBLISH_RIGHTS = "It seems you are not authorized to publish on catalogue. Request it to the VRE manager or the portal administrator."; protected static final String MISSING_PUBLISH_RIGHTS = "It seems you are not authorized to publish on catalogue. Request it to the VRE manager or the portal administrator.";
// tab panel
private TabPanel tabPanel;
// add resource form
private AddResourceToDataset resourceForm;
// the licenses // the licenses
private List<LicenseBean> licenseBean; private List<LicenseBean> licenseBean;
@ -307,6 +304,8 @@ public class CreateDatasetForm extends Composite {
private WizardCreator wizCreator; private WizardCreator wizCreator;
private FlowPanel alertPanel = new FlowPanel();
/** /**
* Invoked in the most general case * Invoked in the most general case
* *
@ -413,7 +412,8 @@ public class CreateDatasetForm extends Composite {
tagsPanel.setVisible(false); tagsPanel.setVisible(false);
// check if the user has publishing rights // check if the user has publishing rights
setAlertBlock("Checking your permissions, please wait...", AlertType.INFO, true); LoaderIcon loader = new LoaderIcon("Checking your permissions, please wait...");
setAlertBlock(null, loader, AlertType.INFO, true);
ckanServices.isPublisherUser(new AsyncCallback<Boolean>() { ckanServices.isPublisherUser(new AsyncCallback<Boolean>() {
@ -423,7 +423,8 @@ public class CreateDatasetForm extends Composite {
if (result) { if (result) {
// set info block // set info block
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true); LoaderIcon loader = new LoaderIcon("Retrieving information, please wait...");
setAlertBlock(null, loader, AlertType.INFO, true);
// get back the licenses and the metadata information // get back the licenses and the metadata information
ckanServices.getDatasetBean(idFolderOrFileWorkspace, new AsyncCallback<DatasetBean>() { ckanServices.getDatasetBean(idFolderOrFileWorkspace, new AsyncCallback<DatasetBean>() {
@ -431,7 +432,7 @@ public class CreateDatasetForm extends Composite {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
setAlertBlock(caught.getMessage(), AlertType.ERROR, true); setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true);
} }
@ -439,8 +440,7 @@ public class CreateDatasetForm extends Composite {
public void onSuccess(final DatasetBean bean) { public void onSuccess(final DatasetBean bean) {
if (bean == null) { if (bean == null) {
setAlertBlock("Error while retrieving information.", null, AlertType.ERROR, true);
setAlertBlock("Error while retrieving information.", AlertType.ERROR, true);
} else { } else {
// save it // save it
@ -455,7 +455,8 @@ public class CreateDatasetForm extends Composite {
maintainerTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName()); maintainerTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
maintainerEmailTextbox.setText(bean.getMaintainerEmail()); maintainerEmailTextbox.setText(bean.getMaintainerEmail());
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true); LoaderIcon loader = new LoaderIcon("Retrieving information, please wait...");
setAlertBlock(null, loader, AlertType.INFO, true);
// vocabulary list of tags has preemption // vocabulary list of tags has preemption
List<String> vocabularyTags = bean.getTagsVocabulary(); List<String> vocabularyTags = bean.getTagsVocabulary();
@ -532,7 +533,8 @@ public class CreateDatasetForm extends Composite {
.get(organizationsListbox.getSelectedItemText()); .get(organizationsListbox.getSelectedItemText());
// force tags // force tags
setAlertBlock("Checking for tags vocabulary, please wait...", AlertType.INFO, true); LoaderIcon loaderT = new LoaderIcon("Checking for tags vocabulary, please wait...");
setAlertBlock(null, loader, AlertType.INFO, true);
ckanServices.getTagsForOrganization(orgName, new AsyncCallback<List<String>>() { ckanServices.getTagsForOrganization(orgName, new AsyncCallback<List<String>>() {
@Override @Override
@ -547,21 +549,21 @@ public class CreateDatasetForm extends Composite {
setAlertBlock( setAlertBlock(
"Error while checking if a vocabulary of tags is defined in the selected organization.", "Error while checking if a vocabulary of tags is defined in the selected organization.",
AlertType.ERROR, true); null, AlertType.ERROR, true);
tagsPanel.setVisible(true); tagsPanel.setVisible(true);
} }
}); });
// try to retrieve the profiles LoaderIcon loaderTyp = new LoaderIcon("Retrieving types, please wait...");
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true); setAlertBlock(null, loaderTyp, AlertType.INFO, true);
// perform remote request of profiles for the selected organization // perform remote request of profiles for the selected organization
ckanServices.getProfiles(orgName, new AsyncCallback<List<MetaDataProfileBean>>() { ckanServices.getProfiles(orgName, new AsyncCallback<List<MetaDataProfileBean>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
setAlertBlock(caught.getMessage(), AlertType.ERROR, true); setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true);
} }
@Override @Override
@ -569,7 +571,7 @@ public class CreateDatasetForm extends Composite {
if (profiles == null) { if (profiles == null) {
setAlertBlock("An unknow error occurred while retrieving types, sorry", setAlertBlock("An unknow error occurred while retrieving types, sorry",
AlertType.ERROR, true); null, AlertType.ERROR, true);
} else { } else {
GWT.log("Profile returned are: " + profiles.size()); GWT.log("Profile returned are: " + profiles.size());
@ -586,12 +588,15 @@ public class CreateDatasetForm extends Composite {
metadataTypeListbox.setEnabled(true); metadataTypeListbox.setEnabled(true);
// try to retrieve the licenses // try to retrieve the licenses
setAlertBlock("Retrieving licenses, please wait...", AlertType.INFO, true); LoaderIcon loaderLic = new LoaderIcon(
"Retrieving licenses, please wait...");
setAlertBlock(null, loaderLic, AlertType.INFO, true);
ckanServices.getLicenses(new AsyncCallback<List<LicenseBean>>() { ckanServices.getLicenses(new AsyncCallback<List<LicenseBean>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
setAlertBlock(caught.getMessage(), AlertType.ERROR, true); setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true);
} }
@Override @Override
@ -609,9 +614,10 @@ public class CreateDatasetForm extends Composite {
// set the url of the license, if any // set the url of the license, if any
showLicenseUrl(); showLicenseUrl();
// try to retrieve the licenses // try to retrieve groups
setAlertBlock("Retrieving groups, please wait...", LoaderIcon loaderLic = new LoaderIcon(
AlertType.INFO, true); "Retrieving groups, please wait...");
setAlertBlock(null, loaderLic, AlertType.INFO, true);
// request groups // request groups
ckanServices.getUserGroups(orgName, ckanServices.getUserGroups(orgName,
@ -623,7 +629,7 @@ public class CreateDatasetForm extends Composite {
if (groups == null) { if (groups == null) {
setAlertBlock( setAlertBlock(
"Error while retrieving groups", "Error while retrieving groups",
AlertType.ERROR, true); null, AlertType.ERROR, true);
} else { } else {
if (groups.isEmpty()) { if (groups.isEmpty()) {
groupsControlGroup.setVisible(false); groupsControlGroup.setVisible(false);
@ -638,7 +644,8 @@ public class CreateDatasetForm extends Composite {
hideGroupsAlreadyInProfile(profiles); hideGroupsAlreadyInProfile(profiles);
} }
// everything went ok // everything went ok
setAlertBlock("", AlertType.ERROR, false); setAlertBlock("", null, AlertType.ERROR,
false);
continueButton.setEnabled(true); continueButton.setEnabled(true);
resetButton.setEnabled(true); resetButton.setEnabled(true);
} }
@ -646,13 +653,13 @@ public class CreateDatasetForm extends Composite {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
setAlertBlock(caught.getMessage(), setAlertBlock(caught.getMessage(), null,
AlertType.ERROR, true); AlertType.ERROR, true);
} }
}); });
} else { } else {
setAlertBlock("Error while retrieving licenses", setAlertBlock("Error while retrieving licenses", null,
AlertType.ERROR, true); AlertType.ERROR, true);
} }
} }
@ -665,14 +672,14 @@ public class CreateDatasetForm extends Composite {
}); });
} else { } else {
setAlertBlock(MISSING_PUBLISH_RIGHTS, AlertType.ERROR, true); setAlertBlock(MISSING_PUBLISH_RIGHTS, null, AlertType.ERROR, true);
} }
} }
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
setAlertBlock(MISSING_PUBLISH_RIGHTS, AlertType.ERROR, true); setAlertBlock(MISSING_PUBLISH_RIGHTS, null, AlertType.ERROR, true);
} }
}); });
@ -698,7 +705,8 @@ public class CreateDatasetForm extends Composite {
final String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle); final String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
// try to retrieve the profiles // try to retrieve the profiles
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true); LoaderIcon loader = new LoaderIcon("Retrieving types, please wait...");
setAlertBlock(null, loader, AlertType.INFO, true);
// disable the list of organizations name so that the user doesn't change it // disable the list of organizations name so that the user doesn't change it
// again // again
@ -721,8 +729,9 @@ public class CreateDatasetForm extends Composite {
organizationsListbox.setEnabled(true); organizationsListbox.setEnabled(true);
metadataTypeListbox.setEnabled(true); metadataTypeListbox.setEnabled(true);
// try to retrieve the licenses // try to retrieve the groups
setAlertBlock("Retrieving groups, please wait...", AlertType.INFO, true); LoaderIcon loaderG = new LoaderIcon("Retrieving groups, please wait...");
setAlertBlock(null, loaderG, AlertType.INFO, true);
// request groups // request groups
ckanServices.getUserGroups(orgName, new AsyncCallback<List<OrganizationBean>>() { ckanServices.getUserGroups(orgName, new AsyncCallback<List<OrganizationBean>>() {
@ -731,7 +740,8 @@ public class CreateDatasetForm extends Composite {
public void onSuccess(List<OrganizationBean> groups) { public void onSuccess(List<OrganizationBean> groups) {
if (groups == null) { if (groups == null) {
setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR, true); setAlertBlock("Error while retrieving groups. Refresh and retry later", null,
AlertType.ERROR, true);
} else { } else {
if (groups.isEmpty()) { if (groups.isEmpty()) {
groupsControlGroup.setVisible(false); groupsControlGroup.setVisible(false);
@ -744,19 +754,22 @@ public class CreateDatasetForm extends Composite {
groupsListbox.setEnabled(true); groupsListbox.setEnabled(true);
hideGroupsAlreadyInProfile(profiles); hideGroupsAlreadyInProfile(profiles);
} }
setAlertBlock("", AlertType.ERROR, false); setAlertBlock("", null, AlertType.ERROR, false);
} }
} }
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR, true); setAlertBlock("Error while retrieving groups. Refresh and retry later", null,
AlertType.ERROR, true);
} }
}); });
// check also for tags (if for that context there is a vocabulary or not) // check also for tags (if for that context there is a vocabulary or not)
tagsPanel.setVisible(false); tagsPanel.setVisible(false);
setAlertBlock("Checking for tags vocabulary, please wait...", AlertType.INFO, true); LoaderIcon loaderV = new LoaderIcon("Checking for tags vocabulary, please wait...");
setAlertBlock(null, loaderV, AlertType.INFO, true);
ckanServices.getTagsForOrganization(orgName, new AsyncCallback<List<String>>() { ckanServices.getTagsForOrganization(orgName, new AsyncCallback<List<String>>() {
@Override @Override
@ -764,7 +777,7 @@ public class CreateDatasetForm extends Composite {
tagsPanel.setVocabulary(vocabulary); tagsPanel.setVocabulary(vocabulary);
tagsPanel.setVisible(true); tagsPanel.setVisible(true);
setAlertBlock("", AlertType.ERROR, false); setAlertBlock("", null, AlertType.ERROR, false);
} }
@Override @Override
@ -772,7 +785,7 @@ public class CreateDatasetForm extends Composite {
setAlertBlock( setAlertBlock(
"Error while checking if a vocabulary of tags is defined in the selected organization.", "Error while checking if a vocabulary of tags is defined in the selected organization.",
AlertType.ERROR, true); null, AlertType.ERROR, true);
tagsPanel.setVocabulary(null); tagsPanel.setVocabulary(null);
tagsPanel.setVisible(true); tagsPanel.setVisible(true);
@ -780,14 +793,14 @@ public class CreateDatasetForm extends Composite {
}); });
} else } else
setAlertBlock("Error while retrieving types, sorry", AlertType.ERROR, true); setAlertBlock("Error while retrieving types. Refresh and retry", null, AlertType.ERROR, true);
} }
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
setAlertBlock("Error while retrieving types, sorry", AlertType.ERROR, true); setAlertBlock("Error while retrieving types. Refresh and retry", null, AlertType.ERROR, true);
} }
}); });
@ -1290,8 +1303,6 @@ public class CreateDatasetForm extends Composite {
alertOnCreate(ERROR_PRODUCT_CREATION, false, AlertType.ERROR, true); alertOnCreate(ERROR_PRODUCT_CREATION, false, AlertType.ERROR, true);
} }
} }
@Override @Override
@ -1607,19 +1618,42 @@ public class CreateDatasetForm extends Composite {
resourcesSelectByWEMainPanel.freeze(); resourcesSelectByWEMainPanel.freeze();
} }
// /**
// * change alert block behavior.
// *
// * @param textToShow
// * @param type
// * @param visible
// */
// private void setAlertBlock(String textToShow, AlertType type, boolean visible) {
//
// infoBlock.setText(textToShow);
// infoBlock.setType(type);
// infoBlock.setVisible(visible);
//
// }
/** /**
* change alert block behavior. * change alert block behavior.
* *
* @param textToShow * @param textToShow the text to show
* @param type * @param type the type
* @param visible * @param visible the visible
*/ */
private void setAlertBlock(String textToShow, AlertType type, boolean visible) { private void setAlertBlock(String textToShow, LoaderIcon loader, AlertType type, boolean visible) {
infoBlock.setText(textToShow); alertPanel.clear();
if (loader != null) {
alertPanel.add(loader);
}
infoBlock.setType(type); infoBlock.setType(type);
infoBlock.setVisible(visible); infoBlock.setVisible(visible);
if (textToShow != null) {
alertPanel.add(new HTML(textToShow));
}
} }
@UiHandler("licenseListbox") @UiHandler("licenseListbox")

View File

@ -1165,7 +1165,7 @@ public class UpdateDatasetForm extends Composite {
String errorMessage = areProfileDataValid(); String errorMessage = areProfileDataValid();
if (errorMessage != null) { if (errorMessage != null) {
alertOnCreate("Please check the inserted values and the mandatory fields [" + errorMessage + "]", false, alertOnUpdated("Please check the inserted values and the mandatory fields [" + errorMessage + "]", false,
AlertType.ERROR, true); AlertType.ERROR, true);
} else { } else {
@ -1280,7 +1280,7 @@ public class UpdateDatasetForm extends Composite {
theDatasetBean.setCustomFields(customFieldsMap); theDatasetBean.setCustomFields(customFieldsMap);
// alert // alert
alertOnCreate(TRYING_TO_UPDATE_PRODUCT, true, AlertType.INFO, false); alertOnUpdated(TRYING_TO_UPDATE_PRODUCT, true, AlertType.INFO, false);
// invoke the create method // invoke the create method
updateButton.setEnabled(false); updateButton.setEnabled(false);
@ -1300,7 +1300,7 @@ public class UpdateDatasetForm extends Composite {
final String datasetUrl = createdDatasetBean.getSource(); final String datasetUrl = createdDatasetBean.getSource();
alertOnCreate(PRODUCT_UPDATED_OK, false, AlertType.SUCCESS, false); alertOnUpdated(PRODUCT_UPDATED_OK, false, AlertType.SUCCESS, false);
try { try {
// disable dataset fields // disable dataset fields
@ -1343,14 +1343,14 @@ public class UpdateDatasetForm extends Composite {
} else { } else {
alertOnCreate(ERROR_PRODUCT_CREATION, false, AlertType.ERROR, true); alertOnUpdated(ERROR_PRODUCT_CREATION, false, AlertType.ERROR, true);
} }
} }
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
alertOnCreate(ERROR_PRODUCT_CREATION + " Error message is : " + caught.getMessage(), false, alertOnUpdated(ERROR_PRODUCT_CREATION + " Error message is : " + caught.getMessage(), false,
AlertType.ERROR, true); AlertType.ERROR, true);
CKanMetadataPublisher.printJs(caught.toString()); CKanMetadataPublisher.printJs(caught.toString());
} }
@ -1547,7 +1547,7 @@ public class UpdateDatasetForm extends Composite {
* @param type the type * @param type the type
* @param hideAfterAWhile the hide after A while * @param hideAfterAWhile the hide after A while
*/ */
private void alertOnCreate(String text, boolean showSpinner, AlertType type, boolean hideAfterAWhile) { private void alertOnUpdated(String text, boolean showSpinner, AlertType type, boolean hideAfterAWhile) {
onCreateAlertBlock.clear(); onCreateAlertBlock.clear();
@ -1737,10 +1737,6 @@ public class UpdateDatasetForm extends Composite {
*/ */
private void setAlertBlock(String textToShow, LoaderIcon loader, AlertType type, boolean visible) { private void setAlertBlock(String textToShow, LoaderIcon loader, AlertType type, boolean visible) {
// infoBlock.setText(textToShow);
// infoBlock.setType(type);
// infoBlock.setVisible(visible);
alertPanel.clear(); alertPanel.clear();
if (loader != null) { if (loader != null) {