use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class RenametStandardizePhoneNumberColumnName method changeCustomerColumn.
private void changeCustomerColumn(Item item) throws PersistenceException {
ProcessType processType = getProcessType(item);
if (processType == null) {
return;
}
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
for (Object o : processType.getNode()) {
NodeType node = (NodeType) o;
if ("tStandardizePhoneNumber".equalsIgnoreCase(node.getComponentName())) {
for (Object o2 : node.getMetadata()) {
MetadataType metadata = (MetadataType) o2;
for (Object o3 : metadata.getColumn()) {
ColumnType column = (ColumnType) o3;
if ("IsPossiblePhoneNumber ".equals(column.getName())) {
column.setName("IsPossiblePhoneNumber");
modified = true;
break;
}
}
}
}
}
if (modified) {
factory.save(item, true);
}
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class SalesforceMultiSchemaMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org .talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
if (item instanceof SalesforceSchemaConnectionItem) {
boolean modify = false;
SalesforceSchemaConnectionItem salesforceItem = (SalesforceSchemaConnectionItem) item;
if (salesforceItem.getConnection() instanceof SalesforceSchemaConnection) {
SalesforceSchemaConnection sfConnection = (SalesforceSchemaConnection) salesforceItem.getConnection();
SalesforceModuleUnit module = ConnectionFactory.eINSTANCE.createSalesforceModuleUnit();
module.setId(ProxyRepositoryFactory.getInstance().getNextId());
String moduleName = sfConnection.getModuleName();
if (moduleName == null || "".equals(moduleName)) {
moduleName = "Default";
}
module.setLabel(moduleName);
module.setModuleName(moduleName);
EList<orgomg.cwm.objectmodel.core.Package> originalPackages = sfConnection.getDataPackage();
for (int i = 0; i < originalPackages.size(); i++) {
MetadataTable table = (MetadataTable) originalPackages.get(i).getOwnedElement().get(0);
if (originalPackages.get(i) instanceof RecordFile) {
table.setLabel(moduleName);
}
module.getTables().add(table);
}
sfConnection.getModules().add(module);
modify = true;
}
if (modify) {
try {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class LoginDialog method logIn.
/**
* DOC smallet Comment method "logIn".
*
* @param project
* @throws Exception
*/
protected boolean logIn(final Project project) {
final ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
ConnectionBean connBean = loginComposite.getConnection();
final boolean needRestartForLocal = loginComposite.needRestartForLocal();
if (connBean == null || project == null || project.getLabel() == null) {
return false;
}
try {
if (!project.getEmfProject().isLocal() && factory.isLocalConnectionProvider()) {
List<IRepositoryFactory> rfList = RepositoryFactoryProvider.getAvailableRepositories();
IRepositoryFactory remoteFactory = null;
for (IRepositoryFactory rf : rfList) {
if (!rf.isLocalConnectionProvider()) {
remoteFactory = rf;
break;
}
}
if (remoteFactory != null) {
factory.setRepositoryFactoryFromProvider(remoteFactory);
factory.getRepositoryContext().setOffline(true);
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// Save last used parameters
PreferenceManipulator prefManipulator = new PreferenceManipulator(CorePlugin.getDefault().getPreferenceStore());
prefManipulator.setLastProject(project.getTechnicalLabel());
saveLastConnBean(connBean);
// check for Talendforge
if (PluginChecker.isExchangeSystemLoaded() && !TalendPropertiesUtil.isHideExchange()) {
IPreferenceStore prefStore = PlatformUI.getPreferenceStore();
boolean checkTisVersion = prefStore.getBoolean(ITalendCorePrefConstants.EXCHANGE_CHECK_TIS_VERSION);
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
if (!checkTisVersion && brandingService.isPoweredbyTalend()) {
int count = prefStore.getInt(TalendForgeDialog.LOGINCOUNT);
if (count < 0) {
count = 1;
}
ExchangeUser exchangeUser = project.getExchangeUser();
boolean isExchangeLogon = exchangeUser.getLogin() != null && !exchangeUser.getLogin().equals("");
boolean isUserPassRight = true;
if (isExchangeLogon) {
IExchangeService service = (IExchangeService) GlobalServiceRegister.getDefault().getService(IExchangeService.class);
if (service.checkUserAndPass(exchangeUser.getUsername(), exchangeUser.getPassword()) != null) {
isUserPassRight = false;
}
}
if (!isExchangeLogon || !isUserPassRight) {
if ((count + 1) % 4 == 0) {
// if (Platform.getOS().equals(Platform.OS_LINUX)) {
// TalendForgeDialog tfDialog = new TalendForgeDialog(this.getShell(), project);
// tfDialog.open();
// } else {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
String userEmail = null;
if (project.getAuthor() != null) {
userEmail = project.getAuthor().getLogin();
}
TalendForgeDialog tfDialog = new TalendForgeDialog(getShell(), userEmail);
tfDialog.setBlockOnOpen(true);
tfDialog.open();
}
});
}
prefStore.setValue(TalendForgeDialog.LOGINCOUNT, count + 1);
}
}
}
try {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
final ICoreTisService service = (ICoreTisService) GlobalServiceRegister.getDefault().getService(ICoreTisService.class);
if (service != null) {
// if in TIS then update the bundle status according to the project type
if (!service.validProject(project, needRestartForLocal)) {
LoginComposite.isRestart = true;
return true;
}
}
// else not in TIS so ignor caus we may not have a licence so we do not know which bundles belong to
// DI, DQ or MDM
}
} catch (PersistenceException e) {
e.printStackTrace();
loginComposite.populateProjectList();
MessageDialog.openError(getShell(), getShell().getText(), e.getMessage());
return false;
}
final Shell shell = this.getShell();
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// monitorWrap = new EventLoopProgressMonitor(monitor);
try {
factory.logOnProject(project, monitor);
} catch (LoginException e) {
throw new InvocationTargetException(e);
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
} catch (OperationCanceledException e) {
throw new InterruptedException(e.getLocalizedMessage());
}
monitor.done();
}
};
try {
dialog.run(true, true, runnable);
} catch (final InvocationTargetException e) {
if (PluginChecker.isSVNProviderPluginLoaded()) {
loginComposite.populateProjectList();
if (e.getTargetException() instanceof OperationCancelException) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.getString("LoginDialog.logonCanceled"), e.getTargetException().getLocalizedMessage());
}
});
} else {
MessageBoxExceptionHandler.process(e.getTargetException(), getShell());
}
} else {
loginComposite.populateTOSProjectList();
MessageBoxExceptionHandler.process(e.getTargetException(), getShell());
}
return false;
} catch (InterruptedException e) {
if (PluginChecker.isSVNProviderPluginLoaded()) {
loginComposite.populateProjectList();
} else {
loginComposite.populateTOSProjectList();
}
return false;
}
return true;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class LoginHelper method getProjects.
public Project[] getProjects(ConnectionBean connBean, ErrorManager errorManager) {
if (connBean == null) {
return null;
}
Project[] projects = null;
if (connBean != null) {
String user2 = connBean.getUser();
String repositoryId2 = connBean.getRepositoryId();
String workSpace = connBean.getWorkSpace();
String name = connBean.getName();
if (//$NON-NLS-1$ //$NON-NLS-2$
user2 != null && !"".equals(user2) && repositoryId2 != null && !"".equals(repositoryId2) && workSpace != null && !"".equals(workSpace) && name != null && !"".equals(name)) {
//$NON-NLS-1$ //$NON-NLS-2$
boolean valid = false;
if (isRemoteConnection(connBean)) {
String url = connBean.getDynamicFields().get(RepositoryConstants.REPOSITORY_URL);
//$NON-NLS-1$
valid = url != null && !"".equals(url);
} else {
valid = Pattern.matches(RepositoryConstants.MAIL_PATTERN, user2);
}
connBean.setComplete(valid);
}
}
ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
repositoryFactory.setRepositoryFactoryFromProvider(RepositoryFactoryProvider.getRepositoriyById(connBean.getRepositoryId()));
if (!connBean.isComplete()) {
return projects;
}
boolean initialized = false;
//$NON-NLS-1$
final String newLine = ":\n";
try {
try {
repositoryFactory.checkAvailability();
} catch (WarningException e) {
String warnings = e.getMessage();
if (warnings != null && !warnings.equals(lastWarnings)) {
lastWarnings = warnings;
if (errorManager != null) {
errorManager.setWarnMessage(warnings);
} else {
final Shell shell = new Shell(DisplayUtils.getDisplay(), SWT.ON_TOP | SWT.TOP);
//$NON-NLS-1$
MessageDialog.openWarning(shell, Messages.getString("LoginComposite.warningTitle"), warnings);
}
}
}
OverTimePopupDialogTask<Boolean> overTimePopupDialogTask = new OverTimePopupDialogTask<Boolean>() {
@Override
public Boolean run() throws Throwable {
ProxyRepositoryFactory.getInstance().initialize();
return null;
}
};
overTimePopupDialogTask.setNeedWaitingProgressJob(false);
overTimePopupDialogTask.runTask();
initialized = true;
} catch (Throwable e) {
projects = new Project[0];
if (errorManager != null) {
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
} else {
final Shell shell = new Shell(DisplayUtils.getDisplay(), SWT.ON_TOP | SWT.TOP);
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
shell, //$NON-NLS-1$
Messages.getString("LoginComposite.warningTitle"), //$NON-NLS-1$
Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
}
}
if (initialized) {
try {
OverTimePopupDialogTask<Project[]> overTimePopupDialogTask = new OverTimePopupDialogTask<Project[]>() {
@Override
public Project[] run() throws Throwable {
return ProxyRepositoryFactory.getInstance().readProject();
}
};
overTimePopupDialogTask.setNeedWaitingProgressJob(false);
projects = overTimePopupDialogTask.runTask();
Arrays.sort(projects, new Comparator<Project>() {
@Override
public int compare(Project p1, Project p2) {
return p1.getLabel().compareTo(p2.getLabel());
}
});
} catch (PersistenceException e) {
projects = new Project[0];
if (errorManager != null) {
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
} else {
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
getUsableShell(), //$NON-NLS-1$
Messages.getString("LoginComposite.errorTitle"), //$NON-NLS-1$
Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
}
} catch (BusinessException e) {
projects = new Project[0];
if (errorManager != null) {
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
} else {
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
getUsableShell(), //$NON-NLS-1$
Messages.getString("LoginComposite.errorTitle"), //$NON-NLS-1$
Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
}
} catch (Throwable e) {
projects = new Project[0];
if (errorManager != null) {
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
} else {
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
getUsableShell(), //$NON-NLS-1$
Messages.getString("LoginComposite.errorTitle"), //$NON-NLS-1$
Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
}
}
}
return projects;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class LoginHelper method logIn.
public boolean logIn(ConnectionBean connBean, final Project project) {
final ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
final boolean needRestartForLocal = needRestartForLocal(connBean);
if (connBean == null || project == null || project.getLabel() == null) {
return false;
}
try {
if (!project.getEmfProject().isLocal() && factory.isLocalConnectionProvider()) {
List<IRepositoryFactory> rfList = RepositoryFactoryProvider.getAvailableRepositories();
IRepositoryFactory remoteFactory = null;
for (IRepositoryFactory rf : rfList) {
if (!rf.isLocalConnectionProvider()) {
remoteFactory = rf;
break;
}
}
if (remoteFactory != null) {
factory.setRepositoryFactoryFromProvider(remoteFactory);
factory.getRepositoryContext().setOffline(true);
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// Save last used parameters
prefManipulator.setLastProject(project.getTechnicalLabel());
saveLastConnBean(connBean);
try {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
final ICoreTisService service = (ICoreTisService) GlobalServiceRegister.getDefault().getService(ICoreTisService.class);
if (service != null) {
// if in TIS then update the bundle status according to the project type
if (!service.validProject(project, needRestartForLocal)) {
isRestart = true;
return true;
}
}
// else not in TIS so ignor caus we may not have a licence so we do not know which bundles belong to
// DI, DQ or MDM
}
} catch (PersistenceException e) {
CommonExceptionHandler.process(e);
MessageDialog.openError(getUsableShell(), getUsableShell().getText(), e.getMessage());
return false;
}
final Shell shell = getUsableShell();
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// monitorWrap = new EventLoopProgressMonitor(monitor);
try {
factory.logOnProject(project, monitor);
} catch (LoginException e) {
throw new InvocationTargetException(e);
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
} catch (OperationCanceledException e) {
throw new InterruptedException(e.getLocalizedMessage());
}
monitor.done();
}
};
try {
dialog.run(true, true, runnable);
} catch (final InvocationTargetException e) {
// if (PluginChecker.isSVNProviderPluginLoaded()) {
if (e.getTargetException() instanceof OperationCancelException) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.getString("LoginDialog.logonCanceled"), e.getTargetException().getLocalizedMessage());
}
});
} else {
MessageBoxExceptionHandler.process(e.getTargetException(), getUsableShell());
}
factory.getRepositoryContext().setProject(null);
// }
return false;
} catch (InterruptedException e) {
// }
return false;
}
return true;
}
Aggregations