use of org.talend.designer.core.ICamelDesignerCoreService 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.ICamelDesignerCoreService in project tdi-studio-se by Talend.
the class CreateComponentOnLinkHelper method canCreateNodeOnLink.
public static boolean canCreateNodeOnLink(org.talend.designer.core.ui.editor.connections.Connection connection, Node node) {
if (connection != null && node != null) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (camelService.isRouteBuilderNode(node)) {
return camelService.canCreateNodeOnLink(connection, node);
}
}
INode source = connection.getSource();
INodeConnector sourceConnector = connection.getSourceNodeConnector();
INode target = connection.getTarget();
INodeConnector targetConnector = node.getConnectorFromType(EConnectionType.FLOW_MAIN);
for (INodeConnector connector : node.getConnectorsFromType(EConnectionType.FLOW_MAIN)) {
if (connector.getMaxLinkOutput() != 0) {
targetConnector = connector;
break;
}
}
EConnectionType outputConnectionType = node.getConnectorFromName(targetConnector.getName()).getDefaultConnectionType();
// only consider Flow connection
EConnectionType connectionType = source.getConnectorFromName(sourceConnector.getName()).getDefaultConnectionType();
if (connectionType.hasConnectionCategory(EConnectionType.FLOW)) {
boolean b1 = ConnectionManager.canConnectToTarget(source, null, node, connectionType, sourceConnector.getName(), null);
boolean b2 = ConnectionManager.canConnectToSource(source, node, target, outputConnectionType, targetConnector.getName(), null, true);
return b1 && b2;
}
}
return false;
}
use of org.talend.designer.core.ICamelDesignerCoreService in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method addDependenciesSourceCode.
protected void addDependenciesSourceCode(ExportFileResource[] process, ExportFileResource resource, boolean needSource) {
if (!needSource) {
return;
}
try {
// get different routines.
IRunProcessService service = CorePlugin.getDefault().getRunProcessService();
ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
if (talendProcessJavaProject == null) {
return;
}
IFolder srcFolder = talendProcessJavaProject.getSrcFolder();
IFolder systemRoutineFolder = srcFolder.getFolder(SYSTEM_ROUTINES_PATH);
List<URL> systemRoutinesFileUrls = new ArrayList<URL>();
if (systemRoutineFolder.exists()) {
for (IResource fileResource : systemRoutineFolder.members()) {
if (fileResource instanceof IFile && ((IFile) fileResource).getFileExtension().equals(ECodeLanguage.JAVA.getExtension())) {
systemRoutinesFileUrls.add(fileResource.getLocationURI().toURL());
}
}
resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + SYSTEM_ROUTINES_PATH, systemRoutinesFileUrls);
}
// bug TDI-8647
// empty and re-use it
systemRoutinesFileUrls.clear();
systemRoutineFolder = srcFolder.getFolder(SYSTEM_ROUTINES_PATH + PATH_SEPARATOR + JavaUtils.JAVA_SYSTEM_ROUTINES_API_DIRECTORY);
if (systemRoutineFolder.exists()) {
for (IResource fileResource : systemRoutineFolder.members()) {
if (fileResource instanceof IFile && ((IFile) fileResource).getFileExtension().equals(ECodeLanguage.JAVA.getExtension())) {
systemRoutinesFileUrls.add(fileResource.getLocationURI().toURL());
}
}
resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + SYSTEM_ROUTINES_PATH + PATH_SEPARATOR + JavaUtils.JAVA_SYSTEM_ROUTINES_API_DIRECTORY, systemRoutinesFileUrls);
}
// add for routines
boolean useBeans = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (camelService.isInstanceofCamel(process[0].getItem())) {
useBeans = true;
}
}
addRoutinesSourceCodes(process, resource, talendProcessJavaProject, useBeans);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.talend.designer.core.ICamelDesignerCoreService in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method collectRoutines.
protected Collection<IRepositoryViewObject> collectRoutines(ExportFileResource[] process, String type) {
List<IRepositoryViewObject> toReturn = new ArrayList<IRepositoryViewObject>();
if (USER_BEANS_PATH.equals(type)) {
ERepositoryObjectType beansType = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService service = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
beansType = service.getBeansType();
}
try {
toReturn = ProxyRepositoryFactory.getInstance().getAll(beansType);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
toReturn = Collections.emptyList();
}
} else {
Set<String> allRoutinesNames = new HashSet<String>();
ERepositoryObjectType objectType = ERepositoryObjectType.ROUTINES;
if (USER_PIGUDF_PATH.equals(type)) {
objectType = ERepositoryObjectType.PIG_UDF;
}
if (ERepositoryObjectType.ROUTINES == objectType) {
for (ExportFileResource resource : process) {
if (resource.getItem() instanceof ProcessItem) {
Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
if (routinesNeededForJob != null) {
allRoutinesNames.addAll(routinesNeededForJob);
}
}
}
} else {
for (ExportFileResource resource : process) {
if (resource.getItem() instanceof ProcessItem) {
Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getPigudfNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
if (routinesNeededForJob != null) {
allRoutinesNames.addAll(routinesNeededForJob);
}
}
}
}
if (allRoutinesNames.isEmpty()) {
toReturn.addAll(RoutinesUtil.getCurrentSystemRoutines());
} else {
toReturn.addAll(collectRoutinesFromRepository(allRoutinesNames, objectType));
}
}
return toReturn;
}
use of org.talend.designer.core.ICamelDesignerCoreService in project tdi-studio-se by Talend.
the class ConnectionCreateCommand method execute.
@Override
public void execute() {
canExecute();
if (connectionName == null) {
// ask for the name if there is no
final INodeConnector mainConnector;
EConnectionType connecType;
if (source.isELTComponent()) {
connecType = EConnectionType.TABLE;
} else if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(source.getComponent().getType())) {
connecType = EConnectionType.ROUTE;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
connecType = camelService.getTargetConnectionType(source);
} else {
connecType = EConnectionType.ROUTE;
}
} else {
connecType = EConnectionType.FLOW_MAIN;
}
mainConnector = NodeUtil.getValidConnector(source);
if (source.getConnectorFromName(connectorName).isMultiSchema()) {
boolean connectionOk = false;
while (!connectionOk) {
connectionName = askForConnectionName(source.getLabel(), connectionName);
if (StringUtils.isEmpty(connectionName)) {
creatingConnection = false;
connectionName = null;
dispose();
return;
}
metaName = connectionName;
newMetadata = getNewMetadataTable();
newMetadata.setTableName(connectionName);
newMetadata.setLabel(connectionName);
newMetadata.setAttachedConnector(connectorName);
if ((connecType.equals(EConnectionType.TABLE) || source.getProcess().checkValidConnectionName(connectionName)) && (ConnectionManager.canConnectToTarget(source, null, target, source.getConnectorFromName(connectorName).getDefaultConnectionType(), connectorName, connectionName))) {
connectionOk = true;
} else {
String message = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"ConnectionCreateAction.errorCreateConnectionName", connectionName);
//$NON-NLS-1$
MessageDialog.openError(null, Messages.getString("ConnectionCreateAction.error"), message);
}
}
// add for feature TDI-17358
//$NON-NLS-1$
IElementParameter elementParameter = source.getElementParameter("SCHEMAS");
if (elementParameter != null) {
Map<String, Object> map = new HashMap<String, Object>();
Object[] itemsValue = elementParameter.getListItemsValue();
String[] items = elementParameter.getListItemsDisplayCodeName();
map.put(IEbcdicConstant.FIELD_CODE, newMetadata.getTableName());
map.put(IEbcdicConstant.FIELD_SCHEMA, newMetadata.getTableName());
for (int i = 1; i < items.length; i++) {
map.put(items[i], ((IElementParameter) itemsValue[i]).getValue());
}
Object value = elementParameter.getValue();
if (value instanceof List) {
List list = (List) value;
list.add(map);
}
ComponentSettings.switchToCurComponentSettingsView();
}
} else {
newMetadata = null;
if (source.isELTComponent()) {
if (source.getElementParameter("ELT_SCHEMA_NAME") != null) {
connectionName = askForConnectionSchemaAndTableName(source.getLabel(), connectionName);
} else {
connectionName = askForConnectionName(source.getLabel(), connectionName);
}
} else if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(source.getComponent().getType())) {
connectionName = ConnectionUtil.generateUniqueConnectionName(connecType, source.getProcess(), source.getConnectorFromType(connecType));
} else {
IMetadataTable metaTable = source.getMetadataFromConnector(mainConnector.getName());
if (metaTable != null) {
metaName = metaTable.getTableName();
}
String baseName = source.getConnectionName();
if (source.getProcess().checkValidConnectionName(baseName)) {
connectionName = source.getProcess().generateUniqueConnectionName(baseName);
}
}
}
}
if (insertTMap) {
metaName = connectionName;
newMetadata = getNewMetadataTable();
newMetadata.setTableName(connectionName);
newMetadata.setLabel(connectionName);
newMetadata.setAttachedConnector(connectorName);
}
// Default not monitor the connection
boolean monitorConnection = false;
if (newLineStyle == null) {
newLineStyle = source.getConnectorFromName(connectorName).getDefaultConnectionType();
}
if (connection == null) {
if (newMetadata != null) {
// add for eltmap
if (source instanceof Node && source.isELTMapComponent()) {
for (IMetadataTable metaTable : source.getMetadataList()) {
String tableName = metaTable.getTableName();
if (tableName != null && source.getProcess().checkValidConnectionName(tableName)) {
source.getProcess().addUniqueConnectionName(tableName);
}
}
}
source.getMetadataList().add(newMetadata);
this.connection = new Connection(source, target, newLineStyle, connectorName, metaName, connectionName, monitorConnection);
} else {
this.connection = new Connection(source, target, newLineStyle, connectorName, metaName, connectionName, metaName, monitorConnection);
}
} else {
// in case of redo, reuse the same instance
if (newMetadata != null) {
source.getMetadataList().add(newMetadata);
}
connection.reconnect(source, target, newLineStyle);
}
INodeConnector nodeConnectorSource, nodeConnectorTarget;
nodeConnectorSource = connection.getSourceNodeConnector();
nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() + 1);
nodeConnectorTarget = connection.getTargetNodeConnector();
nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() + 1);
creatingConnection = false;
((Process) source.getProcess()).checkStartNodes();
source.checkAndRefreshNode();
boolean isJoblet = false;
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (jobletService != null && jobletService.isJobletComponent(target)) {
jobletService.upateJobletComonentList(target);
isJoblet = true;
}
}
if (!isJoblet) {
target.checkAndRefreshNode();
}
}
Aggregations