use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class AddConnectorNameInConnections method addConnectorName.
/**
* DOC nrousseau Comment method "addConnectorName".
*
* @param item
* @return
*/
private boolean addConnectorName(Item item) throws PersistenceException {
ProcessType processType = getProcessType(item);
if (processType == null) {
return false;
}
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
for (Object o : processType.getConnection()) {
ConnectionType currentConnection = (ConnectionType) o;
if (currentConnection.getConnectorName() == null) {
EConnectionType connectionType = EConnectionType.getTypeFromId(currentConnection.getLineStyle());
currentConnection.setConnectorName(connectionType.getName());
modified = true;
}
}
if (modified) {
factory.save(item, true);
}
return modified;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class AddDdColumnMigrationTask method removeDbColumn.
private void removeDbColumn(Item item) throws PersistenceException {
ProcessType processType = getProcessType(item);
if (processType == null) {
return;
}
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
for (Object o : processType.getNode()) {
NodeType node = (NodeType) o;
for (Object o2 : node.getMetadata()) {
MetadataType metadata = (MetadataType) o2;
for (Object o3 : metadata.getColumn()) {
ColumnType column = (ColumnType) o3;
if (column.getOriginalDbColumnName() != null) {
column.setOriginalDbColumnName(null);
modified = true;
}
}
}
}
if (modified) {
factory.save(item, true);
}
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class QuoteWraptSSHcommandMigrationTask method wrapQuot.
private boolean wrapQuot(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
EList node = processType.getNode();
for (Object n : node) {
NodeType type = (NodeType) n;
if (type.getComponentName().equals("tSSH")) {
//$NON-NLS-1$
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (elemType.getName().equals("COMMANDS")) {
//$NON-NLS-1$
EList elemValue = elemType.getElementValue();
for (Object eVal : elemValue) {
ElementValueType elemVal = (ElementValueType) eVal;
String originV = elemVal.getValue();
//$NON-NLS-1$ //$NON-NLS-2$
elemVal.setValue("\"" + originV + "\"");
modified = true;
}
}
}
}
}
if (modified) {
factory.save(item, true);
}
return modified;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class RemoveSpaceInJobNameMigrationTask method renameJobs.
/**
* Rename jobs if needed, remove spaces and replace them by "_". Note that this migration is only for 1.0 or 1.1 to
* more recent version, after the 1.1 it was not possible to add some spaces.
*
* @throws PersistenceException
*/
private void renameJobs(Item item) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (item.getProperty().getLabel().contains(" ")) {
// if the job contain some spaces //$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
item.getProperty().setLabel(item.getProperty().getLabel().replaceAll(" ", "_"));
factory.save(item, true);
}
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class MysqlOutputDBVersionForBug13250 method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
public ExecutionResult execute(Item item) {
if (item instanceof DatabaseConnectionItem) {
boolean modify = false;
DatabaseConnectionItem mysqlConnItem = (DatabaseConnectionItem) item;
if (mysqlConnItem.getConnection() instanceof DatabaseConnection) {
DatabaseConnection mysqlConnection = (DatabaseConnection) mysqlConnItem.getConnection();
if ("MySQL".equalsIgnoreCase(mysqlConnection.getDatabaseType())) {
if (mysqlConnection.getDbVersionString() == null || "".equals(mysqlConnection.getDbVersionString())) {
mysqlConnection.setDbVersionString("MYSQL_5");
modify = true;
}
}
}
if (modify) {
try {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
Aggregations