use of org.talend.designer.core.model.utils.emf.component.IMPORTType in project tdi-studio-se by Talend.
the class JavaProcessorUtilities method getNeededModulesForProcess.
public static Set<ModuleNeeded> getNeededModulesForProcess(IProcess process) {
Set<ModuleNeeded> neededLibraries = new TreeSet<ModuleNeeded>(new Comparator<ModuleNeeded>() {
@Override
public int compare(ModuleNeeded m1, ModuleNeeded m2) {
return m1.toString().compareTo(m2.toString());
}
});
Set<ModuleNeeded> neededModules = LastGenerationInfo.getInstance().getModulesNeededWithSubjobPerJob(process.getId(), process.getVersion());
neededLibraries.addAll(neededModules);
if (process == null || !(process instanceof IProcess2)) {
if (neededLibraries.isEmpty() && process != null) {
neededLibraries = process.getNeededModules(true);
if (neededLibraries == null) {
neededLibraries = new HashSet<ModuleNeeded>();
// for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getModulesNeeded()) {
// neededLibraries.add(moduleNeeded.getModuleName());
// }
}
} else {
for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getRunningModules()) {
neededLibraries.add(moduleNeeded);
}
}
return neededLibraries;
}
Property property = ((IProcess2) process).getProperty();
if (neededLibraries.isEmpty()) {
neededLibraries = process.getNeededModules(true);
if (neededLibraries == null) {
neededLibraries = new HashSet<ModuleNeeded>();
for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getModulesNeeded()) {
neededLibraries.add(moduleNeeded);
}
}
} else {
if (property != null && property.getItem() instanceof ProcessItem) {
neededLibraries.addAll(ModulesNeededProvider.getModulesNeededForProcess((ProcessItem) property.getItem(), process));
} else {
for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getRunningModules()) {
neededLibraries.add(moduleNeeded);
}
}
}
if (property != null && GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (camelService.isInstanceofCamel(property.getItem())) {
// http://jira.talendforge.org/browse/TESB-5887 LiXiaopeng 2012-6-19
// Synchronize Route resources
camelService.synchronizeRouteResource((ProcessItem) property.getItem());
try {
for (IRepositoryViewObject object : CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().getAll(camelService.getBeansType())) {
Item item = object.getProperty().getItem();
if (item instanceof RoutineItem) {
RoutineItem routine = (RoutineItem) item;
for (Object o : routine.getImports()) {
IMPORTType type = (IMPORTType) o;
ModuleNeeded neededModule = new ModuleNeeded("camel bean dependencies", type.getMODULE(), "camel bean dependencies", true);
neededLibraries.add(neededModule);
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
return neededLibraries;
}
use of org.talend.designer.core.model.utils.emf.component.IMPORTType in project tdi-studio-se by Talend.
the class RemoveRoutineAntlrJarDependencyTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
if (getProject().getLanguage() == ECodeLanguage.JAVA) {
RoutineItem routineItem = (RoutineItem) item;
if (routineItem.isBuiltIn()) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
EList<IMPORTType> imports = routineItem.getImports();
List<IMPORTType> toRemove = new ArrayList<IMPORTType>();
for (IMPORTType importElement : imports) {
if ("antlr-3.3.jar".equals(importElement.getMODULE())) {
//$NON-NLS-1$
toRemove.add(importElement);
}
}
if (toRemove.size() > 0) {
imports.removeAll(toRemove);
ProxyRepositoryFactory.getInstance().save(routineItem);
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
} else {
return ExecutionResult.NOTHING_TO_DO;
}
}
use of org.talend.designer.core.model.utils.emf.component.IMPORTType in project tdi-studio-se by Talend.
the class RemoveRoutineJarDependencyTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
if (getProject().getLanguage() == ECodeLanguage.JAVA) {
RoutineItem routineItem = (RoutineItem) item;
if (routineItem.isBuiltIn()) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
EList<IMPORTType> imports = routineItem.getImports();
List<Object> toRemove = new ArrayList<Object>();
for (IMPORTType importElement : imports) {
if ("org.talend.dataquality.parser.jar".equals(importElement.getMODULE())) {
//$NON-NLS-1$
toRemove.add(importElement);
}
}
if (toRemove.size() > 0) {
imports.removeAll(toRemove);
ProxyRepositoryFactory.getInstance().save(routineItem);
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
} else {
return ExecutionResult.NOTHING_TO_DO;
}
}
use of org.talend.designer.core.model.utils.emf.component.IMPORTType in project tdi-studio-se by Talend.
the class ExportProjectsAsAction method getLinksFromProject.
/**
* DOC zwang Comment method "getLinksFromProject".
*
* @param project
* @return
*/
private List<LinkTargetStore> getLinksFromProject(Project project) {
List<IMPORTType> imports = null;
String linkTarget = null;
RootContainer<String, IRepositoryViewObject> routines = getRoutineFromProject(project);
List<LinkTargetStore> paths = new ArrayList<LinkTargetStore>();
String language = project.getLanguage().getName().trim();
for (IRepositoryViewObject obj : routines.getMembers()) {
RoutineItem routine = (RoutineItem) obj.getProperty().getItem();
imports = routine.getImports();
if (language != null) {
if (project != null && ECodeLanguage.JAVA.getName().equals(language)) {
IPath containerPath = getContainerFullPath(project.getTechnicalLabel());
for (IMPORTType importType : imports) {
try {
LinkTargetStore store = new LinkTargetStore();
IPath newFilePath = containerPath.append(ExportProjectsAsAction.LIB + java.io.File.separatorChar + ECodeLanguage.JAVA.getName() + java.io.File.separatorChar + importType.getMODULE());
linkTarget = EXTERNAL_LIB_JAVA_PATH + java.io.File.separatorChar + importType.getMODULE();
URI path = new URI(linkTarget.replace(java.io.File.separatorChar, '/'));
store.file = ResourcesPlugin.getWorkspace().getRoot().getFile(newFilePath);
store.uri = path;
paths.add(store);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
}
}
return paths;
}
use of org.talend.designer.core.model.utils.emf.component.IMPORTType in project tdi-studio-se by Talend.
the class ImportModuleManagerTest method testGetImportTypes.
@Test
public void testGetImportTypes() {
manager = ImportModuleManager.getInstance();
initTestImportsType();
List<IMPORTType> importTypes = manager.getImportTypes(testImportsType);
assertNotNull(importTypes);
assertTrue(importTypes.size() == 3);
IMPORTType importType1 = importTypes.get(0);
//$NON-NLS-1$
assertEquals("test-jar1.jar", importType1.getMODULE());
//$NON-NLS-1$
assertEquals("x > 0", importType1.getREQUIREDIF());
IMPORTType importType2 = importTypes.get(1);
//$NON-NLS-1$
assertEquals("test-jar2.jar", importType2.getMODULE());
//$NON-NLS-1$
assertEquals("y > 0", importType2.getREQUIREDIF());
IMPORTType importType3 = importTypes.get(2);
//$NON-NLS-1$
assertEquals("test-jar3.jar", importType3.getMODULE());
//$NON-NLS-1$
assertEquals("z > 0 AND (x > y)", importType3.getREQUIREDIF());
}
Aggregations