use of org.talend.repository.nosql.exceptions.NoSQLServerException in project tbd-studio-se by Talend.
the class CassandraOldVersionMetadataHandler method getKeySpaces.
private List<Object> getKeySpaces(NoSQLConnection connection) throws NoSQLServerException {
List<Object> keySpaces = new ArrayList<Object>();
try {
List<Object> ksDefs = (List<Object>) NoSQLReflection.invokeMethod(getOrCreateCluster(connection), // $NON-NLS-1$
"describeKeyspaces");
keySpaces.addAll(ksDefs);
} catch (NoSQLReflectionException e) {
throw new NoSQLServerException(e);
}
return keySpaces;
}
use of org.talend.repository.nosql.exceptions.NoSQLServerException in project tbd-studio-se by Talend.
the class CassandraOldVersionMetadataHandler method getKeySpaceNames.
@Override
public List<String> getKeySpaceNames(NoSQLConnection connection) throws NoSQLServerException {
List<String> ksNames = new ArrayList<String>();
try {
List<Object> keySpaces = getKeySpaces(connection);
for (Object keySpace : keySpaces) {
// $NON-NLS-1$
String ksName = (String) NoSQLReflection.invokeMethod(keySpace, "getName");
ksNames.add(ksName);
}
} catch (Exception e) {
throw new NoSQLServerException(e);
}
return ksNames;
}
use of org.talend.repository.nosql.exceptions.NoSQLServerException in project tbd-studio-se by Talend.
the class CassandraMetadataHandler method getSuperColumnFamilyNames.
@Override
public Set<String> getSuperColumnFamilyNames(NoSQLConnection connection, String ksName) throws NoSQLServerException {
Set<String> scfNames = new HashSet<String>();
Object session = null;
ClassLoader classLoader = NoSQLClassLoaderFactory.getClassLoader(connection);
try {
if (ksName == null) {
List<String> ksNames = getKeySpaceNames(connection);
for (String name : ksNames) {
scfNames.addAll(getColumnFamilyNames(connection, name));
}
} else {
initCluster(connection);
// $NON-NLS-1$ //$NON-NLS-2$
session = NoSQLReflection.invokeMethod(cluster, "connect", new Object[] { "system" });
Object toPrepare = // $NON-NLS-1$
NoSQLReflection.newInstance(// $NON-NLS-1$
"com.datastax.driver.core.SimpleStatement", new Object[] { "select * from schema_columnfamilies where keyspace_name =?" }, // $NON-NLS-1$
classLoader);
Object prepared = // $NON-NLS-1$
NoSQLReflection.invokeMethod(// $NON-NLS-1$
session, // $NON-NLS-1$
"prepare", // $NON-NLS-1$
new Object[] { toPrepare }, // $NON-NLS-1$
Class.forName("com.datastax.driver.core.RegularStatement", false, classLoader));
Object statement = // $NON-NLS-1$
NoSQLReflection.invokeMethod(// $NON-NLS-1$
prepared, // $NON-NLS-1$
"bind", // $NON-NLS-1$
new Object[] { new Object[] { ksName } }, Object[].class);
// Statement
Object resultSet = // $NON-NLS-1$
NoSQLReflection.invokeMethod(// $NON-NLS-1$
session, // $NON-NLS-1$
"execute", // $NON-NLS-1$
new Object[] { statement }, // $NON-NLS-1$
Class.forName("com.datastax.driver.core.Statement", false, classLoader));
// $NON-NLS-1$
Iterator iterator = (Iterator) NoSQLReflection.invokeMethod(resultSet, "iterator");
while (iterator.hasNext()) {
Object row = iterator.next();
// String type = row.getString("type");s
// $NON-NLS-1$ //$NON-NLS-2$
String type = (String) NoSQLReflection.invokeMethod(row, "getString", new Object[] { "type" });
String scfName = (String) NoSQLReflection.invokeMethod(row, "getString", // $NON-NLS-1$ //$NON-NLS-2$
new Object[] { "columnfamily_name" });
if (type.equalsIgnoreCase("super")) {
// $NON-NLS-1$
scfNames.add(scfName);
}
}
}
} catch (Exception e) {
throw new NoSQLServerException(e);
} finally {
try {
if (session != null) {
// $NON-NLS-1$
NoSQLReflection.invokeMethod(session, "close");
closeConnections();
}
} catch (NoSQLReflectionException e) {
// only for debug
e.printStackTrace();
}
}
return scfNames;
}
use of org.talend.repository.nosql.exceptions.NoSQLServerException in project tbd-studio-se by Talend.
the class CassandraMetadataHandler method getColumnTalendType.
@Override
public String getColumnTalendType(Object column) throws NoSQLServerException {
String talendType = null;
try {
String dbType = getColumnDbType(column);
MappingTypeRetriever mappingTypeRetriever = MetadataTalendType.getMappingTypeRetriever(dbmsId);
talendType = mappingTypeRetriever.getDefaultSelectedTalendType(dbType);
if (talendType == null) {
talendType = JavaTypesManager.STRING.getId();
}
} catch (Exception e) {
throw new NoSQLServerException(e);
}
return talendType;
}
use of org.talend.repository.nosql.exceptions.NoSQLServerException in project tbd-studio-se by Talend.
the class CassandraMetadataHandler method getKeySpaces.
private List<Object> getKeySpaces(NoSQLConnection connection) throws NoSQLServerException {
List<Object> keySpaces = new ArrayList<Object>();
initCluster(connection);
try {
// $NON-NLS-1$
Object metadata = NoSQLReflection.invokeMethod(cluster, "getMetadata");
// $NON-NLS-1$
keySpaces.addAll((List) NoSQLReflection.invokeMethod(metadata, "getKeyspaces"));
} catch (NoSQLReflectionException e) {
throw new NoSQLServerException(e);
}
return keySpaces;
}
Aggregations