| /** |
| * |
| * 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 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| */ |
| package org.eclipse.osbp.wizard.ui.basic; |
| |
| import java.io.BufferedInputStream; |
| import java.io.IOException; |
| import java.io.InputStream; |
| import java.net.URISyntaxException; |
| import java.net.URL; |
| import java.nio.file.Files; |
| import java.nio.file.Paths; |
| import java.util.Arrays; |
| import java.util.Calendar; |
| import java.util.Collection; |
| import java.util.Enumeration; |
| import java.util.HashSet; |
| import java.util.LinkedHashMap; |
| import java.util.Locale; |
| import java.util.Map; |
| import java.util.Set; |
| import java.util.TreeMap; |
| |
| import org.apache.commons.io.IOUtils; |
| import org.apache.commons.lang3.StringUtils; |
| import org.eclipse.core.runtime.IPath; |
| import org.eclipse.core.runtime.Platform; |
| import org.eclipse.osbp.preferences.DataSourceConfiguration; |
| import org.eclipse.osbp.preferences.ProductConfiguration; |
| import org.eclipse.osbp.preferences.ProductConfigurationPrefs; |
| import org.eclipse.osbp.preferences.ProductFileConfigurations; |
| import org.eclipse.osbp.preferences.ProductFileFeatures; |
| import org.eclipse.osbp.utils.themes.ui.VaaclipseUiTheme; |
| import org.eclipse.osbp.wizard.ui.Activator; |
| import org.eclipse.osbp.wizard.ui.allinonedsl.AllInOneDSLsProjectMasterTemplate; |
| import org.eclipse.osbp.wizard.ui.basic.BasicProjectCreator.ManifestAttribute; |
| import org.eclipse.osbp.wizard.ui.theme.ThemeProjectMasterTemplate; |
| import org.osgi.framework.Bundle; |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| public class BasicProjectInfo extends org.eclipse.xtext.ui.wizard.DefaultProjectInfo { |
| |
| private static final Logger LOGGER = LoggerFactory.getLogger(BasicProjectInfo.class); |
| |
| public void log(String text) { |
| Gofl.log(this, text); |
| } |
| |
| private final static String DEFAULT_THEME_NAME = "osbp"; |
| |
| private static final String MANIFEST_MF_ADDONS = "MANIFEST.MF.ADDONS"; |
| |
| protected final static double BREE_MINIMUM = 1.8; |
| |
| public static final String IGNORE_THIS_FILE = "!!IGNORE THIS FILE!!"; |
| |
| private static final String PROJECT_PREFIX = "PROJECT"; |
| private static final String PROJECT_MAIN_PREFIX = PROJECT_PREFIX; |
| private static final String PROJECT_MAIN_PATH = PROJECT_MAIN_PREFIX + "/"; |
| private static final String PROJECT_SUB_PREFIX = PROJECT_PREFIX + "."; |
| private static final String PROJECT_BASIC_POSTFIX = ".__basic__"; |
| private static final String PROJECT_BASIC_NAME = PROJECT_PREFIX + PROJECT_BASIC_POSTFIX; |
| |
| public static final String FILE_PROJECT_NAME = "PROJECTNAME"; |
| public static final String FILE_PROJECT_PATH = "PROJECTPATH"; |
| public static final String FILE_BUSINESS_BUNDLE_CLASS_NAME = "BUSINESSBUNDLECLASSNAME"; |
| public static final String FILE_THEME_BUNDLE_CLASS_NAME = "THEMEBUNDLECLASSNAME"; |
| |
| public static final String PRE = "${{"; |
| public static final String POST = "}}"; |
| |
| public static final String CONTENT_SAMPLE_VENDOR_NAME = PRE + "SAMPLE_VENDOR_NAME" + POST; |
| public static final String CONTENT_SAMPLE_VENDOR_COUNTRY = PRE + "SAMPLE_VENDOR_COUNTRY" + POST; |
| public static final String CONTENT_SAMPLE_VENDOR_ISO3166 = PRE + "SAMPLE_VENDOR_ISO3166" + POST; |
| |
| public static final String CONTENT_BUNDLE_VERSION = PRE + "BUNDLE_VERSION" + POST; |
| public static final String CONTENT_BUSINESS_BUNDLE_CLASS_NAME = PRE + "BUSINESS_BUNDLE_CLASS_NAME" + POST; |
| public static final String CONTENT_BUSINESS_BUNDLE = PRE + "BUSINESS_BUNDLE" + POST; |
| public static final String CONTENT_BUSINESSDATA_DATABASE_SCHEMA = PRE + "BUSINESSDATA_DATABASE_SCHEMA" + POST; |
| public static final String CONTENT_BUSINESSDATA_DATASOURCE_NAME = PRE + "BUSINESSDATA_DATASOURCE_NAME" + POST; |
| public static final String CONTENT_BUSINESSDATA_PERSISTENCE_UNIT = PRE + "BUSINESSDATA_PERSISTENCE_UNIT" + POST; |
| public static final String CONTENT_VAACLIPSE_THEME = PRE + "VAACLIPSE_THEME" + POST; |
| |
| public static final String CONTENT_BASIC_PROJECT_NAME = PRE + "BASIC_PROJECT_NAME" + POST; |
| public static final String CONTENT_BASIC_SYMBOLIC_NAME = PRE + "BASIC_SYMBOLIC_NAME" + POST; |
| public static final String CONTENT_MODEL_PROJECT_NAME = PRE + "MODEL_PROJECT_NAME" + POST; |
| public static final String CONTENT_MODEL_PROJECT_PACKAGE_NAME = PRE + "MODEL_PROJECT_PACKAGE_NAME" + POST; |
| public static final String CONTENT_MODEL_SYMBOLIC_NAME = PRE + "MODEL_SYMBOLIC_NAME" + POST; |
| public static final String CONTENT_PRODUCT_PROJECT_NAME = PRE + "PRODUCT_PROJECT_NAME" + POST; |
| public static final String CONTENT_PRODUCT_SYMBOLIC_NAME = PRE + "PRODUCT_SYMBOLIC_NAME" + POST; |
| public static final String CONTENT_APPLICATION_PROJECT_NAME = PRE + "APPLICATION_PROJECT_NAME" + POST; |
| public static final String CONTENT_APPLICATION_SYMBOLIC_NAME = PRE + "APPLICATION_SYMBOLIC_NAME" + POST; |
| public static final String CONTENT_AGGREGATOR_PROJECT_NAME = PRE + "AGGREGATOR_PROJECT_NAME" + POST; |
| public static final String CONTENT_AGGREGATOR_SYMBOLIC_NAME = PRE + "AGGREGATOR_SYMBOLIC_NAME" + POST; |
| public static final String CONTENT_FEATURE_PROJECT_NAME = PRE + "FEATURE_PROJECT_NAME" + POST; |
| public static final String CONTENT_FEATURE_SYMBOLIC_NAME = PRE + "FEATURE_SYMBOLIC_NAME" + POST; |
| |
| public static final String CONTENT_MOCK_PRODUCT_DATA_FORCE = PRE + "MOCK_PRODUCT_DATA_FORCE" + POST; |
| public static final String CONTENT_MOCK_PRODUCT_DATA_PROJECT_NAME = PRE + "MOCK_PRODUCT_DATA_PROJECT_NAME" + POST; |
| public static final String CONTENT_MOCK_AUTHENTICATION_DATA_FORCE = PRE + "MOCK_AUTHENTICATION_DATA_FORCE" + POST; |
| public static final String CONTENT_MOCK_BLOB_DATA_FORCE = PRE + "MOCK_BLOB_DATA_FORCE" + POST; |
| |
| public static final String CONTENT_PRODUCT_PORT_NO = PRE + "PRODUCT_PORT_NO" + POST; |
| public static final String CONTENT_PRODUCT_URL_PATH = PRE + "PRODUCT_URL_PATH" + POST; |
| public static final String CONTENT_PRODUCT_DESKTOP_URL_PATH = PRE + "PRODUCT_DESKTOP_URL_PATH" + POST; |
| public static final String CONTENT_PRODUCT_MOBILE_URL_PATH = PRE + "PRODUCT_MOBILE_URL_PATH" + POST; |
| |
| public static final String CONTENT_PROJECT_FILE_PATH = PRE + "PROJECT_FILE_PATH" + POST; |
| |
| public static final String CONTENT_THEME_SYMBOLIC_BUNDLE_NAME = PRE + "THEME_SYMBOLIC_BUNDLE_NAME" + POST; |
| public static final String CONTENT_THEME_SYMBOLIC_NAME = PRE + "THEME_SYMBOLIC_NAME" + POST; |
| public static final String CONTENT_THEME_PROJECT_NAME = PRE + "THEME_PROJECT_NAME" + POST; |
| |
| public static final String CONTENT_REQUIRED_FEATURES = PRE + "REQUIRED_FEATURES" + POST; |
| public static final String CONTENT_REQUIRED_PLUGINS = PRE + "REQUIRED_PLUGINS" + POST; |
| public static final String CONTENT_RECOMMENDED_PLUGINS = PRE + "RECOMMENDED_PLUGINS" + POST; |
| public static final String CONTENT_REQUIRED_CONFIGURATIONS = PRE + "REQUIRED_CONFIGURATIONS" + POST; |
| public static final String CONTENT_RECOMMENDED_CONFIGURATIONS = PRE + "RECOMMENDED_CONFIGURATIONS" + POST; |
| |
| public static final String CONTENT_ENTITY_PROPERTY_BASE_ID = PRE + "ENTITY_PROPERTY_BASE_ID" + POST; |
| public static final String CONTENT_ENTITY_PROPERTY_BASE_UUID = PRE + "ENTITY_PROPERTY_BASE_UUID" + POST; |
| |
| public static final String CONTENT_PROJECT_LOC = PRE + "PROJECT_LOC" + POST; |
| private static final String DEFAULT_PROJECT_LOC = "${project_loc}"; |
| |
| protected static final String CONTENT_BREE_VERSION = PRE + "BREE_VERSION" + POST; |
| protected static final String CONTENT_XMS_SIZE = PRE + "XMS_SIZE" + POST; |
| protected static final String CONTENT_XMX_SIZE = PRE + "XMX_SIZE" + POST; |
| |
| private static final String BINARY_PREFIX_EXTENSION = "BINARY."; |
| public static final String TEMPLATE_POSTFIX_EXTENSION = ".TEMPLATE"; |
| private static final String NO_COMMENT_TEMPLATE_POSTFIX_EXTENSION = ".TEMPLATE_NO_COMMENT"; |
| public static final String TEMPLATE_BASE_PATH = "/wizardtemplates/"; |
| protected static final String BASIC_TEMPLATE = "__basic__"; |
| protected static final String PRODUCT_TEMPLATE = "__product__"; |
| |
| protected CommonProjectWizardType wizardType; |
| protected BundleType bundleType; |
| protected IPath projectLocation; |
| protected String postfix; |
| |
| public static enum BundleType { |
| AGGREGATOR, APPLICATION, FEATURE, MODEL, PRODUCT, THEME |
| } |
| |
| public static enum IgnoreFileType { |
| ADDONS, IGNORE |
| } |
| |
| private static final String[] binaryExtensions = { "bmp", "eot", "ico", "gif", "jar", "jpeg", "jpg", "png", "ttf", |
| "woff" }; |
| |
| private static final String[] lu_postfixes = { ".entity", ".dto", ".service" }; |
| |
| private static final Map<String, URL> wizardTemplateFiles = new TreeMap<String, URL>(); |
| |
| private final String MAVEN_POM_FILE = "pom.xml"; |
| |
| private Map<String, URL> getWizardTemplateFiles() { |
| if (wizardTemplateFiles.isEmpty()) { |
| Enumeration<URL> files = thisBundle().findEntries("/", "*", true); |
| Gofl.log(this, "findFilesInBundle('/')"); |
| Gofl.log(this, "files==NULL: <" + (files == null) + " >"); |
| if (files != null) { |
| // DONT'T DO THIS!!!! Gofl.log(this, "files.hasMoreElements(): |
| // <"+(files.hasMoreElements())+" >" ); |
| } |
| while (files != null && files.hasMoreElements()) { |
| URL fileURL = files.nextElement(); |
| String filePath = fileURL.getFile(); |
| if (filePath.contains(TEMPLATE_BASE_PATH) && !filePath.contains("/bin/") && isPomFileAllowed(filePath)) { |
| wizardTemplateFiles.put(filePath, fileURL); |
| Gofl.log(this, " - " + filePath); |
| } |
| } |
| } |
| return wizardTemplateFiles; |
| } |
| |
| private boolean isPomFileAllowed(String filePath) { |
| if (filePath != null && filePath.contains(MAVEN_POM_FILE)){ |
| return ProductConfiguration.isMavenActivated(); |
| } |
| return true; |
| } |
| |
| private static boolean isBinaryFile(String filePath) { |
| if (filePath.contains(BINARY_PREFIX_EXTENSION)) { |
| return true; |
| } else { |
| String[] items = filePath.split("\\."); |
| String fileExtension = items[items.length - 1].toLowerCase(); |
| return (Arrays.asList(binaryExtensions).contains(fileExtension)); |
| } |
| } |
| |
| public BasicProjectInfo(CommonProjectWizardType wizardType) { |
| this.postfix = ""; |
| this.wizardType = wizardType; |
| switch (wizardType) { |
| case AllInOneDSLs: |
| this.bundleType = BundleType.MODEL; |
| setBusinessBundle("Example Business"); |
| setMasterTemplate(AllInOneDSLsProjectMasterTemplate.EMPTY); |
| break; |
| case Theme: |
| this.bundleType = BundleType.THEME; |
| this.masterTemplate = ThemeProjectMasterTemplate.OSBPDEFAULT; |
| setBusinessBundle("Example"); |
| break; |
| } |
| } |
| |
| private void useForAnyFactory() { |
| productFileFeatures = new ProductFileFeatures(ProductConfiguration.prefs(), dataSourceForAuthentication, |
| dataSourceForBLOB, dataSourceForBPM, dataSourceForBusinessData); |
| productFileConfigurations = new ProductFileConfigurations(ProductConfiguration.prefs(), |
| dataSourceForAuthentication, dataSourceForBLOB, dataSourceForBPM, dataSourceForBusinessData); |
| } |
| |
| public void useForProductFactory() { |
| useForAnyFactory(); |
| postfix = ""; |
| templateFiles = null; |
| switch (wizardType) { |
| case AllInOneDSLs: |
| bundleType = BundleType.PRODUCT; |
| break; |
| case Theme: |
| break; |
| } |
| } |
| |
| public void useForApplicationFactory() { |
| // useForAnyFactory(); |
| templateFiles = null; |
| this.postfix = ""; |
| switch (wizardType) { |
| case AllInOneDSLs: |
| bundleType = BundleType.APPLICATION; |
| break; |
| case Theme: |
| break; |
| } |
| } |
| |
| public void useForFeatureFactory() { |
| // useForAnyFactory(); |
| templateFiles = null; |
| this.postfix = ""; |
| switch (wizardType) { |
| case AllInOneDSLs: |
| bundleType = BundleType.FEATURE; |
| break; |
| case Theme: |
| break; |
| } |
| } |
| |
| public void useForAggregatorFactory() { |
| templateFiles = null; |
| this.postfix = ""; |
| switch (wizardType) { |
| case AllInOneDSLs: |
| bundleType = BundleType.AGGREGATOR; |
| break; |
| case Theme: |
| break; |
| } |
| } |
| |
| public void useForModelFactory(String postfix) { |
| // useForAnyFactory(); |
| templateFiles = null; |
| this.postfix = postfix; |
| switch (wizardType) { |
| case AllInOneDSLs: |
| bundleType = BundleType.MODEL; |
| break; |
| case Theme: |
| break; |
| } |
| } |
| |
| public void useForThemeFactory() { |
| useForAnyFactory(); |
| postfix = ""; |
| templateFiles = null; |
| switch (wizardType) { |
| case AllInOneDSLs: |
| break; |
| case Theme: |
| bundleType = BundleType.THEME; |
| break; |
| } |
| } |
| |
| protected static boolean isDirectory(String filePath) { |
| return (filePath.trim().isEmpty() || filePath.trim().endsWith("/")); |
| } |
| |
| private String addPersistenceUnitConfiguration(String persistenceUnit, String dataSourceName) { |
| DataSourceConfiguration dsc = ProductConfiguration.prefs().getDataSource(dataSourceName); |
| return "\n" + "persistenceUnit/" + persistenceUnit + "/batchWriting=" + dsc.getDefaultBatchWriting() + "\n" |
| + "persistenceUnit/" + persistenceUnit + "/batchWritingSize=1000\n" + "persistenceUnit/" |
| + persistenceUnit + "/cacheStatements=true\n" + "persistenceUnit/" + persistenceUnit |
| + "/cacheStatementsSize=200\n" + "persistenceUnit/" + persistenceUnit |
| + "/ddlGeneration=create-or-extend-tables\n" + "persistenceUnit/" + persistenceUnit |
| + "/deployOnStartup=true\n" + "persistenceUnit/" + persistenceUnit + "/jndiName=" + dataSourceName |
| + "\n" + "persistenceUnit/" + persistenceUnit + "/loggingLevel=off\n" + "persistenceUnit/" |
| + persistenceUnit + "/persistenceXMLPath=META-INF/persistence.xml\n" + "persistenceUnit/" |
| + persistenceUnit + "/queryCache=true\n" + "persistenceUnit/" + persistenceUnit + "/schema=" |
| + dsc.getDefaultSchemaName()+ persistenceUnit + "\n"; |
| } |
| |
| private final static String PRODUCTION_PREFERENCES = ".metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.osbp.production.prefs"; |
| |
| public String getCloneWorkspaceProductConfiguration() { |
| String clone = ""; |
| clone += ProductConfigurationPrefs.BUSINESS_BUNDLE_CLASS_NAME + "=" + getBusinessBundleClassName(); |
| clone += "\n" + ProductConfigurationPrefs.getCloneWorkspaceProductConfiguration(); |
| clone += "\n" + ProductConfigurationPrefs.AUTHENTICATION_NODE + "/" |
| + ProductConfigurationPrefs.AUTHENTICATION_ENCRYPT_PASSWORDS + "=" |
| + (MockDataGenerateType.NONE.equals(mockAuthenticationDataGenerateType) ? "false" : "true"); |
| clone += "\n" + ProductConfigurationPrefs.SHIRO_NODE + "/" + ProductConfigurationPrefs.SHIRO_PROTOCOL_DATASOURCE |
| + "=" + getDataSourceForAuthentication(); |
| clone += "\n" + ProductConfigurationPrefs.SHIRO_NODE + "/" + ProductConfigurationPrefs.SHIRO_PROTOCOL_UNIT + "=" |
| + ProductConfigurationPrefs.PERSISTENCE_UNIT_AUTHENTICATION; |
| // clone += |
| // "\n"+ProductConfigurationPrefs.DATASOURCE_FOR_AUTHENTICATION+"="+getDataSourceForAuthentication(); |
| // clone += |
| // "\n"+ProductConfigurationPrefs.DATASOURCE_FOR_BLOB+"="+getDataSourceForBLOB(); |
| // clone += |
| // "\n"+ProductConfigurationPrefs.DATASOURCE_FOR_BPM+"="+getDataSourceForBPM(); |
| // clone += |
| // "\n"+ProductConfigurationPrefs.DATASOURCE_FOR_BUSINESSDATA+"="+getDataSourceForBusinessData(); |
| clone += addPersistenceUnitConfiguration(ProductConfigurationPrefs.PERSISTENCE_UNIT_AUTHENTICATION, |
| getDataSourceForAuthentication()); |
| clone += addPersistenceUnitConfiguration(ProductConfigurationPrefs.PERSISTENCE_UNIT_BLOB, |
| getDataSourceForBLOB()); |
| clone += addPersistenceUnitConfiguration(ProductConfigurationPrefs.PERSISTENCE_UNIT_BPM, getDataSourceForBPM()); |
| clone += addPersistenceUnitConfiguration(ProductConfigurationPrefs.PERSISTENCE_UNIT_BUSINESSDATA, |
| getDataSourceForBusinessData()); |
| if (templateFiles.containsKey(PRODUCTION_PREFERENCES)) { |
| clone += "\n" + templateFiles.get(PRODUCTION_PREFERENCES).getGeneratedFileContent().trim(); |
| } |
| return clone; |
| } |
| |
| public class TemplateFile { |
| private final String bundlePath; |
| private final String relativePath; |
| private final URL sourceUrl; |
| private final boolean preGeneratedComment; |
| |
| protected TemplateFile(String bundlePath, String relativePath, URL sourceUrl, boolean preGeneratedComment) { |
| this.bundlePath = bundlePath; |
| this.relativePath = relativePath; |
| this.sourceUrl = sourceUrl; |
| this.preGeneratedComment = preGeneratedComment; |
| } |
| |
| protected boolean isDirectory() { |
| return BasicProjectInfo.isDirectory(relativePath); |
| } |
| |
| public String getGeneratedFilePathForXpand() { |
| for (IgnoreFileType ignoreFileType : IgnoreFileType.values()) { |
| if (relativePath.contains(ignoreFileType.name())) { |
| return ""; |
| } |
| } |
| return getGeneratedFilePath(); |
| } |
| |
| public String getGeneratedFilePath() { |
| String file = relativePath.replace(PROJECT_MAIN_PATH, ""); |
| file = file.replace(PROJECT_BASIC_NAME, PROJECT_MAIN_PREFIX + postfix); |
| file = file.replace(PROJECT_MAIN_PREFIX + postfix + "/", ""); |
| if (file.startsWith(PROJECT_SUB_PREFIX)) { |
| file = "../" + file.replace(PROJECT_PREFIX, BasicProjectInfo.this.getProjectName()); |
| } |
| if (isDirectory()) { |
| file += "README.TXT"; |
| } |
| return file.replace(BINARY_PREFIX_EXTENSION, "").replace(NO_COMMENT_TEMPLATE_POSTFIX_EXTENSION, "") |
| .replace(TEMPLATE_POSTFIX_EXTENSION, "") |
| .replace(FILE_BUSINESS_BUNDLE_CLASS_NAME, getBusinessBundleClassName()) |
| .replace(FILE_PROJECT_NAME, getProjectName()).replace(FILE_PROJECT_PATH, getProjectFilePath()) |
| .replace(FILE_THEME_BUNDLE_CLASS_NAME, getBasicSymbolicName()); |
| } |
| |
| private String showLinesFound(String content, String search) { |
| String found = ""; |
| String lines[] = content.split("\n"); |
| for (int line = 0; line < lines.length; line++) { |
| if (lines[line].contains(search)) { |
| found += " - line " + (line + 1) + ": " + lines[line] + "\n"; |
| } |
| } |
| return found; |
| } |
| |
| public boolean isNotEmpty() throws Exception { |
| String content = null; |
| try { |
| content = getOriginalFileContent(); |
| } catch (URISyntaxException e) { |
| } catch (IOException e) { |
| } |
| return content != null; |
| } |
| |
| public String getOriginalFileContent() throws Exception { |
| String content = ""; |
| if (preGeneratedComment) { |
| content = getWizardGeneratedFileComment(); |
| } |
| try { |
| InputStream fisSourceFile = new BufferedInputStream( |
| this.getClass().getClassLoader().getResourceAsStream(bundlePath)); |
| content = IOUtils.toString(fisSourceFile, "UTF-8"); |
| if (content != null) { |
| if (content.contains(IGNORE_THIS_FILE)) { |
| content = null; |
| } else if (content.trim().isEmpty()) { |
| content = null; |
| } |
| } |
| } catch (Exception e) { |
| Gofl.log(this, "getOriginalFileContent() - sourceUrl=" + sourceUrl.toString() + " - bundlePath=" |
| + bundlePath + " relativePath=" + relativePath); |
| Gofl.log(this, e); |
| throw e; |
| } |
| return content; |
| } |
| |
| public String getGeneratedFileContent() { |
| Gofl.log(this, "getGeneratedFileContent() " + relativePath + " binary=" + isBinaryFile(relativePath)); |
| String content = ""; |
| try { |
| if (isDirectory()) { |
| content = getWizardGeneratedFileComment(); |
| content += "\n\nThis directory is necessary for the bundle to be consistent!"; |
| } else { |
| if (preGeneratedComment) { |
| content = getWizardGeneratedFileComment(); |
| } |
| try { |
| String original = getOriginalFileContent(); |
| if (original != null) { |
| content += original; |
| } |
| } catch (Exception e) { |
| content += sourceUrl + " could not be loaded: " + e.getLocalizedMessage(); |
| } |
| } |
| } catch (Exception e) { |
| Gofl.log(this, |
| "getGeneratedFileContent() " + relativePath + ": exception " + e.getClass().getCanonicalName()); |
| Gofl.log(this, e); |
| } |
| if (!isBinaryFile(relativePath) && (content.contains(PRE))) { |
| content = content.replace(CONTENT_SAMPLE_VENDOR_NAME, getVendor()) |
| .replace(CONTENT_SAMPLE_VENDOR_COUNTRY, getTopLevelDomain().getNativeName()) |
| .replace(CONTENT_SAMPLE_VENDOR_ISO3166, getTopLevelDomain().getTopLevelDomain()) |
| .replace(CONTENT_BUNDLE_VERSION, getVersion()) |
| .replace(CONTENT_BUSINESS_BUNDLE_CLASS_NAME, getBusinessBundleClassName()) |
| .replace(CONTENT_BUSINESS_BUNDLE, getBusinessBundle()) |
| .replace(CONTENT_BUSINESSDATA_DATABASE_SCHEMA, getDatabaseSchemaForBusinessName()) |
| .replace(CONTENT_BUSINESSDATA_DATASOURCE_NAME, |
| ProductConfiguration.getPersistenceUnitJndiName( |
| ProductConfigurationPrefs.PERSISTENCE_UNIT_BUSINESSDATA)) |
| .replace(CONTENT_BUSINESSDATA_PERSISTENCE_UNIT, |
| ProductConfigurationPrefs.PERSISTENCE_UNIT_BUSINESSDATA) |
| .replace(CONTENT_VAACLIPSE_THEME, |
| (getVaaclipseTheme() == null ? DEFAULT_THEME_NAME : getVaaclipseTheme().getId())) |
| .replace(CONTENT_PROJECT_FILE_PATH, getProjectFilePath()) |
| .replace(CONTENT_BASIC_PROJECT_NAME, getBasicProjectName()) |
| .replace(CONTENT_BASIC_SYMBOLIC_NAME, getBasicSymbolicName()) |
| .replace(CONTENT_MOCK_AUTHENTICATION_DATA_FORCE, getMockAuthenticationDataForceFlag()) |
| .replace(CONTENT_MOCK_BLOB_DATA_FORCE, getMockBlobDataForceFlag()) |
| .replace(CONTENT_MOCK_PRODUCT_DATA_FORCE, getMockProductDataForceFlag()) |
| .replace(CONTENT_MOCK_PRODUCT_DATA_PROJECT_NAME, getMockProductDataProjectName()) |
| .replace(CONTENT_MODEL_PROJECT_NAME, getModelProjectName()) |
| .replace(CONTENT_MODEL_PROJECT_PACKAGE_NAME, getModelProjectPackageName()) |
| .replace(CONTENT_MODEL_SYMBOLIC_NAME, getModelSymbolicName()) |
| .replace(CONTENT_PRODUCT_PROJECT_NAME, getProductProjectName()) |
| .replace(CONTENT_APPLICATION_PROJECT_NAME, getApplicationProjectName()) |
| .replace(CONTENT_AGGREGATOR_PROJECT_NAME, getAggregatorProjectName()) |
| .replace(CONTENT_FEATURE_PROJECT_NAME, getFeatureProjectName()) |
| .replace(CONTENT_PRODUCT_SYMBOLIC_NAME, getProductSymbolicName()) |
| .replace(CONTENT_APPLICATION_SYMBOLIC_NAME, getApplicationSymbolicName()) |
| .replace(CONTENT_AGGREGATOR_SYMBOLIC_NAME, getAggregatorSymbolicName()) |
| .replace(CONTENT_FEATURE_SYMBOLIC_NAME, getFeatureSymbolicName()) |
| .replace(CONTENT_PRODUCT_PORT_NO, getProductPortNo()) |
| .replace(CONTENT_PRODUCT_URL_PATH, getProductDesktopUrlPath()) |
| .replace(CONTENT_PRODUCT_DESKTOP_URL_PATH, getProductDesktopUrlPath()) |
| .replace(CONTENT_PRODUCT_MOBILE_URL_PATH, getProductMobileUrlPath()) |
| .replace(CONTENT_THEME_SYMBOLIC_BUNDLE_NAME, getThisSymbolicName()) |
| .replace(CONTENT_THEME_SYMBOLIC_NAME, getBasicSymbolicName()) |
| .replace(CONTENT_THEME_PROJECT_NAME, getBasicSymbolicName()) |
| .replace(CONTENT_REQUIRED_FEATURES, getProductFileFeatures().getRequiredAsString()) |
| // .replace(CONTENT_RECOMMENDED_PLUGINS, |
| // getProductFileFeatures().getRecommendedAsString()) |
| .replace(CONTENT_REQUIRED_CONFIGURATIONS, getProductFileConfigurations().getRequiredAsString()) |
| .replace(CONTENT_RECOMMENDED_CONFIGURATIONS, |
| getProductFileConfigurations().getRecommendedAsString()) |
| .replace(CONTENT_ENTITY_PROPERTY_BASE_ID, getEntityPropertyBaseID()) |
| .replace(CONTENT_ENTITY_PROPERTY_BASE_UUID, getEntityPropertyBaseUUID()) |
| .replace(CONTENT_PROJECT_LOC, getProjectLoc()).replace(CONTENT_BREE_VERSION, "" + bree_version) |
| .replace(CONTENT_XMS_SIZE, "" + xms_size).replace(CONTENT_XMX_SIZE, "" + xmx_size) |
| // .replace(CONTENT_PERM_SIZE, ""+perm_size) |
| // .replace(CONTENT_MAX_PERMSIZE, ""+max_perm_size) |
| ; |
| if (content.contains(PRE)) { |
| IllegalArgumentException e = new IllegalArgumentException( |
| "variable could not be replaced in " + (sourceUrl == null ? "<null>" : sourceUrl.toString()) |
| + "\n" + showLinesFound(content, PRE)); |
| LOGGER.error("", e); |
| throw e; |
| } |
| } |
| return content; |
| } |
| |
| /* |
| * public String getMetaInfBundleName() { } |
| * |
| * public String getMetaInfBundleSymbolicName() { } |
| */ |
| |
| public boolean getCopyIfBinaryFile() { |
| boolean retcode = false; |
| if (isBinaryFile(relativePath)) { |
| Gofl.log(this, "getCopyIfBinaryFile() " + relativePath + " binary=" + isBinaryFile(relativePath)); |
| startExecute(); |
| try { |
| InputStream fisSourceFile = new BufferedInputStream( |
| this.getClass().getClassLoader().getResourceAsStream(bundlePath)); |
| byte[] bytes = IOUtils.toByteArray(fisSourceFile); |
| IPath targetPath = BasicProjectInfo.this.getLocationPath(); |
| targetPath = targetPath.append(getGeneratedFilePath()); |
| Files.write(Paths.get(targetPath.toString()), bytes); // creates, |
| // overwrites |
| retcode = true; |
| } catch (Exception e) { |
| LOGGER.error("ERROR copy binary '" + sourceUrl.toString() + "' to '" + getGeneratedFilePath() |
| + "' : " + e.getLocalizedMessage(), e); |
| Gofl.log(this, "ERROR copy binary '" + sourceUrl.toString() + "' to '" + getGeneratedFilePath() |
| + "' : " + e.getLocalizedMessage()); |
| } |
| endExecute(); |
| } |
| return retcode; |
| } |
| } |
| |
| private final static String OS_BEE_VENDOR = "Loetz GmbH&Co.KG, 69115 Heidelberg, Germany"; |
| private final static String LU_VENDOR = "Lunifera GmbH (Gross Enzersdorf)"; |
| private final static String SAMPLE_VENDER = OS_BEE_VENDOR; // ??? "Sample |
| // Corp., |
| // Smalltown, |
| // Sampleland"; |
| |
| private IProjectMasterTemplate masterTemplate; |
| private String vendor = SAMPLE_VENDER; |
| private TopLevelDomain topLevelDomain = TopLevelDomain.getDefault(); |
| private String companyDomain = "eclipse.osbp"; |
| private String businessBundle; |
| private String version = "0.0.1"; |
| private Map<String, Locale> languages = ProductConfiguration.getLanguages(); |
| private Map<String, TemplateFile> templateFiles; |
| // private String applicationProductBundle = |
| // "org.eclipse.osbp.vaaclipse.charts.demo"; |
| // private String jndiName = "CCNGDEFAULT"; |
| private String dataSourceForAuthentication; // ProductConfiguration.getDataSourceNameForAuthentication(); |
| private String dataSourceForBLOB; // ProductConfiguration.getDataSourceNameForBLOB(); |
| private String dataSourceForBPM; // ProductConfiguration.getDataSourceNameForBPM(); |
| private String dataSourceForBusinessData; // ProductConfiguration.getDataSourceNameForBusinessData(); |
| private MockDataGenerateType mockProductDataGenerateType = MockDataGenerateType.ONCE; |
| private MockDataGenerateType mockAuthenticationDataGenerateType = MockDataGenerateType.ONCE; |
| private MockDataGenerateType mockBlobDataGenerateType = MockDataGenerateType.ONCE; |
| private VaaclipseUiTheme vaaclipseTheme = VaaclipseUiTheme.forText(DEFAULT_THEME_NAME); |
| protected double bree_version = BREE_MINIMUM; |
| private int physical_size = 0; |
| private int xms_size = 4096; |
| private int xmx_size = 4096; |
| |
| // private int perm_size = 64; |
| // private int max_perm_size = 512; |
| |
| public void setTotalPhysicalMemoryInMB(int physicalMemoryMB) { |
| physical_size = physicalMemoryMB; |
| setXmsSizeInMB(physicalMemoryMB / 4); |
| setXmxSizeInMB(physicalMemoryMB / 4); |
| // max_perm_size = physicalMemoryMB / 32; |
| // perm_size = physicalMemoryMB / 8; |
| } |
| |
| public String getXmsSizeInMB() { |
| return "" + xms_size; |
| } |
| |
| public String getXmxSizeInMB() { |
| return "" + xmx_size; |
| } |
| |
| public String setXmsSizeInMB(int size) { |
| int min = physical_size / 64; |
| int max = physical_size / 2; |
| xms_size = Math.min(max, Math.max(min, size)); |
| return getXmsSizeInMB(); |
| } |
| |
| public String setXmxSizeInMB(int size) { |
| int min = physical_size / 64; |
| int max = physical_size / 2; |
| xmx_size = Math.min(max, Math.max(min, size)); |
| return getXmxSizeInMB(); |
| } |
| |
| public String getProductPortNo() { |
| return "" + productPortNo; |
| } |
| |
| public String getMockProductDataProjectName() { |
| return getBasicProjectName(); |
| } |
| |
| public String getMockProductDataForceFlag() { |
| switch (mockProductDataGenerateType) { |
| case EVERYTIME: |
| return "FORCE-"; |
| case NONE: |
| return "NEVER-"; |
| case ONCE: |
| return ""; |
| default: |
| return ""; |
| } |
| } |
| |
| public String getMockAuthenticationDataForceFlag() { |
| switch (mockAuthenticationDataGenerateType) { |
| case EVERYTIME: |
| return "FORCE-"; |
| case NONE: |
| return "NEVER-"; |
| case ONCE: |
| return ""; |
| default: |
| return ""; |
| } |
| } |
| |
| public String getMockBlobDataForceFlag() { |
| switch (mockBlobDataGenerateType) { |
| case EVERYTIME: |
| return "FORCE-"; |
| case NONE: |
| return "NEVER-"; |
| case ONCE: |
| return ""; |
| default: |
| return ""; |
| } |
| } |
| |
| public void setProductPortNo(String productPortNo) { |
| try { |
| this.productPortNo = Integer.parseInt(productPortNo); |
| } catch (NumberFormatException nfe) { |
| this.productPortNo = 0; |
| } |
| if (this.productPortNo <= 0) { |
| this.productPortNo = 8081; |
| } |
| } |
| |
| public String getProductDesktopUrlPath() { |
| return productDesktopUrlPath; |
| } |
| |
| private String generateLink(String url) { |
| return "<a href=\"" + url + "\">" + url + "</a>"; |
| } |
| |
| public String getProductLocalDesktopLink() { |
| return generateLink("http://localhost:" + getProductPortNo() + getProductDesktopUrlPath()); |
| } |
| |
| public String getProductMobileUrlPath() { |
| return productDesktopUrlPath + MOBILE_POSTFIX; |
| } |
| |
| public String getProductLocalMobileLink() { |
| return generateLink("http://localhost:" + getProductPortNo() + getProductMobileUrlPath()); |
| } |
| |
| public void setProductDesktopUrlPath(String productDesktopUrlPath) { |
| this.productDesktopUrlPath = productDesktopUrlPath; |
| } |
| |
| private final static String MOBILE_POSTFIX = "mobile"; |
| |
| private int productPortNo = 8081; |
| private String productDesktopUrlPath = "/charts"; |
| |
| private ProductFileFeatures productFileFeatures; |
| private ProductFileConfigurations productFileConfigurations; |
| |
| public String getDatabaseSchemaForBusinessName() { |
| return ProductConfiguration.workspacePrefs().getDataSource(dataSourceForBusinessData).getDefaultSchemaName(); |
| } |
| |
| @Override |
| public String getProjectName() { |
| generateProjectName(); |
| if (isExecuting() && bundleType != BundleType.AGGREGATOR) { |
| return getProjectName(super.getProjectName(), bundleType); |
| } else { |
| return super.getProjectName(); |
| } |
| } |
| |
| public String getBasicProjectName() { |
| generateProjectName(); |
| return super.getProjectName(); |
| } |
| |
| public String getModelProjectName() { |
| return getProjectName(BundleType.MODEL); |
| } |
| |
| public String getModelProjectPackageName() { |
| String projName = getProjectName(BundleType.MODEL); |
| return projName.endsWith("y") ? projName.substring(0,projName.lastIndexOf("y")).concat("ies") : projName.concat("s"); |
| } |
| |
| public String getProductProjectName() { |
| return getProjectName(BundleType.PRODUCT); |
| } |
| |
| public String getApplicationProjectName() { |
| return getProjectName(BundleType.APPLICATION); |
| } |
| |
| public String getAggregatorProjectName() { |
| return getProjectName(BundleType.AGGREGATOR); |
| } |
| |
| public String getFeatureProjectName() { |
| return getProjectName(BundleType.FEATURE); |
| } |
| |
| public String getThisProjectName() { |
| return getProjectName(bundleType); |
| } |
| |
| private String getProjectName(String projectName, BundleType type) { |
| String retcode = projectName; |
| if (type != null) { |
| retcode += "." + type.toString().toLowerCase(); |
| } |
| retcode += postfix; |
| return retcode; |
| } |
| |
| private String getProjectName(BundleType type) { |
| generateProjectName(); |
| return getProjectName(super.getProjectName(), type); |
| } |
| |
| public String getProjectFilePath() { |
| return getBasicProjectName().replace('.', '/'); |
| } |
| |
| public String getModelProjectPackageFilePath() { |
| return getModelProjectPackageName().replace('.', '/'); |
| } |
| |
| public ProductFileFeatures getProductFileFeatures() { |
| return productFileFeatures; |
| } |
| |
| public ProductFileConfigurations getProductFileConfigurations() { |
| return productFileConfigurations; |
| } |
| |
| public String getDefaultProjectLoc() { |
| if (ProductConfiguration.projectWizardUsesAbsoluteLocation() && (projectLocation != null)) { |
| return projectLocation.toOSString().replace("\\", "/"); |
| } |
| return DEFAULT_PROJECT_LOC; |
| } |
| |
| public String getProjectLoc() { |
| if (ProductConfiguration.projectWizardUsesAbsoluteLocation()) { |
| return Platform.getLocation().append(getBasicProjectName()).append(getApplicationProjectName()).toOSString() |
| .replace("\\", "/"); |
| } |
| return DEFAULT_PROJECT_LOC; |
| } |
| |
| // private Set<EnumDatabaseVendor> getNecessaryDataBaseVendors() { |
| // return |
| // ProductConfiguration.getNecessaryDataBaseVendors(ProductConfiguration.getPersistenceUnitNames()); |
| // } |
| |
| public String getEntityPropertyBaseID() { |
| DataSourceConfiguration ds = ProductConfiguration.getDataSource(dataSourceForBusinessData); |
| if (ds != null) { |
| return ds.getDatabaseVendor().getEntityPropertyBaseID(); |
| } |
| return "<unknown>"; |
| } |
| |
| public String getEntityPropertyBaseUUID() { |
| DataSourceConfiguration ds = ProductConfiguration.getDataSource(dataSourceForBusinessData); |
| if (ds != null) { |
| return ds.getDatabaseVendor().getEntityPropertyBaseUUID(); |
| } |
| return "<unknown>"; |
| } |
| |
| public String getBasicSymbolicName() { |
| // return |
| // BundleUtilities.generateSymbolicNameForPackage(getBasicProjectName()); |
| return getBasicProjectName(); |
| } |
| |
| public String getModelSymbolicName() { |
| // return |
| // BundleUtilities.generateSymbolicNameForPackage(getModelProjectName()); |
| return getModelProjectName(); |
| } |
| |
| public String getProductSymbolicName() { |
| // return |
| // BundleUtilities.generateSymbolicNameForPackage(getProductProjectName()); |
| return getProductProjectName(); |
| } |
| |
| public String getApplicationSymbolicName() { |
| // return |
| // BundleUtilities.generateSymbolicNameForPackage(getProductProjectName()); |
| return getApplicationProjectName(); |
| } |
| |
| public String getAggregatorSymbolicName() { |
| // return |
| // BundleUtilities.generateSymbolicNameForPackage(getProductProjectName()); |
| return getAggregatorProjectName(); |
| } |
| |
| public String getFeatureSymbolicName() { |
| // return |
| // BundleUtilities.generateSymbolicNameForPackage(getProductProjectName()); |
| return getFeatureProjectName(); |
| } |
| |
| public String getThisSymbolicName() { |
| // return |
| // BundleUtilities.generateSymbolicNameForPackage(getThisProjectName()); |
| return getThisProjectName(); |
| } |
| |
| public String getBusinessBundleClassName() { |
| return StringUtils.stripAccents(businessBundle.trim().toLowerCase().replace(" ", "").replace("-", "")); |
| } |
| |
| public String getBpmProject() { |
| return getBusinessBundleClassName(); |
| } |
| |
| public String getWizardGeneratedFileComment() { |
| return "/**\n" + |
| " * Copyright (c) 2011, " + getActualYear() + " - " + getCopyrightVendor() + "\n" + |
| " * All rights reserved. This program and the accompanying materials\n" + |
| " * are made available under the terms of the Eclipse Public License 2.0 \n" + |
| " * which accompanies this distribution, and is available at\n" + |
| " * http://www.eclipse.org/legal/epl-v10.html" + |
| " *\n" + |
| " * Contributors: \n" + |
| " *\t\t" + getCopyrightVendor() + "\n" + |
| " */\n" + |
| "\n"; |
| } |
| |
| protected Bundle thisBundle() { |
| return Activator.getInstance().getBundle(); |
| } |
| |
| public Set<String> getAllProjectPostFixes() { |
| Set<String> projectPostFixes = new HashSet<String>(); |
| // Map<String, TemplateFile> map = new HashMap<String, TemplateFile>(); |
| // // --- first get all basic templates --- |
| // findTemplateFiles(map, null, TEMPLATE_BASE_PATH + BundleType.MODEL.toString() + "/" + BASIC_TEMPLATE + "/"); |
| // // --- second overwrite with specific templates --- |
| // findTemplateFiles(map, null, |
| // TEMPLATE_BASE_PATH + BundleType.MODEL.toString() + "/" + masterTemplate.toString() + "/"); |
| // for (TemplateFile templateFile : map.values()) { |
| // String postfix = templateFile.relativePath.split("/")[0]; |
| // if (!PROJECT_BASIC_NAME.equals(postfix) && postfix.startsWith(PROJECT_PREFIX)) { |
| // projectPostFixes.add(postfix.replace(PROJECT_PREFIX, "")); |
| // } |
| // } |
| String searchPath = TEMPLATE_BASE_PATH + BundleType.MODEL.toString() + "/" + BASIC_TEMPLATE + "/"; |
| for (String filePath : getWizardTemplateFiles().keySet()) { |
| if (filePath.startsWith(searchPath)) { |
| String relativePath = filePath.replace(searchPath, ""); |
| if ((relativePath != null) && !relativePath.isEmpty()) { |
| if (!relativePath.contains(PROJECT_MAIN_PREFIX + "." + BASIC_TEMPLATE)){ |
| projectPostFixes.add(relativePath.split("/")[0].replace(PROJECT_PREFIX, "")); |
| } |
| } |
| } |
| } |
| Gofl.log(this, " - projectPostFixes: " + projectPostFixes); |
| return projectPostFixes; |
| } |
| |
| public Collection<TemplateFile> getTemplateFiles() { |
| if (templateFiles == null) { |
| Gofl.log(this, "getTemplateFile()"); |
| // A LinkedHashMap instead of an HashMap is required to ensure that the basic entries will be the first template files |
| // to be considered and that the specific templates will overwrite the basic templates when needed. |
| templateFiles = new LinkedHashMap<String, TemplateFile>(); |
| // --- first get all basic templates --- |
| findTemplateFiles(templateFiles, postfix, |
| TEMPLATE_BASE_PATH + BasicProjectInfo.this.bundleType.toString() + "/" + BASIC_TEMPLATE + "/"); |
| // --- second overwrite with specific templates --- |
| findTemplateFiles(templateFiles, postfix, TEMPLATE_BASE_PATH + BasicProjectInfo.this.bundleType.toString() |
| + "/" + masterTemplate.toString() + "/"); |
| Gofl.log(this, "getTemplateFile() found " + templateFiles.size() + " template files"); |
| } |
| return templateFiles.values(); |
| } |
| |
| private void findTemplateFiles(Map<String, TemplateFile> map, String targetPostFix, String searchPath) { |
| Gofl.log(this, "findTemplateFiles('" + searchPath + "') for target postfix: '" + targetPostFix + "'"); |
| for (String filePath : getWizardTemplateFiles().keySet()) { |
| if (filePath.startsWith(searchPath)) { |
| String relativePath = filePath.replace(searchPath, ""); |
| if ((relativePath != null) && !relativePath.isEmpty()) { |
| if (relativePath.startsWith(PROJECT_BASIC_NAME + "/") || relativePath.startsWith(PROJECT_MAIN_PREFIX + targetPostFix + "/")){ |
| Gofl.log(this, " - " + filePath); |
| boolean generateComment = filePath.endsWith(TEMPLATE_POSTFIX_EXTENSION); |
| TemplateFile templateFile = new TemplateFile(filePath, relativePath, |
| getWizardTemplateFiles().get(filePath), generateComment); |
| if (templateFile.isDirectory()) { |
| Gofl.log(this, " " + filePath + " / " + relativePath + " " + generateComment |
| + " templateFile is a directory"); |
| map.put(relativePath, templateFile); |
| } else { |
| Gofl.log(this, " " + filePath + " / " + relativePath + " " + generateComment |
| + " templateFile is a file"); |
| try { |
| if (templateFile.isNotEmpty()) { |
| map.put(relativePath, templateFile); |
| } else { |
| map.remove(relativePath); |
| } |
| } catch (Exception e) { |
| map.remove(relativePath); |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| /** |
| * use setFirstLevelDomain(), setSecondLevelDomain() and setBusinessBundle() |
| * instead! |
| */ |
| @Override |
| @Deprecated |
| public final void setProjectName(String projectName) { |
| } |
| |
| /** |
| * <b>important! do not use underscore!</b> |
| * |
| * @see org.eclipse.osbp.xtext.reportdsl.jvmmodel.Constants#ODA_PROP_CONFIG_KEY_SEPARATOR |
| */ |
| public static final String REPLACING = ""; |
| |
| /** |
| * @param topLevelDomain |
| * @param companyDomain |
| * @param businessBundle |
| * @return |
| */ |
| public String createProjectName(String topLevelDomain, String companyDomain, String businessBundle) { |
| return StringUtils |
| .stripAccents(topLevelDomain.trim().toLowerCase().replace(" ", REPLACING).replace("-", REPLACING)) |
| + "." |
| + StringUtils.stripAccents( |
| companyDomain.trim().toLowerCase().replace(" ", REPLACING).replace("-", REPLACING)) |
| + "." + StringUtils.stripAccents( |
| businessBundle.trim().toLowerCase().replace(" ", REPLACING).replace("-", REPLACING)); |
| } |
| |
| protected void generateProjectName() { |
| super.setProjectName(createProjectName(topLevelDomain.getTopLevelDomain(), companyDomain, businessBundle)); |
| // setApplicationProductBundle(super.getProjectName()); |
| } |
| |
| public MockDataGenerateType getMockProductDataGenerateType() { |
| return mockProductDataGenerateType; |
| } |
| |
| public void setMockProductDataGenerateType(String item) { |
| setMockProductDataGenerateType(MockDataGenerateType.byText(item)); |
| } |
| |
| public void setMockProductDataGenerateType(MockDataGenerateType type) { |
| this.mockProductDataGenerateType = type; |
| } |
| |
| public MockDataGenerateType getMockAuthenticationDataGenerateType() { |
| return mockAuthenticationDataGenerateType; |
| } |
| |
| public void setMockAuthenticationDataGenerateType(String item) { |
| setMockAuthenticationDataGenerateType(MockDataGenerateType.byText(item)); |
| } |
| |
| public void setMockAuthenticationDataGenerateType(MockDataGenerateType type) { |
| this.mockAuthenticationDataGenerateType = type; |
| } |
| |
| public MockDataGenerateType getMockBlobDataGenerateType() { |
| return mockBlobDataGenerateType; |
| } |
| |
| public void setMockBlobDataGenerateType(String item) { |
| setMockBlobDataGenerateType(MockDataGenerateType.byText(item)); |
| } |
| |
| public void setMockBlobDataGenerateType(MockDataGenerateType type) { |
| this.mockBlobDataGenerateType = type; |
| } |
| |
| public IProjectMasterTemplate getMasterTemplate() { |
| return masterTemplate; |
| } |
| |
| public void setMasterTemplate(String item) { |
| setMasterTemplate(AllInOneDSLsProjectMasterTemplate.byText(item)); |
| } |
| |
| public void setMasterTemplate(IProjectMasterTemplate masterTemplate) { |
| this.masterTemplate = masterTemplate; |
| if (wizardType == CommonProjectWizardType.AllInOneDSLs) { |
| setBusinessBundle(masterTemplate.getDescription().replace(" project", "").replace(" Project", "")); |
| } |
| } |
| |
| public String getCopyrightVendor() { |
| if (isLuPostfix()) { |
| return OS_BEE_VENDOR + ", " + LU_VENDOR; |
| } |
| return OS_BEE_VENDOR; |
| } |
| |
| public boolean isLuPostfix(){ |
| if (Arrays.asList(lu_postfixes).contains(postfix)) { |
| return true; |
| } |
| return false; |
| } |
| |
| private String getActualYear() { |
| return Integer.toString(Calendar.getInstance().get(Calendar.YEAR)); |
| } |
| |
| public String getVendor() { |
| return vendor; |
| } |
| |
| public void setVendor(String vendor) { |
| this.vendor = vendor; |
| } |
| |
| public TopLevelDomain getTopLevelDomain() { |
| return topLevelDomain; |
| } |
| |
| public void setTopLevelDomain(String topLevelDomain) { |
| setTopLevelDomain(TopLevelDomain.forTopLevelDomain(topLevelDomain)); |
| } |
| |
| public void setTopLevelDomain(TopLevelDomain topLevelDomain) { |
| this.topLevelDomain = topLevelDomain; |
| generateProjectName(); |
| } |
| |
| public String getCompanyDomain() { |
| return companyDomain; |
| } |
| |
| public void setCompanyDomain(String companyDomain) { |
| this.companyDomain = companyDomain; |
| generateProjectName(); |
| } |
| |
| public String getBusinessBundle() { |
| return businessBundle; |
| } |
| |
| public void setBusinessBundle(String businessBundle) { |
| this.businessBundle = businessBundle; |
| generateProjectName(); |
| productDesktopUrlPath = "/" + getBusinessBundleClassName(); |
| } |
| |
| public String getVersion() { |
| return version; |
| } |
| |
| public void setVersion(String version) { |
| this.version = version; |
| } |
| |
| public Map<String, Locale> getLanguages() { |
| return languages; |
| } |
| |
| public void setLanguages(Map<String, Locale> languages) { |
| this.languages = languages; |
| } |
| |
| public String getDataSourceForAuthentication() { |
| return dataSourceForAuthentication; |
| } |
| |
| public String getDataSourceForBLOB() { |
| return dataSourceForBLOB; |
| } |
| |
| public String getDataSourceForBPM() { |
| return dataSourceForBPM; |
| } |
| |
| public String getDataSourceForBusinessData() { |
| return dataSourceForBusinessData; |
| } |
| |
| public void setDataSourceForAuthentication(String dataSource) { |
| this.dataSourceForAuthentication = dataSource; |
| } |
| |
| public void setDataSourceForBLOB(String dataSource) { |
| this.dataSourceForBLOB = dataSource; |
| } |
| |
| public void setDataSourceForBPM(String dataSource) { |
| this.dataSourceForBPM = dataSource; |
| } |
| |
| public void setDataSourceForBusinessData(String dataSource) { |
| this.dataSourceForBusinessData = dataSource; |
| } |
| |
| // private static final String UNDERSCORE = "_"; |
| |
| // public String getProjectPath() { |
| // return getProjectName().replace('.', '/'); |
| // } |
| |
| // public String getSymbolicBundleName() { |
| // // String bundleName = |
| // StringUtils.stripAccents(topLevelDomain.getTopLevelDomain().replace(" ", |
| // UNDERSCORE).replace("-", UNDERSCORE)) |
| // // |
| // +UNDERSCORE+StringUtils.stripAccents(companyDomain.trim().toLowerCase().replace(" |
| // ", UNDERSCORE).replace("-", UNDERSCORE)) |
| // // |
| // +UNDERSCORE+StringUtils.stripAccents(businessBundle.trim().toLowerCase().replace(" |
| // ", UNDERSCORE).replace("-", UNDERSCORE)); |
| // // while (bundleName.contains(UNDERSCORE+UNDERSCORE)) { |
| // // bundleName = bundleName.replace(UNDERSCORE+UNDERSCORE, UNDERSCORE); |
| // // } |
| // String bundleName = getProjectName(); |
| // return Utilities.getSymbolicName(bundleName); |
| // } |
| |
| public VaaclipseUiTheme getVaaclipseTheme() { |
| return vaaclipseTheme; |
| } |
| |
| public void setVaaclipseTheme(String vaaclipseTheme) { |
| setVaaclipseTheme(VaaclipseUiTheme.forText(vaaclipseTheme)); |
| } |
| |
| public void setVaaclipseTheme(VaaclipseUiTheme vaaclipseTheme) { |
| this.vaaclipseTheme = vaaclipseTheme; |
| } |
| |
| private int isExecuting = 0; |
| |
| private boolean isExecuting() { |
| return isExecuting > 0; |
| } |
| |
| public void startExecute() { |
| isExecuting++; |
| } |
| |
| public void endExecute() { |
| isExecuting--; |
| } |
| |
| public void setProjectLocation(IPath projectLocation) { |
| this.projectLocation = projectLocation; |
| } |
| |
| public boolean isProjectPostFix(String postfix) { |
| return postfix!=null?postfix.equals(this.postfix):false; |
| } |
| |
| public void setProjectPostFix(String postfix) { |
| this.postfix = postfix; |
| } |
| |
| public String getManifestTemplate(ManifestAttribute manifestAttribute) { |
| String result = ""; |
| for (TemplateFile templateFile : getTemplateFiles()) { |
| if (templateFile.getGeneratedFilePath().contains(MANIFEST_MF_ADDONS)) { |
| try { |
| String[] content = templateFile.getOriginalFileContent().split("\n"); |
| boolean inside = false; |
| for (String line : content) { |
| if (inside) { |
| if (!line.isEmpty() && !line.startsWith("#")) { |
| if (line.charAt(0) == ' ') { |
| result += "," + line.trim(); |
| } else { |
| inside = false; |
| break; |
| } |
| } |
| } else { |
| inside = line.startsWith(manifestAttribute.name()); |
| } |
| } |
| } catch (Exception e) { |
| e.printStackTrace(); |
| } |
| break; |
| } |
| } |
| return result; |
| } |
| } |