use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class JSONConnectionContextHelper method convertContextLabel.
/**
*
* change the mode of lebel to Context mode
*
* @param label which you want to convert(it is the name of connection normal)
* @return Context mode label
*/
public static String convertContextLabel(String label) {
if (label != null) {
//$NON-NLS-1$ //$NON-NLS-2$
String newLabel = label.replaceAll("[\\.\\-\\ \\(\\)\\[\\]=]", "_");
//$NON-NLS-1$
Pattern pattern = Pattern.compile("^[0-9]+.*$");
Matcher m = pattern.matcher(newLabel);
if (m.matches()) {
//$NON-NLS-1$
newLabel = "_" + newLabel;
}
//
try {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<IRepositoryViewObject> contextObjectList = factory.getAll(ERepositoryObjectType.CONTEXT, true);
int i = 1;
String tmpLabel = newLabel;
while (!isValidContextName(contextObjectList, tmpLabel)) {
tmpLabel = newLabel + i;
i++;
}
return tmpLabel;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
return newLabel;
}
return null;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class ExcleGenerationModeMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
FileExcelConnection fileExcelConn = null;
if (item instanceof ExcelFileConnectionItem) {
ExcelFileConnectionItem exelConnItem = (ExcelFileConnectionItem) item;
if (exelConnItem.getConnection() instanceof FileExcelConnection) {
fileExcelConn = (FileExcelConnection) exelConnItem.getConnection();
}
}
if (fileExcelConn == null) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
boolean isXsls = false;
String filePath = fileExcelConn.getFilePath();
if (filePath.endsWith(".xlsx")) {
isXsls = true;
}
String genMode = fileExcelConn.getGenerationMode();
if (isXsls && genMode == null) {
fileExcelConn.setGenerationMode("USER_MODE");
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} else {
return ExecutionResult.NOTHING_TO_DO;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class FileInputRegexContextVariableMigrationTask method addQuote.
private boolean addQuote(Item item) {
ProcessType processType = getProcessType(item);
if (processType == null) {
return false;
}
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
EList nodes = processType.getNode();
for (Object n : nodes) {
NodeType type = (NodeType) n;
if (type.getComponentName().equals("tFileInputRegex")) {
//$NON-NLS-1$
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (//$NON-NLS-1$ //$NON-NLS-2$
elemType.getName().equals("HEADER") || elemType.getName().equals("FOOTER") || elemType.getName().equals("LIMIT")) {
//$NON-NLS-1$
String oldV = elemType.getValue();
if (oldV == null || oldV.length() == 0) {
if (elemType.getName().equals("LIMIT")) {
//$NON-NLS-1$
//$NON-NLS-1$
oldV = "-1";
} else {
//$NON-NLS-1$
oldV = "0";
}
}
if (!oldV.contains("\"")) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
elemType.setValue("\"" + oldV + "\"");
}
modified = true;
}
}
}
}
return modified;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class FileInputRegexContextVariableMigrationTaskForSave method removeQuote.
private boolean removeQuote(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
EList nodes = processType.getNode();
for (Object n : nodes) {
NodeType type = (NodeType) n;
if (type.getComponentName().equals("tFileInputRegex")) {
//$NON-NLS-1$
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (//$NON-NLS-1$ //$NON-NLS-2$
elemType.getName().equals("HEADER") || elemType.getName().equals("FOOTER") || elemType.getName().equals("LIMIT")) {
//$NON-NLS-1$
String oldV = elemType.getValue();
if (oldV != null && oldV.startsWith("\"") && oldV.endsWith("\"")) {
//$NON-NLS-1$ //$NON-NLS-2$
elemType.setValue(oldV.substring(1, oldV.length() - 1));
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 MigrateOracleJobSettingsParameterMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType != null) {
boolean modified = false;
final ParametersType parameters = processType.getParameters();
if (parameters != null) {
EList elementParameters = parameters.getElementParameter();
for (int i = 0; i < elementParameters.size(); i++) {
ElementParameterType param = (ElementParameterType) elementParameters.get(i);
if (param.getName().equals("DB_TYPE_IMPLICIT_CONTEXT") || param.getName().equals("DB_TYPE")) {
//$NON-NLS-1$ //$NON-NLS-2$
if (ORACLE_INPUT.equals(param.getValue())) {
param.setValue(ORACLE_INPUT + ORACLE_SID);
modified = true;
} else if (ORACLE_OUTPUT.equals(param.getValue())) {
param.setValue(ORACLE_OUTPUT + ORACLE_SID);
modified = true;
}
}
}
}
if (modified) {
try {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
}
return ExecutionResult.NOTHING_TO_DO;
}
Aggregations