use of org.talend.core.ui.IJobletProviderService 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();
}
}
use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.
the class CodeView method refresh.
public void refresh() {
ICodeGeneratorService service = DesignerPlugin.getDefault().getCodeGeneratorService();
if (service.isInitializingJet()) {
return;
}
if (isGenerating()) {
return;
}
setGenerating(true);
final List<? extends INode> generatingNodes = selectedNode.getProcess().getGeneratingNodes();
Job job = new //$NON-NLS-1$
Job(//$NON-NLS-1$
Messages.getString("CodeView.initMessage")) {
@Override
protected IStatus run(IProgressMonitor monitor) {
if (selectedNode != null) {
//$NON-NLS-1$
generatedCode = "";
try {
// joblet or joblet node
boolean isJoblet = AbstractProcessProvider.isExtensionProcessForJoblet(selectedNode.getProcess());
if (!isJoblet && PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService jobletSservice = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (jobletSservice != null && jobletSservice.isJobletComponent(selectedNode)) {
isJoblet = true;
}
}
if (isJoblet) {
return org.eclipse.core.runtime.Status.OK_STATUS;
}
generatingNode = null;
for (INode node : generatingNodes) {
if (node.getUniqueName().equals(selectedNode.getUniqueName())) {
generatingNode = node;
}
}
if (generatingNode == null) {
//$NON-NLS-1$
generatedCode = Messages.getString("CodeView.MultipleComponentError");
return org.eclipse.core.runtime.Status.OK_STATUS;
}
ICodeGeneratorService service = DesignerPlugin.getDefault().getCodeGeneratorService();
// have to do this dirty change to avoid the side effect for BD component.
codeGenerator = service.createCodeGenerator(selectedNode.getProcess(), false, false);
viewStartAction.setChecked(false);
viewMainAction.setChecked(false);
viewEndAction.setChecked(false);
viewAllAction.setChecked(false);
switch(codeView) {
case CODE_START:
viewStartAction.setChecked(true);
generatedCode = codeGenerator.generateComponentCode(generatingNode, ECodePart.BEGIN);
break;
case CODE_MAIN:
viewMainAction.setChecked(true);
generatedCode = codeGenerator.generateComponentCode(generatingNode, ECodePart.MAIN);
break;
case CODE_END:
viewEndAction.setChecked(true);
generatedCode = codeGenerator.generateComponentCode(generatingNode, ECodePart.END);
break;
case CODE_ALL:
viewAllAction.setChecked(true);
generatedCode = codeGenerator.generateComponentCode(generatingNode, ECodePart.BEGIN);
generatedCode += codeGenerator.generateComponentCode(generatingNode, ECodePart.MAIN);
generatedCode += codeGenerator.generateComponentCode(generatingNode, ECodePart.END);
break;
default:
}
} catch (SystemException e) {
//$NON-NLS-1$
generatedCode = Messages.getString("CodeView.Error");
ExceptionHandler.process(e);
} catch (Exception e) {
// Some exceptions can appear in case we close some jobs while generating
// Just ignore them, and set blank directly to the code view
//$NON-NLS-1$
generatedCode = "";
}
}
return org.eclipse.core.runtime.Status.OK_STATUS;
}
};
job.setPriority(Job.INTERACTIVE);
job.schedule();
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
new UIJob("") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
document.set(generatedCode);
setGenerating(false);
return org.eclipse.core.runtime.Status.OK_STATUS;
}
}.schedule();
}
});
}
use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.
the class ComponentsFactory method reset.
@Override
public void reset() {
componentList = null;
skeletonList = null;
customComponentList = null;
Collection<IComponentFactoryFilter> filters = ComponentsFactoryProviderManager.getInstance().getProviders();
for (IComponentFactoryFilter filter : filters) {
filter.cleanCache();
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IJobletProviderService.class)) {
IJobletProviderService jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (jobletService != null) {
jobletService.clearJobletComponent();
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkJobletProviderService.class)) {
ISparkJobletProviderService jobletService = (ISparkJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkJobletProviderService.class);
if (jobletService != null) {
jobletService.clearSparkJobletComponent();
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkStreamingJobletProviderService.class)) {
ISparkStreamingJobletProviderService jobletService = (ISparkStreamingJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkStreamingJobletProviderService.class);
if (jobletService != null) {
jobletService.clearSparkStreamingJobletComponent();
}
}
}
use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.
the class ComponentListController method updateComponentList.
public static void updateComponentList(IElement elem, IElementParameter param) {
if (elem instanceof INode) {
final INode currentNode = (INode) elem;
final List<INode> nodeList;
IJobletProviderService jobletService = getJobletProviderService(param);
if (jobletService != null) {
nodeList = jobletService.getConnNodesForInputTrigger(currentNode, param);
} else {
List<? extends INode> list = null;
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService jobletProviderService = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
INode jobletNode = currentNode.getJobletNode();
if (jobletNode != null && jobletProviderService.isJobletComponent(jobletNode)) {
List<? extends INode> jobletNodes = jobletProviderService.getGraphNodesForJoblet(jobletNode);
for (INode node : jobletNodes) {
if (node != null && node.getUniqueName() != null && node.getUniqueName().equals(currentNode.getUniqueName())) {
list = node.getProcess().getNodesOfType(param.getFilter());
break;
}
}
}
}
if (list == null) {
list = currentNode.getProcess().getNodesOfType(param.getFilter());
}
nodeList = new ArrayList<INode>();
if (list != null) {
for (INode datanode : list) {
// it's possible to filter the virtual components from this list
if (!datanode.isVirtualGenerateNode() && datanode.getUniqueName() != null && !datanode.getUniqueName().equals(StatsAndLogsManager.CONNECTION_UID)) {
nodeList.add(datanode);
}
}
}
}
updateComponentList(nodeList, currentNode, param, true);
}
}
use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.
the class ConnectionManager method canConnectToTarget.
public static boolean canConnectToTarget(INode source, INode oldTarget, INode newTarget, EConnectionType lineStyle, String connectorName, String connectionName, boolean refactorJoblet) {
newlineStyle = lineStyle;
if (source.equals(newTarget)) {
return false;
}
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null) {
if (service.isTriggerNode(newTarget) && !service.canConnectTriggerNode(newTarget, lineStyle)) {
return false;
}
// can't connect from joblet's node, bug 21411
if (service.isJobletComponent(source.getJobletNode())) {
return false;
}
}
}
INode processStartNode = source.getProcessStartNode(true);
// if the target is the start of the (source) process, then can't connect.
if (processStartNode.equals(newTarget)) {
return false;
}
// to avoid different db elt input link to map.
if (newTarget.isELTComponent() && newTarget.getComponent().getName().endsWith("Map")) {
//$NON-NLS-1$
String targetName = newTarget.getComponent().getOriginalFamilyName();
String sourceName = processStartNode.getComponent().getOriginalFamilyName();
if (!targetName.equals(sourceName) && !(lineStyle.hasConnectionCategory(IConnectionCategory.DEPENDENCY))) {
return false;
}
}
// fix bug 0004935: Error on job save
if (checkCircle(source, newTarget)) {
return false;
}
if (newTarget.isFileScaleComponent()) {
if (newlineStyle.hasConnectionCategory(IConnectionCategory.FLOW) && !connectorName.equals("FSCOMBINE")) {
//$NON-NLS-1$
return false;
}
}
// Modify Connection Type depending old and new target.
if (newlineStyle.hasConnectionCategory(IConnectionCategory.FLOW)) {
// if the connection type is not the default one, then we don't change automatically.
// && newlineStyle.getName().equals(newConnectionType)) {
newlineStyle = EConnectionType.FLOW_MAIN;
if (newTarget.getComponent().useLookup()) {
int nbMain = 0;
for (IConnection connec : newTarget.getIncomingConnections()) {
if (connec.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
nbMain++;
}
}
if (nbMain >= 1) {
newlineStyle = EConnectionType.FLOW_REF;
} else {
newlineStyle = EConnectionType.FLOW_MAIN;
}
} else if (newTarget.getComponent().useMerge()) {
newlineStyle = EConnectionType.FLOW_MERGE;
}
}
boolean isJoblet = false;
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null && service.isJobletComponent(newTarget) && !lineStyle.hasConnectionCategory(IConnectionCategory.FLOW)) {
List<INodeConnector> inputConnector = service.getFreeTriggerBuiltConnectors(newTarget, lineStyle, true);
if (inputConnector.isEmpty()) {
return false;
}
isJoblet = true;
}
}
if (!isJoblet) {
INodeConnector connectorFromType = newTarget.getConnectorFromType(newlineStyle);
int maxInput = connectorFromType.getMaxLinkInput();
if (maxInput != -1 && (connectorFromType.getCurLinkNbInput() >= maxInput)) {
return false;
}
}
if (!canConnect(source, newTarget, lineStyle, connectionName, refactorJoblet)) {
return false;
}
return true;
}
Aggregations