blob: a992fd5c66904e6c978e651835b46d791a9e6e62 [file] [log] [blame]
/**
*
* 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 final static 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", //ProductConfigurationPrefs.DATASOURCE_FOR_BUSINESSDATA,
EnumDatabaseVendor.ORACLE, "<ip-or-host>", 1521, "<database>", "<username>", "<password>");
/* === datasource using a MySQL database === */
initializeIfNotExists ("mysql", null,
EnumDatabaseVendor.MYSQL, "<ip-or-host>", 3306, "<database>", "<username>", "");
/* === 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>", "<username>", "<password>");
// --- 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(
String dataSource, String dataSourceConsumer, EnumDatabaseVendor vendor,
String serverName, int serverPort,
String database, String username, String password) {
String vendorName = vendor.name();
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,
String dataSource, boolean deployOnStartup, boolean queryCache,
String batchWriting, int batchWritingSize, boolean cacheStatements, int cacheStatementsSize,
String loggingLevel, String dllGeneration, String xmlPath) { // NOSONAR
DataSourceConfiguration dataSourceConfiguration = dataSources.get(dataSource);
if ((batchWriting == null) && (dataSourceConfiguration != null)) {
batchWriting = dataSourceConfiguration.getDefaultBatchWriting();
}
PersistenceUnitConfiguration configuration = new PersistenceUnitConfiguration(
persistenceUnit,
dataSource, deployOnStartup,
queryCache, batchWriting, 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";
}
/* (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 Collection<DataSourceConfiguration> getDataSources() {
// return dataSources.values();
// }
// public Set<String> getDataSourceNames() {
// return dataSources.keySet();
// }
// /* (non-Javadoc)
// * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getDataSourceNameForAuthentication()
// */
// @Override
// public String getDataSourceNameForAuthentication() {
// return ProductConfigurationPrefs.DEFAULT_DATASOURCE_FOR_AUTHENTICATION;
// }
//
// /* (non-Javadoc)
// * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getDataSourceNameForBLOB()
// */
// @Override
// public String getDataSourceNameForBLOB() {
// return ProductConfigurationPrefs.DEFAULT_DATASOURCE_FOR_BLOB;
// }
//
// /* (non-Javadoc)
// * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getDataSourceNameForBPM()
// */
// @Override
// public String getDataSourceNameForBPM() {
// return ProductConfigurationPrefs.DEFAULT_DATASOURCE_FOR_BPM;
// }
//
// /* (non-Javadoc)
// * @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getDataSourceNameForBusinessData()
// */
// @Override
// public String getDataSourceNameForBusinessData() {
// return ProductConfigurationPrefs.DEFAULT_DATASOURCE_FOR_BUSINESSDATA;
// }
// public Properties getDataSourceProperties(String jndiName) {
// DataSourceConfiguration jndi = getDataSource(jndiName);
// return (jndi == null) ? null : jndi.getDataSourceProperties();
// }
// public DataSourceConfiguration getDataSource(String jndiName) {
// return dataSources.get(jndiName);
// }
// public String getDataSourceDriverClass(String jndiName) {
// DataSourceConfiguration jndi = dataSources.get(jndiName);
// return (jndi == null) ? null : jndi.getDriverClass();
// }
// public Properties getJpaProperties(String jndiName) {
// DataSourceConfiguration jndi = dataSources.get(jndiName);
// return (jndi == null) ? null : jndi.getJpaProperties();
// }
// public Collection<PersistenceUnitConfiguration> getPersistenceUnits() {
// return persistenceUnits.values();
// }
// public Set<String> getPersistenceUnitNames() {
// return persistenceUnits.keySet();
// }
// public String getPersistenceUnitJndiName(String persistenceUnitName) {
// return persistenceUnits.get(persistenceUnitName).getJndiName();
// }
// public String getPersistenceUnitSchemaName(String persistenceUnitName) {
// return persistenceUnits.get(persistenceUnitName).getSchemaName();
// }
// public String getPersistenceUnitHibernateDialect(String persistenceUnitName) {
// return getJndiNameHibernateDialect(getPersistenceUnitJndiName(persistenceUnitName));
// }
// public String getJndiNameHibernateDialect(String jndiName) {
// DataSourceConfiguration jndi = dataSources.get(jndiName);
// return (jndi == null) ? null : jndi.getDatabaseVendor().getHibernateDialect();
// }
// public Properties getPersistenceUnitProperties(
// String persistenceUnitName, CommonDataSource dataSource, ClassLoader classLoader) {
// if (persistenceUnits.containsKey(persistenceUnitName)) {
// return persistenceUnits.get(persistenceUnitName)
// .getPersistenceUnitProperties(dataSource, classLoader);
// }
// return null;
// }
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;
}
// public final String getShiroConfiguration(String staticRealmClassName) {
// String mainSection = "[main]" + IShiroConfiguration.INI_NEWLINE;
// String realms = "";
// if (!shiros.containsKey(ProductConfiguration.SHIRO_STATIC_REALM)) {
// shiros.put(ProductConfiguration.SHIRO_STATIC_REALM, new StaticConfiguration(staticRealmClassName, 1));
// }
// for (String name : shiros.keySet()) {
// mainSection += shiros.get(name).getShiroConfiguration(name);
// if (!realms.isEmpty()) {
// realms += ",";
// }
// realms += "$" + name;
// }
// mainSection += "securityManager.realms = " + realms + IShiroConfiguration.INI_NEWLINE;
// return mainSection;
// }
/* (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#getLanguagesGoogleHttpReferrer()
*/
@Override
public String getLanguagesGoogleHttpReferrer() {
return "";
}
/* (non-Javadoc)
* @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#getLanguagesGoogleApiKey()
*/
@Override
public String getLanguagesGoogleApiKey() {
return "";
}
/* (non-Javadoc)
* @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#hasDemoToolsTheme()
*/
@Override
public final boolean hasDemoToolsTheme() {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#hasDemoToolsStrategy()
*/
@Override
public final boolean hasDemoToolsStrategy() {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.osbp.preferences.IProductConfigurationPrefs#hasDemoToolsLanguage()
*/
@Override
public final boolean hasDemoToolsLanguage() {
return true;
}
@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 "";
}
}