Search in sources :

Example 21 with IRepositoryFactory

use of org.talend.core.repository.model.IRepositoryFactory in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method initProxyRepository.

/**
 * DOC talend Comment method "initProxyRepository".
 */
public static void initProxyRepository(IProject rootProject) {
    Project project = null;
    ProxyRepositoryFactory proxyRepository = ProxyRepositoryFactory.getInstance();
    IRepositoryFactory repository = RepositoryFactoryProvider.getRepositoriyById(RepositoryConstants.REPOSITORY_LOCAL_ID);
    if (repository == null) {
        log.fatal(DefaultMessagesImpl.getString(// $NON-NLS-1$
        "No local Repository found! Probably due to a missing plugin in the product."));
    }
    proxyRepository.setRepositoryFactoryFromProvider(repository);
    try {
        proxyRepository.checkAvailability();
        proxyRepository.initialize();
        XmiResourceManager xmiResourceManager = new XmiResourceManager();
        if (rootProject.getFile(FileConstants.LOCAL_PROJECT_FILENAME).exists()) {
            // Initialize TDQ EMF model packages.
            new EMFUtil();
            project = new Project(xmiResourceManager.loadProject(rootProject));
        } else {
            User user = org.talend.core.model.properties.impl.PropertiesFactoryImpl.eINSTANCE.createUser();
            // $NON-NLS-1$
            user.setLogin("talend@talend.com");
            // $NON-NLS-1$
            user.setPassword("talend@talend.com".getBytes());
            String projectName = rootProject.getName();
            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(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);
        }
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : Status(org.talend.core.model.properties.Status) IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) User(org.talend.core.model.properties.User) EMFUtil(org.talend.commons.emf.EMFUtil) PersistenceException(org.talend.commons.exception.PersistenceException) XmiResourceManager(org.talend.core.repository.utils.XmiResourceManager)

Example 22 with IRepositoryFactory

use of org.talend.core.repository.model.IRepositoryFactory in project tdq-studio-se by Talend.

the class ItemRecordTest method initProxyRepository.

/**
 * DOC talend Comment method "initProxyRepository".
 */
private void initProxyRepository(IProject rootProject) {
    Project project = null;
    // $NON-NLS-1$
    log.debug("##############ProxyRepositoryFactory.getInstance()");
    ProxyRepositoryFactory proxyRepository = ProxyRepositoryFactory.getInstance();
    // $NON-NLS-1$
    log.debug("##############RepositoryFactoryProvider.getRepositoriyById(RepositoryConstants.REPOSITORY_LOCAL_ID)");
    IRepositoryFactory repository = RepositoryFactoryProvider.getRepositoriyById(RepositoryConstants.REPOSITORY_LOCAL_ID);
    proxyRepository.setRepositoryFactoryFromProvider(repository);
    try {
        // $NON-NLS-1$
        log.debug("##############proxyRepository.checkAvailability()");
        proxyRepository.checkAvailability();
        // $NON-NLS-1$
        log.debug("##############proxyRepository.initialize()");
        try {
            proxyRepository.initialize();
        } catch (Exception e) {
            log.error(e, e);
        }
        proxyRepository.logOffProject();
        XmiResourceManager xmiResourceManager = new XmiResourceManager();
        // $NON-NLS-1$
        log.debug("##############rootProject.getFile(FileConstants.LOCAL_PROJECT_FILENAME).exists()");
        if (rootProject.getFile(FileConstants.LOCAL_PROJECT_FILENAME).exists()) {
            // Initialize TDQ EMF model packages.
            // $NON-NLS-1$
            log.debug("##############Project name is " + rootProject.getName());
            new EMFUtil();
            project = new Project(xmiResourceManager.loadProject(rootProject));
            // $NON-NLS-1$
            log.debug("############## after loadProject Project name is " + project.getTechnicalLabel());
        } else {
            User user = org.talend.core.model.properties.impl.PropertiesFactoryImpl.eINSTANCE.createUser();
            // $NON-NLS-1$
            user.setLogin("talend@talend.com");
            // $NON-NLS-1$
            user.setPassword("talend@talend.com".getBytes());
            String projectName = rootProject.getName();
            // $NON-NLS-1$
            log.debug("##############default project is not exist then create new project which is  " + projectName);
            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(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);
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        Assert.fail(e.getMessage());
    } catch (Exception e) {
        log.error(e, e);
        // $NON-NLS-1$
        log.debug("##############exception message is  " + e.getMessage());
    }
}
Also used : Status(org.talend.core.model.properties.Status) Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) User(org.talend.core.model.properties.User) EMFUtil(org.talend.commons.emf.EMFUtil) PersistenceException(org.talend.commons.exception.PersistenceException) XmiResourceManager(org.talend.core.repository.utils.XmiResourceManager) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 23 with IRepositoryFactory

use of org.talend.core.repository.model.IRepositoryFactory in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method initProxyRepository.

/**
 * DOC talend Comment method "initProxyRepository".
 */
public static void initProxyRepository(IProject rootProject) {
    Project project = null;
    ProxyRepositoryFactory proxyRepository = ProxyRepositoryFactory.getInstance();
    IRepositoryFactory repository = RepositoryFactoryProvider.getRepositoriyById(RepositoryConstants.REPOSITORY_LOCAL_ID);
    if (repository == null) {
        log.fatal(DefaultMessagesImpl.getString(// $NON-NLS-1$
        "No local Repository found! Probably due to a missing plugin in the product."));
    }
    proxyRepository.setRepositoryFactoryFromProvider(repository);
    try {
        proxyRepository.checkAvailability();
        proxyRepository.setFullLogonFinished(false);
        // proxyRepository.initialize();
        XmiResourceManager xmiResourceManager = new XmiResourceManager();
        if (rootProject.getFile(FileConstants.LOCAL_PROJECT_FILENAME).exists()) {
            // Initialize TDQ EMF model packages.
            new EMFUtil();
            project = new Project(xmiResourceManager.loadProject(rootProject));
        } else {
            User user = org.talend.core.model.properties.impl.PropertiesFactoryImpl.eINSTANCE.createUser();
            // $NON-NLS-1$
            user.setLogin("talend@talend.com");
            // $NON-NLS-1$
            user.setPassword("talend@talend.com".getBytes());
            String projectName = rootProject.getName();
            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(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);
        }
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : Status(org.talend.core.model.properties.Status) Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) User(org.talend.core.model.properties.User) EMFUtil(org.talend.commons.emf.EMFUtil) PersistenceException(org.talend.commons.exception.PersistenceException) XmiResourceManager(org.talend.core.repository.utils.XmiResourceManager)

Example 24 with IRepositoryFactory

use of org.talend.core.repository.model.IRepositoryFactory in project tdq-studio-se by Talend.

the class ReportFileHelperTest method setUp.

@Before
public void setUp() throws Exception {
    IRepositoryFactory localRepository = RepositoryFactoryProvider.getRepositoriyById(RepositoryConstants.REPOSITORY_LOCAL_ID);
    ProxyRepositoryFactory.getInstance().setRepositoryFactoryFromProvider(localRepository);
}
Also used : IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) Before(org.junit.Before)

Aggregations

IRepositoryFactory (org.talend.core.repository.model.IRepositoryFactory)24 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)13 PersistenceException (org.talend.commons.exception.PersistenceException)11 Project (org.talend.core.model.general.Project)11 User (org.talend.core.model.properties.User)10 XmiResourceManager (org.talend.core.repository.utils.XmiResourceManager)10 IProject (org.eclipse.core.resources.IProject)7 EMFUtil (org.talend.commons.emf.EMFUtil)6 Status (org.talend.core.model.properties.Status)6 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)6 Before (org.junit.Before)5 RepositoryContext (org.talend.core.context.RepositoryContext)5 LabelText (org.talend.commons.ui.swt.formtools.LabelText)4 LabelledCombo (org.talend.commons.ui.swt.formtools.LabelledCombo)4 ResourceBundle (java.util.ResourceBundle)3 ImageRegistry (org.eclipse.jface.resource.ImageRegistry)3 Shell (org.eclipse.swt.widgets.Shell)3 LoginException (org.talend.commons.exception.LoginException)3 OperationCancelException (org.talend.commons.exception.OperationCancelException)3 CoreRuntimePlugin (org.talend.core.runtime.CoreRuntimePlugin)3