use of org.talend.core.repository.model.ProxyRepositoryFactory 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());
}
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdq-studio-se by Talend.
the class TDQResourceChangeHandlerTest method setUp.
@Before
public void setUp() throws Exception {
if (tdqResourceChangeHandler == null) {
ProxyRepositoryFactory proxFactory = mock(ProxyRepositoryFactory.class);
// $NON-NLS-1$
stub(method(ProxyRepositoryFactory.class, "getInstance")).toReturn(proxFactory);
IRepositoryFactory repFactory = mock(IRepositoryFactory.class);
when(proxFactory.getRepositoryFactoryFromProvider()).thenReturn(repFactory);
XmiResourceManager resManager = mock(XmiResourceManager.class);
when(repFactory.getResourceManager()).thenReturn(resManager);
tdqResourceChangeHandler = new TDQResourceChangeHandler();
}
}
use of org.talend.core.repository.model.ProxyRepositoryFactory 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());
}
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdq-studio-se by Talend.
the class UnitTestBuildHelper method mockLocalRepositoryObjectCRUD.
/**
* mock LocalRepositoryObjectCRUD for RepNodeUtils.getRepositoryObjectCRUD().
*/
public static void mockLocalRepositoryObjectCRUD() {
IProject proj = mock(IProject.class);
when(proj.getFullPath()).thenReturn(new Path(PluginConstant.EMPTY_STRING));
PowerMockito.mockStatic(ResourceManager.class);
when(ResourceManager.getRootProject()).thenReturn(proj);
PowerMockito.mockStatic(ProxyRepositoryFactory.class);
ProxyRepositoryFactory proxFactory = mock(ProxyRepositoryFactory.class);
when(ProxyRepositoryFactory.getInstance()).thenReturn(proxFactory);
PowerMockito.mockStatic(RepNodeUtils.class);
LocalRepositoryObjectCRUD localRepCRUD = mock(LocalRepositoryObjectCRUD.class);
when(RepNodeUtils.getRepositoryObjectCRUD()).thenReturn(localRepCRUD);
}
use of org.talend.core.repository.model.ProxyRepositoryFactory 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());
}
}
Aggregations