From 380cfb92feaf92209323e8671ae26fb5342c77d5 Mon Sep 17 00:00:00 2001 From: Sonia Zorba Date: Fri, 18 Mar 2016 17:22:51 +0100 Subject: [PATCH] Small improvements --- .../webapp/SchemaSelectionBean.java | 24 ++++++++++++++++-- .../webapp/TapSchemaEditingBean.java | 2 +- .../src/main/webapp/resources/css/style.css | 25 ++++++++++++++++++- .../webapp/resources/js/edit-tapschema.js | 11 ++++++++ .../src/main/webapp/schemaSelection.xhtml | 6 ++--- .../src/main/webapp/tapSchemaEditing.xhtml | 12 ++++++--- .../datalayer/TapSchemaHandler.java | 11 +++++--- 7 files changed, 77 insertions(+), 14 deletions(-) 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 e072fac..2d94e3f 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 379f2b7..cf3b2af 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 d4419d4..8373e63 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 cfda5da..a612f01 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 830f5f7..da3eff0 100644 --- a/TapSchemaManager/src/main/webapp/schemaSelection.xhtml +++ b/TapSchemaManager/src/main/webapp/schemaSelection.xhtml @@ -60,9 +60,7 @@
Name: - - - +
@@ -86,7 +84,7 @@
- + Close session diff --git a/TapSchemaManager/src/main/webapp/tapSchemaEditing.xhtml b/TapSchemaManager/src/main/webapp/tapSchemaEditing.xhtml index 9531b7d..213082f 100644 --- a/TapSchemaManager/src/main/webapp/tapSchemaEditing.xhtml +++ b/TapSchemaManager/src/main/webapp/tapSchemaEditing.xhtml @@ -282,7 +282,7 @@
- + #{tapSchemaEditing.tapSchema.selectedColumn.ucd} @@ -385,9 +385,9 @@
- + - +
@@ -490,5 +490,11 @@
+ +
+
+ +
+
\ No newline at end of file diff --git a/TapSchemaManagerDL/src/main/java/it/inaf/oats/ia2/tapschemamanager/datalayer/TapSchemaHandler.java b/TapSchemaManagerDL/src/main/java/it/inaf/oats/ia2/tapschemamanager/datalayer/TapSchemaHandler.java index 4ceb16e..0a20495 100644 --- a/TapSchemaManagerDL/src/main/java/it/inaf/oats/ia2/tapschemamanager/datalayer/TapSchemaHandler.java +++ b/TapSchemaManagerDL/src/main/java/it/inaf/oats/ia2/tapschemamanager/datalayer/TapSchemaHandler.java @@ -1,5 +1,6 @@ package it.inaf.oats.ia2.tapschemamanager.datalayer; +import java.io.Closeable; import java.io.Serializable; import java.sql.Connection; import java.sql.SQLException; @@ -66,10 +67,13 @@ class ColumnsInfo implements Serializable { } /** - * + * This class manage load of TAP_SCHEMA entities and other database schemas informations. + * IMPORTANT: If you use this class inside another object remember to call the + * close method to release the occupied resources. + * * @author Sonia Zorba */ -public class TapSchemaHandler implements Serializable { +public class TapSchemaHandler implements Serializable, Closeable { private static final long serialVersionUID = 1193743698810532785L; @@ -366,7 +370,8 @@ public class TapSchemaHandler implements Serializable { } } - public void onDestroy() { + @Override + public void close() { EntityManagerFactory efFactory = entityManager.getEntityManagerFactory(); entityManager.close(); efFactory.close(); -- GitLab