resolved to get profiles on organization name change

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@130700 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-07-22 10:51:19 +00:00
parent 4431c2c729
commit 802fc83dfa
2 changed files with 20 additions and 11 deletions

View File

@ -343,7 +343,7 @@ public class CreateDatasetForm extends Composite{
@Override @Override
public void onChange(ChangeEvent event) { public void onChange(ChangeEvent event) {
event.preventDefault();
organizationsListboxChangeHandlerBody(); organizationsListboxChangeHandlerBody();
} }
@ -437,26 +437,29 @@ public class CreateDatasetForm extends Composite{
*/ */
private void organizationsListboxChangeHandlerBody() { private void organizationsListboxChangeHandlerBody() {
// disable the list of organizations name so that the user doesn't change it again // remove any other product profiles
organizationsListbox.setEnabled(false);
metadataProfilesFormatListbox.setEnabled(false);
// remove any other product profiles but "none"
int presentItems = metadataProfilesFormatListbox.getItemCount(); int presentItems = metadataProfilesFormatListbox.getItemCount();
for (int i = 0; i < presentItems; i++) { for (int i = presentItems - 1; i >= 0; i--) {
if(!metadataProfilesFormatListbox.getValue(i).equals("none")) metadataProfilesFormatListbox.removeItem(i);
metadataProfilesFormatListbox.removeItem(i);
} }
// add "none" item again
metadataProfilesFormatListbox.addItem("none");
// select "none" // select "none"
metadataProfilesFormatListbox.setSelectedIndex(0); metadataProfilesFormatListbox.setSelectedIndex(0);
// get the name of the organization from the title // get the name of the organization from the title
String orgName = nameTitleOrganizationMap.get(organizationsListbox.getSelectedItemText()); String selectedOrganizationTitle = organizationsListbox.getSelectedItemText();
String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
// try to retrieve the profiles // try to retrieve the profiles
setAlertBlock("Retrieving profiles, please wait...", AlertType.INFO, true); setAlertBlock("Retrieving profiles, please wait...", AlertType.INFO, true);
// disable the list of organizations name so that the user doesn't change it again
organizationsListbox.setEnabled(false);
metadataProfilesFormatListbox.setEnabled(false);
// 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>>() {
@ -467,6 +470,8 @@ public class CreateDatasetForm extends Composite{
receivedBean.setMetadataList(result); receivedBean.setMetadataList(result);
prepareMetadataList(receivedBean); prepareMetadataList(receivedBean);
organizationsListbox.setEnabled(true);
metadataProfilesFormatListbox.setEnabled(true);
// everything went ok // everything went ok
setAlertBlock("", AlertType.ERROR, false); setAlertBlock("", AlertType.ERROR, false);

View File

@ -545,10 +545,14 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
@Override @Override
public List<MetaDataProfileBean> getProfiles(String orgName) { public List<MetaDataProfileBean> getProfiles(String orgName) {
logger.debug("Requested profiles for products into orgName " + orgName);
List<MetaDataProfileBean> toReturn = new ArrayList<MetaDataProfileBean>(); List<MetaDataProfileBean> toReturn = new ArrayList<MetaDataProfileBean>();
try{ try{
toReturn = Utils.getMetadataProfilesList(Utils.retrieveScopeFromOrganizationName(orgName), getThreadLocalRequest().getSession(), getASLSession(), CKAN_PROFILES_KEY); String evaluatedScope = Utils.retrieveScopeFromOrganizationName(orgName);
logger.debug("Evaluated scope is " + evaluatedScope);
toReturn = Utils.getMetadataProfilesList(evaluatedScope, getThreadLocalRequest().getSession(), getASLSession(), CKAN_PROFILES_KEY);
}catch(Exception e){ }catch(Exception e){
logger.error("Failed to retrieve profiles for scope coming from organization name " + orgName, e); logger.error("Failed to retrieve profiles for scope coming from organization name " + orgName, e);
} }