CCM NG: Classes for the new database based configuration system (not tested yet)

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3772 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2015-12-16 15:15:38 +00:00
parent 5b1121e264
commit fd010fef1a
24 changed files with 1610 additions and 514 deletions

View File

@ -20,6 +20,7 @@ package org.libreccm.configuration;
import static org.libreccm.core.CoreConstants.*; import static org.libreccm.core.CoreConstants.*;
import org.hibernate.validator.constraints.NotBlank;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import java.io.Serializable; import java.io.Serializable;
@ -28,38 +29,55 @@ import java.util.Objects;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.Pattern;
/** /**
* * Abstract base class for all settings.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @param <T> * @param <T> The value type of the setting.
*/ */
@Entity @Entity
@Table(name = "CONFIGURATION_ENTRIES", schema = DB_SCHEMA) @Table(name = "SETTINGS", schema = DB_SCHEMA)
public abstract class AbstractConfigurationEntry<T> public abstract class AbstractSetting<T>
extends CcmObject implements Serializable { extends CcmObject implements Serializable {
private static final long serialVersionUID = -839223659103128135L; private static final long serialVersionUID = -839223659103128135L;
@Column(name = "comment", length = 2048) /**
private String comment; * The name of the setting. The string must be a valid URL fragment.
*/
@Column(name = "name", nullable = false, length = 512)
@NotBlank
@Pattern(regexp = "[\\w-.]*")
private String name;
public String getComment() { public String getName() {
return comment; return name;
} }
public void setComment(final String comment) { public void setName(final String name) {
this.comment = comment; this.name = name;
} }
/**
* Getter for the value of the setting.
*
* @return The value of the setting.
*/
public abstract T getValue(); public abstract T getValue();
/**
* Setter for the value of the setting.
*
* @param value The new value of the setting.
*/
public abstract void setValue(T value); public abstract void setValue(T value);
@Override @Override
public int hashCode() { public int hashCode() {
int hash = super.hashCode(); int hash = super.hashCode();
hash = 47 * hash + Objects.hashCode(comment); hash = 47 * hash + Objects.hashCode(name);
return hash; return hash;
} }
@ -73,28 +91,28 @@ public abstract class AbstractConfigurationEntry<T>
return false; return false;
} }
if (!(obj instanceof AbstractConfigurationEntry)) { if (!(obj instanceof AbstractSetting)) {
return false; return false;
} }
final AbstractConfigurationEntry<?> other final AbstractSetting<?> other
= (AbstractConfigurationEntry) obj; = (AbstractSetting) obj;
if (!other.canEqual(this)) { if (!other.canEqual(this)) {
return false; return false;
} }
return Objects.equals(comment, other.getComment()); return Objects.equals(name, other.getName());
} }
@Override @Override
public boolean canEqual(final Object obj) { public boolean canEqual(final Object obj) {
return obj instanceof AbstractConfigurationEntry; return obj instanceof AbstractSetting;
} }
@Override @Override
public String toString(final String data) { public String toString(final String data) {
return super.toString(String.format(", comment = \"%s\"%s", return super.toString(String.format(", name = \"%s\"%s",
comment, name,
data)); data));
} }

View File

@ -0,0 +1,133 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.configuration;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.web.CcmApplication;
import java.util.Objects;
/**
* Base class for application instance specific configurations.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ApplicationConfiguration {
private static final Logger LOGGER = LogManager.getLogger(
ApplicationConfiguration.class);
/**
* The primary URL identifying the application instance for which this
* configuration stores settings.
*/
@Setting
private String applicationInstance;
/**
* The fully qualified name of the application class.
*/
@Setting
private String applicationClass;
public String getApplicationInstance() {
return applicationInstance;
}
public void setApplicationInstance(final String applicationInstance) {
this.applicationInstance = applicationInstance;
}
public Class<CcmApplication> getApplicationClass() {
try {
@SuppressWarnings("unchecked")
final Class<CcmApplication> clazz = (Class<CcmApplication>) Class
.forName(applicationClass);
return clazz;
} catch (ClassNotFoundException ex) {
LOGGER.warn(String.format(
"Class '%s' for ApplicationConfiguration was not found.",
applicationClass),
ex);
return null;
}
}
public void setApplicationClass(final Class<CcmApplication> clazz) {
applicationClass = clazz.getName();
}
@Override
public int hashCode() {
int hash = 7;
hash = 79 * hash + Objects.hashCode(applicationInstance);
hash = 79 * hash + Objects.hashCode(applicationClass);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ApplicationConfiguration)) {
return false;
}
final ApplicationConfiguration other = (ApplicationConfiguration) obj;
if (!other.canEqual(this)) {
return false;
}
if (!Objects.equals(applicationInstance, other.getApplicationInstance())) {
return false;
}
if (Objects.equals(applicationClass, other.getApplicationClass())) {
} else {
return false;
}
return true;
}
public boolean canEqual(final Object obj) {
return obj instanceof ApplicationConfiguration;
}
@Override
public final String toString() {
return toString("");
}
public String toString(final String data) {
return String.format("%s{ "
+ "applicationInstance = \"%s\", "
+ "applicationClass = \"%s\"%s"
+ " }",
super.toString(),
applicationInstance,
applicationClass,
data);
}
}

View File

@ -29,24 +29,27 @@ import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
* Setting storing a {@link BigDecimal} value. If the precision of
* {@code BigDecimal} is not required {@link LongSetting} or
* {@link DoubleSetting} should be used.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Entity @Entity
@Table(name = "CONF_ENTRIES_BIG_DECIMAL", schema = DB_SCHEMA) @Table(name = "SETTINGS_BIG_DECIMAL", schema = DB_SCHEMA)
public class BigDecimalConfigurationEntry public class BigDecimalSetting
extends AbstractConfigurationEntry<BigDecimal> implements Serializable { extends AbstractSetting<BigDecimal> implements Serializable {
private static final long serialVersionUID = 1869044294174385532L; private static final long serialVersionUID = 1869044294174385532L;
@Column(name = "entry_value") @Column(name = "entry_value")
private BigDecimal value; private BigDecimal value;
@Override @Override
public BigDecimal getValue() { public BigDecimal getValue() {
return value; return value;
} }
@Override @Override
public void setValue(final BigDecimal value) { public void setValue(final BigDecimal value) {
this.value = value; this.value = value;
@ -64,28 +67,28 @@ public class BigDecimalConfigurationEntry
if (!super.equals(obj)) { if (!super.equals(obj)) {
return false; return false;
} }
if (obj == null) { if (obj == null) {
return false; return false;
} }
if (!(obj instanceof BigDecimalConfigurationEntry)) { if (!(obj instanceof BigDecimalSetting)) {
return false; return false;
} }
final BigDecimalConfigurationEntry other final BigDecimalSetting other
= (BigDecimalConfigurationEntry) obj; = (BigDecimalSetting) obj;
if (!other.canEqual(this)) { if (!other.canEqual(this)) {
return false; return false;
} }
return Objects.equals(value, other.getValue()); return Objects.equals(value, other.getValue());
} }
@Override @Override
public boolean canEqual(final Object obj) { public boolean canEqual(final Object obj) {
return obj instanceof BigDecimalConfigurationEntry; return obj instanceof BigDecimalSetting;
} }
@Override @Override
public String toString(final String data) { public String toString(final String data) {
return super.toString(String.format(", value = %s%s", return super.toString(String.format(", value = %s%s",
@ -93,5 +96,4 @@ public class BigDecimalConfigurationEntry
data)); data));
} }
} }

View File

