Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormtaal2006-11-28 06:14:10 +0000
committermtaal2006-11-28 06:14:10 +0000
commitbac6976121897cf48e183176e04cba6f0f0c0c55 (patch)
tree9a1fa9000f3825f60c06355b2dc9558b9460d1de
parentcc399202d24b499565c733911162d1e1375ca617 (diff)
downloadorg.eclipse.emf.teneo-bac6976121897cf48e183176e04cba6f0f0c0c55.tar.gz
org.eclipse.emf.teneo-bac6976121897cf48e183176e04cba6f0f0c0c55.tar.xz
org.eclipse.emf.teneo-bac6976121897cf48e183176e04cba6f0f0c0c55.zip
[165450] [165851] [165428] [165070] [156926]
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/elist/EListWrapper.java11
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/elist/RemoveLifeCycleListener.java5
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/JPOXMappingGenerator.java23
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingContext.java36
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingUtil.java11
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/AssociationMapper.java10
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/EmbeddedMapper.java11
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToManyMapper.java18
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToOneMapper.java28
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToManyMapper.java25
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToOneMapper.java30
11 files changed, 137 insertions, 71 deletions
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/elist/EListWrapper.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/elist/EListWrapper.java
index 1c4ca30cd..b74ea3052 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/elist/EListWrapper.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/elist/EListWrapper.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: EListWrapper.java,v 1.5 2006/11/20 08:18:28 mtaal Exp $
+ * $Id: EListWrapper.java,v 1.6 2006/11/28 06:14:10 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.elist;
@@ -64,7 +64,7 @@ import org.jpox.store.query.ResultObjectFactory;
* the jpox arraylist is the delegate.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.5 $ $Date: 2006/11/20 08:18:28 $
+ * @version $Revision: 1.6 $ $Date: 2006/11/28 06:14:10 $
*/
public class EListWrapper extends PersistableEList implements SCO, Queryable, SCOList {
@@ -547,12 +547,11 @@ public class EListWrapper extends PersistableEList implements SCO, Queryable, SC
final Object child = it.next();
if (containmentList) {
EContainerRepairControl.repair(getEObject(), child, getEStructuralFeature());
- } else if (res != null && res instanceof ResourceImpl) {
+ } else if (res != null && res instanceof ResourceImpl &&
+ child instanceof EObject && ((EObject)child).eResource() == null) {
// attach the new objects so that they are adapted when
// required
- if (child instanceof EObject) {
- ((ResourceImpl) res).attached((EObject) child);
- }
+ ((StoreResource) res).attached((InternalEObject) child);
}
}
if (setLoading) {
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/elist/RemoveLifeCycleListener.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/elist/RemoveLifeCycleListener.java
index 064404842..73ce7ef4d 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/elist/RemoveLifeCycleListener.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/elist/RemoveLifeCycleListener.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: RemoveLifeCycleListener.java,v 1.2 2006/11/20 08:18:28 mtaal Exp $
+ * $Id: RemoveLifeCycleListener.java,v 1.3 2006/11/28 06:14:10 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.elist;
@@ -27,13 +27,12 @@ import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.FeatureMapUtil;
-import org.eclipse.emf.teneo.jpox.mapping.AnyTypeEObject;
/**
* Captures the remove life cycle listener to ensure load of featuremaps before a delete.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.2 $ $Date: 2006/11/20 08:18:28 $
+ * @version $Revision: 1.3 $ $Date: 2006/11/28 06:14:10 $
*/
public class RemoveLifeCycleListener implements DeleteLifecycleListener {
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/JPOXMappingGenerator.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/JPOXMappingGenerator.java
index e00e79c99..758dc3d6c 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/JPOXMappingGenerator.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/JPOXMappingGenerator.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: JPOXMappingGenerator.java,v 1.8 2006/09/26 12:47:35 mtaal Exp $
+ * $Id: JPOXMappingGenerator.java,v 1.9 2006/11/28 06:14:10 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper;
@@ -33,6 +33,7 @@ import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEStructuralFeature;
import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedModel;
import org.eclipse.emf.teneo.annotations.pannotation.PrimaryKeyJoinColumn;
import org.eclipse.emf.teneo.annotations.pannotation.SecondaryTable;
+import org.eclipse.emf.teneo.ecore.EClassNameStrategy;
import org.eclipse.emf.teneo.simpledom.Document;
import org.eclipse.emf.teneo.simpledom.DocumentHelper;
import org.eclipse.emf.teneo.simpledom.Element;
@@ -41,7 +42,7 @@ import org.eclipse.emf.teneo.simpledom.Element;
* Generates a jpox mapping file based on the pamodel.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
public class JPOXMappingGenerator {
@@ -61,10 +62,14 @@ public class JPOXMappingGenerator {
/** The version column name */
private final String versionColumnName;
+ /** The eclass naming strategy */
+ private EClassNameStrategy eclassNameStrategy;
+
/** The constructor, creates all mappers etc. */
public JPOXMappingGenerator(PersistenceOptions po) {
- mappingContext = new MappingContext();
versionColumnName = po.getVersionColumnName();
+ eclassNameStrategy = po.getEClassNameStrategy();
+ mappingContext = new MappingContext(eclassNameStrategy);
}
/** Method gets a created annotatedModel and creates a jpox mapping file */
@@ -77,7 +82,6 @@ public class JPOXMappingGenerator {
// "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN",
// "http://java.sun.com/dtd/jdo_2_0.dtd") );
-
Element rootElement = new Element();
rootElement.setName("jdo");
mappingDoc.setRoot(rootElement);
@@ -88,7 +92,9 @@ public class JPOXMappingGenerator {
PAnnotatedEPackage aPackage = (PAnnotatedEPackage) it.next();
epackages.add(aPackage.getAnnotatedElement());
}
- ERuntime.INSTANCE.register((EPackage[]) epackages.toArray(new EPackage[epackages.size()]));
+ final EPackage[] epackagesArray = (EPackage[]) epackages.toArray(new EPackage[epackages.size()]);
+ ERuntime.INSTANCE.register(epackagesArray);
+ mappingContext.setEpackages(epackagesArray);
// group the eclasses by their impl. java package, this is required because
// class tags should be all grouped in one package
@@ -271,4 +277,11 @@ public class JPOXMappingGenerator {
collectImplements(interfaces[i], result);
}
}
+
+ /**
+ * @return the eclassNameStrategy
+ */
+ public EClassNameStrategy getEClassNameStrategy() {
+ return eclassNameStrategy;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingContext.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingContext.java
index 48a127077..43ac4487e 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingContext.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingContext.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: MappingContext.java,v 1.3 2006/09/06 21:59:25 mtaal Exp $
+ * $Id: MappingContext.java,v 1.4 2006/11/28 06:14:10 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper;
@@ -21,9 +21,11 @@ import java.util.Stack;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.teneo.annotations.mapper.AbstractProcessingContext;
import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEClass;
import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEStructuralFeature;
+import org.eclipse.emf.teneo.ecore.EClassNameStrategy;
import org.eclipse.emf.teneo.jpox.mapper.association.EmbeddedMapper;
import org.eclipse.emf.teneo.jpox.mapper.association.ManyToManyMapper;
import org.eclipse.emf.teneo.jpox.mapper.association.ManyToOneMapper;
@@ -42,7 +44,7 @@ import org.eclipse.emf.teneo.jpox.mapper.property.TableMapper;
* Contains instances of the mappers used.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class MappingContext extends AbstractProcessingContext {
@@ -108,9 +110,16 @@ public class MappingContext extends AbstractProcessingContext {
/** The tableMapper */
private TableMapper tableMapper;
+
+ /** The eclass naming strategy */
+ private EClassNameStrategy eclassNameStrategy;
+ /** The epackages for which this is all done */
+ private EPackage[] epackages;
+
/** The constructor, creates all mappers etc. */
- public MappingContext() {
+ public MappingContext(EClassNameStrategy eclassNameStrategy) {
+ this.eclassNameStrategy = eclassNameStrategy;
namingHandler = new NamingHandler();
otmMapper = new OneToManyMapper(this);
mtmMapper = new ManyToManyMapper(this);
@@ -258,4 +267,25 @@ public class MappingContext extends AbstractProcessingContext {
public void setCurrentAClass(PAnnotatedEClass currentAClass) {
this.currentAClass = currentAClass;
}
+
+ /**
+ * @return the eclassNameStrategy
+ */
+ public EClassNameStrategy getEClassNameStrategy() {
+ return eclassNameStrategy;
+ }
+
+ /**
+ * @return the epackages
+ */
+ public EPackage[] getEpackages() {
+ return epackages;
+ }
+
+ /**
+ * @param epackages the epackages to set
+ */
+ public void setEpackages(EPackage[] epackages) {
+ this.epackages = epackages;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingUtil.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingUtil.java
index d98163432..88b9ba143 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingUtil.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingUtil.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: MappingUtil.java,v 1.5 2006/11/01 11:39:25 mtaal Exp $
+ * $Id: MappingUtil.java,v 1.6 2006/11/28 06:14:10 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper;
@@ -39,7 +39,7 @@ import org.eclipse.emf.teneo.util.StoreUtil;
* Generates a jpox mapping file based on the pamodel.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class MappingUtil {
@@ -47,8 +47,11 @@ public class MappingUtil {
protected static final Log log = LogFactory.getLog(MappingUtil.class);
/** Returns the impl class name of an eclass */
- public static String getImplNameOfEClass(String eClassURI) {
- final EClass eclass = StoreUtil.getEClassFromURI(eClassURI, ERuntime.INSTANCE.getEPackages());
+ public static String getImplNameOfEClass(String eClassURI, MappingContext mappingContext) {
+ if (mappingContext == null || mappingContext.getEClassNameStrategy() == null) {
+ System.err.println("TEST");
+ }
+ final EClass eclass = mappingContext.getEClassNameStrategy().toEClass(eClassURI, mappingContext.getEpackages());
if (eclass == null) {
throw new JPOXMappingException("Uri: " + eClassURI + " does not translate to an eclass");
}
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/AssociationMapper.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/AssociationMapper.java
index 64ed9826d..7a1399681 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/AssociationMapper.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/AssociationMapper.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: AssociationMapper.java,v 1.2 2006/07/22 13:04:20 mtaal Exp $
+ * $Id: AssociationMapper.java,v 1.3 2006/11/28 06:14:10 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper.association;
@@ -30,7 +30,7 @@ import org.eclipse.emf.teneo.simpledom.Element;
* The abstract class for different mappers.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class AssociationMapper extends AbstractMapper {
@@ -43,7 +43,8 @@ public class AssociationMapper extends AbstractMapper {
}
/** Sets common reference field attributes */
- protected void setCommonReferenceAttributes(Element fieldElement, PAnnotatedEReference aReference, boolean cascadeRemove) {
+ protected void setCommonReferenceAttributes(Element fieldElement, PAnnotatedEReference aReference,
+ boolean cascadeRemove) {
EReference eReference = (EReference) aReference.getAnnotatedElement();
boolean isWildcard = MappingUtil.isWildcard(eReference);
@@ -52,7 +53,8 @@ public class AssociationMapper extends AbstractMapper {
// our experience showed that if dependent is set on wildcard that errors occur in jpox.
if (cascadeRemove) {
fieldElement.addAttribute("dependent", "true");
- } else if (FeatureMapUtil.isFeatureMap(eReference) && !isWildcard) { // featuremap entries are always dependent
+ } else if (FeatureMapUtil.isFeatureMap(eReference) && !isWildcard) { // featuremap entries are always
+ // dependent
fieldElement.addAttribute("dependent", "true");
} else if (eReference.isContainment() && !isWildcard) {
// dependent if containment and it is a single reference field (not multi)
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/EmbeddedMapper.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/EmbeddedMapper.java
index dfa47f741..e93dc6c2c 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/EmbeddedMapper.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/EmbeddedMapper.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: EmbeddedMapper.java,v 1.4 2006/09/04 15:42:17 mtaal Exp $
+ * $Id: EmbeddedMapper.java,v 1.5 2006/11/28 06:14:10 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper.association;
@@ -29,7 +29,7 @@ import org.eclipse.emf.teneo.simpledom.Element;
* The abstract class for different mappers.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class EmbeddedMapper extends AbstractMapper {
@@ -44,15 +44,16 @@ public class EmbeddedMapper extends AbstractMapper {
/** Handles a normal basic attribute */
public void map(PAnnotatedEReference aReference, Element fieldElement) {
log.debug("Processing embedded field: " + aReference.getAnnotatedElement().getName());
-
+
mappingContext.pushOverrideOnStack();
mappingContext.addAttributeOverrides(aReference.getAttributeOverrides());
-
+
EReference eReference = aReference.getAnnotatedEReference();
if (eReference.isMany() || eReference.getEOpposite() != null || aReference.getAttributeOverrides().size() > 0) {
Element embeddedElement = fieldElement.addElement("embedded");
if (eReference.getEOpposite() != null) {
- embeddedElement.addAttribute("owner-field", namingHandler.correctName(mappingContext, eReference.getEOpposite()));
+ embeddedElement.addAttribute("owner-field", namingHandler.correctName(mappingContext, eReference
+ .getEOpposite()));
}
// now map the embedded class
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToManyMapper.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToManyMapper.java
index ec1bafdf1..d0e7ee96b 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToManyMapper.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToManyMapper.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: ManyToManyMapper.java,v 1.5 2006/09/21 00:56:36 mtaal Exp $
+ * $Id: ManyToManyMapper.java,v 1.6 2006/11/28 06:14:10 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper.association;
@@ -32,7 +32,7 @@ import org.eclipse.emf.teneo.simpledom.Element;
* Generates a jpox mapping file based on the pamodel.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class ManyToManyMapper extends AssociationMapper {
@@ -51,13 +51,16 @@ public class ManyToManyMapper extends AssociationMapper {
// TODO: cascaderemove will set dependent=true on the element maybe this is to rough for all cases?
List cascade = aReference.getManyToMany().getCascade();
- boolean cascadeRemove = cascade.contains(CascadeType.ALL_LITERAL) || cascade.contains(CascadeType.REMOVE_LITERAL);
+ boolean cascadeRemove = cascade.contains(CascadeType.ALL_LITERAL)
+ || cascade.contains(CascadeType.REMOVE_LITERAL);
log.debug("Cascaderemove " + cascadeRemove);
- if (cascadeRemove) log.warn("Cascade (all) remove on a many to many relation is an unlikely case");
+ if (cascadeRemove)
+ log.warn("Cascade (all) remove on a many to many relation is an unlikely case");
Element field = eclassElement.addElement("field");
- field.addAttribute("name", namingHandler.correctName(mappingContext, eReference)).addAttribute("persistence-modifier", "persistent");
+ field.addAttribute("name", namingHandler.correctName(mappingContext, eReference)).addAttribute(
+ "persistence-modifier", "persistent");
// two way were the otherside is the container then the reference should be delete
// confusing but foreign-key constraints are defined the other way around in jpox
@@ -77,7 +80,7 @@ public class ManyToManyMapper extends AssociationMapper {
ManyToMany mtm = aReference.getManyToMany();
if (mtm.getMappedBy() != null && !aReference.getAnnotatedEReference().isContainment()) {
// see above
- //field.addAttribute("mapped-by", mtm.getMappedBy());
+ // field.addAttribute("mapped-by", mtm.getMappedBy());
}
// collection element is present befpre join element
@@ -94,7 +97,8 @@ public class ManyToManyMapper extends AssociationMapper {
mappingContext.getJoinColumnMapper().map(aReference.getJoinColumns(), joinElement);
}
- collection.addAttribute("element-type", MappingUtil.getImplNameOfEClass(aReference.getManyToMany().getTargetEntity()));
+ collection.addAttribute("element-type", MappingUtil.getImplNameOfEClass(aReference.getManyToMany()
+ .getTargetEntity(), mappingContext));
if (cascadeRemove) {
collection.addAttribute("dependent-element", "true");
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToOneMapper.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToOneMapper.java
index 0451a7dae..ada64e262 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToOneMapper.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/ManyToOneMapper.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: ManyToOneMapper.java,v 1.6 2006/11/20 08:18:28 mtaal Exp $
+ * $Id: ManyToOneMapper.java,v 1.7 2006/11/28 06:14:10 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper.association;
@@ -23,17 +23,17 @@ import org.apache.commons.logging.LogFactory;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEReference;
import org.eclipse.emf.teneo.annotations.pannotation.CascadeType;
+import org.eclipse.emf.teneo.ecore.EClassNameStrategy;
import org.eclipse.emf.teneo.jpox.mapper.MappingContext;
import org.eclipse.emf.teneo.jpox.mapper.MappingUtil;
import org.eclipse.emf.teneo.jpox.mapping.AnyTypeEObject;
import org.eclipse.emf.teneo.simpledom.Element;
-import org.eclipse.emf.teneo.util.StoreUtil;
/**
* Generates a jpox mapping for the one to one association.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public class ManyToOneMapper extends AssociationMapper {
@@ -52,11 +52,13 @@ public class ManyToOneMapper extends AssociationMapper {
// TODO: cascaderemove will set dependent=true on the element maybe this is to rough for all cases?
List cascade = aReference.getManyToOne().getCascade();
- boolean cascadeRemove = cascade.contains(CascadeType.ALL_LITERAL) || cascade.contains(CascadeType.REMOVE_LITERAL);
+ boolean cascadeRemove = cascade.contains(CascadeType.ALL_LITERAL)
+ || cascade.contains(CascadeType.REMOVE_LITERAL);
log.debug("Cascaderemove " + cascadeRemove);
Element field = eclassElement.addElement("field");
- field.addAttribute("name", namingHandler.correctName(mappingContext, eReference)).addAttribute("persistence-modifier", "persistent");
+ field.addAttribute("name", namingHandler.correctName(mappingContext, eReference)).addAttribute(
+ "persistence-modifier", "persistent");
setCommonReferenceAttributes(field, aReference, cascadeRemove);
// special case if a modelField is a referencemodelfield and part of a two way relation then it
@@ -66,7 +68,8 @@ public class ManyToOneMapper extends AssociationMapper {
// - its depedent child is deleted, the reference from o to the child is nullified
// - exception is thrown before o can be deleted that reference to child is null
// maybe required dependent is an uncommon model.
- boolean setNullable = aReference.getManyToOne().isOptional() || eReference.getEOpposite() != null || cascadeRemove;
+ boolean setNullable = aReference.getManyToOne().isOptional() || eReference.getEOpposite() != null
+ || cascadeRemove;
field.addAttribute("null-value", setNullable ? "none" : "exception");
if (aReference.getEmbedded() != null) {
@@ -77,11 +80,12 @@ public class ManyToOneMapper extends AssociationMapper {
// for embedded no foreign key constraint
Element fk = null;
if (cascadeRemove && aReference.getEmbedded() == null) {
- fk = field.addElement("foreign-key").addAttribute("delete-action", "cascade").addAttribute("update-action", "cascade");
+ fk = field.addElement("foreign-key").addAttribute("delete-action", "cascade").addAttribute(
+ "update-action", "cascade");
} else {
fk = field.addElement("foreign-key");
}
-
+
if (aReference.getJoinColumns() != null && aReference.getJoinColumns().size() > 0) {
// Element elemElement = field.addElement("element");
mappingContext.getJoinColumnMapper().map(aReference.getJoinColumns(), fk);
@@ -90,13 +94,13 @@ public class ManyToOneMapper extends AssociationMapper {
String targetEntity = aReference.getManyToOne().getTargetEntity();
String implName = null;
- if (targetEntity.compareTo(StoreUtil.EOBJECT_ECLASS_URI) == 0) {
+ if (targetEntity.compareTo(EClassNameStrategy.EOBJECT_ECLASS_URI) == 0) {
implName = AnyTypeEObject.class.getName();
} else {
- implName = MappingUtil.getImplNameOfEClass(aReference.getManyToOne().getTargetEntity());
+ implName = MappingUtil.getImplNameOfEClass(aReference.getManyToOne().getTargetEntity(), mappingContext);
}
- field.addElement("extension").addAttribute("vendor-name", "jpox").addAttribute("key", "implementation-classes").addAttribute(
- "value", implName);
+ field.addElement("extension").addAttribute("vendor-name", "jpox").addAttribute("key", "implementation-classes")
+ .addAttribute("value", implName);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToManyMapper.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToManyMapper.java
index 7101c9de8..b34c3a561 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToManyMapper.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToManyMapper.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: OneToManyMapper.java,v 1.7 2006/09/21 00:56:36 mtaal Exp $
+ * $Id: OneToManyMapper.java,v 1.8 2006/11/28 06:14:10 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper.association;
@@ -35,7 +35,7 @@ import org.eclipse.emf.teneo.simpledom.Element;
* Generates a jpox mapping file based on the pamodel.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
public class OneToManyMapper extends AssociationMapper {
@@ -54,11 +54,13 @@ public class OneToManyMapper extends AssociationMapper {
// TODO: cascaderemove will set dependent=true on the element maybe this is to rough for all cases?
List cascade = aReference.getOneToMany().getCascade();
- boolean cascadeRemove = cascade.contains(CascadeType.ALL_LITERAL) || cascade.contains(CascadeType.REMOVE_LITERAL);
+ boolean cascadeRemove = cascade.contains(CascadeType.ALL_LITERAL)
+ || cascade.contains(CascadeType.REMOVE_LITERAL);
log.debug("Cascaderemove " + cascadeRemove);
Element field = eclassElement.addElement("field");
- field.addAttribute("name", namingHandler.correctName(mappingContext, eReference)).addAttribute("persistence-modifier", "persistent");
+ field.addAttribute("name", namingHandler.correctName(mappingContext, eReference)).addAttribute(
+ "persistence-modifier", "persistent");
OneToMany otm = aReference.getOneToMany();
@@ -71,7 +73,7 @@ public class OneToManyMapper extends AssociationMapper {
// item from the list.
// -> result item points back to the list but is not present anymore in the list
if (otm.getMappedBy() != null && !aReference.getAnnotatedEReference().isContainment()) {
- //field.addAttribute("mapped-by", otm.getMappedBy());
+ // field.addAttribute("mapped-by", otm.getMappedBy());
}
// collection element is present befpre join element
@@ -83,7 +85,8 @@ public class OneToManyMapper extends AssociationMapper {
// use a join table for mtm relations and non unique relations
boolean useJoin = aReference.getJoinTable() != null || isWildcard
|| eReference.getEReferenceType().getInstanceClass().equals(EObject.class)
- || eReference.getEReferenceType().getInstanceClass().equals(Object.class) || aReference.getEmbedded() != null;
+ || eReference.getEReferenceType().getInstanceClass().equals(Object.class)
+ || aReference.getEmbedded() != null;
if (useJoin) {
Element joinElement = field.addElement("join");
if (aReference.getJoinTable() != null) {
@@ -117,7 +120,7 @@ public class OneToManyMapper extends AssociationMapper {
field.addAttribute("embedded", "true");
} else { // this is the normal case
String targetEntity = aReference.getOneToMany().getTargetEntity();
- collection.addAttribute("element-type", MappingUtil.getImplNameOfEClass(targetEntity));
+ collection.addAttribute("element-type", MappingUtil.getImplNameOfEClass(targetEntity, mappingContext));
}
if (!embedded && aReference.getEmbedded() != null) {
@@ -129,7 +132,7 @@ public class OneToManyMapper extends AssociationMapper {
// set dependent attribute
if (embedded) {
// do nothing, embedded is dependent anyway
- } else if (cascade.contains(CascadeType.ALL_LITERAL) || MappingUtil.isGroup(eReference)) { //cascadeRemove ||
+ } else if (cascade.contains(CascadeType.ALL_LITERAL) || MappingUtil.isGroup(eReference)) { // cascadeRemove ||
collection.addAttribute("dependent-element", "true");
} else {
collection.addAttribute("dependent-element", "false");
@@ -160,9 +163,11 @@ public class OneToManyMapper extends AssociationMapper {
// do foreign key
if (!useJoin && cascadeRemove) { // containment does not need a join table
- field.addElement("foreign-key").addAttribute("delete-action", "cascade").addAttribute("update-action", "cascade");
+ field.addElement("foreign-key").addAttribute("delete-action", "cascade").addAttribute("update-action",
+ "cascade");
} else if (!useJoin) {
- field.addElement("foreign-key").addAttribute("delete-action", "restrict").addAttribute("update-action", "cascade");
+ field.addElement("foreign-key").addAttribute("delete-action", "restrict").addAttribute("update-action",
+ "cascade");
}
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToOneMapper.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToOneMapper.java
index 8e7735159..0aad08013 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToOneMapper.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/association/OneToOneMapper.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: OneToOneMapper.java,v 1.5 2006/09/04 15:42:17 mtaal Exp $
+ * $Id: OneToOneMapper.java,v 1.6 2006/11/28 06:14:10 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper.association;
@@ -31,7 +31,7 @@ import org.eclipse.emf.teneo.simpledom.Element;
* Generates a jpox mapping for the one to one association.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class OneToOneMapper extends AssociationMapper {
@@ -50,11 +50,13 @@ public class OneToOneMapper extends AssociationMapper {
// TODO: cascaderemove will set dependent=true on the element maybe this is to rough for all cases?
List cascade = aReference.getOneToOne().getCascade();
- boolean cascadeRemove = cascade.contains(CascadeType.ALL_LITERAL) || cascade.contains(CascadeType.REMOVE_LITERAL);
+ boolean cascadeRemove = cascade.contains(CascadeType.ALL_LITERAL)
+ || cascade.contains(CascadeType.REMOVE_LITERAL);
log.debug("Cascaderemove " + cascadeRemove);
Element field = eclassElement.addElement("field");
- field.addAttribute("name", namingHandler.correctName(mappingContext, eReference)).addAttribute("persistence-modifier", "persistent");
+ field.addAttribute("name", namingHandler.correctName(mappingContext, eReference)).addAttribute(
+ "persistence-modifier", "persistent");
setCommonReferenceAttributes(field, aReference, cascadeRemove);
// special case if a modelField is a referencemodelfield and part of a two way relation then it
@@ -64,7 +66,8 @@ public class OneToOneMapper extends AssociationMapper {
// - its depedent child is deleted, the reference from o to the child is nullified
// - exception is thrown before o can be deleted that reference to child is null
// maybe required dependent is an uncommon model.
- boolean setNullable = aReference.getOneToOne().isOptional() || eReference.getEOpposite() != null || cascadeRemove;
+ boolean setNullable = aReference.getOneToOne().isOptional() || eReference.getEOpposite() != null
+ || cascadeRemove;
field.addAttribute("null-value", setNullable ? "none" : "exception");
if (aReference.getEmbedded() != null) {
@@ -78,16 +81,17 @@ public class OneToOneMapper extends AssociationMapper {
// -> result item points back to the list but is not present anymore in the list
if (aReference.getOneToOne() != null && aReference.getOneToOne().getMappedBy() != null
&& !aReference.getAnnotatedEReference().isContainment()) {
- // disabled mapped-by for now, for one reason or another jpox did not cascade the
- // persist action over a bidirectional relation, bidirectionality is controlled
- // anyway by emf.
- //field.addAttribute("mapped-by", aReference.getOneToOne().getMappedBy());
+ // disabled mapped-by for now, for one reason or another jpox did not cascade the
+ // persist action over a bidirectional relation, bidirectionality is controlled
+ // anyway by emf.
+ // field.addAttribute("mapped-by", aReference.getOneToOne().getMappedBy());
}
// add extra foreign key constraint
// for embedded no foreign key constraint
if (cascadeRemove && aReference.getEmbedded() == null) {
- field.addElement("foreign-key").addAttribute("delete-action", "cascade").addAttribute("update-action", "cascade");
+ field.addElement("foreign-key").addAttribute("delete-action", "cascade").addAttribute("update-action",
+ "cascade");
} else {
field.addElement("foreign-key");
}
@@ -98,7 +102,9 @@ public class OneToOneMapper extends AssociationMapper {
}
}
- field.addElement("extension").addAttribute("vendor-name", "jpox").addAttribute("key", "implementation-classes").addAttribute(
- "value", MappingUtil.getImplNameOfEClass(aReference.getOneToOne().getTargetEntity()));
+ field.addElement("extension").addAttribute("vendor-name", "jpox").addAttribute("key", "implementation-classes")
+ .addAttribute(
+ "value",
+ MappingUtil.getImplNameOfEClass(aReference.getOneToOne().getTargetEntity(), mappingContext));
}
} \ No newline at end of file

Back to the top