use of org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType in project tdi-studio-se by Talend.
the class SetupProcessDependenciesRoutinesAction method createRoutinesDependencies.
private void createRoutinesDependencies(ProcessType process, List<RoutineItemRecord> routineRecords) {
if (routineRecords == null) {
return;
}
for (RoutineItemRecord r : routineRecords) {
List<RoutinesParameterType> routinesDependencies = process.getParameters().getRoutinesParameter();
boolean found = false;
for (RoutinesParameterType type : routinesDependencies) {
// if (r.isSystem() == type.isSystem()) {
if (type.getId().equals(r.getId()) || type.getName().equals(r.getName())) {
found = true;
break;
}
// }
}
if (!found) {
RoutinesParameterType itemRecordType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
itemRecordType.setName(r.getName());
itemRecordType.setId(r.getId());
process.getParameters().getRoutinesParameter().add(itemRecordType);
}
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType in project tdi-studio-se by Talend.
the class GenerateGrammarController method generateJavaFile.
/**
* Generate java source file
*
* DOC ytao Comment method "generateJavaFile".
*/
private void generateJavaFile() {
Node node = (Node) elem;
final String JOB_NAME = node.getProcess().getName().toLowerCase();
final String COMPONENT_NAME = node.getUniqueName().toLowerCase();
String javaClassName = StringUtils.capitalize(JOB_NAME) + StringUtils.capitalize(COMPONENT_NAME);
ITDQItemService service = (ITDQItemService) GlobalServiceRegister.getDefault().getService(ITDQItemService.class);
File fileCreated = null;
try {
fileCreated = service.fileCreatedInRoutines(node, javaClassName);
} catch (Exception ex) {
MessageDialog.openError(Display.getDefault().getActiveShell(), //$NON-NLS-1$
Messages.getString("GenerateGrammarController.prompt"), ex.getMessage());
}
if (fileCreated == null) {
return;
}
try {
RoutineItem returnItem = persistInRoutine(new Path(JOB_NAME), fileCreated, javaClassName);
addReferenceJavaFile(returnItem, true);
// ADD (to line 292) xwang 2011-08-12 add routine dependency in job
if (node.getProcess() instanceof org.talend.designer.core.ui.editor.process.Process) {
RoutinesParameterType r = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
r.setId(returnItem.getProperty().getId());
r.setName(returnItem.getProperty().getLabel());
List<RoutinesParameterType> routines = new ArrayList<RoutinesParameterType>();
routines.add(r);
((org.talend.designer.core.ui.editor.process.Process) node.getProcess()).addGeneratingRoutines(routines);
}
refreshProject();
} catch (Exception e) {
ExceptionHandler.process(e);
}
// remove temporary files of grammar
FilesUtils.removeFolder(new File(fileCreated.getParent()), true);
}
use of org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType in project tdi-studio-se by Talend.
the class AddRoutineDependenciesMigrationTask method execute.
@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
if (!(item instanceof ProcessItem)) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
ProcessItem item2 = (ProcessItem) item;
if (item2.getProcess().getParameters() == null || item2.getProcess().getParameters().getRoutinesParameter() == null) {
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
item2.getProcess().setParameters(parameterType);
}
List<RoutinesParameterType> routinesDependencies = (List<RoutinesParameterType>) item2.getProcess().getParameters().getRoutinesParameter();
List<RoutinesParameterType> neededRoutineDependencies = new ArrayList<RoutinesParameterType>();
neededRoutineDependencies.addAll(RoutinesUtil.createJobRoutineDependencies(true));
neededRoutineDependencies.addAll(RoutinesUtil.createJobRoutineDependencies(false));
boolean modified = false;
for (RoutinesParameterType added : neededRoutineDependencies) {
boolean found = false;
for (RoutinesParameterType type : routinesDependencies) {
if (added.getId().equals(type.getId()) || added.getName().equals(type.getName())) {
found = true;
break;
}
}
if (!found) {
routinesDependencies.add(added);
modified = true;
}
}
if (modified) {
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().save(item, true);
RelationshipItemBuilder.getInstance().addOrUpdateItem(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType 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.designer.core.model.utils.emf.talendfile.RoutinesParameterType in project tdi-studio-se by Talend.
the class NewProcessWizard method createProcessItem.
@SuppressWarnings("unchecked")
protected void createProcessItem() {
try {
property.setId(repositoryFactory.getNextId());
// changed by hqzhang for TDI-19527, label=displayName
property.setLabel(property.getDisplayName());
ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
// add depended routines.
List<RoutinesParameterType> dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
parameterType.getRoutinesParameter().addAll(dependenciesInPreference);
process.setParameters(parameterType);
processItem.setProcess(process);
repositoryFactory.create(processItem, mainPage.getDestinationPath());
} catch (PersistenceException e) {
MessageDialog.openError(getShell(), Messages.getString("NewProcessWizard.failureTitle"), //$NON-NLS-1$
Messages.getString("NewProcessWizard.failureText") + " : " + //$NON-NLS-1$ //$NON-NLS-2$
e.getMessage());
ExceptionHandler.process(e);
}
}
Aggregations