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:
parent
4431c2c729
commit
802fc83dfa
|
@ -343,7 +343,7 @@ public class CreateDatasetForm extends Composite{
|
|||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
|
||||
event.preventDefault();
|
||||
organizationsListboxChangeHandlerBody();
|
||||
|
||||
}
|
||||
|
@ -437,26 +437,29 @@ public class CreateDatasetForm extends Composite{
|
|||
*/
|
||||
private void organizationsListboxChangeHandlerBody() {
|
||||
|
||||
// disable the list of organizations name so that the user doesn't change it again
|
||||
organizationsListbox.setEnabled(false);
|
||||
metadataProfilesFormatListbox.setEnabled(false);
|
||||
|
||||
// remove any other product profiles but "none"
|
||||
// remove any other product profiles
|
||||
int presentItems = metadataProfilesFormatListbox.getItemCount();
|
||||
for (int i = 0; i < presentItems; i++) {
|
||||
if(!metadataProfilesFormatListbox.getValue(i).equals("none"))
|
||||
metadataProfilesFormatListbox.removeItem(i);
|
||||
for (int i = presentItems - 1; i >= 0; i--) {
|
||||
metadataProfilesFormatListbox.removeItem(i);
|
||||
}
|
||||
|
||||
// add "none" item again
|
||||
metadataProfilesFormatListbox.addItem("none");
|
||||
|
||||
// select "none"
|
||||
metadataProfilesFormatListbox.setSelectedIndex(0);
|
||||
|
||||
// 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
|
||||
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
|
||||
ckanServices.getProfiles(orgName, new AsyncCallback<List<MetaDataProfileBean>>() {
|
||||
|
||||
|
@ -467,6 +470,8 @@ public class CreateDatasetForm extends Composite{
|
|||
|
||||
receivedBean.setMetadataList(result);
|
||||
prepareMetadataList(receivedBean);
|
||||
organizationsListbox.setEnabled(true);
|
||||
metadataProfilesFormatListbox.setEnabled(true);
|
||||
|
||||
// everything went ok
|
||||
setAlertBlock("", AlertType.ERROR, false);
|
||||
|
|
|
@ -545,10 +545,14 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
|||
|
||||
@Override
|
||||
public List<MetaDataProfileBean> getProfiles(String orgName) {
|
||||
|
||||
logger.debug("Requested profiles for products into orgName " + orgName);
|
||||
|
||||
List<MetaDataProfileBean> toReturn = new ArrayList<MetaDataProfileBean>();
|
||||
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){
|
||||
logger.error("Failed to retrieve profiles for scope coming from organization name " + orgName, e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue