summaryrefslogtreecommitdiffstats
path: root/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read
diff options
context:
space:
mode:
Diffstat (limited to 'das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read')
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReader.java131
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java365
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java100
-rw-r--r--das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java161
4 files changed, 757 insertions, 0 deletions
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReader.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReader.java
new file mode 100644
index 0000000000..9add9b7677
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReader.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.read;
+
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.sdo.EDataGraph;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+import org.eclipse.emf.ecore.sdo.SDOFactory;
+
+public class EDataGraphReader
+implements DASConstants
+{
+ public static EDataGraph read(
+ EClass rootDataObjectEClass,
+ String id,
+ LdapContext rootContext,
+ Map<EDataObject, String> dataObjectToRelativeDNCache)
+ throws NamingException, LdapNameNotFoundException
+ {
+ EDataGraph eDataGraph =
+ SDOFactory.eINSTANCE.createEDataGraph();
+
+ String namespaceURI =
+ rootDataObjectEClass.getEPackage().
+ getNsURI();
+
+ EAttribute idEAttribute =
+ rootDataObjectEClass.getEIDAttribute();
+
+ String qualifiedIDEAttributeName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ rootDataObjectEClass.getName(),
+ idEAttribute.getName() );
+
+ String normalizedIDEAttributeName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedIDEAttributeName);
+
+ String eDataObjectRDN =
+ normalizedIDEAttributeName + "=" + id;
+
+ LdapContext eDataObjectContext =
+ (LdapContext)
+ rootContext.
+ lookup(eDataObjectRDN);
+
+ Attributes attributes =
+ rootContext.
+ getAttributes(eDataObjectRDN);
+
+ Map<EDataObject, Map<EStructuralFeature, List<String>>> crossReferenceIDCache =
+ new Hashtable<EDataObject, Map<EStructuralFeature, List<String>>>();
+
+ EDataObject rootDataObject =
+ EDataGraphReaderHelper.
+ restoreEDataObject(
+ crossReferenceIDCache,
+ rootDataObjectEClass,
+ namespaceURI,
+ attributes);
+
+ String relativeDN =
+ EDataGraphReaderHelper.calculateRelativeDN(
+ rootContext,
+ eDataObjectContext);
+
+ dataObjectToRelativeDNCache.
+ put(rootDataObject, relativeDN);
+
+ List<EReference> eReferences =
+ rootDataObjectEClass.getEAllContainments();
+
+ if (rootDataObjectEClass.getEAllContainments().size() > 0)
+ {
+ EDataGraphReaderHelper.
+ addContainmentDataObjects(
+ crossReferenceIDCache,
+ dataObjectToRelativeDNCache,
+ rootDataObject,
+ attributes,
+ namespaceURI,
+ eDataObjectContext,
+ rootContext);
+ }
+
+ eDataGraph.setERootObject(rootDataObject);
+
+ Resource resource = eDataGraph.getRootResource();
+
+ EDataGraphReaderHelper.restoreCrossReferences(
+ crossReferenceIDCache,
+ resource);
+
+ return eDataGraph;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java
new file mode 100644
index 0000000000..1496d91dab
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataGraphReaderHelper.java
@@ -0,0 +1,365 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.read;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EClassImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class EDataGraphReaderHelper
+implements DASConstants
+{
+ public static String calculateRelativeDN(
+ LdapContext containerContext,
+ LdapContext dataObjectContext) throws NamingException
+ {
+ String containerDN = containerContext.getNameInNamespace();
+ String dataObjectDN = dataObjectContext.getNameInNamespace();
+
+ int beginIndex = 0;
+ int endIndex =
+ dataObjectDN.length() - containerDN.length() - 1;
+
+ String result =
+ dataObjectDN.substring(
+ beginIndex,
+ endIndex);
+
+ return result;
+ }
+
+
+ public static EDataObject restoreEDataObject(
+ Map<EDataObject, Map<EStructuralFeature, List<String>>> crossReferenceIDCache,
+ EClass eClass,
+ String namespaceURI,
+ Attributes attributes)
+ throws NamingException
+ {
+ EDataObject eDataObject =
+ (EDataObject)
+ eClass.getEPackage().
+ getEFactoryInstance().
+ create(eClass);
+
+ EDataObjectReaderHelper.
+ restoreEAttributes(
+ eClass,
+ eDataObject,
+ namespaceURI,
+ attributes );
+
+ EStructuralFeature[] eCrossReferences =
+ ((EClassImpl.FeatureSubsetSupplier)
+ eDataObject.
+ eClass().
+ getEAllStructuralFeatures()).
+ crossReferences();
+
+ if (eCrossReferences != null)
+ {
+ Map<EStructuralFeature, List<String>> eReferenceToEObjectIDs =
+ new Hashtable<EStructuralFeature, List<String>>();
+
+ for (EStructuralFeature eReference : eCrossReferences)
+ {
+ String qualifiedEReferenceName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ eReference.getName() );
+
+ String normalizedEReferenceName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEReferenceName);
+
+ if (eReference.isMany())
+ {
+ List<String> idList =
+ new ArrayList<String>();
+
+ Attribute eReferenceAttribute =
+ attributes.get(normalizedEReferenceName);
+
+ NamingEnumeration namingEnumeration =
+ eReferenceAttribute.getAll();
+
+ while (namingEnumeration.hasMore())
+ {
+ String id = (String) namingEnumeration.next();
+ idList.add(id);
+ eReferenceToEObjectIDs.put(eReference, idList);
+ }
+ }
+ else
+ {
+ List<String> idList =
+ new ArrayList<String>();
+
+ String value =
+ (String)
+ attributes.
+ get(normalizedEReferenceName).
+ get();
+
+ idList.add(value);
+ eReferenceToEObjectIDs.put(eReference, idList);
+ }
+ crossReferenceIDCache.put(
+ eDataObject,
+ eReferenceToEObjectIDs);
+ }
+ }
+ return eDataObject;
+ }
+
+ public static void restoreCrossReferences(
+ Map<EDataObject, Map<EStructuralFeature, List<String>>> crossReferenceIDCache,
+ Resource resource)
+ {
+ for (EDataObject eDataObject : crossReferenceIDCache.keySet())
+ {
+ Map<EStructuralFeature, List<String>> eReferenceToIDListMap =
+ crossReferenceIDCache.get(eDataObject);
+
+ for (EStructuralFeature eStructuralFeature : eReferenceToIDListMap.keySet())
+ {
+ if (eStructuralFeature.isMany())
+ {
+ List<String> eReferenceIDs =
+ eReferenceToIDListMap.
+ get(eStructuralFeature);
+
+ EList<EDataObject> multiplicityManyList = null;
+ if (eReferenceIDs.size() > 0)
+ {
+ multiplicityManyList =
+ new BasicEList<EDataObject>();
+ }
+ for (String eReferenceID : eReferenceIDs)
+ {
+ Object referencedDataObject = resource.getEObject(eReferenceID);
+ multiplicityManyList.add((EDataObject) referencedDataObject);
+ eDataObject.eSet(
+ eStructuralFeature,
+ multiplicityManyList);
+ }
+ }
+ else
+ {
+ String eReferenceID =
+ eReferenceToIDListMap.
+ get(eStructuralFeature).
+ get(0);
+
+ Object referencedDataObject = resource.getEObject(eReferenceID);
+ eDataObject.eSet(
+ eStructuralFeature,
+ referencedDataObject);
+ }
+ }
+ }
+ }
+
+ public static void addContainmentDataObjects(
+ Map crossReferenceIDCache,
+ Map<EDataObject, String> dataObjectToRelativeDNCache,
+ EDataObject containerDataObject,
+ Attributes attributes,
+ String namespaceURI,
+ LdapContext eDataObjectContext,
+ LdapContext rootContext) throws NamingException
+ {
+ EClass eClass =
+ containerDataObject.eClass();
+
+ List<EReference> eReferences =
+ eClass.getEAllContainments();
+
+ for (EReference eReference : eReferences)
+ {
+ String qualifiedEReferenceName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ eReference.getName() );
+
+ String normalizedReferenceName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEReferenceName);
+
+ Attribute attribute =
+ attributes.
+ get(normalizedReferenceName);
+
+ if (attribute.size() > 0)
+ {
+ LdapContext eReferenceContainmentContext =
+ (LdapContext)
+ eDataObjectContext.
+ lookup("cn=" + eReference.getName());
+
+ EClass eReferenceType =
+ (EClass) eReference.getEType();
+
+ EAttribute eReferenceTypeEIDAttribute =
+ eReferenceType.getEIDAttribute();
+
+ String qualifiedEReferenceTypeIDEAttributeName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eReferenceType.getName(),
+ eReferenceTypeEIDAttribute.getName() );
+
+ String normalizedReferenceTypeEIDAttributeName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEReferenceTypeIDEAttributeName);
+
+ if (eReference.isMany())
+ {
+ EList<EDataObject> containmentList =
+ new BasicEList<EDataObject>();
+
+ NamingEnumeration idNamingEnumeration =
+ attribute.getAll();
+
+ while(idNamingEnumeration.hasMore())
+ {
+ String containedDataObjectID =
+ (String) idNamingEnumeration.next();
+
+ String containedDataObjectEntryRDN =
+ normalizedReferenceTypeEIDAttributeName
+ + "=" + containedDataObjectID;
+
+ Attributes eReferenceAttributes =
+ eReferenceContainmentContext.
+ getAttributes(containedDataObjectEntryRDN);
+
+
+ EDataObject eReferenceDataObject =
+ EDataGraphReaderHelper.
+ restoreEDataObject(
+ crossReferenceIDCache,
+ eReferenceType,
+ namespaceURI,
+ eReferenceAttributes);
+
+ //TODO Consider using aspects
+ String relativeDN =
+ calculateRelativeDN(
+ rootContext,
+ (LdapContext)
+ eReferenceContainmentContext.
+ lookup(containedDataObjectEntryRDN));
+ dataObjectToRelativeDNCache.put(eReferenceDataObject, relativeDN);
+ //End of Aspect
+
+ containmentList.add(eReferenceDataObject);
+
+ if (eReferenceDataObject.eClass().getEAllContainments().size() > 0)
+ {
+ addContainmentDataObjects(
+ crossReferenceIDCache,
+ dataObjectToRelativeDNCache,
+ eReferenceDataObject,
+ eReferenceAttributes,
+ namespaceURI,
+ (LdapContext) eReferenceContainmentContext.
+ lookup(containedDataObjectEntryRDN),
+ rootContext);
+ }
+ }
+ containerDataObject.eSet(eReference, containmentList);
+ }
+ else
+ {
+ String containedDataObjectID =
+ (String) attribute.get();
+
+ String containedDataObjectEntryRDN =
+ normalizedReferenceTypeEIDAttributeName
+ + "=" + containedDataObjectID;
+
+ Attributes eReferenceAttributes =
+ eReferenceContainmentContext.
+ getAttributes(containedDataObjectEntryRDN);
+
+ EDataObject eReferenceDataObject =
+ EDataGraphReaderHelper.
+ restoreEDataObject(
+ crossReferenceIDCache,
+ eReferenceType,
+ namespaceURI,
+ eReferenceAttributes);
+
+ //TODO Consider using aspects
+ String relativeDN =
+ calculateRelativeDN(
+ rootContext,
+ (LdapContext)
+ eReferenceContainmentContext.
+ lookup(containedDataObjectEntryRDN));
+
+ dataObjectToRelativeDNCache.put(eReferenceDataObject, relativeDN);
+ //End of Aspect
+
+ containerDataObject.eSet(eReference, eReferenceDataObject);
+
+ if (eReferenceDataObject.eClass().getEAllContainments().size() > 0)
+ {
+ addContainmentDataObjects(
+ crossReferenceIDCache,
+ dataObjectToRelativeDNCache,
+ eReferenceDataObject,
+ eReferenceAttributes,
+ namespaceURI,
+ (LdapContext) eReferenceContainmentContext.
+ lookup(containedDataObjectEntryRDN),
+ rootContext);
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java
new file mode 100644
index 0000000000..0c812f4bfc
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReader.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.read;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+
+public class EDataObjectReader
+implements DASConstants
+{
+ /**
+ * Read.
+ *
+ * @param eClass the e class
+ * @param id the id
+ * @param containerContext the container context
+ *
+ * @return the e data object
+ *
+ * @throws NamingException the naming exception
+ *
+ * Note that this is more of a utility, as only this class's
+ * helper is used in restoring the EDataGraph.
+ */
+ public static EDataObject read(
+ EClass eClass,
+ String id,
+ LdapContext containerContext)
+ throws NamingException
+ {
+ String namespaceURI =
+ eClass.getEPackage().
+ getNsURI();
+
+ EAttribute idEAttribute =
+ eClass.getEIDAttribute();
+
+ String qualifiedIDEAttributeName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ idEAttribute.getName() );
+
+ String normalizedIDEAttributeName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedIDEAttributeName);
+
+ String eDataObjectRDN =
+ normalizedIDEAttributeName + "=" + id;
+
+ LdapContext eDataObjectContext =
+ (LdapContext)
+ containerContext.
+ lookup(eDataObjectRDN);
+
+ Attributes attributes =
+ eDataObjectContext.getAttributes("");
+
+ EDataObject eDataObject =
+ (EDataObject)
+ eClass.getEPackage().
+ getEFactoryInstance().
+ create(eClass);
+
+ EDataObjectReaderHelper.
+ restoreEAttributes(
+ eClass,
+ eDataObject,
+ namespaceURI,
+ attributes );
+
+ return eDataObject;
+ }
+} \ No newline at end of file
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java
new file mode 100644
index 0000000000..2fa6321a65
--- /dev/null
+++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/emf/read/EDataObjectReaderHelper.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.tuscany.das.ldap.emf.read;
+
+import java.util.List;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+
+import org.apache.tuscany.das.ldap.constants.DASConstants;
+import org.apache.tuscany.das.ldap.util.QualifiedNameNormalizer;
+import org.apache.tuscany.das.ldap.util.SimpleTypeNamespaceQualifier;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.sdo.EDataObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+public class EDataObjectReaderHelper
+implements DASConstants
+{
+ public static void restoreEAttributes(
+ EClass eClass,
+ EDataObject eDataObject,
+ String namespaceURI,
+ Attributes attributes)
+ throws NamingException
+ {
+ List<EAttribute> eAttributes =
+ eClass.getEAllAttributes();
+
+ for (EAttribute eAttribute : eAttributes)
+ {
+ String qualifiedEAttributeName =
+ SimpleTypeNamespaceQualifier.
+ qualify(
+ namespaceURI,
+ eClass.getName(),
+ eAttribute.getName() );
+
+ String normalizedEAttributeName =
+ QualifiedNameNormalizer.
+ normalize(qualifiedEAttributeName);
+
+ if (eAttribute.isMany())
+ {
+ EList<Object> values =
+ new BasicEList<Object>();
+
+ Attribute attribute =
+ attributes.
+ get(normalizedEAttributeName);
+
+ for (int i = 0; i < attribute.size(); i++)
+ {
+ String value = (String) attribute.get(i);
+
+ values.add(EcoreUtil.createFromString(
+ eAttribute.getEAttributeType(),
+ value));
+ }
+
+ eDataObject.eSet(
+ eAttribute, values);
+ }
+ else
+ {
+ String value =
+ (String)
+ attributes.
+ get(normalizedEAttributeName).
+ get();
+
+ eDataObject.eSet(
+ eAttribute,
+ EcoreUtil.createFromString(
+ eAttribute.getEAttributeType(),
+ value));
+ }
+ }
+ }
+
+
+ //TODO Test all of these verifying that we get out what we put in
+ //TODO Move to helper
+ //TODO Note that we are using eDataObject.eSet(eAttribute, EcoreUtil.createFromString(eAttribute.getEAttributeType(), value)); instead
+ /*
+ public static void setEDataObjectFeature(
+ EDataObject eDataObject,
+ String value,
+ EAttribute eAttribute)
+ {
+ if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEString())
+ {
+ eDataObject.eSet(eAttribute, value);
+ }
+ else if (
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEInt() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEIntegerObject())
+ {
+ eDataObject.eSet(eAttribute, new Integer(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEBooleanObject())
+ {
+ eDataObject.eSet(eAttribute, new Boolean(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEFloat() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEFloatObject())
+ {
+ eDataObject.eSet(eAttribute, new Float(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEDouble() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEDoubleObject())
+ {
+ eDataObject.eSet(eAttribute, new Double(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEBigDecimal())
+ {
+ eDataObject.eSet(eAttribute, new BigDecimal(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEBigInteger() )
+ {
+ eDataObject.eSet(eAttribute, new BigInteger(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByte() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteObject())
+ {
+ eDataObject.eSet(eAttribute, new Byte(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByte() ||
+ eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteObject())
+ {
+ eDataObject.eSet(eAttribute, new Byte(value));
+ }
+ else if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteArray())
+ {
+ throw new RuntimeException("Sorry - ByteArrays are not supported.");
+ }
+ }
+ */
+} \ No newline at end of file