Search in sources :

Example 31 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class LoginDialogV2 method getFirstTimeStartupPageIfNeeded.

protected AbstractLoginActionPage getFirstTimeStartupPageIfNeeded() {
    AbstractLoginActionPage loginPage = null;
    IBrandingService service = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    if (service != null) {
        IBrandingConfiguration brandingConfiguration = service.getBrandingConfiguration();
        if (brandingConfiguration != null && brandingConfiguration.isOnlyRemoteConnection()) {
            return null;
        }
    }
    // try to find if there are projects in workspace
    Project[] projects = LoginHelper.getInstance().getProjects(LoginHelper.createDefaultLocalConnection());
    if (projects == null || projects.length == 0) {
        List<ConnectionBean> storedConnections = LoginHelper.getInstance().getStoredConnections();
        if (storedConnections == null || storedConnections.isEmpty() || (storedConnections.size() == 1 && !LoginHelper.isRemoteConnection(storedConnections.get(0)) && LoginHelper.isWorkspaceSame(storedConnections.get(0)))) {
            // for local license case
            loginPage = new LoginFirstTimeStartupActionPage(base, this, SWT.NONE);
        }
    }
    return loginPage;
}
Also used : Project(org.talend.core.model.general.Project) IBrandingConfiguration(org.talend.core.ui.branding.IBrandingConfiguration) ConnectionBean(org.talend.core.model.general.ConnectionBean) IBrandingService(org.talend.core.ui.branding.IBrandingService)

Example 32 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class LoginProjectPage method getBranch.

public String getBranch() {
    Project project = getProject();
    boolean isRemoteConnection = LoginHelper.isRemoteConnection(getConnection());
    if (branchesViewer != null && isRemoteConnection && !branchesViewer.getSelection().isEmpty() && project != null) {
        IStructuredSelection ss = (IStructuredSelection) branchesViewer.getSelection();
        String branch = (String) ss.getFirstElement();
        // if (branchList != null && branchList.contains(branch)) {
        return branch;
    // }
    } else if (!isRemoteConnection && project != null) {
        List<ProjectReference> referenceProjects = project.getEmfProject().getReferencedProjects();
        String currentBranch = null;
        if (referenceProjects != null && !referenceProjects.isEmpty()) {
            boolean allBranchesAreSame = true;
            for (ProjectReference referenceProject : referenceProjects) {
                String branchFromReference = referenceProject.getBranch();
                if (currentBranch == null) {
                    if (branchFromReference == null) {
                        //$NON-NLS-1$
                        branchFromReference = "";
                    }
                    currentBranch = branchFromReference;
                    continue;
                }
                if (!currentBranch.equals(branchFromReference)) {
                    allBranchesAreSame = false;
                    break;
                }
            }
            if (!allBranchesAreSame) {
                //$NON-NLS-1$
                currentBranch = "";
            }
        } else {
            //$NON-NLS-1$
            currentBranch = "";
        }
        return currentBranch;
    }
    return null;
}
Also used : Project(org.talend.core.model.general.Project) ProjectReference(org.talend.core.model.properties.ProjectReference) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 33 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class LoginProjectPage method saveLastUsedProjectAndBranch.

