Search in sources :

Example 41 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tdi-studio-se by Talend.

the class NewProjectWizard method performFinish.

/**
     * @see org.eclipse.jface.wizard.Wizard#performFinish()
     */
@Override
public boolean performFinish() {
    IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
    Context ctx = CorePlugin.getContext();
    RepositoryContext repositoryContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
    try {
        Project projectInfor = ProjectHelper.createProject(mainPage.getName().trim().replace(' ', '_'), mainPage.getDescription(), mainPage.getLanguage(), repositoryContext.getUser());
        project = repositoryFactory.createProject(projectInfor);
        return true;
    } catch (PersistenceException e) {
        MessageDialog.openError(getShell(), Messages.getString("NewProjectWizard.failureTitle"), //$NON-NLS-1$
        Messages.getString(//$NON-NLS-1$ //$NON-NLS-2$
        "NewProjectWizard.failureText"));
        MessageBoxExceptionHandler.process(e);
        return false;
    }
}
Also used : Context(org.talend.core.context.Context) RepositoryContext(org.talend.core.context.RepositoryContext) Project(org.talend.core.model.general.Project) RepositoryContext(org.talend.core.context.RepositoryContext) PersistenceException(org.talend.commons.exception.PersistenceException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 42 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tmdm-studio-se by Talend.

the class MDMLockDecorator method isEditableAsReadOnly.

private void isEditableAsReadOnly() {
    Context ctx = CoreRuntimePlugin.getInstance().getContext();
    RepositoryContext rc = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
    editableAsReadOnly = rc.isEditableAsReadOnly();
}
Also used : Context(org.talend.core.context.Context) RepositoryContext(org.talend.core.context.RepositoryContext) RepositoryContext(org.talend.core.context.RepositoryContext)

Example 43 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tmdm-studio-se by Talend.

the class MDMRepositoryLabelProvider method getLockInfo.

private String getLockInfo(Object element) {
    User currentLoginUser = ((RepositoryContext) CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser();
    String currentLogin = null;
    if (currentLoginUser != null) {
        currentLogin = currentLoginUser.getLogin();
    }
    IRepositoryViewObject viewObj = (IRepositoryViewObject) element;
    Item item = viewObj.getProperty().getItem();
    if (item != null) {
        LockInfo lockInfo = ProxyRepositoryFactory.getInstance().getLockInfo(item);
        if (!lockInfo.getUser().equals(currentLogin)) {
            String login = lockInfo.getUser();
            String application = lockInfo.getApplication();
            if (login != null && !"".equals(login)) {
                // $NON-NLS-1$
                String content = Messages.bind(Messages.MDMRepositoryLabelProvider_lockinfo, login, application);
                return content;
            }
        }
    }
    return null;
}
Also used : Item(org.talend.core.model.properties.Item) RepositoryContext(org.talend.core.context.RepositoryContext) User(org.talend.core.model.properties.User) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) LockInfo(org.talend.core.model.repository.LockInfo) StyledString(org.eclipse.jface.viewers.StyledString)

Example 44 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method initRepositoryContext.

private static void initRepositoryContext(Project project) {
    RepositoryContext repositoryContext = new RepositoryContext();
    Context ctx = CoreRuntimePlugin.getInstance().getContext();
    ctx.putProperty(Context.REPOSITORY_CONTEXT_KEY, repositoryContext);
    repositoryContext.setUser(project.getAuthor());
    repositoryContext.setClearPassword(project.getLabel());
    repositoryContext.setProject(project);
    repositoryContext.setFields(new HashMap<String, String>());
    ProjectManager.getInstance().setMainProjectBranch(project, null);
    ReponsitoryContextBridge.initialized(project.getEmfProject(), project.getAuthor());
}
Also used : AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Context(org.talend.core.context.Context) RepositoryContext(org.talend.core.context.RepositoryContext) RepositoryContext(org.talend.core.context.RepositoryContext)

Example 45 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tdq-studio-se by Talend.

the class CorePlugin method initProxyRepository.

/**
 * DOC zshen Comment method "initProxyRepository".
 */
public ReturnCode initProxyRepository() {
    ReturnCode rc = new ReturnCode();
    Project project = null;
    RepositoryContext repositoryContext = (RepositoryContext) org.talend.core.runtime.CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
    if (repositoryContext != null) {
        project = repositoryContext.getProject();
        User user = repositoryContext.getUser();
        ReponsitoryContextBridge.initialized(project.getEmfProject(), user);
    } else {
        // else project is null, then we are in TOP only
        Location instanceLoc = Platform.getInstanceLocation();
        try {
            if (instanceLoc.isLocked()) {
                // $NON-NLS-1$
                rc.setMessage(DefaultMessagesImpl.getString("CorePlugin.workspaceInUse"));
                rc.setOk(false);
                return rc;
            } else {
                instanceLoc.lock();
            }
        } catch (IOException e) {
            log.error(e, e);
        }
        ProxyRepositoryFactory proxyRepository = ProxyRepositoryFactory.getInstance();
        IRepositoryFactory repository = RepositoryFactoryProvider.getRepositoriyById(RepositoryConstants.REPOSITORY_LOCAL_ID);
        if (repository == null) {
            // $NON-NLS-1$
            log.fatal(DefaultMessagesImpl.getString("CorePlugin.noLocalRepositoryFound"));
            // $NON-NLS-1$
            rc.setMessage(DefaultMessagesImpl.getString("CorePlugin.noLocalRepositoryFound"));
            rc.setOk(false);
            return rc;
        }
        proxyRepository.setRepositoryFactoryFromProvider(repository);
        try {
            proxyRepository.checkAvailability();
            proxyRepository.initialize();
            XmiResourceManager xmiResourceManager = proxyRepository.getRepositoryFactoryFromProvider().getResourceManager();
            IProject rootProject = ResourceManager.getRootProject();
            if (rootProject.getFile(FileConstants.LOCAL_PROJECT_FILENAME).exists()) {
                // Initialize TDQ EMF model packages.
                new EMFUtil();
                project = new Project(xmiResourceManager.loadProject(rootProject));
            } else {
                // $NON-NLS-1$
                String username = "talend@talend.com";
                // $NON-NLS-1$
                String password = "talend@talend.com";
                User user = PropertiesFactoryImpl.eINSTANCE.createUser();
                user.setLogin(username);
                user.setPassword(password.getBytes());
                String projectName = ResourceManager.getRootProjectName();
                String projectDesc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName).getComment();
                Project projectInfor = ProjectHelper.createProject(projectName, projectDesc, ECodeLanguage.JAVA.getName(), user);
                // MOD zshen create project by proxyRepository
                checkFileName(projectInfor.getLabel(), RepositoryConstants.PROJECT_PATTERN);
                project = proxyRepository.getRepositoryFactoryFromProvider().createProject(user, password, projectInfor);
            }
            if (project != null) {
                initRepositoryContext(project);
                // add status
                // $NON-NLS-1$
                String defaultTechnicalStatusList = "DEV development;TEST testing;PROD production";
                List<Status> statusList = StatusHelper.parse(defaultTechnicalStatusList);
                proxyRepository.setTechnicalStatus(statusList);
                // 'maven_user_settings.xml').before set, must check user setting first.
                if (org.talend.commons.utils.platform.PluginChecker.isOnlyTopLoaded()) {
                    if (GlobalServiceRegister.getDefault().isServiceRegistered(IMavenUIService.class)) {
                        IMavenUIService mavenUIService = (IMavenUIService) GlobalServiceRegister.getDefault().getService(IMavenUIService.class);
                        if (mavenUIService != null) {
                            mavenUIService.checkUserSettings(new NullProgressMonitor());
                            mavenUIService.updateMavenResolver(false);
                            mavenUIService.addMavenConfigurationChangeListener();
                        }
                    }
                    // deploy libraries and maven index here
                    if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
                        ILibrariesService librariesService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
                        if (librariesService != null) {
                            librariesService.syncLibraries();
                            // TDQ-9529 check libararies install status at here,so that
                            // "Optional third-party libraries" is displayed in the "Additional Talend Package"
                            // dialog.
                            librariesService.checkLibraries();
                        }
                    }
                }
                CWMPlugin.getDefault().createLibFolderIfNotExist();
                // TDQ-11348 the readOnlyUser property is false for TOP.
                // $NON-NLS-1$
                System.getProperties().put("ReadOnlyUser", new Boolean(false).toString());
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            rc.setMessage(e.getMessage());
            rc.setOk(false);
            return rc;
        }
    }
    return rc;
}
Also used : Status(org.talend.core.model.properties.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RepositoryContext(org.talend.core.context.RepositoryContext) IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) ReturnCode(org.talend.utils.sugars.ReturnCode) User(org.talend.core.model.properties.User) ILibrariesService(org.talend.core.model.general.ILibrariesService) XmiResourceManager(org.talend.core.repository.utils.XmiResourceManager) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) EMFUtil(org.talend.commons.emf.EMFUtil) PersistenceException(org.talend.commons.exception.PersistenceException) IMavenUIService(org.talend.core.runtime.services.IMavenUIService) Location(org.eclipse.osgi.service.datalocation.Location)

Aggregations

RepositoryContext (org.talend.core.context.RepositoryContext)53 Context (org.talend.core.context.Context)28 Project (org.talend.core.model.general.Project)18 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)14 PersistenceException (org.talend.commons.exception.PersistenceException)11 User (org.talend.core.model.properties.User)8 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)7 IProject (org.eclipse.core.resources.IProject)6 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)6 ECodeLanguage (org.talend.core.language.ECodeLanguage)5 IRepositoryFactory (org.talend.core.repository.model.IRepositoryFactory)5 IRepositoryNodeConfiguration (org.talend.mdm.repository.core.IRepositoryNodeConfiguration)5 IRepositoryNodeResourceProvider (org.talend.mdm.repository.core.IRepositoryNodeResourceProvider)5 Property (org.talend.core.model.properties.Property)4 RecycleBinNodeConfiguration (org.talend.mdm.repository.core.impl.recyclebin.RecycleBinNodeConfiguration)4 File (java.io.File)3 IOException (java.io.IOException)3 ResourceBundle (java.util.ResourceBundle)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 ImageRegistry (org.eclipse.jface.resource.ImageRegistry)3