teiid SVN: r1534 - trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-10-24 14:00:19 -0400 (Sat, 24 Oct 2009)
New Revision: 1534
Added:
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java
Removed:
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AnnotationRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ConnectorMetadata.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataConstants.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/PropertyRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TransformationRecordImpl.java
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/BaseColumn.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSetRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/DatatypeRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKeyRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ModelRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameterRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TableRecordImpl.java
Log:
TEIID-871 TEIID-792 TEIID-102 TEIID-254 TEIID-869 TEIID-875 further clean up of metadata related logic. The index connector has been removed and the system virtual views promoted to physical tables. some of the tables/procedures have been removed. and minor changes have been made to MMDatabaseMetadata queries.
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -23,74 +23,52 @@
package org.teiid.connector.metadata.runtime;
import java.io.Serializable;
-import java.util.Collection;
-import java.util.Properties;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.core.util.HashCodeUtil;
/**
* AbstractMetadataRecord
*/
public abstract class AbstractMetadataRecord implements Serializable {
- /**
- * Constants for names of accessor methods that map to fields stored on the MetadataRecords.
- * Note the names do not have "get" on them, this is also the nameInSource
- * of the attributes on SystemPhysicalModel.
- * @since 4.3
- */
- public static interface MetadataFieldNames {
- String RECORD_TYPE_FIELD = "Recordtype"; //$NON-NLS-1$
- String NAME_FIELD = "Name"; //$NON-NLS-1$
- String FULL_NAME_FIELD = "FullName"; //$NON-NLS-1$
- String MODEL_NAME_FIELD = "ModelName"; //$NON-NLS-1$
- String UUID_FIELD = "UUID"; //$NON-NLS-1$
- String NAME_IN_SOURCE_FIELD = "NameInSource"; //$NON-NLS-1$
- String PARENT_UUID_FIELD = "ParentUUID"; //$NON-NLS-1$
- }
-
public final static char NAME_DELIM_CHAR = '.';
- private String pathString;
- private String modelName;
- private char recordType;
+ private String uuid; //globally unique id
+ private String name; //contextually unique name
+ private String fullName;
- private String uuid;
- private String parentUUID;
private String nameInSource;
- private String fullName;
- private String name;
- private Collection<PropertyRecordImpl> extensionProperties;
- private transient Properties properties;
- private AnnotationRecordImpl annotation;
+ private LinkedHashMap<String, String> properties;
+ private String annotation;
public String getUUID() {
return uuid;
}
+
public void setUUID(String uuid) {
this.uuid = uuid;
}
- public String getParentUUID() {
- return parentUUID;
- }
- public void setParentUUID(String parentUUID) {
- this.parentUUID = parentUUID;
- }
+
public String getNameInSource() {
return nameInSource;
}
+
public void setNameInSource(String nameInSource) {
this.nameInSource = nameInSource;
}
+
public String getFullName() {
return this.fullName == null ? this.name : this.fullName;
}
+
public void setFullName(String fullName) {
this.fullName = fullName;
}
+
public String getName() {
if(this.name == null || this.name.trim().length() == 0) {
int nmIdx = this.fullName != null ? this.fullName.lastIndexOf(NAME_DELIM_CHAR) : -1;
@@ -102,45 +80,21 @@
}
return name;
}
+
public void setName(String name) {
this.name = name;
}
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.MetadataRecord#getModelName()
- */
+
public String getModelName() {
- if(this.modelName == null) {
- int prntIdx = getFullName() != null ? getFullName().indexOf(NAME_DELIM_CHAR) : -1;
- if (prntIdx <= 0) {
- this.modelName = getFullName();
- } else {
- this.modelName = getFullName() != null ? getFullName().substring(0, prntIdx) : null;
- }
- }
-
- return this.modelName;
+ int prntIdx = fullName.indexOf(NAME_DELIM_CHAR);
+ return fullName.substring(0, prntIdx);
}
- /*
- * @see com.metamatrix.modeler.core.metadata.runtime.MetadataRecord#getPathString()
- */
- public String getPathString() {
- if(this.pathString == null) {
- this.pathString = getFullName() != null ? getFullName().replace(NAME_DELIM_CHAR, FileUtils.SEPARATOR) : null;
- }
- return this.pathString;
+ public String toString() {
+ return uuid + ": " + name; //$NON-NLS-1$
}
-
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.MetadataRecord#getPath()
- */
- public String getPath() {
- return getPathString();
- }
/**
- * @see com.metamatrix.modeler.core.metadata.runtime.MetadataRecord#getParentFullName()
* @deprecated the returned value may be incorrect in the case of an XML element (see defects #11326 and #11362)
*/
public String getParentFullName() {
@@ -150,55 +104,36 @@
}
return getFullName().substring(0, prntIdx);
}
-
+
/**
- * @see com.metamatrix.modeler.core.metadata.runtime.MetadataRecord#getParentPathString()
- * @deprecated the returned value may be incorrect in the case of an XML element (see defects #11326 and #11362)
+ * Return the extension properties for this record - may be null
+ * if {@link #setProperties(LinkedHashMap)} or {@link #setProperty(String, String)}
+ * has not been called
+ * @return
*/
- public String getParentPathString() {
- String parentFullName = getParentFullName();
- return parentFullName != null ? parentFullName.replace(NAME_DELIM_CHAR, FileUtils.SEPARATOR) : null;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.MetadataRecord#getRecordType()
- */
- public char getRecordType() {
- return this.recordType;
- }
-
- /**
- * @param c
- */
- public void setRecordType(char c) {
- recordType = c;
- }
-
- public String toString() {
- return getFullName();
- }
-
- public Collection<PropertyRecordImpl> getExtensionProperties() {
- return extensionProperties;
+ public Map<String, String> getProperties() {
+ if (properties == null) {
+ return Collections.emptyMap();
+ }
+ return properties;
}
- public void setExtensionProperties(Collection<PropertyRecordImpl> properties) {
- this.extensionProperties = properties;
- }
+ public void setProperty(String key, String value) {
+ if (this.properties == null) {
+ this.properties = new LinkedHashMap<String, String>();
+ }
+ this.properties.put(key, value);
+ }
- public Properties getProperties() {
- return properties;
- }
-
- public void setProperties(Properties properties) {
+ public void setProperties(LinkedHashMap<String, String> properties) {
this.properties = properties;
}
- public AnnotationRecordImpl getAnnotation() {
+ public String getAnnotation() {
return annotation;
}
- public void setAnnotation(AnnotationRecordImpl annotation) {
+ public void setAnnotation(String annotation) {
this.annotation = annotation;
}
@@ -211,35 +146,17 @@
return true;
}
- if(obj == null || obj.getClass() != this.getClass()) {
+ if(obj.getClass() != this.getClass()) {
return false;
}
AbstractMetadataRecord other = (AbstractMetadataRecord)obj;
- if(this.getRecordType() != other.getRecordType()) { return false; }
- if(!EquivalenceUtil.areEqual(this.getUUID(), other.getUUID())) { return false; }
- if(!EquivalenceUtil.areEqual(this.getParentUUID(), other.getParentUUID())) { return false; }
- if(!EquivalenceUtil.areEqual(this.getFullName(), other.getFullName())) { return false; }
- if(!EquivalenceUtil.areEqual(this.getNameInSource(), other.getNameInSource())) { return false; }
-
- return true;
+ return EquivalenceUtil.areEqual(this.getUUID(), other.getUUID());
}
- /**
- * WARNING: The hash code relies on the variables
- * in the record, so changing the variables will change the hash code, causing
- * a select to be lost in a hash structure. Do not hash a record if you plan
- * to change it.
- */
public int hashCode() {
- int myHash = 0;
- myHash = HashCodeUtil.hashCode(myHash, this.recordType);
- myHash = HashCodeUtil.hashCode(myHash, this.getFullName());
- myHash = HashCodeUtil.hashCode(myHash, this.getUUID());
- myHash = HashCodeUtil.hashCode(myHash, this.getParentUUID());
- myHash = HashCodeUtil.hashCode(myHash, this.getNameInSource());
- return myHash;
+ return this.uuid.hashCode();
}
}
\ No newline at end of file
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AnnotationRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AnnotationRecordImpl.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AnnotationRecordImpl.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-
-
-/**
- * AnnotationRecordImpl
- */
-public class AnnotationRecordImpl extends AbstractMetadataRecord {
-
- private String description;
-
- //==================================================================================
- // I N T E R F A C E M E T H O D S
- //==================================================================================
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.AnnotationRecord#getDescription()
- */
- public String getDescription() {
- return this.description;
- }
-
- // ==================================================================================
- // P U B L I C M E T H O D S
- // ==================================================================================
-
- public String toString() {
- StringBuffer sb = new StringBuffer(100);
- sb.append(getClass().getSimpleName());
- sb.append(" name="); //$NON-NLS-1$
- sb.append(getName());
- sb.append(", nameInSource="); //$NON-NLS-1$
- sb.append(getNameInSource());
- sb.append(", uuid="); //$NON-NLS-1$
- sb.append(getUUID());
- sb.append(", pathInModel="); //$NON-NLS-1$
- sb.append(getPath());
- return sb.toString();
- }
-
- /**
- * @param string
- */
- public void setDescription(final String string) {
- this.description = string;
- }
-
-}
\ No newline at end of file
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/BaseColumn.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/BaseColumn.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/BaseColumn.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -22,20 +22,31 @@
package org.teiid.connector.metadata.runtime;
-public class BaseColumn extends AbstractMetadataRecord {
+public abstract class BaseColumn extends AbstractMetadataRecord {
+ public enum NullType {
+ No_Nulls {
+ @Override
+ public String toString() {
+ return "No Nulls"; //$NON-NLS-1$
+ }
+ },
+ Nullable,
+ Unknown
+ }
+
private String datatypeUUID;
private String runtimeType;
- private Object defaultValue;
+ private String defaultValue;
private int length;
private int scale;
private int radix;
private int precision;
- private int nullType;
+ private NullType nullType;
private int position;
private DatatypeRecordImpl datatype;
- public Object getDefaultValue() {
+ public String getDefaultValue() {
return defaultValue;
}
@@ -67,7 +78,10 @@
return position;
}
- public int getNullType() {
+ public NullType getNullType() {
+ if (nullType == null) {
+ return NullType.Unknown;
+ }
return nullType;
}
@@ -87,7 +101,7 @@
radix = i;
}
- public void setNullType(int i) {
+ public void setNullType(NullType i) {
nullType = i;
}
@@ -103,7 +117,7 @@
datatypeUUID = string;
}
- public void setDefaultValue(Object object) {
+ public void setDefaultValue(String object) {
defaultValue = object;
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnRecordImpl.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnRecordImpl.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -22,11 +22,29 @@
package org.teiid.connector.metadata.runtime;
+
/**
* ColumnRecordImpl
*/
public class ColumnRecordImpl extends BaseColumn implements Comparable<ColumnRecordImpl> {
+ public enum SearchType {
+ Unsearchable,
+ Like_Only {
+ @Override
+ public String toString() {
+ return "Like Only"; //$NON-NLS-1$
+ }
+ },
+ All_Except_Like {
+ @Override
+ public String toString() {
+ return "All Except Like"; //$NON-NLS-1$
+ }
+ },
+ Searchable
+ }
+
private boolean selectable = true;
private boolean updatable;
private boolean autoIncrementable;
@@ -34,145 +52,83 @@
private boolean signed;
private boolean currency;
private boolean fixedLength;
- private boolean tranformationInputParameter;
- private int searchType;
- private Object minValue;
- private Object maxValue;
+ private SearchType searchType;
+ private String minValue;
+ private String maxValue;
private String nativeType;
private String format;
private int charOctetLength;
private int distinctValues = -1;
private int nullValues = -1;
- //==================================================================================
- // I N T E R F A C E M E T H O D S
- //==================================================================================
-
@Override
public int compareTo(ColumnRecordImpl record) {
return this.getPosition() - record.getPosition();
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#getCharOctetLength()
- */
public int getCharOctetLength() {
return charOctetLength;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#getMaxValue()
- */
- public Object getMaxValue() {
+ public String getMaxValue() {
return maxValue;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#getMinValue()
- */
- public Object getMinValue() {
+ public String getMinValue() {
return minValue;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#getSearchTye()
- */
- public int getSearchType() {
+ public SearchType getSearchType() {
+ if (searchType == null) {
+ return this.getDatatype().getSearchType();
+ }
return searchType;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#getFormat()
- */
public String getFormat() {
return format;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#isAutoIncrementable()
- */
public boolean isAutoIncrementable() {
return autoIncrementable;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#isCaseSensitive()
- */
public boolean isCaseSensitive() {
return caseSensitive;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#isCurrency()
- */
public boolean isCurrency() {
return currency;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#isFixedLength()
- */
public boolean isFixedLength() {
return fixedLength;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#isTranformationInputParameter()
- * @since 4.2
- */
- public boolean isTranformationInputParameter() {
- return tranformationInputParameter;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#isSelectable()
- */
public boolean isSelectable() {
return selectable;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#isSigned()
- */
public boolean isSigned() {
return signed;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#isUpdatable()
- */
public boolean isUpdatable() {
return updatable;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#getNativeType()
- * @since 4.2
- */
public String getNativeType() {
return nativeType;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#getDistinctValues()
- * @since 4.3
- */
public int getDistinctValues() {
return this.distinctValues;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnRecord#getNullValues()
- * @since 4.3
- */
public int getNullValues() {
return this.nullValues;
}
- // ==================================================================================
- // P U B L I C M E T H O D S
- // ==================================================================================
-
/**
* @param b
*/
@@ -211,21 +167,21 @@
/**
* @param object
*/
- public void setMaxValue(Object object) {
+ public void setMaxValue(String object) {
maxValue = object;
}
/**
* @param object
*/
- public void setMinValue(Object object) {
+ public void setMinValue(String object) {
minValue = object;
}
/**
* @param s
*/
- public void setSearchType(int s) {
+ public void setSearchType(SearchType s) {
searchType = s;
}
@@ -281,13 +237,6 @@
this.nativeType = nativeType;
}
- /**
- * @param b
- */
- public void setTransformationInputParameter(boolean b) {
- this.tranformationInputParameter = b;
- }
-
public String toString() {
StringBuffer sb = new StringBuffer(100);
sb.append(getClass().getSimpleName());
@@ -297,9 +246,7 @@
sb.append(getNameInSource());
sb.append(", uuid="); //$NON-NLS-1$
sb.append(getUUID());
- sb.append(", pathInModel="); //$NON-NLS-1$
- sb.append(getPath());
return sb.toString();
}
-
+
}
\ No newline at end of file
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSetRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSetRecordImpl.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSetRecordImpl.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -22,82 +22,21 @@
package org.teiid.connector.metadata.runtime;
-import java.util.ArrayList;
import java.util.List;
/**
* ColumnSetRecordImpl
*/
public class ColumnSetRecordImpl extends AbstractMetadataRecord {
-
- private List<String> columnIDs;
- private short type;
+
private List<ColumnRecordImpl> columns;
- public ColumnSetRecordImpl(short type) {
- this.type = type;
- }
-
public List<ColumnRecordImpl> getColumns() {
return columns;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnSetRecord#getColumnIDs()
- */
- public List<String> getColumnIDs() {
- return columnIDs;
- }
-
- /**
- * Retrieves a list of ColumnRecordImpls containing only id and position information (used by System Tables)
- */
- public List<ColumnRecordImpl> getColumnIdEntries() {
- int count = getColumnCount();
- final List<ColumnRecordImpl> entryRecords = new ArrayList<ColumnRecordImpl>(count);
- for (int i = 0; i < count; i++) {
- final String uuid = getUUID(i);
- ColumnRecordImpl impl = new ColumnRecordImpl();
- entryRecords.add( impl );
- impl.setUUID(uuid);
- impl.setPosition(i+1);
- }
- return entryRecords;
- }
-
- private int getColumnCount() {
- if (columnIDs != null) {
- return columnIDs.size();
- }
- if (columns != null) {
- return columns.size();
- }
- return 0;
- }
-
- private String getUUID(int index) {
- if (columnIDs != null) {
- return columnIDs.get(index);
- }
- return columns.get(index).getUUID();
- }
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.ColumnSetRecord#getType()
- */
- public short getType() {
- return type;
- }
-
- /**
- * @param list
- */
- public void setColumnIDs(List<String> list) {
- columnIDs = list;
- }
-
public void setColumns(List<ColumnRecordImpl> columns) {
this.columns = columns;
}
-
+
}
\ No newline at end of file
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ConnectorMetadata.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ConnectorMetadata.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ConnectorMetadata.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.io.Serializable;
-import java.util.Collection;
-
-public interface ConnectorMetadata extends Serializable {
-
- /**
- * Get the model that this metadata represents. The model name is treated as
- * a top level schema for all source metadata.
- * @return
- */
- ModelRecordImpl getModel();
-
- /**
- * Get the tables defined for this model
- * @return
- */
- Collection<TableRecordImpl> getTables();
-
- /**
- * Get the procedures defined for this model
- * @return
- */
- Collection<ProcedureRecordImpl> getProcedures();
-
- /**
- * Get the annotations defined for this model
- * @return
- */
- Collection<AnnotationRecordImpl> getAnnotations();
-
- /**
- * Get the extension properties defined for this model
- * @return
- */
- Collection<PropertyRecordImpl> getProperties();
-
- //costing
-
-}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/DatatypeRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/DatatypeRecordImpl.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/DatatypeRecordImpl.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -22,26 +22,28 @@
package org.teiid.connector.metadata.runtime;
-import java.util.List;
+import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
+import org.teiid.connector.metadata.runtime.ColumnRecordImpl.SearchType;
+
/**
* ColumnRecordImpl
*/
public class DatatypeRecordImpl extends AbstractMetadataRecord {
-
- /**
- * Constants for names of accessor methods that map to fields stored on the DatatypeRecords.
- * Note the names do not have "get" on them, this is also the nameInsource
- * of the attributes on SystemPhysicalModel.
- * @since 4.3
- */
- public static interface MetadataFieldNames {
- String DATA_TYPE_UUID = "DatatypeID"; //$NON-NLS-1$
- String BASE_TYPE_UUID = "BasetypeID"; //$NON-NLS-1$
- String RUN_TYPE_NAME = "RuntimeTypeName"; //$NON-NLS-1$
+ public enum Type {
+ Basic,
+ UserDefined,
+ ResultSet
}
+
+ public enum Variety {
+ Atomic,
+ List,
+ Union,
+ Complex
+ }
/** Delimiter used to separate the URI string from the URI fragment */
public static final String URI_REFERENCE_DELIMITER = "#"; //$NON-NLS-1$
@@ -55,26 +57,18 @@
private boolean isSigned;
private boolean isAutoIncrement;
private boolean isCaseSensitive;
- private short type;
- private short searchType;
- private short nullType;
+ private Type type;
+ private SearchType searchType;
+ private NullType nullType;
private String javaClassName = DEFAULT_JAVA_CLASS_NAME;
private String runtimeTypeName;
private String datatypeID;
private String basetypeID;
private String primitiveTypeID;
- private short varietyType;
- private List varietyProps;
+ private Variety varietyType;
- //==================================================================================
- // I N T E R F A C E M E T H O D S
- //==================================================================================
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.MetadataRecord#getName()
- */
public String getName() {
- final String fullName = super.getFullName();
+ final String fullName = super.getName();
int indx = fullName.lastIndexOf(URI_REFERENCE_DELIMITER);
if (indx > -1) {
return fullName.substring(indx+1);
@@ -86,134 +80,70 @@
return fullName;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.MetadataRecord#getModelName()
- */
- public String getModelName() {
- final String fullName = super.getFullName();
- int indx = fullName.lastIndexOf(URI_REFERENCE_DELIMITER);
- if (indx > -1) {
- return fullName.substring(0, indx);
- }
- indx = fullName.lastIndexOf(AbstractMetadataRecord.NAME_DELIM_CHAR);
- if (indx > -1) {
- return fullName.substring(0, indx);
- }
- return fullName;
- }
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getLength()
- */
public int getLength() {
return this.length;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getPrecisionLength()
- */
public int getPrecisionLength() {
return this.precisionLength;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getScale()
- */
public int getScale() {
return this.scale;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getRadix()
- */
public int getRadix() {
return this.radix;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#isSigned()
- */
public boolean isSigned() {
return this.isSigned;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#isAutoIncrement()
- */
public boolean isAutoIncrement() {
return this.isAutoIncrement;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#isCaseSensitive()
- */
public boolean isCaseSensitive() {
return this.isCaseSensitive;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getType()
- */
- public short getType() {
+ public Type getType() {
return this.type;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#isBuiltin()
- */
public boolean isBuiltin() {
- if ( getType() == MetadataConstants.DATATYPE_TYPES.BASIC ) {
- return true;
- }
- return false;
+ return getType() == Type.Basic;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getSearchType()
- */
- public short getSearchType() {
+ public SearchType getSearchType() {
return this.searchType;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getNullType()
- */
- public short getNullType() {
+ public NullType getNullType() {
+ if (this.nullType == null) {
+ return NullType.Unknown;
+ }
return this.nullType;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getJavaClassName()
- */
public String getJavaClassName() {
return this.javaClassName;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getRuntimeTypeName()
- */
public String getRuntimeTypeName() {
return this.runtimeTypeName;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getDatatypeID()
- */
public String getDatatypeID() {
return this.datatypeID;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getBasetypeID()
- */
public String getBasetypeID() {
return this.basetypeID;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getBasetypeName()
- */
public String getBasetypeName() {
if ( this.basetypeID != null ) {
final int i = getBasetypeID().lastIndexOf(URI_REFERENCE_DELIMITER);
@@ -224,33 +154,15 @@
return null;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getPrimitiveTypeID()
- * @since 4.3
- */
public String getPrimitiveTypeID() {
return this.primitiveTypeID;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getVarietyType()
- */
- public short getVarietyType() {
+ public Variety getVarietyType() {
return this.varietyType;
}
/**
- * @see com.metamatrix.modeler.core.metadata.runtime.DatatypeRecord#getVarietyProps()
- */
- public List getVarietyProps() {
- return this.varietyProps;
- }
-
- // ==================================================================================
- // P U B L I C M E T H O D S
- // ==================================================================================
-
- /**
* @param string
*/
public void setBasetypeID(String string) {
@@ -302,7 +214,7 @@
/**
* @param s
*/
- public void setNullType(short s) {
+ public void setNullType(NullType s) {
nullType = s;
}
@@ -337,14 +249,14 @@
/**
* @param s
*/
- public void setSearchType(short s) {
+ public void setSearchType(SearchType s) {
searchType = s;
}
/**
* @param s
*/
- public void setType(short s) {
+ public void setType(Type s) {
type = s;
}
@@ -356,16 +268,9 @@
}
/**
- * @param list
- */
- public void setVarietyProps(List list) {
- varietyProps = list;
- }
-
- /**
* @param s
*/
- public void setVarietyType(short s) {
+ public void setVarietyType(Variety s) {
varietyType = s;
}
@@ -384,7 +289,6 @@
sb.append(getUUID());
sb.append(", datatypeID="); //$NON-NLS-1$
sb.append(getDatatypeID());
-
return sb.toString();
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKeyRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKeyRecordImpl.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKeyRecordImpl.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -25,30 +25,19 @@
/**
* ForeignKeyRecordImpl
*/
-public class ForeignKeyRecordImpl extends ColumnSetRecordImpl {
+public class ForeignKeyRecordImpl extends KeyRecord {
private String uniqueKeyID;
- private ColumnSetRecordImpl primaryKey;
+ private KeyRecord primaryKey;
public ForeignKeyRecordImpl() {
- super(MetadataConstants.KEY_TYPES.FOREIGN_KEY);
+ super(Type.Foreign);
}
- //==================================================================================
- // I N T E R F A C E M E T H O D S
- //==================================================================================
-
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ForeignKeyRecord#getPrimaryKeyID()
- */
public String getUniqueKeyID() {
return uniqueKeyID;
}
- // ==================================================================================
- // P U B L I C M E T H O D S
- // ==================================================================================
-
/**
* @param object
*/
@@ -56,11 +45,11 @@
uniqueKeyID = keyID;
}
- public ColumnSetRecordImpl getPrimaryKey() {
+ public KeyRecord getPrimaryKey() {
return this.primaryKey;
}
- public void setPrimaryKey(ColumnSetRecordImpl primaryKey) {
+ public void setPrimaryKey(KeyRecord primaryKey) {
this.primaryKey = primaryKey;
}
}
\ No newline at end of file
Added: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.metadata.runtime;
+
+public class KeyRecord extends ColumnSetRecordImpl {
+
+ public enum Type {
+ Primary,
+ Foreign,
+ Unique, //constraint
+ NonUnique,
+ AccessPattern,
+ Index,
+ }
+
+ private Type type;
+ private TableRecordImpl table;
+
+ public KeyRecord(Type type) {
+ this.type = type;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public TableRecordImpl getTable() {
+ return table;
+ }
+
+ public void setTable(TableRecordImpl table) {
+ this.table = table;
+ }
+
+}
Property changes on: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataConstants.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataConstants.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataConstants.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -1,293 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import com.metamatrix.core.util.StringUtil;
-
-/**
- * MetadataConstants are all the constant values used to identify all the valid values for a multi-value attribute.
- * All assigned short values start with 1. Therefore, when the get...TypeName(type) method is called, the
- * method needs to subtract 1 from the argument.
- */
-public final class MetadataConstants {
-
- /** Definition of not defined long type. */
- public static final long NOT_DEFINED_LONG = Long.MIN_VALUE;
- /** Definition of not defined int type. */
- public static final int NOT_DEFINED_INT = Integer.MIN_VALUE;
- /** Definition of not defined short type. */
- public static final short NOT_DEFINED_SHORT = Short.MIN_VALUE;
-
- public final static String BLANK = StringUtil.Constants.EMPTY_STRING;
-
- //properties
- public static final String VERSION_DATE = "versionDate"; //$NON-NLS-1$
-
- /**
- * These types are associated with a KEY, indicating the type of matching that can be performed on it.
- */
- public final static class MATCH_TYPES {
- public final static short FULL_MATCH = 0;
- public final static short PARTIAL_MATCH = 1;
- public final static short NEITHER_MATCH = 2;
- public final static short NA = 3;
- public final static String[] TYPE_NAMES = { "Full", //$NON-NLS-1$
- "Partial", //$NON-NLS-1$
- "Neither", //$NON-NLS-1$
- "N/A" }; //$NON-NLS-1$
- }
-
- public final static String getMatchTypeName(short type) {
- return MATCH_TYPES.TYPE_NAMES[type];
- }
-
-
- /**
- * These types indicate the type of KEY it is.
- * The values must be kept consistent with the values referenced in
- * KeyTypeEnumeration.properties in connector.metadata
- */
- public final static class KEY_TYPES {
- public final static short PRIMARY_KEY = 0;
- public final static short FOREIGN_KEY = 1;
- public final static short UNIQUE_KEY = 2;
- public final static short NON_UNIQUE_KEY = 3;
- public final static short ACCESS_PATTERN = 4;
- public final static short INDEX = 5;
- public final static String[] TYPE_NAMES = { "Primary", //$NON-NLS-1$
- "Foreign", //$NON-NLS-1$
- "Unique", //$NON-NLS-1$
- "NonUnique", //$NON-NLS-1$
- "AccessPattern", //$NON-NLS-1$
- "Index" }; //$NON-NLS-1$
- }
- public final static String getKeyTypeName(short type) {
- return KEY_TYPES.TYPE_NAMES[type];
- }
-
- /**
- * These types indicate the type of COLUMN_SET it is.
- * The values must be kept consistent with the values referenced in
- * KeyTypeEnumeration.properties in connector.metadata
- */
- public final static class COLUMN_SET_TYPES {
- public final static short FOREIGN_KEY = 0;
- public final static short UNIQUE_KEY = 1;
- public final static short ACCESS_PATTERN = 2;
- public final static short INDEX = 3;
- public final static short PROCEDURE_RESULT = 4;
- public final static short TABLE = 5;
- public final static String[] TYPE_NAMES = { "Foreign", //$NON-NLS-1$
- "Unique", //$NON-NLS-1$
- "AccessPattern", //$NON-NLS-1$
- "Index", //$NON-NLS-1$
- "Procedure_Result", //$NON-NLS-1$
- "Table"}; //$NON-NLS-1$
- }
- public final static String getColumnSetTypeName(short type) {
- return KEY_TYPES.TYPE_NAMES[type];
- }
-
- /**
- * These types indicate the type of PROCEDURE it is.
- * The values must be kept consistent with the values referenced in
- * ProcTypeEnumeration.properties in connector.metadata
- */
- public final static class PROCEDURE_TYPES {
- public final static short FUNCTION = 0;
- public final static short STORED_PROCEDURE = 1;
- public final static short STORED_QUERY = 2;
- public final static String[] TYPE_NAMES = { "Function", //$NON-NLS-1$
- "StoredProc", //$NON-NLS-1$
- "StoredQuery" }; //$NON-NLS-1$
- }
- public final static String getProcedureTypeName(short type) {
- return PROCEDURE_TYPES.TYPE_NAMES[type];
- }
-
- /**
- * These types indicate the type of TRANSFORMATION it it.
- */
- public final static class SQL_TRANSFORMATION_TYPES {
- public final static short MAPPING_DEFN = 0;
- public final static short QUERY_PLAN_SELECT_QUERY = 1;
- public final static short QUERY_PLAN_INSERT_QUERY = 2;
- public final static short QUERY_PLAN_UPDATE_QUERY = 3;
- public final static short QUERY_PLAN_DELETE_QUERY = 4;
- public final static short QUERY_PLAN_STORED_QUERY = 5;
- public final static String[] TYPE_NAMES = { "MappingDefn", //$NON-NLS-1$
- "QueryPlanSelectQuery", //$NON-NLS-1$
- "QueryPlanInsertQuery", //$NON-NLS-1$
- "QueryPlanUpdateQuery", //$NON-NLS-1$
- "QueryPlanDeleteQuery", //$NON-NLS-1$
- "QueryPlanStoredQuery"}; //$NON-NLS-1$
- }
- public final static String getSqlTransformationTypeName(short type) {
- return SQL_TRANSFORMATION_TYPES.TYPE_NAMES[type];
- }
-
- /**
- * These types indicate the type of PROCEDURE_PARAMETER it is.
- * The values must be kept consistent with the DirectionKind enumeration in the relational
- * metamodel and the values referenced in ProcParamDirectionEnumeration.properties in connector.metadata
- */
- public final static class PARAMETER_TYPES {
- public final static short IN_PARM = 0;
- public final static short OUT_PARM = 1;
- public final static short INOUT_PARM = 2;
- public final static short RETURN_VALUE = 3;
- public final static short RESULT_SET = 4;
- public final static String[] TYPE_NAMES = { "In", //$NON-NLS-1$
- "Out", //$NON-NLS-1$
- "InOut", //$NON-NLS-1$
- "ReturnValue", //$NON-NLS-1$
- "ResultSet" }; //$NON-NLS-1$
- }
- public final static String getParameterTypeName(short type) {
- return PARAMETER_TYPES.TYPE_NAMES[type];
- }
-
- /**
- * These types are associated with the Element having valid search types.
- * The values must be kept consistent with the SearchabilityType enumeration in the relational
- * metamodel and the values referenced in SearchTypeEnumeration.properties in connector.metadata
- */
- public final static class SEARCH_TYPES {
- public final static short SEARCHABLE = 0;
- public final static short ALLEXCEPTLIKE = 1;
- public final static short LIKE_ONLY = 2;
- public final static short UNSEARCHABLE = 3;
- public final static String[] TYPE_NAMES = { "Searchable", //$NON-NLS-1$
- "All Except Like", //$NON-NLS-1$
- "Like Only", //$NON-NLS-1$
- "Unsearchable" }; //$NON-NLS-1$
- }
- public final static String getSearchTypeName(short type) {
- return SEARCH_TYPES.TYPE_NAMES[type];
- }
-
- /**
- * A DataType object will be identified as being of one of these types.
- * The values must be kept consistent with the values referenced in
- * DatatypeTypeEnumeration.properties in connector.metadata
- */
- public final static class DATATYPE_TYPES {
- public final static short BASIC = 0;
- public final static short USER_DEFINED = 1;
- public final static short RESULT_SET = 2;
- public final static String[] TYPE_NAMES = { "Basic", //$NON-NLS-1$
- "UserDefined", //$NON-NLS-1$
- "ResultSet" }; //$NON-NLS-1$
- }
- public final static String getDataTypeTypeName(short type) {
- return DATATYPE_TYPES.TYPE_NAMES[type];
- }
-
- /**
- * User defined DataType objects will be categorized by a variety
- * The values must be kept consistent with the XSDVariety enumeration in the xsd
- * metamodel and the values referenced in DatatypeVarietyEnumeration.properties in
- * connector.metadata
- */
- public final static class DATATYPE_VARIETIES {
- public final static short ATOMIC = 0;
- public final static short LIST = 1;
- public final static short UNION = 2;
- public final static short COMPLEX = 3;
- public final static String[] TYPE_NAMES = { "Atomic", //$NON-NLS-1$
- "List", //$NON-NLS-1$
- "Union", //$NON-NLS-1$
- "Complex" }; //$NON-NLS-1$
- }
- public final static String getDataTypeVarietyName(short type) {
- return DATATYPE_VARIETIES.TYPE_NAMES[type];
- }
-
- /**
- * These types represent the type of table a Group is.
- */
- public final static class TABLE_TYPES {
- public static final short TABLE_TYPE = 0;
- public static final short VIEW_TYPE = 1;
- public static final short DOCUMENT_TYPE = 2;
- public static final short XML_MAPPING_CLASS_TYPE = 3;
- public static final short XML_STAGING_TABLE_TYPE = 4;
- public static final short MATERIALIZED_TYPE = 5;
- public final static String[] TYPE_NAMES = { "Table", //$NON-NLS-1$
- "View", //$NON-NLS-1$
- "Document", //$NON-NLS-1$
- "XmlMappingClass", //$NON-NLS-1$
- "XmlStagingTable", //$NON-NLS-1$
- "MaterializedTable" }; //$NON-NLS-1$
- }
- public final static String getTableTypeName(short type) {
- return TABLE_TYPES.TYPE_NAMES[type];
- }
-
- /**
- * These types are associated with a DataType or an Element needing the indication of null types.
- * The values must be kept consistent with the NullableType enumeration in the relational
- * metamodel and the values referenced in NullTypeEnumeration.properties in connector.metadata
- */
- public final static class NULL_TYPES {
- public static final short NOT_NULL = 0;
- public static final short NULLABLE = 1;
- public static final short UNKNOWN = 2;
- public final static String[] TYPE_NAMES = { "No Nulls", //$NON-NLS-1$
- "Nullable", //$NON-NLS-1$
- "Unknown" }; //$NON-NLS-1$
- }
- //Record type Constants
- public static class RECORD_TYPE {
- public final static char MODEL = 'A';
- public final static char TABLE = 'B';
- public final static char RESULT_SET = 'C';
- public final static char JOIN_DESCRIPTOR = 'D';
- public final static char CALLABLE = 'E';
- public final static char CALLABLE_PARAMETER = 'F';
- public final static char COLUMN = 'G';
- public final static char ACCESS_PATTERN = 'H';
- public final static char UNIQUE_KEY = 'I';
- public final static char FOREIGN_KEY = 'J';
- public final static char PRIMARY_KEY = 'K';
- public final static char INDEX = 'L';
- public final static char DATATYPE = 'M';
- //public final static char DATATYPE_ELEMENT = 'N';
- //public final static char DATATYPE_FACET = 'O';
- public final static char SELECT_TRANSFORM = 'P';
- public final static char INSERT_TRANSFORM = 'Q';
- public final static char UPDATE_TRANSFORM = 'R';
- public final static char DELETE_TRANSFORM = 'S';
- public final static char PROC_TRANSFORM = 'T';
- public final static char MAPPING_TRANSFORM = 'U';
- public final static char VDB_ARCHIVE = 'V';
- public final static char ANNOTATION = 'W';
- public final static char PROPERTY = 'X';
- public final static char FILE = 'Z';
- public final static char RECORD_CONTINUATION = '&';
- }
-
- public final static String getNullTypeName(short type) {
- return NULL_TYPES.TYPE_NAMES[type];
- }
-}
\ No newline at end of file
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -23,7 +23,6 @@
package org.teiid.connector.metadata.runtime;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -34,74 +33,52 @@
import org.teiid.connector.DataPlugin;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.metadata.runtime.MetadataConstants.PARAMETER_TYPES;
-import org.teiid.connector.metadata.runtime.MetadataConstants.RECORD_TYPE;
+import org.teiid.connector.metadata.runtime.ModelRecordImpl.Type;
import com.metamatrix.core.id.UUIDFactory;
-import com.metamatrix.core.vdb.ModelType;
-public class MetadataFactory implements ConnectorMetadata {
+/**
+ * Allows connectors to build metadata for use by the engine.
+ *
+ * TODO: add support for datatype import
+ * TODO: add support for unique constraints
+ */
+public class MetadataFactory {
- private transient UUIDFactory factory = new UUIDFactory();
- private transient Map<String, DatatypeRecordImpl> dataTypes;
- private transient Properties importProperties;
-
private ModelRecordImpl model;
- private Collection<TableRecordImpl> tables = new ArrayList<TableRecordImpl>();
- private Collection<ProcedureRecordImpl> procedures = new ArrayList<ProcedureRecordImpl>();
- private Collection<AnnotationRecordImpl> annotations = new ArrayList<AnnotationRecordImpl>();
- private Collection<PropertyRecordImpl> properties = new ArrayList<PropertyRecordImpl>();
-
+ private UUIDFactory factory = new UUIDFactory();
+ private Map<String, DatatypeRecordImpl> dataTypes;
+ private Properties importProperties;
+ private MetadataStore store = new MetadataStore();
private Set<String> uniqueNames = new HashSet<String>();
public MetadataFactory(String modelName, Map<String, DatatypeRecordImpl> dataTypes, Properties importProperties) {
this.dataTypes = dataTypes;
this.importProperties = importProperties;
model = new ModelRecordImpl();
- model.setFullName(modelName);
- model.setModelType(ModelType.PHYSICAL);
- model.setRecordType(RECORD_TYPE.MODEL);
+ model.setName(modelName);
+ model.setModelType(Type.Physical);
model.setPrimaryMetamodelUri("http://www.metamatrix.com/metamodels/Relational"); //$NON-NLS-1$
setUUID(model);
+ store.addModel(model);
}
+ public MetadataStore getMetadataStore() {
+ return store;
+ }
+
public Properties getImportProperties() {
return importProperties;
}
- @Override
- public ModelRecordImpl getModel() {
- return model;
- }
-
- @Override
- public Collection<TableRecordImpl> getTables() {
- return tables;
- }
-
- @Override
- public Collection<ProcedureRecordImpl> getProcedures() {
- return procedures;
- }
-
- @Override
- public Collection<AnnotationRecordImpl> getAnnotations() {
- return annotations;
- }
-
- public Collection<PropertyRecordImpl> getProperties() {
- return properties;
- }
-
private void setUUID(AbstractMetadataRecord record) {
record.setUUID(factory.create().toString());
}
private void setValuesUsingParent(String name,
- AbstractMetadataRecord parent, AbstractMetadataRecord child) throws ConnectorException {
- child.setFullName(parent.getFullName() + "." + name); //$NON-NLS-1$
- child.setParentUUID(parent.getUUID());
- if (!uniqueNames.add(child.getRecordType() + "/" + child.getFullName())) { //$NON-NLS-1$
+ AbstractMetadataRecord parent, AbstractMetadataRecord child, String recordType) throws ConnectorException {
+ child.setFullName(parent.getFullName() + AbstractMetadataRecord.NAME_DELIM_CHAR + name);
+ if (!uniqueNames.add(recordType + "/" + child.getFullName())) { //$NON-NLS-1$
throw new ConnectorException(DataPlugin.Util.getString("MetadataFactory.duplicate_name", child)); //$NON-NLS-1$
}
}
@@ -114,16 +91,15 @@
*/
public TableRecordImpl addTable(String name) throws ConnectorException {
TableRecordImpl table = new TableRecordImpl();
- setValuesUsingParent(name, model, table);
- table.setRecordType(RECORD_TYPE.TABLE);
+ table.setTableType(TableRecordImpl.Type.Table);
+ setValuesUsingParent(name, model, table, "table"); //$NON-NLS-1$
table.setColumns(new LinkedList<ColumnRecordImpl>());
- table.setAccessPatterns(new LinkedList<ColumnSetRecordImpl>());
- table.setIndexes(new LinkedList<ColumnSetRecordImpl>());
- table.setExtensionProperties(new LinkedList<PropertyRecordImpl>());
+ table.setAccessPatterns(new LinkedList<KeyRecord>());
+ table.setIndexes(new LinkedList<KeyRecord>());
table.setForiegnKeys(new LinkedList<ForeignKeyRecordImpl>());
- table.setUniqueKeys(new LinkedList<ColumnSetRecordImpl>());
+ table.setUniqueKeys(new LinkedList<KeyRecord>());
setUUID(table);
- this.tables.add(table);
+ this.store.addTable(table);
return table;
}
@@ -137,15 +113,13 @@
*/
public ColumnRecordImpl addColumn(String name, String type, ColumnSetRecordImpl table) throws ConnectorException {
ColumnRecordImpl column = new ColumnRecordImpl();
- setValuesUsingParent(name, table, column);
- column.setRecordType(RECORD_TYPE.COLUMN);
+ setValuesUsingParent(name, table, column, "column"); //$NON-NLS-1$
table.getColumns().add(column);
column.setPosition(table.getColumns().size()); //1 based indexing
DatatypeRecordImpl datatype = setColumnType(type, column);
column.setCaseSensitive(datatype.isCaseSensitive());
column.setAutoIncrementable(datatype.isAutoIncrement());
column.setSigned(datatype.isSigned());
- column.setExtensionProperties(new LinkedList<PropertyRecordImpl>());
setUUID(column);
return column;
}
@@ -159,7 +133,6 @@
column.setDatatype(datatype);
column.setDatatypeUUID(datatype.getUUID());
column.setLength(datatype.getLength());
- column.setNullType(datatype.getNullType());
column.setPrecision(datatype.getPrecisionLength());
column.setRadix(datatype.getRadix());
column.setRuntimeType(datatype.getRuntimeTypeName());
@@ -167,23 +140,6 @@
}
/**
- * Add an annotation of description to a record. Only one annotation should be added per record.
- * @param annotation
- * @param record
- * @return
- */
- public AnnotationRecordImpl addAnnotation(String annotation, AbstractMetadataRecord record) {
- AnnotationRecordImpl annotationRecordImpl = new AnnotationRecordImpl();
- annotationRecordImpl.setRecordType(RECORD_TYPE.ANNOTATION);
- setUUID(annotationRecordImpl);
- annotationRecordImpl.setParentUUID(record.getUUID());
- annotationRecordImpl.setDescription(annotation);
- record.setAnnotation(annotationRecordImpl);
- annotations.add(annotationRecordImpl);
- return annotationRecordImpl;
- }
-
- /**
* Adds a primary key to the given table. The column names should be in key order.
* @param name
* @param columnNames
@@ -192,41 +148,55 @@
* @throws ConnectorException
*/
public ColumnSetRecordImpl addPrimaryKey(String name, List<String> columnNames, TableRecordImpl table) throws ConnectorException {
- ColumnSetRecordImpl primaryKey = new ColumnSetRecordImpl(MetadataConstants.KEY_TYPES.PRIMARY_KEY);
+ KeyRecord primaryKey = new KeyRecord(KeyRecord.Type.Primary);
+ primaryKey.setTable(table);
primaryKey.setColumns(new ArrayList<ColumnRecordImpl>(columnNames.size()));
- primaryKey.setRecordType(RECORD_TYPE.PRIMARY_KEY);
- setValuesUsingParent(name, table, primaryKey);
+ setValuesUsingParent(name, table, primaryKey, "pk"); //$NON-NLS-1$
setUUID(primaryKey);
assignColumns(columnNames, table, primaryKey);
table.setPrimaryKey(primaryKey);
- table.setPrimaryKeyID(primaryKey.getUUID());
return primaryKey;
}
/**
- * Adds an index or unique key constraint to the given table.
+ * Adds an access pattern to the given table.
* @param name
+ * @param columnNames
+ * @param table
+ * @return
+ * @throws ConnectorException
+ */
+ public KeyRecord addAccessPattern(String name, List<String> columnNames, TableRecordImpl table) throws ConnectorException {
+ KeyRecord ap = new KeyRecord(KeyRecord.Type.AccessPattern);
+ ap.setTable(table);
+ ap.setColumns(new ArrayList<ColumnRecordImpl>(columnNames.size()));
+ setValuesUsingParent(name, table, ap, "index"); //$NON-NLS-1$
+ setUUID(ap);
+ assignColumns(columnNames, table, ap);
+ table.getAccessPatterns().add(ap);
+ return ap;
+ }
+
+ /**
+ * Adds an index to the given table.
+ * @param name
* @param nonUnique true indicates that an index is being added.
* @param columnNames
* @param table
* @return
* @throws ConnectorException
*/
- public ColumnSetRecordImpl addIndex(String name, boolean nonUnique, List<String> columnNames, TableRecordImpl table) throws ConnectorException {
- ColumnSetRecordImpl index = new ColumnSetRecordImpl(nonUnique?MetadataConstants.KEY_TYPES.INDEX:MetadataConstants.KEY_TYPES.UNIQUE_KEY);
+ public KeyRecord addIndex(String name, boolean nonUnique, List<String> columnNames, TableRecordImpl table) throws ConnectorException {
+ KeyRecord index = new KeyRecord(nonUnique?KeyRecord.Type.NonUnique:KeyRecord.Type.Index);
+ index.setTable(table);
index.setColumns(new ArrayList<ColumnRecordImpl>(columnNames.size()));
- index.setRecordType(nonUnique?MetadataConstants.RECORD_TYPE.INDEX:MetadataConstants.RECORD_TYPE.UNIQUE_KEY);
- setValuesUsingParent(name, table, index);
+ setValuesUsingParent(name, table, index, "index"); //$NON-NLS-1$
setUUID(index);
assignColumns(columnNames, table, index);
- if (nonUnique) {
- table.getIndexes().add(index);
- } else {
- table.getUniqueKeys().add(index);
- }
+ table.getIndexes().add(index);
return index;
}
-
+
/**
* Adds a foreign key to the given table. The column names should be in key order.
* @param name
@@ -238,41 +208,21 @@
*/
public ForeignKeyRecordImpl addForiegnKey(String name, List<String> columnNames, TableRecordImpl pkTable, TableRecordImpl table) throws ConnectorException {
ForeignKeyRecordImpl foreignKey = new ForeignKeyRecordImpl();
+ foreignKey.setTable(table);
foreignKey.setColumns(new ArrayList<ColumnRecordImpl>(columnNames.size()));
- foreignKey.setRecordType(RECORD_TYPE.FOREIGN_KEY);
- setValuesUsingParent(name, table, foreignKey);
+ setValuesUsingParent(name, table, foreignKey, "fk"); //$NON-NLS-1$
setUUID(foreignKey);
+ if (pkTable.getPrimaryKey() == null) {
+ throw new ConnectorException("No primary key defined for table " + pkTable); //$NON-NLS-1$
+ }
foreignKey.setPrimaryKey(pkTable.getPrimaryKey());
- foreignKey.setUniqueKeyID(pkTable.getPrimaryKeyID());
+ foreignKey.setUniqueKeyID(pkTable.getPrimaryKey().getUUID());
assignColumns(columnNames, table, foreignKey);
table.getForeignKeys().add(foreignKey);
return foreignKey;
}
/**
- * Adds an extension property to the given record.
- * @param name
- * @param value
- * @param record
- * @return
- * @throws ConnectorException
- */
- public PropertyRecordImpl addExtensionProperty(String name, String value, AbstractMetadataRecord record) throws ConnectorException {
- PropertyRecordImpl property = new PropertyRecordImpl();
- property.setRecordType(RECORD_TYPE.PROPERTY);
- setValuesUsingParent(name, record, property);
- setUUID(property);
- property.setPropertyName(name);
- property.setPropertyValue(value);
- properties.add(property);
- if (record.getExtensionProperties() == null) {
- record.setExtensionProperties(new LinkedList<PropertyRecordImpl>());
- }
- record.getExtensionProperties().add(property);
- return property;
- }
-
- /**
* Add a procedure with the given name to the model.
* @param name
* @return
@@ -280,27 +230,25 @@
*/
public ProcedureRecordImpl addProcedure(String name) throws ConnectorException {
ProcedureRecordImpl procedure = new ProcedureRecordImpl();
- procedure.setRecordType(RECORD_TYPE.CALLABLE);
- setValuesUsingParent(name, this.model, procedure);
+ setValuesUsingParent(name, this.model, procedure, "proc"); //$NON-NLS-1$
setUUID(procedure);
procedure.setParameters(new LinkedList<ProcedureParameterRecordImpl>());
- this.procedures.add(procedure);
+ this.store.addProcedure(procedure);
return procedure;
}
/**
- *
+ * Add a procedure parameter.
* @param name
- * @param type should be one of {@link PARAMETER_TYPES}
- * @param parameterType should be one of {@link TypeFacility.RUNTIME_NAMES}
+ * @param type should be one of {@link TypeFacility.RUNTIME_NAMES}
+ * @param parameterType should be one of {@link ProcedureParameterRecordImpl.Type}
* @param procedure
* @return
* @throws ConnectorException
*/
- public ProcedureParameterRecordImpl addProcedureParameter(String name, String type, short parameterType, ProcedureRecordImpl procedure) throws ConnectorException {
+ public ProcedureParameterRecordImpl addProcedureParameter(String name, String type, ProcedureParameterRecordImpl.Type parameterType, ProcedureRecordImpl procedure) throws ConnectorException {
ProcedureParameterRecordImpl param = new ProcedureParameterRecordImpl();
- param.setRecordType(RECORD_TYPE.CALLABLE_PARAMETER);
- setValuesUsingParent(name, procedure, param);
+ setValuesUsingParent(name, procedure, param, "param"); //$NON-NLS-1$
setUUID(param);
param.setType(parameterType);
setColumnType(type, param);
@@ -310,7 +258,7 @@
}
/**
- *
+ * Add a procedure resultset column to the given procedure.
* @param name
* @param type should be one of {@link TypeFacility.RUNTIME_NAMES}
* @param procedure
@@ -319,9 +267,8 @@
*/
public ColumnRecordImpl addProcedureResultSetColumn(String name, String type, ProcedureRecordImpl procedure) throws ConnectorException {
if (procedure.getResultSet() == null) {
- ColumnSetRecordImpl resultSet = new ColumnSetRecordImpl((short)-1);
- resultSet.setRecordType(RECORD_TYPE.RESULT_SET);
- setValuesUsingParent("RESULT_SET", procedure, resultSet); //$NON-NLS-1$
+ ColumnSetRecordImpl resultSet = new ColumnSetRecordImpl();
+ setValuesUsingParent("RESULT_SET", procedure, resultSet, "rs"); //$NON-NLS-1$ //$NON-NLS-2$
setUUID(resultSet);
procedure.setResultSet(resultSet);
procedure.setResultSetID(resultSet.getUUID());
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java (from rev 1529, trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ConnectorMetadata.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.metadata.runtime;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Simple holder for metadata.
+ */
+public class MetadataStore implements Serializable {
+
+ private static final long serialVersionUID = -5276588417872522795L;
+ private Map<String, ModelRecordImpl> models = new LinkedHashMap<String, ModelRecordImpl>();
+ private Map<String, TableRecordImpl> tables = new LinkedHashMap<String, TableRecordImpl>();
+ private Map<String, ProcedureRecordImpl> procedures = new LinkedHashMap<String, ProcedureRecordImpl>();
+ private Collection<DatatypeRecordImpl> datatypes = new ArrayList<DatatypeRecordImpl>();
+
+ public void addModel(ModelRecordImpl model) {
+ this.models.put(model.getFullName().toLowerCase(), model);
+ }
+
+ public void addTable(TableRecordImpl table) {
+ this.tables.put(table.getFullName().toLowerCase(), table);
+ }
+
+ public void addProcedure(ProcedureRecordImpl procedure) {
+ this.procedures.put(procedure.getFullName().toLowerCase(), procedure);
+ }
+
+ public void addDatatype(DatatypeRecordImpl datatype) {
+ this.datatypes.add(datatype);
+ }
+
+ /**
+ * Get the models represented in this store.
+ * For a connector there will only be 1 model and the model name is treated as
+ * a top level schema for all source metadata.
+ * @return
+ */
+ public Map<String, ModelRecordImpl> getModels() {
+ return models;
+ }
+
+ /**
+ * Get the tables defined in this store
+ * @return
+ */
+ public Map<String, TableRecordImpl> getTables() {
+ return tables;
+ }
+
+ /**
+ * Get the procedures defined in this store
+ * @return
+ */
+ public Map<String, ProcedureRecordImpl> getProcedures() {
+ return procedures;
+ }
+
+ /**
+ * Get the datatypes defined in this store
+ * @return
+ */
+ public Collection<DatatypeRecordImpl> getDatatypes() {
+ return datatypes;
+ }
+
+}
Property changes on: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ModelRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ModelRecordImpl.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ModelRecordImpl.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -22,100 +22,51 @@
package org.teiid.connector.metadata.runtime;
-import com.metamatrix.core.vdb.ModelType;
/**
* ModelRecordImpl
*/
public class ModelRecordImpl extends AbstractMetadataRecord {
- private int modelType;
- private int maxSetSize;
+ public enum Type {
+ Physical,
+ Virtual,
+ Type,
+ VDB_Archive() {
+ @Override
+ public String toString() {
+ return "VDB Archive"; //$NON-NLS-1$
+ }
+ },
+ Unknown,
+ Function,
+ Configuration,
+ Metamodel,
+ Extension,
+ Logical,
+ Materialization
+ }
+
+ private Type modelType;
private boolean isVisible = true;
- private boolean supportsDistinct;
- private boolean supportsJoin;
- private boolean supportsOrderBy;
- private boolean supportsOuterJoin;
- private boolean supportsWhereAll;
private String primaryMetamodelUri;
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.ModelRecord#getPrimaryMetamodelUri()
- */
public String getPrimaryMetamodelUri() {
return primaryMetamodelUri;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ModelRecord#getMaxSetSize()
- */
- public int getMaxSetSize() {
- return maxSetSize;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ModelRecord#isVisible()
- */
public boolean isVisible() {
return isVisible;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ModelRecord#supportsDistinct()
- */
- public boolean supportsDistinct() {
- return supportsDistinct;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ModelRecord#supportsJoin()
- */
- public boolean supportsJoin() {
- return supportsJoin;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ModelRecord#supportsOrderBy()
- */
- public boolean supportsOrderBy() {
- return supportsOrderBy;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ModelRecord#supportsOuterJoin()
- */
- public boolean supportsOuterJoin() {
- return supportsOuterJoin;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ModelRecord#supportsWhereAll()
- */
- public boolean supportsWhereAll() {
- return supportsWhereAll;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ModelRecord#getModelType()
- */
- public int getModelType() {
+ public Type getModelType() {
return modelType;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.ModelRecord#isPhysical()
- */
public boolean isPhysical() {
- if (getModelType() == ModelType.PHYSICAL) {
- return true;
- }
- return false;
+ return getModelType() == Type.Physical;
}
- // ==================================================================================
- // P U B L I C M E T H O D S
- // ==================================================================================
-
/**
* @param string
*/
@@ -133,49 +84,7 @@
/**
* @param i
*/
- public void setMaxSetSize(int i) {
- maxSetSize = i;
- }
-
- /**
- * @param b
- */
- public void setSupportsDistinct(boolean b) {
- supportsDistinct = b;
- }
-
- /**
- * @param b
- */
- public void setSupportsJoin(boolean b) {
- supportsJoin = b;
- }
-
- /**
- * @param b
- */
- public void setSupportsOrderBy(boolean b) {
- supportsOrderBy = b;
- }
-
- /**
- * @param b
- */
- public void setSupportsOuterJoin(boolean b) {
- supportsOuterJoin = b;
- }
-
- /**
- * @param b
- */
- public void setSupportsWhereAll(boolean b) {
- supportsWhereAll = b;
- }
-
- /**
- * @param i
- */
- public void setModelType(int i) {
+ public void setModelType(Type i) {
modelType = i;
}
@@ -188,8 +97,6 @@
sb.append(getNameInSource());
sb.append(", uuid="); //$NON-NLS-1$
sb.append(getUUID());
- sb.append(", pathInModel="); //$NON-NLS-1$
- sb.append(getPath());
return sb.toString();
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameterRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameterRecordImpl.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameterRecordImpl.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -22,19 +22,29 @@
package org.teiid.connector.metadata.runtime;
+
/**
* ProcedureParameterRecordImpl
*/
public class ProcedureParameterRecordImpl extends BaseColumn {
- private short type;
+ public enum Type {
+ Unknown,
+ In,
+ InOut,
+ ResultSet,
+ Out,
+ ReturnValue
+ }
+
+ private Type type;
private boolean optional;
- public void setType(short type) {
+ public void setType(Type type) {
this.type = type;
}
- public short getType() {
+ public Type getType() {
return type;
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureRecordImpl.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureRecordImpl.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -30,6 +30,13 @@
*/
public class ProcedureRecordImpl extends AbstractMetadataRecord {
+ public enum Type {
+ Function,
+ UDF,
+ StoredProc,
+ StoredQuery
+ }
+
private List<String> parameterIDs;
private boolean isFunction;
private boolean isVirtual;
@@ -38,46 +45,36 @@
private List<ProcedureParameterRecordImpl> parameters;
private ColumnSetRecordImpl resultSet;
private String queryPlan;
-
- /*
- * @see com.metamatrix.modeler.core.metadata.runtime.ProcedureRecord#getParameterIDs()
- */
+
public List<String> getParameterIDs() {
return parameterIDs;
}
- /*
- * @see com.metamatrix.modeler.core.metadata.runtime.ProcedureRecord#isFunction()
- */
public boolean isFunction() {
return isFunction;
}
- /*
- * @see com.metamatrix.modeler.core.metadata.runtime.ProcedureRecord#isVirtual()
- */
public boolean isVirtual() {
return this.isVirtual;
}
- /*
- * @see com.metamatrix.modeler.core.metadata.runtime.ProcedureRecord#getResultSetID()
- */
public String getResultSetID() {
return resultSetID;
}
- /*
- * @see com.metamatrix.modeler.core.metadata.runtime.ProcedureRecord#getType()
- */
- public short getType() {
- return this.getProcedureType();
+ public Type getType() {
+ if (isFunction()) {
+ if (isVirtual()) {
+ return Type.UDF;
+ }
+ return Type.Function;
+ }
+ if (isVirtual()) {
+ return Type.StoredQuery;
+ }
+ return Type.StoredProc;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.ProcedureRecord#getUpdateCount()
- * @since 5.5.3
- */
public int getUpdateCount() {
return this.updateCount;
}
@@ -130,16 +127,6 @@
this.updateCount = count;
}
- protected short getProcedureType() {
- if (isFunction()) {
- return MetadataConstants.PROCEDURE_TYPES.FUNCTION;
- }
- if (isVirtual()) {
- return MetadataConstants.PROCEDURE_TYPES.STORED_QUERY;
- }
- return MetadataConstants.PROCEDURE_TYPES.STORED_PROCEDURE;
- }
-
public void setResultSet(ColumnSetRecordImpl resultSet) {
this.resultSet = resultSet;
}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/PropertyRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/PropertyRecordImpl.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/PropertyRecordImpl.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -1,96 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-
-
-/**
- * PropertyRecordImpl
- */
-public class PropertyRecordImpl extends AbstractMetadataRecord {
-
- /**
- * Constants for names of accessor methods that map to fields stored on the PropertyRecords.
- * Note the names do not have "get" on them, this is also the nameInsource
- * of the attributes on SystemPhysicalModel.
- * @since 4.3
- */
- public static interface MetadataFieldNames {
- String PROPERTY_NAME_FIELD = "PropertyName"; //$NON-NLS-1$
- String PROPERTY_VALUE_FIELD = "PropertyValue"; //$NON-NLS-1$
- }
-
- private String name;
- private String value;
-
- //==================================================================================
- // I N T E R F A C E M E T H O D S
- //==================================================================================
-
- /*
- * @see com.metamatrix.modeler.core.metadata.runtime.PropertyRecord#getPropertyName()
- */
- public String getPropertyName() {
- return this.name;
- }
-
- /*
- * @see com.metamatrix.modeler.core.metadata.runtime.PropertyRecord#getPropertyValue()
- */
- public String getPropertyValue() {
- return this.value;
- }
-
- // ==================================================================================
- // P U B L I C M E T H O D S
- // ==================================================================================
-
- public String toString() {
- StringBuffer sb = new StringBuffer(100);
- sb.append(getClass().getSimpleName());
- sb.append(", uuid="); //$NON-NLS-1$
- sb.append(getUUID());
- sb.append(" propName="); //$NON-NLS-1$
- sb.append(getPropertyName());
- sb.append(" propValue="); //$NON-NLS-1$
- sb.append(getPropertyValue());
- sb.append(", pathInModel="); //$NON-NLS-1$
- sb.append(getPath());
- return sb.toString();
- }
-
- /**
- * @param list
- */
- public void setPropertyName(final String name) {
- this.name = name;
- }
-
- /**
- * @param list
- */
- public void setPropertyValue(final String value) {
- this.value = value;
- }
-
-}
\ No newline at end of file
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TableRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TableRecordImpl.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TableRecordImpl.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -23,117 +23,105 @@
package org.teiid.connector.metadata.runtime;
import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
/**
* TableRecordImpl
*/
public class TableRecordImpl extends ColumnSetRecordImpl {
+ public enum Type {
+ Table,
+ View,
+ Document,
+ XmlMappingClass,
+ XmlStagingTable,
+ MaterializedTable
+ }
+
private int cardinality;
- private int tableType;
- private String primaryKeyID;
+ private Type tableType;
private String materializedTableID;
private String materializedStageTableID;
private boolean isVirtual;
private boolean isSystem;
private boolean isMaterialized;
private boolean supportsUpdate;
+ private List<ForeignKeyRecordImpl> foriegnKeys;
+ private List<KeyRecord> indexes;
+ private List<KeyRecord> uniqueKeys;
+ private List<KeyRecord> accessPatterns;
+ private KeyRecord primaryKey;
+
+ //view information
+ private String selectTransformation;
private String insertPlan;
private String updatePlan;
private String deletePlan;
- private Collection<ForeignKeyRecordImpl> foriegnKeys;
- private Collection<ColumnSetRecordImpl> indexes;
- private Collection<ColumnSetRecordImpl> uniqueKeys;
- private Collection<ColumnSetRecordImpl> accessPatterns;
- private ColumnSetRecordImpl primaryKey;
- private TransformationRecordImpl selectTransformation;
private String materializedStageTableName;
private String materializedTableName;
-
- public TableRecordImpl() {
- super((short)-1);
+
+ //XML specific
+ private List<String> bindings;
+ private List<String> schemaPaths;
+ private String resourcePath;
+
+ public List<String> getBindings() {
+ return bindings;
}
-
- //==================================================================================
- // I N T E R F A C E M E T H O D S
- //==================================================================================
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.TableRecord#getCardinality()
- */
+ public void setBindings(List<String> bindings) {
+ this.bindings = bindings;
+ }
+
+ public List<String> getSchemaPaths() {
+ return schemaPaths;
+ }
+
+ public void setSchemaPaths(List<String> schemaPaths) {
+ this.schemaPaths = schemaPaths;
+ }
+
public int getCardinality() {
return cardinality;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.TableRecord#getPrimaryKeyID()
- */
- public String getPrimaryKeyID() {
- return primaryKeyID;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.TableRecord#isVirtual()
- */
public boolean isVirtual() {
return isVirtual;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.TableRecord#isMaterialized()
- * @since 4.2
- */
public boolean isMaterialized() {
return isMaterialized;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.TableRecord#isPhysical()
- */
public boolean isPhysical() {
return !isVirtual();
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.TableRecord#isSystem()
- */
public boolean isSystem() {
return isSystem;
}
- /*
- * @see com.metamatrix.modeler.core.metadata.runtime.TableRecord#getTableType()
- */
- public int getTableType() {
+ public Type getTableType() {
+ if (tableType == null) {
+ return Type.Table;
+ }
return tableType;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.TableRecord#getMaterializedStageTableID()
- * @since 4.2
- */
public String getMaterializedStageTableID() {
return this.materializedStageTableID;
}
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.TableRecord#getMaterializedTableID()
- * @since 4.2
- */
+
public String getMaterializedTableID() {
return this.materializedTableID;
}
- /* (non-Javadoc)
- * @see com.metamatrix.modeler.core.metadata.runtime.TableRecord#supportsUpdate()
- */
public boolean supportsUpdate() {
return supportsUpdate;
}
- // ==================================================================================
- // P U B L I C M E T H O D S
- // ==================================================================================
-
/**
* @param i
*/
@@ -144,18 +132,11 @@
/**
* @param i
*/
- public void setTableType(int i) {
+ public void setTableType(Type i) {
tableType = i;
}
/**
- * @param object
- */
- public void setPrimaryKeyID(String keyID) {
- primaryKeyID = keyID;
- }
-
- /**
* @param b
*/
public void setSupportsUpdate(boolean b) {
@@ -224,52 +205,51 @@
this.deletePlan = deletePlan;
}
- public Collection<ForeignKeyRecordImpl> getForeignKeys() {
+ public List<ForeignKeyRecordImpl> getForeignKeys() {
return this.foriegnKeys;
}
- public void setForiegnKeys(Collection<ForeignKeyRecordImpl> foriegnKeys) {
+ public void setForiegnKeys(List<ForeignKeyRecordImpl> foriegnKeys) {
this.foriegnKeys = foriegnKeys;
}
- public Collection<ColumnSetRecordImpl> getIndexes() {
+ public List<KeyRecord> getIndexes() {
return this.indexes;
}
- public void setIndexes(Collection<ColumnSetRecordImpl> indexes) {
+ public void setIndexes(List<KeyRecord> indexes) {
this.indexes = indexes;
}
- public Collection<ColumnSetRecordImpl> getUniqueKeys() {
+ public List<KeyRecord> getUniqueKeys() {
return this.uniqueKeys;
}
- public void setUniqueKeys(Collection<ColumnSetRecordImpl> uniqueKeys) {
+ public void setUniqueKeys(List<KeyRecord> uniqueKeys) {
this.uniqueKeys = uniqueKeys;
}
- public Collection<ColumnSetRecordImpl> getAccessPatterns() {
+ public List<KeyRecord> getAccessPatterns() {
return this.accessPatterns;
}
- public void setAccessPatterns(Collection<ColumnSetRecordImpl> accessPatterns) {
+ public void setAccessPatterns(List<KeyRecord> accessPatterns) {
this.accessPatterns = accessPatterns;
}
- public ColumnSetRecordImpl getPrimaryKey() {
+ public KeyRecord getPrimaryKey() {
return this.primaryKey;
}
- public void setPrimaryKey(ColumnSetRecordImpl primaryKey) {
+ public void setPrimaryKey(KeyRecord primaryKey) {
this.primaryKey = primaryKey;
}
- public TransformationRecordImpl getSelectTransformation() {
+ public String getSelectTransformation() {
return selectTransformation;
}
- public void setSelectTransformation(
- TransformationRecordImpl selectTransformation) {
+ public void setSelectTransformation(String selectTransformation) {
this.selectTransformation = selectTransformation;
}
@@ -289,6 +269,26 @@
this.materializedTableName = materializedTableName;
}
+ public void setResourcePath(String resourcePath) {
+ this.resourcePath = resourcePath;
+ }
+
+ public String getResourcePath() {
+ return resourcePath;
+ }
+
+ public Collection<KeyRecord> getAllKeys() {
+ Collection<KeyRecord> keys = new LinkedList<KeyRecord>();
+ if (getPrimaryKey() != null) {
+ keys.add(getPrimaryKey());
+ }
+ keys.addAll(getForeignKeys());
+ keys.addAll(getAccessPatterns());
+ keys.addAll(getIndexes());
+ keys.addAll(getUniqueKeys());
+ return keys;
+ }
+
public String toString() {
StringBuffer sb = new StringBuffer(100);
sb.append(getClass().getSimpleName());
@@ -298,8 +298,6 @@
sb.append(getNameInSource());
sb.append(", uuid="); //$NON-NLS-1$
sb.append(getUUID());
- sb.append(", pathInModel="); //$NON-NLS-1$
- sb.append(getPath());
return sb.toString();
}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TransformationRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TransformationRecordImpl.java 2009-10-24 17:31:56 UTC (rev 1533)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TransformationRecordImpl.java 2009-10-24 18:00:19 UTC (rev 1534)
@@ -1,142 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.util.List;
-
-/**
- * TransformationRecordImpl
- */
-public class TransformationRecordImpl extends AbstractMetadataRecord {
-
- public static interface Types {
- public static final String MAPPING = "Mapping"; //$NON-NLS-1$
- public static final String SELECT = "Select"; //$NON-NLS-1$
- public static final String INSERT = "Insert"; //$NON-NLS-1$
- public static final String UPDATE = "Update"; //$NON-NLS-1$
- public static final String DELETE = "Delete"; //$NON-NLS-1$
- public static final String PROCEDURE = "Procedure"; //$NON-NLS-1$
- }
-
- private String transformation;
- private String transformationType;
- private List bindings;
- private List schemaPaths;
- private String resourcePath;
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.TransformationRecord#getTransformation()
- */
- public String getTransformation() {
- return transformation;
- }
-
- /*
- * @see com.metamatrix.modeler.core.metadata.runtime.TransformationRecord#getBindings()
- */
- public List getBindings() {
- return this.bindings;
- }
-
- /*
- * @see com.metamatrix.modeler.core.metadata.runtime.TransformationRecord#getSchemaPaths()
- */
- public List getSchemaPaths() {
- return schemaPaths;
- }
-
- /*
- * @see com.metamatrix.modeler.core.metadata.runtime.TransformationRecord#getTransformationType()
- */
- public String getTransformationType() {
- return transformationType;
- }
-
- /**
- * @see com.metamatrix.modeler.core.metadata.runtime.TransformationRecord#getType()
- */
- public String getType() {
- return this.transformationType;
- }
-
- // ==================================================================================
- // P U B L I C M E T H O D S
- // ==================================================================================
-
- /**
- * @param string
- */
- public void setTransformation(final String string) {
- transformation = string;
- }
-
- /**
- * @param string
- */
- public void setTransformationType(String string) {
- transformationType = string;
- }
-
- /**
- * @param collection
- */
- public void setBindings(List bindings) {
- this.bindings = bindings;
- }
-
- /**
- * @param collection
- */
- public void setSchemaPaths(List collection) {
- schemaPaths = collection;
- }
-
- /**
- * @return
- */
- public String getResourcePath() {
- return resourcePath;
- }
-
- /**
- * @param path
- */
- public void setResourcePath(String path) {
- resourcePath = path;
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer(100);
- sb.append(getClass().getSimpleName());
- sb.append(" name="); //$NON-NLS-1$
- sb.append(getName());
- sb.append(", nameInSource="); //$NON-NLS-1$
- sb.append(getNameInSource());
- sb.append(", uuid="); //$NON-NLS-1$
- sb.append(getUUID());
- sb.append(", pathInModel="); //$NON-NLS-1$
- sb.append(getPath());
- return sb.toString();
- }
-
-}
\ No newline at end of file
15 years, 2 months
teiid SVN: r1533 - trunk.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-10-24 13:31:56 -0400 (Sat, 24 Oct 2009)
New Revision: 1533
Removed:
trunk/connector-metadata/
Log:
TEIID-871 TEIID-792 TEIID-102 TEIID-254 TEIID-869 TEIID-875 further clean up of metadata related logic. The index connector has been removed and the system virtual views promoted to physical tables. some of the tables/procedures have been removed. and minor changes have been made to MMDatabaseMetadata queries.
15 years, 2 months
teiid SVN: r1532 - trunk/test-integration/db/src/main/java/org/teiid/test/framework/query.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-10-14 19:45:49 -0400 (Wed, 14 Oct 2009)
New Revision: 1532
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
Log:
Teiid 773 - added query timeout option to the statement assignment
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java 2009-10-14 23:42:59 UTC (rev 1531)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java 2009-10-14 23:45:49 UTC (rev 1532)
@@ -10,6 +10,7 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.sql.Connection;
+import java.sql.SQLException;
import java.sql.Statement;
import java.util.Map;
import java.util.Properties;
@@ -40,6 +41,8 @@
public abstract class AbstractQueryTransactionTest extends AbstractQueryTest implements TransactionQueryTest{
protected Properties executionProperties = null;
protected String testname = "NA";
+ protected int fetchSize = -1;
+ protected int queryTimeout = -1;
protected Map<String, DataSource> datasources = null;
@@ -70,7 +73,17 @@
public void setExecutionProperties(Properties props) {
assertNotNull(props);
- this.executionProperties = props;
+ this.executionProperties = props;
+
+ String fetchSizeStr = executionProperties.getProperty(CONNECTION_STRATEGY_PROPS.FETCH_SIZE);
+ if ( fetchSizeStr != null ) {
+ try {
+ fetchSize = Integer.parseInt(fetchSizeStr);
+ } catch ( NumberFormatException e ) {
+ fetchSize = -1;
+ this.print("Invalid fetch size value: " + fetchSizeStr + ", ignoring");
+ }
+ }
}
@Override
protected void compareResults(BufferedReader resultReader, BufferedReader expectedReader) throws IOException {
@@ -78,19 +91,34 @@
}
@Override protected void assignExecutionProperties(Statement stmt) {
- if (this.executionProperties != null) {
- if (stmt instanceof com.metamatrix.jdbc.api.Statement) {
- com.metamatrix.jdbc.api.Statement statement = (com.metamatrix.jdbc.api.Statement)stmt;
+ if (stmt instanceof com.metamatrix.jdbc.api.Statement) {
+ com.metamatrix.jdbc.api.Statement statement = (com.metamatrix.jdbc.api.Statement)stmt;
+
+ if (this.executionProperties != null) {
String txnautowrap = this.executionProperties.getProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP);
if (txnautowrap != null) {
statement.setExecutionProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, txnautowrap);
}
- if (this.executionProperties.getProperty(CONNECTION_STRATEGY_PROPS.FETCH_SIZE) != null) {
- statement.setExecutionProperty(CONNECTION_STRATEGY_PROPS.FETCH_SIZE, this.executionProperties.getProperty(CONNECTION_STRATEGY_PROPS.FETCH_SIZE));
- }
- }
- }
+ }
+
+ if (this.fetchSize > 0) {
+ try {
+ statement.setFetchSize(this.fetchSize);
+ } catch (SQLException e) {
+ this.print(e);
+ }
+ }
+
+ if (this.queryTimeout > 0) {
+ try {
+ statement.setQueryTimeout(this.queryTimeout);
+ } catch (SQLException e) {
+ this.print(e);
+ }
+ }
+ }
+
}
15 years, 2 months
teiid SVN: r1531 - trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-10-14 19:42:59 -0400 (Wed, 14 Oct 2009)
New Revision: 1531
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java
Log:
Teiid 773 - fix a NPE and the logic when there are multiple models that are to be assigned to the same datasource. example is bqt (3 models).
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java 2009-10-14 23:40:04 UTC (rev 1530)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java 2009-10-14 23:42:59 UTC (rev 1531)
@@ -1,5 +1,6 @@
package org.teiid.test.framework.datasource;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -148,6 +149,8 @@
excludedDBTypes = new HashSet<String>(eprops.size());
excludedDBTypes.addAll(eprops);
System.out.println("EXCLUDE datasources: " + excludeprop);
+ } else {
+ excludedDBTypes = Collections.EMPTY_SET;
}
@@ -313,14 +316,8 @@
+ " was not found in the allDatasources map");
}
- } else {
- throw new QueryTestFailedException("Model:id " + modelName
- + ":" + datasourceid
- + " did not map to the usedatasources: "
- + useDS.toString());
+ }
- }
-
} else {
15 years, 2 months
teiid SVN: r1530 - trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-10-14 19:40:04 -0400 (Wed, 14 Oct 2009)
New Revision: 1530
Modified:
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java
Log:
Teiid 773 - refactored out the create statement calls so that an extending class can create a statement based on other parameters that connection.createStatement(...) can accept.
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java 2009-10-06 15:20:35 UTC (rev 1529)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java 2009-10-14 23:40:04 UTC (rev 1530)
@@ -112,15 +112,15 @@
if (params != null && params.length > 0) {
if (sql.startsWith("exec ")) { //$NON-NLS-1$
sql = sql.substring(5);
- this.internalStatement = this.internalConnection.prepareCall("{?=call "+sql+"}"); //$NON-NLS-1$ //$NON-NLS-2$
+ this.internalStatement = createPrepareCallStatement(sql);
} else {
- this.internalStatement = this.internalConnection.prepareStatement(sql);
+ this.internalStatement = createPrepareStatement(sql);
}
setParameters((PreparedStatement)this.internalStatement, params);
assignExecutionProperties(this.internalStatement);
result = ((PreparedStatement)this.internalStatement).execute();
} else {
- this.internalStatement = this.internalConnection.createStatement();
+ this.internalStatement = createStatement();
assignExecutionProperties(this.internalStatement);
result = this.internalStatement.execute(sql);
}
@@ -138,6 +138,20 @@
}
return false;
}
+
+ protected Statement createPrepareCallStatement(String sql) throws SQLException{
+ return this.internalConnection.prepareCall("{?=call "+sql+"}");
+ }
+
+ protected Statement createPrepareStatement(String sql) throws SQLException{
+ return this.internalConnection.prepareStatement(sql);
+ }
+
+ protected Statement createStatement() throws SQLException{
+ return this.internalConnection.createStatement();
+ }
+
+
private void setParameters(PreparedStatement stmt, Object[] params) throws SQLException{
for (int i = 0; i < params.length; i++) {
@@ -163,7 +177,7 @@
}
}
- this.internalStatement = this.internalConnection.createStatement();
+ this.internalStatement = createStatement();
assignExecutionProperties(this.internalStatement);
if (timeout != -1) {
15 years, 2 months
teiid SVN: r1529 - trunk/test-integration/db/src/test/java/org/teiid/test/testcases.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-10-06 11:20:35 -0400 (Tue, 06 Oct 2009)
New Revision: 1529
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java
Log:
Teiid 773 - refactored out of the test code into the main framework code
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java 2009-10-06 15:18:45 UTC (rev 1528)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java 2009-10-06 15:20:35 UTC (rev 1529)
@@ -4,12 +4,11 @@
*/
package org.teiid.test.testcases;
-import java.util.Map;
-import org.teiid.test.framework.AbstractQueryTransactionTest;
-import org.teiid.test.framework.QueryExecution;
-import org.teiid.test.framework.datasource.DataSource;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+
import com.metamatrix.jdbc.api.AbstractQueryTest;
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java 2009-10-06 15:18:45 UTC (rev 1528)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java 2009-10-06 15:20:35 UTC (rev 1529)
@@ -8,8 +8,9 @@
import java.sql.SQLException;
import java.util.ArrayList;
-import org.teiid.test.framework.AbstractQueryTransactionTest;
-import org.teiid.test.framework.QueryExecution;
+import org.teiid.test.framework.ConfigPropertyNames;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
import com.metamatrix.jdbc.api.AbstractQueryTest;
@@ -359,6 +360,10 @@
* result = commit
*/
public void testMultipleSourceViewMultipleCommands() throws Exception {
+ // this.setAssignModelToDatabaseType("pm1", DataSourceFactory.DataBaseTypes.);
+
+ this.addProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP, "oracle");
+
AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceViewMultipleCommands") {
public void testCase() throws Exception {
15 years, 2 months
teiid SVN: r1528 - trunk/test-integration/db/src/test/java/org/teiid/test/testcases.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-10-06 11:18:45 -0400 (Tue, 06 Oct 2009)
New Revision: 1528
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
Log:
Teiid 773 - updated logic to support fine grain control over which datasource type is assigned to which model
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java 2009-10-06 15:16:35 UTC (rev 1527)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java 2009-10-06 15:18:45 UTC (rev 1528)
@@ -21,8 +21,8 @@
super(name);
}
+
-
@Override
protected void setUp() throws Exception {
// TODO Auto-generated method stub
@@ -32,11 +32,27 @@
}
+
+ protected ConfigPropertyLoader getConfig() {
+ return this.config;
+ }
-
protected void addProperty(String key, String value) {
config.setProperty(key, value);
}
+
+ /**
+ * Call to assign a specific database type to the model. When a datasource is requested for this model,
+ * a datasource of the specific dbtype will be returned. See {@link DataSourceFactory} for the logic that
+ * controls this behavior.
+ * @param modelName
+ * @param dbtype
+ *
+ * @since
+ */
+ protected void setAssignModelToDatabaseType(String modelName, String dbtype) {
+ config.setModelAssignedToDatabaseType(modelName, dbtype);
+ }
protected TransactionContainer getTransactionContainter() throws QueryTestFailedException {
return TransactionFactory.create(config);
15 years, 2 months
teiid SVN: r1527 - trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-10-06 11:16:35 -0400 (Tue, 06 Oct 2009)
New Revision: 1527
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java
trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
Log:
Teiid 773 - refactored out of the test code into the main framework code
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java 2009-10-06 15:15:15 UTC (rev 1526)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java 2009-10-06 15:16:35 UTC (rev 1527)
@@ -6,10 +6,10 @@
import java.util.Map;
-import org.teiid.test.framework.QueryExecution;
import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.connection.ConnectionUtil;
import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.query.QueryExecution;
import com.metamatrix.jdbc.api.AbstractQueryTest;
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java 2009-10-06 15:15:15 UTC (rev 1526)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java 2009-10-06 15:16:35 UTC (rev 1527)
@@ -6,10 +6,10 @@
import java.util.Map;
-import org.teiid.test.framework.QueryExecution;
import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.connection.ConnectionUtil;
import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.query.QueryExecution;
import com.metamatrix.jdbc.api.AbstractQueryTest;
15 years, 2 months