| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| */ |
| package org.eclipse.osbp.preferences; |
| |
| import java.util.Collection; |
| import java.util.HashMap; |
| import java.util.Locale; |
| import java.util.Map; |
| import java.util.TreeMap; |
| |
| import org.eclipse.core.resources.IProject; |
| import org.eclipse.persistence.config.PersistenceUnitProperties; |
| |
| /** |
| * Access to the Product Configuration!<br> |
| * <i>For now empty configuration data will be <u>auto-generated to hit out |
| * internal development configuration</u>!</i> |
| */ |
| public class ProductConfigurationDefaultPrefs implements IProductConfigurationPrefs { |
| |
| public static final String MYSQL = "mysql"; |
| public static final String ORACLE = "oracle"; |
| public static final String PASSWORD_HINT = "<password>"; // NOSONAR |
| public static final String USERNAME_HINT = "<username>"; |
| public static final String DATABASE_HINT = "<database>"; |
| public static final String H2MEMORY = "H2MEMORY"; |
| public static final String DERBYLOCALFILE = "DERBYLOCALFILE"; |
| public static final String H2LOCALFILE = "H2LOCALFILE"; |
| public static final String DERBYMEMORY = "DERBYMEMORY"; |
| public static final String IP_OR_HOST = "<ip-or-host>"; |
| public static final String BPM_ENGINE_PERSISTENCE_UNIT = "bpm"; |
| |
| public String getBusinessBundleClassNameReadOnly() { |
| return ""; |
| } |
| |
| private Map<String, DataSourceConfiguration> dataSources = new HashMap<>(); |
| private Map<String, PersistenceUnitConfiguration> persistenceUnits = new HashMap<>(); |
| |
| public ProductConfigurationDefaultPrefs() { |
| initializeIfNotExists (ORACLE, ORACLE, |
| EnumDatabaseVendor.ORACLE, IP_OR_HOST, 1521, DATABASE_HINT, USERNAME_HINT, PASSWORD_HINT); |
| /* === datasource using a MySQL database === */ |
| initializeIfNotExists (MYSQL, null, |
| EnumDatabaseVendor.MYSQL, IP_OR_HOST, 3306, DATABASE_HINT, USERNAME_HINT, ""); |
| /* === datasource using a H2 in-Memory database === */ |
| initializeIfNotExists (ProductConfigurationPrefs.DEFAULT_H2MEMORY_DATASOURCE, null, |
| EnumDatabaseVendor.H2_IN_MEMORY, null, -1, H2MEMORY, H2MEMORY, H2MEMORY); // NOSONAR |
| /* === datasource using a H2 local-file database === */ |
| initializeIfNotExists (ProductConfigurationPrefs.DEFAULT_H2LOCALFILE_DATASOURCE, null, |
| EnumDatabaseVendor.H2_LOCAL_FILE, null, -1, H2LOCALFILE, H2LOCALFILE, H2LOCALFILE); |
| /* === datasource using a Derby in-Memory database === */ |
| initializeIfNotExists (ProductConfigurationPrefs.DEFAULT_DERBYMEMORY_DATASOURCE, null, |
| EnumDatabaseVendor.DERBY_IN_MEMORY, null, -1, DERBYMEMORY, DERBYMEMORY, DERBYMEMORY); |
| /* === datasource using a Derby local-file database === */ |
| initializeIfNotExists (ProductConfigurationPrefs.DEFAULT_DERBYLOCALFILE_DATASOURCE, null, |
| EnumDatabaseVendor.DERBY_LOCAL_FILE, null, -1, DERBYLOCALFILE, DERBYLOCALFILE, DERBYLOCALFILE); |
| /* === datasource using a Derby database === */ |
| initializeIfNotExists (ProductConfigurationPrefs.DEFAULT_DERBYSERVER_DATASOURCE, null, |
| EnumDatabaseVendor.DERBY_CLIENT, IP_OR_HOST, 1527, DATABASE_HINT, USERNAME_HINT, PASSWORD_HINT); |
| |
| // --- generate reasonable default preferences for development product |
| initializeIfNotExists (ProductConfigurationPrefs.PERSISTENCE_UNIT_AUTHENTICATION, |
| ProductConfigurationPrefs.DEFAULT_DATASOURCE_FOR_AUTHENTICATION, true, true, |
| null, 1000, |
| true, 200, |
| "off", "create-or-extend-tables", // NOSONAR |
| PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML_DEFAULT); |
| initializeIfNotExists (ProductConfigurationPrefs.PERSISTENCE_UNIT_BLOB, |
| ProductConfigurationPrefs.DEFAULT_DATASOURCE_FOR_BLOB, true, true, |
| null, 1000, |
| true, 200, |
| "off", "create-or-extend-tables", |
| PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML_DEFAULT); |
| initializeIfNotExists (ProductConfigurationPrefs.PERSISTENCE_UNIT_BPM, |
| ProductConfigurationPrefs.DEFAULT_DATASOURCE_FOR_BPM, true, true, |
| null, 1000, |
| true, 200, |
| "off", "update", |
| PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML_DEFAULT); |
| initializeIfNotExists (ProductConfigurationPrefs.PERSISTENCE_UNIT_BUSINESSDATA, |
| ProductConfigurationPrefs.DEFAULT_DATASOURCE_FOR_BUSINESSDATA, true, true, |
| null, 1000, |
| true, 200, |
| "off", "create-or-extend-tables", |
| PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML_DEFAULT); |
| } |
| |
| private void initializeIfNotExists( // NOSONAR |
| String dataSource, String dataSourceConsumer, EnumDatabaseVendor vendor, // NOSONAR |
| String serverName, int serverPort, |
| String database, String username, String password) { |
| String driverVendor = vendor.getDriverVendor(); |
| String driverType = vendor.getDriverType(); |
| String driverClass = vendor.getDriverClass(); |
| if (!driverClass.isEmpty() && |
| !database.isEmpty() && !username.isEmpty()) { |
| DataSourceConfiguration configuration = new DataSourceConfiguration( |
| dataSource, |
| vendor, |
| driverVendor, driverType, driverClass, |
| serverName, |
| serverPort, |
| database, username, password, |
| ""); |
| dataSources.put(dataSource, configuration); |
| } |
| } |
| |
| private void initializeIfNotExists(String persistenceUnit,// NOSONAR |
| String dataSource, boolean deployOnStartup, boolean queryCache, |
| String batchWriting, int batchWritingSize, boolean cacheStatements, int cacheStatementsSize, |
| String loggingLevel, String dllGeneration, String xmlPath) { |
| DataSourceConfiguration dataSourceConfiguration = dataSources.get(dataSource); |
| String bw = batchWriting; |
| if ((batchWriting == null) && (dataSourceConfiguration != null)) { |
| bw = dataSourceConfiguration.getDefaultBatchWriting(); |
| } |
| PersistenceUnitConfiguration configuration = new PersistenceUnitConfiguration( |
| persistenceUnit, |
| dataSource, deployOnStartup, |
| queryCache, bw, batchWritingSize, |
| cacheStatements, cacheStatementsSize, loggingLevel, |
| dllGeneration, xmlPath, "static"); |
| persistenceUnits.put(persistenceUnit, configuration); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getBpmServerIp() |
| */ |
| @Override |
| public String getBpmServerIp() { |
| return "127.0.0.1"; // NOSONAR |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getBpmServerPort() |
| */ |
| @Override |
| public int getBpmServerPort() { |
| return DEFAULT_PORT_BPM_ENGINE; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getBpmResponseTimeout() |
| */ |
| @Override |
| public int getBpmResponseTimeout() { |
| return 10000; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getEuroXRefRatesURLDaily() |
| */ |
| @Override |
| public String getEuroXRefRatesURLDaily() { |
| return "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getEuroXRefRatesURLPrevious() |
| */ |
| @Override |
| public String getEuroXRefRatesURLPrevious() { |
| return "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml"; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getActiveMqBrokerServerName() |
| */ |
| @Override |
| public String getActiveMqBrokerServerName() { |
| return "<ActiveMqBrokerServerIp>"; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getActiveMqBrokerServerPort() |
| */ |
| @Override |
| public int getActiveMqBrokerServerPort() { |
| return DEFAULT_PORT_ACTIVE_MQ_BROKER_SERVICE; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getHybridRefresherMilliSecsActive() |
| */ |
| @Override |
| public int getHybridRefresherMilliSecsActive() { |
| return 2000; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getHybridRefresherMilliSecsInactive() |
| */ |
| @Override |
| public int getHybridRefresherMilliSecsInactive() { |
| return 10000; |
| } |
| |
| public final String getAuthenticationOrganizationId() { |
| return "FoodMart"; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getAuthRESTfulPort() |
| */ |
| @Override |
| public final int getAuthRESTfulPort() { |
| return 8554; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#hasAutoLogin() |
| */ |
| @Override |
| public final boolean hasAutoLogin() { |
| return false; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#hasEncryptPasswords() |
| */ |
| @Override |
| public final boolean hasEncryptPasswords() { |
| return true; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#hasNoRememberMe() |
| */ |
| @Override |
| public final boolean hasNoRememberMe() { |
| return false; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getDtoRealmPortalId() |
| */ |
| @Override |
| public final int getDtoRealmPortalId() { |
| return 1; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getLdapRealmPortalId() |
| */ |
| @Override |
| public final int getLdapRealmPortalId() { |
| return 1; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getLdapContextFactoryUrl() |
| */ |
| @Override |
| public final String getLdapContextFactoryUrl() { |
| return "ldap://<ldapserver>:389"; // NOSONAR |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getLdapUserDnTemplate() |
| */ |
| @Override |
| public final String getLdapUserDnTemplate() { |
| return "cn={0},ou=users,dc=<organisation>,dc=<countrycode>"; // NOSONAR |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getAdminEmail() |
| */ |
| @Override |
| public final String getAdminEmail() { |
| return "admin@support.com"; |
| } |
| |
| @Override |
| public final String getAdminEmailUsername() { |
| return ""; |
| } |
| |
| @Override |
| public final String getAdminEmailPassword() { |
| return ""; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getMaxLoginAttempts() |
| */ |
| @Override |
| public final int getMaxLoginAttempts() { |
| return 3; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getProtocolDatasource() |
| */ |
| @Override |
| public final String getProtocolDatasource() { |
| return ""; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getProtocolUnit() |
| */ |
| @Override |
| public final String getProtocolUnit() { |
| return ""; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getIdentifyByUsername() |
| */ |
| @Override |
| public final boolean getIdentifyByUsername() { |
| return true; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getLanguages() |
| */ |
| @Override |
| public Map<String, Locale> getLanguages() { |
| Map<String, Locale> languages = new TreeMap<>(); |
| Locale[] supported = new Locale[] { |
| Locale.GERMAN, |
| Locale.ENGLISH, |
| Locale.FRENCH, |
| new Locale("de", "AT"), |
| Locale.US |
| }; |
| for (Locale locale : supported) { |
| languages.put(locale.toString(), locale); |
| } |
| return languages; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#isLanguagesAutotranslate() |
| */ |
| @Override |
| public boolean isLanguagesAutotranslate() { |
| return false; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#willLanguagesAutocreate() |
| */ |
| @Override |
| public boolean willLanguagesAutocreate() { |
| return true; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#isUomoMetricUnit() |
| */ |
| @Override |
| public boolean isUomoMetricUnit() { |
| return true; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#showLanguageSelectInRespectiveLocale() |
| */ |
| @Override |
| public boolean showLanguageSelectInRespectiveLocale() { |
| return true; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#hasDemoToolsTheme() |
| */ |
| @Override |
| public final boolean hasDemoToolsTheme() { |
| return false; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#hasDemoToolsLanguage() |
| */ |
| @Override |
| public final boolean hasDemoToolsLanguage() { |
| return false; |
| } |
| |
| @Override |
| public boolean hasToolsPrintService() { |
| return true; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#projectWizardUsesAbsoluteLocation() |
| */ |
| @Override |
| public final boolean projectWizardUsesAbsoluteLocation() { |
| return true; |
| } |
| |
| @Override |
| public Collection<DataSourceConfiguration> getDataSources() { |
| return dataSources.values(); |
| } |
| |
| @Override |
| public Collection<PersistenceUnitConfiguration> getPersistenceUnits() { |
| return persistenceUnits.values(); |
| } |
| |
| @Override |
| public boolean isBpmEngineHibernateShowSql() { |
| return false; |
| } |
| |
| @Override |
| public boolean isBpmEngineHibernateFormatSql() { |
| return false; |
| } |
| |
| @Override |
| public int getBpmEngineHibernateMaxFetchDepth() { |
| return 3; |
| } |
| |
| @Override |
| public String getBpmEnginePersistenceUnit() { |
| return BPM_ENGINE_PERSISTENCE_UNIT; |
| } |
| |
| @Override |
| public String getBpmEngineHibernateSchemaName(String persistenceUnit) { |
| return "BPM"; |
| } |
| |
| @Override |
| public IProject getProject() { |
| return null; |
| } |
| |
| @Override |
| public String getEmailServerIp() { |
| return "<EmailServerIp>"; |
| } |
| |
| @Override |
| public int getEmailSmtpPort() { |
| return DEFAULT_PORT_EMAIL_SMTP; |
| } |
| |
| @Override |
| public boolean isEmailUseSslOnConnect() { |
| return false; |
| } |
| |
| @Override |
| public String getJavaPosConfiguration() { |
| return ""; |
| } |
| |
| @Override |
| public String getDatainterchangeConfiguration() { |
| return ""; |
| } |
| |
| @Override |
| public boolean isMavenActivated() { |
| return false; |
| } |
| } |