use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class AbstractVersionManagementProjectSettingPage method checkAllVerSionLatest.
protected void checkAllVerSionLatest(List<ItemVersionObject> tableList, ItemVersionObject object) {
if (object.getRepositoryNode() != null) {
List<Relation> relations = builder.getItemsJobRelatedTo(object.getRepositoryNode().getId(), object.getItem().getProperty().getVersion(), RelationshipItemBuilder.JOB_RELATION);
for (Relation relation : relations) {
try {
IRepositoryViewObject obj = FACTORY.getLastVersion(relation.getId());
if (obj != null) {
for (ItemVersionObject obj2 : versionObjects) {
if (obj2.getItem() == obj.getProperty().getItem()) {
ItemVersionObject relat = obj2;
if (!tableList.contains(relat)) {
tableList.add(relat);
checkAllVerSionLatest(tableList, relat);
}
break;
}
}
}
} catch (PersistenceException et) {
ExceptionHandler.process(et);
}
}
}
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class AutoConversionTypesEditor method applyChange.
private void applyChange() {
try {
IProject project = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
IFolder prefsSettingFolder = ResourceUtils.getFolder(project, RepositoryConstants.SETTING_DIRECTORY, false);
AutoConvertTypesUtils.save(typeModel.getBeansList(), AutoConvertTypesUtils.getTypeFile());
prefsSettingFolder.refreshLocal(IResource.DEPTH_ONE, null);
} catch (CoreException e) {
ExceptionHandler.process(e);
} catch (PersistenceException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class PaletteSettingPage method getComponentsUsedInProject.
public Set<IComponent> getComponentsUsedInProject(Project project) {
if (componentsUsed != null) {
return componentsUsed;
}
componentsUsed = new HashSet<IComponent>();
IProxyRepositoryFactory repositoryFactory = CoreUIPlugin.getDefault().getProxyRepositoryFactory();
try {
ERepositoryObjectType jobType = ERepositoryObjectType.PROCESS;
if (jobType != null) {
List<IRepositoryViewObject> allProcess = repositoryFactory.getAll(project, jobType, true);
addUsedComponents(componentsUsed, allProcess, ComponentCategory.CATEGORY_4_DI);
}
ERepositoryObjectType jobletType = ERepositoryObjectType.JOBLET;
if (jobletType != null) {
List<IRepositoryViewObject> allJoblet = repositoryFactory.getAll(project, jobletType, true);
addUsedComponents(componentsUsed, allJoblet, ComponentCategory.CATEGORY_4_DI);
}
ERepositoryObjectType routeType = ERepositoryObjectType.PROCESS_ROUTE;
if (routeType != null) {
List<IRepositoryViewObject> allRoutes = repositoryFactory.getAll(project, routeType, true);
addUsedComponents(componentsUsed, allRoutes, ComponentCategory.CATEGORY_4_CAMEL);
}
//$NON-NLS-1$
ERepositoryObjectType mrType = ERepositoryObjectType.valueOf("PROCESS_MR");
if (mrType != null) {
List<IRepositoryViewObject> allMr = repositoryFactory.getAll(project, mrType, true);
addUsedComponents(componentsUsed, allMr, ComponentCategory.CATEGORY_4_MAPREDUCE);
addUsedComponents(componentsUsed, allMr, ComponentCategory.CATEGORY_4_SPARK);
}
//$NON-NLS-1$
ERepositoryObjectType stormType = ERepositoryObjectType.valueOf("PROCESS_STORM");
if (stormType != null) {
List<IRepositoryViewObject> allStorm = repositoryFactory.getAll(project, stormType, true);
addUsedComponents(componentsUsed, allStorm, ComponentCategory.CATEGORY_4_STORM);
addUsedComponents(componentsUsed, allStorm, ComponentCategory.CATEGORY_4_SPARKSTREAMING);
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null) {
ERepositoryObjectType testCaseType = testContainerService.getTestCaseObjectType();
if (testCaseType != null) {
List<IRepositoryViewObject> allTestCase = repositoryFactory.getAll(project, testCaseType, true);
addUsedComponents(componentsUsed, allTestCase, ComponentCategory.CATEGORY_4_SPARK);
addUsedComponents(componentsUsed, allTestCase, ComponentCategory.CATEGORY_4_DI);
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
return componentsUsed;
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class CustomComponentSettingPage method finish.
private void finish(IProgressMonitor... monitorWrap) {
IProgressMonitor monitor = null;
if (monitorWrap != null && monitorWrap.length == 1) {
monitor = monitorWrap[0];
}
final IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
if (PluginChecker.isSVNProviderPluginLoaded() && (!sharedAdded.isEmpty() || !backAdded.isEmpty())) {
RepositoryWorkUnit repositoryWorkUnit = new RepositoryWorkUnit("Update custom components") {
@Override
public void run() throws PersistenceException {
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor subMonitor) throws CoreException {
ISVNProviderService service = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
String projectLabel = pro.getTechnicalLabel();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject eclipseProject = workspace.getRoot().getProject(projectLabel);
String targetRoot = eclipseProject.getLocation().toString() + "/" + ERepositoryObjectType.getFolderName(ERepositoryObjectType.COMPONENTS);
File componentFolder = new File(targetRoot);
URL url = null;
try {
if (!componentFolder.exists()) {
FilesUtils.createFoldersIfNotExists(targetRoot, false);
}
Bundle b = Platform.getBundle(IComponentsFactory.COMPONENTS_LOCATION);
url = FileLocator.toFileURL(FileLocator.find(b, new Path(""), null));
String sourceRoot = url.getFile();
// delete share
for (IComponent component : backAdded.keySet()) {
String componentFullPath = targetRoot + File.separator + component.getName();
if (service.isSVNProject(pro)) {
service.svnEclipseHandlerDelete(eclipseProject, pro, componentFullPath);
if (subMonitor != null) {
subMonitor.worked(10);
}
} else {
File file = new File(componentFullPath);
if (file != null && file.exists()) {
org.talend.utils.io.FilesUtils.deleteFolder(file, true);
}
}
}
if (!backAdded.isEmpty()) {
getCustomComponentSettings().removeAll(backAdded.values());
}
FileFilter ff = new FileFilter() {
@Override
public boolean accept(File pathname) {
if (FilesUtils.isSVNFolder(pathname)) {
return false;
}
return true;
}
};
// share
for (IComponent component : sharedAdded.keySet()) {
String sourcePath = sourceRoot + component.getPathSource() + File.separator + component.getName();
File sourceFile = new File(sourcePath);
String targetPath = targetRoot + File.separatorChar + component.getName();
File targetFile = new File(targetPath);
FilesUtils.copyFolder(sourceFile, targetFile, true, ff, null, true, false);
if (subMonitor != null) {
subMonitor.worked(10);
}
}
} catch (Exception e) {
resetCustomComponentSetting();
ExceptionHandler.process(e);
}
try {
prf.saveProject(pro);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
try {
eclipseProject.refreshLocal(IResource.DEPTH_INFINITE, subMonitor);
} catch (CoreException e1) {
ExceptionHandler.process(e1);
}
}
};
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
// the update the project files need to be done in the workspace runnable to avoid all
// notification
// of changes before the end of the modifications.
workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
} catch (CoreException e) {
throw new PersistenceException(e.getCause());
}
}
};
repositoryWorkUnit.setRefreshRepository(false);
repositoryWorkUnit.setForceTransaction(true);
prf.executeRepositoryWorkUnit(repositoryWorkUnit);
try {
repositoryWorkUnit.throwPersistenceExceptionIfAny();
} catch (PersistenceException e) {
e.printStackTrace();
}
}
if (monitor != null) {
monitor.done();
}
// refresh again after the gui closed .
try {
String projectLabel = pro.getTechnicalLabel();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject eclipseProject = workspace.getRoot().getProject(projectLabel);
eclipseProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException e1) {
ExceptionHandler.process(e1);
}
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class StatusManagerSettingPage method updateItemsVersion.
private void updateItemsVersion() {
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
//$NON-NLS-1$
monitor.beginTask("", getModifiedVersionItems().size() * 100);
Set<ERepositoryObjectType> types = new HashSet<ERepositoryObjectType>();
for (RepositoryObject object : getModifiedVersionItems()) {
// IRepositoryViewObject repositoryObject = object.getRepositoryNode().getObject();
if (object != null && object.getProperty() != null) {
if (object.getStatusCode().equals(object.getProperty().getStatusCode())) {
final Item item = object.getProperty().getItem();
item.getProperty().setOldStatusCode(object.getStatusCode());
// types.add(object.getRepositoryNode().getObjectType());
try {
// }
if (object != null) {
// obj.setVersion(object.getNewVersion());
FACTORY.save(project, object.getProperty());
} else {
// FACTORY.save(project, item.getProperty());
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
monitor.worked(100);
}
// RepositoryManager.refresh(types);
monitor.done();
}
};
// final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(null);
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
try {
dialog.run(false, false, runnable);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
Aggregations