use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class MainComposite method getStatusMap.
protected Map<String, String> getStatusMap() {
statusHelper = new StatusHelper(CoreRuntimePlugin.getInstance().getProxyRepositoryFactory());
Map<String, String> statusMap = new HashMap();
try {
if (statusHelper != null) {
List<org.talend.core.model.properties.Status> statusList = statusHelper.getStatusList(repositoryObject.getProperty());
if (statusList != null) {
for (org.talend.core.model.properties.Status s : statusList) {
statusMap.put(s.getCode(), s.getLabel());
}
}
}
} catch (PersistenceException e) {
CommonExceptionHandler.process(e);
}
return statusMap;
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class FTPWizard method performFinish.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.wizard.IWizard#performFinish()
*/
@Override
public boolean performFinish() {
final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
if (creation) {
String nextId = factory.getNextId();
connectionProperty.setId(nextId);
factory.create(connectionItem, propertiesWizardPage.getDestinationPath());
} else {
RepositoryUpdateManager.updateFileConnection(connectionItem);
boolean isModified = propertiesWizardPage.isNameModifiedByUser();
if (isModified) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
IDesignerCoreService service = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
if (service != null) {
service.refreshComponentView(connectionItem);
}
}
}
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRunnable operation = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
try {
factory.save(connectionItem);
closeLockStrategy();
} catch (PersistenceException e) {
throw new CoreException(new Status(IStatus.ERROR, "", "", e));
}
}
};
workspace.run(operation, null);
}
} catch (Exception e) {
String detailError = e.toString();
new //$NON-NLS-1$
ErrorDialogWidthDetailArea(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
PID, //$NON-NLS-1$
"", detailError);
return false;
}
return true;
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class GenericConnPropertiesWizard method performFinish.
@Override
public boolean performFinish() {
boolean done = super.performFinish();
if (done) {
Property property = object.getProperty();
GenericConnectionItem gcItem = (GenericConnectionItem) property.getItem();
boolean itemChanged = GenericConnectionUtil.synNamePropertyWithItem(gcItem);
if (itemChanged) {
try {
ProxyRepositoryFactory.getInstance().save(gcItem);
} catch (PersistenceException e) {
done = false;
ExceptionHandler.process(e);
}
}
}
return done;
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class AddContextCommentValueMigrationTask method execute.
@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
EList<ContextType> contexts = null;
if (item instanceof ProcessItem) {
// process, process_mr, process_storm, route, routelet.
ProcessItem processItem = (ProcessItem) item;
contexts = processItem.getProcess().getContext();
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobletItem = (JobletProcessItem) item;
contexts = jobletItem.getJobletProcess().getContext();
} else if (item instanceof ContextItem) {
ContextItem contextItem = (ContextItem) item;
contexts = contextItem.getContext();
}
// 2 kinds of situation should be excluded before doing migration to the old context:
// 1.has null, 2.all same comment values;
// 1 is from 6.1.0 release and 5.6.2 patched TPS-1109, all null comment value will set to "".
// for repository context in job, won't change anything because the repository context has been fixed
// the update action will execute when opening job.
boolean hasNull = false, isSame = true;
if (contexts != null && contexts.size() > 1) {
List<String> firstComments = new ArrayList<String>();
for (int x = 0; x < contexts.size(); x++) {
List<ContextParameterType> contextParams = contexts.get(x).getContextParameter();
for (int y = 0; y < contextParams.size(); y++) {
ContextParameterType param = contextParams.get(y);
boolean isBuiltin = param.getRepositoryContextId() == null;
String comment = param.getComment();
if (comment == null) {
if (isBuiltin) {
//$NON-NLS-1$
param.setComment("");
hasNull = true;
}
continue;
}
// comments to show in old item before 5.6.1 are always in the first group.
if (x == 0) {
if (!isBuiltin) {
//$NON-NLS-1$
firstComments.add("NOT_BUILTIN");
} else {
firstComments.add(comment);
}
continue;
}
if (isBuiltin && !comment.equals(firstComments.get(y))) {
isSame = false;
}
}
}
try {
if (hasNull) {
ProxyRepositoryFactory.getInstance().save(item, true);
return ExecutionResult.SUCCESS_NO_ALERT;
}
if (!isSame) {
for (int x = 1; x < contexts.size(); x++) {
List<ContextParameterType> contextParams = contexts.get(x).getContextParameter();
for (int y = 0; y < contextParams.size(); y++) {
ContextParameterType param = contextParams.get(y);
String comment = param.getComment();
if (param.getRepositoryContextId() == null && !firstComments.get(y).equals(comment)) {
if (!firstComments.get(y).equals("NOT_BUILTIN")) {
//$NON-NLS-1$
param.setComment(firstComments.get(y));
}
}
}
}
ProxyRepositoryFactory.getInstance().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 AddCopyBookXc2jFileMigrationTask method getReferenceXc2jFile.
public static IFile getReferenceXc2jFile(ConnectionItem connectionItem) {
IFile x2cjFile = null;
try {
IProject currentProject = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
String label = connectionItem.getProperty().getLabel();
String version = connectionItem.getProperty().getVersion();
String xc2jFileName = label + "_" + version + ".xc2j";
String folderPath = "";
String folder = "";
if (connectionItem.getState() != null) {
folderPath = connectionItem.getState().getPath();
}
if (!folderPath.equals("")) {
folder = "/" + folderPath;
}
x2cjFile = currentProject.getFolder("metadata/fileEBCDIC" + folder).getFile(xc2jFileName);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
return x2cjFile;
}
Aggregations