Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 185606 Details for
Bug 332961
ODA Driver Improvements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
changes to oda.ecore
oda_ecore.patch (text/plain), 10.07 KB, created by
Kenn Hussey
on 2010-12-20 20:58:37 EST
(
hide
)
Description:
changes to oda.ecore
Filename:
MIME Type:
Creator:
Kenn Hussey
Created:
2010-12-20 20:58:37 EST
Size:
10.07 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.oda.ecore >Index: src/org/eclipse/emf/oda/ecore/impl/Connection.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.oda.ecore/src/org/eclipse/emf/oda/ecore/impl/Connection.java,v >retrieving revision 1.1 >diff -u -r1.1 Connection.java >--- src/org/eclipse/emf/oda/ecore/impl/Connection.java 5 Dec 2010 01:42:04 -0000 1.1 >+++ src/org/eclipse/emf/oda/ecore/impl/Connection.java 21 Dec 2010 01:48:14 -0000 >@@ -16,6 +16,7 @@ > */ > package org.eclipse.emf.oda.ecore.impl; > >+import java.util.Map; > import java.util.Properties; > > import org.eclipse.datatools.connectivity.oda.IConnection; >@@ -38,16 +39,32 @@ > { > public static final String RESOURCE_PROPERTY_NAME = "resource"; //$NON-NLS-1$ > >+ protected Map< ? , ? > appContext = null; > protected ResourceSet resourceSet = null; > > public void open(Properties connProperties) throws OdaException > { >- String uri = connProperties.getProperty(RESOURCE_PROPERTY_NAME); >+ if (appContext != null) >+ { >+ try >+ { >+ resourceSet = (ResourceSet)appContext.get(ResourceSet.class); >+ } >+ catch (Exception e) >+ { >+ throw new OdaException(e); >+ } >+ } > >- if (!StringUtil.isEmpty(uri)) >+ if (resourceSet == null) > { > resourceSet = new ResourceSetImpl(); >+ } > >+ String uri = connProperties.getProperty(RESOURCE_PROPERTY_NAME); >+ >+ if (!StringUtil.isEmpty(uri)) >+ { > try > { > resourceSet.getResource(URI.createURI(uri), true); >@@ -57,10 +74,6 @@ > throw new OdaException(e); > } > } >- else >- { >- throw new OdaException(new IllegalArgumentException(String.valueOf(connProperties))); >- } > } > > /** >@@ -74,7 +87,19 @@ > > public void setAppContext(Object context) throws OdaException > { >- // do nothing; no support for pass-through context >+ if (context == null && appContext != null) >+ { >+ if (appContext.containsKey(ResourceSet.class)) >+ { >+ resourceSet = null; >+ } >+ >+ appContext = null; >+ } >+ else if (context instanceof Map< ? , ? >) >+ { >+ appContext = (Map< ? , ? >)context; >+ } > } > > public void close() throws OdaException >Index: src/org/eclipse/emf/oda/ecore/impl/Query.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.oda.ecore/src/org/eclipse/emf/oda/ecore/impl/Query.java,v >retrieving revision 1.1 >diff -u -r1.1 Query.java >--- src/org/eclipse/emf/oda/ecore/impl/Query.java 5 Dec 2010 01:42:04 -0000 1.1 >+++ src/org/eclipse/emf/oda/ecore/impl/Query.java 21 Dec 2010 01:48:14 -0000 >@@ -16,6 +16,7 @@ > */ > package org.eclipse.emf.oda.ecore.impl; > >+import java.lang.reflect.InvocationTargetException; > import java.math.BigDecimal; > import java.sql.Date; > import java.sql.Time; >@@ -37,6 +38,7 @@ > import org.eclipse.emf.common.util.TreeIterator; > import org.eclipse.emf.common.util.URI; > import org.eclipse.emf.common.util.UniqueEList; >+import org.eclipse.emf.ecore.EClass; > import org.eclipse.emf.ecore.EClassifier; > import org.eclipse.emf.ecore.resource.ResourceSet; > import org.eclipse.emf.ecore.util.EcoreUtil; >@@ -58,6 +60,7 @@ > > protected QuerySpecification specification = null; > >+ protected QueryDelegate.Factory factory = null; > protected QueryDelegate delegate = null; > protected EClassifier context = null; > protected Map<String, EClassifier> variables = null; >@@ -140,7 +143,7 @@ > > try > { >- QueryDelegate.Factory factory = (QueryDelegate.Factory)QueryDelegate.Factory.Registry.INSTANCE.get((String)specification.getProperty(DELEGATE_PROPERTY_NAME)); >+ factory = (QueryDelegate.Factory)QueryDelegate.Factory.Registry.INSTANCE.get((String)specification.getProperty(DELEGATE_PROPERTY_NAME)); > > ResourceSet resourceSet = connection.getResourceSet(); > >@@ -177,80 +180,160 @@ > return ResultSetMetaData.create(type); > } > >+ protected EList<Object> getAllObjectsByType(EList<Object> objects, EClassifier type) >+ { >+ for (TreeIterator<Object> allContents = EcoreUtil.getAllContents(connection.getResourceSet(), true); allContents.hasNext();) >+ { >+ Object next = allContents.next(); >+ >+ if (type.isInstance(next)) >+ { >+ objects.add(next); >+ } >+ } >+ >+ return objects; >+ } >+ >+ protected EList<Object> getResults( >+ EList<Object> results, >+ QueryDelegate delegate, >+ EList<Object> targets, >+ Map<String, Object> arguments, >+ EClassifier type) throws InvocationTargetException >+ { >+ for (Object target : targets) >+ { >+ Object result = delegate.execute(target, arguments); >+ >+ if (result instanceof Collection< ? >) >+ { >+ results.addAll(EcoreUtil.getObjectsByType((Collection< ? >)result, type)); >+ } >+ else if (type.isInstance(result)) >+ { >+ results.add(result); >+ } >+ } >+ >+ return results; >+ } >+ > public IResultSet executeQuery() throws OdaException > { > assertPrepared(); > > EList<Object> targets = new UniqueEList.FastCompare<Object>(); >- > Map<String, Object> arguments = new HashMap<String, Object>(); > >- for (Map.Entry<ParameterIdentifier, ? > entry : specification.getParameterValues().entrySet()) >+ Map<ParameterIdentifier, ? > parameterValues = specification.getParameterValues(); >+ >+ if (!parameterValues.isEmpty()) > { >- String name = entry.getKey().getParameterName(); >+ Object targetArgument = null; >+ >+ Map<String, EClassifier> dataTypeParameters = new HashMap<String, EClassifier>(); >+ Map<String, Object> dataTypeArguments = new HashMap<String, Object>(); > >- if (!StringUtil.isEmpty(name)) >+ Map<String, Object> classArguments = new HashMap<String, Object>(); >+ >+ for (Map.Entry<ParameterIdentifier, ? > entry : parameterValues.entrySet()) > { >- Object value = entry.getValue(); >+ String name = entry.getKey().getParameterName(); > >- if (value instanceof ResultSet.JavaObject) >+ if (!StringUtil.isEmpty(name)) > { >- value = ((ResultSet.JavaObject)value).getObject(); >- } >+ Object value = entry.getValue(); > >- if (ParameterMetaData.TARGET_PARAMETER_NAME.equals(name)) >- { >- if (value != null && !ParameterMetaData.DEFAULT_PARAMETER_VALUE.equals(value)) >+ if (value instanceof ResultSet.JavaObject) > { >- if (value instanceof Collection< ? >) >+ value = ((ResultSet.JavaObject)value).getObject(); >+ } >+ >+ if (value != null) >+ { >+ if (ParameterMetaData.TARGET_PARAMETER_NAME.equals(name)) > { >- targets.addAll((Collection< ? >)value); >+ targetArgument = value; > } > else > { >- targets.add(value); >+ EClassifier type = variables.get(name); >+ >+ if (type instanceof EClass) >+ { >+ classArguments.put(name, value); >+ } >+ else >+ { >+ dataTypeParameters.put(name, type); >+ dataTypeArguments.put(name, value); >+ } > } > } > } >- else >- { >- arguments.put(name, value); >- } > } >- } > >- try >- { >- if (targets.isEmpty()) >+ if (targetArgument == null || ParameterMetaData.DEFAULT_PARAMETER_VALUE.equals(targetArgument)) >+ { >+ getAllObjectsByType(targets, context); >+ } >+ else if (targetArgument instanceof String) > { >- for (TreeIterator<Object> allContents = EcoreUtil.getAllContents(connection.getResourceSet(), true); allContents.hasNext();) >+ try > { >- Object next = allContents.next(); >- >- if (context.isInstance(next)) >- { >- targets.add(next); >- } >+ QueryDelegate delegate = factory.createQueryDelegate(context, dataTypeParameters, (String)targetArgument); >+ getResults(targets, delegate, getAllObjectsByType(new UniqueEList.FastCompare<Object>(), context), dataTypeArguments, context); >+ } >+ catch (Exception e) >+ { >+ throw new OdaException(e); > } > } >+ else if (targetArgument instanceof Collection< ? >) >+ { >+ targets.addAll((Collection< ? >)targetArgument); >+ } >+ else >+ { >+ targets.add(targetArgument); >+ } > >- EList<Object> results = new UniqueEList<Object>(); >+ arguments.putAll(dataTypeArguments); > >- for (Object target : targets) >+ for (Map.Entry<String, Object> entry : classArguments.entrySet()) > { >- Object result = delegate.execute(target, arguments); >+ String name = entry.getKey(); >+ Object value = entry.getValue(); > >- if (result instanceof Collection< ? >) >- { >- results.addAll(EcoreUtil.getObjectsByType((Collection< ? >)result, type)); >- } >- else if (type.isInstance(result)) >+ if (value instanceof String) > { >- results.add(result); >+ EClassifier type = variables.get(name); >+ EList<Object> values = getAllObjectsByType(new UniqueEList.FastCompare<Object>(), type); >+ >+ if (!ParameterMetaData.DEFAULT_PARAMETER_VALUE.equals(value)) >+ { >+ try >+ { >+ QueryDelegate delegate = factory.createQueryDelegate(type, dataTypeParameters, (String)value); >+ values = getResults(new UniqueEList.FastCompare<Object>(), delegate, values, dataTypeArguments, type); >+ } >+ catch (Exception e) >+ { >+ throw new OdaException(e); >+ } >+ } >+ >+ value = values.isEmpty() ? null : values.iterator().next(); > } >+ >+ arguments.put(name, value); > } >+ } > >- IResultSet resultSet = ResultSet.create(type, results); >+ try >+ { >+ IResultSet resultSet = ResultSet.create(type, getResults(new UniqueEList<Object>(), delegate, targets, arguments, type)); > resultSet.setMaxRows(getMaxRows()); > return resultSet; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 332961
:
185584
| 185606 |
185607