use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method codeSync.
private void codeSync() {
IProcess2 process = getProcess();
if (!(process.getProperty().getItem() instanceof ProcessItem)) {
// shouldn't work for joblet
return;
}
if (jobletEditor == getEditor(oldPageIndex)) {
// added for routines code generated switch editor 0 to 3.
ProcessItem processItem = (ProcessItem) process.getProperty().getItem();
covertJobscriptOnPageChange();
ParametersType parameters = processItem.getProcess().getParameters();
if (parameters != null && parameters.getRoutinesParameter() != null && parameters.getRoutinesParameter().size() == 0) {
try {
List<RoutinesParameterType> dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
parameters.getRoutinesParameter().addAll(dependenciesInPreference);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
// if some code has been generated already, for the editor we should need only the main job, not the childs.
try {
boolean lastGeneratedWithStats = ProcessorUtilities.getLastGeneratedWithStats(process.getId());
boolean lastGeneratedWithTrace = ProcessorUtilities.getLastGeneratedWithTrace(process.getId());
if (processor.isCodeGenerated()) {
ProcessorUtilities.generateCode(process, process.getContextManager().getDefaultContext(), lastGeneratedWithStats, lastGeneratedWithTrace, true, ProcessorUtilities.GENERATE_MAIN_ONLY);
} else {
ProcessorUtilities.generateCode(process, process.getContextManager().getDefaultContext(), lastGeneratedWithStats, lastGeneratedWithTrace, true, ProcessorUtilities.GENERATE_WITH_FIRST_CHILD);
}
} catch (ProcessorException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method generateCode.
/**
* DOC bqian Comment method "generateCode".
*/
protected void generateCode() {
final IProcess2 process = getProcess();
if (!(process.getProperty().getItem() instanceof ProcessItem)) {
// shouldn't work for joblet
return;
}
if (process.getGeneratingNodes().size() != 0) {
Job job = new //$NON-NLS-1$
AccessingEmfJob(//$NON-NLS-1$
"Generating code") {
@Override
protected IStatus doRun(IProgressMonitor monitor) {
try {
ProcessorUtilities.generateCode(process, process.getContextManager().getDefaultContext(), false, false, true, ProcessorUtilities.GENERATE_WITH_FIRST_CHILD);
} catch (ProcessorException e) {
ExceptionHandler.process(e);
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.setPriority(Job.BUILD);
// start as soon as possible
job.schedule();
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class Connection method init.
private void init(INode source, INode target, EConnectionType lineStyle, String connectorName, String metaName, String linkName, final boolean monitorConnection) {
if (lineStyle.equals(EConnectionType.ITERATE)) {
performance = new IterateConnectionPerformance(this);
} else if (lineStyle.hasConnectionCategory(IConnectionCategory.DEPENDENCY)) {
// "OnComponentOK/OnComponentError/OnSubJobOK/OnSubJobError/If"
performance = new LiteralConnectionPerformance(this);
} else if (ComponentCategory.CATEGORY_4_SPARK.getName().equals(source.getProcess().getComponentsType())) {
performance = new SparkBatchConnectionPerformance(this);
} else {
// if no parallel execution existed, just delegate to super class.
performance = new ParallelConnectionPerformance(this);
}
this.connectorName = connectorName;
this.lineStyle = lineStyle;
this.metaName = metaName;
this.monitorConnection = monitorConnection;
resuming = new ConnectionResuming(this);
if (lineStyle.hasConnectionCategory(IConnectionCategory.FLOW)) {
trace = new ConnectionTrace(this);
createTraceParamters();
IComponent component = ComponentsFactoryProvider.getInstance().get("tFlowMeter", //$NON-NLS-1$
ComponentCategory.CATEGORY_4_DI.getName());
if (component != null) {
// only if tFlowMeter is available and not M/R job
IProcess process = source.getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (!ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
createMeterParameters(process2);
}
}
}
}
setName(linkName);
if (trace != null) {
trace.setOffset(label.getOffset());
}
if (resuming != null) {
resuming.setOffset(label.getOffset());
}
if (source.getProcess().getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName()) && ComponentsFactoryProvider.getInstance().get("tPartitioner", ComponentCategory.CATEGORY_4_DI.getName()) != null) {
this.source = source;
createParallelizeParameters();
}
reconnect(source, target, lineStyle);
updateName();
if (lineStyle.equals(EConnectionType.RUN_IF)) {
ElementParameter param = new ElementParameter(this);
switch(LanguageManager.getCurrentLanguage()) {
case JAVA:
param.setFieldType(EParameterFieldType.MEMO_JAVA);
break;
default:
param.setFieldType(EParameterFieldType.MEMO_PERL);
}
param.setCategory(EComponentCategory.BASIC);
//$NON-NLS-1$
param.setValue("");
param.setNbLines(5);
param.setName(EParameterName.CONDITION.getName());
param.setDisplayName(EParameterName.CONDITION.getDisplayName());
param.setShow(true);
param.setNumRow(1);
param.setDefaultValue(param.getValue());
addElementParameter(param);
}
if (lineStyle.equals(EConnectionType.ROUTE_WHEN)) {
String[] strList = { "constant", "el", "groovy", "header", "javaScript", "jxpath", "mvel", "ognl", "php", "property", "python", "ruby", "simple", "spel", "sql", "xpath", "xquery" };
IElementParameter supportedLanguages = source.getElementParameter("ROUTE_WHEN_LANGUAGES");
if (supportedLanguages != null) {
Object[] values = supportedLanguages.getListItemsValue();
if (values != null) {
strList = new String[values.length];
System.arraycopy(values, 0, strList, 0, values.length);
}
}
IElementParameter param = new ElementParameter(this);
param.setCategory(EComponentCategory.BASIC);
param.setName(EParameterName.ROUTETYPE.getName());
param.setDisplayName(EParameterName.ROUTETYPE.getDisplayName());
param.setListItemsValue(strList);
param.setListItemsDisplayName(strList);
param.setListItemsDisplayCodeName(strList);
param.setNbLines(1);
param.setFieldType(EParameterFieldType.CLOSED_LIST);
param.setValue(supportedLanguages.getValue());
param.setShow(true);
param.setNumRow(1);
addElementParameter(param);
param = new ElementParameter(this);
switch(LanguageManager.getCurrentLanguage()) {
case JAVA:
param.setFieldType(EParameterFieldType.MEMO_JAVA);
break;
default:
param.setFieldType(EParameterFieldType.MEMO_PERL);
}
param.setCategory(EComponentCategory.BASIC);
//$NON-NLS-1$
param.setValue("");
param.setNbLines(5);
param.setName(EParameterName.CONDITION.getName());
param.setDisplayName(EParameterName.CONDITION.getDisplayName());
param.setShow(true);
param.setNumRow(2);
addElementParameter(param);
// TESB-8043
if ("cMessageRouter".equals(source.getComponent().getName())) {
param = new ElementParameter(this);
param.setFieldType(EParameterFieldType.CHECK);
param.setCategory(EComponentCategory.BASIC);
//$NON-NLS-1$
param.setValue("false");
param.setName(EParameterName.ENDOFCHOICE.getName());
param.setDisplayName(EParameterName.ENDOFCHOICE.getDisplayName());
param.setShow(true);
param.setNumRow(1);
addElementParameter(param);
param = new ElementParameter(this);
param.setFieldType(EParameterFieldType.CHECK);
param.setCategory(EComponentCategory.BASIC);
param.setValue("false");
param.setName(EParameterName.USE_NAMESPACES.getName());
param.setDisplayName(EParameterName.USE_NAMESPACES.getDisplayName());
param.setShowIf(EParameterName.ROUTETYPE.getName() + "=='xpath'");
param.setShow(true);
param.setNumRow(17);
addElementParameter(param);
param = new ElementParameter(this);
param.setFieldType(EParameterFieldType.TABLE);
param.setCategory(EComponentCategory.BASIC);
param.setName(EParameterName.NAMESPACES.getName());
param.setDisplayName(EParameterName.NAMESPACES.getDisplayName());
param.setShow(true);
param.setShowIf("(" + EParameterName.ROUTETYPE.getName() + "=='xpath') AND (" + EParameterName.USE_NAMESPACES.getName() + " == 'true')");
param.setNumRow(18);
String[] columns = new String[] { EParameterName.PREFIX.getName(), EParameterName.URI.getName() };
param.setListItemsDisplayCodeName(columns);
param.setListItemsDisplayName(new String[] { EParameterName.PREFIX.getDisplayName(), EParameterName.URI.getName() });
ElementParameter p = new ElementParameter(this);
p.setFieldType(EParameterFieldType.TEXT);
p.setName(EParameterName.PREFIX.getName());
ElementParameter p1 = new ElementParameter(this);
p1.setFieldType(EParameterFieldType.TEXT);
p1.setName(EParameterName.URI.getName());
param.setListItemsValue(new ElementParameter[] { p, p1 });
param.setValue(new ArrayList<Map<String, Object>>());
addElementParameter(param);
param = new ElementParameter(this);
param.setFieldType(EParameterFieldType.LABEL);
param.setCategory(EComponentCategory.BASIC);
param.setName("WARNING");
param.setDisplayName(EParameterName.LANGUAGEWARNING.getDisplayName());
param.setShow(true);
param.setShowIf("(" + EParameterName.ROUTETYPE.getName() + "=='xpath') AND (" + EParameterName.USE_NAMESPACES.getName() + " == 'true')");
param.setValue(EParameterName.LANGUAGEWARNING.getDisplayName());
param.setNumRow(19);
addElementParameter(param);
}
}
if (lineStyle.equals(EConnectionType.ROUTE_CATCH)) {
IElementParameter param = new ElementParameter(this);
param.setCategory(EComponentCategory.BASIC);
param.setName(EParameterName.EXCEPTIONLIST.getName());
param.setDisplayName(EParameterName.EXCEPTIONLIST.getDisplayName());
param.setNbLines(5);
param.setFieldType(EParameterFieldType.TEXT);
param.setShow(true);
param.setNumRow(1);
addElementParameter(param);
}
if (lineStyle.equals(EConnectionType.ITERATE)) {
IElementParameter param = new ElementParameter(this);
param.setFieldType(EParameterFieldType.CHECK);
param.setCategory(EComponentCategory.BASIC);
param.setValue(Boolean.FALSE);
param.setName(ENABLE_PARALLEL);
//$NON-NLS-1$
param.setDisplayName(Messages.getString("Connection.enableParallel"));
param.setShow(true);
param.setNumRow(1);
addElementParameter(param);
param = new ElementParameter(this);
param.setFieldType(EParameterFieldType.TEXT);
param.setCategory(EComponentCategory.BASIC);
// param.setListItemsDisplayName(new String[] { "2", "3", "4" });
// param.setListItemsDisplayCodeName(new String[] { "2", "3", "4" });
// param.setListItemsValue(new String[] { "2", "3", "4" });
//$NON-NLS-1$
param.setValue("2");
param.setName(NUMBER_PARALLEL);
//$NON-NLS-1$
param.setDisplayName(Messages.getString("Connection.numberParallel"));
param.setShow(true);
//$NON-NLS-1$
param.setShowIf("ENABLE_PARALLEL == 'true'");
param.setNumRow(1);
param.setRequired(true);
addElementParameter(param);
}
// add activate parameter
ElementParameter param = new ElementParameter(this);
param.setFieldType(EParameterFieldType.CHECK);
param.setCategory(EComponentCategory.TECHNICAL);
param.setValue(Boolean.TRUE);
param.setName(EParameterName.ACTIVATE.getName());
param.setDisplayName(EParameterName.ACTIVATE.getDisplayName());
param.setShow(false);
param.setNumRow(1);
param.setDefaultValue(param.getValue());
addElementParameter(param);
param = new ElementParameter(this);
param.setName(EParameterName.UNIQUE_NAME.getName());
param.setValue(this.getUniqueName());
param.setDisplayName(EParameterName.UNIQUE_NAME.getDisplayName());
param.setFieldType(EParameterFieldType.TEXT);
param.setCategory(EComponentCategory.ADVANCED);
param.setNumRow(1);
param.setReadOnly(true);
param.setShow(false);
addElementParameter(param);
param = new ElementParameter(this);
param.setName(EParameterName.UPDATE_COMPONENTS.getName());
param.setValue(Boolean.FALSE);
param.setDisplayName(EParameterName.UPDATE_COMPONENTS.getDisplayName());
param.setFieldType(EParameterFieldType.CHECK);
param.setCategory(EComponentCategory.BASIC);
param.setNumRow(5);
param.setReadOnly(true);
param.setRequired(false);
param.setShow(false);
addElementParameter(param);
if (lineStyle.hasConnectionCategory(IConnectionCategory.FLOW)) {
initTraceParamters();
}
if (PluginChecker.isTeamEdition()) {
boolean isLocalRepository = (ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider() instanceof ILocalRepositoryFactory);
param = new ElementParameter(this);
param.setName(EParameterName.RESUMING_CHECKPOINT.getName());
param.setValue(Boolean.FALSE);
param.setGroupDisplayName(EParameterName.RESUMING_CHECKPOINT.getDisplayName());
param.setDisplayName(EParameterName.RESUMING_CHECKPOINT.getDisplayName());
param.setFieldType(EParameterFieldType.CHECK);
param.setCategory(EComponentCategory.RESUMING);
param.setGroup(RESUMING_CHECKPOINT);
param.setNumRow(2);
param.setShow(true);
param.setReadOnly(isLocalRepository);
param.setDefaultValue(param.getValue());
addElementParameter(param);
param = new ElementParameter(this);
param.setName(EParameterName.RESUMLABEL.getName());
param.setDisplayName(EParameterName.RESUMLABEL.getDisplayName());
param.setFieldType(EParameterFieldType.TEXT);
param.setCategory(EComponentCategory.RESUMING);
param.setGroup(RESUMING_CHECKPOINT);
param.setValue("");
param.setNumRow(3);
param.setShow(true);
param.setReadOnly(isLocalRepository);
param.setDefaultValue(param.getValue());
addElementParameter(param);
param = new ElementParameter(this);
param.setName(EParameterName.FAILURE_INSTRUCTIONS.getName());
param.setDisplayName(EParameterName.FAILURE_INSTRUCTIONS.getDisplayName());
param.setFieldType(EParameterFieldType.MEMO);
param.setCategory(EComponentCategory.RESUMING);
param.setGroup(RESUMING_CHECKPOINT);
param.setNbLines(5);
param.setNumRow(4);
param.setShow(true);
param.setReadOnly(isLocalRepository);
param.setDefaultValue(param.getValue());
addElementParameter(param);
// breakpoint
if (lineStyle.hasConnectionCategory(IConnectionCategory.FLOW) || lineStyle.hasConnectionCategory(IConnectionCategory.MERGE)) {
param = new ElementParameter(this);
param.setName(EParameterName.ACTIVEBREAKPOINT.getName());
param.setDisplayName(EParameterName.ACTIVEBREAKPOINT.getDisplayName());
param.setFieldType(EParameterFieldType.CHECK);
param.setCategory(EComponentCategory.BREAKPOINT);
param.setNumRow(13);
param.setValue(false);
param.setContextMode(false);
param.setDefaultValue(param.getValue());
param.setShow(true);
addElementParameter(param);
IComponent component = ComponentsFactoryProvider.getInstance().get("tFilterRow", ComponentCategory.CATEGORY_4_DI.getName());
Node tmpNode = new Node(component, (Process) source.getProcess());
tmpNode.setTemplate(source.isTemplate());
tmpNode.setGeneratedByJobscriptBool(source.isGeneratedByJobscriptBool());
tmpNode.addInput(this);
ElementParameter tmpParam = (ElementParameter) tmpNode.getElementParameter("LOGICAL_OP");
if (tmpParam != null) {
tmpParam.setElement(this);
tmpParam.setCategory(EComponentCategory.BREAKPOINT);
tmpParam.setNumRow(14);
tmpParam.setDefaultValue(tmpParam.getValue());
addElementParameter(tmpParam);
}
tmpParam = (ElementParameter) tmpNode.getElementParameter("CONDITIONS");
if (tmpParam != null) {
tmpParam.setElement(this);
tmpParam.setCategory(EComponentCategory.BREAKPOINT);
tmpParam.setNumRow(15);
ColumnListController.updateColumnList(tmpNode, null, true);
tmpParam.setDefaultValue(tmpParam.getValue());
addElementParameter(tmpParam);
}
tmpParam = (ElementParameter) tmpNode.getElementParameter("USE_ADVANCED");
if (tmpParam != null) {
tmpParam.setElement(this);
tmpParam.setCategory(EComponentCategory.BREAKPOINT);
tmpParam.setNumRow(16);
tmpParam.setDefaultValue(tmpParam.getValue());
addElementParameter(tmpParam);
}
tmpParam = (ElementParameter) tmpNode.getElementParameter("ADVANCED_COND");
if (tmpParam != null) {
tmpParam.setElement(this);
tmpParam.setCategory(EComponentCategory.BREAKPOINT);
tmpParam.setNumRow(17);
tmpParam.setDefaultValue(tmpParam.getValue());
addElementParameter(tmpParam);
}
}
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class Connection method setPropertyValue.
/*
* (non-Javadoc)
*
* @see org.talend.designer.core.ui.editor.Element#setPropertyValue(java.lang.Object, java.lang.Object)
*/
@Override
public void setPropertyValue(String id, Object value) {
if (id.equals(EParameterName.ACTIVATE.getName())) {
setActivate((Boolean) value);
}
if (id.equals(EParameterName.RESUMING_CHECKPOINT.getName())) {
setResumingConnection((Boolean) value);
}
if (id.equals(EParameterName.RESUMLABEL.getName())) {
setResumingLabelConnection(value.toString());
}
if (id.equals(EParameterName.UNIQUE_NAME.getName())) {
// parameter.setValue(value);
setUniqueName(value.toString());
}
// feature 6355
if (EParameterName.TRACES_CONNECTION_ENABLE.getName().equals(id) && value instanceof Boolean) {
setTraceConnection((Boolean) value);
}
if ((EParameterName.TRACES_SHOW_ENABLE.getName().equals(id) || EParameterName.ACTIVEBREAKPOINT.getName().equals(id)) && value instanceof Boolean) {
if (PluginChecker.isTraceDebugPluginLoaded() && (lineStyle.hasConnectionCategory(IConnectionCategory.FLOW) || lineStyle.hasConnectionCategory(IConnectionCategory.MERGE))) {
if (EParameterName.ACTIVEBREAKPOINT.getName().equals(id)) {
this.getElementParameter(EParameterName.ACTIVEBREAKPOINT.getName()).setValue(value);
}
if (this.trace != null) {
this.trace.setPropertyValue(EParameterName.ACTIVEBREAKPOINT.getName(), value);
}
firePropertyChange(EParameterName.ACTIVEBREAKPOINT.getName(), null, value);
setProcessStates();
}
}
if (EParameterName.TRACES_CONNECTION_FILTER.getName().equals(id)) {
if (this.trace != null) {
this.trace.setPropertyValue(id, value);
}
firePropertyChange(id, null, value);
setProcessStates();
}
if (id.equals(LINESTYLE_PROP)) {
// setLineStyle((EConnectionType) value);
setConnectorName((String) value);
} else {
if (id.equals(NAME)) {
setName((String) value);
} else {
super.setPropertyValue(id, value);
}
}
if (id.equals(NUMBER_PARALLEL) || id.equals(ENABLE_PARALLEL) || id.equals(EParameterName.LABEL.getName())) {
updateName();
}
if (EParameterName.REPARTITIONER.getName().equals(id) || EParameterName.PARTITIONER.getName().equals(id) || EParameterName.DEPARTITIONER.getName().equals(id) || EParameterName.NONE.getName().equals(id)) {
firePropertyChange(id, null, value);
// in case user change manual,need to check warning on time
IProcess process = this.getSource().getProcess();
if (process instanceof IProcess2) {
((IProcess2) process).checkProcess();
}
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class PropertyChangeCommand method refreshMR.
private void refreshMR(String propName) {
if (elem instanceof Node) {
Node node = (Node) elem;
if (!node.isMapReduce()) {
return;
}
if (!propName.equals("MAP_ONLY") && !propName.equals("REPLICATED_JOIN") && !propName.equals(EParameterName.GROUPBYS.getName())) {
return;
}
((IProcess2) node.getProcess()).getGeneratingNodes();
node.refreshNodeContainer();
} else if (elem instanceof IProcess2) {
IProcess2 process = (IProcess2) elem;
for (INode inode : process.getGraphicalNodes()) {
Node node = (Node) inode;
if (!node.isMapReduceStart()) {
return;
}
if (!propName.equals("DISTRIBUTION")) {
return;
}
node.refreshNodeContainer();
}
}
}
Aggregations