use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class SalesforceTimeoutMigrationTask 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();
if (sfConnection.getTimeOut() == null || "".equals(sfConnection.getTimeOut())) {
sfConnection.setTimeOut("60000");
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 ReplaceRunBeforeAfterWithThenRunMigrationTask method replaceConnections.
/**
* Replace run before and after connection with then run.
*
* yzhang Comment method "replaceConnections".
*
* @param processType
*
* @throws PersistenceException
*/
public void replaceConnections(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
Map<String, List> runAfterMap = new TreeMap<String, List>();
if (isMultiJob(processType.getConnection())) {
// TODO: if it's a job with muliti sub jobs an error mark need to be added in repository.
}
for (Object o : processType.getConnection()) {
ConnectionType currentConnection = (ConnectionType) o;
if (currentConnection.getLabel().equals(Messages.getString("ReplaceRunBeforeAfterWithThenRunMigrationTask.RunAfter"))) {
//$NON-NLS-1$
//$NON-NLS-1$
currentConnection.setLabel(Messages.getString("ReplaceRunBeforeAfterWithThenRunMigrationTask.ThenRun"));
currentConnection.setLineStyle(EConnectionType.ON_SUBJOB_OK.getId());
String sourceKey = currentConnection.getSource();
if (!runAfterMap.containsKey(sourceKey)) {
List<ConnectionType> connectionList = new ArrayList<ConnectionType>();
connectionList.add(currentConnection);
runAfterMap.put(sourceKey, connectionList);
} else {
runAfterMap.get(sourceKey).add(currentConnection);
}
modified = true;
} else if (currentConnection.getLabel().equals(Messages.getString("ReplaceRunBeforeAfterWithThenRunMigrationTask.RunBefore"))) {
//$NON-NLS-1$
//$NON-NLS-1$
currentConnection.setLabel(Messages.getString("ReplaceRunBeforeAfterWithThenRunMigrationTask.ThenRun"));
String target = currentConnection.getTarget();
currentConnection.setTarget(currentConnection.getSource());
currentConnection.setSource(target);
String sourceKey = currentConnection.getSource();
if (!runAfterMap.containsKey(sourceKey)) {
List<ConnectionType> connectionList = new ArrayList<ConnectionType>();
connectionList.add(currentConnection);
runAfterMap.put(sourceKey, connectionList);
} else {
runAfterMap.get(sourceKey).add(currentConnection);
}
modified = true;
}
}
if (modified) {
resetDirectionOfConnections(runAfterMap);
factory.save(item);
}
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class ReplaceMultiFlowBytReplicateMigrationTask method checkMaxOutputAndUpdate.
/**
* DOC nrousseau Comment method "checkMaxOutputAndUpdate".
*
* @param processItem
* @param processType
* @param component
*/
@SuppressWarnings("unchecked")
private boolean checkMaxOutputAndUpdate(Item processItem, ProcessType processType, IComponent component, NodeType nodeTypeSource) throws PersistenceException {
boolean modified = false;
String nodeSourceUniqueName = ComponentUtilities.getNodeUniqueName(nodeTypeSource);
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<INodeConnector> nodeConnectors = (List<INodeConnector>) component.createConnectors(null);
for (INodeConnector nodeConnector : nodeConnectors) {
if (nodeConnector.getBaseSchema().equals("FLOW") && nodeConnector.getMaxLinkOutput() == 1) {
//$NON-NLS-1$
List<ConnectionType> connections = getConnectionsToMove(processType, nodeConnector, nodeSourceUniqueName);
if (connections != null) {
List<Rectangle> targetPos = getTargetsRectangle(connections);
Rectangle startPos = getNodeRectangle(processType, nodeSourceUniqueName);
Integer tReplicateYPos = 0;
Integer tReplicateXPos = Integer.MAX_VALUE;
for (Rectangle rect : targetPos) {
if (rect.x < tReplicateXPos) {
tReplicateXPos = rect.x;
}
tReplicateYPos += rect.y;
}
tReplicateXPos = (tReplicateXPos + startPos.x) / 2;
tReplicateYPos = tReplicateYPos / targetPos.size();
int tempVar = tReplicateXPos / GRID_SIZE;
tReplicateXPos = tempVar * GRID_SIZE;
tempVar = tReplicateYPos / GRID_SIZE;
tReplicateYPos = tempVar * GRID_SIZE;
Point tReplicatePos = findLocationForNode(processType, new Point(tReplicateXPos, tReplicateYPos));
addtReplicateComponent(processType, tReplicatePos, nodeTypeSource, nodeSourceUniqueName, nodeConnector, connections);
modified = true;
}
}
}
if (modified) {
factory.save(processItem);
}
return modified;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class ContextRepositoryReviewDialog method okPressed.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.dialog.RepositoryReviewDialog#okPressed()
*/
@SuppressWarnings("unchecked")
@Override
protected void okPressed() {
if (params == null || params.isEmpty()) {
super.okPressed();
}
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (createNewButton.getSelection()) {
if (nameInvalid(contextNameText)) {
//$NON-NLS-1$
MessageDialog.openError(getShell(), "Context", msg);
return;
} else {
item = PropertiesFactory.eINSTANCE.createContextItem();
if (item == null) {
return;
}
Property createProperty = PropertiesFactory.eINSTANCE.createProperty();
createProperty.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
createProperty.setVersion(VersionUtils.DEFAULT_VERSION);
//$NON-NLS-1$
createProperty.setStatusCode("");
try {
String nextId = factory.getNextId();
createProperty.setId(nextId);
item.setProperty(createProperty);
for (IContext context : contextManager.getListContext()) {
ContextType contextType = TalendFileFactory.eINSTANCE.createContextType();
contextType.setName(context.getName());
item.getContext().add(contextType);
}
item.setDefaultContext(contextManager.getDefaultContext().getName());
item.getProperty().setLabel(contextNameText.getText().trim());
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IProxyRepositoryFactory repositoryFactory = service.getProxyRepositoryFactory();
try {
boolean nameAvaliabe = repositoryFactory.isNameAvailable(createProperty.getItem(), contextNameText.getText());
if (!nameAvaliabe) {
MessageDialog.openError(getShell(), "Context", //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"PropertiesWizardPage.ItemExistsError"));
return;
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
super.okPressed();
}
//$NON-NLS-1$
factory.create(item, new Path(""));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
super.okPressed();
}
}
} else {
IStructuredSelection selection = (IStructuredSelection) getRepositoryTreeViewer().getSelection();
RepositoryNode context = (RepositoryNode) selection.getFirstElement();
try {
// get the item from file
IRepositoryViewObject contextObj = factory.getLastVersion(context.getObject().getProperty().getId());
item = (ContextItem) contextObj.getProperty().getItem();
} catch (PersistenceException e) {
ExceptionHandler.process(e);
super.okPressed();
}
}
super.okPressed();
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class ProjectSettingsPreferenceDialog method unloadProject.
private void unloadProject() {
Project currentProject = ProjectManager.getInstance().getCurrentProject();
final ProxyRepositoryFactory instance = ProxyRepositoryFactory.getInstance();
if (PluginChecker.isSVNProviderPluginLoaded()) {
try {
if (!instance.isLocalConnectionProvider()) {
// instance.getRepositoryFactoryFromProvider().reloadProject(currentProject);
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
Aggregations