diff --git a/TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/SchemaSelectionBean.java b/TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/SchemaSelectionBean.java index e072facb93a180f0d3bacd8f626e502a1b3255c5..2d94e3fdc736667ca1679ad9ed5bc26b7a96f9e7 100644 --- a/TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/SchemaSelectionBean.java +++ b/TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/SchemaSelectionBean.java @@ -11,7 +11,10 @@ import java.util.List; import javax.annotation.PostConstruct; import javax.enterprise.context.Conversation; import javax.enterprise.context.ConversationScoped; +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; +import javax.faces.validator.ValidatorException; import javax.inject.Inject; import javax.inject.Named; @@ -22,7 +25,7 @@ import javax.inject.Named; @Named("schemaSelection") @ConversationScoped public class SchemaSelectionBean implements Serializable { - + private static final long serialVersionUID = -5745720427701334323L; @Inject @@ -51,7 +54,7 @@ public class SchemaSelectionBean implements Serializable { exposedSchemas = ""; } - public void onPageLoad() { + public void onPageLoad() { FacesContext fc = FacesContext.getCurrentInstance(); final boolean ajaxRequest = fc.getPartialViewContext().isAjaxRequest(); final boolean validationFailed = fc.isValidationFailed(); @@ -192,4 +195,21 @@ public class SchemaSelectionBean implements Serializable { conversation.end(); return "index.xhtml?faces-redirect=true"; } + + public void validateTapSchemaName(FacesContext context, UIComponent inputComponent, Object value) { + String textValue = (String) value; + + String validatorMessage = null; + if (textValue == null || textValue.isEmpty()) { + validatorMessage = "TAP_SCHEMA name is required"; + } else if (!textValue.matches("^[a-zA-Z0-9_[-]]*$")) { + validatorMessage = "TAP_SCHEMA name has to be a valid table name"; + } else if (allSchemas.contains(textValue)) { + validatorMessage = "Database already contains a schema with this name. Please choose another name"; + } + + if (validatorMessage != null) { + throw new ValidatorException(new FacesMessage(validatorMessage)); + } + } } diff --git a/TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/TapSchemaEditingBean.java b/TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/TapSchemaEditingBean.java index 379f2b78c6454e63634683ccfbb3641e54ee59aa..cf3b2afde3f6c0751ce6dc08b6f6fef864fb42db 100644 --- a/TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/TapSchemaEditingBean.java +++ b/TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/TapSchemaEditingBean.java @@ -210,6 +210,6 @@ public class TapSchemaEditingBean implements Serializable { @PreDestroy public void onDestroy() { - tapSchema.getTapSchemaHandler().onDestroy(); + tapSchema.getTapSchemaHandler().close(); } } diff --git a/TapSchemaManager/src/main/webapp/resources/css/style.css b/TapSchemaManager/src/main/webapp/resources/css/style.css index d4419d4fbb1360592aa09e76bdb407b7ee09b161..8373e63e6d91c4c5f53aedfb8f3f8de70c403aee 100644 --- a/TapSchemaManager/src/main/webapp/resources/css/style.css +++ b/TapSchemaManager/src/main/webapp/resources/css/style.css @@ -161,4 +161,27 @@ input[type="checkbox"].changed { #columnUcd { cursor:pointer; -} \ No newline at end of file +} + +.loading { + position: fixed; + top: 0; + bottom: 0; + right: 0; + left: 0; + background-color: rgba(0, 0, 0, 0.33); + z-index: 10000; + text-align: center; +} + +.loading .icon-wrapper { + display: table; + width: 100%; + height: 100%; +} + +.loading .glyphicon { + display: table-cell; + vertical-align: middle; + font-size: 45px; +} diff --git a/TapSchemaManager/src/main/webapp/resources/js/edit-tapschema.js b/TapSchemaManager/src/main/webapp/resources/js/edit-tapschema.js index cfda5da23ca5b987df07a190b2c8aba2ca746ec1..a612f014d2ed77a70adb32bd9c917328432c10a2 100644 --- a/TapSchemaManager/src/main/webapp/resources/js/edit-tapschema.js +++ b/TapSchemaManager/src/main/webapp/resources/js/edit-tapschema.js @@ -106,6 +106,7 @@ }, openSearchUCDModal: function (event) { if (event.status === 'success') { + $('.loading').addClass('hide'); $('#searchUCDModal').modal('show'); } }, @@ -118,6 +119,16 @@ if (event.status === 'success' && $(event.responseXML).find('error').length === 0) { $('#updateSuccessModal').modal('show'); } + }, + // Show loading div + showLoading: function () { + $('.loading').removeClass('hide'); + }, + // Hide loading div + hideLoading: function (event) { + if (event.status === 'success') { + $('.loading').addClass('hide'); + } } }; diff --git a/TapSchemaManager/src/main/webapp/schemaSelection.xhtml b/TapSchemaManager/src/main/webapp/schemaSelection.xhtml index 830f5f71cf13728a330939b5220169e15496daa8..da3eff0ea24f8b852d283236680d00fdf18f57c9 100644 --- a/TapSchemaManager/src/main/webapp/schemaSelection.xhtml +++ b/TapSchemaManager/src/main/webapp/schemaSelection.xhtml @@ -60,9 +60,7 @@