Skip to content

Commit

Permalink
Adds in support for teiid clients 8.5, 8.6 and 8.7
Browse files Browse the repository at this point in the history
* Tries to take a view on each change made as a result of the new teiid
  releases
 * Change is a fix => backwards compatible with all teiid versions
 * Change is a new function => guarded by tests against the teiid version
 * Change changes api => rolled into deprecated teiid client plugins
 * Changes not relevant => ignored and not included
 * Change brings in needless extra classes => ignored and not included
  • Loading branch information
Paul Richardson committed Apr 1, 2014
1 parent 80a22bf commit 9fb51ae
Show file tree
Hide file tree
Showing 85 changed files with 1,763 additions and 620 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public interface ITeiidServerVersion {
enum VersionID {
TEIID_7_7(SEVEN + DOT + SEVEN + DOT + ZERO),

TEIID_8_0(EIGHT + DOT + ZERO + DOT + ZERO),

TEIID_8_1(EIGHT + DOT + ONE + DOT + ZERO),

TEIID_8_2(EIGHT + DOT + TWO + DOT + ZERO),

TEIID_8_3(EIGHT + DOT + THREE + DOT + ZERO),

TEIID_8_4(EIGHT + DOT + FOUR + DOT + ZERO),

TEIID_8_5(EIGHT + DOT + FIVE + DOT + ZERO),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@ public static enum Version {
*/
TEIID_7_7(VersionID.TEIID_7_7),

/**
* Teiid 8.0
*/
TEIID_8_0(VersionID.TEIID_8_0),

/**
* Teiid 8.1
*/
TEIID_8_1(VersionID.TEIID_8_1),

/**
* Teiid 8.2
*/
TEIID_8_2(VersionID.TEIID_8_2),

/**
* Teiid 8.3
*/
TEIID_8_3(VersionID.TEIID_8_3),

/**
* Teiid 8.4
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public boolean equalsIgnoreCase(String name) {
*
* @return those functions in the given category
*/
@Deprecated
List<F> getFunctionForms(String category);

/**
Expand All @@ -122,8 +123,20 @@ public boolean equalsIgnoreCase(String name) {
*
* @return function or null
*/
@Deprecated
F findFunctionForm(String name, int length);

/**
* Find whether library contains function with the
* given name and number of arguments
*
* @param name
* @param length number of arguments
*
* @return true if library has function
*/
boolean hasFunctionMethod(String name, int length);

/**
* Find a function descriptor given a name and the types of the arguments.
* This method matches based on case-insensitive function name and
Expand Down
2 changes: 1 addition & 1 deletion plugins/teiid/org.teiid.7.7.x
2 changes: 1 addition & 1 deletion plugins/teiid/org.teiid.8.3.x
2 changes: 1 addition & 1 deletion plugins/teiid/org.teiid.8.4.x
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ public enum PermissionType {
*/
boolean isAnyAuthenticated();

/**
* If the policy grants all permissions
* @return
*/
@Since("8.7.0")
boolean isGrantAll();

/**
* If the policy allows for temporary table usage
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
import java.io.ObjectInputStream.GetField;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import org.teiid.adminapi.AdminObject;
import org.teiid.core.util.CopyOnWriteLinkedHashMap;
import org.teiid.designer.annotation.Removed;
import org.teiid.designer.annotation.Since;

Expand Down Expand Up @@ -66,9 +66,9 @@ public String getKey(PropertyMetadata entry) {
@Since("8.0.0")
private String hostName;

private Map<String, String> properties = Collections.synchronizedMap(new LinkedHashMap<String, String>(2));
private Map<String, String> properties = new CopyOnWriteLinkedHashMap<String, String>();

protected transient Map<Class<?>, Object> attachments = Collections.synchronizedMap(new HashMap<Class<?>, Object>(2));
protected transient Map<Class<?>, Object> attachments = new CopyOnWriteLinkedHashMap<Class<?>, Object>();

protected boolean isListOverMap(Object obj) {
return obj instanceof ListOverMap;
Expand All @@ -83,7 +83,7 @@ protected boolean isMap(Object obj) {
}

private Map<String, String> convertProperties(ListOverMap<PropertyMetadata> overMap) {
Map<String, String> newMap = new LinkedHashMap<String, String>();
Map<String, String> newMap = new CopyOnWriteLinkedHashMap<String, String>();
for (Entry<String, PropertyMetadata> entry : overMap.getMap().entrySet()) {
PropertyMetadata propertyMetadata = entry.getValue();
newMap.put(propertyMetadata.getName(), propertyMetadata.getValue());
Expand All @@ -92,6 +92,18 @@ private Map<String, String> convertProperties(ListOverMap<PropertyMetadata> over
return Collections.synchronizedMap(newMap);
}

protected <K, V> CopyOnWriteLinkedHashMap<K, V> newCopyOnWriteLinkedHashMap(Map<K, V> oldMap) {

/* Teiid Version 8.7 */
if (oldMap instanceof CopyOnWriteLinkedHashMap) {
return (CopyOnWriteLinkedHashMap<K, V>) oldMap;
}

CopyOnWriteLinkedHashMap<K, V> newMap = new CopyOnWriteLinkedHashMap<K, V>();
newMap.putAll(oldMap);
return newMap;
}

/*
* Helper method for serialization to deal with differences between Teiid 7 and 8
*/
Expand All @@ -108,7 +120,7 @@ private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IO
Object serProps = serFields.get("properties", null);
/* Teiid Version 8+ */
if (serProps instanceof Map) {
properties = (Map<String, String>)serProps;
properties = newCopyOnWriteLinkedHashMap((Map<String, String>) serProps);
return;
}

Expand Down Expand Up @@ -155,9 +167,7 @@ public void setHostName(String name) {
@Override
public Properties getProperties() {
Properties props = new Properties();
synchronized (properties) {
props.putAll(this.properties);
}
props.putAll(this.properties);
return props;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.TreeSet;
import java.util.concurrent.CopyOnWriteArrayList;
import org.teiid.adminapi.DataPolicy;
import org.teiid.designer.annotation.Since;
import org.teiid.runtime.client.Messages;


Expand All @@ -50,6 +51,9 @@ public class DataPolicyMetadata implements DataPolicy, Serializable {

private Set<String> hasRowPermissions = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);

@Since("8.7.0")
private boolean grantAll;

@Override
public String getName() {
return name;
Expand Down Expand Up @@ -471,6 +475,17 @@ public void setAnyAuthenticated(boolean anyAuthenticated) {
this.anyAuthenticated = anyAuthenticated;
}

@Override
@Since("8.7.0")
public boolean isGrantAll() {
return this.grantAll;
}

@Since("8.7.0")
public void setGrantAll(boolean grantAll) {
this.grantAll = grantAll;
}

public DataPolicyMetadata clone() {
DataPolicyMetadata clone = new DataPolicyMetadata();
clone.allowCreateTemporaryTables = this.allowCreateTemporaryTables;
Expand All @@ -481,6 +496,7 @@ public DataPolicyMetadata clone() {
clone.languagePermissions = new HashMap<String, DataPolicyMetadata.PermissionMetaData>(this.languagePermissions);
clone.mappedRoleNames = this.mappedRoleNames; //direct reference to preserve updates
clone.name = this.name;
clone.grantAll = this.grantAll;
clone.permissions = new TreeMap<String, PermissionMetaData>(String.CASE_INSENSITIVE_ORDER);
clone.permissions.putAll(this.permissions);
return clone;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.teiid.adminapi.Model;
import org.teiid.core.util.ArgCheck;
import org.teiid.core.util.CopyOnWriteLinkedHashMap;
import org.teiid.designer.annotation.Removed;
import org.teiid.designer.annotation.Since;

Expand Down Expand Up @@ -61,7 +63,7 @@ public String getKey(SourceMappingMetadata entry) {
}
});

protected LinkedHashMap<String, SourceMappingMetadata> sources = new LinkedHashMap<String, SourceMappingMetadata>();
protected Map<String, SourceMappingMetadata> sources = new CopyOnWriteLinkedHashMap<String, SourceMappingMetadata>();
protected String modelType = Type.PHYSICAL.name();
protected String description;
protected String path;
Expand All @@ -81,8 +83,8 @@ public String getKey(SourceMappingMetadata entry) {
@Since("8.0.0")
protected MetadataStatus metadataStatus = MetadataStatus.LOADING;

private LinkedHashMap<String, SourceMappingMetadata> convertSources(ListOverMap<SourceMappingMetadata> overMap) {
LinkedHashMap<String, SourceMappingMetadata> newMap = new LinkedHashMap<String, SourceMappingMetadata>();
private Map<String, SourceMappingMetadata> convertSources(ListOverMap<SourceMappingMetadata> overMap) {
Map<String, SourceMappingMetadata> newMap = new CopyOnWriteLinkedHashMap<String, SourceMappingMetadata>();
for (Entry<String, SourceMappingMetadata> entry : overMap.getMap().entrySet()) {
newMap.put(entry.getKey(), entry.getValue());
}
Expand All @@ -99,7 +101,7 @@ private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IO

Object serSources = serFields.get("sources", null);
if (isLinkedHashMap(serSources)) { /* Teiid Version 8+ */
sources = (LinkedHashMap<String, SourceMappingMetadata>)serSources;
sources = newCopyOnWriteLinkedHashMap((LinkedHashMap<String, SourceMappingMetadata>) serSources);
} else if (isListOverMap(serSources)) { /* Teiid Version 7 */
ListOverMap<SourceMappingMetadata> overMap = (ListOverMap<SourceMappingMetadata>)serSources;
sources = convertSources(overMap);
Expand Down Expand Up @@ -202,7 +204,7 @@ public List<SourceMappingMetadata> getSourceMappings(){
return new ArrayList<SourceMappingMetadata>(this.sources.values());
}

public LinkedHashMap<String, SourceMappingMetadata> getSources() {
public Map<String, SourceMappingMetadata> getSources() {
return sources;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.teiid.adminapi.Model;
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.VDB;
import org.teiid.core.util.CopyOnWriteLinkedHashMap;
import org.teiid.core.util.StringUtil;
import org.teiid.designer.annotation.Removed;
import org.teiid.designer.annotation.Since;
Expand Down Expand Up @@ -457,10 +458,10 @@ public VDBMetaData clone() {
try {
VDBMetaData clone = (VDBMetaData) super.clone();
clone.models = new LinkedHashMap<String, ModelMetaData>(this.models);
synchronized (this.attachments) {
clone.attachments = Collections.synchronizedMap(new LinkedHashMap<Class<?>, Object>(attachments));
}
return clone;
clone.attachments = new CopyOnWriteLinkedHashMap<Class<?>, Object>();
clone.attachments.putAll(attachments);
clone.dataPolicies = new LinkedHashMap<String, DataPolicyMetadata>(dataPolicies);
return clone;
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public interface NonReserved {
String CHAIN = "CHAIN"; //$NON-NLS-1$
@Since ("8.0.0")
String JSONOBJECT = "JSONOBJECT"; //$NON-NLS-1$
@Since ("8.7.0")
String AUTO_INCREMENT = "AUTO_INCREMENT"; //$NON-NLS-1$
}

public interface Reserved {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

package org.teiid.metadata;

import java.util.Collections;
import org.teiid.core.types.DataTypeManagerService;
import org.teiid.core.util.StringUtil;
import org.teiid.designer.annotation.Since;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;


Expand Down Expand Up @@ -53,6 +56,10 @@ public String toString() {
private NullType nullType;
private int position;
private Datatype datatype;
@Since("8.7.0")
private int arrayDimensions;
@Since("8.7.0")
private String nativeType;

public BaseColumn(ITeiidServerVersion teiidVersion) {
this.teiidVersion = teiidVersion;
Expand Down Expand Up @@ -146,14 +153,22 @@ public Datatype getDatatype() {
}

public void setDatatype(Datatype datatype) {
setDatatype(datatype, false);
setDatatype(datatype, false, 0);
}

public void setDatatype(Datatype datatype, boolean copyAttributes) {
setDatatype(datatype, copyAttributes, 0);
}

public void setDatatype(Datatype datatype, boolean copyAttributes, int arrayDimensions) {
this.datatype = datatype;
this.arrayDimensions = arrayDimensions;
if (datatype != null) {
this.datatypeUUID = this.datatype.getUUID();
this.runtimeType = this.datatype.getRuntimeTypeName();
if (arrayDimensions > 0) {
this.runtimeType += StringUtil.join(Collections.nCopies(arrayDimensions, "[]"), ""); //$NON-NLS-1$ //$NON-NLS-2$
}
if (copyAttributes) {
this.radix = this.datatype.getRadix();
this.length = this.datatype.getLength();
Expand All @@ -162,6 +177,27 @@ public void setDatatype(Datatype datatype, boolean copyAttributes) {
this.nullType = this.datatype.getNullType();
}
}
}

/**
* Get the array dimensions.
* @return
*/
public int getArrayDimensions() {
return arrayDimensions;
}


@Since("8.7.0")
public String getNativeType() {
return nativeType;
}

/**
* @param nativeType The nativeType to set.
* @since 4.2
*/
@Since("8.7.0")
public void setNativeType(String nativeType) {
this.nativeType = nativeType;
}
}

0 comments on commit 9fb51ae

Please sign in to comment.