Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2012-05-31 05:17:20 -0400
committerMartin Taal2012-05-31 05:17:20 -0400
commitfddb613786e477f1d039981b59e99e939851c7be (patch)
treebf3b276ab2cb050b1abd695cb92e3045325144f3 /generator/org.eclipse.emf.texo.orm
parent6aa93994502bef899e40207b39d3c2a0effcdb1e (diff)
downloadorg.eclipse.emf.texo-fddb613786e477f1d039981b59e99e939851c7be.tar.gz
org.eclipse.emf.texo-fddb613786e477f1d039981b59e99e939851c7be.tar.xz
org.eclipse.emf.texo-fddb613786e477f1d039981b59e99e939851c7be.zip
Implemented ORM Mapping Options concept
Diffstat (limited to 'generator/org.eclipse.emf.texo.orm')
-rw-r--r--generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMMappingOptions.java83
-rwxr-xr-xgenerator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/ormannotations/EPackageORMAnnotation.java39
2 files changed, 95 insertions, 27 deletions
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMMappingOptions.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMMappingOptions.java
new file mode 100644
index 00000000..384e6d17
--- /dev/null
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMMappingOptions.java
@@ -0,0 +1,83 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2012 Springsite BV (The Netherlands) and others
+ * 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:
+ * Martin Taal - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id: StandardORMGenerator.java,v 1.2 2011/08/26 05:34:12 mtaal Exp $
+ */
+
+package org.eclipse.emf.texo.orm.annotator;
+
+/**
+ * Container for a set of ORM mapping options, either set by tests or by the project properties.
+ *
+ * @author <a href="mtaal@elver.org">Martin Taal</a>
+ */
+public class ORMMappingOptions {
+
+ private static ORMMappingOptions defaultOptions = null;
+
+ public static ORMMappingOptions getDefaultOptions() {
+ return defaultOptions;
+ }
+
+ public static void setDefaultOptions(ORMMappingOptions defaultOptions) {
+ ORMMappingOptions.defaultOptions = defaultOptions;
+ }
+
+ private boolean addOrderColumnToListMappings = false;
+ private boolean enforceUniqueNames = false;
+ private boolean renameSQLReservedNames = false;
+ private boolean generateFullDbSchemaNames = false;
+ private int maximumSqlNameLength = -1;
+
+ public boolean isAddOrderColumnToListMappings() {
+ return addOrderColumnToListMappings;
+ }
+
+ public void setAddOrderColumnToListMappings(boolean addOrderColumnToListMappings) {
+ this.addOrderColumnToListMappings = addOrderColumnToListMappings;
+ }
+
+ public boolean isEnforceUniqueNames() {
+ return enforceUniqueNames;
+ }
+
+ public void setEnforceUniqueNames(boolean enforceUniqueNames) {
+ this.enforceUniqueNames = enforceUniqueNames;
+ }
+
+ public boolean isRenameSQLReservedNames() {
+ return renameSQLReservedNames;
+ }
+
+ public void setRenameSQLReservedNames(boolean renameSQLReservedNames) {
+ this.renameSQLReservedNames = renameSQLReservedNames;
+ }
+
+ public boolean isGenerateFullDbSchemaNames() {
+ return generateFullDbSchemaNames;
+ }
+
+ public void setGenerateFullDbSchemaNames(boolean generateFullDbSchemaNames) {
+ this.generateFullDbSchemaNames = generateFullDbSchemaNames;
+ }
+
+ public int getMaximumSqlNameLength() {
+ return maximumSqlNameLength;
+ }
+
+ public void setMaximumSqlNameLength(int maximumSqlNameLength) {
+ this.maximumSqlNameLength = maximumSqlNameLength;
+ }
+
+} \ No newline at end of file
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/ormannotations/EPackageORMAnnotation.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/ormannotations/EPackageORMAnnotation.java
index 363e9a00..1f1d8661 100755
--- a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/ormannotations/EPackageORMAnnotation.java
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/ormannotations/EPackageORMAnnotation.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.texo.annotations.annotationsmodel.EPackageAnnotation;
import org.eclipse.emf.texo.generator.AnnotationManager;
import org.eclipse.emf.texo.orm.annotations.model.orm.CascadeType;
import org.eclipse.emf.texo.orm.annotations.model.orm.EntityMappingsType;
+import org.eclipse.emf.texo.orm.annotator.ORMMappingOptions;
import org.eclipse.emf.texo.orm.annotator.ORMNamingStrategy;
import org.eclipse.emf.texo.orm.annotator.ORMNamingStrategyProvider;
@@ -66,25 +67,6 @@ import org.eclipse.emf.texo.orm.annotator.ORMNamingStrategyProvider;
*/
public class EPackageORMAnnotation extends EPackageAnnotation implements ENamedElementORMAnnotation {
- private static boolean inTestRun = false;
- private static boolean inSafeMappingMode = false;
-
- public static boolean isInSafeMappingMode() {
- return inSafeMappingMode;
- }
-
- public static void setInSafeMappingMode(boolean inSafeMappingMode) {
- EPackageORMAnnotation.inSafeMappingMode = inSafeMappingMode;
- }
-
- public static boolean isInTestRun() {
- return inTestRun;
- }
-
- public static void setInTestRun(boolean inTestRun) {
- EPackageORMAnnotation.inTestRun = inTestRun;
- }
-
/**
* The default value of the '{@link #isGenerateFullDbSchemaNames() <em>Generate Full Db Schema Names</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
@@ -359,15 +341,18 @@ public class EPackageORMAnnotation extends EPackageAnnotation implements ENamedE
*/
protected EPackageORMAnnotation() {
super();
- // restore some old defaults which help to run
- // different testcases
- if (inTestRun) {
+ // set some defaults which help to run
+ // different testcases or are read from the project
+ // properties
+ if (ORMMappingOptions.getDefaultOptions() != null) {
+ final ORMMappingOptions options = ORMMappingOptions.getDefaultOptions();
// otherwise order of lists is not maintained
- addOrderColumnToListMappings = true;
- enforceUniqueNames = true;
- if (!inSafeMappingMode) {
- renameSQLReservedNames = false;
- generateFullDbSchemaNames = false;
+ addOrderColumnToListMappings = options.isAddOrderColumnToListMappings();
+ enforceUniqueNames = options.isEnforceUniqueNames();
+ renameSQLReservedNames = options.isRenameSQLReservedNames();
+ generateFullDbSchemaNames = options.isGenerateFullDbSchemaNames();
+ if (options.getMaximumSqlNameLength() > 0) {
+ maximumSqlNameLength = options.getMaximumSqlNameLength();
}
}

Back to the top