teiid SVN: r2749 - branches/7.1.x/runtime/src/main/java/org/teiid/deployers.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-11-30 13:55:44 -0500 (Tue, 30 Nov 2010)
New Revision: 2749
Modified:
branches/7.1.x/runtime/src/main/java/org/teiid/deployers/ObjectSerializer.java
branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
Log:
TEIID-1380: Based on the last modified time of the VDB file, the old serialized metadata file will be deleted if the VDB file is updated during server shutdown.
Modified: branches/7.1.x/runtime/src/main/java/org/teiid/deployers/ObjectSerializer.java
===================================================================
--- branches/7.1.x/runtime/src/main/java/org/teiid/deployers/ObjectSerializer.java 2010-11-30 09:03:48 UTC (rev 2748)
+++ branches/7.1.x/runtime/src/main/java/org/teiid/deployers/ObjectSerializer.java 2010-11-30 18:55:44 UTC (rev 2749)
@@ -80,6 +80,10 @@
}
}
+ public boolean isStale(File cacheFile, long timeAfter) {
+ return (cacheFile.exists() && timeAfter > cacheFile.lastModified());
+ }
+
public void removeAttachments(VFSDeploymentUnit vf) {
String dirName = baseDirectory(vf);
FileUtils.removeDirectoryAndChildren(new File(dirName));
Modified: branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-11-30 09:03:48 UTC (rev 2748)
+++ branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-11-30 18:55:44 UTC (rev 2749)
@@ -43,7 +43,6 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
-import org.teiid.core.util.FileUtils;
import org.teiid.dqp.internal.datamgr.ConnectorManager;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.TranslatorRepository;
@@ -236,7 +235,7 @@
deployment.setRemoved(true);
try {
- deleteMetadataStore((VFSDeploymentUnit)unit, deployment);
+ deleteMetadataStore((VFSDeploymentUnit)unit);
} catch (IOException e) {
LogManager.logWarning(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_delete_failed", e.getMessage())); //$NON-NLS-1$
}
@@ -249,18 +248,17 @@
}
private void saveMetadataStore(VFSDeploymentUnit unit, VDBMetaData vdb, MetadataStoreGroup store) throws IOException {
- File cacheFileName = this.serializer.getAttachmentPath(unit, vdb.getName()+"_"+vdb.getVersion()); //$NON-NLS-1$
+ File cacheFileName = buildCachedVDBFileName(this.serializer, unit, vdb);
if (!cacheFileName.exists()) {
this.serializer.saveAttachment(cacheFileName,store);
- }
+ LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+unit.getRoot().getName()+" metadata has been cached to "+ cacheFileName); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
- private void deleteMetadataStore(VFSDeploymentUnit unit, VDBMetaData vdb) throws IOException {
+ private void deleteMetadataStore(VFSDeploymentUnit unit) throws IOException {
if (!unit.getRoot().exists() || !shutdownListener.isShutdownInProgress()) {
- File cacheFileName = this.serializer.getAttachmentPath(unit, vdb.getName()+"_"+vdb.getVersion()); //$NON-NLS-1$
- if (cacheFileName.exists()) {
- FileUtils.removeDirectoryAndChildren(cacheFileName.getParentFile());
- }
+ this.serializer.removeAttachments(unit);
+ LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+unit.getRoot().getName()+" metadata removed"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -273,7 +271,7 @@
}
final boolean cache = "cached".equalsIgnoreCase(vdb.getPropertyValue("UseConnectorMetadata")); //$NON-NLS-1$ //$NON-NLS-2$
- final File cacheFile = buildCachedFileName(unit, vdb, model.getName());
+ final File cacheFile = buildCachedModelFileName(unit, vdb, model.getName());
boolean loaded = false;
if (cache) {
MetadataStore store = this.serializer.loadSafe(cacheFile, MetadataStore.class);
@@ -346,10 +344,14 @@
}
}
- private File buildCachedFileName(VFSDeploymentUnit unit, VDBMetaData vdb, String modelName) {
+ private File buildCachedModelFileName(VFSDeploymentUnit unit, VDBMetaData vdb, String modelName) {
return this.serializer.getAttachmentPath(unit, vdb.getName()+"_"+vdb.getVersion()+"_"+modelName); //$NON-NLS-1$ //$NON-NLS-2$
}
+ static File buildCachedVDBFileName(ObjectSerializer serializer, VFSDeploymentUnit unit, VDBMetaData vdb) {
+ return serializer.getAttachmentPath(unit, vdb.getName()+"_"+vdb.getVersion()); //$NON-NLS-1$
+ }
+
public void setTranslatorRepository(TranslatorRepository repo) {
this.translatorRepository = repo;
}
Modified: branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
===================================================================
--- branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-11-30 09:03:48 UTC (rev 2748)
+++ branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-11-30 18:55:44 UTC (rev 2749)
@@ -142,12 +142,21 @@
unit.addAttachment(IndexMetadataFactory.class, imf);
// add the cached store.
- File cacheFile = this.serializer.getAttachmentPath(unit, vdb.getName()+"_"+vdb.getVersion()); //$NON-NLS-1$
+ File cacheFile = VDBDeployer.buildCachedVDBFileName(this.serializer, unit, vdb);
+ // check to see if the vdb has been modified when server is down; if it is then clear the old files
+ if (this.serializer.isStale(cacheFile, unit.getRoot().getLastModified())) {
+ this.serializer.removeAttachments(unit);
+ LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+unit.getRoot().getName()+" old cached metadata has been removed"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
MetadataStoreGroup stores = this.serializer.loadSafe(cacheFile, MetadataStoreGroup.class);
- if (stores == null) {
+ if (stores == null) {
+ // start to build the new metadata
stores = new MetadataStoreGroup();
stores.addStore(imf.getMetadataStore(vdbRepository.getSystemStore().getDatatypes()));
}
+ else {
+ LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+unit.getRoot().getName()+" has being loaded from cached metadata"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
unit.addAttachment(MetadataStoreGroup.class, stores);
}
14 years
teiid SVN: r2748 - in branches/7.1.x/console/src/main: resources/META-INF and 1 other directory.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-11-30 04:03:48 -0500 (Tue, 30 Nov 2010)
New Revision: 2748
Modified:
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
Log:
TEIID-1364: Added a property to the Data Services tab to enable/disable filtering of preview VDBs.
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-11-29 21:03:01 UTC (rev 2747)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-11-30 09:03:48 UTC (rev 2748)
@@ -179,7 +179,6 @@
try {
managementView.updateComponent(managedComponent);
- managementView.load();
} catch (Exception e) {
LOG.error("Unable to update component [" //$NON-NLS-1$
+ managedComponent.getName() + "] of type " //$NON-NLS-1$
@@ -193,6 +192,8 @@
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessageFromThrowable(e);
}
+
+ managementView.load();
}
@@ -205,8 +206,8 @@
public Configuration loadResourceConfiguration() {
// Get plugin config
- Configuration c = resourceContext.getPluginConfiguration();
-
+ Configuration c = resourceConfiguration;
+
getProperties(c);
return c;
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-11-29 21:03:01 UTC (rev 2747)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-11-30 09:03:48 UTC (rev 2748)
@@ -90,8 +90,7 @@
);
Configuration configuration = detail.getPluginConfiguration();
- configuration.put(new PropertySimple(
- PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT, 600));
+ configuration.put(new PropertySimple("displayPreviewVDBS", Boolean.FALSE));
detail.setPluginConfiguration(configuration);
// Add to return values
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-11-29 21:03:01 UTC (rev 2747)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-11-30 09:03:48 UTC (rev 2748)
@@ -28,6 +28,10 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.plugins.ManagedObjectImpl;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.GenericValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
@@ -58,9 +62,35 @@
.getManagedComponents(connection, new ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE));
-
+
+ PropertySimple displayPreviewVdbs = ((PlatformComponent)discoveryContext.getParentResourceComponent()).getResourceConfiguration().getSimple("displayPreviewVDBS");
+
for (ManagedComponent mcVdb : vdbs) {
+ boolean skipVdb = false;
+ if (!displayPreviewVdbs.getBooleanValue()){
+ MetaValue[] propsArray = ((CollectionValueSupport)mcVdb.getProperty("JAXBProperties").getValue()).getElements();
+ String isPreview = "false";
+
+ for (MetaValue propertyMetaData : propsArray) {
+ GenericValueSupport genValueSupport = (GenericValueSupport) propertyMetaData;
+ ManagedObjectImpl managedObject = (ManagedObjectImpl) genValueSupport
+ .getValue();
+
+ String propertyName = ProfileServiceUtil.getSimpleValue(
+ managedObject, "name", String.class);
+ if (propertyName.equals("preview")){
+ isPreview =ProfileServiceUtil.getSimpleValue(
+ managedObject, "value", String.class);
+ if (Boolean.valueOf(isPreview)) skipVdb=true;
+ break;
+ }
+ }
+ }
+
+ //If this is a Preview VDB and displayPreviewVdbs is false, skip this VDB
+ if (skipVdb) continue;
+
String vdbKey = (String)mcVdb.getName();
String vdbName = vdbKey;
String fullName = ProfileServiceUtil.getSimpleValue(mcVdb, "fullName",
Modified: branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml 2010-11-29 21:03:01 UTC (rev 2747)
+++ branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml 2010-11-30 09:03:48 UTC (rev 2748)
@@ -296,6 +296,13 @@
property="QUERY_SERVICE_RESULT_SET_CACHE.requestCount" description="Total number of requests made against cache" />
<resource-configuration>
+ <c:group name="SessionSettings" displayName="Settings for the Data Services plugin. Will be reset with a server restart."
+ hiddenByDefault="false">
+ <c:simple-property name="displayPreviewVDBS" displayName="Display Preview VDBs"
+ description="If 'Yes', Preview VDBs (created by the Teiid Designer) will display in the Virtual Database resource grouping. The default is 'No'"
+ required="true" readOnly="false" type="boolean" default="true" />
+ </c:group>
+
<c:group name="RuntimeEngineDeployer" displayName="Runtime Engine Properties (restart required before modifications take effect)"
hiddenByDefault="false">
<c:simple-property name="RuntimeEngineDeployer.maxRowsFetchSize"
14 years
teiid SVN: r2747 - in branches/7.1.x/console/src/main: java/org/teiid/rhq/plugin and 2 other directories.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-11-29 16:03:01 -0500 (Mon, 29 Nov 2010)
New Revision: 2747
Modified:
branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
Log:
TEIID-1367: Added VDB level operation to clear the cache for Result Sets or Prepared Plans.
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-11-24 20:56:57 UTC (rev 2746)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-11-29 21:03:01 UTC (rev 2747)
@@ -274,6 +274,20 @@
MetaValue resultsMetaValue = executeMaterializedViewQuery( connection, vdbName, Integer.parseInt(vdbVersion));
getResultsCollectionValue(resultsMetaValue, sqlResultsObject);
operationResult.setContent(createReportResultListForMatViewQuery(fieldNameList, sqlResultsObject.iterator()));
+ } else if (operationName.equals(VDB.Operations.CLEAR_CACHE)) {
+
+ try {
+ executeClearCache( connection, vdbName, Integer.parseInt(vdbVersion),
+ (String) valueMap.get(Operation.Value.CACHE_TYPE));
+
+ }catch(Exception e){
+ //Some failure during Clear Cache. Set message here since it has already been logged.
+ operationResult.setContent("failure - see log for details"); //$NON-NLS-1$
+ }
+
+ //If no exceptions, we assume the clear cache worked
+ operationResult.setContent("cache successfully cleared!"); //$NON-NLS-1$
+
} else if (operationName.equals(VDB.Operations.RELOAD_MATVIEW)) {
MetaValue resultsMetaValue = reloadMaterializedView(connection, vdbName, Integer.parseInt(vdbVersion),
(String) valueMap.get(Operation.Value.MATVIEW_SCHEMA),
@@ -330,6 +344,22 @@
}
+ protected void executeClearCache(
+ ProfileServiceConnection connection, String vdbName, int vdbVersion, String cacheType) throws Exception {
+
+ MetaValue[] args = new MetaValue[] {SimpleValueSupport.wrap(cacheType),
+ SimpleValueSupport.wrap(vdbName),
+ SimpleValueSupport.wrap(vdbVersion) };
+
+ try {
+ executeManagedOperation(connection, getRuntimeEngineDeployer(connection, mc), VDB.Operations.CLEAR_CACHE, args);
+ } catch (Exception e) {
+ final String msg = "Exception executing operation: " + VDB.Operations.EXECUTE_QUERIES; //$NON-NLS-1$
+ LOG.error(msg, e);
+ throw e;
+ }
+ }
+
protected MetaValue executeMaterializedViewQuery(
ProfileServiceConnection connection, String vdbName, int vdbVersion) {
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-11-24 20:56:57 UTC (rev 2746)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-11-29 21:03:01 UTC (rev 2747)
@@ -105,7 +105,7 @@
null));
String version = VDB.VERSION;
valueMap.put(version, this.resourceConfiguration.getSimpleValue(
- "version", null));
+ VDB.VERSION, null));
// Parameter logic for VDB Operations
if (name.equals(VDB.Operations.KILL_REQUEST)) {
@@ -113,6 +113,9 @@
Operation.Value.REQUEST_ID).getLongValue());
valueMap.put(Operation.Value.SESSION_ID, configuration.getSimple(
Operation.Value.SESSION_ID).getLongValue());
+ } else if (name.equals(VDB.Operations.CLEAR_CACHE)) {
+ valueMap.put(Operation.Value.CACHE_TYPE, configuration.getSimple(
+ Operation.Value.CACHE_TYPE).getStringValue());
} else if (name.equals(Platform.Operations.KILL_SESSION)) {
valueMap.put(Operation.Value.SESSION_ID, configuration.getSimple(
Operation.Value.SESSION_ID).getLongValue());
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-11-24 20:56:57 UTC (rev 2746)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-11-29 21:03:01 UTC (rev 2747)
@@ -98,6 +98,7 @@
public static interface Operations {
public final static String GET_QUERIES = "listQueries"; //$NON-NLS-1$
+ public final static String CLEAR_CACHE = "clearCache"; //$NON-NLS-1$
public final static String EXECUTE_QUERIES = "executeQuery"; //$NON-NLS-1$
public final static String GET_LONGRUNNINGQUERIES = "getLongRunningRequests"; //$NON-NLS-1$
public final static String KILL_REQUEST = "cancelRequest"; //$NON-NLS-1$
@@ -253,6 +254,7 @@
public final static String MATVIEW_SCHEMA = "schema"; //$NON-NLS-1$
public final static String MATVIEW_TABLE = "table"; //$NON-NLS-1$
public final static String INVALIDATE_MATVIEW = "invalidate"; //$NON-NLS-1$
+ public final static String CACHE_TYPE = "cacheType"; //$NON-NLS-1$
}
Modified: branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml 2010-11-24 20:56:57 UTC (rev 2746)
+++ branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml 2010-11-29 21:03:01 UTC (rev 2747)
@@ -526,7 +526,26 @@
type="string" description="Result of refresh" />
</results>
</operation>
+
+ <operation name="clearCache" displayName="Clear Cache"
+ description="Clears the cache for a given type for this VDB">
+ <parameters>
+ <c:simple-property displayName="Cache Type"
+ name="cacheType" type="string" required="true"
+ description="The cache type to clear" default="QUERY_SERVICE_RESULT_SET_CACHE">
+ <c:property-options>
+ <c:option value="QUERY_SERVICE_RESULT_SET_CACHE" default="true" name="Result Set" />
+ <c:option value="PREPARED_PLAN_CACHE" name="Prepared Plan" />
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ <results>
+ <c:simple-property displayName="Result" name="operationResult"
+ type="string" description="Result of clear cache" />
+ </results>
+ </operation>
+
<metric displayName="Status" defaultOn="true" dataType="trait"
displayType="summary" category="availability" property="status"
description="The status of this VDB" />
14 years
teiid SVN: r2746 - in trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution: visitors and 1 other directory.
by teiid-commits@lists.jboss.org
Author: jdoyle
Date: 2010-11-24 15:56:57 -0500 (Wed, 24 Nov 2010)
New Revision: 2746
Modified:
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/SelectVisitor.java
Log:
TEIID-1362
The Salesforce API created for CXF does not drill through the SF objects so that you can get the join results. This change drills down through the XML looking for the child objects.
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java 2010-11-24 18:41:55 UTC (rev 2745)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java 2010-11-24 20:56:57 UTC (rev 2746)
@@ -32,7 +32,6 @@
import java.util.Map;
import javax.resource.ResourceException;
-import javax.xml.namespace.QName;
import org.teiid.language.AggregateFunction;
import org.teiid.language.Join;
@@ -56,12 +55,22 @@
import org.teiid.translator.salesforce.execution.visitors.JoinQueryVisitor;
import org.teiid.translator.salesforce.execution.visitors.SelectVisitor;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import com.sforce.soap.partner.QueryResult;
import com.sforce.soap.partner.sobject.SObject;
public class QueryExecutionImpl implements ResultSetExecution {
+ private static final String SF_ID = "sf:Id";
+
+ private static final String SF_TYPE = "sf:type";
+
+ private static final String SF_S_OBJECT = "sf:sObject";
+
+ private static final String XSI_TYPE = "xsi:type";
+
private SalesforceConnection connection;
private RuntimeMetadata metadata;
@@ -123,7 +132,6 @@
visitor.visitNode(query);
finalQuery = visitor.getQuery().trim();
LogManager.logDetail(LogConstants.CTX_CONNECTOR, getLogPreamble(), "Executing Query:", finalQuery); //$NON-NLS-1$
-
results = connection.query(finalQuery, this.context.getBatchSize(), visitor.getQueryAll());
} else {
visitor = new SelectVisitor(metadata);
@@ -202,27 +210,77 @@
List<Object> topFields = sObject.getAny();
logAndMapFields(sObject.getType(), topFields);
List<Object[]> result = new ArrayList<Object[]>();
- for(int i = 0; i < topFields.size(); i++) {
- Element element = (Element) topFields.get(i);
- QName qName = new QName(element.getNamespaceURI(), element.getLocalName());
- if(null != qName) {
- String type = qName.getLocalPart();
- if(type.equals("sObject")) { //$NON-NLS-1$
- //SObject parent = (SObject)element.;
- //result.addAll(getObjectData(parent));
- } else if(type.equals("QueryResult")) { //$NON-NLS-1$
- //QueryResult subResult = (QueryResult)element.getValue();
- //for(int resultIndex = 0; resultIndex < subResult.getSize(); resultIndex++) {
- // SObject subObject = subResult.getRecords().get(resultIndex);
- // result.addAll(getObjectData(subObject));
- //}
- }
+ if(visitor instanceof JoinQueryVisitor) {
+ for(int i = 0; i < topFields.size(); i++) {
+ Element element = (Element) topFields.get(i);
+ extactJoinResults(element, result);
}
}
return extractDataFromFields(sObject, topFields, result);
-
+
}
+ private void extactJoinResults(Element node, List<Object[]> result) throws TranslatorException {
+ if(isSObject(node)) {
+ extractValuesFromElement(node, result);
+ } else {
+ NodeList children = node.getChildNodes();
+ if(null != children && children.getLength() > 0) {
+ for( int i = 0; i < children.getLength(); i++) {
+ Node item = children.item(i);
+ if(item instanceof Element) {
+ Element childElement = (Element)item;
+ if(isSObject(childElement)) {
+ extractValuesFromElement(childElement, result);
+ } else if(item.getChildNodes().getLength() > 0) {
+ extactJoinResults(childElement, result);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private List<Object[]> extractValuesFromElement(Element sObject,
+ List<Object[]> result) throws TranslatorException {
+ Element typeElement = (Element) sObject.getElementsByTagName(SF_TYPE).item(0);
+ String sObjectName = typeElement.getFirstChild().getNodeValue();
+ Object[] row = new Object[visitor.getSelectSymbolCount()];
+ for (int j = 0; j < visitor.getSelectSymbolCount(); j++) {
+ Column element = visitor.getSelectSymbolMetadata(j);
+ AbstractMetadataRecord parent = element.getParent();
+ Table table;
+ if(parent instanceof Table) {
+ table = (Table)parent;
+ } else {
+ parent = parent.getParent();
+ if(parent instanceof Table) {
+ table = (Table)parent;
+ } else {
+ throw new TranslatorException("Could not resolve Table for column " + element.getName()); //$NON-NLS-1$
+ }
+ }
+ if(table.getNameInSource().equals(sObjectName)) {
+ Integer index = visitor.getSelectSymbolIndex(sObjectName + ':' + element.getNameInSource());
+ // id gets dropped from the result if it is not the
+ // first field in the querystring. Add it back in.
+ if (null == index) {
+ if (element.getNameInSource().equalsIgnoreCase("id")) { //$NON-NLS-1$
+ setElementValueInColumn(j, sObject.getElementsByTagName(SF_ID), row);
+ } else {
+ throw new TranslatorException(SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.missing.field")+ element.getNameInSource()); //$NON-NLS-1$
+ }
+ } else {
+ Object cell;
+ cell = sObject.getElementsByTagName("sf:" + element.getNameInSource()).item(0);
+ setElementValueInColumn(j, cell, row);
+ }
+ }
+ }
+ result.add(row);
+ return result;
+ }
+
private List<Object[]> extractDataFromFields(SObject sObject,
List<Object> fields, List<Object[]> result) throws TranslatorException {
Map<String,Integer> fieldToIndexMap = sObjectToResponseField.get(sObject.getType());
@@ -260,6 +318,14 @@
return result;
}
+ private void setElementValueInColumn(int columnIndex, Object value, Object[] row) {
+ if(value instanceof Element) {
+ row[columnIndex] = ((Element)value).getFirstChild().getNodeValue();
+ } else {
+ row[columnIndex] = value;
+ }
+ }
+
private void setValueInColumn(int columnIndex, Object value, List<Object[]> result) {
if(result.isEmpty()) {
Object[] row = new Object[visitor.getSelectSymbolCount()];
@@ -271,7 +337,7 @@
row[columnIndex] = value;
}
}
-
+
/**
* Load the map of response field names to index.
* @param fields
@@ -353,8 +419,12 @@
}
return result;
}
+
+ private boolean isSObject(Element element) {
+ String type = element.getAttribute(XSI_TYPE);
+ return type != null && type.equals(SF_S_OBJECT);
+ }
-
private String getLogPreamble() {
if (null == logPreamble) {
StringBuffer preamble = new StringBuffer();
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/SelectVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/SelectVisitor.java 2010-11-24 18:41:55 UTC (rev 2745)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/SelectVisitor.java 2010-11-24 20:56:57 UTC (rev 2746)
@@ -74,7 +74,8 @@
if (expression instanceof ColumnReference) {
Column element = ((ColumnReference) expression).getMetadataObject();
selectSymbolIndexToElement.put(index, element);
- selectSymbolNameToIndex .put(element.getNameInSource(), index);
+ String qualifiedName = element.getParent().getNameInSource() + ':' + element.getNameInSource();
+ selectSymbolNameToIndex .put(qualifiedName, index);
String nameInSource = element.getNameInSource();
if (null == nameInSource || nameInSource.length() == 0) {
exceptions.add(new TranslatorException("name in source is null or empty for column "+ symbol.toString()));
@@ -182,6 +183,10 @@
return result;
}
+ public Integer getSelectSymbolIndex(String name) {
+ return selectSymbolNameToIndex.get(name);
+ }
+
/**
* Returns the index of the ID column.
* @return the index of the ID column, -1 if there is no ID column.
14 years
teiid SVN: r2745 - in branches/7.1.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution: visitors and 1 other directory.
by teiid-commits@lists.jboss.org
Author: jdoyle
Date: 2010-11-24 13:41:55 -0500 (Wed, 24 Nov 2010)
New Revision: 2745
Modified:
branches/7.1.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java
branches/7.1.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/SelectVisitor.java
Log:
TEIID-1362
The Salesforce API created for CXF does not drill through the SF objects so that you can get the join results. This change drills down through the XML looking for the child objects.
Modified: branches/7.1.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java
===================================================================
--- branches/7.1.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java 2010-11-24 18:15:45 UTC (rev 2744)
+++ branches/7.1.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java 2010-11-24 18:41:55 UTC (rev 2745)
@@ -32,7 +32,6 @@
import java.util.Map;
import javax.resource.ResourceException;
-import javax.xml.namespace.QName;
import org.teiid.language.AggregateFunction;
import org.teiid.language.Join;
@@ -56,12 +55,22 @@
import org.teiid.translator.salesforce.execution.visitors.JoinQueryVisitor;
import org.teiid.translator.salesforce.execution.visitors.SelectVisitor;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import com.sforce.soap.partner.QueryResult;
import com.sforce.soap.partner.sobject.SObject;
public class QueryExecutionImpl implements ResultSetExecution {
+ private static final String SF_ID = "sf:Id";
+
+ private static final String SF_TYPE = "sf:type";
+
+ private static final String SF_S_OBJECT = "sf:sObject";
+
+ private static final String XSI_TYPE = "xsi:type";
+
private SalesforceConnection connection;
private RuntimeMetadata metadata;
@@ -123,7 +132,6 @@
visitor.visitNode(query);
finalQuery = visitor.getQuery().trim();
LogManager.logDetail(LogConstants.CTX_CONNECTOR, getLogPreamble(), "Executing Query:", finalQuery); //$NON-NLS-1$
-
results = connection.query(finalQuery, this.context.getBatchSize(), visitor.getQueryAll());
} else {
visitor = new SelectVisitor(metadata);
@@ -202,27 +210,77 @@
List<Object> topFields = sObject.getAny();
logAndMapFields(sObject.getType(), topFields);
List<Object[]> result = new ArrayList<Object[]>();
- for(int i = 0; i < topFields.size(); i++) {
- Element element = (Element) topFields.get(i);
- QName qName = new QName(element.getNamespaceURI(), element.getLocalName());
- if(null != qName) {
- String type = qName.getLocalPart();
- if(type.equals("sObject")) { //$NON-NLS-1$
- //SObject parent = (SObject)element.;
- //result.addAll(getObjectData(parent));
- } else if(type.equals("QueryResult")) { //$NON-NLS-1$
- //QueryResult subResult = (QueryResult)element.getValue();
- //for(int resultIndex = 0; resultIndex < subResult.getSize(); resultIndex++) {
- // SObject subObject = subResult.getRecords().get(resultIndex);
- // result.addAll(getObjectData(subObject));
- //}
- }
+ if(visitor instanceof JoinQueryVisitor) {
+ for(int i = 0; i < topFields.size(); i++) {
+ Element element = (Element) topFields.get(i);
+ extactJoinResults(element, result);
}
}
return extractDataFromFields(sObject, topFields, result);
-
+
}
+ private void extactJoinResults(Element node, List<Object[]> result) throws TranslatorException {
+ if(isSObject(node)) {
+ extractValuesFromElement(node, result);
+ } else {
+ NodeList children = node.getChildNodes();
+ if(null != children && children.getLength() > 0) {
+ for( int i = 0; i < children.getLength(); i++) {
+ Node item = children.item(i);
+ if(item instanceof Element) {
+ Element childElement = (Element)item;
+ if(isSObject(childElement)) {
+ extractValuesFromElement(childElement, result);
+ } else if(item.getChildNodes().getLength() > 0) {
+ extactJoinResults(childElement, result);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private List<Object[]> extractValuesFromElement(Element sObject,
+ List<Object[]> result) throws TranslatorException {
+ Element typeElement = (Element) sObject.getElementsByTagName(SF_TYPE).item(0);
+ String sObjectName = typeElement.getFirstChild().getNodeValue();
+ Object[] row = new Object[visitor.getSelectSymbolCount()];
+ for (int j = 0; j < visitor.getSelectSymbolCount(); j++) {
+ Column element = visitor.getSelectSymbolMetadata(j);
+ AbstractMetadataRecord parent = element.getParent();
+ Table table;
+ if(parent instanceof Table) {
+ table = (Table)parent;
+ } else {
+ parent = parent.getParent();
+ if(parent instanceof Table) {
+ table = (Table)parent;
+ } else {
+ throw new TranslatorException("Could not resolve Table for column " + element.getName()); //$NON-NLS-1$
+ }
+ }
+ if(table.getNameInSource().equals(sObjectName)) {
+ Integer index = visitor.getSelectSymbolIndex(sObjectName + ':' + element.getNameInSource());
+ // id gets dropped from the result if it is not the
+ // first field in the querystring. Add it back in.
+ if (null == index) {
+ if (element.getNameInSource().equalsIgnoreCase("id")) { //$NON-NLS-1$
+ setElementValueInColumn(j, sObject.getElementsByTagName(SF_ID), row);
+ } else {
+ throw new TranslatorException(SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.missing.field")+ element.getNameInSource()); //$NON-NLS-1$
+ }
+ } else {
+ Object cell;
+ cell = sObject.getElementsByTagName("sf:" + element.getNameInSource()).item(0);
+ setElementValueInColumn(j, cell, row);
+ }
+ }
+ }
+ result.add(row);
+ return result;
+ }
+
private List<Object[]> extractDataFromFields(SObject sObject,
List<Object> fields, List<Object[]> result) throws TranslatorException {
Map<String,Integer> fieldToIndexMap = sObjectToResponseField.get(sObject.getType());
@@ -260,6 +318,14 @@
return result;
}
+ private void setElementValueInColumn(int columnIndex, Object value, Object[] row) {
+ if(value instanceof Element) {
+ row[columnIndex] = ((Element)value).getFirstChild().getNodeValue();
+ } else {
+ row[columnIndex] = value;
+ }
+ }
+
private void setValueInColumn(int columnIndex, Object value, List<Object[]> result) {
if(result.isEmpty()) {
Object[] row = new Object[visitor.getSelectSymbolCount()];
@@ -271,7 +337,7 @@
row[columnIndex] = value;
}
}
-
+
/**
* Load the map of response field names to index.
* @param fields
@@ -353,8 +419,12 @@
}
return result;
}
+
+ private boolean isSObject(Element element) {
+ String type = element.getAttribute(XSI_TYPE);
+ return type != null && type.equals(SF_S_OBJECT);
+ }
-
private String getLogPreamble() {
if (null == logPreamble) {
StringBuffer preamble = new StringBuffer();
Modified: branches/7.1.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/SelectVisitor.java
===================================================================
--- branches/7.1.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/SelectVisitor.java 2010-11-24 18:15:45 UTC (rev 2744)
+++ branches/7.1.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/SelectVisitor.java 2010-11-24 18:41:55 UTC (rev 2745)
@@ -74,7 +74,8 @@
if (expression instanceof ColumnReference) {
Column element = ((ColumnReference) expression).getMetadataObject();
selectSymbolIndexToElement.put(index, element);
- selectSymbolNameToIndex .put(element.getNameInSource(), index);
+ String qualifiedName = element.getParent().getNameInSource() + ':' + element.getNameInSource();
+ selectSymbolNameToIndex .put(qualifiedName, index);
String nameInSource = element.getNameInSource();
if (null == nameInSource || nameInSource.length() == 0) {
exceptions.add(new TranslatorException("name in source is null or empty for column "+ symbol.toString()));
@@ -182,6 +183,10 @@
return result;
}
+ public Integer getSelectSymbolIndex(String name) {
+ return selectSymbolNameToIndex.get(name);
+ }
+
/**
* Returns the index of the ID column.
* @return the index of the ID column, -1 if there is no ID column.
14 years
teiid SVN: r2744 - in branches/7.1.x: client/src/main/java/org/teiid/adminapi and 3 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-11-24 13:15:45 -0500 (Wed, 24 Nov 2010)
New Revision: 2744
Modified:
branches/7.1.x/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
branches/7.1.x/client/src/main/java/org/teiid/adminapi/Admin.java
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
branches/7.1.x/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
Log:
TEIID-1379: Adding a new "clearCache" admin api call that can be used clear cache specific to a VDB.
Modified: branches/7.1.x/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
===================================================================
--- branches/7.1.x/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-11-24 18:11:42 UTC (rev 2743)
+++ branches/7.1.x/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-11-24 18:15:45 UTC (rev 2744)
@@ -141,6 +141,14 @@
@Doc(text = "cache type") String cacheType) throws AdminException {
getAdmin().clearCache(cacheType);
}
+
+ @Doc(text = "Clear the given cache for a VDB")
+ public static void clearCache(
+ @Doc(text = "cache type") String cacheType, @Doc(text = "vdb name") String vdbName,
+ @Doc(text = "vdb version") int vdbVersion
+ ) throws AdminException {
+ getAdmin().clearCache(cacheType, vdbName, vdbVersion);
+ }
@Doc(text = "Delete a VDB")
public static void deleteVDB(
Modified: branches/7.1.x/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/adminapi/Admin.java 2010-11-24 18:11:42 UTC (rev 2743)
+++ branches/7.1.x/client/src/main/java/org/teiid/adminapi/Admin.java 2010-11-24 18:15:45 UTC (rev 2744)
@@ -168,6 +168,16 @@
* @throws AdminException
*/
void clearCache(String cacheType) throws AdminException;
+
+ /**
+ * Clear the cache of the given VDB for provided cache type
+ * @param cacheType Cache Type
+ * No wild cards currently supported, must be explicit
+ * @param vdbName - Name of the VDB
+ * @param vdbVersion - VDB version
+ * @throws AdminException
+ */
+ void clearCache(String cacheType, String vdbName, int vdbVersion) throws AdminException;
/**
Modified: branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2010-11-24 18:11:42 UTC (rev 2743)
+++ branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2010-11-24 18:15:45 UTC (rev 2744)
@@ -35,6 +35,7 @@
boolean cancelRequest(String sessionId, long requestId) throws AdminException;
Collection<String> getCacheTypes();
void clearCache(String cacheType);
+ void clearCache(String cacheType, String vdbName, int version);
Collection<SessionMetadata> getActiveSessions() throws AdminException;
int getActiveSessionsCount() throws AdminException;
Collection<org.teiid.adminapi.Transaction> getTransactions();
Modified: branches/7.1.x/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- branches/7.1.x/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-11-24 18:11:42 UTC (rev 2743)
+++ branches/7.1.x/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-11-24 18:15:45 UTC (rev 2744)
@@ -329,6 +329,17 @@
}
@Override
+ public void clearCache(String cacheType, String vdbName, int version) throws AdminException{
+ try {
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
+ ManagedUtil.executeOperation(mc, "clearCache", SimpleValueSupport.wrap(cacheType), //$NON-NLS-1$
+ SimpleValueSupport.wrap(vdbName), SimpleValueSupport.wrap(version));
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
public Collection<Transaction> getTransactions() throws AdminException {
try {
Collection<Transaction> txnList = new ArrayList<Transaction>();
Modified: branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-11-24 18:11:42 UTC (rev 2743)
+++ branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-11-24 18:15:45 UTC (rev 2744)
@@ -426,6 +426,12 @@
}
@Override
+ @ManagementOperation(description="Clear the caches in the system for a VDB", params={@ManagementParameter(name="cacheType",description="Type of Cache"), @ManagementParameter(name="vdbName",description="VDB Name"),@ManagementParameter(name="version",description="VDB Version")}, impact=Impact.ReadOnly)
+ public void clearCache(String cacheType, String vdbName, int version) {
+ this.dqpCore.clearCache(cacheType, vdbName, version);
+ }
+
+ @Override
@ManagementOperation(description="Get the cache statistics", impact=Impact.ReadOnly)
public CacheStatisticsMetadata getCacheStatistics(String cacheType) {
return this.dqpCore.getCacheStatistics(cacheType);
14 years
teiid SVN: r2743 - in trunk: engine/src/main/java/org/teiid/query/optimizer/relational/rules and 4 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-11-24 13:11:42 -0500 (Wed, 24 Nov 2010)
New Revision: 2743
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/updatable_views.xml
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidator.java
trunk/engine/src/test/java/org/teiid/query/validator/TestUpdateValidator.java
Log:
TEIID-1349 adding support to detect key preserved in non-ansi joins
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/updatable_views.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/updatable_views.xml 2010-11-24 17:42:05 UTC (rev 2742)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/updatable_views.xml 2010-11-24 18:11:42 UTC (rev 2743)
@@ -50,7 +50,7 @@
<para>A key-preserved table has a primary or unique key that would remain unique if it were projected into the result of the query.
Note that it is not actually required for a view to reference the key columns in the SELECT clause.
- The query engine can detect a key preserved table by analyzing the join structure - which is currently required to be in ANSI join form.
+ The query engine can detect a key preserved table by analyzing the join structure.
The engine will ensure that a join of a key-preserved table must be against one of its foreign keys.</para>
</section>
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java 2010-11-24 17:42:05 UTC (rev 2742)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java 2010-11-24 18:11:42 UTC (rev 2743)
@@ -540,7 +540,7 @@
return true;
}
HashSet<GroupSymbol> keyPreservingGroups = new HashSet<GroupSymbol>();
- ResolverUtil.findKeyPreserinvg((FromClause)query.getFrom().getClauses().get(0), keyPreservingGroups, metadata);
+ ResolverUtil.findKeyPreserved(query, keyPreservingGroups, metadata);
return NewCalculateCostUtil.usesKey(expressions, keyPreservingGroups, metadata);
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java 2010-11-24 17:42:05 UTC (rev 2742)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java 2010-11-24 18:11:42 UTC (rev 2743)
@@ -56,6 +56,7 @@
import org.teiid.query.optimizer.relational.rules.RuleChooseJoinStrategy;
import org.teiid.query.optimizer.relational.rules.RuleRaiseAccess;
import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.FromClause;
import org.teiid.query.sql.lang.JoinPredicate;
@@ -941,8 +942,67 @@
symbol.setOutputName(name);
}
- public static void findKeyPreserinvg(FromClause clause, Set<GroupSymbol> keyPreservingGroups, QueryMetadataInterface metadata)
+ public static void findKeyPreserved(Query query, Set<GroupSymbol> keyPreservingGroups, QueryMetadataInterface metadata)
throws TeiidComponentException, QueryMetadataException {
+ if (query.getFrom() == null) {
+ return;
+ }
+ if (query.getFrom().getClauses().size() == 1) {
+ findKeyPreserved((FromClause)query.getFrom().getClauses().get(0), keyPreservingGroups, metadata);
+ return;
+ }
+ //non-ansi join
+ Set<GroupSymbol> groups = new HashSet<GroupSymbol>(query.getFrom().getGroups());
+ for (GroupSymbol groupSymbol : groups) {
+ if (metadata.getUniqueKeysInGroup(groupSymbol.getMetadataID()).isEmpty()) {
+ return;
+ }
+ }
+ LinkedList<Expression> leftExpressions = new LinkedList<Expression>();
+ LinkedList<Expression> rightExpressions = new LinkedList<Expression>();
+ for (Criteria crit : Criteria.separateCriteriaByAnd(query.getCriteria())) {
+ if (!(crit instanceof CompareCriteria)) {
+ continue;
+ }
+ CompareCriteria cc = (CompareCriteria)crit;
+ if (cc.getOperator() != CompareCriteria.EQ) {
+ continue;
+ }
+ if (cc.getLeftExpression() instanceof ElementSymbol && cc.getRightExpression() instanceof ElementSymbol) {
+ ElementSymbol left = (ElementSymbol)cc.getLeftExpression();
+ ElementSymbol right = (ElementSymbol)cc.getRightExpression();
+ int compare = left.getGroupSymbol().compareTo(right.getGroupSymbol());
+ if (compare > 0) {
+ leftExpressions.add(left);
+ rightExpressions.add(right);
+ } else if (compare != 0) {
+ leftExpressions.add(right);
+ rightExpressions.add(left);
+ }
+ }
+ }
+ HashMap<List<GroupSymbol>, List<HashSet<Object>>> crits = createGroupMap(leftExpressions, rightExpressions);
+ HashSet<GroupSymbol> tempSet = new HashSet<GroupSymbol>();
+ for (GroupSymbol group : groups) {
+ LinkedHashSet<GroupSymbol> visited = new LinkedHashSet<GroupSymbol>();
+ LinkedList<GroupSymbol> toVisit = new LinkedList<GroupSymbol>();
+ toVisit.add(group);
+ while (!toVisit.isEmpty()) {
+ GroupSymbol visiting = toVisit.removeLast();
+ if (!visited.add(visiting)) {
+ continue;
+ }
+ toVisit.addAll(findKeyPreserved(tempSet, Collections.singleton(visiting), crits, true, metadata, groups));
+ toVisit.addAll(findKeyPreserved(tempSet, Collections.singleton(visiting), crits, false, metadata, groups));
+ }
+ if (visited.containsAll(groups)) {
+ keyPreservingGroups.add(group);
+ }
+ }
+ }
+
+ public static void findKeyPreserved(FromClause clause, Set<GroupSymbol> keyPreservingGroups, QueryMetadataInterface metadata)
+ throws TeiidComponentException, QueryMetadataException {
if (clause instanceof UnaryFromClause) {
UnaryFromClause ufc = (UnaryFromClause)clause;
@@ -956,9 +1016,9 @@
return;
}
HashSet<GroupSymbol> leftPk = new HashSet<GroupSymbol>();
- findKeyPreserinvg(jp.getLeftClause(), leftPk, metadata);
+ findKeyPreserved(jp.getLeftClause(), leftPk, metadata);
HashSet<GroupSymbol> rightPk = new HashSet<GroupSymbol>();
- findKeyPreserinvg(jp.getRightClause(), rightPk, metadata);
+ findKeyPreserved(jp.getRightClause(), rightPk, metadata);
if (leftPk.isEmpty() && rightPk.isEmpty()) {
return;
@@ -973,48 +1033,58 @@
LinkedList<Expression> rightExpressions = new LinkedList<Expression>();
RuleChooseJoinStrategy.separateCriteria(leftGroups, rightGroups, leftExpressions, rightExpressions, jp.getJoinCriteria(), new LinkedList<Criteria>());
- HashMap<List<GroupSymbol>, List<HashSet<Object>>> crits = new HashMap<List<GroupSymbol>, List<HashSet<Object>>>();
-
- for (int i = 0; i < leftExpressions.size(); i++) {
- Expression lexpr = leftExpressions.get(i);
- Expression rexpr = rightExpressions.get(i);
- if (!(lexpr instanceof ElementSymbol) || !(rexpr instanceof ElementSymbol)) {
- continue;
- }
- ElementSymbol les = (ElementSymbol)lexpr;
- ElementSymbol res = (ElementSymbol)rexpr;
- List<GroupSymbol> tbls = Arrays.asList(les.getGroupSymbol(), res.getGroupSymbol());
- List<HashSet<Object>> ids = crits.get(tbls);
- if (ids == null) {
- ids = Arrays.asList(new HashSet<Object>(), new HashSet<Object>());
- crits.put(tbls, ids);
- }
- ids.get(0).add(les.getMetadataID());
- ids.get(1).add(res.getMetadataID());
- }
+ HashMap<List<GroupSymbol>, List<HashSet<Object>>> crits = createGroupMap(leftExpressions, rightExpressions);
if (!leftPk.isEmpty() && (jp.getJoinType() == JoinType.JOIN_INNER || jp.getJoinType() == JoinType.JOIN_LEFT_OUTER)) {
- findKeyPreserving(keyPreservingGroups, leftPk, crits, true, metadata);
+ findKeyPreserved(keyPreservingGroups, leftPk, crits, true, metadata, rightPk);
}
if (!rightPk.isEmpty() && (jp.getJoinType() == JoinType.JOIN_INNER || jp.getJoinType() == JoinType.JOIN_RIGHT_OUTER)) {
- findKeyPreserving(keyPreservingGroups, rightPk, crits, false, metadata);
+ findKeyPreserved(keyPreservingGroups, rightPk, crits, false, metadata, leftPk);
}
}
}
- static private void findKeyPreserving(Set<GroupSymbol> keyPreservingGroups,
- HashSet<GroupSymbol> pk,
- HashMap<List<GroupSymbol>, List<HashSet<Object>>> crits, boolean left, QueryMetadataInterface metadata)
+ private static HashMap<List<GroupSymbol>, List<HashSet<Object>>> createGroupMap(
+ LinkedList<Expression> leftExpressions,
+ LinkedList<Expression> rightExpressions) {
+ HashMap<List<GroupSymbol>, List<HashSet<Object>>> crits = new HashMap<List<GroupSymbol>, List<HashSet<Object>>>();
+
+ for (int i = 0; i < leftExpressions.size(); i++) {
+ Expression lexpr = leftExpressions.get(i);
+ Expression rexpr = rightExpressions.get(i);
+ if (!(lexpr instanceof ElementSymbol) || !(rexpr instanceof ElementSymbol)) {
+ continue;
+ }
+ ElementSymbol les = (ElementSymbol)lexpr;
+ ElementSymbol res = (ElementSymbol)rexpr;
+ List<GroupSymbol> tbls = Arrays.asList(les.getGroupSymbol(), res.getGroupSymbol());
+ List<HashSet<Object>> ids = crits.get(tbls);
+ if (ids == null) {
+ ids = Arrays.asList(new HashSet<Object>(), new HashSet<Object>());
+ crits.put(tbls, ids);
+ }
+ ids.get(0).add(les.getMetadataID());
+ ids.get(1).add(res.getMetadataID());
+ }
+ return crits;
+ }
+
+ static private HashSet<GroupSymbol> findKeyPreserved(Set<GroupSymbol> keyPreservingGroups,
+ Set<GroupSymbol> pk,
+ HashMap<List<GroupSymbol>, List<HashSet<Object>>> crits, boolean left, QueryMetadataInterface metadata, Set<GroupSymbol> otherGroups)
throws TeiidComponentException, QueryMetadataException {
+ HashSet<GroupSymbol> result = new HashSet<GroupSymbol>();
for (GroupSymbol gs : pk) {
for (Map.Entry<List<GroupSymbol>, List<HashSet<Object>>> entry : crits.entrySet()) {
- if (!entry.getKey().get(left?0:1).equals(gs)) {
+ if (!entry.getKey().get(left?0:1).equals(gs) || !otherGroups.contains(entry.getKey().get(left?1:0))) {
continue;
}
if (RuleRaiseAccess.matchesForeignKey(metadata, entry.getValue().get(left?0:1), entry.getValue().get(left?1:0), gs, false)) {
keyPreservingGroups.add(gs);
+ result.add(entry.getKey().get(left?1:0));
}
}
}
+ return result;
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-11-24 17:42:05 UTC (rev 2742)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-11-24 18:11:42 UTC (rev 2743)
@@ -688,7 +688,7 @@
if (query.getFrom().getClauses().size() > 1) {
continue;
}
- ResolverUtil.findKeyPreserinvg((FromClause)query.getFrom().getClauses().get(0), keyPreservingGroups, metadata);
+ ResolverUtil.findKeyPreserved(query, keyPreservingGroups, metadata);
if (!NewCalculateCostUtil.usesKey(plannedResult.leftExpressions, keyPreservingGroups, metadata)) {
continue;
}
Modified: trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidator.java 2010-11-24 17:42:05 UTC (rev 2742)
+++ trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidator.java 2010-11-24 18:11:42 UTC (rev 2743)
@@ -35,7 +35,6 @@
import org.teiid.query.metadata.SupportConstants;
import org.teiid.query.resolver.util.ResolverUtil;
import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.lang.FromClause;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.UnaryFromClause;
import org.teiid.query.sql.symbol.ElementSymbol;
@@ -233,9 +232,7 @@
List<GroupSymbol> allGroups = query.getFrom().getGroups();
HashSet<GroupSymbol> keyPreservingGroups = new HashSet<GroupSymbol>();
- if (query.getFrom().getClauses().size() == 1) {
- ResolverUtil.findKeyPreserinvg((FromClause)query.getFrom().getClauses().get(0), keyPreservingGroups, metadata);
- }
+ ResolverUtil.findKeyPreserved(query, keyPreservingGroups, metadata);
for (GroupSymbol groupSymbol : keyPreservingGroups) {
setUpdateFlags(groupSymbol);
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestUpdateValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/validator/TestUpdateValidator.java 2010-11-24 17:42:05 UTC (rev 2742)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestUpdateValidator.java 2010-11-24 18:11:42 UTC (rev 2743)
@@ -230,6 +230,11 @@
helpTest("SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2",
example1(), true);
}
+
+ @Test public void testCreateInsertCommand14(){
+ helpTest("SELECT pm1.g2.e1 FROM pm1.g1, pm1.g2 where g1.e1 = g2.e1",
+ example1(), false);
+ }
@Test public void testCreateInsertCommand2_fail(){
helpTest("SELECT CONCAT(pm1.g1.e1, convert(pm1.g2.e1, string)) as x FROM pm1.g1, pm1.g2",
14 years
teiid SVN: r2742 - branches/7.1.x/documentation/reference/src/main/docbook/en-US/content.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-11-24 12:42:05 -0500 (Wed, 24 Nov 2010)
New Revision: 2742
Modified:
branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/translators.xml
Log:
TEIID-1369 adding information about modeshape usage
Modified: branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/translators.xml
===================================================================
--- branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-11-24 16:50:41 UTC (rev 2741)
+++ branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-11-24 17:42:05 UTC (rev 2742)
@@ -247,6 +247,16 @@
</listitem>
<listitem>
<para>
+ <emphasis>modeshape</emphasis> - for use with Modeshape 2.2.1 or later. The PATH, NAME, LOCALNODENAME, DEPTH, and SCORE functions should be accessed as pseudo-columns, e.g. "nt:base"."jcr:path".
+ Teiid UFDs (prefixed by JCR_) are available for CONTIANS, ISCHILDNODE, ISDESCENDENT, ISSAMENODE, REFERENCE - see the JCRFunctions.xmi.
+ If a selector name is needed in a JCR function, you should use the pseudo-column "jcr:path", e.g. JCR_ISCHILDNODE(foo.jcr_path, 'x/y') would become ISCHILDNODE(foo, 'x/y') in the ModeShape query.
+ An additional pseudo-column "mode:properties" should be imported by setting the ModeShape JDBC connection property teiidsupport=true.
+ The column "mode:properties" should be used by the JCR_REFERENCE and other
+ functions that expect a .* selector name, e.g. JCR_REFERENCE(nt_base.jcr_properties) would become REFERENCE("nt:base".*) in the ModeShape query.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
<emphasis>mysql</emphasis>/<emphasis>mysql5</emphasis> - for use with
MySQL version 4.x and 5 or later respectively.
</para>
14 years
teiid SVN: r2741 - in branches/7.1.x/connectors/translator-jdbc/src: test/java/org/teiid/translator/jdbc/modeshape and 1 other directory.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-11-24 11:50:41 -0500 (Wed, 24 Nov 2010)
New Revision: 2741
Modified:
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/IdentifierFunctionModifier.java
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/modeshape/TestModeShapeSqlTranslator.java
Log:
TEIID-1369 changed the translator to look for jcr:path, instead of mode:path
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/IdentifierFunctionModifier.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/IdentifierFunctionModifier.java 2010-11-24 16:06:08 UTC (rev 2740)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/IdentifierFunctionModifier.java 2010-11-24 16:50:41 UTC (rev 2741)
@@ -62,7 +62,7 @@
if ("\"mode:properties\"".equalsIgnoreCase(c.getNameInSource())) { //$NON-NLS-1$
dotAll = true;
useSelector = true;
- } else if ("\"mode:path\"".equalsIgnoreCase(c.getNameInSource())) { //$NON-NLS-1$
+ } else if ("\"jcr:path\"".equalsIgnoreCase(c.getNameInSource())) { //$NON-NLS-1$
useSelector = true;
}
}
Modified: branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/modeshape/TestModeShapeSqlTranslator.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/modeshape/TestModeShapeSqlTranslator.java 2010-11-24 16:06:08 UTC (rev 2740)
+++ branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/modeshape/TestModeShapeSqlTranslator.java 2010-11-24 16:50:41 UTC (rev 2741)
@@ -61,13 +61,13 @@
Schema modeshape = RealMetadataFactory.createPhysicalModel("modeshape", store);
Table nt_base = RealMetadataFactory.createPhysicalGroup("nt_base", modeshape);
nt_base.setNameInSource("\"nt:base\"");
- List<Column> cols = RealMetadataFactory.createElements(nt_base, new String[] { "mode_path",
+ List<Column> cols = RealMetadataFactory.createElements(nt_base, new String[] { "jcr_path",
"mode_properties", "jcr_primaryType", "prop" }, new String[] {
TypeFacility.RUNTIME_NAMES.STRING,
TypeFacility.RUNTIME_NAMES.STRING,
TypeFacility.RUNTIME_NAMES.STRING,
TypeFacility.RUNTIME_NAMES.STRING });
- cols.get(0).setNameInSource("\"mode:path\"");
+ cols.get(0).setNameInSource("\"jcr:path\"");
cols.get(1).setNameInSource("\"mode:properties\"");
cols.get(2).setNameInSource("\"jcr:primaryType\"");
return RealMetadataFactory.createTransformationMetadata(store, "modeshape");
@@ -81,7 +81,7 @@
@Test
public void testSelectAllFromBase() throws Exception {
String input = "select * from nt_base"; //$NON-NLS-1$
- String output = "SELECT g_0.\"mode:path\", g_0.\"mode:properties\", g_0.\"jcr:primaryType\", g_0.prop FROM \"nt:base\" AS g_0"; //$NON-NLS-1$
+ String output = "SELECT g_0.\"jcr:path\", g_0.\"mode:properties\", g_0.\"jcr:primaryType\", g_0.prop FROM \"nt:base\" AS g_0"; //$NON-NLS-1$
helpTestVisitor(input, output);
@@ -90,7 +90,7 @@
@Test
public void testPredicate() throws Exception {
- String input = "SELECT x.jcr_primaryType from nt_base inner join nt_base as x on jcr_issamenode(nt_base.mode_path, x.mode_path) = true where jcr_isdescendantnode(nt_base.mode_path, 'x/y/z') = true and jcr_reference(nt_base.mode_properties) = 'x'"; //$NON-NLS-1$
+ String input = "SELECT x.jcr_primaryType from nt_base inner join nt_base as x on jcr_issamenode(nt_base.jcr_path, x.jcr_path) = true where jcr_isdescendantnode(nt_base.jcr_path, 'x/y/z') = true and jcr_reference(nt_base.mode_properties) = 'x'"; //$NON-NLS-1$
String output = "SELECT g_1.\"jcr:primaryType\" FROM \"nt:base\" AS g_0 INNER JOIN \"nt:base\" AS g_1 ON issamenode(g_0, g_1) WHERE isdescendantnode(g_0, 'x/y/z') AND reference(g_0.*) = 'x'"; //$NON-NLS-1$
helpTestVisitor(input, output);
14 years
teiid SVN: r2740 - branches/7.1.x/console.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-11-24 11:06:08 -0500 (Wed, 24 Nov 2010)
New Revision: 2740
Modified:
branches/7.1.x/console/pom.xml
Log:
TEIID-1378: Removed build step that copied the Teiid client jar into the plugin's lib folder.
Modified: branches/7.1.x/console/pom.xml
===================================================================
--- branches/7.1.x/console/pom.xml 2010-11-23 21:23:39 UTC (rev 2739)
+++ branches/7.1.x/console/pom.xml 2010-11-24 16:06:08 UTC (rev 2740)
@@ -160,34 +160,6 @@
<build>
<outputDirectory>target/classes</outputDirectory>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy</id>
- <phase>clean</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-client</artifactId>
- <version>${project.version}</version>
- <type>jar</type>
- <overWrite>true</overWrite>
- </artifactItem>
- </artifactItems>
- <outputDirectory>src/main/resources/lib</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
-
<resources>
<resource>
<directory>src/main/resources</directory>
@@ -195,7 +167,6 @@
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
- <include>**/teiid*client*.jar</include>
</includes>
</resource>
</resources>
14 years