use of org.talend.core.model.properties.ExcelFileConnectionItem 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;
}
}
Aggregations