use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class JSONConnectionContextHelper method getRepositoryContext.
private static ISelection getRepositoryContext(final String contextNameOrId, boolean isId) {
if (contextNameOrId == null || "".equals(contextNameOrId.trim())) {
//$NON-NLS-1$
return null;
}
if (isId && RepositoryNode.NO_ID.equals(contextNameOrId.trim())) {
return null;
}
IRepositoryViewObject contextObject = null;
try {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<IRepositoryViewObject> contextObjectList = factory.getAll(ERepositoryObjectType.CONTEXT, true);
if (contextObjectList != null) {
for (IRepositoryViewObject object : contextObjectList) {
Item item = object.getProperty().getItem();
if (item != null && item instanceof ContextItem) {
String itemNameOrId = null;
if (isId) {
itemNameOrId = item.getProperty().getId();
} else {
itemNameOrId = item.getProperty().getLabel();
}
if (contextNameOrId.equals(itemNameOrId)) {
contextObject = object;
break;
}
}
}
}
} catch (PersistenceException e) {
//
}
StructuredSelection selection = new StructuredSelection();
if (contextObject != null) {
RepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(contextObject);
if (repositoryNode != null) {
selection = new StructuredSelection(repositoryNode);
}
}
return selection;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class RenametForCurrentIterationMigrationTask method convertItem.
private boolean convertItem(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
ECodeLanguage language = getProject().getLanguage();
EList node = processType.getNode();
for (Object n : node) {
NodeType type = (NodeType) n;
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (!elemType.getField().equals("CHECK")) {
//$NON-NLS-1$
if (language.equals(ECodeLanguage.JAVA)) {
if (elemType.getValue() != null && elemType.getValue().contains(TFOR) && elemType.getValue().contains(CURRENT_ITER)) {
elemType.setValue(elemType.getValue().replaceAll(CURRENT_ITER, CURRENT_VALUE));
}
}
if (elemType.getValue() != null && elemType.getValue().contains(TFOR)) {
elemType.setValue(elemType.getValue().replaceAll(TFOR, TLOOP));
modified = true;
}
// for table
EList elemValue = elemType.getElementValue();
for (Object elemV : elemValue) {
ElementValueType elemVal = (ElementValueType) elemV;
if (language.equals(ECodeLanguage.JAVA)) {
if (elemVal.getValue() != null && elemVal.getValue().contains(TFOR) && elemVal.getValue().contains(CURRENT_ITER)) {
elemVal.setValue(elemVal.getValue().replaceAll(CURRENT_ITER, CURRENT_VALUE));
}
}
if (elemVal.getValue() != null && elemVal.getValue().contains(TFOR)) {
elemVal.setValue(elemVal.getValue().replaceAll(TFOR, TLOOP));
modified = true;
}
}
}
}
}
if (modified) {
factory.save(item, true);
}
return modified;
}
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;
}
Aggregations