use of org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager in project tdi-studio-se by Talend.
the class ImportDemoProjectItemsPage method getResourceManagers.
private List<ResourcesManager> getResourceManagers(List<DemoProjectBean> checkedProjectBean) {
List<ResourcesManager> resManagers = new ArrayList<ResourcesManager>();
try {
for (DemoProjectBean pro : checkedProjectBean) {
ResourcesManager resManager = null;
Bundle bundle = Platform.getBundle(pro.getPluginId());
URL demoURL = FileLocator.find(bundle, new Path(pro.getDemoProjectFilePath()), null);
demoURL = FileLocator.toFileURL(demoURL);
String filePath = new Path(demoURL.getFile()).toOSString();
File srcFile = new File(filePath);
// TUP-1924:use UnityManager here ,same with import normal items.
FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
resManager = fileUnityManager.doUnify();
if (resManager != null) {
resManagers.add(resManager);
}
}
} catch (ZipException e) {
//$NON-NLS-1$
displayErrorDialog(Messages.getString("ImportItemsWizardPage_ZipImport_badFormat"));
} catch (TarException e) {
//$NON-NLS-1$
displayErrorDialog(Messages.getString("ImportItemsWizardPage_TarImport_badFormat"));
} catch (FileNotFoundException e) {
ExceptionHandler.process(e);
} catch (IOException e) {
ExceptionHandler.process(e);
}
return resManagers;
}
use of org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager in project tdi-studio-se by Talend.
the class DqDemoImportTest method testDqDemoComplete.
@Test
public void testDqDemoComplete() throws Exception {
// test the job items under DQ_Demo.zip
Assert.assertTrue(dqResManager instanceof FileResourcesUnityManager);
Iterator path = dqResManager.getPaths().iterator();
String firstFilePath = ((Path) path.next()).toPortableString();
String tempFolderPath = firstFilePath.substring(0, firstFilePath.indexOf(TEMP_FOLDER_SUFFIEX) + TEMP_FOLDER_SUFFIEX.length());
Assert.assertTrue(new File(tempFolderPath).exists());
String rootPath = tempFolderPath + File.separator + demoName;
Assert.assertTrue(new File(rootPath).exists());
File tempJobsFolder = new File(rootPath + File.separator + processItemPath);
List<File> demoJobItemFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempJobsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoJobItemFiles.size() > 0);
int currentJobItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS).size();
Assert.assertTrue(currentJobItemsSize > 0);
Assert.assertEquals(demoJobItemFiles.size(), currentJobItemsSize);
// test the context items under DQ_Demo.zip
int currentContextItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.CONTEXT).size();
Assert.assertTrue(currentContextItemsSize > 0);
File tempContextItemsFolder = new File(rootPath + File.separator + contextItemPath);
List<File> demoContextItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempContextItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoContextItemsFiles.size() > 0);
Assert.assertEquals(demoContextItemsFiles.size(), currentContextItemsSize);
// test the metadata items under DQ_Demo.zip
int currentConnectionItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.METADATA).size();
Assert.assertTrue(currentConnectionItemsSize > 0);
File tempConnItemsFolder = new File(rootPath + File.separator + connectionItemPath);
List<File> demoConItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempConnItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoConItemsFiles.size() > 0);
Assert.assertEquals(demoConItemsFiles.size(), currentConnectionItemsSize);
// test the routine items under DQ_Demo.zip
doRoutinesItemsTest(rootPath);
// test the business process items under DQ_Demo.zip
int currentBusinessItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.BUSINESS_PROCESS).size();
Assert.assertTrue(currentBusinessItemsSize > 0);
File tempBusinessItemsFolder = new File(rootPath + File.separator + bussniessProcessPath);
List<File> demoBusinessItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempBusinessItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoBusinessItemsFiles.size() > 0);
Assert.assertEquals(demoBusinessItemsFiles.size(), currentBusinessItemsSize);
// test the documention items under DQ_Demo.zip
int currentDocItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.DOCUMENTATION).size();
Assert.assertTrue(currentDocItemsSize > 0);
File tempDocItemsFolder = new File(rootPath + File.separator + documentionPath);
List<File> demoDocItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempDocItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoDocItemsFiles.size() > 0);
Assert.assertEquals(demoDocItemsFiles.size(), currentDocItemsSize);
// test the analyes items under DQ_Demo.zip
int currentAnaItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT).size();
Assert.assertTrue(currentAnaItemsSize > 0);
File tempAnaItemsFolder = new File(rootPath + File.separator + tdqProfilingAnaPath);
List<File> demoAnaItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempAnaItemsFolder, FileConstants.ANA_EXTENSION, true);
Assert.assertTrue(demoAnaItemsFiles.size() > 0);
Assert.assertEquals(demoAnaItemsFiles.size(), currentAnaItemsSize);
// test the reports items under DQ_Demo.zip
int currentRepItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.TDQ_REPORT_ELEMENT).size();
Assert.assertTrue(currentRepItemsSize > 0);
File tempRepItemsFolder = new File(rootPath + File.separator + tdqProfilingRepPath);
List<File> demoRepItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempRepItemsFolder, FileConstants.REP_EXTENSION, true);
Assert.assertTrue(demoRepItemsFiles.size() > 0);
Assert.assertEquals(demoRepItemsFiles.size(), currentRepItemsSize);
// test the rules sql items under DQ_Demo.zip(DQ_EE_DEMOS\TDQ_Libraries\Rules\SQL)
int currentRuleSqlItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.TDQ_RULES_SQL).size();
Assert.assertTrue(currentRuleSqlItemsSize > 0);
File tempRuleSqlItemsFolder = new File(rootPath + File.separator + tdqLibrariesRuleSqlPath);
List<File> demoRuleSqlItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempRuleSqlItemsFolder, FileConstants.RULE_EXTENSION, true);
Assert.assertTrue(demoRuleSqlItemsFiles.size() > 0);
Assert.assertEquals(demoRuleSqlItemsFiles.size(), currentRuleSqlItemsSize);
// test the pattern items under DQ_Demo.zip(DQ_EE_DEMOS\TDQ_Libraries\Patterns)
int currentPatItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.TDQ_PATTERN_ELEMENT).size();
Assert.assertTrue(currentPatItemsSize > 0);
File tempPatItemsFolder = new File(rootPath + File.separator + tdqLibrariesPatternPath);
List<File> demoPatItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempPatItemsFolder, FileConstants.PAT_EXTENSION, true);
Assert.assertTrue(demoPatItemsFiles.size() > 0);
Assert.assertEquals(demoPatItemsFiles.size(), currentPatItemsSize);
}
use of org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager in project tdi-studio-se by Talend.
the class EsbDemoImportTest method testEsbDemoComplete.
@Test
public void testEsbDemoComplete() throws Exception {
// test the job items under ESB_Demo.zip
Assert.assertTrue(esbResManager instanceof FileResourcesUnityManager);
Iterator pathes = esbResManager.getPaths().iterator();
IPath projectPath = null;
while (pathes.hasNext()) {
IPath p = ((Path) pathes.next());
if (p.lastSegment().equals(FileConstants.LOCAL_PROJECT_FILENAME)) {
projectPath = p;
break;
}
}
Assert.assertNotNull("Can't find the talend.project, so it's invalid demo", projectPath);
final File talendProjectFile = projectPath.toFile();
Assert.assertTrue(talendProjectFile.exists());
String rootPath = talendProjectFile.getParentFile().toString();
File tempJobsFolder = new File(rootPath + File.separator + processItemPath);
List<File> demoJobItemFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempJobsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoJobItemFiles.size() > 0);
int currentJobItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS).size();
Assert.assertTrue(currentJobItemsSize > 0);
Assert.assertEquals(demoJobItemFiles.size(), currentJobItemsSize);
// test the metadata items under ESB_Demo.zip
int currentConnectionItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.METADATA).size();
Assert.assertTrue(currentConnectionItemsSize > 0);
File tempConnItemsFolder = new File(rootPath + File.separator + connectionItemPath);
List<File> demoConItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempConnItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoConItemsFiles.size() > 0);
Assert.assertEquals(demoConItemsFiles.size(), currentConnectionItemsSize);
// test the routes under ESB_Demo.zip
int currentRoutesSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS_ROUTE).size();
Assert.assertTrue(currentRoutesSize > 0);
File tempRoutesFolder = new File(rootPath + File.separator + routesItemPath);
List<File> demoRoutesFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempRoutesFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoRoutesFiles.size() > 0);
Assert.assertEquals(demoRoutesFiles.size(), currentRoutesSize);
// test the route_resources items under ESB_Demo.zip
int currentRouteResourcesSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, ROUTE_RESOURCES)).size();
Assert.assertTrue(currentRouteResourcesSize > 0);
File tempRouteResourcesFolder = new File(rootPath + File.separator + routeResourcePath);
List<File> demoRouteResourceFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempRouteResourcesFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoRouteResourceFiles.size() > 0);
Assert.assertEquals(demoRouteResourceFiles.size(), currentRouteResourcesSize);
// test the wsdls under ESB_Demo.zip(ESB_DEMO/services)
int currentWSDLsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, SERVICES)).size();
Assert.assertTrue(currentWSDLsSize > 0);
File tempWSDLServicesFolder = new File(rootPath + File.separator + servicesItemPath);
List<File> demoWSDLServiceFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempWSDLServicesFolder, FileConstants.WSDL_FILE_SUFFIX, true);
Assert.assertTrue(demoWSDLServiceFiles.size() > 0);
Assert.assertEquals(demoWSDLServiceFiles.size(), currentWSDLsSize);
}
use of org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager in project tdi-studio-se by Talend.
the class BigDataEeImportTest method testBdEeDemoComplete.
@Test
public void testBdEeDemoComplete() throws Exception {
// test the job items under BigDataDemo_ee.zip
Assert.assertTrue(eeResManager instanceof FileResourcesUnityManager);
Iterator path = eeResManager.getPaths().iterator();
String firstFilePath = ((Path) path.next()).toPortableString();
String eeDemoName = demoName.substring(0, demoName.indexOf("_"));
String tempFolderPath = firstFilePath.substring(0, firstFilePath.indexOf(TEMP_FOLDER_SUFFIEX) + TEMP_FOLDER_SUFFIEX.length());
Assert.assertTrue(new File(tempFolderPath).exists());
String rootPath = tempFolderPath + File.separator + eeDemoName;
Assert.assertTrue(new File(rootPath).exists());
File tempJobsFolder = new File(rootPath + File.separator + processItemPath);
List<File> demoJobItemFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempJobsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoJobItemFiles.size() > 0);
int currentJobItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS).size();
Assert.assertTrue(currentJobItemsSize > 0);
Assert.assertEquals(demoJobItemFiles.size(), currentJobItemsSize);
// test the hadoop items under BigDataDemo_ee.zip
int currentMrItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS_MR).size();
File tempMrItemsFolder = new File(rootPath + File.separator + processMrPath);
List<File> demoMrItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempMrItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoMrItemsFiles.size() > 0);
Assert.assertTrue(currentMrItemsSize > 0);
Assert.assertEquals(demoMrItemsFiles.size(), currentMrItemsSize);
// test the context items under BigDataDemo_ee.zip
int currentContextItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.CONTEXT).size();
File tempContextItemsFolder = new File(rootPath + File.separator + contextItemPath);
List<File> demoContextItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempContextItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoContextItemsFiles.size() > 0);
Assert.assertTrue(currentContextItemsSize > 0);
Assert.assertEquals(demoContextItemsFiles.size(), currentContextItemsSize);
// test the routine items under BigDataDemo_ee.zip
doRoutinesItemsTest(rootPath);
// test the metadata items under BigDataDemo_ee.zip
int currentConnectionItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.METADATA).size();
int currentHadoopConnItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, "HADOOPCLUSTER")).size();
File tempConnItemsFolder = new File(rootPath + File.separator + connectionItemPath);
List<File> demoConItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempConnItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoConItemsFiles.size() > 0);
Assert.assertTrue(currentConnectionItemsSize > 0);
Assert.assertEquals(demoConItemsFiles.size(), currentConnectionItemsSize);
// test the documention items under BigDataDemo_ee.zip
int currentDocItemsSize = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.DOCUMENTATION).size();
File tempDocItemsFolder = new File(rootPath + File.separator + documentionPath);
List<File> demoDocItemsFiles = DemoImportTestUtil.collectProjectFilesFromDirectory(tempDocItemsFolder, FileConstants.ITEM_EXTENSION, true);
Assert.assertTrue(demoDocItemsFiles.size() > 0);
Assert.assertTrue(currentDocItemsSize > 0);
Assert.assertEquals(demoDocItemsFiles.size(), currentDocItemsSize);
}
use of org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager in project tdi-studio-se by Talend.
the class DemoImportTestUtil method getResourceManagers.
public static List<ResourcesManager> getResourceManagers(List<DemoProjectBean> checkedProjectBean) {
List<ResourcesManager> resManagers = new ArrayList<ResourcesManager>();
try {
for (DemoProjectBean pro : checkedProjectBean) {
ResourcesManager resManager = null;
Bundle bundle = Platform.getBundle(pro.getPluginId());
URL demoURL = FileLocator.find(bundle, new Path(pro.getDemoProjectFilePath()), null);
demoURL = FileLocator.toFileURL(demoURL);
String filePath = new Path(demoURL.getFile()).toOSString();
File srcFile = new File(filePath);
FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
resManager = fileUnityManager.doUnify();
if (resManager != null) {
resManagers.add(resManager);
}
}
} catch (ZipException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (TarException e) {
e.printStackTrace();
}
return resManagers;
}
Aggregations