2017-04-25 15:52:37 +02:00
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form ;
2016-05-26 18:12:53 +02:00
import java.util.ArrayList ;
2021-04-09 14:51:55 +02:00
import java.util.Arrays ;
2016-05-27 19:08:03 +02:00
import java.util.HashMap ;
2017-04-25 18:11:13 +02:00
import java.util.HashSet ;
2016-05-27 19:08:03 +02:00
import java.util.Iterator ;
2016-05-26 18:12:53 +02:00
import java.util.List ;
2016-05-27 19:08:03 +02:00
import java.util.Map ;
import java.util.Map.Entry ;
2017-04-25 18:11:13 +02:00
import java.util.Set ;
2016-05-26 18:12:53 +02:00
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService ;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync ;
2016-07-14 12:14:33 +02:00
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEvent ;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEventHandler ;
2016-05-27 19:08:03 +02:00
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEvent ;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler ;
2017-04-25 15:52:37 +02:00
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.CategoryPanel ;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.CustomFieldEntry ;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.MetaDataFieldSkeleton ;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddResourceContainer ;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddResourceToDataset ;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddedResourcesSummary ;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.tags.TagsPanel ;
2016-07-13 16:11:15 +02:00
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels ;
2021-04-09 14:51:55 +02:00
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.WizardCreator ;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace.SelectResourceByWEMainPanel ;
2017-04-25 15:41:27 +02:00
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean ;
2016-07-20 22:41:15 +02:00
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean ;
2017-04-25 15:41:27 +02:00
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.licenses.LicenseBean ;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.CategoryWrapper ;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.MetaDataProfileBean ;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.MetadataFieldWrapper ;
2016-05-26 18:12:53 +02:00
2016-05-27 19:08:03 +02:00
import com.github.gwtbootstrap.client.ui.AlertBlock ;
2016-05-26 18:12:53 +02:00
import com.github.gwtbootstrap.client.ui.Button ;
import com.github.gwtbootstrap.client.ui.ControlGroup ;
2016-06-09 18:58:19 +02:00
import com.github.gwtbootstrap.client.ui.Form ;
2016-07-13 16:11:15 +02:00
import com.github.gwtbootstrap.client.ui.Icon ;
2016-05-26 18:12:53 +02:00
import com.github.gwtbootstrap.client.ui.ListBox ;
2016-06-09 18:58:19 +02:00
import com.github.gwtbootstrap.client.ui.Paragraph ;
2016-07-13 16:11:15 +02:00
import com.github.gwtbootstrap.client.ui.Popover ;
2016-06-07 17:50:33 +02:00
import com.github.gwtbootstrap.client.ui.Tab ;
import com.github.gwtbootstrap.client.ui.TabPanel ;
2016-05-26 18:12:53 +02:00
import com.github.gwtbootstrap.client.ui.TextArea ;
import com.github.gwtbootstrap.client.ui.TextBox ;
2016-05-27 19:08:03 +02:00
import com.github.gwtbootstrap.client.ui.constants.AlertType ;
2016-09-16 17:40:32 +02:00
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType ;
2022-06-14 12:28:03 +02:00
import com.github.gwtbootstrap.client.ui.constants.IconType ;
2021-04-09 14:51:55 +02:00
import com.github.gwtbootstrap.client.ui.constants.ResizeType ;
2016-06-07 17:50:33 +02:00
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs ;
2016-05-26 18:12:53 +02:00
import com.google.gwt.core.client.GWT ;
2016-11-17 14:08:22 +01:00
import com.google.gwt.dom.client.SelectElement ;
2016-11-14 17:07:03 +01:00
import com.google.gwt.dom.client.Style.Unit ;
2016-06-09 18:58:19 +02:00
import com.google.gwt.event.dom.client.ChangeEvent ;
import com.google.gwt.event.dom.client.ChangeHandler ;
2016-05-26 18:12:53 +02:00
import com.google.gwt.event.dom.client.ClickEvent ;
2016-05-27 19:08:03 +02:00
import com.google.gwt.event.dom.client.ClickHandler ;
import com.google.gwt.event.shared.HandlerManager ;
2016-05-26 18:12:53 +02:00
import com.google.gwt.uibinder.client.UiBinder ;
import com.google.gwt.uibinder.client.UiField ;
import com.google.gwt.uibinder.client.UiHandler ;
2016-06-06 17:24:52 +02:00
import com.google.gwt.user.client.Timer ;
2016-06-10 12:10:18 +02:00
import com.google.gwt.user.client.Window ;
2016-05-26 18:12:53 +02:00
import com.google.gwt.user.client.rpc.AsyncCallback ;
2016-07-13 16:11:15 +02:00
import com.google.gwt.user.client.ui.Anchor ;
2016-05-26 18:12:53 +02:00
import com.google.gwt.user.client.ui.Composite ;
2016-07-13 16:11:15 +02:00
import com.google.gwt.user.client.ui.FocusPanel ;
2016-06-10 12:10:18 +02:00
import com.google.gwt.user.client.ui.HTMLPanel ;
2019-04-10 15:53:29 +02:00
import com.google.gwt.user.client.ui.HorizontalPanel ;
2016-07-06 18:41:43 +02:00
import com.google.gwt.user.client.ui.SimplePanel ;
2016-06-07 17:50:33 +02:00
import com.google.gwt.user.client.ui.VerticalPanel ;
2016-05-26 18:12:53 +02:00
import com.google.gwt.user.client.ui.Widget ;
/ * *
2016-09-28 16:41:55 +02:00
* Create metadata form for ckan product .
2022-06-14 12:28:03 +02:00
*
2016-05-26 18:12:53 +02:00
* @author Costantino Perciante at ISTI - CNR ( costantino . perciante @isti.cnr.it )
* /
2022-06-14 12:28:03 +02:00
public class CreateDatasetForm extends Composite {
2016-07-14 11:26:43 +02:00
2022-06-14 12:28:03 +02:00
private static EditMetadataFormUiBinder uiBinder = GWT . create ( EditMetadataFormUiBinder . class ) ;
2016-05-26 18:12:53 +02:00
2022-06-14 12:28:03 +02:00
interface EditMetadataFormUiBinder extends UiBinder < Widget , CreateDatasetForm > {
2016-05-26 18:12:53 +02:00
}
2022-06-14 12:28:03 +02:00
@UiField
HTMLPanel createDatasetMainPanel ;
@UiField
TextBox titleTextBox ;
@UiField
TextArea descriptionTextarea ;
@UiField
ListBox licenseListbox ;
@UiField
ListBox visibilityListbox ;
@UiField
ListBox organizationsListbox ;
@UiField
TextBox versionTextbox ;
@UiField
TextBox authorTextbox ;
@UiField
TextBox authorEmailTextbox ;
@UiField
TextBox maintainerTextbox ;
@UiField
TextBox maintainerEmailTextbox ;
@UiField
ControlGroup customFields ;
@UiField
Button addCustomFieldButton ;
@UiField
Button createButton ;
@UiField
Button resetButton ;
@UiField
AlertBlock infoBlock ;
@UiField
AlertBlock alertNoResources ;
@UiField
AlertBlock onContinueAlertBlock ;
@UiField
AlertBlock onCreateAlertBlock ;
@UiField
VerticalPanel metadataFieldsPanel ;
@UiField
ListBox metadataTypeListbox ;
@UiField
Form formFirstStep ;
@UiField
Form formSecondStep ;
@UiField
Form formThirdStep ;
@UiField
Button continueButton ;
@UiField
Button goBackButtonSecondStep ;
@UiField
Paragraph selectedProfile ;
@UiField
Button goToDatasetButton ;
@UiField
HorizontalPanel goToDatasetButtonPanel ;
@UiField
Button addResourcesButton ;
@UiField
SimplePanel workspaceResourcesContainer ;
@UiField
Button continueThirdStep ;
@UiField
Button goBackButtonFirstStep ;
@UiField
Anchor licenseUrlAnchor ;
@UiField
Paragraph unavailableUrl ;
@UiField
TagsPanel tagsPanel ;
@UiField
ListBox groupsListbox ;
2016-10-04 14:58:26 +02:00
2016-07-13 16:11:15 +02:00
// info panels
2022-06-14 12:28:03 +02:00
@UiField
Icon infoIconLicenses ;
@UiField
FocusPanel focusPanelLicenses ;
@UiField
Popover popoverLicenses ;
@UiField
Icon infoIconVisibility ;
@UiField
FocusPanel focusPanelVisibility ;
@UiField
Popover popoverVisibility ;
@UiField
Icon infoIconAuthor ;
@UiField
FocusPanel focusPanelAuthor ;
@UiField
Popover popoverAuthor ;
@UiField
Icon infoIconMaintainerEmail ;
@UiField
FocusPanel focusPanelMaintainerEmail ;
@UiField
Popover popoverMaintainerEmail ;
@UiField
Icon infoIconAuthorEmail ;
@UiField
FocusPanel focusPanelAuthorEmail ;
@UiField
Popover popoverAuthorEmail ;
@UiField
Icon infoIconTypes ;
@UiField
FocusPanel focusPanelTypes ;
@UiField
Popover popoverTypes ;
@UiField
Icon infoIconMaintainer ;
@UiField
FocusPanel focusPanelMaintainer ;
@UiField
Popover popoverMaintainer ;
@UiField
Icon infoIconCustomFields ;
@UiField
FocusPanel focusPanelCustomFields ;
@UiField
Popover popoverCustomFields ;
@UiField
Icon infoIconResources ;
@UiField
FocusPanel focusPanelResources ;
@UiField
Popover popoverResources ;
@UiField
Icon infoIconTitle ;
@UiField
FocusPanel focusPanelTitle ;
@UiField
Popover popoverGroups ;
@UiField
Icon infoIconGroups ;
@UiField
FocusPanel focusPanelGroups ;
@UiField
Popover popoverTitle ;
@UiField
Icon infoIconDescription ;
@UiField
Popover popoverDescription ;
@UiField
FocusPanel focusPanelDescription ;
@UiField
ControlGroup metadataTypesControlGroup ;
@UiField
ControlGroup productTitleGroup ;
@UiField
ControlGroup maintainerControlGroup ;
@UiField
ControlGroup versionControlGroup ;
@UiField
ControlGroup organizationsGroup ;
@UiField
ControlGroup groupsControlGroup ;
@UiField
HTMLPanel wizardCreatorPanel ;
2021-04-09 14:51:55 +02:00
2022-06-14 12:28:03 +02:00
private Icon iconSpinner = new Icon ( IconType . SPINNER ) ;
2016-07-14 11:26:43 +02:00
2016-09-26 12:15:05 +02:00
// Create a remote service proxy to talk to the server-side ckan service.
private final CKanPublisherServiceAsync ckanServices = GWT . create ( CKanPublisherService . class ) ;
2022-06-14 12:28:03 +02:00
// private static final String REGEX_TITLE_PRODUCT_SUBWORD = "[^a-zA-Z0-9_.-]";
2016-09-26 12:15:05 +02:00
private static final String REGEX_MAIL = " \\ b[ \\ w.%-]+@[-. \\ w]+ \\ .[A-Za-z]{2,4} \\ b " ;
2016-10-03 16:56:32 +02:00
private static final String NONE_PROFILE = " none " ;
2016-09-26 12:15:05 +02:00
2016-09-26 14:12:26 +02:00
// error/info messages
2017-04-05 18:42:07 +02:00
protected static final String ERROR_PRODUCT_CREATION = " There was an error while trying to publish your item. " ;
2017-02-15 17:10:22 +01:00
protected static final String PRODUCT_CREATED_OK = " Item correctly published! " ;
2017-04-05 18:42:07 +02:00
private static final String TRYING_TO_CREATE_PRODUCT = " Trying to publish the item, please wait... " ;
2017-01-25 18:29:47 +01:00
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. " ;
2016-06-07 17:50:33 +02:00
2018-11-20 12:29:41 +01:00
// tab panel
private TabPanel tabPanel ;
2016-06-07 17:50:33 +02:00
// add resource form
2016-06-08 18:31:54 +02:00
private AddResourceToDataset resourceForm ;
2016-05-27 19:08:03 +02:00
2016-05-26 18:12:53 +02:00
// the licenses
2017-04-25 15:41:27 +02:00
private List < LicenseBean > licenseBean ;
2016-05-26 18:12:53 +02:00
2016-05-27 19:08:03 +02:00
// event bus
2016-07-20 22:41:15 +02:00
private HandlerManager eventBus ;
2016-05-27 19:08:03 +02:00
2017-04-25 15:41:27 +02:00
// added custom field entries (by the user)
2016-07-20 22:41:15 +02:00
private List < CustomFieldEntry > customFieldEntriesList = new ArrayList < CustomFieldEntry > ( ) ;
2016-06-06 17:24:52 +02:00
2019-06-10 17:48:28 +02:00
// the list of MetaDataField added
private List < MetaDataField > listOfMetadataFields = new ArrayList < MetaDataField > ( ) ;
2017-04-25 15:41:27 +02:00
2016-05-27 19:08:03 +02:00
// dataset metadata bean
2017-04-25 15:41:27 +02:00
private DatasetBean receivedBean ;
2016-05-26 18:12:53 +02:00
2016-06-07 17:50:33 +02:00
// the owner
private String owner ;
2016-06-06 17:24:52 +02:00
2016-06-08 18:31:54 +02:00
// workspace request?
private boolean isWorkspaceRequest = false ;
2016-07-06 18:41:43 +02:00
// resource table
2022-06-14 12:28:03 +02:00
// private TwinColumnSelectionMainPanel resourcesTwinPanel;
2021-04-09 14:51:55 +02:00
// resource table
private SelectResourceByWEMainPanel resourcesSelectByWEMainPanel ;
2016-07-19 21:24:42 +02:00
2016-07-14 12:14:33 +02:00
// List of opened popup'ids
2016-07-20 22:41:15 +02:00
private List < String > popupOpenedIds = new ArrayList < String > ( ) ;
// map of organization name title
private Map < String , String > nameTitleOrganizationMap = new HashMap < String , String > ( ) ;
2022-06-14 12:28:03 +02:00
2021-04-09 14:51:55 +02:00
private WizardCreator wizCreator ;
2016-07-06 18:41:43 +02:00
2016-06-06 17:24:52 +02:00
/ * *
* Invoked in the most general case
2022-06-14 12:28:03 +02:00
*
2016-09-28 16:41:55 +02:00
* @param eventBus the event bus
2016-06-06 17:24:52 +02:00
* /
2016-09-23 18:50:16 +02:00
public CreateDatasetForm ( HandlerManager eventBus ) {
createDatasetFormBody ( false , null , eventBus ) ;
2016-07-20 22:41:15 +02:00
}
2016-06-06 17:24:52 +02:00
2016-07-20 22:41:15 +02:00
/ * *
2016-09-12 17:58:50 +02:00
* Invoked when the workspace is used
2022-06-14 12:28:03 +02:00
*
2016-07-20 22:41:15 +02:00
* @param idFolderWorkspace
2022-06-14 12:28:03 +02:00
* @param eventBus the event bus
2016-07-20 22:41:15 +02:00
* /
2017-02-22 17:40:16 +01:00
public CreateDatasetForm ( String idFolderOrFileWorkspace , HandlerManager eventBus ) {
createDatasetFormBody ( true , idFolderOrFileWorkspace , eventBus ) ;
2016-06-08 18:31:54 +02:00
}
2016-09-20 17:33:39 +02:00
/ * *
* Bind on events
* /
private void bind ( ) {
// when a custom field is removed, remove it from the list
eventBus . addHandler ( DeleteCustomFieldEvent . TYPE , new DeleteCustomFieldEventHandler ( ) {
@Override
public void onRemoveEntry ( DeleteCustomFieldEvent event ) {
customFieldEntriesList . remove ( event . getRemovedEntry ( ) ) ;
customFields . remove ( event . getRemovedEntry ( ) ) ;
}
} ) ;
// on close form
eventBus . addHandler ( CloseCreationFormEvent . TYPE , new CloseCreationFormEventHandler ( ) {
@Override
public void onClose ( CloseCreationFormEvent event ) {
2016-10-03 17:27:12 +02:00
InfoIconsLabels . closeDialogBox ( popupOpenedIds ) ;
2016-09-20 17:33:39 +02:00
}
} ) ;
}
2016-07-20 22:41:15 +02:00
2016-06-06 17:24:52 +02:00
/ * *
2016-07-20 22:41:15 +02:00
* The real constructor
2022-06-14 12:28:03 +02:00
*
2016-07-20 22:41:15 +02:00
* @param isWorkspaceRequest
2016-06-06 17:24:52 +02:00
* @param idFolderWorkspace
* @param owner
2016-07-20 22:41:15 +02:00
* @param eventBus
2016-06-06 17:24:52 +02:00
* /
2022-06-14 12:28:03 +02:00
private void createDatasetFormBody ( final boolean isWorkspaceRequest , final String idFolderOrFileWorkspace ,
final HandlerManager eventBus ) {
2016-07-20 22:41:15 +02:00
2016-05-26 18:12:53 +02:00
initWidget ( uiBinder . createAndBindUi ( this ) ) ;
2016-07-14 12:14:33 +02:00
this . eventBus = eventBus ;
2016-07-20 22:41:15 +02:00
this . isWorkspaceRequest = isWorkspaceRequest ;
2021-04-09 14:51:55 +02:00
2022-06-14 12:28:03 +02:00
iconSpinner . setSpin ( true ) ;
iconSpinner . getElement ( ) . getStyle ( ) . setMarginLeft ( 5 , Unit . PX ) ;
2021-04-09 14:51:55 +02:00
List < String > listOfSteps = null ;
2022-06-14 12:28:03 +02:00
if ( isWorkspaceRequest ) {
listOfSteps = Arrays . asList ( " Edit Common Metadata " , " Select Item Resources " ,
" Edit Item Specific Metadata & Publish " ) ;
} else {
2021-04-09 14:51:55 +02:00
listOfSteps = Arrays . asList ( " Edit Common Metadata " , " Edit Item Specific Metadata & Publish " ) ;
}
2022-06-14 12:28:03 +02:00
2021-04-09 14:51:55 +02:00
this . wizCreator = new WizardCreator ( listOfSteps ) ;
wizardCreatorPanel . add ( wizCreator ) ;
2022-06-14 12:28:03 +02:00
2021-04-09 14:51:55 +02:00
this . descriptionTextarea . setResize ( ResizeType . VERTICAL ) ;
2016-05-27 19:08:03 +02:00
bind ( ) ;
2016-07-20 22:41:15 +02:00
prepareInfoIcons ( ) ;
2016-06-09 18:58:19 +02:00
// disable continue button
continueButton . setEnabled ( false ) ;
2016-06-06 17:24:52 +02:00
resetButton . setEnabled ( false ) ;
2017-04-25 15:41:27 +02:00
// hide tags panel
2017-04-05 18:42:07 +02:00
tagsPanel . setVisible ( false ) ;
2016-07-21 22:39:46 +02:00
2017-01-25 18:29:47 +01:00
// check if the user has publishing rights
setAlertBlock ( " Checking your permissions, please wait... " , AlertType . INFO , true ) ;
2016-05-27 19:08:03 +02:00
2017-01-25 18:29:47 +01:00
ckanServices . isPublisherUser ( isWorkspaceRequest , new AsyncCallback < Boolean > ( ) {
2016-05-27 19:08:03 +02:00
2016-07-20 22:41:15 +02:00
@Override
2017-01-25 18:29:47 +01:00
public void onSuccess ( Boolean result ) {
2016-07-20 22:41:15 +02:00
2022-06-14 12:28:03 +02:00
if ( result ) {
2016-07-20 22:41:15 +02:00
2017-01-25 18:29:47 +01:00
// set info block
setAlertBlock ( " Retrieving information, please wait... " , AlertType . INFO , true ) ;
2016-07-20 22:41:15 +02:00
2017-01-25 18:29:47 +01:00
// get back the licenses and the metadata information
2017-04-25 15:41:27 +02:00
ckanServices . getDatasetBean ( idFolderOrFileWorkspace , new AsyncCallback < DatasetBean > ( ) {
2016-05-27 19:08:03 +02:00
2017-01-25 18:29:47 +01:00
@Override
public void onFailure ( Throwable caught ) {
2016-07-20 22:41:15 +02:00
2017-04-27 16:24:21 +02:00
setAlertBlock ( caught . getMessage ( ) , AlertType . ERROR , true ) ;
2016-06-06 17:24:52 +02:00
2017-01-25 18:29:47 +01:00
}
2016-05-27 19:08:03 +02:00
2017-01-25 18:29:47 +01:00
@Override
2017-04-25 15:41:27 +02:00
public void onSuccess ( final DatasetBean bean ) {
2016-05-27 19:08:03 +02:00
2022-06-14 12:28:03 +02:00
if ( bean = = null ) {
2016-05-27 19:08:03 +02:00
2017-04-27 16:24:21 +02:00
setAlertBlock ( " Error while retrieving information. " , AlertType . ERROR , true ) ;
2022-06-14 12:28:03 +02:00
} else {
2016-05-27 19:08:03 +02:00
2017-01-25 18:29:47 +01:00
// save it
receivedBean = bean ;
2016-05-27 19:08:03 +02:00
2017-01-25 18:29:47 +01:00
// fill the form
titleTextBox . setText ( bean . getTitle ( ) ) ;
descriptionTextarea . setText ( bean . getDescription ( ) ) ;
versionTextbox . setText ( String . valueOf ( bean . getVersion ( ) ) ) ;
authorTextbox . setText ( bean . getAuthorSurname ( ) + " " + bean . getAuthorName ( ) ) ;
authorEmailTextbox . setText ( bean . getAuthorEmail ( ) ) ;
maintainerTextbox . setText ( bean . getAuthorSurname ( ) + " " + bean . getAuthorName ( ) ) ;
maintainerEmailTextbox . setText ( bean . getMaintainerEmail ( ) ) ;
2017-04-28 17:31:42 +02:00
2017-04-27 17:22:04 +02:00
setAlertBlock ( " Retrieving information, please wait... " , AlertType . INFO , true ) ;
2017-04-25 15:41:27 +02:00
// vocabulary list of tags has preemption
2017-04-27 17:22:04 +02:00
List < String > vocabularyTags = bean . getTagsVocabulary ( ) ;
2017-04-27 16:24:21 +02:00
tagsPanel . setVocabulary ( vocabularyTags ) ;
2017-04-28 17:31:42 +02:00
2017-04-27 17:22:04 +02:00
// retrieve custom fields
2018-11-20 12:29:41 +01:00
Map < String , List < String > > customFieldsMap = bean . getCustomFields ( ) ;
2017-04-25 15:41:27 +02:00
2017-04-27 17:22:04 +02:00
// TODO Check if these tags are ok for the vocabulary
2022-06-14 12:28:03 +02:00
if ( customFieldsMap ! = null & & vocabularyTags = = null ) {
2016-05-27 19:08:03 +02:00
2018-11-20 12:29:41 +01:00
// get the keys and put them as tags
2022-06-14 12:28:03 +02:00
Iterator < Entry < String , List < String > > > iteratorOverCustomField = customFieldsMap
. entrySet ( ) . iterator ( ) ;
2016-05-27 19:08:03 +02:00
2017-01-25 18:29:47 +01:00
while ( iteratorOverCustomField . hasNext ( ) ) {
2018-11-20 12:29:41 +01:00
Map . Entry < java . lang . String , java . util . List < java . lang . String > > entry = iteratorOverCustomField
2017-01-25 18:29:47 +01:00
. next ( ) ;
2016-07-07 16:52:10 +02:00
2017-01-25 18:29:47 +01:00
List < String > values = entry . getValue ( ) ;
2016-11-13 22:38:27 +01:00
2017-01-25 18:29:47 +01:00
for ( String value : values ) {
// these are fixed key, variable value custom fields
2022-06-14 12:28:03 +02:00
CustomFieldEntry toAdd = new CustomFieldEntry ( eventBus , entry . getKey ( ) ,
value , false ) ;
2017-01-25 18:29:47 +01:00
customFieldEntriesList . add ( toAdd ) ;
customFields . add ( toAdd ) ;
2016-07-21 22:39:46 +02:00
2017-01-25 18:29:47 +01:00
// add as tag
tagsPanel . addTagElement ( entry . getKey ( ) ) ;
}
}
}
2017-04-25 15:41:27 +02:00
2017-04-05 18:42:07 +02:00
// set it as visible anyway
tagsPanel . setVisible ( true ) ;
2016-07-20 22:41:15 +02:00
2022-06-14 12:28:03 +02:00
if ( isWorkspaceRequest ) {
// if there are not resources, for now just checked it ( and hide so that the
// step will be skipped)
if ( hideManageResources ( ) ) {
2017-01-25 18:29:47 +01:00
alertNoResources . setType ( AlertType . WARNING ) ;
alertNoResources . setVisible ( true ) ;
2022-06-14 12:28:03 +02:00
} else
// resourcesSelectByWEMainPanel = new
// TwinColumnSelectionMainPanel(bean.getResourceRoot());
resourcesSelectByWEMainPanel = new SelectResourceByWEMainPanel (
bean . getResourceRoot ( ) ) ;
2017-01-25 18:29:47 +01:00
}
2016-05-27 19:08:03 +02:00
2017-01-25 18:29:47 +01:00
// set organizations
List < OrganizationBean > organizations = bean . getOrganizationList ( ) ;
2016-05-27 19:08:03 +02:00
2017-01-25 18:29:47 +01:00
for ( OrganizationBean organization : organizations ) {
organizationsListbox . addItem ( organization . getTitle ( ) ) ;
nameTitleOrganizationMap . put ( organization . getTitle ( ) , organization . getName ( ) ) ;
}
2016-05-27 19:08:03 +02:00
2018-11-20 12:29:41 +01:00
// force the selection of the first one, and retrieve the list of profiles
2017-01-25 18:29:47 +01:00
organizationsListbox . setSelectedIndex ( 0 ) ;
2016-07-07 16:52:10 +02:00
2017-01-26 19:00:55 +01:00
// add change handler to dynamically retrieve the list of profiles
2017-01-25 18:29:47 +01:00
organizationsListbox . addChangeHandler ( new ChangeHandler ( ) {
2016-07-20 22:41:15 +02:00
2017-01-25 18:29:47 +01:00
@Override
public void onChange ( ChangeEvent event ) {
event . preventDefault ( ) ;
organizationsListboxChangeHandlerBody ( ) ;
}
} ) ;
2016-05-27 19:08:03 +02:00
2017-01-25 18:29:47 +01:00
// get the name of the organization from the title
2022-06-14 12:28:03 +02:00
final String orgName = nameTitleOrganizationMap
. get ( organizationsListbox . getSelectedItemText ( ) ) ;
2016-05-27 19:08:03 +02:00
2017-04-27 16:24:21 +02:00
// force tags
setAlertBlock ( " Checking for tags vocabulary, please wait... " , AlertType . INFO , true ) ;
ckanServices . getTagsForOrganization ( orgName , new AsyncCallback < List < String > > ( ) {
@Override
public void onSuccess ( List < String > vocabulary ) {
tagsPanel . setVocabulary ( vocabulary ) ;
tagsPanel . setVisible ( true ) ;
}
@Override
public void onFailure ( Throwable arg0 ) {
2022-06-14 12:28:03 +02:00
setAlertBlock (
" Error while checking if a vocabulary of tags is defined in the selected organization. " ,
AlertType . ERROR , true ) ;
2017-04-27 16:24:21 +02:00
tagsPanel . setVisible ( true ) ;
}
} ) ;
2017-04-27 17:22:04 +02:00
// try to retrieve the profiles
setAlertBlock ( " Retrieving types, please wait... " , AlertType . INFO , true ) ;
2017-04-27 16:24:21 +02:00
2017-01-25 18:29:47 +01:00
// perform remote request of profiles for the selected organization
ckanServices . getProfiles ( orgName , new AsyncCallback < List < MetaDataProfileBean > > ( ) {
2016-05-27 19:08:03 +02:00
2016-07-20 22:41:15 +02:00
@Override
2017-01-25 18:29:47 +01:00
public void onFailure ( Throwable caught ) {
2017-04-27 16:24:21 +02:00
setAlertBlock ( caught . getMessage ( ) , AlertType . ERROR , true ) ;
2016-07-20 22:41:15 +02:00
}
@Override
2017-01-25 18:29:47 +01:00
public void onSuccess ( final List < MetaDataProfileBean > profiles ) {
2016-07-20 22:41:15 +02:00
2022-06-14 12:28:03 +02:00
if ( profiles = = null ) {
setAlertBlock ( " An unknow error occurred while retrieving types, sorry " ,
AlertType . ERROR , true ) ;
} else {
GWT . log ( " Profile returned are: " + profiles . size ( ) ) ;
if ( ! GWT . isProdMode ( ) ) {
2021-04-09 14:51:55 +02:00
for ( MetaDataProfileBean profile : profiles ) {
2022-06-14 12:28:03 +02:00
GWT . log ( " Profile title: " + profile . getTitle ( ) + " , type: "
+ profile . getType ( ) ) ;
2021-04-09 14:51:55 +02:00
}
}
2016-07-20 22:41:15 +02:00
2017-04-25 15:41:27 +02:00
receivedBean . setMetadataList ( profiles ) ;
2017-01-25 18:29:47 +01:00
prepareMetadataList ( receivedBean ) ;
organizationsListbox . setEnabled ( true ) ;
2017-04-05 18:42:07 +02:00
metadataTypeListbox . setEnabled ( true ) ;
2016-07-20 22:41:15 +02:00
2017-01-25 18:29:47 +01:00
// try to retrieve the licenses
setAlertBlock ( " Retrieving licenses, please wait... " , AlertType . INFO , true ) ;
2017-04-25 15:41:27 +02:00
ckanServices . getLicenses ( new AsyncCallback < List < LicenseBean > > ( ) {
2016-07-20 22:41:15 +02:00
2017-01-25 18:29:47 +01:00
@Override
2022-06-14 12:28:03 +02:00
public void onFailure ( Throwable caught ) {
2017-04-27 16:24:21 +02:00
setAlertBlock ( caught . getMessage ( ) , AlertType . ERROR , true ) ;
2017-01-25 18:29:47 +01:00
}
2016-07-20 22:41:15 +02:00
2017-01-25 18:29:47 +01:00
@Override
2017-04-25 15:41:27 +02:00
public void onSuccess ( List < LicenseBean > licenses ) {
2016-11-15 10:40:13 +01:00
2022-06-14 12:28:03 +02:00
if ( licenses ! = null & & ! licenses . isEmpty ( ) ) {
2016-11-14 18:37:45 +01:00
2017-04-25 15:41:27 +02:00
licenseBean = licenses ;
2017-01-25 18:29:47 +01:00
// fill the listbox
2022-06-14 12:28:03 +02:00
for ( int i = 0 ; i < licenses . size ( ) ; i + + ) {
2017-04-25 15:41:27 +02:00
licenseListbox . addItem ( licenses . get ( i ) . getTitle ( ) ) ;
2016-12-13 17:40:50 +01:00
}
2016-11-17 14:08:22 +01:00
2017-01-25 18:29:47 +01:00
// set the url of the license, if any
showLicenseUrl ( ) ;
// try to retrieve the licenses
2022-06-14 12:28:03 +02:00
setAlertBlock ( " Retrieving groups, please wait... " ,
AlertType . INFO , true ) ;
2017-01-25 18:29:47 +01:00
// request groups
2022-06-14 12:28:03 +02:00
ckanServices . getUserGroups ( orgName ,
new AsyncCallback < List < OrganizationBean > > ( ) {
@Override
public void onSuccess (
List < OrganizationBean > groups ) {
if ( groups = = null ) {
setAlertBlock (
" Error while retrieving groups " ,
AlertType . ERROR , true ) ;
} else {
if ( groups . isEmpty ( ) ) {
groupsControlGroup . setVisible ( false ) ;
} else {
// add groups
for ( OrganizationBean group : groups ) {
groupsListbox . addItem (
group . getTitle ( ) ,
group . getName ( ) ) ;
}
hideGroupsAlreadyInProfile ( profiles ) ;
}
// everything went ok
setAlertBlock ( " " , AlertType . ERROR , false ) ;
continueButton . setEnabled ( true ) ;
resetButton . setEnabled ( true ) ;
}
2017-01-25 18:29:47 +01:00
}
2022-06-14 12:28:03 +02:00
@Override
public void onFailure ( Throwable caught ) {
setAlertBlock ( caught . getMessage ( ) ,
AlertType . ERROR , true ) ;
2017-01-25 18:29:47 +01:00
}
2022-06-14 12:28:03 +02:00
} ) ;
} else {
setAlertBlock ( " Error while retrieving licenses " ,
AlertType . ERROR , true ) ;
2017-01-25 18:29:47 +01:00
}
2016-11-14 18:37:45 +01:00
}
} ) ;
2016-07-20 22:41:15 +02:00
}
}
} ) ;
}
}
} ) ;
2017-01-25 18:29:47 +01:00
2022-06-14 12:28:03 +02:00
} else {
2017-01-25 18:29:47 +01:00
setAlertBlock ( MISSING_PUBLISH_RIGHTS , AlertType . ERROR , true ) ;
2016-07-20 22:41:15 +02:00
}
2017-01-25 18:29:47 +01:00
}
@Override
public void onFailure ( Throwable caught ) {
setAlertBlock ( MISSING_PUBLISH_RIGHTS , AlertType . ERROR , true ) ;
2016-06-29 12:39:27 +02:00
}
} ) ;
2016-06-09 18:58:19 +02:00
2016-06-29 12:39:27 +02:00
}
2016-06-09 18:58:19 +02:00
2016-07-20 19:14:20 +02:00
/ * *
2022-06-14 12:28:03 +02:00
* When the organization name is changed we need to retrieve the list of
* profiles and groups
2016-07-20 19:14:20 +02:00
* /
private void organizationsListboxChangeHandlerBody ( ) {
2016-07-22 12:51:19 +02:00
// remove any other product profiles
2017-04-05 18:42:07 +02:00
metadataTypeListbox . clear ( ) ;
2016-07-21 11:26:18 +02:00
2016-07-22 12:51:19 +02:00
// add "none" item again
2017-04-05 18:42:07 +02:00
metadataTypeListbox . addItem ( NONE_PROFILE ) ;
2016-07-22 12:51:19 +02:00
2016-07-20 22:41:15 +02:00
// select "none"
2017-04-05 18:42:07 +02:00
metadataTypeListbox . setSelectedIndex ( 0 ) ;
2016-07-20 22:41:15 +02:00
// get the name of the organization from the title
2018-11-20 12:29:41 +01:00
String selectedOrganizationTitle = organizationsListbox . getSelectedItemText ( ) ;
2016-12-22 23:53:30 +01:00
final String orgName = nameTitleOrganizationMap . get ( selectedOrganizationTitle ) ;
2016-07-21 11:26:18 +02:00
2016-07-20 22:41:15 +02:00
// try to retrieve the profiles
2017-04-05 18:42:07 +02:00
setAlertBlock ( " Retrieving types, please wait... " , AlertType . INFO , true ) ;
2016-07-20 19:14:20 +02:00
2022-06-14 12:28:03 +02:00
// disable the list of organizations name so that the user doesn't change it
// again
2016-11-17 14:08:22 +01:00
// also disable the profiles and the list of groups
2016-07-22 12:51:19 +02:00
organizationsListbox . setEnabled ( false ) ;
2017-04-05 18:42:07 +02:00
metadataTypeListbox . setEnabled ( false ) ;
2016-12-26 22:07:05 +01:00
groupsListbox . clear ( ) ;
2016-11-17 14:08:22 +01:00
groupsControlGroup . setVisible ( false ) ;
2016-07-22 12:51:19 +02:00
2016-07-20 19:14:20 +02:00
// perform remote request of profiles for the selected organization
2016-07-20 22:41:15 +02:00
ckanServices . getProfiles ( orgName , new AsyncCallback < List < MetaDataProfileBean > > ( ) {
2016-07-20 19:14:20 +02:00
@Override
2016-11-17 14:08:22 +01:00
public void onSuccess ( final List < MetaDataProfileBean > profiles ) {
2016-07-20 19:14:20 +02:00
2022-06-14 12:28:03 +02:00
if ( profiles ! = null ) {
2016-07-20 19:14:20 +02:00
2017-04-25 15:41:27 +02:00
receivedBean . setMetadataList ( profiles ) ;
2016-07-20 19:14:20 +02:00
prepareMetadataList ( receivedBean ) ;
2016-07-22 12:51:19 +02:00
organizationsListbox . setEnabled ( true ) ;
2017-04-05 18:42:07 +02:00
metadataTypeListbox . setEnabled ( true ) ;
2016-11-17 14:08:22 +01:00
// try to retrieve the licenses
setAlertBlock ( " Retrieving groups, please wait... " , AlertType . INFO , true ) ;
2016-07-21 11:26:18 +02:00
2016-11-17 14:08:22 +01:00
// request groups
2017-04-25 15:41:27 +02:00
ckanServices . getUserGroups ( orgName , new AsyncCallback < List < OrganizationBean > > ( ) {
2016-11-17 14:08:22 +01:00
@Override
2017-04-25 15:41:27 +02:00
public void onSuccess ( List < OrganizationBean > groups ) {
2016-11-17 14:08:22 +01:00
2022-06-14 12:28:03 +02:00
if ( groups = = null ) {
2016-11-17 14:08:22 +01:00
setAlertBlock ( " Error while retrieving groups, try later " , AlertType . ERROR , true ) ;
2022-06-14 12:28:03 +02:00
} else {
if ( groups . isEmpty ( ) ) {
2016-12-24 01:25:17 +01:00
groupsControlGroup . setVisible ( false ) ;
2022-06-14 12:28:03 +02:00
} else {
2016-11-17 14:08:22 +01:00
// add groups
2017-04-25 15:41:27 +02:00
for ( OrganizationBean group : groups ) {
groupsListbox . addItem ( group . getTitle ( ) , group . getName ( ) ) ;
2016-11-17 14:08:22 +01:00
}
groupsListbox . setEnabled ( true ) ;
2016-12-26 22:07:05 +01:00
hideGroupsAlreadyInProfile ( profiles ) ;
2016-11-17 14:08:22 +01:00
}
setAlertBlock ( " " , AlertType . ERROR , false ) ;
}
}
@Override
public void onFailure ( Throwable caught ) {
setAlertBlock ( " Error while retrieving groups, try later " , AlertType . ERROR , true ) ;
}
} ) ;
2016-07-20 19:14:20 +02:00
2017-04-25 15:41:27 +02:00
// check also for tags (if for that context there is a vocabulary or not)
2018-11-20 12:29:41 +01:00
tagsPanel . setVisible ( false ) ;
2017-04-27 16:24:21 +02:00
setAlertBlock ( " Checking for tags vocabulary, please wait... " , AlertType . INFO , true ) ;
2017-04-25 15:41:27 +02:00
ckanServices . getTagsForOrganization ( orgName , new AsyncCallback < List < String > > ( ) {
@Override
public void onSuccess ( List < String > vocabulary ) {
tagsPanel . setVocabulary ( vocabulary ) ;
tagsPanel . setVisible ( true ) ;
2017-04-27 16:24:21 +02:00
setAlertBlock ( " " , AlertType . ERROR , false ) ;
2017-04-25 15:41:27 +02:00
}
@Override
public void onFailure ( Throwable arg0 ) {
2022-06-14 12:28:03 +02:00
setAlertBlock (
" Error while checking if a vocabulary of tags is defined in the selected organization. " ,
AlertType . ERROR , true ) ;
2017-04-27 16:24:21 +02:00
tagsPanel . setVocabulary ( null ) ;
2017-04-25 15:41:27 +02:00
tagsPanel . setVisible ( true ) ;
}
} ) ;
2022-06-14 12:28:03 +02:00
} else
2017-04-05 18:42:07 +02:00
setAlertBlock ( " Error while retrieving types, sorry " , AlertType . ERROR , true ) ;
2016-07-20 19:14:20 +02:00
}
@Override
public void onFailure ( Throwable caught ) {
2017-04-05 18:42:07 +02:00
setAlertBlock ( " Error while retrieving types, sorry " , AlertType . ERROR , true ) ;
2016-07-20 19:14:20 +02:00
}
} ) ;
}
2016-06-29 12:39:27 +02:00
/ * *
* Add the items to the listbox and put data into the metadataPanel
2022-06-14 12:28:03 +02:00
*
2016-06-29 12:39:27 +02:00
* @param receivedBean
* /
2017-04-25 15:41:27 +02:00
private void prepareMetadataList ( final DatasetBean receivedBean ) {
2016-06-09 18:58:19 +02:00
2017-04-25 15:41:27 +02:00
List < MetaDataProfileBean > profiles = receivedBean . getMetadataList ( ) ;
2016-06-09 18:58:19 +02:00
2022-06-14 12:28:03 +02:00
if ( profiles ! = null & & ! profiles . isEmpty ( ) ) {
for ( MetaDataProfileBean metadataBean : profiles ) {
2016-06-09 18:58:19 +02:00
2018-11-20 12:29:41 +01:00
metadataTypeListbox . addItem ( metadataBean . getType ( ) ) ;
2016-06-09 18:58:19 +02:00
2016-07-19 21:24:42 +02:00
// add handler on select
2017-04-05 18:42:07 +02:00
metadataTypeListbox . addChangeHandler ( new ChangeHandler ( ) {
2016-06-09 18:58:19 +02:00
2016-07-19 21:24:42 +02:00
@Override
public void onChange ( ChangeEvent event ) {
2016-06-09 18:58:19 +02:00
2017-04-05 18:42:07 +02:00
String selectedItemText = metadataTypeListbox . getSelectedItemText ( ) ;
2017-04-25 15:41:27 +02:00
metadataFieldsPanel . clear ( ) ;
2022-06-14 12:28:03 +02:00
if ( selectedItemText . equals ( NONE_PROFILE ) ) {
2016-07-19 21:24:42 +02:00
metadataFieldsPanel . setVisible ( false ) ;
2017-04-05 18:42:07 +02:00
receivedBean . setChosenType ( null ) ;
2022-06-14 12:28:03 +02:00
} else {
2017-04-05 18:42:07 +02:00
receivedBean . setChosenType ( selectedItemText ) ;
2016-11-17 14:08:22 +01:00
addFields ( selectedItemText ) ;
2016-07-19 21:24:42 +02:00
}
2016-06-28 12:05:23 +02:00
}
2016-07-19 21:24:42 +02:00
} ) ;
}
2016-11-17 14:08:22 +01:00
2022-06-14 12:28:03 +02:00
// hide elements or show them if needed (groups in profiles cannot be present
// again in groups listbox)
if ( groupsControlGroup . isVisible ( ) ) {
2016-11-17 14:08:22 +01:00
List < String > groupsToHide = new ArrayList < String > ( ) ;
2022-06-14 12:28:03 +02:00
for ( MetaDataProfileBean profile : profiles )
2016-11-17 14:08:22 +01:00
groupsToHide . add ( profile . getType ( ) . toString ( ) ) ;
SelectElement se = groupsListbox . getElement ( ) . cast ( ) ;
for ( int i = 0 ; i < groupsListbox . getItemCount ( ) ; i + + ) {
2022-06-14 12:28:03 +02:00
if ( groupsToHide . contains ( groupsListbox . getItemText ( i ) ) ) {
2016-11-17 14:08:22 +01:00
se . getOptions ( ) . getItem ( i ) . getStyle ( ) . setProperty ( " display " , " none " ) ;
2022-06-14 12:28:03 +02:00
} else
2016-11-17 14:08:22 +01:00
se . getOptions ( ) . getItem ( i ) . getStyle ( ) . setProperty ( " display " , " " ) ;
}
}
2017-04-05 18:42:07 +02:00
metadataTypesControlGroup . setVisible ( true ) ;
2022-06-14 12:28:03 +02:00
} else {
2016-07-19 21:24:42 +02:00
// just hide this listbox
2017-04-05 18:42:07 +02:00
metadataTypesControlGroup . setVisible ( false ) ;
2016-07-28 10:21:22 +02:00
metadataFieldsPanel . clear ( ) ;
listOfMetadataFields . clear ( ) ;
2017-04-05 18:42:07 +02:00
receivedBean . setChosenType ( null ) ;
2016-06-09 18:58:19 +02:00
}
2016-06-29 12:39:27 +02:00
}
2016-06-09 18:58:19 +02:00
2016-09-28 16:41:55 +02:00
/ * *
* Add fields of the selected metadata profile to the widget
2022-06-14 12:28:03 +02:00
*
2016-09-28 16:41:55 +02:00
* @param selectedItem
* /
2016-06-29 12:39:27 +02:00
protected void addFields ( String selectedItem ) {
2016-05-27 19:08:03 +02:00
2022-06-14 12:28:03 +02:00
for ( MetaDataProfileBean bean : receivedBean . getMetadataList ( ) ) {
if ( bean . getType ( ) . equals ( selectedItem ) ) {
2016-05-27 19:08:03 +02:00
2017-04-25 15:41:27 +02:00
// clear old data
listOfMetadataFields . clear ( ) ;
2016-06-29 12:39:27 +02:00
// prepare the data
List < MetadataFieldWrapper > fields = bean . getMetadataFields ( ) ;
2017-04-25 15:41:27 +02:00
List < CategoryWrapper > categories = bean . getCategories ( ) ;
2017-04-27 16:24:21 +02:00
GWT . log ( " There are " + categories . size ( ) + " categories for profile " + bean . getTitle ( ) ) ;
2022-06-14 12:28:03 +02:00
if ( categories = = null | | categories . isEmpty ( ) ) {
2017-04-25 15:41:27 +02:00
for ( MetadataFieldWrapper field : fields ) {
2022-06-14 12:28:03 +02:00
/ *
* MetaDataFieldSkeleton fieldWidget ; try { fieldWidget = new
* MetaDataFieldSkeleton ( field , eventBus ) ; metadataFieldsPanel . add ( fieldWidget ) ;
* listOfMetadataFields . add ( fieldWidget ) ; } catch ( Exception e ) {
* GWT . log ( " Unable to build such widget " , e ) ; }
* /
2019-06-10 17:48:28 +02:00
MetaDataField fieldWidget ;
try {
fieldWidget = new MetaDataField ( field , eventBus ) ;
metadataFieldsPanel . add ( fieldWidget ) ;
listOfMetadataFields . add ( fieldWidget ) ;
} catch ( Exception e ) {
GWT . log ( " Unable to build such widget " , e ) ;
2017-04-25 15:41:27 +02:00
}
}
2022-06-14 12:28:03 +02:00
} else {
2016-05-27 19:08:03 +02:00
2022-06-14 12:28:03 +02:00
// create the categories, then parse the fields. Fields do not belonging to a
// category are put at the end
2017-04-25 15:41:27 +02:00
for ( CategoryWrapper categoryWrapper : categories ) {
2022-06-14 12:28:03 +02:00
if ( categoryWrapper . getFieldsForThisCategory ( ) ! = null
& & categoryWrapper . getFieldsForThisCategory ( ) . size ( ) > 0 ) {
CategoryPanel cp = new CategoryPanel ( categoryWrapper . getTitle ( ) ,
categoryWrapper . getDescription ( ) ) ;
List < MetadataFieldWrapper > fieldsForThisCategory = categoryWrapper
. getFieldsForThisCategory ( ) ;
2017-04-27 16:24:21 +02:00
fields . removeAll ( fieldsForThisCategory ) ;
for ( MetadataFieldWrapper metadataFieldWrapper : fieldsForThisCategory ) {
2022-06-14 12:28:03 +02:00
/ *
* MetaDataFieldSkeleton fieldWidget ; try { fieldWidget = new
* MetaDataFieldSkeleton ( metadataFieldWrapper , eventBus ) ;
* cp . addField ( fieldWidget ) ; listOfMetadataFields . add ( fieldWidget ) ; } catch
* ( Exception e ) { GWT . log ( " Unable to build such widget " , e ) ; }
* /
2019-06-10 17:48:28 +02:00
MetaDataField fieldWidget ;
try {
fieldWidget = new MetaDataField ( metadataFieldWrapper , eventBus ) ;
cp . addField ( fieldWidget ) ;
listOfMetadataFields . add ( fieldWidget ) ;
} catch ( Exception e ) {
GWT . log ( " Unable to build such widget " , e ) ;
2017-04-27 16:24:21 +02:00
}
2017-04-25 15:41:27 +02:00
}
2017-04-27 16:24:21 +02:00
metadataFieldsPanel . add ( cp ) ;
2017-04-25 15:41:27 +02:00
}
}
2017-04-27 16:24:21 +02:00
// add the remaining one at the end of the categories
CategoryPanel extrasCategory = new CategoryPanel ( " Other " , null ) ;
2017-04-25 15:41:27 +02:00
for ( MetadataFieldWrapper field : fields ) {
2022-06-14 12:28:03 +02:00
/ *
* MetaDataFieldSkeleton fieldWidget ; try { fieldWidget = new
* MetaDataFieldSkeleton ( field , eventBus ) ; extrasCategory . addField ( fieldWidget ) ;
* listOfMetadataFields . add ( fieldWidget ) ; } catch ( Exception e ) {
* GWT . log ( " Unable to build such widget " , e ) ; }
* /
2019-06-10 17:48:28 +02:00
MetaDataField fieldWidget ;
try {
fieldWidget = new MetaDataField ( field , eventBus ) ;
extrasCategory . addField ( fieldWidget ) ;
listOfMetadataFields . add ( fieldWidget ) ;
} catch ( Exception e ) {
GWT . log ( " Unable to build such widget " , e ) ;
2017-04-25 15:41:27 +02:00
}
2016-09-14 16:29:52 +02:00
}
2017-04-27 16:24:21 +02:00
metadataFieldsPanel . add ( extrasCategory ) ;
2016-06-28 12:05:23 +02:00
}
2018-11-20 12:29:41 +01:00
metadataFieldsPanel . setVisible ( true ) ;
2016-06-29 12:39:27 +02:00
}
2016-06-28 12:05:23 +02:00
}
2016-06-29 12:39:27 +02:00
}
2016-05-26 18:12:53 +02:00
2016-06-29 12:39:27 +02:00
@UiHandler ( " addCustomFieldButton " )
2022-06-14 12:28:03 +02:00
void addCustomFieldEvent ( ClickEvent e ) {
2016-06-29 12:39:27 +02:00
CustomFieldEntry toAdd = new CustomFieldEntry ( eventBus , " " , " " , true ) ;
customFieldEntriesList . add ( toAdd ) ;
customFields . add ( toAdd ) ;
2016-05-27 19:08:03 +02:00
2016-06-29 12:39:27 +02:00
}
@UiHandler ( " continueButton " )
2022-06-14 12:28:03 +02:00
void onContinueButton ( ClickEvent e ) {
2016-06-08 18:31:54 +02:00
2016-06-29 12:39:27 +02:00
// validate data
2016-09-26 12:15:05 +02:00
final String errorMsg = validateDataOnContinue ( ) ;
2022-06-14 12:28:03 +02:00
if ( errorMsg ! = null ) {
2016-06-08 18:31:54 +02:00
2016-09-26 12:15:05 +02:00
alertOnContinue ( " Please check inserted data [ " + errorMsg + " ] " , AlertType . ERROR ) ;
return ;
2016-07-06 18:41:43 +02:00
2022-06-14 12:28:03 +02:00
} else {
2016-09-26 14:12:26 +02:00
2022-06-14 12:28:03 +02:00
// better check for title (only if the dataset was not created.. if it is the
// case, fields are not frozen)
if ( ! titleTextBox . isEnabled ( ) )
2016-10-04 14:58:26 +02:00
actionsAfterOnContinue ( ) ;
2022-06-14 12:28:03 +02:00
else {
2017-02-15 17:10:22 +01:00
alertOnContinue ( " Checking if a item with such title already exists, please wait... " , AlertType . INFO ) ;
2021-05-24 16:51:02 +02:00
final String orgName = nameTitleOrganizationMap . get ( organizationsListbox . getSelectedItemText ( ) ) ;
ckanServices . datasetIdAlreadyExists ( titleTextBox . getText ( ) , orgName , new AsyncCallback < Boolean > ( ) {
2016-07-21 22:39:46 +02:00
2016-10-04 14:58:26 +02:00
@Override
public void onSuccess ( Boolean result ) {
2022-06-14 12:28:03 +02:00
if ( result ) {
alertOnContinue ( " Sorry but an item with such title already exists, try to change it " ,
AlertType . WARNING ) ;
} else {
2016-10-04 14:58:26 +02:00
actionsAfterOnContinue ( ) ;
2016-09-26 14:12:26 +02:00
}
2016-10-04 14:58:26 +02:00
}
2016-09-26 12:15:05 +02:00
2016-10-04 14:58:26 +02:00
@Override
public void onFailure ( Throwable caught ) {
2022-06-14 12:28:03 +02:00
alertOnContinue ( " Sorry but there was a problem while checking if the inserted data are correct " ,
AlertType . ERROR ) ;
2016-09-26 12:15:05 +02:00
}
2016-10-04 14:58:26 +02:00
} ) ;
}
}
}
2016-09-26 12:15:05 +02:00
2016-10-04 14:58:26 +02:00
/ * *
* After onContinue . . .
* /
2022-06-14 12:28:03 +02:00
private void actionsAfterOnContinue ( ) {
2016-09-26 12:15:05 +02:00
2018-11-20 12:29:41 +01:00
// check what to do
2022-06-14 12:28:03 +02:00
if ( isWorkspaceRequest ) {
2016-09-26 12:15:05 +02:00
2016-10-04 14:58:26 +02:00
// we need to show the page to handle resources one by one from the workspace
formFirstStep . setVisible ( false ) ;
2021-04-09 14:51:55 +02:00
boolean hideManageRes = hideManageResources ( ) ;
int stepActive = - 1 ;
2022-06-14 12:28:03 +02:00
if ( hideManageRes ) {
2021-04-09 14:51:55 +02:00
stepActive = 3 ;
2022-06-14 12:28:03 +02:00
} else {
2021-04-09 14:51:55 +02:00
stepActive = 2 ;
}
2022-06-14 12:28:03 +02:00
2021-04-09 14:51:55 +02:00
formSecondStep . setVisible ( ! hideManageRes ) ;
formThirdStep . setVisible ( hideManageRes ) ;
activeWizardStep ( stepActive ) ;
2016-10-04 14:58:26 +02:00
// add the resources to the container panel
2022-06-14 12:28:03 +02:00
if ( workspaceResourcesContainer . getWidget ( ) = = null ) {
2016-11-14 17:07:03 +01:00
workspaceResourcesContainer . getElement ( ) . getStyle ( ) . setMarginLeft ( 20 , Unit . PX ) ;
2021-04-09 14:51:55 +02:00
workspaceResourcesContainer . add ( resourcesSelectByWEMainPanel ) ;
2016-11-11 19:31:05 +01:00
}
2016-10-04 14:58:26 +02:00
2022-06-14 12:28:03 +02:00
} else {
2016-10-04 14:58:26 +02:00
// this is not a workspace request
formFirstStep . setVisible ( false ) ;
formThirdStep . setVisible ( true ) ;
2021-04-09 14:51:55 +02:00
activeWizardStep ( 2 ) ;
2016-09-26 12:15:05 +02:00
2016-06-28 12:05:23 +02:00
}
2016-10-04 14:58:26 +02:00
2022-06-14 12:28:03 +02:00
if ( metadataTypeListbox . getSelectedItemText ( ) . equals ( NONE_PROFILE ) )
2016-10-04 14:58:26 +02:00
selectedProfile . setText ( " " ) ;
else
2017-04-05 18:42:07 +02:00
selectedProfile . setText ( " Selected Type is " + metadataTypeListbox . getSelectedItemText ( ) ) ;
2016-10-04 14:58:26 +02:00
2016-06-29 12:39:27 +02:00
}
2022-06-14 12:28:03 +02:00
2021-04-09 14:51:55 +02:00
private void activeWizardStep ( int step ) {
2022-06-14 12:28:03 +02:00
if ( wizCreator ! = null ) {
2021-04-09 14:51:55 +02:00
wizCreator . activeStep ( step ) ;
}
}
2016-06-09 18:58:19 +02:00
2016-07-06 18:41:43 +02:00
@UiHandler ( " goBackButtonFirstStep " )
2022-06-14 12:28:03 +02:00
void onGoBackButtonFirstStep ( ClickEvent e ) {
2016-06-09 18:58:19 +02:00
2016-06-29 12:39:27 +02:00
// swap forms
formFirstStep . setVisible ( true ) ;
2021-04-09 14:51:55 +02:00
activeWizardStep ( 1 ) ;
2016-06-29 12:39:27 +02:00
formSecondStep . setVisible ( false ) ;
2016-07-06 18:41:43 +02:00
formThirdStep . setVisible ( false ) ;
2016-06-09 18:58:19 +02:00
2016-06-29 12:39:27 +02:00
}
2016-06-09 18:58:19 +02:00
2016-09-12 17:58:50 +02:00
@UiHandler ( " goBackButtonSecondStep " )
2022-06-14 12:28:03 +02:00
void onGoBackButton ( ClickEvent e ) {
2016-07-06 18:41:43 +02:00
// swap forms
2022-06-14 12:28:03 +02:00
if ( isWorkspaceRequest ) {
2021-04-09 14:51:55 +02:00
boolean hideManageRes = hideManageResources ( ) ;
int stepActive = - 1 ;
2022-06-14 12:28:03 +02:00
if ( hideManageRes ) {
2021-04-09 14:51:55 +02:00
stepActive = 1 ;
2022-06-14 12:28:03 +02:00
} else {
2021-04-09 14:51:55 +02:00
stepActive = 2 ;
}
formFirstStep . setVisible ( hideManageRes ) ;
formSecondStep . setVisible ( ! hideManageRes ) ;
activeWizardStep ( stepActive ) ;
2022-06-14 12:28:03 +02:00
} else {
2021-04-09 14:51:55 +02:00
2016-07-06 18:41:43 +02:00
formFirstStep . setVisible ( true ) ;
formSecondStep . setVisible ( false ) ;
2021-04-09 14:51:55 +02:00
activeWizardStep ( 1 ) ;
2016-07-06 18:41:43 +02:00
}
formThirdStep . setVisible ( false ) ;
}
@UiHandler ( " continueThirdStep " )
2022-06-14 12:28:03 +02:00
void onContinueThirdStep ( ClickEvent e ) {
2016-07-06 18:41:43 +02:00
// swap forms
formSecondStep . setVisible ( false ) ;
formThirdStep . setVisible ( true ) ;
2021-04-09 14:51:55 +02:00
activeWizardStep ( 3 ) ;
2016-07-06 18:41:43 +02:00
}
2016-06-29 12:39:27 +02:00
@UiHandler ( " createButton " )
2022-06-14 12:28:03 +02:00
void createDatasetEvent ( ClickEvent e ) {
2016-06-29 12:39:27 +02:00
2016-07-13 16:11:15 +02:00
String errorMessage = areProfileDataValid ( ) ;
2016-06-29 12:39:27 +02:00
2022-06-14 12:28:03 +02:00
if ( errorMessage ! = null ) {
alertOnCreate ( " Please check the inserted values and the mandatory fields [ " + errorMessage + " ] " , false ,
AlertType . ERROR , true ) ;
} else {
2016-06-29 12:39:27 +02:00
2016-10-03 16:56:32 +02:00
String title = titleTextBox . getValue ( ) . trim ( ) ;
String description = descriptionTextarea . getText ( ) . trim ( ) ;
2016-06-29 12:39:27 +02:00
String selectedLicense = licenseListbox . getSelectedItemText ( ) ;
String visibility = visibilityListbox . getSelectedItemText ( ) ;
2016-10-03 16:56:32 +02:00
long version = Long . valueOf ( versionTextbox . getValue ( ) . trim ( ) ) ;
2016-06-29 12:39:27 +02:00
String author = authorTextbox . getValue ( ) ;
String authorEmail = authorEmailTextbox . getValue ( ) ;
2016-10-03 16:56:32 +02:00
String maintainer = maintainerTextbox . getValue ( ) . trim ( ) ;
String maintainerEmail = maintainerEmailTextbox . getValue ( ) . trim ( ) ;
2016-07-20 22:41:15 +02:00
String chosenOrganizationTitle = organizationsListbox . getSelectedItemText ( ) ;
2017-04-25 18:11:13 +02:00
Set < String > tags = new HashSet < String > ( tagsPanel . getTags ( ) ) ;
2016-07-20 22:41:15 +02:00
2022-06-14 12:28:03 +02:00
// we need to retrieve the organization's name from this title
2016-07-20 22:41:15 +02:00
List < OrganizationBean > orgs = receivedBean . getOrganizationList ( ) ;
String chosenOrganization = null ;
for ( OrganizationBean organizationBean : orgs ) {
2022-06-14 12:28:03 +02:00
if ( chosenOrganizationTitle . equals ( organizationBean . getTitle ( ) ) ) {
2016-07-20 22:41:15 +02:00
chosenOrganization = organizationBean . getName ( ) ;
break ;
}
}
2016-11-15 10:40:13 +01:00
2017-04-25 15:41:27 +02:00
List < OrganizationBean > groups = new ArrayList < OrganizationBean > ( ) ;
2017-04-27 16:24:21 +02:00
List < OrganizationBean > groupsToForceCreation = new ArrayList < OrganizationBean > ( ) ;
2016-11-15 10:40:13 +01:00
2016-11-14 18:37:45 +01:00
// get groups, if any
int items = groupsListbox . getItemCount ( ) ;
for ( int i = 0 ; i < items ; i + + ) {
String groupTitle = groupsListbox . getItemText ( i ) ;
String groupName = groupsListbox . getValue ( i ) ;
2022-06-14 12:28:03 +02:00
if ( groupsListbox . isItemSelected ( i ) ) {
2017-04-25 15:41:27 +02:00
groups . add ( new OrganizationBean ( groupTitle , groupName , false ) ) ;
2016-11-14 18:37:45 +01:00
}
}
2016-06-29 12:39:27 +02:00
2016-12-07 10:58:11 +01:00
Map < String , List < String > > customFieldsMap = new HashMap < String , List < String > > ( ) ;
2016-06-29 12:39:27 +02:00
// prepare custom fields
2019-06-10 17:48:28 +02:00
for ( MetaDataField metaField : listOfMetadataFields ) {
2022-06-14 12:28:03 +02:00
2019-06-10 17:48:28 +02:00
for ( MetaDataFieldSkeleton field : metaField . getListOfMetadataFields ( ) ) {
2022-06-14 12:28:03 +02:00
2019-06-10 17:48:28 +02:00
List < String > valuesForField = field . getFieldCurrentValue ( ) ;
2022-06-14 12:28:03 +02:00
if ( ! valuesForField . isEmpty ( ) ) {
2019-06-10 17:48:28 +02:00
String key = field . getFieldNameQualified ( ) ;
List < String > valuesForThisField = null ;
2022-06-14 12:28:03 +02:00
if ( customFieldsMap . containsKey ( key ) )
2019-06-10 17:48:28 +02:00
valuesForThisField = customFieldsMap . get ( key ) ;
else
valuesForThisField = new ArrayList < String > ( ) ;
2022-06-14 12:28:03 +02:00
2019-06-10 17:48:28 +02:00
valuesForThisField . addAll ( valuesForField ) ;
customFieldsMap . put ( key , valuesForThisField ) ;
2022-06-14 12:28:03 +02:00
2019-06-10 17:48:28 +02:00
// get also tag/group if it is the case for this field
List < String > tagsField = field . getTagFromThisField ( ) ;
2022-06-14 12:28:03 +02:00
if ( tagsField ! = null )
2019-06-10 17:48:28 +02:00
tags . addAll ( tagsField ) ;
2022-06-14 12:28:03 +02:00
2019-06-10 17:48:28 +02:00
List < String > groupsTitle = field . getGroupTitleFromThisGroup ( ) ;
2022-06-14 12:28:03 +02:00
if ( groupsTitle ! = null ) {
2019-06-10 17:48:28 +02:00
for ( String groupTitle : groupsTitle ) {
2022-06-14 12:28:03 +02:00
if ( field . isGroupToForce ( ) )
groupsToForceCreation . add (
new OrganizationBean ( groupTitle , groupTitle , false , field . isPropagateUp ( ) ) ) ;
2019-06-10 17:48:28 +02:00
else
2022-06-14 12:28:03 +02:00
groups . add (
new OrganizationBean ( groupTitle , groupTitle , false , field . isPropagateUp ( ) ) ) ;
2019-06-10 17:48:28 +02:00
}
2017-04-28 17:31:42 +02:00
}
2017-04-27 16:24:21 +02:00
}
2016-12-07 10:58:11 +01:00
}
2016-06-29 12:39:27 +02:00
}
2016-06-06 17:24:52 +02:00
2022-06-14 12:28:03 +02:00
for ( CustomFieldEntry customEntry : customFieldEntriesList ) {
2016-06-29 12:39:27 +02:00
String key = customEntry . getKey ( ) ;
String value = customEntry . getValue ( ) ;
2022-06-14 12:28:03 +02:00
if ( value ! = null & & ! value . isEmpty ( ) ) {
2016-12-07 10:58:11 +01:00
List < String > valuesForThisField = null ;
2022-06-14 12:28:03 +02:00
if ( customFieldsMap . containsKey ( key ) )
2016-12-07 10:58:11 +01:00
valuesForThisField = customFieldsMap . get ( key ) ;
else
valuesForThisField = new ArrayList < String > ( ) ;
valuesForThisField . add ( value ) ;
customFieldsMap . put ( key , valuesForThisField ) ;
}
2016-06-06 17:24:52 +02:00
2016-06-29 12:39:27 +02:00
}
2016-06-06 17:24:52 +02:00
2017-04-25 18:11:13 +02:00
// fill the bean
receivedBean . setAuthorFullName ( author ) ;
receivedBean . setAuthorEmail ( authorEmail ) ;
receivedBean . setDescription ( description ) ;
receivedBean . setLicense ( selectedLicense ) ;
receivedBean . setMaintainer ( maintainer ) ;
receivedBean . setMaintainerEmail ( maintainerEmail ) ;
receivedBean . setVersion ( version ) ;
receivedBean . setVisibile ( visibility . equals ( " Public " ) ) ;
receivedBean . setTitle ( title ) ;
receivedBean . setTags ( new ArrayList < String > ( tags ) ) ;
receivedBean . setSelectedOrganization ( chosenOrganization ) ;
receivedBean . setGroups ( groups ) ;
2017-04-27 16:24:21 +02:00
receivedBean . setGroupsForceCreation ( groupsToForceCreation ) ;
2022-06-14 12:28:03 +02:00
if ( resourcesSelectByWEMainPanel ! = null ) {
2021-04-09 14:51:55 +02:00
receivedBean . setResourceRoot ( resourcesSelectByWEMainPanel . getResourcesToPublish ( ) ) ;
}
2022-06-14 12:28:03 +02:00
2016-06-29 12:39:27 +02:00
receivedBean . setCustomFields ( customFieldsMap ) ;
2016-06-06 17:24:52 +02:00
2018-11-20 12:29:41 +01:00
// alert
2022-06-14 12:28:03 +02:00
alertOnCreate ( TRYING_TO_CREATE_PRODUCT , true , AlertType . INFO , false ) ;
2016-06-06 17:24:52 +02:00
2016-06-29 12:39:27 +02:00
// invoke the create method
createButton . setEnabled ( false ) ;
2016-09-12 17:58:50 +02:00
goBackButtonSecondStep . setEnabled ( false ) ;
2016-06-06 17:24:52 +02:00
2017-04-25 15:41:27 +02:00
ckanServices . createCKanDataset ( receivedBean , new AsyncCallback < DatasetBean > ( ) {
2016-06-06 17:24:52 +02:00
2016-06-29 12:39:27 +02:00
@Override
2017-04-25 15:41:27 +02:00
public void onSuccess ( final DatasetBean createdDatasetBean ) {
2022-06-14 12:28:03 +02:00
GWT . log ( " Created the dataset: " + createdDatasetBean ) ;
if ( createdDatasetBean ! = null ) {
2019-04-10 15:53:29 +02:00
final String datasetUrl = createdDatasetBean . getSource ( ) ;
2016-06-07 17:50:33 +02:00
2022-06-14 12:28:03 +02:00
alertOnCreate ( PRODUCT_CREATED_OK , false , AlertType . SUCCESS , false ) ;
2019-04-10 15:53:29 +02:00
try {
2022-06-14 12:28:03 +02:00
// disable dataset fields
2019-04-10 15:53:29 +02:00
disableDatasetFields ( ) ;
2022-06-14 12:28:03 +02:00
} catch ( Exception e ) {
2019-04-10 15:53:29 +02:00
// TODO: handle exception
}
2016-06-10 12:10:18 +02:00
2016-06-29 12:39:27 +02:00
// disable reset
resetButton . setEnabled ( false ) ;
2016-06-13 17:40:19 +02:00
2016-06-29 12:39:27 +02:00
// show the go to dataset button
2022-06-14 12:28:03 +02:00
2016-10-25 17:03:41 +02:00
goToDatasetButtonPanel . setVisible ( true ) ;
2016-06-29 12:39:27 +02:00
goToDatasetButton . setVisible ( true ) ;
2022-06-14 12:28:03 +02:00
String title = createdDatasetBean . getTitle ( ) ;
String link = " (click here) " ;
link + = title . length ( ) > 90 ? title . substring ( 0 , 90 ) + " ... " : title ;
goToDatasetButton . setTitle ( " Go to the item: " + title ) ;
goToDatasetButton . setText ( link ) ;
2016-06-29 12:39:27 +02:00
goToDatasetButton . addClickHandler ( new ClickHandler ( ) {
2016-06-10 12:10:18 +02:00
2016-06-29 12:39:27 +02:00
@Override
public void onClick ( ClickEvent event ) {
2016-10-22 17:51:43 +02:00
Window . open ( datasetUrl , " _blank " , " " ) ;
2022-06-14 12:28:03 +02:00
// Window.Location.assign(datasetUrl);
2016-06-29 12:39:27 +02:00
}
} ) ;
2022-06-14 12:28:03 +02:00
2019-04-10 15:53:29 +02:00
// set hidden the create button
createButton . setVisible ( false ) ;
2016-06-10 12:10:18 +02:00
2016-06-29 12:39:27 +02:00
// if we are in the "general case" we need to show a form for adding resources
2022-06-14 12:28:03 +02:00
if ( ! isWorkspaceRequest ) {
2019-04-10 15:53:29 +02:00
try {
// show the add resources button
addResourcesButton . setVisible ( true ) ;
2022-06-14 12:28:03 +02:00
2019-04-10 15:53:29 +02:00
addResourcesButton . addClickHandler ( new ClickHandler ( ) {
2022-06-14 12:28:03 +02:00
2019-04-10 15:53:29 +02:00
@Override
public void onClick ( ClickEvent event ) {
2022-06-14 12:28:03 +02:00
2019-04-10 15:53:29 +02:00
// remove content of the main panel
createDatasetMainPanel . clear ( ) ;
2022-06-14 12:28:03 +02:00
2019-04-10 15:53:29 +02:00
// TabPanelException
tabPanel = new TabPanel ( Tabs . ABOVE ) ;
tabPanel . setWidth ( " 100% " ) ;
2022-06-14 12:28:03 +02:00
2019-04-10 15:53:29 +02:00
// add the form
2022-06-14 12:28:03 +02:00
resourceForm = new AddResourceToDataset ( eventBus , createdDatasetBean . getId ( ) ,
createdDatasetBean . getTitle ( ) ,
createdDatasetBean . getSelectedOrganization ( ) , owner , datasetUrl ) ;
2019-04-10 15:53:29 +02:00
// tab for the form
Tab formContainer = new Tab ( ) ;
formContainer . add ( resourceForm ) ;
formContainer . setHeading ( " Add New Resource " ) ;
tabPanel . add ( formContainer ) ;
2022-06-14 12:28:03 +02:00
2019-04-10 15:53:29 +02:00
// tab for the added resources
Tab addedResources = new Tab ( ) ;
addedResources . add ( new AddedResourcesSummary ( eventBus ) ) ;
addedResources . setHeading ( " Added Resource " ) ;
tabPanel . add ( addedResources ) ;
2022-06-14 12:28:03 +02:00
2019-04-10 15:53:29 +02:00
// add tabs to resources panel
tabPanel . selectTab ( 0 ) ;
2022-06-14 12:28:03 +02:00
2019-04-10 15:53:29 +02:00
// form container
AddResourceContainer container = new AddResourceContainer ( datasetUrl ) ;
container . add ( tabPanel ) ;
2022-06-14 12:28:03 +02:00
2019-04-10 15:53:29 +02:00
// add the new content of the main panel
createDatasetMainPanel . add ( container ) ;
}
} ) ;
2022-06-14 12:28:03 +02:00
} catch ( Exception e2 ) {
// silent
2019-04-10 15:53:29 +02:00
}
2016-06-29 12:39:27 +02:00
}
2016-06-28 12:05:23 +02:00
2022-06-14 12:28:03 +02:00
} else {
2017-04-25 15:41:27 +02:00
2022-06-14 12:28:03 +02:00
alertOnCreate ( ERROR_PRODUCT_CREATION , false , AlertType . ERROR , true ) ;
2016-06-06 17:24:52 +02:00
}
2016-06-29 12:39:27 +02:00
}
2016-06-06 17:24:52 +02:00
2016-06-29 12:39:27 +02:00
@Override
public void onFailure ( Throwable caught ) {
2022-06-14 12:28:03 +02:00
alertOnCreate ( ERROR_PRODUCT_CREATION + " Error message is : " + caught . getMessage ( ) , false ,
AlertType . ERROR , true ) ;
2016-06-29 12:39:27 +02:00
}
} ) ;
2016-06-09 18:58:19 +02:00
}
2016-06-29 12:39:27 +02:00
}
2016-06-09 18:58:19 +02:00
2016-07-13 18:13:50 +02:00
/ * *
* Prepare the info icons of all core metadata info
* /
private void prepareInfoIcons ( ) {
2016-10-04 14:58:26 +02:00
2016-07-13 18:13:50 +02:00
// tags
2016-10-03 17:27:12 +02:00
tagsPanel . prepareIcon ( popupOpenedIds ) ;
2016-07-19 21:24:42 +02:00
2016-07-14 16:47:17 +02:00
// licenses
2022-06-14 12:28:03 +02:00
InfoIconsLabels . preparePopupPanelAndPopover ( InfoIconsLabels . LICENSES_INFO_ID_POPUP ,
InfoIconsLabels . LICENSES_INFO_TEXT , InfoIconsLabels . LICENSES_INFO_CAPTION , infoIconLicenses ,
popoverLicenses , focusPanelLicenses , popupOpenedIds ) ;
2016-07-13 18:13:50 +02:00
// visibility
2022-06-14 12:28:03 +02:00
InfoIconsLabels . preparePopupPanelAndPopover ( InfoIconsLabels . VISIBILITY_INFO_ID_POPUP ,
InfoIconsLabels . VISIBILITY_INFO_TEXT , InfoIconsLabels . VISIBILITY_INFO_CAPTION , infoIconVisibility ,
popoverVisibility , focusPanelVisibility , popupOpenedIds ) ;
2016-07-13 18:13:50 +02:00
// author
2022-06-14 12:28:03 +02:00
InfoIconsLabels . preparePopupPanelAndPopover ( InfoIconsLabels . AUTHOR_INFO_ID_POPUP ,
InfoIconsLabels . AUTHOR_INFO_TEXT , InfoIconsLabels . AUTHOR_INFO_CAPTION , infoIconAuthor , popoverAuthor ,
focusPanelAuthor , popupOpenedIds ) ;
2016-07-13 18:13:50 +02:00
// author's email
2022-06-14 12:28:03 +02:00
InfoIconsLabels . preparePopupPanelAndPopover ( InfoIconsLabels . AUTHOR_EMAIL_INFO_ID_POPUP ,
InfoIconsLabels . AUTHOR_EMAIL_INFO_TEXT , InfoIconsLabels . AUTHOR_EMAIL_INFO_CAPTION , infoIconAuthorEmail ,
popoverAuthorEmail , focusPanelAuthorEmail , popupOpenedIds ) ;
2016-07-13 18:13:50 +02:00
// maintainer
2022-06-14 12:28:03 +02:00
InfoIconsLabels . preparePopupPanelAndPopover ( InfoIconsLabels . MAINTAINER_INFO_ID_POPUP ,
InfoIconsLabels . MAINTAINER_INFO_TEXT , InfoIconsLabels . MAINTAINER_INFO_CAPTION , infoIconMaintainer ,
popoverMaintainer , focusPanelMaintainer , popupOpenedIds ) ;
2016-07-13 18:13:50 +02:00
// maintainer's email
2022-06-14 12:28:03 +02:00
InfoIconsLabels . preparePopupPanelAndPopover ( InfoIconsLabels . MAINTAINER_EMAIL_INFO_ID_POPUP ,
InfoIconsLabels . MAINTAINER_EMAIL_INFO_TEXT , InfoIconsLabels . MAINTAINER_EMAIL_INFO_CAPTION ,
infoIconMaintainerEmail , popoverMaintainerEmail , focusPanelMaintainerEmail , popupOpenedIds ) ;
2016-07-13 18:13:50 +02:00
2017-04-05 18:42:07 +02:00
// profiles (or types)
2022-06-14 12:28:03 +02:00
InfoIconsLabels . preparePopupPanelAndPopover ( InfoIconsLabels . PROFILES_INFO_ID_POPUP ,
InfoIconsLabels . PROFILES_INFO_TEXT , InfoIconsLabels . PROFILES_INFO_CAPTION , infoIconTypes , popoverTypes ,
focusPanelTypes , popupOpenedIds ) ;
2016-07-13 18:13:50 +02:00
// custom fields
2022-06-14 12:28:03 +02:00
InfoIconsLabels . preparePopupPanelAndPopover ( InfoIconsLabels . CUSTOM_FIELDS_INFO_ID_POPUP ,
InfoIconsLabels . CUSTOM_FIELDS_INFO_TEXT , InfoIconsLabels . CUSTOM_FIELDS_INFO_CAPTION ,
infoIconCustomFields , popoverCustomFields , focusPanelCustomFields , popupOpenedIds ) ;
2016-07-13 18:13:50 +02:00
// resources field
2022-06-14 12:28:03 +02:00
InfoIconsLabels . preparePopupPanelAndPopover ( InfoIconsLabels . RESOURCES_INFO_ID_POPUP ,
InfoIconsLabels . RESOURCES_INFO_TEXT , InfoIconsLabels . RESOURCES_INFO_CAPTION , infoIconResources ,
popoverResources , focusPanelResources , popupOpenedIds ) ;
2016-07-13 18:13:50 +02:00
2016-09-23 18:50:16 +02:00
// title
2022-06-14 12:28:03 +02:00
InfoIconsLabels . preparePopupPanelAndPopover ( InfoIconsLabels . TITLE_INFO_ID_POPUP ,
InfoIconsLabels . TITLE_INFO_TEXT , InfoIconsLabels . TITLE_INFO_CAPTION , infoIconTitle , popoverTitle ,
focusPanelTitle , popupOpenedIds ) ;
2017-02-22 17:40:16 +01:00
2017-01-25 18:29:47 +01:00
// description
2022-06-14 12:28:03 +02:00
InfoIconsLabels . preparePopupPanelAndPopover ( InfoIconsLabels . DESCRIPTION_INFO_ID_POPUP ,
InfoIconsLabels . DESCRIPTION_INFO_TEXT , InfoIconsLabels . DESCRIPTION_INFO_CAPTION , infoIconDescription ,
popoverDescription , focusPanelDescription , popupOpenedIds ) ;
2016-11-14 18:37:45 +01:00
// groups
2022-06-14 12:28:03 +02:00
InfoIconsLabels . preparePopupPanelAndPopover ( InfoIconsLabels . GROUPS_INFO_ID_POPUP ,
InfoIconsLabels . GROUPS_INFO_TEXT , InfoIconsLabels . GROUPS_INFO_CAPTION , infoIconGroups , popoverGroups ,
focusPanelGroups , popupOpenedIds ) ;
2016-07-13 18:13:50 +02:00
}
2016-06-29 12:39:27 +02:00
/ * *
* Test if profile data are valid
2022-06-14 12:28:03 +02:00
*
2016-06-29 12:39:27 +02:00
* @return
* /
2016-07-13 16:11:15 +02:00
private String areProfileDataValid ( ) {
2016-06-09 18:58:19 +02:00
2019-06-10 17:48:28 +02:00
for ( MetaDataField metaField : listOfMetadataFields ) {
2022-06-14 12:28:03 +02:00
2019-06-10 17:48:28 +02:00
for ( MetaDataFieldSkeleton field : metaField . getListOfMetadataFields ( ) ) {
2016-06-09 18:58:19 +02:00
2019-06-10 17:48:28 +02:00
field . removeError ( ) ;
2022-06-14 12:28:03 +02:00
2019-06-10 17:48:28 +02:00
String error = field . isFieldValueValid ( ) ;
2022-06-14 12:28:03 +02:00
if ( error ! = null ) {
2019-06-10 17:48:28 +02:00
field . showError ( ) ;
return field . getFieldNameOriginal ( ) + " is not valid. Suggestion: " + error ;
}
2016-07-14 16:47:17 +02:00
}
2016-06-29 12:39:27 +02:00
}
2016-06-09 18:58:19 +02:00
2016-07-13 16:11:15 +02:00
return null ;
2016-06-29 12:39:27 +02:00
}
2016-06-09 18:58:19 +02:00
2016-06-29 12:39:27 +02:00
/ * *
* On continue show alert box and enable buttons
2022-06-14 12:28:03 +02:00
*
2016-06-29 12:39:27 +02:00
* @param text
* @param type
* /
2022-06-14 12:28:03 +02:00
private void alertOnContinue ( String text , AlertType type ) {
2016-06-09 18:58:19 +02:00
2016-06-29 12:39:27 +02:00
onContinueAlertBlock . setText ( text ) ;
onContinueAlertBlock . setType ( type ) ;
onContinueAlertBlock . setVisible ( true ) ;
continueButton . setEnabled ( true ) ;
resetButton . setEnabled ( true ) ;
2016-06-09 18:58:19 +02:00
2016-06-29 12:39:27 +02:00
// hide after some seconds
Timer t = new Timer ( ) {
2016-06-09 18:58:19 +02:00
2016-06-29 12:39:27 +02:00
@Override
public void run ( ) {
2016-06-09 18:58:19 +02:00
2016-06-29 12:39:27 +02:00
onContinueAlertBlock . setVisible ( false ) ;
2016-06-09 18:58:19 +02:00
2016-06-29 12:39:27 +02:00
}
} ;
2016-06-09 18:58:19 +02:00
2016-06-29 12:39:27 +02:00
t . schedule ( 4000 ) ;
}
2016-06-06 17:24:52 +02:00
2016-06-29 12:39:27 +02:00
/ * *
* On continue show alert box and enable buttons
2022-06-14 12:28:03 +02:00
*
2016-06-29 12:39:27 +02:00
* @param text
* @param type
* /
2022-06-14 12:28:03 +02:00
private void alertOnCreate ( String text , boolean showSpinner , AlertType type , boolean hideAfterAWhile ) {
onCreateAlertBlock . clear ( ) ;
try {
onCreateAlertBlock . remove ( iconSpinner ) ;
} catch ( Exception e ) {
}
if ( showSpinner ) {
onCreateAlertBlock . add ( iconSpinner ) ;
}
2016-06-06 17:24:52 +02:00
2016-06-29 12:39:27 +02:00
onCreateAlertBlock . setText ( text ) ;
onCreateAlertBlock . setType ( type ) ;
onCreateAlertBlock . setVisible ( true ) ;
createButton . setEnabled ( true ) ;
2016-09-12 17:58:50 +02:00
goBackButtonSecondStep . setEnabled ( true ) ;
2016-05-26 18:12:53 +02:00
2022-06-14 12:28:03 +02:00
if ( hideAfterAWhile ) {
2016-09-26 14:12:26 +02:00
// hide after some seconds
Timer t = new Timer ( ) {
2016-06-06 17:24:52 +02:00
2016-09-26 14:12:26 +02:00
@Override
public void run ( ) {
2016-06-06 17:24:52 +02:00
2016-09-26 14:12:26 +02:00
onCreateAlertBlock . setVisible ( false ) ;
2016-06-06 17:24:52 +02:00
2016-09-26 14:12:26 +02:00
}
} ;
2021-04-09 14:51:55 +02:00
t . schedule ( 15000 ) ;
2016-09-26 14:12:26 +02:00
}
2016-06-29 12:39:27 +02:00
}
2016-05-26 18:12:53 +02:00
2016-06-29 12:39:27 +02:00
/ * *
* Validate data
2022-06-14 12:28:03 +02:00
*
2016-06-29 12:39:27 +02:00
* @return true on success , false otherwise
* /
private String validateDataOnContinue ( ) {
2016-06-09 18:58:19 +02:00
2016-09-16 17:40:32 +02:00
// remove errors
productTitleGroup . setType ( ControlGroupType . NONE ) ;
maintainerControlGroup . setType ( ControlGroupType . NONE ) ;
versionControlGroup . setType ( ControlGroupType . NONE ) ;
2017-04-05 18:42:07 +02:00
metadataTypesControlGroup . setType ( ControlGroupType . NONE ) ;
2016-09-16 17:40:32 +02:00
organizationsGroup . setType ( ControlGroupType . NONE ) ;
2017-01-25 18:29:47 +01:00
tagsPanel . setGroupPanelType ( ControlGroupType . NONE ) ;
2016-06-09 18:58:19 +02:00
2016-10-03 16:56:32 +02:00
String title = titleTextBox . getText ( ) . trim ( ) ;
2022-06-14 12:28:03 +02:00
if ( title . isEmpty ( ) ) {
2016-09-16 17:40:32 +02:00
productTitleGroup . setType ( ControlGroupType . ERROR ) ;
2016-09-23 18:50:16 +02:00
return " Missing title " ;
2016-06-29 12:39:27 +02:00
}
2022-06-14 12:28:03 +02:00
if ( title . length ( ) < 2 ) {
2021-04-09 14:51:55 +02:00
productTitleGroup . setType ( ControlGroupType . ERROR ) ;
return " The field title is too short " ;
}
2016-06-27 12:36:45 +02:00
2018-11-20 12:29:41 +01:00
// better check for the title
2022-06-14 12:28:03 +02:00
// String[] splittedTitle = title.split(" ");
/ *
* No check , see # 20828 for ( String word : splittedTitle ) { String replaced =
* word . replaceAll ( REGEX_TITLE_PRODUCT_SUBWORD , " " ) ; if ( ! replaced . equals ( word ) ) {
* productTitleGroup . setType ( ControlGroupType . ERROR ) ; return
* " Please note not all characters are allowed for the title " ; } }
* /
2016-06-27 12:36:45 +02:00
2016-06-29 12:39:27 +02:00
// email reg expression
2016-10-03 16:56:32 +02:00
String maintainerMail = maintainerEmailTextbox . getText ( ) ;
2022-06-14 12:28:03 +02:00
if ( ! maintainerMail . isEmpty ( ) & & ! maintainerMail . matches ( REGEX_MAIL ) ) {
2016-09-16 17:40:32 +02:00
maintainerControlGroup . setType ( ControlGroupType . ERROR ) ;
2016-09-23 18:50:16 +02:00
return " Not valid maintainer email " ;
2016-06-09 18:58:19 +02:00
}
2016-07-07 16:52:10 +02:00
// check if version is a number
2022-06-14 12:28:03 +02:00
try {
2016-10-03 16:56:32 +02:00
int number = Integer . valueOf ( versionTextbox . getText ( ) . trim ( ) ) ;
2022-06-14 12:28:03 +02:00
if ( number < = 0 )
2016-09-23 18:50:16 +02:00
throw new Exception ( ) ;
2022-06-14 12:28:03 +02:00
} catch ( Exception e ) {
2016-09-16 17:40:32 +02:00
versionControlGroup . setType ( ControlGroupType . ERROR ) ;
2016-09-23 18:50:16 +02:00
return " Version must be a natural number greater than zero " ;
2016-07-07 16:52:10 +02:00
}
2022-06-14 12:28:03 +02:00
// check if metadata profile is different from none and its mandatory fields
// have been fulfilled
if ( checkSelectedMetaDataProfile ( ) ) {
2017-04-05 18:42:07 +02:00
metadataTypesControlGroup . setType ( ControlGroupType . ERROR ) ;
return " You must select a Type different frome none " ;
2016-06-09 18:58:19 +02:00
}
2016-06-13 17:40:19 +02:00
2022-06-14 12:28:03 +02:00
if ( organizationsListbox . getSelectedItemText ( ) = = null ) {
2016-09-16 17:40:32 +02:00
organizationsGroup . setType ( ControlGroupType . ERROR ) ;
2016-09-23 18:50:16 +02:00
return " You must select an organization in which you want to publish " ;
2016-06-29 12:39:27 +02:00
}
2017-02-22 17:40:16 +01:00
2017-01-25 18:29:47 +01:00
// at least one tag..
2022-06-14 12:28:03 +02:00
if ( tagsPanel . getTags ( ) . isEmpty ( ) ) {
2017-01-25 18:29:47 +01:00
tagsPanel . setGroupPanelType ( ControlGroupType . ERROR ) ;
2017-02-15 17:10:22 +01:00
return " Please add at least one meaningful tag for the item " ;
2017-01-25 18:29:47 +01:00
}
2016-06-09 18:58:19 +02:00
2016-09-23 18:50:16 +02:00
return null ;
2016-06-29 12:39:27 +02:00
}
2016-05-26 18:12:53 +02:00
2016-06-29 12:39:27 +02:00
/ * *
2022-06-14 12:28:03 +02:00
* Checks if a metadata profile has been chosen and its fields have been
* fulfilled
*
2016-06-29 12:39:27 +02:00
* @return
* /
private boolean checkSelectedMetaDataProfile ( ) {
2022-06-14 12:28:03 +02:00
return metadataTypeListbox . getSelectedItemText ( ) . equals ( NONE_PROFILE )
& & metadataTypeListbox . getItemCount ( ) ! = 1 ;
2016-06-29 12:39:27 +02:00
}
2016-06-09 18:58:19 +02:00
2016-06-29 12:39:27 +02:00
@UiHandler ( " resetButton " )
2022-06-14 12:28:03 +02:00
void resetFormEvent ( ClickEvent e ) {
2016-05-26 18:12:53 +02:00
2016-06-29 12:39:27 +02:00
// reset main fields
titleTextBox . setText ( " " ) ;
descriptionTextarea . setText ( " " ) ;
versionTextbox . setText ( " " ) ;
maintainerTextbox . setText ( " " ) ;
maintainerEmailTextbox . setText ( " " ) ;
2016-10-03 17:27:12 +02:00
tagsPanel . removeTags ( ) ;
2016-05-26 18:12:53 +02:00
2016-12-27 21:13:53 +01:00
// unselect all groups
2022-06-14 12:28:03 +02:00
for ( int i = 0 ; i < groupsListbox . getItemCount ( ) ; i + + )
2016-12-27 21:13:53 +01:00
groupsListbox . setItemSelected ( i , false ) ;
2016-06-29 12:39:27 +02:00
// delete custom fields
for ( CustomFieldEntry customField : customFieldEntriesList ) {
customField . removeFromParent ( ) ;
}
customFieldEntriesList . clear ( ) ;
}
2016-05-27 19:08:03 +02:00
2016-06-29 12:39:27 +02:00
/ * *
2022-06-14 12:28:03 +02:00
* Disable dataset editable fields once the dataset has been successfully
* created .
2016-06-29 12:39:27 +02:00
* /
protected void disableDatasetFields ( ) {
2016-06-08 18:31:54 +02:00
2016-06-29 12:39:27 +02:00
titleTextBox . setEnabled ( false ) ;
descriptionTextarea . setEnabled ( false ) ;
versionTextbox . setEnabled ( false ) ;
maintainerTextbox . setEnabled ( false ) ;
maintainerEmailTextbox . setEnabled ( false ) ;
visibilityListbox . setEnabled ( false ) ;
2016-10-03 17:27:12 +02:00
tagsPanel . freeze ( ) ;
2016-06-29 12:39:27 +02:00
licenseListbox . setEnabled ( false ) ;
organizationsListbox . setEnabled ( false ) ;
addCustomFieldButton . setEnabled ( false ) ;
2017-04-05 18:42:07 +02:00
metadataTypeListbox . setEnabled ( false ) ;
2016-11-17 14:08:22 +01:00
groupsListbox . setEnabled ( false ) ;
2016-10-04 14:58:26 +02:00
2022-06-14 12:28:03 +02:00
for ( CustomFieldEntry ce : customFieldEntriesList )
2016-10-04 14:58:26 +02:00
ce . freeze ( ) ;
2016-06-08 18:31:54 +02:00
2016-06-29 12:39:27 +02:00
// disable profile fields
2019-06-10 17:48:28 +02:00
for ( MetaDataField metaField : listOfMetadataFields ) {
for ( MetaDataFieldSkeleton field : metaField . getListOfMetadataFields ( ) ) {
field . freeze ( ) ;
}
2022-06-14 12:28:03 +02:00
2016-06-09 18:58:19 +02:00
}
2016-07-07 16:52:10 +02:00
2016-07-06 18:41:43 +02:00
// freeze table of resources
2022-06-14 12:28:03 +02:00
if ( resourcesSelectByWEMainPanel ! = null )
2021-04-09 14:51:55 +02:00
resourcesSelectByWEMainPanel . freeze ( ) ;
2016-06-29 12:39:27 +02:00
}
2016-06-07 17:50:33 +02:00
2016-06-29 12:39:27 +02:00
/ * *
* change alert block behavior .
2022-06-14 12:28:03 +02:00
*
2016-06-29 12:39:27 +02:00
* @param textToShow
* @param type
* @param visible
* /
2022-06-14 12:28:03 +02:00
private void setAlertBlock ( String textToShow , AlertType type , boolean visible ) {
2016-05-27 19:08:03 +02:00
2016-06-29 12:39:27 +02:00
infoBlock . setText ( textToShow ) ;
infoBlock . setType ( type ) ;
infoBlock . setVisible ( visible ) ;
2016-05-27 19:08:03 +02:00
2016-06-29 12:39:27 +02:00
}
2016-05-27 19:08:03 +02:00
2016-07-13 16:11:15 +02:00
@UiHandler ( " licenseListbox " )
2022-06-14 12:28:03 +02:00
void onSelectedLicenseChange ( ChangeEvent c ) {
2016-07-13 16:11:15 +02:00
showLicenseUrl ( ) ;
2017-04-25 15:41:27 +02:00
2016-07-13 16:11:15 +02:00
}
/ * *
* The body of the onSelectedLicenseChange
* /
2022-06-14 12:28:03 +02:00
private void showLicenseUrl ( ) {
2016-07-13 16:11:15 +02:00
String selectedLicense = licenseListbox . getSelectedItemText ( ) ;
2017-04-25 15:41:27 +02:00
int index = - 1 ;
2022-06-14 12:28:03 +02:00
if ( ( index = licenseBean . indexOf ( new LicenseBean ( selectedLicense , null ) ) ) > = 0 ) {
2017-04-25 15:41:27 +02:00
LicenseBean foundLicense = licenseBean . get ( index ) ;
licenseUrlAnchor . setText ( foundLicense . getUrl ( ) ) ;
licenseUrlAnchor . setHref ( foundLicense . getUrl ( ) ) ;
licenseUrlAnchor . setVisible ( true ) ;
unavailableUrl . setVisible ( false ) ;
2022-06-14 12:28:03 +02:00
} else {
2017-04-25 15:41:27 +02:00
licenseUrlAnchor . setVisible ( false ) ;
unavailableUrl . setVisible ( true ) ;
2016-07-13 16:11:15 +02:00
}
}
2016-11-17 14:08:22 +01:00
/ * *
* Hide the groups that are already listed in the profiles page
2022-06-14 12:28:03 +02:00
*
2016-11-17 14:08:22 +01:00
* @param profiles
* /
private void hideGroupsAlreadyInProfile ( List < MetaDataProfileBean > profiles ) {
List < String > groupsToHide = new ArrayList < String > ( ) ;
2022-06-14 12:28:03 +02:00
for ( MetaDataProfileBean profile : profiles )
2017-04-25 15:41:27 +02:00
groupsToHide . add ( profile . getType ( ) ) ;
2016-11-17 14:08:22 +01:00
SelectElement se = groupsListbox . getElement ( ) . cast ( ) ;
2016-12-26 22:07:05 +01:00
int hiddenElements = 0 ;
2016-11-17 14:08:22 +01:00
for ( int i = 0 ; i < groupsListbox . getItemCount ( ) ; i + + ) {
2022-06-14 12:28:03 +02:00
if ( groupsToHide . contains ( groupsListbox . getItemText ( i ) ) ) {
2016-11-17 14:08:22 +01:00
se . getOptions ( ) . getItem ( i ) . getStyle ( ) . setProperty ( " display " , " none " ) ;
2016-12-26 22:07:05 +01:00
hiddenElements + + ;
2016-11-17 14:08:22 +01:00
}
}
2022-06-14 12:28:03 +02:00
if ( hiddenElements = = groupsListbox . getItemCount ( ) )
2016-12-26 22:07:05 +01:00
groupsControlGroup . setVisible ( false ) ;
else
groupsControlGroup . setVisible ( true ) ;
2016-11-17 14:08:22 +01:00
}
2017-02-22 17:40:16 +01:00
/ * *
* Check if resource ( s ) are missing
2022-06-14 12:28:03 +02:00
*
2017-02-22 17:40:16 +01:00
* @return
* /
2022-06-14 12:28:03 +02:00
private boolean hideManageResources ( ) {
2017-02-22 17:40:16 +01:00
2022-06-14 12:28:03 +02:00
return receivedBean . getResourceRoot ( ) = = null | | receivedBean . getResourceRoot ( ) . isFolder ( )
& & ( receivedBean . getResourceRoot ( ) . getChildrenSize ( ) = = null
| | receivedBean . getResourceRoot ( ) . getChildrenSize ( ) = = 0 ) ;
2017-02-22 17:40:16 +01:00
}
2017-04-25 15:41:27 +02:00
}