use of org.talend.designer.core.IDesignerCoreService in project tdi-studio-se by Talend.
the class HTMLDocGenerator method generateSourceCodeInfo.
/**
* DOC qwei Comment method "generateSourceCodeInfo".
*/
private void generateSourceCodeInfo(ProcessItem item, Element element) {
if (CorePlugin.getDefault().getPreferenceStore().getBoolean(ITalendCorePrefConstants.DOC_GENERATESOURCECODE)) {
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
IProcess process = service.getProcessFromProcessItem(item);
IProcessor processor = ProcessorUtilities.getProcessor(process, null, process.getContextManager().getDefaultContext());
// hidePasswordInSourceCode4Doc(process);
try {
processor.cleanBeforeGenerate(TalendProcessOptionConstants.CLEAN_JAVA_CODES | TalendProcessOptionConstants.CLEAN_CONTEXTS | TalendProcessOptionConstants.CLEAN_DATA_SETS);
processor.generateCode(false, true, false);
} catch (ProcessorException e) {
ExceptionHandler.process(e);
}
//$NON-NLS-1$
Element sourceCodeInfoElement = DocumentHelper.createElement("sourcecodes");
ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
// StringBuffer componentsCode = new StringBuffer();
try {
IFile codeFile = synchronizer.getFile(item);
if (codeFile == null) {
return;
}
//$NON-NLS-1$
String tempStr = "";
InputStream in = codeFile.getContents();
BufferedReader buffer = new BufferedReader(new InputStreamReader(in));
while ((tempStr = buffer.readLine()) != null) {
//$NON-NLS-1$
Element codeElement = DocumentHelper.createElement("code");
// componentsCode.append(tempStr).append("\n");
//$NON-NLS-1$
codeElement.addAttribute("content", tempStr);
sourceCodeInfoElement.add(codeElement);
}
buffer.close();
in.close();
} catch (Exception e) {
// TODO Auto-generated catch block
// e.printStackTrace();
ExceptionHandler.process(e);
}
element.add(sourceCodeInfoElement);
}
}
use of org.talend.designer.core.IDesignerCoreService in project tdi-studio-se by Talend.
the class FTPWizard method performFinish.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.wizard.IWizard#performFinish()
*/
@Override
public boolean performFinish() {
final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
if (creation) {
String nextId = factory.getNextId();
connectionProperty.setId(nextId);
factory.create(connectionItem, propertiesWizardPage.getDestinationPath());
} else {
RepositoryUpdateManager.updateFileConnection(connectionItem);
boolean isModified = propertiesWizardPage.isNameModifiedByUser();
if (isModified) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
IDesignerCoreService service = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
if (service != null) {
service.refreshComponentView(connectionItem);
}
}
}
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRunnable operation = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
try {
factory.save(connectionItem);
closeLockStrategy();
} catch (PersistenceException e) {
throw new CoreException(new Status(IStatus.ERROR, "", "", e));
}
}
};
workspace.run(operation, null);
}
} catch (Exception e) {
String detailError = e.toString();
new //$NON-NLS-1$
ErrorDialogWidthDetailArea(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
PID, //$NON-NLS-1$
"", detailError);
return false;
}
return true;
}
use of org.talend.designer.core.IDesignerCoreService in project tdi-studio-se by Talend.
the class BDJobReArchieveCreator method getLibPath.
/**
*
* maybe, should be same result with JobJavaScriptsManager.getLibPath
*/
public List<File> getLibPath(File zipTmpFolder, boolean isSpecialMR) {
List<File> neededLibFiles = new ArrayList<File>();
File libFolder = new File(zipTmpFolder, JavaUtils.JAVA_LIB_DIRECTORY);
Set<String> compiledModulesSet = new HashSet<String>(100);
Set<ModuleNeeded> neededModules = LastGenerationInfo.getInstance().getModulesNeededWithSubjobPerJob(processItem.getProperty().getId(), processItem.getProperty().getVersion());
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
IDesignerCoreService designerCoreService = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
IProcess process = designerCoreService.getProcessFromProcessItem(processItem);
compiledModulesSet.addAll(PomUtil.getCodesExportJars(process));
if (neededModules.isEmpty()) {
neededModules = process.getNeededModules(true);
}
}
for (ModuleNeeded module : neededModules) {
if (((isSpecialMR || isSparkWithHDInsight) && module.isMrRequired()) || (!isSpecialMR && !isSparkWithHDInsight)) {
compiledModulesSet.add(module.getModuleName());
}
}
Set<String> jarNames = new HashSet<String>();
try {
// from org.talend.libraries.apache.storm/lib
Bundle bundle = Platform.getBundle(PLUGIN_ID);
if (bundle != null) {
//$NON-NLS-1$
URL stormLibUrl = FileLocator.toFileURL(FileLocator.find(bundle, new Path("lib"), null));
if (stormLibUrl != null) {
File file = new File(stormLibUrl.getFile());
File[] jars = file.listFiles();
for (File f : jars) {
jarNames.add(f.getName());
}
}
}
} catch (IOException e) {
ExceptionHandler.process(e);
}
for (String jarName : compiledModulesSet) {
File jarFile = new File(libFolder, jarName);
if (jarFile.exists()) {
if (!isSpecialMR && !jarNames.isEmpty()) {
// for storm not include the jar from libraries.apache.strom
if (!jarNames.contains(jarName)) {
neededLibFiles.add(jarFile);
}
} else {
neededLibFiles.add(jarFile);
}
}
}
return neededLibFiles;
}
use of org.talend.designer.core.IDesignerCoreService in project tesb-studio-se by Talend.
the class JobJavaScriptOSGIForESBRuntimeManager method generateJobFiles.
@Override
protected IProcess generateJobFiles(ProcessItem process, String contextName, String version, boolean statistics, boolean trace, boolean applyContextToChildren, IProgressMonitor monitor) throws ProcessorException {
LastGenerationInfo.getInstance().getUseDynamicMap().clear();
// TODO stat port tracer, to replace the port, need to improve efficiency
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
IProcess currentProcess = service.getProcessFromProcessItem(process);
IProcessor processor = ProcessorUtilities.getProcessor(currentProcess, null);
StatPortChecker checker = null;
if (processor instanceof MavenJavaProcessor) {
MavenJavaProcessor mvnProcessor = (MavenJavaProcessor) processor;
checker = new StatPortChecker(processor.getCodeProject().getFile(mvnProcessor.getSrcCodePath()).getLocation(), statisticPort, tracePort);
new Thread(checker, "Statistic Port Finder").start();
mvnProcessor = null;
}
IProcessor processor2 = ProcessorUtilities.generateCode(process, contextName, version, statistics, trace, applyContextToChildren, isOptionChoosed(ExportChoice.needContext), monitor);
if (checker != null) {
checker.stop();
}
return processor2.getProcess();
}
use of org.talend.designer.core.IDesignerCoreService in project tesb-studio-se by Talend.
the class AssignJobAction method assign.
public boolean assign(IRepositoryNode jobNode) {
if (jobNode == null) {
return false;
}
IRepositoryViewObject repositoryObject = jobNode.getObject();
final Item item = repositoryObject.getProperty().getItem();
// judge the job whether had T_ESB_PROVIDER_REQUEST
ProcessItem processItem = (ProcessItem) item;
NodeType providerNode = null;
for (Object obj : processItem.getProcess().getNode()) {
NodeType node = (NodeType) obj;
if (CreateNewJobAction.T_ESB_PROVIDER_REQUEST.equals(node.getComponentName())) {
providerNode = node;
break;
}
}
if (null == providerNode) {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.AssignJobAction_WarningTitle, Messages.AssignJobAction_WarningMessage);
return false;
}
try {
String jobID = item.getProperty().getId();
String jobName = item.getProperty().getLabel();
String operationName = repositoryNode.getObject().getLabel();
String portName = repositoryNode.getParent().getObject().getLabel();
ServiceItem serviceItem = (ServiceItem) repositoryNode.getParent().getParent().getObject().getProperty().getItem();
List<ServicePort> listPort = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
for (ServicePort port : listPort) {
if (port.getName().equals(portName)) {
List<ServiceOperation> listOperation = port.getServiceOperation();
for (ServiceOperation operation : listOperation) {
if (operation.getLabel().equals(operationName)) {
// should not change the job name
// String jobNewName = port.getName() + "_" + operation.getName();
// if (resetJobname(item, jobNewName)) {
// jobName = jobNewName;
// }
operation.setReferenceJobId(jobID);
operation.setLabel(operation.getName() + "-" + jobName);
break;
}
}
break;
}
}
IFile wsdlPath = WSDLUtils.getWsdlFile(serviceItem);
Map<String, String> serviceParameters = WSDLUtils.getServiceOperationParameters(wsdlPath, ((OperationRepositoryObject) repositoryNode.getObject()).getName(), portName);
for (Object paramObj : providerNode.getElementParameter()) {
ElementParameterType param = (ElementParameterType) paramObj;
String name = param.getName();
if (serviceParameters.containsKey(name)) {
param.setValue(serviceParameters.get(name));
}
}
IProcess2 process = null;
IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
for (IProcess2 processOpen : processes) {
if (processOpen.getProperty().getItem() == processItem) {
process = processOpen;
break;
}
}
if (process == null) {
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
IProcess proc = service.getProcessFromProcessItem(processItem);
if (proc instanceof IProcess2) {
process = (IProcess2) proc;
}
}
if (process != null) {
List<? extends INode> nodelist = process.getGraphicalNodes();
for (INode node : nodelist) {
if (node.getComponent().getName().equals("tESBProviderRequest")) {
repositoryChange(repositoryNode, node);
}
}
processItem.setProcess(process.saveXmlFile());
}
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(processItem);
factory.save(serviceItem);
return true;
} catch (Exception e) {
ExceptionHandler.process(e);
}
return false;
}
Aggregations