Search in sources :

Example 6 with ProxyRepositoryFactory

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;
}
Also used : SalesforceSchemaConnection(org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) SalesforceSchemaConnectionItem(org.talend.core.model.properties.SalesforceSchemaConnectionItem)

Example 7 with ProxyRepositoryFactory

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);
    }
}
Also used : ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) EConnectionType(org.talend.core.model.process.EConnectionType) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) TreeMap(java.util.TreeMap)

Example 8 with ProxyRepositoryFactory

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;
}
Also used : ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) INodeConnector(org.talend.core.model.process.INodeConnector) Point(org.eclipse.draw2d.geometry.Point) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ArrayList(java.util.ArrayList) List(java.util.List)

Example 9 with ProxyRepositoryFactory

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();
}
Also used : Path(org.eclipse.core.runtime.Path) ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) IContext(org.talend.core.model.process.IContext) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryService(org.talend.repository.model.IRepositoryService) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 10 with ProxyRepositoryFactory

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);
        }
    }
}
Also used : Project(org.talend.core.model.general.Project) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) PersistenceException(org.talend.commons.exception.PersistenceException)

Aggregations

ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)74 PersistenceException (org.talend.commons.exception.PersistenceException)32 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)25 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)22 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)18 EList (org.eclipse.emf.common.util.EList)15 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)11 Project (org.talend.core.model.general.Project)10 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)9 BusinessException (org.talend.commons.exception.BusinessException)8 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)8 ArrayList (java.util.ArrayList)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 Path (org.eclipse.core.runtime.Path)6 EConnectionType (org.talend.core.model.process.EConnectionType)6 ConnectionItem (org.talend.core.model.properties.ConnectionItem)6 List (java.util.List)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)5