use of org.talend.repository.nosql.metadata.IMetadataProvider in project tbd-studio-se by Talend.
the class Neo4jSchemaForm method generateSchema.
private void generateSchema() throws NoSQLExtractSchemaException {
if (metadataTable == null) {
return;
}
String cypher = metadataTable.getAdditionalProperties().get(INeo4jConstants.CYPHER);
if (cypher == null) {
return;
}
IMetadataProvider metadataProvider = NoSQLRepositoryFactory.getInstance().getMetadataProvider(getConnection().getDbType());
if (metadataProvider == null) {
return;
}
List<MetadataColumn> columns = metadataProvider.extractColumns(getConnection(), cypher);
metadataTable.getColumns().clear();
metadataTable.getColumns().addAll(columns);
}
use of org.talend.repository.nosql.metadata.IMetadataProvider in project tbd-studio-se by Talend.
the class CreateNoSQLSchemaAction method checkNoSQLConnection.
private boolean checkNoSQLConnection(final NoSQLConnection connection) {
boolean checkedResult = false;
try {
IMetadataProvider metadataProvider = NoSQLRepositoryFactory.getInstance().getMetadataProvider(connection.getDbType());
if (metadataProvider != null) {
checkedResult = metadataProvider.checkConnection(connection);
}
} catch (Exception ex) {
checkedResult = false;
ExceptionHandler.process(ex);
}
if (!checkedResult) {
// $NON-NLS-1$
String mainMsg = Messages.getString("CreateNoSQLSchemaAction.connectionFailure.mainMsg");
// $NON-NLS-1$
String detailMsg = Messages.getString("CreateNoSQLSchemaAction.connectionFailure.detailMsg");
new ErrorDialogWidthDetailArea(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), RepositoryNoSQLPlugin.PLUGIN_ID, mainMsg, detailMsg);
}
return checkedResult;
}
use of org.talend.repository.nosql.metadata.IMetadataProvider in project tbd-studio-se by Talend.
the class Neo4jMetadataProviderTest method testLocalRetrieveSchema.
@Test
public void testLocalRetrieveSchema() throws Exception {
EMap<String, String> attributes = localConnection.getAttributes();
// $NON-NLS-1$
attributes.put(INeo4jAttributes.REMOTE_SERVER, "false");
attributes.put(INeo4jAttributes.DATABASE_PATH, tmpFolder.getCanonicalPath());
attributes.put(INeo4jAttributes.DB_VERSION, INeo4jConstants.NEO4J_3_2_X);
localConnection.setDbType("NEO4J");
ExecutorService threadExecutor = null;
try {
threadExecutor = Executors.newSingleThreadExecutor();
Future future = threadExecutor.submit(new Runnable() {
public void run() {
try {
Neo4jConnectionUtil.checkConnection(localConnection);
List<MetadataColumn> metadataColumns = new ArrayList<MetadataColumn>();
String cypher = "create (n:Test {first_name : 'Peppa', last_name : 'Pig'})\r\nreturn n;";
IMetadataProvider metadataProvider = NoSQLRepositoryFactory.getInstance().getMetadataProvider(localConnection.getDbType());
metadataColumns = metadataProvider.extractColumns(localConnection, cypher);
String lastName = metadataColumns.get(0).getName();
assertEquals("last_name", lastName);
String firstName = metadataColumns.get(1).getName();
assertEquals("first_name", firstName);
} catch (Exception e) {
fail(e.getMessage());
}
}
});
while (true) {
if (future.get() == null) {
break;
}
Thread.sleep(1000);
}
} catch (Exception exception) {
fail(exception.getMessage());
} finally {
if (threadExecutor != null) {
threadExecutor.shutdown();
threadExecutor = null;
}
}
}
use of org.talend.repository.nosql.metadata.IMetadataProvider in project tbd-studio-se by Talend.
the class CreateNoSQLSchemaAction method checkNoSQLConnectionInIndependentThread.
protected boolean checkNoSQLConnectionInIndependentThread(final NoSQLConnection connection) {
final AtomicBoolean checkedResult = new AtomicBoolean(true);
IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// $NON-NLS-1$
monitor.beginTask(Messages.getString("CreateNoSQLSchemaAction.checkConnection"), IProgressMonitor.UNKNOWN);
Display display = PlatformUI.getWorkbench().getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
try {
IMetadataProvider metadataProvider = NoSQLRepositoryFactory.getInstance().getMetadataProvider(connection.getDbType());
if (metadataProvider != null) {
checkedResult.set(metadataProvider.checkConnection(connection));
}
} catch (Exception e) {
checkedResult.set(false);
ExceptionHandler.process(e);
} finally {
monitor.done();
}
}
});
if (!checkedResult.get()) {
display.syncExec(new Runnable() {
@Override
public void run() {
// $NON-NLS-1$
String mainMsg = Messages.getString("CreateNoSQLSchemaAction.connectionFailure.mainMsg");
// $NON-NLS-1$
String detailMsg = Messages.getString("CreateNoSQLSchemaAction.connectionFailure.detailMsg");
new ErrorDialogWidthDetailArea(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), RepositoryNoSQLPlugin.PLUGIN_ID, mainMsg, detailMsg);
return;
}
});
}
}
};
ProgressMonitorDialog dialog = new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
try {
dialog.run(true, true, runnableWithProgress);
} catch (Exception e) {
checkedResult.set(false);
ExceptionHandler.process(e);
}
return checkedResult.get();
}
use of org.talend.repository.nosql.metadata.IMetadataProvider in project tbd-studio-se by Talend.
the class AbstractNoSQLSchemaForm method pressGuessSchemaButton.
protected void pressGuessSchemaButton() {
boolean doit = true;
if (tableEditorView.getMetadataEditor().getBeanCount() > 0) {
doit = // $NON-NLS-1$
MessageDialog.openConfirm(// $NON-NLS-1$
getShell(), // $NON-NLS-1$
Messages.getString("AbstractNoSQLSchemaForm.DialogUpdateTitle"), // $NON-NLS-1$
Messages.getString("AbstractNoSQLSchemaForm.DialogUpdateMsg"));
}
if (doit) {
List<MetadataColumn> metadataColumns = new ArrayList<MetadataColumn>();
IMetadataProvider metadataProvider = NoSQLRepositoryFactory.getInstance().getMetadataProvider(getConnection().getDbType());
if (metadataProvider != null) {
String tableName = tableCombo.getText();
try {
metadataColumns = metadataProvider.extractColumns(getConnection(), tableName);
} catch (NoSQLExtractSchemaException e) {
ExceptionHandler.process(e);
}
}
tableEditorView.getMetadataEditor().removeAll();
tableEditorView.getMetadataEditor().addAll(metadataColumns);
}
updateGuessSchemaButton();
changeTableNavigatorStatus(checkFieldsValue());
}
Aggregations