use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.
the class ComponentSettingsView method getCategories.
/**
* yzhang Comment method "getCategories".
*
* @param elem
* @return
*/
private EComponentCategory[] getCategories(Element elem) {
if (elem instanceof Connection) {
EComponentCategory[] categories = EElementType.CONNECTION.getCategories();
if (PluginChecker.isTeamEdition()) {
Object propertyValue = elem.getPropertyValue(Connection.LINESTYLE_PROP);
if (propertyValue instanceof EConnectionType && ((EConnectionType) propertyValue).hasConnectionCategory(IConnectionCategory.FLOW)) {
// if (((Connection) elem).checkTraceShowEnable()) {
final List<EComponentCategory> list = new ArrayList<EComponentCategory>(Arrays.asList(categories));
boolean isMRProcess = false;
IProcess process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
isMRProcess = true;
}
}
boolean isStormProcess = false;
process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
isStormProcess = true;
}
}
// mrjob and stormjob not add breakpoint
if (!isStormProcess && !isMRProcess) {
list.add(EComponentCategory.BREAKPOINT);
}
if (elem.getElementParameter(EParameterName.DEPARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.PARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.REPARTITIONER.getName()) != null) {
list.add(EComponentCategory.PARALLELIZATION);
}
// if it mr group line then add errorRecovery
if (isMRProcess && isMrGroupLine(elem)) {
list.add(EComponentCategory.RESUMING);
}
return list.toArray(new EComponentCategory[0]);
// }
} else if (propertyValue.equals(EConnectionType.ON_COMPONENT_OK) || propertyValue.equals(EConnectionType.ON_COMPONENT_ERROR) || propertyValue.equals(EConnectionType.RUN_IF) || propertyValue.equals(EConnectionType.ON_SUBJOB_OK) || propertyValue.equals(EConnectionType.ON_SUBJOB_ERROR) || propertyValue.equals(EConnectionType.ROUTE_WHEN) || propertyValue.equals(EConnectionType.ROUTE_CATCH) || propertyValue.equals(EConnectionType.STARTS)) {
boolean isMRProcess = false;
IProcess process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
isMRProcess = true;
}
}
boolean isStormProcess = false;
process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
isStormProcess = true;
}
}
int length = categories.length;
EComponentCategory[] newCategories;
boolean isNormalJobNeedRecovery = (!isMRProcess && !isStormProcess && !isAvoidRecoveryByConditions(elem));
boolean isMrStormJobNeedRecovery = isMRProcess || isStormProcess;
if (isNeedRecoveryCategory(propertyValue, isNormalJobNeedRecovery, isMrStormJobNeedRecovery)) {
newCategories = new EComponentCategory[length + 1];
for (int i = 0; i < length; i++) {
newCategories[i] = categories[i];
}
EComponentCategory resuming = EComponentCategory.RESUMING;
newCategories[length] = resuming;
} else {
newCategories = new EComponentCategory[length];
for (int i = 0; i < length; i++) {
newCategories[i] = categories[i];
}
}
return newCategories;
}
}
return categories;
} else if (elem instanceof Node) {
// if (isAdvancedType(elem)) {
if (((Node) elem).isELTComponent()) {
if (//$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Output") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Input") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Map") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("TableList") && !((Node) elem).getComponent().getName().endsWith("ColumnList")) {
//$NON-NLS-1$
return EElementType.ELT_NODE.getCategories();
}
}
EComponentCategory[] categories = EElementType.ADVANCED_NODE.getCategories();
// add for bug TDI-8476
if (((Node) elem).getComponent() != null) {
String paletteType = ((Node) elem).getComponent().getPaletteType();
if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(paletteType)) {
categories = EElementType.NODE.getCategories();
}
}
if (PluginChecker.isValidationrulesPluginLoaded() && isSupportValidationRuleNode((Node) elem)) {
// show
EComponentCategory[] newCategories = new EComponentCategory[categories.length + 1];
System.arraycopy(categories, 0, newCategories, 0, categories.length);
newCategories[categories.length] = EComponentCategory.VALIDATION_RULES;
return newCategories;
}
return categories;
} else if (elem instanceof Note) {
return EElementType.NOTE.getCategories();
} else if (elem instanceof SubjobContainer) {
return EElementType.SUBJOB.getCategories();
} else if (elem instanceof ConnectionLabel) {
return getCategories(((ConnectionLabel) elem).getConnection());
}
return null;
}
use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.
the class DisableUseBatchWhenRejectLineExists method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
List<String> filterList = Arrays.asList("tFirebirdOutput", "tGreenplumOutput", "tIngresOutput", "tInterbaseOutput", "tParAccelOutput", "tPostgresPlusOutput", "tSQLiteOutput", "tRedshiftOutput");
List<String> filterListMore = Arrays.asList("tTeradataOutput", "tOracleOutput");
IComponentConversion disableUseBatchWhenRejectLineExists = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType useBatch = ComponentUtilities.getNodeProperty(node, "USE_BATCH");
List<ConnectionType> list = ComponentUtilities.getNodeOutputConnections(node);
for (ConnectionType connType : list) {
EConnectionType eConnType = EConnectionType.getTypeFromId(connType.getLineStyle());
if (eConnType == EConnectionType.FLOW_MAIN && connType.getConnectorName().equals("REJECT")) {
if (useBatch == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH", "CHECK");
}
ComponentUtilities.getNodeProperty(node, "USE_BATCH").setValue("false");
break;
}
}
}
};
IComponentConversion disableUseBatchWhenRejectLineExistsMore = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType useBatch = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
ElementParameterType useBatchAndUseExistingConn = ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN");
List<ConnectionType> list = ComponentUtilities.getNodeOutputConnections(node);
for (ConnectionType connType : list) {
EConnectionType eConnType = EConnectionType.getTypeFromId(connType.getLineStyle());
if (eConnType == EConnectionType.FLOW_MAIN && connType.getConnectorName().equals("REJECT")) {
if (useBatch == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
}
if (useBatchAndUseExistingConn == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_AND_USE_CONN", "CHECK");
}
ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN").setValue("false");
break;
}
}
}
};
for (String componentName : filterList) {
IComponentFilter filter = new NameComponentFilter(componentName);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(disableUseBatchWhenRejectLineExists));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
for (String componentName : filterListMore) {
IComponentFilter filter = new NameComponentFilter(componentName);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(disableUseBatchWhenRejectLineExistsMore));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.
the class SetParallelizationCommand method setDeparallelization.
private void setDeparallelization(INode node) {
if (node.isActivate()) {
for (IConnection con : node.getIncomingConnections()) {
EConnectionType lineStyle = con.getLineStyle();
if (lineStyle.hasConnectionCategory(IConnectionCategory.DATA)) {
con.getElementParameter(EParameterName.PARTITIONER.getName()).setValue(Boolean.FALSE);
con.getElementParameter(EParameterName.REPARTITIONER.getName()).setValue(Boolean.FALSE);
con.getElementParameter(EParameterName.NONE.getName()).setValue(Boolean.FALSE);
con.setPropertyValue(EParameterName.DEPARTITIONER.getName(), Boolean.TRUE);
}
}
if (node.getOutgoingConnections().size() > 0) {
setParallelization(node);
}
}
}
use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.
the class DisableParallelizationCommand method disableParallelization.
private void disableParallelization(INode node) {
if (node.getOutgoingConnections().size() > 0) {
for (IConnection con : node.getOutgoingConnections()) {
EConnectionType lineStyle = con.getLineStyle();
if (lineStyle.hasConnectionCategory(IConnectionCategory.DATA)) {
con.getElementParameter(EParameterName.REPARTITIONER.getName()).setValue(Boolean.FALSE);
con.getElementParameter(EParameterName.DEPARTITIONER.getName()).setValue(Boolean.FALSE);
con.getElementParameter(EParameterName.PARTITIONER.getName()).setValue(Boolean.FALSE);
con.setPropertyValue(EParameterName.NONE.getName(), Boolean.TRUE);
if (con.getTarget() != null) {
disableParallelization(con.getTarget());
}
} else {
node = con.getTarget();
disableParallelization(node);
}
}
}
}
use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.
the class Component method createConnectors.
@Override
public List<INodeConnector> createConnectors(INode parentNode) {
List<INodeConnector> listConnector = new ArrayList<>();
ComponentProperties componentProperties = ComponentsUtils.getComponentProperties(getName());
Set<? extends Connector> inputConnectors = componentProperties.getPossibleConnectors(false);
if (inputConnectors.isEmpty()) {
INodeConnector connector = null;
connector = addStandardType(listConnector, EConnectionType.FLOW_MAIN, parentNode);
connector.setMaxLinkInput(0);
connector.setMaxLinkOutput(0);
} else {
for (Connector connector : inputConnectors) {
addGenericType(listConnector, EConnectionType.FLOW_MAIN, connector.getName(), parentNode, componentProperties, false);
}
}
Set<? extends Connector> outputConnectors = componentProperties.getPossibleConnectors(true);
List<? extends Connector> sortedOutputConnectors = new ArrayList<>(outputConnectors);
sortedOutputConnectors.sort(new Comparator<Connector>() {
@Override
public int compare(Connector o1, Connector o2) {
if (Connector.MAIN_NAME.equals(o1.getName())) {
return -1;
}
if (Connector.MAIN_NAME.equals(o2.getName())) {
return 1;
}
return 0;
}
});
for (Connector connector : sortedOutputConnectors) {
EConnectionType type = EConnectionType.FLOW_MAIN;
if (Connector.REJECT_NAME.equals(connector.getName())) {
type = EConnectionType.REJECT;
}
addGenericType(listConnector, type, connector.getName(), parentNode, componentProperties, true);
}
addStandardType(listConnector, EConnectionType.RUN_IF, parentNode);
addStandardType(listConnector, EConnectionType.ON_COMPONENT_OK, parentNode);
addStandardType(listConnector, EConnectionType.ON_COMPONENT_ERROR, parentNode);
addStandardType(listConnector, EConnectionType.ON_SUBJOB_OK, parentNode);
addStandardType(listConnector, EConnectionType.ON_SUBJOB_ERROR, parentNode);
Set<ConnectorTopology> topologies = componentDefinition.getSupportedConnectorTopologies();
createIterateConnectors(topologies, listConnector, parentNode);
for (int i = 0; i < EConnectionType.values().length; i++) {
EConnectionType currentType = EConnectionType.values()[i];
if ((currentType == EConnectionType.FLOW_REF) || (currentType == EConnectionType.FLOW_MERGE)) {
continue;
}
boolean exists = false;
for (INodeConnector curNodeConn : listConnector) {
if (curNodeConn.getDefaultConnectionType().equals(currentType)) {
exists = true;
if (currentType == EConnectionType.FLOW_MAIN) {
curNodeConn.addConnectionProperty(EConnectionType.FLOW_REF, EConnectionType.FLOW_REF.getRGB(), EConnectionType.FLOW_REF.getDefaultLineStyle());
curNodeConn.addConnectionProperty(EConnectionType.FLOW_MERGE, EConnectionType.FLOW_MERGE.getRGB(), EConnectionType.FLOW_MERGE.getDefaultLineStyle());
}
}
}
if (!exists) {
// will add by default all connectors not defined in
NodeConnector nodeConnector = new NodeConnector(parentNode);
nodeConnector.setDefaultConnectionType(currentType);
nodeConnector.setName(currentType.getName());
nodeConnector.setBaseSchema(currentType.getName());
nodeConnector.addConnectionProperty(currentType, currentType.getRGB(), currentType.getDefaultLineStyle());
nodeConnector.setLinkName(currentType.getDefaultLinkName());
nodeConnector.setMenuName(currentType.getDefaultMenuName());
if ((currentType == EConnectionType.PARALLELIZE) || (currentType == EConnectionType.SYNCHRONIZE)) {
nodeConnector.setMaxLinkInput(1);
} else {
nodeConnector.setMaxLinkInput(0);
}
nodeConnector.setMaxLinkOutput(0);
nodeConnector.setMinLinkInput(0);
nodeConnector.setMinLinkOutput(0);
listConnector.add(nodeConnector);
}
}
return listConnector;
}
Aggregations