private void saveLastUsedProjectAndBranch() {
    Project project = getProject();
    loginHelper.getPrefManipulator().setLastProject(project.getLabel());
    if (loginHelper.isRemoteConnection(getConnection())) {
        String branch = getBranch();
        if (branch == null) {
            branch = SVNConstant.EMPTY;
        }
        try {
            loginHelper.getPrefManipulator().setLastSVNBranch(//$NON-NLS-1$
            new JSONObject(project.getEmfProject().getUrl()).getString("location"), //$NON-NLS-1$
            project.getTechnicalLabel(), branch);
        } catch (JSONException e) {
            ExceptionHandler.process(e);
        }
    } else {
        try {
            String jsonStr = project.getEmfProject().getUrl();
            if (jsonStr != null && !jsonStr.isEmpty()) {
                String lastLogonBranch = loginHelper.getPrefManipulator().getLastSVNBranch(new JSONObject(jsonStr).getString("location"), //$NON-NLS-1$
                project.getTechnicalLabel());
                ProjectManager.getInstance().setMainProjectBranch(project, lastLogonBranch);
            }
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : Project(org.talend.core.model.general.Project) JSONObject(org.talend.utils.json.JSONObject) JSONException(org.talend.utils.json.JSONException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SystemException(org.talend.commons.exception.SystemException) JSONException(org.talend.utils.json.JSONException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 34 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class ComponentChooseDialog method propaHadoopCfgChanges.

/**
     * DOC ycbai Comment method "propaHadoopCfgChanges".
     *
     * <P>
     * Propagate the changes from hadoop cluster to M/R process when drag&drop hadoop subnode from repository view to
     * M/R process.
     * </P>
     *
     * @param repositoryNode
     */
private void propaHadoopCfgChanges(IRepositoryNode repositoryNode) {
    if (repositoryNode == null || repositoryNode.getObject() == null) {
        return;
    }
    IHadoopClusterService hadoopClusterService = HadoopRepositoryUtil.getHadoopClusterService();
    if (hadoopClusterService == null || !hadoopClusterService.isHadoopSubnode(repositoryNode)) {
        return;
    }
    IProcess process = editor.getProcess();
    if (!ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process.getComponentsType()) && !ComponentCategory.CATEGORY_4_SPARK.getName().equals(process.getComponentsType()) && !ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(process.getComponentsType())) {
        return;
    }
    if ((process instanceof IProcess2) && (((IProcess2) process).getProperty().getItem() instanceof JobletProcessItem)) {
        return;
    }
    Item subItem = repositoryNode.getObject().getProperty().getItem();
    String propertyParamName = MR_PROPERTY_PREFIX + EParameterName.PROPERTY_TYPE.getName();
    String propertyRepTypeParamName = MR_PROPERTY_PREFIX + EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
    IElementParameter propertyParam = process.getElementParameter(propertyParamName);
    if (propertyParam == null) {
        return;
    }
    String repositoryValue = propertyParam.getRepositoryValue();
    if (repositoryValue == null) {
        return;
    }
    //$NON-NLS-1$
    String[] supportedRepositoryTypes = repositoryValue.split("\\|");
    String repositoryType = hadoopClusterService.getRepositoryTypeOfHadoopSubItem(subItem);
    if (!ArrayUtils.contains(supportedRepositoryTypes, repositoryType)) {
        return;
    }
    Item hadoopClusterItem = hadoopClusterService.getHadoopClusterBySubitemId(new Project(ProjectManager.getInstance().getProject(subItem)), subItem.getProperty().getId());
    String hadoopClusterId = hadoopClusterItem.getProperty().getId();
    if (EmfComponent.REPOSITORY.equals(propertyParam.getValue())) {
        // do nothing when select the same hadoop cluster.
        String propertyId = (String) process.getElementParameter(propertyRepTypeParamName).getValue();
        if (hadoopClusterId.equals(propertyId)) {
            return;
        }
    }
    Connection connection = ((ConnectionItem) subItem).getConnection();
    if (hadoopClusterService.hasDiffsFromClusterToProcess(subItem, process)) {
        boolean confirmUpdate = MessageDialog.openConfirm(editor.getSite().getShell(), //$NON-NLS-1$
        Messages.getString("TalendEditorDropTargetListener.updateHadoopCfgDialog.title"), //$NON-NLS-1$
        Messages.getString("TalendEditorDropTargetListener.updateHadoopCfgDialog.msg"));
        if (confirmUpdate) {
            // Update spark mode to YARN_CLIENT if repository
            if (ComponentCategory.CATEGORY_4_SPARK.getName().equals(process.getComponentsType()) || ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(process.getComponentsType())) {
                IElementParameter sparkLocalParam = process.getElementParameter(HadoopConstants.SPARK_LOCAL_MODE);
                IElementParameter sparkParam = process.getElementParameter(HadoopConstants.SPARK_MODE);
                if (sparkLocalParam != null && (Boolean) (sparkLocalParam.getValue())) {
                    sparkLocalParam.setValue(false);
                }
                if (sparkParam != null && !HadoopConstants.SPARK_MODE_YARN_CLIENT.equals(sparkParam.getValue())) {
                    sparkParam.setValue(HadoopConstants.SPARK_MODE_YARN_CLIENT);
                }
            }
            propertyParam.setValue(EmfComponent.REPOSITORY);
            ChangeValuesFromRepository command = new ChangeValuesFromRepository(process, connection, propertyRepTypeParamName, subItem.getProperty().getId());
            execCommandStack(command);
        }
    }
}
Also used : ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) PolylineConnection(org.eclipse.draw2d.PolylineConnection) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) CDCConnection(org.talend.core.model.metadata.builder.connection.CDCConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) RulesItem(org.talend.core.model.properties.RulesItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) FileItem(org.talend.core.model.properties.FileItem) Project(org.talend.core.model.general.Project) IHadoopClusterService(org.talend.core.hadoop.IHadoopClusterService) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IProcess2(org.talend.core.model.process.IProcess2) IElementParameter(org.talend.core.model.process.IElementParameter) IProcess(org.talend.core.model.process.IProcess)

Example 35 with Project

use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.

the class ShowRoutineItemsLabelProvider method getElements.

public Object[] getElements(Object inputElement) {
    Set<Project> projects = allRoutineItems.keySet();
    List<Object> objects = new ArrayList<Object>();
    Project currentProject = ProjectManager.getInstance().getCurrentProject();
    for (Project p : projects) {
        if (p.equals(currentProject)) {
            List<Property> items = allRoutineItems.get(p);
            if (items != null) {
                objects.addAll(items);
            }
        } else {
            objects.add(p);
        }
    }
    return objects.toArray();
}
Also used : Project(org.talend.core.model.general.Project) ArrayList(java.util.ArrayList) Property(org.talend.core.model.properties.Property)

Aggregations

Project (org.talend.core.model.general.Project)160 IProject (org.eclipse.core.resources.IProject)77 PersistenceException (org.talend.commons.exception.PersistenceException)73 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)34 ArrayList (java.util.ArrayList)24 IFolder (org.eclipse.core.resources.IFolder)23 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)23 Property (org.talend.core.model.properties.Property)21 File (java.io.File)20 Path (org.eclipse.core.runtime.Path)19 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)19 IPath (org.eclipse.core.runtime.IPath)18 IOException (java.io.IOException)17 RepositoryContext (org.talend.core.context.RepositoryContext)16 CoreException (org.eclipse.core.runtime.CoreException)14 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)14 IFile (org.eclipse.core.resources.IFile)13 Item (org.talend.core.model.properties.Item)13 User (org.talend.core.model.properties.User)13 Test (org.junit.Test)12