diff --git a/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/gui/AbstractApplicationConfigurationManager.java b/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/gui/AbstractApplicationConfigurationManager.java index 72edce72598f13997cd943c58db89e54aaf2ec2e..5e848cabfb3e9b90b62ec4bbcba69fe9bcfc3da0 100644 --- a/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/gui/AbstractApplicationConfigurationManager.java +++ b/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/gui/AbstractApplicationConfigurationManager.java @@ -14,8 +14,6 @@ import javax.ejb.Remove; * * @author Cédric Eoche-Duval / KEREVAL Rennes IHE development Project * @version 1.0 - 2015, October 23th - * @class AbstractApplicationConfigurationManager.java - * @package net.ihe.gazelle.proxy.admin.gui */ public abstract class AbstractApplicationConfigurationManager { @@ -33,6 +31,15 @@ public abstract class AbstractApplicationConfigurationManager { private String ipLoginAdmin; private Boolean jmsCommunicationEnabled; + protected static String getApplicationProperty(String inPropertyKey) { + String value = ApplicationConfiguration.getValueOfVariable(inPropertyKey); + if (value == null) { + AbstractApplicationConfigurationManager.log.error( + "Variable '" + inPropertyKey + "' is missing in 'app_configuration' table."); + } + return value; + } + @Remove @Destroy public void destroy() { @@ -52,15 +59,6 @@ public abstract class AbstractApplicationConfigurationManager { ipLoginAdmin = null; } - protected static String getApplicationProperty(String inPropertyKey) { - String value = ApplicationConfiguration.getValueOfVariable(inPropertyKey); - if (value == null) { - AbstractApplicationConfigurationManager.log.error( - "Variable '" + inPropertyKey + "' is missing in 'app_configuration' table."); - } - return value; - } - public String getReleaseNoteUrl() { if (releaseNoteUrl == null) { releaseNoteUrl = getApplicationProperty("application_release_notes_url"); @@ -101,7 +99,7 @@ public abstract class AbstractApplicationConfigurationManager { * Returns true if the logged in user has role "admin_role" or if the * application works without cas * - * @return + * @return true if the logged in user has role "admin_role" or if the application works without cas */ public boolean isUserAllowedAsAdmin() { return Identity.instance().isLoggedIn() && Identity.instance().hasRole("admin_role"); diff --git a/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/gui/ApplicationConfigurationManager.java b/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/gui/ApplicationConfigurationManager.java index 22256534002e910079e1a107b029442281de9cc0..f2b824ffc4d19ea325d83912bc73474c11336d63 100644 --- a/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/gui/ApplicationConfigurationManager.java +++ b/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/gui/ApplicationConfigurationManager.java @@ -35,9 +35,6 @@ import java.io.Serializable; * * @author Anne-Gaëlle Bergé / INRIA Rennes IHE development Project * @version 2.0 - 2015, October 23th, (by Cédric Eoche-Duval) - * @class ApplicationConfigurationManager.java - * @package net.ihe.gazelle.simulator.common.action - * @see > Anne-Gaelle.Berge@inria.fr - http://www.ihe-europe.org */ @Name("applicationConfigurationManager") @@ -58,6 +55,10 @@ public class ApplicationConfigurationManager extends AbstractApplicationConfigur private String casUrl; private String dcmDumpPath; + public static ApplicationConfigurationManager instance() { + return (ApplicationConfigurationManager) Component.getInstance("applicationConfigurationManager"); + } + @Remove @Destroy public void destroy() { @@ -72,10 +73,6 @@ public class ApplicationConfigurationManager extends AbstractApplicationConfigur casUrl = null; } - public static ApplicationConfigurationManager instance() { - return (ApplicationConfigurationManager) Component.getInstance("applicationConfigurationManager"); - } - public String getProxyIpAddresses() { if (proxyIpAddresses == null) { proxyIpAddresses = getApplicationProperty("proxy_ip_addresses"); diff --git a/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/model/ApplicationConfiguration.java b/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/model/ApplicationConfiguration.java index 813524c0413d83c2f543445c98849ceadf106b78..877933bf963cf8f3943ef5926919bf3f356c3690 100644 --- a/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/model/ApplicationConfiguration.java +++ b/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/model/ApplicationConfiguration.java @@ -1,29 +1,15 @@ package net.ihe.gazelle.proxy.admin.model; -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EntityManager; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.SequenceGenerator; -import javax.persistence.Table; - import net.ihe.gazelle.hql.HQLQueryBuilder; - -import javax.validation.constraints.NotNull; - import org.jboss.seam.Component; import org.jboss.seam.annotations.Name; -import org.jboss.seam.security.Identity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * @author Abderrazek Boufahja > INRIA Rennes IHE development Project - */ +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + @Entity @Name("applicationConfiguration") @Table(name = "app_configuration", schema = "public") @@ -70,6 +56,45 @@ public class ApplicationConfiguration implements Serializable { // getters and setters // ////////////////////////////////////////////////////////////////////// + public static String getValueOfVariable(String variable) { + EntityManager entityManager = (EntityManager) Component.getInstance("entityManager"); + return getValueOfVariable(variable, entityManager); + } + + public static String getValueOfVariable(String variable, EntityManager entityManager) { + ApplicationConfigurationQuery query = new ApplicationConfigurationQuery( + new HQLQueryBuilder<ApplicationConfiguration>(entityManager, ApplicationConfiguration.class)); + query.variable().eq(variable); + ApplicationConfiguration conf = query.getUniqueResult(); + if (conf == null) { + return null; + } else { + return conf.getValue(); + } + } + + public static ApplicationConfiguration getApplicationConfigurationByVariable(String variable) { + ApplicationConfigurationQuery query = new ApplicationConfigurationQuery(); + query.variable().eq(variable); + return query.getUniqueResult(); + } + + /** + * @param variable : string + * @return true only if the value of the variable fixed to "true" + */ + public static Boolean getBooleanValue(String variable) { + String val = getValueOfVariable(variable); + if (val == null) { + return false; + } + try { + return Boolean.valueOf(val); + } catch (Exception e) { + return false; + } + } + public Integer getId() { return id; } @@ -78,6 +103,9 @@ public class ApplicationConfiguration implements Serializable { this.id = id; } + // hashcode and equals + // ////////////////////////////////////////////////////////////////////// + public String getVariable() { return variable; } @@ -86,6 +114,9 @@ public class ApplicationConfiguration implements Serializable { this.variable = variable; } + // methods + // /////////////////////////////////////////////////////////////////////////////////// + public String getValue() { return value; } @@ -94,9 +125,6 @@ public class ApplicationConfiguration implements Serializable { this.value = value; } - // hashcode and equals - // ////////////////////////////////////////////////////////////////////// - public int hashCode() { final int prime = 31; int result = 1; @@ -133,46 +161,4 @@ public class ApplicationConfiguration implements Serializable { return true; } - // methods - // /////////////////////////////////////////////////////////////////////////////////// - - public static String getValueOfVariable(String variable) { - EntityManager entityManager = (EntityManager) Component.getInstance("entityManager"); - return getValueOfVariable(variable, entityManager); - } - - public static String getValueOfVariable(String variable, EntityManager entityManager) { - ApplicationConfigurationQuery query = new ApplicationConfigurationQuery( - new HQLQueryBuilder<ApplicationConfiguration>(entityManager, ApplicationConfiguration.class)); - query.variable().eq(variable); - ApplicationConfiguration conf = query.getUniqueResult(); - if (conf == null) { - return null; - } else { - return conf.getValue(); - } - } - - public static ApplicationConfiguration getApplicationConfigurationByVariable(String variable) { - ApplicationConfigurationQuery query = new ApplicationConfigurationQuery(); - query.variable().eq(variable); - return query.getUniqueResult(); - } - - /** - * @param variable - * @return true only if the value of the variable fixed to "true" - */ - public static Boolean getBooleanValue(String variable) { - String val = getValueOfVariable(variable); - if (val == null) { - return false; - } - try { - return Boolean.valueOf(val); - } catch (Exception e) { - return false; - } - } - } diff --git a/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/model/Home.java b/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/model/Home.java index 6d41a5c2b716546229cad0a0b6dcac526a6b7d58..d321c1b1d5a7d5431c6eaf7ffff459363185051c 100644 --- a/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/model/Home.java +++ b/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/admin/model/Home.java @@ -1,28 +1,16 @@ package net.ihe.gazelle.proxy.admin.model; -import java.io.Serializable; -import java.util.List; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EntityManager; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Lob; -import javax.persistence.SequenceGenerator; -import javax.persistence.Table; -import javax.persistence.UniqueConstraint; - import net.ihe.gazelle.hql.HQLQueryBuilder; - -import javax.validation.constraints.NotNull; - import org.hibernate.annotations.Type; import org.jboss.seam.Component; import org.jboss.seam.annotations.Name; import org.jboss.seam.web.Locale; +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + @Entity @Name("home") @Table(name = "cmn_home", schema = "public", uniqueConstraints = @UniqueConstraint(columnNames = "iso3_language")) @@ -59,6 +47,26 @@ public class Home implements Serializable { this.iso3Language = iso3Language; } + /** + * @return home + */ + public static Home getHomeForSelectedLanguage() { + String language = Locale.instance().getISO3Language(); + if (language != null && !language.isEmpty()) { + EntityManager entityManager = (EntityManager) Component.getInstance("entityManager"); + HQLQueryBuilder<Home> queryBuilder = new HQLQueryBuilder<Home>(entityManager, Home.class); + queryBuilder.addEq("iso3Language", language); + List<Home> homes = queryBuilder.getList(); + if (homes != null && !homes.isEmpty()) { + return homes.get(0); + } else { + return new Home(language); + } + } else { + return null; + } + } + public Integer getId() { return id; } @@ -92,7 +100,7 @@ public class Home implements Serializable { } /** - * @return + * @return home */ public Home save() { EntityManager entityManager = (EntityManager) Component.getInstance("entityManager"); @@ -100,24 +108,4 @@ public class Home implements Serializable { entityManager.flush(); return home; } - - /** - * @return - */ - public static Home getHomeForSelectedLanguage() { - String language = Locale.instance().getISO3Language(); - if (language != null && !language.isEmpty()) { - EntityManager entityManager = (EntityManager) Component.getInstance("entityManager"); - HQLQueryBuilder<Home> queryBuilder = new HQLQueryBuilder<Home>(entityManager, Home.class); - queryBuilder.addEq("iso3Language", language); - List<Home> homes = queryBuilder.getList(); - if (homes != null && !homes.isEmpty()) { - return homes.get(0); - } else { - return new Home(language); - } - } else { - return null; - } - } }