@ -27,13 +27,14 @@ import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
* * Setting for storing a boolean value.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Entity @Entity
@Table(name = "CONF_ENTRIES_BOOLEAN", schema = DB_SCHEMA) @Table(name = "SETTINGS_BOOLEAN", schema = DB_SCHEMA)
public class BooleanConfigurationEntry public class BooleanSetting
extends AbstractConfigurationEntry<Boolean> implements Serializable { extends AbstractSetting<Boolean> implements Serializable {
private static final long serialVersionUID = -1724350134756734938L; private static final long serialVersionUID = -1724350134756734938L;
@ -74,10 +75,10 @@ public class BooleanConfigurationEntry
if (obj == null) { if (obj == null) {
return false; return false;
} }
if (!(obj instanceof BooleanConfigurationEntry)) { if (!(obj instanceof BooleanSetting)) {
return false; return false;
} }
final BooleanConfigurationEntry other = (BooleanConfigurationEntry) obj; final BooleanSetting other = (BooleanSetting) obj;
if (!other.canEqual(this)) { if (!other.canEqual(this)) {
return false; return false;
} }
@ -87,7 +88,7 @@ public class BooleanConfigurationEntry
@Override @Override
public boolean canEqual(final Object obj) { public boolean canEqual(final Object obj) {
return obj instanceof BooleanConfigurationEntry; return obj instanceof BooleanSetting;
} }
@Override @Override

View File

@ -40,7 +40,7 @@ public @interface Configuration {
* *
* @return Name of the configuration. * @return Name of the configuration.
*/ */
String name() default ""; //String name() default "";
/** /**
* Points to the {@link ResourceBundle} containing the descriptions * Points to the {@link ResourceBundle} containing the descriptions

View File

@ -19,7 +19,8 @@
package org.libreccm.configuration; package org.libreccm.configuration;
/** /**
* * Some constants for the configuration system.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
public class ConfigurationConstants { public class ConfigurationConstants {

View File

@ -0,0 +1,148 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.configuration;
import java.util.Collections;
import java.util.Locale;
import java.util.NavigableMap;
import java.util.Objects;
import java.util.ResourceBundle;
import java.util.TreeMap;
/**
* Describes a configuration. Useful for generating user
* interfaces.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public final class ConfigurationInfo {
/**
* The fully qualified name of the configuration.
*/
private String name;
/**
* The resource bundle containing the description of the configuration and
* its settings.
*/
private String descBundle;
/**
* The key for the description of the configuration in the resource bundle.
*/
private String descKey;
/**
* A navigable map containing a {@link SettingInfo} object for each setting
* of the configuration.
*/
private NavigableMap<String, SettingInfo> settings;
public ConfigurationInfo() {
this.settings = new TreeMap<>();
}
public String getName() {
return name;
}
protected void setName(final String name) {
this.name = name;
}
public String getDescBundle() {
return descBundle;
}
protected void setDescBundle(final String descBundle) {
this.descBundle = descBundle;
}
public ResourceBundle getDescriptionBundle(final Locale locale) {
return ResourceBundle.getBundle(descBundle);
}
public String getDescKey() {
return descKey;
}
protected void setDescKey(final String descKey) {
this.descKey = descKey;
}
public String getDescription(final Locale locale) {
return getDescriptionBundle(locale).getString(descKey);
}
public NavigableMap<String, SettingInfo> getSettings() {
return Collections.unmodifiableNavigableMap(settings);
}
protected void setSettings(final NavigableMap<String, SettingInfo> settings) {
this.settings = settings;
}
protected void addSetting(final SettingInfo info) {
settings.put(info.getName(), info);
}
@Override
public int hashCode() {
int hash = 3;
hash = 59 * hash + Objects.hashCode(name);
hash = 59 * hash + Objects.hashCode(descBundle);
hash = 59 * hash + Objects.hashCode(descKey);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (obj instanceof ConfigurationInfo) {
return false;
}
final ConfigurationInfo other = (ConfigurationInfo) obj;
if (!Objects.equals(name, other.getName())) {
return false;
}
if (!Objects.equals(descBundle, other.getDescBundle())) {
return false;
}
return Objects.equals(descKey, other.getDescKey());
}
@Override
public String toString() {
return String.format("%s{ "
+ "name = \"%s\", "
+ "descBundle = \"%s\", "
+ "descKey = \"%s\""
+ " }",
name,
descBundle,
descKey);
}
}

View File

@ -21,41 +21,591 @@ package org.libreccm.configuration;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import org.libreccm.categorization.CategoryManager; import org.libreccm.categorization.CategoryManager;
import org.libreccm.categorization.Domain; import org.libreccm.categorization.Domain;
import org.libreccm.categorization.DomainManager;
import org.libreccm.categorization.DomainRepository; import org.libreccm.categorization.DomainRepository;
import static org.libreccm.configuration.ConfigurationConstants.*; import static org.libreccm.configuration.ConfigurationConstants.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.categorization.Categorization;
import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryRepository;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.web.CcmApplication;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
/** /**
* Maps between configuration classes and the values stored in the registry.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@RequestScoped @RequestScoped
public class ConfigurationManager { public class ConfigurationManager {
private static final Logger LOGGER = LogManager.getLogger(
ConfigurationManager.class);
@Inject @Inject
private CategoryManager categoryManager; private CategoryManager categoryManager;
@Inject
private CategoryRepository categoryRepository;
@Inject @Inject
private DomainRepository domainRepository; private DomainRepository domainRepository;
@Inject
private DomainManager domainManager;
@Inject @Inject
private EntityManager entityManager; private EntityManager entityManager;
/**
* Load all settings of the provided configuration class.
public <T> AbstractConfigurationEntry<T> getEntry(final String name, *
final Class<T> clazz) { * @param <T> Type of the configuration class.
final String[] tokens = name.split("."); * @param confClass The configuration class.
*
final Domain registry = domainRepository.findByDomainKey(REGISTRY_DOMAIN); * @return An instance of the configuration class with all settings set to
* the values stored in the registry.
throw new UnsupportedOperationException(); */
public <T> T findConfiguration(final Class<T> confClass) {
if (confClass == null) {
throw new IllegalArgumentException("confClass can't be null");
}
if (confClass.getAnnotation(Configuration.class) == null) {
throw new IllegalArgumentException(String.format(
"Provided class \"%s\" is not annotated with \"%s\".",
confClass.getName(),
Configuration.class.getName()));
}
final String confName = confClass.getName();
return findConfiguration(confName, confClass);
} }
/**
* Saves a configuration by writing the values of all setting fields to the
* registry.
*
* @param configuration The configuration to save. The class of the provided
* object must be annotation with
* {@link Configuration}.
*
* @throws IllegalArgumentException If the {@code configuration} parameter
* is {@code null} or if the class of the
* provided object is not annotation with
* {@link Configuration}.
*/
public void saveConfiguration(final Object configuration) {
if (configuration == null) {
throw new IllegalArgumentException("Configuration can't be null");
}
if (configuration.getClass().getAnnotation(Configuration.class) == null) {
throw new IllegalArgumentException(String.format(
"The class \"%s\" of the provided object is not annotated "
+ "with \"%s\".",
configuration.getClass().getName(),
Configuration.class.getName()));
}
final Field[] fields = configuration.getClass().getDeclaredFields();
for (final Field field : fields) {
field.setAccessible(true);
try {
setSettingValue(configuration,
getSettingName(field),
field.getType(),
field.get(configuration));
} catch (IllegalAccessException ex) {
LOGGER.error(String.format(
"Failed to write setting value for setting \"%s\" "
+ "of configuration \"%s\"",
getSettingName(field),
configuration.getClass().getName()),
ex);
throw new IllegalStateException(String.format(
"Failed to write setting value for setting \"%s\" "
+ "of configuration \"%s\"",
getSettingName(field),
configuration.getClass().getName()),
ex);
}
}
}
/**
* Finds an application instance specific configuration and loads it values
* from the registry.
*
* @param <T> The type of the configuration.
* @param confClass The configuration class.
* @param instance The application instance for which the settings are
* loaded.
*
* @return The configuration for the provided application instance.
*/
public <T extends ApplicationConfiguration> T findConfiguration(
final Class<T> confClass, final CcmApplication instance) {
if (confClass == null) {
throw new IllegalArgumentException("confClass can't be null");
}
if (instance == null) {
throw new IllegalArgumentException("instance can't be null");
}
if (confClass.getAnnotation(Configuration.class) == null) {
throw new IllegalArgumentException(String.format(
"Provided class \"%s\" is not annotated with \"%s\".",
confClass.getName(),
Configuration.class.getName()));
}
final String confName = String.format("%s.%s",
confClass.getName(),
instance.getPrimaryUrl());
return findConfiguration(confName, confClass);
}
/**
* Saves a application instance configuration.
*
* @param configuration The configuration to save.
* @param instance The application instance of which the configuration
* stores the settings.
*/
public void saveConfiguration(final ApplicationConfiguration configuration,
final CcmApplication instance) {
if (configuration == null) {
throw new IllegalArgumentException("Configuration can't be null");
}
if (configuration.getClass().getAnnotation(Configuration.class) == null) {
throw new IllegalArgumentException(String.format(
"The class \"%s\" of the provided object is not annotated "
+ "with \"%s\".",
configuration.getClass().getName(),
Configuration.class.getName()));
}
if (instance == null) {
throw new IllegalArgumentException("Instance can't be null");
}
final Field[] fields = configuration.getClass().getDeclaredFields();
for (final Field field : fields) {
field.setAccessible(true);
try {
setSettingValue(configuration,
instance,
getSettingName(field),
field.getType(),
field.get(configuration));
} catch (IllegalAccessException ex) {
LOGGER.error(String.format(
"Failed to write setting value for setting \"%s\" "
+ "of configuration \"%s\"",
getSettingName(field),
configuration.getClass().getName()),
ex);
throw new IllegalStateException(String.format(
"Failed to write setting value for setting \"%s\" "
+ "of configuration \"%s\"",
getSettingName(field),
configuration.getClass().getName()),
ex);
}
}
}
/**
* Get the {@link ConfigurationInfo} for a configuration.
*
* @param configuration The configuration for which the info is generated.
*
* @return a {@link ConfigurationInfo} instance describing the provided
* configuration.
*/
public ConfigurationInfo getConfigurationInfo(final Class<?> configuration) {
if (configuration == null) {
throw new IllegalArgumentException("Configuration can't be null");
}
if (configuration.getAnnotation(Configuration.class) == null) {
throw new IllegalArgumentException(String.format(
"The class \"%s\" of the provided object is not annotated "
+ "with \"%s\".",
configuration.getClass().getName(),
Configuration.class.getName()));
}
final Configuration annotation = configuration.getAnnotation(
Configuration.class);
final ConfigurationInfo confInfo = new ConfigurationInfo();
confInfo.setName(configuration.getClass().getName());
confInfo.setDescBundle(annotation.descBundle());
confInfo.setDescKey(annotation.descKey());
final Field[] fields = configuration.getDeclaredFields();
for (final Field field : fields) {
field.setAccessible(true);
if (field.getAnnotation(Setting.class) != null) {
confInfo.addSetting(getSettingInfo(configuration,
field.getName()));
}
}
return confInfo;
}
/**
* Create a {@link SettingInfo} instance for a setting.
*
* @param configuration The configuration class to which the settings
* belongs.
* @param name The name of the setting for which the
* {@link SettingInfo} is generated.
*
* @return The {@link SettingInfo} for the provided configuration class.
*/
public SettingInfo getSettingInfo(final Class<?> configuration,
final String name) {
if (configuration == null) {
throw new IllegalArgumentException("Configuration can't be null");
}
if (configuration.getAnnotation(Configuration.class) == null) {
throw new IllegalArgumentException(String.format(
"The class \"%s\" of the provided object is not annotated "
+ "with \"%s\".",
configuration.getClass().getName(),
Configuration.class.getName()));
}
final Configuration confAnnotation = configuration.getAnnotation(
Configuration.class);
final String descBundle = confAnnotation.descBundle();
final Field field;
try {
field = configuration.getDeclaredField(name);
} catch (SecurityException | NoSuchFieldException ex) {
LOGGER.warn(String.format(
"Failed to generate SettingInfo for field \"%s\" of "
+ "configuration \"%s\". Ignoring field.",
configuration.getClass().getName(),
name),
ex);
return null;
}
if (field.getAnnotation(Setting.class) == null) {
return null;
}
final Setting settingAnnotation = field.getAnnotation(Setting.class);
final SettingInfo settingInfo = new SettingInfo();
if (settingAnnotation.name() == null
|| settingAnnotation.name().isEmpty()) {
settingInfo.setName(field.getName());
} else {
settingInfo.setName(settingAnnotation.name());
}
settingInfo.setValueType(field.getType().getName());
try {
final Object conf = configuration.newInstance();
settingInfo.setDefaultValue(field.get(conf).toString());
} catch (InstantiationException | IllegalAccessException ex) {
LOGGER.warn(String.format("Failed to create instance of \"%s\" to "
+ "get default values.",
configuration.getName()),
ex);
}
settingInfo.setConfigurationClass(configuration.getName());
settingInfo.setDescBundle(descBundle);
settingInfo.setDescKey(settingAnnotation.descKey());
return settingInfo;
}
/**
* A low level method for finding a setting in the registry.
*
* @param <T> Type of the value of the setting
* @param name The fully qualified name of the setting.
* @param clazz The class of the setting.
*
* @return The requested setting if it exists in the registry, {@code null}
* otherwise.
*/
public <T> AbstractSetting<T> findSetting(final String name,
final Class<T> clazz) {
final String[] tokens = name.split(".");
final String[] categoryTokens = Arrays.copyOfRange(tokens,
0,
tokens.length - 1);
final String categoryPath = String.join(".", categoryTokens);
final Domain registry = domainRepository
.findByDomainKey(REGISTRY_DOMAIN);
final Category category = categoryRepository.findByPath(registry,
categoryPath);
if (category == null) {
return null;
}
final Optional<Categorization> result = category
.getObjects()
.stream()
.filter((Categorization c)
-> c.getCategorizedObject() instanceof AbstractSetting)
.filter((Categorization c)
-> ((AbstractSetting<?>) c.getCategorizedObject())
.getName()
.equals(tokens[tokens.length - 1]))
.findFirst();
if (result.isPresent()) {
final CcmObject object = result.get().getCategorizedObject();
final AbstractSetting<?> entry = (AbstractSetting<?>) object;
if (clazz.isInstance(entry.getValue())) {
@SuppressWarnings("unchecked")
final AbstractSetting<T> resultEntry
= (AbstractSetting<T>) entry;
return resultEntry;
} else {
return null;
}
} else {
return null;
}
}
/**
* Low level method of saving a setting.
*
* @param setting The setting to save.
*/
public void saveSetting(final AbstractSetting<?> setting) {
if (setting.getObjectId() == 0) {
entityManager.persist(setting);
} else {
entityManager.merge(setting);
}
}
/**
* Helper method for generating the name of a setting. This method does not
* check if the provided field is annotated with {@link Setting}. The caller
* is responsible to do that. Passing a field without the {@code Setting}
* annotation to this method will result in a {@code NullPointerException}.
*
* @param field The setting field.
*
* @return The name of the field or if the {@link Setting} annotation of the
* field has a name value, the value of that field.
*/
private String getSettingName(final Field field) {
final Setting annotation = field.getAnnotation(Setting.class);
if (annotation.name() == null || annotation.name().isEmpty()) {
return field.getName();
} else {
return annotation.name();
}
}
/**
* Create a setting instance of a specific value type.
*
* @param <T> Type variable.
* @param valueType The type of the value of the setting to create.
*
* @return An setting instance of the provided value type.
*
* @throws IllegalArgumentException If there is not setting type for the
* provided value type.
*/
@SuppressWarnings("unchecked")
private <T> AbstractSetting<T> createSettingForValueType(
final Class<T> valueType) {
final String valueTypeName = valueType.getName();
if (BigDecimal.class.getName().equals(valueTypeName)) {
return (AbstractSetting<T>) new BigDecimalSetting();
} else if (Boolean.class.getName().equals(valueTypeName)) {
return (AbstractSetting<T>) new BooleanSetting();
} else if (Double.class.getName().equals(valueTypeName)) {
return (AbstractSetting<T>) new DoubleSetting();
} else if (List.class.getName().equals(valueTypeName)) {
return (AbstractSetting<T>) new EnumSetting();
} else if (LocalizedString.class.getName().equals(valueTypeName)) {
return (AbstractSetting<T>) new LocalizedStringSetting();
} else if (LongSetting.class.getName().equals(valueTypeName)) {
return (AbstractSetting<T>) new LongSetting();
} else if (String.class.getName().equals(valueTypeName)) {
return (AbstractSetting<T>) new StringSetting();
} else {
throw new IllegalArgumentException(String.format(
"No setting type for value type \"s\".", valueTypeName));
}
}
/**
* Sets a value on a setting in the registry.
*
* @param <T> The value type of the setting.
* @param configuration The configuration to which the settings belongs.
* @param settingName The name of the setting.
* @param valueType The type of the value of the setting.
* @param value The value to set.
*/
private <T> void setSettingValue(final Object configuration,
final String settingName,
final Class<T> valueType,
final Object value) {
final String settingPath = String.format(
"%s.%s",
configuration.getClass().getName(),
settingName);
AbstractSetting<T> setting = findSetting(settingPath, valueType);
if (setting == null) {
setting = createSettingForValueType(valueType);
setting.setName(settingName);
final Domain registry = domainRepository
.findByDomainKey(REGISTRY_DOMAIN);
final Category category = categoryRepository
.findByPath(registry, configuration.getClass().getName());
categoryManager.addObjectToCategory(setting, category);
}
@SuppressWarnings("unchecked")
final T settingValue = (T) value;
setting.setValue(settingValue);
entityManager.merge(setting);
}
/**
* Sets the value of a setting of application instance configuration.
*
* @param <T> The value type of the setting.
* @param configuration The configuration to which the settings belongs.
* @param instance The application instance to which
* @param settingName The name of the setting.
* @param valueType The type of the value of the setting.
* @param value The value to set.
*/
private <T> void setSettingValue(final Object configuration,
final CcmApplication instance,
final String settingName,
final Class<T> valueType,
final Object value) {
final String settingPath = String.format(
"%s.%s.%s",
configuration.getClass().getName(),
instance.getPrimaryUrl(),
settingName);
AbstractSetting<T> setting = findSetting(settingPath, valueType);
if (setting == null) {
setting = createSettingForValueType(valueType);
setting.setName(settingName);
final Domain registry = domainRepository
.findByDomainKey(REGISTRY_DOMAIN);
final Category category = categoryRepository
.findByPath(registry, configuration.getClass().getName());
categoryManager.addObjectToCategory(setting, category);
}
@SuppressWarnings("unchecked")
final T settingValue = (T) value;
setting.setValue(settingValue);
entityManager.merge(setting);
}
/**
* Helper method for loading a configuration from the registry.
*
* @param <T> The type of the configuration.
* @param confName The fully qualified name of the configuration in the
* registry. For normal configuration this is the fully
* qualified name of the configuration class. For
* application instance configurations this is the fully
* qualified name of the configuration class joined with
* the primary URL of the application instance, separated
* with a dot.
* @param confClass The configuration class.
*
* @return An instance of the configuration class with all setting fields
* set to the values stored in the registry.
*/
private <T> T findConfiguration(final String confName,
final Class<T> confClass) {
final Domain registry = domainRepository
.findByDomainKey(REGISTRY_DOMAIN);
final Category category = categoryRepository.findByPath(registry,
confName);
if (category == null) {
return null;
}
final T conf;
try {
conf = confClass.newInstance();
} catch (InstantiationException | IllegalAccessException ex) {
LOGGER.warn(String.format(
"Failed to instantiate configuration \"%s\".",
confClass.getName()),
ex);
return null;
}
final Field[] fields = confClass.getDeclaredFields();
for (final Field field : fields) {
field.setAccessible(true);
if (field.getAnnotation(Setting.class) == null) {
continue;
}
final String settingPath = String.format("%s.%s",
confClass.getName(),
getSettingName(field));
final Class<?> settingType = field.getType();
final AbstractSetting<?> setting = findSetting(settingPath,
settingType);
if (setting != null) {
try {
field.set(conf, setting.getValue());
} catch (IllegalAccessException ex) {
LOGGER.warn(String.format(
"Failed to set value of configuration class \"%s\". "
+ "Ignoring.",
confClass.getName()),
ex);
}
}
}
return conf;
}
} }

