use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class MetadataColumnComparator method saveEMFQuery.
/**
* method "saveQuery" use save inputed Query to EMF's xml File.
*
* @param repositoryNode current RepositoryNode
* @param query need to save Query
*/
private void saveEMFQuery(String id, Query query, String oldQuery) {
DatabaseConnectionItem item = getEMFItem(id);
if (query != null) {
Connection connection = item.getConnection();
QueriesConnection queriesConnection = connection.getQueries();
if (queriesConnection == null) {
queriesConnection = ConnectionFactory.eINSTANCE.createQueriesConnection();
queriesConnection.setConnection(connection);
connection.setQueries(queriesConnection);
}
boolean isModify = false;
List<Query> queries = queriesConnection.getQuery();
for (Query query2 : queries) {
if (oldQuery != null && (query2.getLabel().equals(oldQuery)) || query2.getLabel().equals(query.getLabel())) {
// reset new label, if changed
query2.setLabel(query.getLabel());
query2.setComment(query.getComment());
query2.setValue(query.getValue());
// add by hywang
query2.setContextMode(query.isContextMode());
// assign id to old query without id
assignQueryId(query2, queriesConnection);
isModify = true;
}
}
if (!isModify) {
// assign id to new query
assignQueryId(query, queriesConnection);
queriesConnection.getQuery().add(query);
}
}
deleteNouseTables(item.getConnection());
saveMetaData(item);
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tesb-studio-se by Talend.
the class ESBService method copyJobForService.
private Item copyJobForService(final Item item, final IPath path, final String newName) {
try {
final Item newItem = ProxyRepositoryFactory.getInstance().copy(item, path, newName);
if (newItem instanceof ConnectionItem) {
Connection connection = ((ConnectionItem) newItem).getConnection();
if (connection != null) {
connection.setLabel(newName);
connection.setName(newName);
connection.getSupplierDependency().clear();
}
}
ProxyRepositoryFactory.getInstance().save(newItem);
return newItem;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
} catch (BusinessException e) {
ExceptionHandler.process(e);
}
return null;
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class JSONConnectionContextHelper method setPropertiesForContextMode.
public static void setPropertiesForContextMode(ConnectionItem connectionItem, ContextItem contextItem, Set<IConnParamName> paramSet, Map<String, String> map) {
if (connectionItem == null || contextItem == null) {
return;
}
final String label = contextItem.getProperty().getLabel();
Connection conn = connectionItem.getConnection();
if (conn instanceof JSONFileConnection) {
setJSONFilePropertiesForContextMode(label, (JSONFileConnection) conn);
}
// set connection for context mode
connectionItem.getConnection().setContextMode(true);
connectionItem.getConnection().setContextId(contextItem.getProperty().getId());
connectionItem.getConnection().setContextName(contextItem.getDefaultContext());
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class JSONConnectionContextHelper method revertPropertiesForContextMode.
public static void revertPropertiesForContextMode(ConnectionItem connItem, ContextType contextType) {
if (connItem == null || contextType == null) {
return;
}
Connection conn = connItem.getConnection();
if (conn instanceof JSONFileConnection) {
revertJSONFilePropertiesForContextMode((JSONFileConnection) conn, contextType);
}
// set connection for context mode
conn.setContextMode(false);
conn.setContextId(EMPTY);
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class FillParametersForDatabaseConnectionMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
if (item instanceof DatabaseConnectionItem) {
DatabaseConnectionItem dbItem = (DatabaseConnectionItem) item;
Connection connection = dbItem.getConnection();
DatabaseConnection dbconn = (DatabaseConnection) connection;
EList<orgomg.cwm.objectmodel.core.Package> pkgs = dbconn.getDataPackage();
// get all tdtables and set sqldatatype
fillParametersForColumns(pkgs);
dbconn.setName(dbItem.getProperty().getLabel());
try {
factory.save(dbItem, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
Aggregations