Search in sources :

Example 1 with ProjectReference

use of org.talend.core.model.properties.ProjectReference in project tdi-studio-se by Talend.

the class SQLPatternComposite method addReferencedSQLTemplate.

private void addReferencedSQLTemplate(List<IRepositoryViewObject> list, Project project) {
    try {
        Context ctx = CorePlugin.getContext();
        if (ctx == null) {
            return;
        }
        String parentBranch = ProjectManager.getInstance().getMainProjectBranch(project);
        List<ProjectReference> referencedProjects = project.getEmfProject().getReferencedProjects();
        for (ProjectReference referenced : referencedProjects) {
            if (referenced.getBranch() != null && !parentBranch.equals(referenced.getBranch())) {
                continue;
            }
            org.talend.core.model.properties.Project referencedEmfProject = referenced.getReferencedProject();
            EList refeInRef = referencedEmfProject.getReferencedProjects();
            Project newProject = new Project(referencedEmfProject);
            if (refeInRef != null && refeInRef.size() > 0) {
                addReferencedSQLTemplate(list, newProject);
            }
            List<IRepositoryViewObject> refList;
            refList = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getAll(newProject, ERepositoryObjectType.SQLPATTERNS, false);
            for (IRepositoryViewObject repositoryObject : refList) {
                Item item = repositoryObject.getProperty().getItem();
                if (item instanceof SQLPatternItem) {
                    if (!((SQLPatternItem) item).isSystem()) {
                        list.add(repositoryObject);
                        sqlPatternAndProject.put((SQLPatternItem) item, project);
                    }
                }
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
}
Also used : Context(org.talend.core.context.Context) ProjectReference(org.talend.core.model.properties.ProjectReference) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) Project(org.talend.core.model.general.Project) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) TableItem(org.eclipse.swt.widgets.TableItem) EList(org.eclipse.emf.common.util.EList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 2 with ProjectReference

use of org.talend.core.model.properties.ProjectReference 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)

Aggregations

Project (org.talend.core.model.general.Project)2 ProjectReference (org.talend.core.model.properties.ProjectReference)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TableItem (org.eclipse.swt.widgets.TableItem)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 Context (org.talend.core.context.Context)1 ConnectionItem (org.talend.core.model.properties.ConnectionItem)1 Item (org.talend.core.model.properties.Item)1 SQLPatternItem (org.talend.core.model.properties.SQLPatternItem)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1