View File

@ -27,13 +27,14 @@ import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
* * A setting for storing a double value.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Entity @Entity
@Table(name = "CONF_ENTRIES_DOUBLE", schema = DB_SCHEMA) @Table(name = "SETTINGS_DOUBLE", schema = DB_SCHEMA)
public class DoubleConfigurationEntry public class DoubleSetting
extends AbstractConfigurationEntry<Double> implements Serializable { extends AbstractSetting<Double> implements Serializable {
private static final long serialVersionUID = -6944518527865528160L; private static final long serialVersionUID = -6944518527865528160L;
@ -66,10 +67,10 @@ public class DoubleConfigurationEntry
if (obj == null) { if (obj == null) {
return false; return false;
} }
if (!(obj instanceof DoubleConfigurationEntry)) { if (!(obj instanceof DoubleSetting)) {
return false; return false;
} }
final DoubleConfigurationEntry other = (DoubleConfigurationEntry) obj; final DoubleSetting other = (DoubleSetting) obj;
if (!other.canEqual(this)) { if (!other.canEqual(this)) {
return false; return false;
} }
@ -80,7 +81,7 @@ public class DoubleConfigurationEntry
@Override @Override
public boolean canEqual(final Object obj) { public boolean canEqual(final Object obj) {
return obj instanceof DoubleConfigurationEntry; return obj instanceof DoubleSetting;
} }
@Override @Override

View File

@ -32,13 +32,15 @@ import javax.persistence.JoinTable;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
* * A setting class for storing a list a strings. This can be used to generate
* enums which can be configured by the administrator.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Entity @Entity
@Table(name = "CONF_ENTRIES_ENUM", schema = DB_SCHEMA) @Table(name = "SETTINGS_ENUM", schema = DB_SCHEMA)
public class EnumConfigurationEntry public class EnumSetting
extends AbstractConfigurationEntry<Set<String>> implements Serializable { extends AbstractSetting<Set<String>> implements Serializable {
private static final long serialVersionUID = 8506016944203102813L; private static final long serialVersionUID = 8506016944203102813L;
@ -86,10 +88,10 @@ public class EnumConfigurationEntry
return false; return false;
} }
if (!(obj instanceof EnumConfigurationEntry)) { if (!(obj instanceof EnumSetting)) {
return false; return false;
} }
final EnumConfigurationEntry other = (EnumConfigurationEntry) obj; final EnumSetting other = (EnumSetting) obj;
if (!other.canEqual(this)) { if (!other.canEqual(this)) {
return false; return false;
} }
@ -99,7 +101,7 @@ public class EnumConfigurationEntry
@Override @Override
public boolean canEqual(final Object obj) { public boolean canEqual(final Object obj) {
return obj instanceof EnumConfigurationEntry; return obj instanceof EnumSetting;
} }
@Override @Override

View File

@ -33,13 +33,16 @@ import javax.persistence.JoinTable;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
* * A setting which stores a {@link LocalizedString} . This can be used for
* storing values for text in the user interface which should be customisable by
* the administrator.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Entity @Entity
@Table(name = "CONF_ENTRIES_L10N_STRING", schema = DB_SCHEMA) @Table(name = "SETTINGS_L10N_STRING", schema = DB_SCHEMA)
public class LocalizedStringConfigurationEntry public class LocalizedStringSetting
extends AbstractConfigurationEntry<LocalizedString> implements Serializable { extends AbstractSetting<LocalizedString> implements Serializable {
private static final long serialVersionUID = -5854552013878000164L; private static final long serialVersionUID = -5854552013878000164L;
@ -79,11 +82,11 @@ public class LocalizedStringConfigurationEntry
return false; return false;
} }
if (!(obj instanceof LocalizedStringConfigurationEntry)) { if (!(obj instanceof LocalizedStringSetting)) {
return false; return false;
} }
final LocalizedStringConfigurationEntry other final LocalizedStringSetting other
= (LocalizedStringConfigurationEntry) obj; = (LocalizedStringSetting) obj;
if (!other.canEqual(this)) { if (!other.canEqual(this)) {
return false; return false;
} }
@ -93,7 +96,7 @@ public class LocalizedStringConfigurationEntry
@Override @Override
public boolean canEqual(final Object obj) { public boolean canEqual(final Object obj) {
return obj instanceof LocalizedStringConfigurationEntry; return obj instanceof LocalizedStringSetting;
} }
@Override @Override

View File

@ -27,13 +27,14 @@ import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
* * Setting for storing a long value.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Entity @Entity
@Table(name = "CONF_ENTRIES_INTEGER", schema = DB_SCHEMA) @Table(name = "SETTINGS_LONG", schema = DB_SCHEMA)
public class LongConfigurationEntry public class LongSetting
extends AbstractConfigurationEntry<Long> implements Serializable{ extends AbstractSetting<Long> implements Serializable{
private static final long serialVersionUID = 818622372461020368L; private static final long serialVersionUID = 818622372461020368L;
@ -66,11 +67,11 @@ public class LongConfigurationEntry
if (obj == null) { if (obj == null) {
return false; return false;
} }
if (!(obj instanceof LongConfigurationEntry)) { if (!(obj instanceof LongSetting)) {
return false; return false;
} }
final LongConfigurationEntry other final LongSetting other
= (LongConfigurationEntry) obj; = (LongSetting) obj;
if (!other.canEqual(this)) { if (!other.canEqual(this)) {
return false; return false;
} }
@ -80,7 +81,7 @@ public class LongConfigurationEntry
@Override @Override
public boolean canEqual(final Object obj) { public boolean canEqual(final Object obj) {
return obj instanceof LongConfigurationEntry; return obj instanceof LongSetting;
} }
@Override @Override

View File

@ -0,0 +1,179 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.configuration;
import java.util.Locale;
import java.util.Objects;
import java.util.ResourceBundle;
/**
* Describes a setting in a configuration class. This class is not designed for
* extension.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public final class SettingInfo {
/**
* The fully qualified name of the setting.
*/
private String name;
/**
* The type of the setting.
*/
private String valueType;
/**
* The default value of the setting.
*/
private String defaultValue;
/**
* The configuration class to which the setting belongs.
*/
private String configurationClass;
/**
* ResourceBundle with the description of the setting.
*/
private String descBundle;
/**
* Key of the description of the setting.
*/
private String descKey;
public String getName() {
return name;
}
protected void setName(final String name) {
this.name = name;
}
public String getValueType() {
return valueType;
}
protected void setValueType(final String valueType) {
this.valueType = valueType;
}
public String getDefaultValue() {
return defaultValue;
}
protected void setDefaultValue(final String defaultValue) {
this.defaultValue = defaultValue;
}
public String getConfigurationClass() {
return configurationClass;
}
protected void setConfigurationClass(final String configurationClass) {
this.configurationClass = configurationClass;
}
public String getDescBundle() {
return descBundle;
}
protected void setDescBundle(final String descBundle) {
this.descBundle = descBundle;
}
public ResourceBundle getDescriptionBundle(final Locale locale) {
return ResourceBundle.getBundle(descBundle, locale);
}
public String getDescKey() {
return descKey;
}
protected void setDescKey(final String descKey) {
this.descKey = descKey;
}
public String getDescription(final Locale locale) {
return getDescriptionBundle(locale).getString(descKey);
}
@Override
public int hashCode() {
int hash = 7;
hash = 79 * hash + Objects.hashCode(name);
hash = 79 * hash + Objects.hashCode(valueType);
hash = 79 * hash + Objects.hashCode(defaultValue);
hash = 79 * hash + Objects.hashCode(configurationClass);
hash = 79 * hash + Objects.hashCode(descBundle);
hash = 79 * hash + Objects.hashCode(descKey);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (obj instanceof SettingInfo) {
return false;
}
final SettingInfo other = (SettingInfo) obj;
if (!Objects.equals(name, other.getName())) {
return false;
}
if (!Objects.equals(valueType, other.getValueType())) {
return false;
}
if (!Objects.equals(defaultValue, other.getDefaultValue())) {
return false;
}
if (!Objects.equals(configurationClass, other.getConfigurationClass())) {
return false;
}
if (!Objects.equals(descBundle, other.getDescBundle())) {
return false;
}
return Objects.equals(descKey, other.getDescKey());
}
@Override
public String toString() {
return String.format("%s{ "
+ "name = \"%s\", "
+ "valueType = \"%s\", "
+ "defaultValue = \"%s\", "
+ "configurationClass = \"%s\", "
+ "descBundle = \"%s\","
+ "descKey = \"%s\""
+ " }",
super.toString(),
name,
valueType,
defaultValue,
configurationClass,
descBundle,
descKey);
}
}

View File

@ -28,13 +28,14 @@ import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
* * A setting for storing a string value.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Entity @Entity
@Table(name = "CONF_ENTRIES_STRING", schema = DB_SCHEMA) @Table(name = "SETTINGS_STRING", schema = DB_SCHEMA)
public class StringConfigurationEntry public class StringSetting
extends AbstractConfigurationEntry<String> implements Serializable { extends AbstractSetting<String> implements Serializable {
private static final long serialVersionUID = -8564570962027541731L; private static final long serialVersionUID = -8564570962027541731L;
@ -68,10 +69,10 @@ public class StringConfigurationEntry
return false; return false;
} }
if (!(obj instanceof StringConfigurationEntry)) { if (!(obj instanceof StringSetting)) {
return false; return false;
} }
final StringConfigurationEntry other = (StringConfigurationEntry) obj; final StringSetting other = (StringSetting) obj;
if (!other.canEqual(this)) { if (!other.canEqual(this)) {
return false; return false;
} }
@ -81,7 +82,7 @@ public class StringConfigurationEntry
@Override @Override
public boolean canEqual(final Object obj) { public boolean canEqual(final Object obj) {
return obj instanceof StringConfigurationEntry; return obj instanceof StringSetting;
} }
@Override @Override

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
/**
* This package contains classes which provide a database driven configuration
* system. Prior to version 7.0.0 the configuration was stored in properties
* files and managed using some classes and XML files.
*
* The configuration classes are still used, but they do work differently.
*
* A configuration class is a simple Java bean with several fields which are
* supported by the configuration system, getters and setters for easy
* access and which is annotated with the
* <a href="Configuration.html"><code>Configuration</code></a>
* annotation. The settings fields must annotated with the
* <a href="Setting.html"><code>Setting</code></a>
* annotation.
*
* The supported value types are:
* <ul>
* <li><code>BigDecimal</code></li>
* <li><code>Boolean</code></li>
* <li><code>Double</code></li>
* <li>List of Strings (<code>EnumSetting</code></li>
* <li><code>LocalizedString</code></li>
* <li><code>Long</code></li>
* <li><code>String</code></li>
* </ul>
*
* The
* <a href="ConfigurationManager.html"><code>ConfigurationManager</code></a>
* provides methods for loading and saving the configurations.
*
* For most use cases it should not be necessary to use the classes which
* extends
* <a href="AbstractSetting.html"><code>AbstractSetting</code></a>
* outside of this package. But there are may use cases where this is necessary.
* Therefore these classes are publicly visible.
*/
package org.libreccm.configuration;

View File

@ -36,11 +36,9 @@ import java.util.Objects;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;

View File

@ -81,46 +81,6 @@
primary key (ROLE_ID) primary key (ROLE_ID)
); );
create table CCM_CORE.CONFIGURATION_ENTRIES (
comment varchar(2048),
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_BIG_DECIMAL (
entry_value decimal(19,2),
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_BOOLEAN (
entry_value boolean,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_DOUBLE (
entry_value double,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_ENUM (
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_INTEGER (
entry_value bigint,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_L10N_STRING (
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES ( create table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES (
ENTRY_ID bigint not null, ENTRY_ID bigint not null,
LOCALIZED_VALUE clob, LOCALIZED_VALUE clob,
@ -128,12 +88,6 @@
primary key (ENTRY_ID, LOCALE) primary key (ENTRY_ID, LOCALE)
); );
create table CCM_CORE.CONF_ENTRIES_STRING (
entry_value varchar(1024),
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.DIGESTS ( create table CCM_CORE.DIGESTS (
FREQUENCY integer, FREQUENCY integer,
HEADER varchar(4096) not null, HEADER varchar(4096) not null,
@ -518,6 +472,52 @@
primary key (MEMBERSHIP_ID) primary key (MEMBERSHIP_ID)
); );
create table CCM_CORE.SETTINGS (
name varchar(512) not null,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_BIG_DECIMAL (
entry_value decimal(19,2),
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_BOOLEAN (
entry_value boolean,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_DOUBLE (
entry_value double,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_ENUM (
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_L10N_STRING (
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_LONG (
entry_value bigint,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_STRING (
entry_value varchar(1024),
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.TASK_ASSIGNMENTS ( create table CCM_CORE.TASK_ASSIGNMENTS (
TASK_ASSIGNMENT_ID bigint not null, TASK_ASSIGNMENT_ID bigint not null,
ROLE_ID bigint, ROLE_ID bigint,
@ -678,50 +678,10 @@
foreign key (OBJECT_ID) foreign key (OBJECT_ID)
references CCM_CORE.CATEGORIES; references CCM_CORE.CATEGORIES;
alter table CCM_CORE.CONFIGURATION_ENTRIES
add constraint FK_8u6h7p0gs4ybf0ju240mggb73
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.CONF_ENTRIES_BIG_DECIMAL
add constraint FK_3tnub4je6c2bwi0c3p9m2n6d1
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_BOOLEAN
add constraint FK_d79uxyam5uhhmw3ijw3c14gk2
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_DOUBLE
add constraint FK_l5qxx6wfngl2hvnqaq77oin1s
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_ENUM
add constraint FK_blwwj2ht4wbg82meuuxf0t7kk
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_INTEGER
add constraint FK_reo0efdw6evf11viwlse1w27
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_L10N_STRING
add constraint FK_dbvyqoliuh0d7bl6ksng4abe
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES alter table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES
add constraint FK_ftb5yqeoli1m932yp3p8ho74g add constraint FK_ftb5yqeoli1m932yp3p8ho74g
foreign key (ENTRY_ID) foreign key (ENTRY_ID)
references CCM_CORE.CONF_ENTRIES_L10N_STRING; references CCM_CORE.SETTINGS_L10N_STRING;
alter table CCM_CORE.CONF_ENTRIES_STRING
add constraint FK_j31m640x2cn0xl5jcbik06708
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.DIGESTS alter table CCM_CORE.DIGESTS
add constraint FK_3xrcpufumqnh4ke4somt89rvh add constraint FK_3xrcpufumqnh4ke4somt89rvh
@ -756,7 +716,7 @@
alter table CCM_CORE.ENUM_CONFIGURATION_ENTRIES_VALUES alter table CCM_CORE.ENUM_CONFIGURATION_ENTRIES_VALUES
add constraint FK_ao3evxajxd8y4gy5a6e8ua49j add constraint FK_ao3evxajxd8y4gy5a6e8ua49j
foreign key (ENUM_ID) foreign key (ENUM_ID)
references CCM_CORE.CONF_ENTRIES_ENUM; references CCM_CORE.SETTINGS_ENUM;
alter table CCM_CORE.FORMBUILDER_COMPONENTS alter table CCM_CORE.FORMBUILDER_COMPONENTS
add constraint FK_72108sd6vsqt88g3fb4kl6o81 add constraint FK_72108sd6vsqt88g3fb4kl6o81
@ -1048,6 +1008,46 @@
foreign key (ROLE_ID) foreign key (ROLE_ID)
references CCM_CORE.CCM_ROLES; references CCM_CORE.CCM_ROLES;
alter table CCM_CORE.SETTINGS
add constraint FK_3k0t3in140j6wj6eq5olwjgu
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.SETTINGS_BIG_DECIMAL
add constraint FK_9mbdc1rjkm80edyuijnkwl6ak
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_BOOLEAN
add constraint FK_1mjjvpjxpwicyv8im6mumc7ug
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_DOUBLE
add constraint FK_kejnkuyk89tw59xg550kugwb5
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_ENUM
add constraint FK_fgrfc2qbl2f2t1l0ku8wo2e5r
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_L10N_STRING
add constraint FK_evnyfg9udprxmbginhc4o0is9
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_LONG
add constraint FK_2l4bw7pbq3koj81cjyoqpenjj
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_STRING
add constraint FK_naonte6jut7b842icvp9ahino
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.TASK_ASSIGNMENTS alter table CCM_CORE.TASK_ASSIGNMENTS
add constraint FK_klh64or0yq26c63181j1tps2o add constraint FK_klh64or0yq26c63181j1tps2o
foreign key (ROLE_ID) foreign key (ROLE_ID)

View File

@ -81,46 +81,6 @@
primary key (ROLE_ID) primary key (ROLE_ID)
); );
create table CCM_CORE.CONFIGURATION_ENTRIES (
comment varchar(2048),
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_BIG_DECIMAL (
entry_value numeric(19, 2),
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_BOOLEAN (
entry_value boolean,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_DOUBLE (
entry_value float8,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_ENUM (
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_INTEGER (
entry_value int8,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_L10N_STRING (
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES ( create table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES (
ENTRY_ID int8 not null, ENTRY_ID int8 not null,
LOCALIZED_VALUE text, LOCALIZED_VALUE text,
@ -128,12 +88,6 @@
primary key (ENTRY_ID, LOCALE) primary key (ENTRY_ID, LOCALE)
); );
create table CCM_CORE.CONF_ENTRIES_STRING (
entry_value varchar(1024),
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.DIGESTS ( create table CCM_CORE.DIGESTS (
FREQUENCY int4, FREQUENCY int4,
HEADER varchar(4096) not null, HEADER varchar(4096) not null,
@ -518,6 +472,52 @@
primary key (MEMBERSHIP_ID) primary key (MEMBERSHIP_ID)
); );
create table CCM_CORE.SETTINGS (
name varchar(512) not null,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_BIG_DECIMAL (
entry_value numeric(19, 2),
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_BOOLEAN (
entry_value boolean,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_DOUBLE (
entry_value float8,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_ENUM (
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_L10N_STRING (
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_LONG (
entry_value int8,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_STRING (
entry_value varchar(1024),
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.TASK_ASSIGNMENTS ( create table CCM_CORE.TASK_ASSIGNMENTS (
TASK_ASSIGNMENT_ID int8 not null, TASK_ASSIGNMENT_ID int8 not null,
ROLE_ID int8, ROLE_ID int8,
@ -678,50 +678,10 @@
foreign key (OBJECT_ID) foreign key (OBJECT_ID)
references CCM_CORE.CATEGORIES; references CCM_CORE.CATEGORIES;
alter table CCM_CORE.CONFIGURATION_ENTRIES
add constraint FK_8u6h7p0gs4ybf0ju240mggb73
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.CONF_ENTRIES_BIG_DECIMAL
add constraint FK_3tnub4je6c2bwi0c3p9m2n6d1
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_BOOLEAN
add constraint FK_d79uxyam5uhhmw3ijw3c14gk2
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_DOUBLE
add constraint FK_l5qxx6wfngl2hvnqaq77oin1s
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_ENUM
add constraint FK_blwwj2ht4wbg82meuuxf0t7kk
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_INTEGER
add constraint FK_reo0efdw6evf11viwlse1w27
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_L10N_STRING
add constraint FK_dbvyqoliuh0d7bl6ksng4abe
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES alter table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES
add constraint FK_ftb5yqeoli1m932yp3p8ho74g add constraint FK_ftb5yqeoli1m932yp3p8ho74g
foreign key (ENTRY_ID) foreign key (ENTRY_ID)
references CCM_CORE.CONF_ENTRIES_L10N_STRING; references CCM_CORE.SETTINGS_L10N_STRING;
alter table CCM_CORE.CONF_ENTRIES_STRING
add constraint FK_j31m640x2cn0xl5jcbik06708
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.DIGESTS alter table CCM_CORE.DIGESTS
add constraint FK_3xrcpufumqnh4ke4somt89rvh add constraint FK_3xrcpufumqnh4ke4somt89rvh
@ -756,7 +716,7 @@
alter table CCM_CORE.ENUM_CONFIGURATION_ENTRIES_VALUES alter table CCM_CORE.ENUM_CONFIGURATION_ENTRIES_VALUES
add constraint FK_ao3evxajxd8y4gy5a6e8ua49j add constraint FK_ao3evxajxd8y4gy5a6e8ua49j
foreign key (ENUM_ID) foreign key (ENUM_ID)
references CCM_CORE.CONF_ENTRIES_ENUM; references CCM_CORE.SETTINGS_ENUM;
alter table CCM_CORE.FORMBUILDER_COMPONENTS alter table CCM_CORE.FORMBUILDER_COMPONENTS
add constraint FK_72108sd6vsqt88g3fb4kl6o81 add constraint FK_72108sd6vsqt88g3fb4kl6o81
@ -1048,6 +1008,46 @@
foreign key (ROLE_ID) foreign key (ROLE_ID)
references CCM_CORE.CCM_ROLES; references CCM_CORE.CCM_ROLES;
alter table CCM_CORE.SETTINGS
add constraint FK_3k0t3in140j6wj6eq5olwjgu
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.SETTINGS_BIG_DECIMAL
add constraint FK_9mbdc1rjkm80edyuijnkwl6ak
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_BOOLEAN
add constraint FK_1mjjvpjxpwicyv8im6mumc7ug
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_DOUBLE
add constraint FK_kejnkuyk89tw59xg550kugwb5
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_ENUM
add constraint FK_fgrfc2qbl2f2t1l0ku8wo2e5r
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_L10N_STRING
add constraint FK_evnyfg9udprxmbginhc4o0is9
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_LONG
add constraint FK_2l4bw7pbq3koj81cjyoqpenjj
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_STRING
add constraint FK_naonte6jut7b842icvp9ahino
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.TASK_ASSIGNMENTS alter table CCM_CORE.TASK_ASSIGNMENTS
add constraint FK_klh64or0yq26c63181j1tps2o add constraint FK_klh64or0yq26c63181j1tps2o
foreign key (ROLE_ID) foreign key (ROLE_ID)

View File

@ -39,13 +39,13 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
@Parameterized.Parameters(name = "{0}") @Parameterized.Parameters(name = "{0}")
public static Collection<Class<?>> data() { public static Collection<Class<?>> data() {
return Arrays.asList(new Class<?>[]{ return Arrays.asList(new Class<?>[]{
BigDecimalConfigurationEntry.class, BigDecimalSetting.class,
BooleanConfigurationEntry.class, BooleanSetting.class,
DoubleConfigurationEntry.class, DoubleSetting.class,
EnumConfigurationEntry.class, EnumSetting.class,
LocalizedStringConfigurationEntry.class, LocalizedStringSetting.class,
LongConfigurationEntry.class, LongSetting.class,
StringConfigurationEntry.class StringSetting.class
}); });
} }

View File

@ -38,13 +38,13 @@ public class ToStringTest extends ToStringVerifier {
@Parameterized.Parameters(name = "{0}") @Parameterized.Parameters(name = "{0}")
public static Collection<Class<?>> data() { public static Collection<Class<?>> data() {
return Arrays.asList(new Class<?>[]{ return Arrays.asList(new Class<?>[]{
BigDecimalConfigurationEntry.class, BigDecimalSetting.class,
BooleanConfigurationEntry.class, BooleanSetting.class,
DoubleConfigurationEntry.class, DoubleSetting.class,
EnumConfigurationEntry.class, EnumSetting.class,
LocalizedStringConfigurationEntry.class, LocalizedStringSetting.class,
LongConfigurationEntry.class, LongSetting.class,
StringConfigurationEntry.class StringSetting.class
}); });
} }

View File

@ -5,7 +5,6 @@ DROP SEQUENCE IF EXISTS hibernate_sequence;
CREATE SCHEMA ccm_core; CREATE SCHEMA ccm_core;
create table CCM_CORE.APPLICATIONS ( create table CCM_CORE.APPLICATIONS (
APPLICATION_TYPE varchar(1024) not null, APPLICATION_TYPE varchar(1024) not null,
PRIMARY_URL varchar(1024) not null, PRIMARY_URL varchar(1024) not null,
@ -88,46 +87,6 @@ CREATE SCHEMA ccm_core;
primary key (ROLE_ID) primary key (ROLE_ID)
); );
create table CCM_CORE.CONFIGURATION_ENTRIES (
comment varchar(2048),
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_BIG_DECIMAL (
entry_value decimal(19,2),
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_BOOLEAN (
entry_value boolean,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_DOUBLE (
entry_value double,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_ENUM (
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_INTEGER (
entry_value bigint,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_L10N_STRING (
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES ( create table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES (
ENTRY_ID bigint not null, ENTRY_ID bigint not null,
LOCALIZED_VALUE clob, LOCALIZED_VALUE clob,
@ -135,12 +94,6 @@ CREATE SCHEMA ccm_core;
primary key (ENTRY_ID, LOCALE) primary key (ENTRY_ID, LOCALE)
); );
create table CCM_CORE.CONF_ENTRIES_STRING (
entry_value varchar(1024),
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.DIGESTS ( create table CCM_CORE.DIGESTS (
FREQUENCY integer, FREQUENCY integer,
HEADER varchar(4096) not null, HEADER varchar(4096) not null,
@ -525,6 +478,52 @@ CREATE SCHEMA ccm_core;
primary key (MEMBERSHIP_ID) primary key (MEMBERSHIP_ID)
); );
create table CCM_CORE.SETTINGS (
name varchar(512) not null,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_BIG_DECIMAL (
entry_value decimal(19,2),
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_BOOLEAN (
entry_value boolean,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_DOUBLE (
entry_value double,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_ENUM (
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_L10N_STRING (
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_LONG (
entry_value bigint,
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_STRING (
entry_value varchar(1024),
OBJECT_ID bigint not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.TASK_ASSIGNMENTS ( create table CCM_CORE.TASK_ASSIGNMENTS (
TASK_ASSIGNMENT_ID bigint not null, TASK_ASSIGNMENT_ID bigint not null,
ROLE_ID bigint, ROLE_ID bigint,
@ -685,50 +684,10 @@ CREATE SCHEMA ccm_core;
foreign key (OBJECT_ID) foreign key (OBJECT_ID)
references CCM_CORE.CATEGORIES; references CCM_CORE.CATEGORIES;
alter table CCM_CORE.CONFIGURATION_ENTRIES
add constraint FK_8u6h7p0gs4ybf0ju240mggb73
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.CONF_ENTRIES_BIG_DECIMAL
add constraint FK_3tnub4je6c2bwi0c3p9m2n6d1
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_BOOLEAN
add constraint FK_d79uxyam5uhhmw3ijw3c14gk2
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_DOUBLE
add constraint FK_l5qxx6wfngl2hvnqaq77oin1s
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_ENUM
add constraint FK_blwwj2ht4wbg82meuuxf0t7kk
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_INTEGER
add constraint FK_reo0efdw6evf11viwlse1w27
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_L10N_STRING
add constraint FK_dbvyqoliuh0d7bl6ksng4abe
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES alter table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES
add constraint FK_ftb5yqeoli1m932yp3p8ho74g add constraint FK_ftb5yqeoli1m932yp3p8ho74g
foreign key (ENTRY_ID) foreign key (ENTRY_ID)
references CCM_CORE.CONF_ENTRIES_L10N_STRING; references CCM_CORE.SETTINGS_L10N_STRING;
alter table CCM_CORE.CONF_ENTRIES_STRING
add constraint FK_j31m640x2cn0xl5jcbik06708
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.DIGESTS alter table CCM_CORE.DIGESTS
add constraint FK_3xrcpufumqnh4ke4somt89rvh add constraint FK_3xrcpufumqnh4ke4somt89rvh
@ -763,7 +722,7 @@ CREATE SCHEMA ccm_core;
alter table CCM_CORE.ENUM_CONFIGURATION_ENTRIES_VALUES alter table CCM_CORE.ENUM_CONFIGURATION_ENTRIES_VALUES
add constraint FK_ao3evxajxd8y4gy5a6e8ua49j add constraint FK_ao3evxajxd8y4gy5a6e8ua49j
foreign key (ENUM_ID) foreign key (ENUM_ID)
references CCM_CORE.CONF_ENTRIES_ENUM; references CCM_CORE.SETTINGS_ENUM;
alter table CCM_CORE.FORMBUILDER_COMPONENTS alter table CCM_CORE.FORMBUILDER_COMPONENTS
add constraint FK_72108sd6vsqt88g3fb4kl6o81 add constraint FK_72108sd6vsqt88g3fb4kl6o81
@ -1055,6 +1014,46 @@ CREATE SCHEMA ccm_core;
foreign key (ROLE_ID) foreign key (ROLE_ID)
references CCM_CORE.CCM_ROLES; references CCM_CORE.CCM_ROLES;
alter table CCM_CORE.SETTINGS
add constraint FK_3k0t3in140j6wj6eq5olwjgu
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.SETTINGS_BIG_DECIMAL
add constraint FK_9mbdc1rjkm80edyuijnkwl6ak
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_BOOLEAN
add constraint FK_1mjjvpjxpwicyv8im6mumc7ug
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_DOUBLE
add constraint FK_kejnkuyk89tw59xg550kugwb5
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_ENUM
add constraint FK_fgrfc2qbl2f2t1l0ku8wo2e5r
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_L10N_STRING
add constraint FK_evnyfg9udprxmbginhc4o0is9
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_LONG
add constraint FK_2l4bw7pbq3koj81cjyoqpenjj
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_STRING
add constraint FK_naonte6jut7b842icvp9ahino
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.TASK_ASSIGNMENTS alter table CCM_CORE.TASK_ASSIGNMENTS
add constraint FK_klh64or0yq26c63181j1tps2o add constraint FK_klh64or0yq26c63181j1tps2o
foreign key (ROLE_ID) foreign key (ROLE_ID)

View File

@ -88,46 +88,6 @@ CREATE SCHEMA ccm_core;
primary key (ROLE_ID) primary key (ROLE_ID)
); );
create table CCM_CORE.CONFIGURATION_ENTRIES (
comment varchar(2048),
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_BIG_DECIMAL (
entry_value numeric(19, 2),
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_BOOLEAN (
entry_value boolean,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_DOUBLE (
entry_value float8,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_ENUM (
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_INTEGER (
entry_value int8,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_L10N_STRING (
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES ( create table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES (
ENTRY_ID int8 not null, ENTRY_ID int8 not null,
LOCALIZED_VALUE text, LOCALIZED_VALUE text,
@ -135,12 +95,6 @@ CREATE SCHEMA ccm_core;
primary key (ENTRY_ID, LOCALE) primary key (ENTRY_ID, LOCALE)
); );
create table CCM_CORE.CONF_ENTRIES_STRING (
entry_value varchar(1024),
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.DIGESTS ( create table CCM_CORE.DIGESTS (
FREQUENCY int4, FREQUENCY int4,
HEADER varchar(4096) not null, HEADER varchar(4096) not null,
@ -525,6 +479,52 @@ CREATE SCHEMA ccm_core;
primary key (MEMBERSHIP_ID) primary key (MEMBERSHIP_ID)
); );
create table CCM_CORE.SETTINGS (
name varchar(512) not null,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_BIG_DECIMAL (
entry_value numeric(19, 2),
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_BOOLEAN (
entry_value boolean,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_DOUBLE (
entry_value float8,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_ENUM (
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_L10N_STRING (
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_LONG (
entry_value int8,
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.SETTINGS_STRING (
entry_value varchar(1024),
OBJECT_ID int8 not null,
primary key (OBJECT_ID)
);
create table CCM_CORE.TASK_ASSIGNMENTS ( create table CCM_CORE.TASK_ASSIGNMENTS (
TASK_ASSIGNMENT_ID int8 not null, TASK_ASSIGNMENT_ID int8 not null,
ROLE_ID int8, ROLE_ID int8,
@ -685,50 +685,10 @@ CREATE SCHEMA ccm_core;
foreign key (OBJECT_ID) foreign key (OBJECT_ID)
references CCM_CORE.CATEGORIES; references CCM_CORE.CATEGORIES;
alter table CCM_CORE.CONFIGURATION_ENTRIES
add constraint FK_8u6h7p0gs4ybf0ju240mggb73
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.CONF_ENTRIES_BIG_DECIMAL
add constraint FK_3tnub4je6c2bwi0c3p9m2n6d1
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_BOOLEAN
add constraint FK_d79uxyam5uhhmw3ijw3c14gk2
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_DOUBLE
add constraint FK_l5qxx6wfngl2hvnqaq77oin1s
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_ENUM
add constraint FK_blwwj2ht4wbg82meuuxf0t7kk
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_INTEGER
add constraint FK_reo0efdw6evf11viwlse1w27
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_L10N_STRING
add constraint FK_dbvyqoliuh0d7bl6ksng4abe
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES alter table CCM_CORE.CONF_ENTRIES_L10N_STR_VALUES
add constraint FK_ftb5yqeoli1m932yp3p8ho74g add constraint FK_ftb5yqeoli1m932yp3p8ho74g
foreign key (ENTRY_ID) foreign key (ENTRY_ID)
references CCM_CORE.CONF_ENTRIES_L10N_STRING; references CCM_CORE.SETTINGS_L10N_STRING;
alter table CCM_CORE.CONF_ENTRIES_STRING
add constraint FK_j31m640x2cn0xl5jcbik06708
foreign key (OBJECT_ID)
references CCM_CORE.CONFIGURATION_ENTRIES;
alter table CCM_CORE.DIGESTS alter table CCM_CORE.DIGESTS
add constraint FK_3xrcpufumqnh4ke4somt89rvh add constraint FK_3xrcpufumqnh4ke4somt89rvh
@ -763,7 +723,7 @@ CREATE SCHEMA ccm_core;
alter table CCM_CORE.ENUM_CONFIGURATION_ENTRIES_VALUES alter table CCM_CORE.ENUM_CONFIGURATION_ENTRIES_VALUES
add constraint FK_ao3evxajxd8y4gy5a6e8ua49j add constraint FK_ao3evxajxd8y4gy5a6e8ua49j
foreign key (ENUM_ID) foreign key (ENUM_ID)
references CCM_CORE.CONF_ENTRIES_ENUM; references CCM_CORE.SETTINGS_ENUM;
alter table CCM_CORE.FORMBUILDER_COMPONENTS alter table CCM_CORE.FORMBUILDER_COMPONENTS
add constraint FK_72108sd6vsqt88g3fb4kl6o81 add constraint FK_72108sd6vsqt88g3fb4kl6o81
@ -1055,6 +1015,46 @@ CREATE SCHEMA ccm_core;
foreign key (ROLE_ID) foreign key (ROLE_ID)
references CCM_CORE.CCM_ROLES; references CCM_CORE.CCM_ROLES;
alter table CCM_CORE.SETTINGS
add constraint FK_3k0t3in140j6wj6eq5olwjgu
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.SETTINGS_BIG_DECIMAL
add constraint FK_9mbdc1rjkm80edyuijnkwl6ak
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_BOOLEAN
add constraint FK_1mjjvpjxpwicyv8im6mumc7ug
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_DOUBLE
add constraint FK_kejnkuyk89tw59xg550kugwb5
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_ENUM
add constraint FK_fgrfc2qbl2f2t1l0ku8wo2e5r
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_L10N_STRING
add constraint FK_evnyfg9udprxmbginhc4o0is9
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_LONG
add constraint FK_2l4bw7pbq3koj81cjyoqpenjj
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.SETTINGS_STRING
add constraint FK_naonte6jut7b842icvp9ahino
foreign key (OBJECT_ID)
references CCM_CORE.SETTINGS;
alter table CCM_CORE.TASK_ASSIGNMENTS alter table CCM_CORE.TASK_ASSIGNMENTS
add constraint FK_klh64or0yq26c63181j1tps2o add constraint FK_klh64or0yq26c63181j1tps2o
foreign key (ROLE_ID) foreign key (ROLE_ID)

View File

@ -45,13 +45,12 @@ import com.arsdigita.util.UncheckedWrapperException;
import org.apache.log4j.Category; import org.apache.log4j.Category;
import org.apache.oro.text.perl.Perl5Util; import org.apache.oro.text.perl.Perl5Util;
import org.apache.oro.text.perl.MalformedPerl5PatternException; import org.apache.oro.text.perl.MalformedPerl5PatternException;
import org.libreccm.cdi.utils.CdiLookupException;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
public class ShortcutForm extends Form { public class ShortcutForm extends Form {
private static final Category log = Category.getInstance(ShortcutForm.class private static final Category log = Category.getInstance(ShortcutForm.class
.getName()); .getName());
private ParameterSingleSelectionModel m_selected_shortcut; private ParameterSingleSelectionModel m_selected_shortcut;
@ -66,52 +65,56 @@ public class ShortcutForm extends Form {
m_selected_shortcut = selected_shortcut; m_selected_shortcut = selected_shortcut;
TrimmedStringParameter urlKeyParameter = new TrimmedStringParameter( TrimmedStringParameter urlKeyParameter = new TrimmedStringParameter(
"url"); "url");
urlKeyParameter.addParameterListener(new NotEmptyValidationListener()); urlKeyParameter.addParameterListener(new NotEmptyValidationListener());
m_url = new TextField(urlKeyParameter); m_url = new TextField(urlKeyParameter);
TrimmedStringParameter redirectParameter = new TrimmedStringParameter( TrimmedStringParameter redirectParameter = new TrimmedStringParameter(
"redirect"); "redirect");
redirectParameter redirectParameter
.addParameterListener(new NotEmptyValidationListener()); .addParameterListener(new NotEmptyValidationListener());
m_redirect = new TextField(redirectParameter); m_redirect = new TextField(redirectParameter);
urlKeyParameter.addParameterListener(new ParameterListener() { urlKeyParameter.addParameterListener(new ParameterListener() {
@Override @Override
public void validate(ParameterEvent e) throws FormProcessException { public void validate(ParameterEvent e) throws FormProcessException {
ParameterData data = e.getParameterData(); ParameterData data = e.getParameterData();
String key = (String) data.getValue(); String key = (String) data.getValue();
if (key == null) { if (key == null) {
return; // Something else will handle return; // Something else will handle this
} // this }
Perl5Util perl = new Perl5Util(); Perl5Util perl = new Perl5Util();
try { try {
if (!perl.match("/^(\\/[-a-zA-Z0-9_.]+)+\\/?$/", key)) { if (!perl.match("/^(\\/[-a-zA-Z0-9_.]+)+\\/?$/", key)) {
data.addError(GlobalizationUtil.globalize( data.addError(GlobalizationUtil.globalize(
"shortcuts.ui.invalid_key_descr")); "shortcuts.ui.invalid_key_descr"));
throw new FormProcessException( throw new FormProcessException(
"Invalid key", "Invalid key",
GlobalizationUtil.globalize("shortcuts.ui.invalid_key") GlobalizationUtil.globalize(
"shortcuts.ui.invalid_key")
); );
} }
} catch (MalformedPerl5PatternException ex) { } catch (MalformedPerl5PatternException ex) {
throw new UncheckedWrapperException("bad regex", ex); throw new UncheckedWrapperException("bad regex", ex);
} }
} }
}); });
redirectParameter.addParameterListener(new ParameterListener() { redirectParameter.addParameterListener(new ParameterListener() {
@Override @Override
public void validate(ParameterEvent e) throws FormProcessException { public void validate(ParameterEvent e) throws FormProcessException {
ParameterData data = e.getParameterData(); ParameterData data = e.getParameterData();
String url = (String) data.getValue(); String url = (String) data.getValue();
if (url == null) { if (url == null) {
return; // Something else will handle return; // Something else will handle this
} // this }
url = url.toLowerCase(); url = url.toLowerCase();
@ -131,11 +134,13 @@ public class ShortcutForm extends Form {
} }
data data
.addError("You must enter an absolute path " .addError("You must enter an absolute path "
+ "(starting with '/') or a fully " + "(starting with '/') or a fully "
+ "qualified URL (starting with 'http://' or 'https://')"); + "qualified URL (starting with 'http://' or 'https://')");
throw new FormProcessException(GlobalizationUtil.globalize("shortcuts.ui.invalid_key")); throw new FormProcessException(GlobalizationUtil.globalize(
"shortcuts.ui.invalid_key"));
} }
}); });
add(new Label("URL Key:")); add(new Label("URL Key:"));
@ -157,14 +162,10 @@ public class ShortcutForm extends Form {
public void init(FormSectionEvent ev) throws FormProcessException { public void init(FormSectionEvent ev) throws FormProcessException {
final PageState state = ev.getPageState(); final PageState state = ev.getPageState();
final CdiUtil cdiUtil = new CdiUtil(); final CdiUtil cdiUtil = new CdiUtil();
final ShortcutRepository shortcutsRepo; final ShortcutRepository shortcutsRepo = cdiUtil.findBean(ShortcutRepository.class);
try {
shortcutsRepo = cdiUtil.findBean(ShortcutRepository.class);
} catch (CdiLookupException ex) {
throw new UncheckedWrapperException(ex);
}
Long shortcutKey = (Long) m_selected_shortcut Long shortcutKey = (Long) m_selected_shortcut
.getSelectedKey(state); .getSelectedKey(state);
if (shortcutKey == null) { if (shortcutKey == null) {
log.debug("init form for empty shortcut"); log.debug("init form for empty shortcut");
m_url.setValue(state, null); m_url.setValue(state, null);
@ -177,10 +178,11 @@ public class ShortcutForm extends Form {
m_redirect.setValue(state, shortcut.getRedirect()); m_redirect.setValue(state, shortcut.getRedirect());
} }
} }
} }
private class ShortcutFormValidationListener implements private class ShortcutFormValidationListener implements
FormValidationListener { FormValidationListener {
@Override @Override
public void validate(FormSectionEvent e) throws FormProcessException { public void validate(FormSectionEvent e) throws FormProcessException {
@ -189,7 +191,7 @@ public class ShortcutForm extends Form {
// get currently edited shortcut // get currently edited shortcut
Long shortcutKey = (Long) m_selected_shortcut Long shortcutKey = (Long) m_selected_shortcut
.getSelectedKey(state); .getSelectedKey(state);
//TODO: maybe adjust url. see com-arsdigita.shortcuts.ShortcutUtil.cleanURLKey() //TODO: maybe adjust url. see com-arsdigita.shortcuts.ShortcutUtil.cleanURLKey()
String key = (String) m_url.getValue(state); String key = (String) m_url.getValue(state);
@ -199,10 +201,11 @@ public class ShortcutForm extends Form {
if (target != null) { if (target != null) {
m_url.addError(GlobalizationUtil.globalize( m_url.addError(GlobalizationUtil.globalize(
"shortcuts.ui.key_already_exists")); "shortcuts.ui.key_already_exists"));
throw new FormProcessException( throw new FormProcessException(
"duplicate key", "duplicate key",
GlobalizationUtil.globalize("shortcuts.ui.duplicate_key") GlobalizationUtil
.globalize("shortcuts.ui.duplicate_key")
); );
} }
} }
@ -210,6 +213,7 @@ public class ShortcutForm extends Form {
int index = key.indexOf("/", 2); int index = key.indexOf("/", 2);
String base = key.substring(0, index + 1); String base = key.substring(0, index + 1);
} }
} }
private class ShortcutFormProcessListener implements FormProcessListener { private class ShortcutFormProcessListener implements FormProcessListener {
@ -219,12 +223,7 @@ public class ShortcutForm extends Form {
ShortcutManager shortcutMgr = new ShortcutManager(); ShortcutManager shortcutMgr = new ShortcutManager();
PageState state = e.getPageState(); PageState state = e.getPageState();
final CdiUtil cdiUtil = new CdiUtil(); final CdiUtil cdiUtil = new CdiUtil();
final ShortcutRepository shortcutsRepo; final ShortcutRepository shortcutsRepo = cdiUtil.findBean(ShortcutRepository.class);
try {
shortcutsRepo = cdiUtil.findBean(ShortcutRepository.class);
} catch (CdiLookupException ex) {
throw new UncheckedWrapperException(ex);
}
Long shortcutKey = (Long) m_selected_shortcut.getSelectedKey(state); Long shortcutKey = (Long) m_selected_shortcut.getSelectedKey(state);
@ -247,11 +246,11 @@ public class ShortcutForm extends Form {
} }
// ShortcutUtil.repopulateShortcuts(); // ShortcutUtil.repopulateShortcuts();
m_redirect.setValue(state, ""); m_redirect.setValue(state, "");
m_url.setValue(state, ""); m_url.setValue(state, "");
m_selected_shortcut.clearSelection(state); m_selected_shortcut.clearSelection(state);
} }
} }
} }

View File

@ -38,7 +38,6 @@ import com.arsdigita.bebop.ControlLink;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import java.util.List; import java.util.List;
import org.libreccm.cdi.utils.CdiLookupException;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.shortcuts.ShortcutRepository; import org.libreccm.shortcuts.ShortcutRepository;
@ -49,7 +48,8 @@ import org.libreccm.shortcuts.ShortcutRepository;
public class ShortcutsTable extends Table { public class ShortcutsTable extends Table {
private static final Category log private static final Category log
= Category.getInstance(ShortcutsTable.class.getName()); = Category.getInstance(
ShortcutsTable.class.getName());
public static final String headers[] = {"URL Key", "Redirect", "", ""}; public static final String headers[] = {"URL Key", "Redirect", "", ""};
@ -57,28 +57,27 @@ public class ShortcutsTable extends Table {
super(new ShortcutsModelBuilder(), headers); super(new ShortcutsModelBuilder(), headers);
setDefaultCellRenderer(new ShortcutsCellRenderer()); setDefaultCellRenderer(new ShortcutsCellRenderer());
final CdiUtil cdiUtil = new CdiUtil(); final CdiUtil cdiUtil = new CdiUtil();
final ShortcutRepository shortcutsRepo; final ShortcutRepository shortcutsRepo = cdiUtil.findBean(
try { ShortcutRepository.class);
shortcutsRepo = cdiUtil.findBean(ShortcutRepository.class);
} catch (CdiLookupException ex) {
throw new UncheckedWrapperException(ex);
}
addTableActionListener(new TableActionListener() { addTableActionListener(new TableActionListener() {
public void cellSelected(TableActionEvent e) { public void cellSelected(TableActionEvent e) {
selected_shortcut.clearSelection(e.getPageState()); selected_shortcut.clearSelection(e.getPageState());
String row = (String) e.getRowKey(); String row = (String) e.getRowKey();
if (e.getColumn().intValue() == 2) { if (e.getColumn().intValue() == 2) {
// edit selected // edit selected
log.debug("selected edit shortcut " + row); log.debug("selected edit shortcut " + row);
selected_shortcut.setSelectedKey(e.getPageState(), new BigDecimal(row)); selected_shortcut.setSelectedKey(e.getPageState(),
new BigDecimal(row));
} else if (e.getColumn().intValue() == 3) { } else if (e.getColumn().intValue() == 3) {
// delete selected // delete selected
log.fatal("selected delete shortcut " + row); log.fatal("selected delete shortcut " + row);
Shortcut shortcut = shortcutsRepo.findById( Shortcut shortcut = shortcutsRepo.findById(
(Long) selected_shortcut.getSelectedKey(e.getPageState())); (Long) selected_shortcut
.getSelectedKey(e.getPageState()));
if (shortcut != null) { if (shortcut != null) {
log.info("delete shortcut " + shortcut.getUrlKey()); log.info("delete shortcut " + shortcut.getUrlKey());
@ -89,11 +88,12 @@ public class ShortcutsTable extends Table {
public void headSelected(TableActionEvent e) { public void headSelected(TableActionEvent e) {
} }
}); });
} }
protected static class ShortcutsModelBuilder extends LockableImpl implements protected static class ShortcutsModelBuilder extends LockableImpl implements
TableModelBuilder { TableModelBuilder {
public TableModel makeModel(Table table, PageState ps) { public TableModel makeModel(Table table, PageState ps) {
return new ShortcutsModel(); return new ShortcutsModel();
@ -133,14 +133,17 @@ public class ShortcutsTable extends Table {
Long id = m_shortcut.getShortcutId(); Long id = m_shortcut.getShortcutId();
return id; return id;
} }
} }
} }
protected static class ShortcutsCellRenderer implements TableCellRenderer { protected static class ShortcutsCellRenderer implements TableCellRenderer {
public Component getComponent(Table table, PageState state, public Component getComponent(Table table, PageState state,
Object value, boolean isSelected, Object key, int row, Object value, boolean isSelected,
int column) { Object key, int row,
int column) {
Shortcut shortcut = (Shortcut) value; Shortcut shortcut = (Shortcut) value;
switch (column) { switch (column) {
@ -158,5 +161,7 @@ public class ShortcutsTable extends Table {
throw new UncheckedWrapperException("Column out of bounds"); throw new UncheckedWrapperException("Column out of bounds");
} }
} }
} }
} }