use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class SynchronizeSchemaOnlyForPerlDemoMigrationTask method execute.
/*
* (non-Javadoc)
*
* @seeorg.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
* ProcessItem)
*/
@Override
public ExecutionResult execute(Item item) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
boolean modified = false;
ECodeLanguage language = LanguageManager.getCurrentLanguage();
if (language == ECodeLanguage.PERL) {
Project project = ProjectManager.getInstance().getProject(item);
if (project != null && project.getTechnicalLabel().equalsIgnoreCase("TALENDDEMOSPERL")) {
//$NON-NLS-1$
IProcess2 process = (IProcess2) RepositoryPlugin.getDefault().getDesignerCoreService().getProcessFromItem(item);
modified = synchronizeSchema(process);
if (modified) {
ProcessType processType = process.saveXmlFile();
if (item instanceof ProcessItem) {
((ProcessItem) item).setProcess(processType);
} else if (item instanceof JobletProcessItem) {
((JobletProcessItem) item).setJobletProcess((JobletProcess) processType);
}
factory.save(item, true);
return ExecutionResult.SUCCESS_NO_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.ProcessType in project tdi-studio-se by Talend.
the class SetupProcessDependenciesRoutinesAction method doRun.
@Override
protected void doRun() {
ISelection selection = getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (obj == null) {
return;
}
RepositoryNode node = (RepositoryNode) obj;
boolean readonly = false;
IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
ERepositoryStatus status = repFactory.getStatus(node.getObject());
if (!repFactory.isPotentiallyEditable(node.getObject()) || status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.LOCK_BY_USER) {
readonly = true;
}
Item item = node.getObject().getProperty().getItem();
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
ProcessType process = processItem.getProcess();
SetupProcessDependenciesRoutinesDialog dialog = new SetupProcessDependenciesRoutinesDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), process, readonly);
if (dialog.open() == Window.OK && !readonly) {
process.getParameters().getRoutinesParameter().clear();
createRoutinesDependencies(process, dialog.getSystemRoutines());
createRoutinesDependencies(process, dialog.getUserRoutines());
try {
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().save(processItem);
RelationshipItemBuilder.getInstance().addOrUpdateItem(processItem);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobProcessItem = (JobletProcessItem) item;
ProcessType process = jobProcessItem.getJobletProcess();
SetupProcessDependenciesRoutinesDialog dialog = new SetupProcessDependenciesRoutinesDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), process, readonly);
if (dialog.open() == Window.OK && !readonly) {
process.getParameters().getRoutinesParameter().clear();
createRoutinesDependencies(process, dialog.getSystemRoutines());
createRoutinesDependencies(process, dialog.getUserRoutines());
try {
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().save(jobProcessItem);
IJobletProviderService jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (jobletService != null) {
jobletService.loadComponentsFromProviders();
}
RelationshipItemBuilder.getInstance().addOrUpdateItem(jobProcessItem);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class UpgradeParameterHelper method upgradeItem.
/**
*
* ggu Comment method "upgradeItem".
*
* upgrade the item parameters.
*/
//$NON-NLS-1$
@SuppressWarnings("unchecked")
public static boolean upgradeItem(Item item) {
if (item == null) {
return false;
}
boolean changed = false;
if (item instanceof ProcessItem) {
// job
ProcessType process = ((ProcessItem) item).getProcess();
if (process != null) {
ParametersType parameters = process.getParameters();
if (parameters != null) {
changed = upgradeMainParameters(parameters.getElementParameter());
}
changed = changed | upgradeNodes(process.getNode());
}
} else if (item instanceof JobletProcessItem) {
// Joblet
JobletProcess jobletProcess = ((JobletProcessItem) item).getJobletProcess();
if (jobletProcess != null) {
ParametersType parameters = jobletProcess.getParameters();
if (parameters != null) {
changed = upgradeMainParameters(parameters.getElementParameter());
}
changed = changed | upgradeNodes(jobletProcess.getNode());
}
}
return changed;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class TXMLMapChangeAllInOneValueMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see
* org.talend.core.model.migration.TXMLMapChangeAllInOneValueMigrationTask
* (org .talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
ProcessType processType = getProcessType(item);
boolean modified = false;
if (processType != null) {
for (Object obj : processType.getNode()) {
NodeType nodeType = (NodeType) obj;
if (nodeType.getComponentName().startsWith("tXMLMap")) {
XmlMapData xmlMapdata = (XmlMapData) nodeType.getNodeData();
EList<OutputXmlTree> outputTables = xmlMapdata.getOutputTrees();
EList<InputXmlTree> inputTables = xmlMapdata.getInputTrees();
boolean hasDocumentInTheMainInputTable = false;
for (InputXmlTree inputTable : inputTables) {
if (!(inputTable.isLookup())) {
for (TreeNode inputEntry : inputTable.getNodes()) {
if ("id_Document".equals(inputEntry.getType())) {
hasDocumentInTheMainInputTable = true;
}
}
}
}
if (hasDocumentInTheMainInputTable) {
for (OutputXmlTree outputTable : outputTables) {
for (TreeNode outputEntry : outputTable.getNodes()) {
if ("id_Document".equals(outputEntry.getType())) {
if (!outputTable.isAllInOne()) {
outputTable.setAllInOne(true);
modified = true;
break;
}
}
}
}
}
}
}
}
try {
if (modified) {
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} else {
return ExecutionResult.SUCCESS_NO_ALERT;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class AddPortForTCassandraConfigurationSpark method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
//$NON-NLS-1$
String[] compNames = { "tCassandraConfiguration" };
IComponentConversion conversion = new IComponentConversion() {
@Override
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType parameter = ComponentUtilities.getNodeProperty(node, "PORT");
List<Object> needRemovedList = new ArrayList<Object>();
if (parameter == null) {
// get the value of native port if the user defined it on the configuration table
String portValue = null;
//$NON-NLS-1$
ElementParameterType configTable = ComponentUtilities.getNodeProperty(node, "CASSANDRA_CONFIGURATION");
boolean findNative = false;
boolean findRpc = false;
for (Object e : configTable.getElementValue()) {
ElementValueTypeImpl el = (ElementValueTypeImpl) e;
if (findNative && "VALUE".equals(el.getElementRef())) {
//$NON-NLS-1$
portValue = el.getValue();
needRemovedList.add(e);
findNative = false;
}
if (findRpc && "VALUE".equals(el.getElementRef())) {
//$NON-NLS-1$
needRemovedList.add(e);
findRpc = false;
}
if ("KEY".equals(el.getElementRef())) {
//$NON-NLS-1$
if ("connection_native_port".equals(el.getValue())) {
//$NON-NLS-1$
findNative = true;
needRemovedList.add(e);
}
if ("connection_rpc_port".equals(el.getValue())) {
//$NON-NLS-1$
findRpc = true;
needRemovedList.add(e);
}
}
}
configTable.getElementValue().removeAll(needRemovedList);
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "PORT", "TEXT");
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "PORT", portValue == null ? "\"9042\"" : portValue);
}
}
};
for (String name : compNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(conversion));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
Aggregations