use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class RepositoryPreferenceStore method save.
public void save() throws IOException {
try {
factory.setDocumentationStatus(StatusHelper.parse(docStatusList));
factory.setTechnicalStatus(StatusHelper.parse(techStatusList));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
throw new IOException(e.getMessage());
}
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class ActivateQueryLogging method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
List<String> filterList = Arrays.asList("tELTTeradataMap", "tTeradataConnection", "tTeradataInput", "tTeradataOutput", "tTeradataRow");
IComponentConversion correctBatchModeForDBComponents = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType queryBand = ComponentUtilities.getNodeProperty(node, "QUERY_BAND");
ElementParameterType activateQueryLogging = ComponentUtilities.getNodeProperty(node, "ACTIVATE_QUERY_LOGGING");
if (activateQueryLogging == null) {
ComponentUtilities.addNodeProperty(node, "ACTIVATE_QUERY_LOGGING", "CHECK");
if (queryBand != null) {
boolean queryBandActived = "true".equalsIgnoreCase(queryBand.getValue());
if (queryBandActived) {
ComponentUtilities.getNodeProperty(node, "ACTIVATE_QUERY_LOGGING").setValue("true");
}
}
}
}
};
for (String componentName : filterList) {
IComponentFilter filter = new NameComponentFilter(componentName);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(correctBatchModeForDBComponents));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class AddHashKeyFromInputConnector4tHashOutput method execute.
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
//$NON-NLS-1$
String[] compNames = { "tHashOutput" };
IComponentConversion action = new IComponentConversion() {
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType property = ComponentUtilities.getNodeProperty(node, "HASH_KEY_FROM_INPUT_CONNECTOR");
if (property == null) {
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "HASH_KEY_FROM_INPUT_CONNECTOR", "CHECK");
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "HASH_KEY_FROM_INPUT_CONNECTOR", "true");
}
}
};
for (String name : compNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(action));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class AddConnectionVersionForJobsettingMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType.getParameters() != null) {
EList elementParameter = processType.getParameters().getElementParameter();
String dbTypeImplicit = "";
String dbTypeStatsLog = "";
String dbImplicitVersionRepository = "";
String dbStasLogVersionRepository = "";
for (int i = 0; i < elementParameter.size(); i++) {
final Object object = elementParameter.get(i);
if (object instanceof ElementParameterTypeImpl) {
ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
String name = parameterType.getName();
if ("DB_TYPE_IMPLICIT_CONTEXT".equals(name)) {
//$NON-NLS-N$
dbTypeImplicit = parameterType.getValue();
}
if ("DB_TYPE".equals(name)) {
//$NON-NLS-N$
dbTypeStatsLog = parameterType.getValue();
}
if ("DB_VERSION_IMPLICIT_CONTEXT".equals(name)) {
//$NON-NLS-N$
dbImplicitVersionRepository = parameterType.getValue();
}
if ("DB_VERSION".equals(name)) {
//$NON-NLS-N$
dbStasLogVersionRepository = parameterType.getValue();
}
}
}
boolean implicitSame = sameDB(dbTypeImplicit, dbImplicitVersionRepository);
boolean stasLogSame = sameDB(dbTypeStatsLog, dbStasLogVersionRepository);
if (!implicitSame) {
if (dbTypeImplicit.toUpperCase().contains("MYSQL")) {
//$NON-NLS-N$
//$NON-NLS-N$//$NON-NLS-N$
setParameterValue(elementParameter, "DB_VERSION_IMPLICIT_CONTEXT", "mysql-connector-java-5.1.0-bin.jar");
} else if (dbTypeImplicit.toUpperCase().contains("ORACLE")) {
//$NON-NLS-N$
//$NON-NLS-N$//$NON-NLS-N$
setParameterValue(elementParameter, "DB_VERSION_IMPLICIT_CONTEXT", "ojdbc14-10g.jar");
} else if (dbTypeImplicit.toUpperCase().contains("ACCESS")) {
//$NON-NLS-N$
//$NON-NLS-N$//$NON-NLS-N$
setParameterValue(elementParameter, "DB_VERSION_IMPLICIT_CONTEXT", "ACCESS_2003");
}
}
if (!stasLogSame) {
if (dbTypeStatsLog.toUpperCase().contains("MYSQL")) {
//$NON-NLS-N$
//$NON-NLS-N$//$NON-NLS-N$
setParameterValue(elementParameter, "DB_VERSION", "mysql-connector-java-5.1.0-bin.jar");
} else if (dbTypeStatsLog.toUpperCase().contains("ORACLE")) {
//$NON-NLS-N$
//$NON-NLS-N$//$NON-NLS-N$
setParameterValue(elementParameter, "DB_VERSION", "ojdbc14-10g.jar");
} else if (dbTypeStatsLog.toUpperCase().contains("ACCESS")) {
//$NON-NLS-N$
//$NON-NLS-N$//$NON-NLS-N$
setParameterValue(elementParameter, "DB_VERSION", "ACCESS_2007");
}
}
if (!implicitSame || !stasLogSame) {
try {
FACTORY.save(item, true);
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class RemoveBinFolderMigrationTask method execute.
@Override
public ExecutionResult execute(Project project) {
XmiResourceManager xmiResourceManager = new XmiResourceManager();
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
for (ERepositoryObjectType type : getTypes()) {
IFolder folder = null;
if (type != null && type.hasFolder()) {
try {
IProject fsProject = ResourceUtils.getProject(project.getTechnicalLabel());
if (!fsProject.getFolder(ERepositoryObjectType.getFolderName(type)).exists()) {
continue;
}
folder = ResourceUtils.getFolder(fsProject, ERepositoryObjectType.getFolderName(type), true);
for (IResource current : ResourceUtils.getMembers(folder)) {
if ((current instanceof IFolder) && ((IFolder) current).getName().equals("bin")) {
for (IResource fileCurrent : ResourceUtils.getMembers((IFolder) current)) {
if (fileCurrent instanceof IFile) {
if (xmiResourceManager.isPropertyFile((IFile) fileCurrent)) {
Property property = null;
try {
property = xmiResourceManager.loadProperty(fileCurrent);
} catch (RuntimeException e) {
// property will be null
ExceptionHandler.process(e);
}
if (property != null) {
// restore folder if doesn't exist anymore.
Item propertyItem = property.getItem();
propertyItem.getState().setDeleted(true);
EmfHelper.saveResource(propertyItem.eResource());
String oldPath = propertyItem.getState().getPath();
IPath path = new Path(oldPath);
factory.createParentFoldersRecursively(project, type, path, true);
FolderItem folderItem = factory.getFolderItem(project, type, path);
propertyItem.setParent(folderItem);
String name = fileCurrent.getName().replace(".properties", "");
// take all the files starting by the same name
IFolder typeRootFolder = ResourceUtils.getFolder(fsProject, ERepositoryObjectType.getFolderName(type), true);
for (IResource filesToMove : ResourceUtils.getMembers((IFolder) current)) {
if (filesToMove.getName().startsWith(name)) {
IPath originalPath = filesToMove.getFullPath();
IPath finalPath = typeRootFolder.getFullPath().append(path).append(originalPath.lastSegment());
if (fsProject.getWorkspace().getRoot().getFile(finalPath).exists()) {
// if the file exists in both bin and target directory, delete
// the one from bin.
filesToMove.delete(true, new NullProgressMonitor());
} else {
ResourceUtils.moveResource(filesToMove, finalPath);
}
}
}
}
}
}
}
IResource[] binFolder = ResourceUtils.getMembers((IFolder) current);
if (binFolder.length == 0 || (binFolder.length == 1 && FilesUtils.isSVNFolder(binFolder[0]))) {
try {
((IFolder) current).delete(true, null);
} catch (CoreException e) {
// not catched, not important if can delete or not
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
} catch (CoreException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
// }
return ExecutionResult.SUCCESS_NO_ALERT;
}
Aggregations