Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormtaal2007-04-23 03:03:59 +0000
committermtaal2007-04-23 03:03:59 +0000
commitaea3485ec9810c5bed58b731fd6fe441474522c0 (patch)
treed59b38679434589f4e6f2f85e5b1c7a2334f8c09
parent71f7ea63d555a0bda7dd38aa95e13cb59375e276 (diff)
downloadorg.eclipse.emf.teneo-aea3485ec9810c5bed58b731fd6fe441474522c0.tar.gz
org.eclipse.emf.teneo-aea3485ec9810c5bed58b731fd6fe441474522c0.tar.xz
org.eclipse.emf.teneo-aea3485ec9810c5bed58b731fd6fe441474522c0.zip
Removed unnecessary system.err.println
Resolved error in JpoxDataStore
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/JpoxDataStore.java3
-rw-r--r--plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/mapper/MappingUtil.java112
2 files changed, 64 insertions, 51 deletions
diff --git a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/JpoxDataStore.java b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/JpoxDataStore.java
index 97bdf6953..414ce0a54 100644
--- a/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/JpoxDataStore.java
+++ b/plugins/org.eclipse.emf.teneo.jpox/src/org/eclipse/emf/teneo/jpox/JpoxDataStore.java
@@ -92,7 +92,7 @@ import org.w3c.dom.NodeList;
* 'top' classes. The classes which are not contained in other classes.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.14 $ $Date: 2007/04/23 02:36:31 $
+ * @version $Revision: 1.15 $ $Date: 2007/04/23 03:03:59 $
*/
public class JpoxDataStore {
@@ -176,6 +176,7 @@ public class JpoxDataStore {
// set the eruntime as the emodel resolver!
ERuntime.setAsEModelResolver();
+ ERuntime.INSTANCE.register(getEPackages());
// the jdo file list
String suffix =
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 c1a6e0c4c..ebb8fb5b1 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
@@ -1,23 +1,14 @@
/**
- * <copyright>
- *
- * Copyright (c) 2005, 2006, 2007 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
- * </copyright>
- *
- * $Id: MappingUtil.java,v 1.8 2007/04/07 12:42:47 mtaal Exp $
+ * <copyright> Copyright (c) 2005, 2006, 2007 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 </copyright> $Id:
+ * MappingUtil.java,v 1.8 2007/04/07 12:42:47 mtaal Exp $
*/
package org.eclipse.emf.teneo.jpox.mapper;
import java.util.ArrayList;
-import java.util.Iterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -39,7 +30,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.8 $
+ * @version $Revision: 1.9 $
*/
public class MappingUtil {
@@ -48,22 +39,24 @@ public class MappingUtil {
/** Returns the impl class name of an eclass */
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());
+ final EClass eclass =
+ mappingContext.getEClassNameStrategy().toEClass(eClassURI,
+ mappingContext.getEpackages());
if (eclass == null) {
throw new JPOXMappingException("Uri: " + eClassURI + " does not translate to an eclass");
}
final Class clazz = getImplClassOfEClass(eclass);
if (clazz == null) {
- throw new JPOXMappingException("Uri: " + eClassURI + " does not translate to an instance class");
+ throw new JPOXMappingException("Uri: " + eClassURI
+ + " does not translate to an instance class");
}
return clazz.getName();
}
- /** Returns the impl class name of an eclass, if the eclass is an interface
- * then the interface class is returned */
+ /**
+ * Returns the impl class name of an eclass, if the eclass is an interface then the interface
+ * class is returned
+ */
public static Class getImplClassOfEClass(EClass eClass) {
if (eClass.isInterface()) {
return eClass.getInstanceClass();
@@ -95,30 +88,40 @@ public class MappingUtil {
}
/** Adds a generic feature map entry to the passed element */
- public static void addGenericFeatureMapEntryMapping(Element field, PAnnotatedEAttribute aAttribute, FetchType ft) {
+ public static void addGenericFeatureMapEntryMapping(Element field,
+ PAnnotatedEAttribute aAttribute, FetchType ft) {
EAttribute eAttribute = aAttribute.getAnnotatedEAttribute();
log.debug("Any feature entry, adding embedded tags");
- Element collection = field.addElement("collection").addAttribute("element-type", GenericFeatureMapEntry.class.getName());
+ Element collection =
+ field.addElement("collection").addAttribute("element-type",
+ GenericFeatureMapEntry.class.getName());
field.addElement("join");
Element embeddedElement = field.addElement("element").addElement("embedded");
- Element fieldElement = embeddedElement.addElement("field").addAttribute("name", "featurePath");
+ Element fieldElement =
+ embeddedElement.addElement("field").addAttribute("name", "featurePath");
- fieldElement = embeddedElement.addElement("field").addAttribute("name", "localAnyValue").addAttribute("embedded", "true");
+ fieldElement =
+ embeddedElement.addElement("field").addAttribute("name", "localAnyValue")
+ .addAttribute("embedded", "true");
addExtensionImplementationClasses(fieldElement, false, false, eAttribute);
- fieldElement = embeddedElement.addElement("field").addAttribute("name", "localReferenceValue");
+ fieldElement =
+ embeddedElement.addElement("field").addAttribute("name", "localReferenceValue");
if (!addExtensionImplementationClasses(fieldElement, true, false, eAttribute)) {
fieldElement.addAttribute("embedded", "true");
}
- fieldElement.addElement("foreign-key").addAttribute("delete-action", "restrict").addAttribute("update-action", "cascade");
+ fieldElement.addElement("foreign-key").addAttribute("delete-action", "restrict")
+ .addAttribute("update-action", "cascade");
fieldElement = embeddedElement.addElement("field");
- fieldElement.addAttribute("name", "localContainmentReferenceValue").addAttribute("dependent", "true");
- fieldElement.addElement("foreign-key").addAttribute("delete-action", "cascade").addAttribute("update-action", "cascade");
+ fieldElement.addAttribute("name", "localContainmentReferenceValue").addAttribute(
+ "dependent", "true");
+ fieldElement.addElement("foreign-key").addAttribute("delete-action", "cascade")
+ .addAttribute("update-action", "cascade");
if (!addExtensionImplementationClasses(fieldElement, true, true, eAttribute)) {
fieldElement.addAttribute("embedded", "true");
@@ -130,11 +133,11 @@ public class MappingUtil {
/** Adds the correct jpox extension based on the fetch type */
public static void addEagerLazyLoading(Element field, FetchType ft) {
if (ft.equals(FetchType.EAGER_LITERAL)) {
- field.addElement("extension").addAttribute("vendor-name", "jpox").addAttribute("key", "cache-lazy-loading").addAttribute(
- "value", "false");
+ field.addElement("extension").addAttribute("vendor-name", "jpox").addAttribute("key",
+ "cache-lazy-loading").addAttribute("value", "false");
} else {
- field.addElement("extension").addAttribute("vendor-name", "jpox").addAttribute("key", "cache-lazy-loading").addAttribute(
- "value", "true");
+ field.addElement("extension").addAttribute("vendor-name", "jpox").addAttribute("key",
+ "cache-lazy-loading").addAttribute("value", "true");
}
}
@@ -149,39 +152,46 @@ public class MappingUtil {
}
/**
- * Returns all the implementation classes which can be stored in a certain featuremap entry. Returns false if no impl. classes
- * could be found
+ * Returns all the implementation classes which can be stored in a certain featuremap entry.
+ * Returns false if no impl. classes could be found
*/
- private static boolean addExtensionImplementationClasses(Element element, boolean onlyEObject, boolean containment,
- EAttribute eattr) {
+ private static boolean addExtensionImplementationClasses(Element element, boolean onlyEObject,
+ boolean containment, EAttribute eattr) {
ArrayList result = new ArrayList();
ArrayList featureResult = new ArrayList();
- for (Iterator it = eattr.getEContainingClass().getEStructuralFeatures().iterator(); it.hasNext();) {
- EStructuralFeature efeature = (EStructuralFeature) it.next();
+ for (Object element2 : eattr.getEContainingClass().getEStructuralFeatures()) {
+ EStructuralFeature efeature = (EStructuralFeature) element2;
- if (containment && efeature instanceof EReference && !((EReference) efeature).isContainment()) {
+ if (containment && efeature instanceof EReference
+ && !((EReference) efeature).isContainment()) {
continue;
}
- if (!containment && onlyEObject && efeature instanceof EReference && ((EReference) efeature).isContainment()) {
+ if (!containment && onlyEObject && efeature instanceof EReference
+ && ((EReference) efeature).isContainment()) {
continue;
}
if (StoreUtil.isElementOfGroup(efeature, eattr)) {
Class instanceClass = efeature.getEType().getInstanceClass();
- if (!onlyEObject && !EObject.class.isAssignableFrom(instanceClass) && !String.class.isAssignableFrom(instanceClass)
+ if (!onlyEObject && !EObject.class.isAssignableFrom(instanceClass)
+ && !String.class.isAssignableFrom(instanceClass)
&& efeature instanceof EAttribute) {
if (!result.contains(instanceClass.getName())) {
String name = instanceClass.getName();
if (name.indexOf('.') == -1) { // assume
log.warn("Primitive type " + name + " prepending java.lang.");
- name = "java.lang." + name.substring(0, 1).toUpperCase() + name.substring(1);
+ name =
+ "java.lang." + name.substring(0, 1).toUpperCase()
+ + name.substring(1);
}
result.add(name);
featureResult.add(efeature);
}
} else if (onlyEObject && efeature instanceof EReference) {
- Class implClass = ERuntime.INSTANCE.getJavaClass(((EReference) efeature).getEReferenceType());
+ Class implClass =
+ ERuntime.INSTANCE.getJavaClass(((EReference) efeature)
+ .getEReferenceType());
if (implClass != null && !result.contains(implClass.getName())) {
result.add(implClass.getName());
featureResult.add(efeature);
@@ -192,7 +202,9 @@ public class MappingUtil {
// add extension to fieldelement
String[] implClasses = (String[]) result.toArray(new String[result.size()]);
- EStructuralFeature[] features = (EStructuralFeature[]) featureResult.toArray(new EStructuralFeature[featureResult.size()]);
+ EStructuralFeature[] features =
+ (EStructuralFeature[]) featureResult.toArray(new EStructuralFeature[featureResult
+ .size()]);
StringBuffer resultStr = new StringBuffer();
StringBuffer fResultStr = new StringBuffer();
boolean foundImpl = implClasses.length > 0;
@@ -213,11 +225,11 @@ public class MappingUtil {
}
}
- element.addElement("extension").addAttribute("vendor-name", "jpox").addAttribute("key", "implementation-classes")
- .addAttribute("value", resultStr.toString());
+ element.addElement("extension").addAttribute("vendor-name", "jpox").addAttribute("key",
+ "implementation-classes").addAttribute("value", resultStr.toString());
- element.addElement("extension").addAttribute("vendor-name", "teneo").addAttribute("key", "estructuralfeatures")
- .addAttribute("value", fResultStr.toString());
+ element.addElement("extension").addAttribute("vendor-name", "teneo").addAttribute("key",
+ "estructuralfeatures").addAttribute("value", fResultStr.toString());
return foundImpl;
}
} \ No newline at end of file

Back to the top