use of org.talend.designer.core.ICamelDesignerCoreService in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getUserRoutine.
/**
* Gets user routine.
*
* @param needUserRoutine
* @return
*/
protected List<URL> getUserRoutine(ExportFileResource[] process) {
try {
boolean useBeans = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService service = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (service.isInstanceofCamel(process[0].getItem())) {
useBeans = true;
}
}
String includePath;
String jar;
if (useBeans) {
includePath = USER_BEANS_PATH;
jar = USERBEANS_JAR;
} else {
includePath = USER_ROUTINES_PATH;
jar = USERROUTINE_JAR;
}
List<URL> urlList = new ArrayList<URL>();
File jarFile = new File(getTmpFolder() + File.separatorChar + jar);
// make a jar file of user routine or bean classes
File classRootFileLocation = getClassRootFileLocation();
if (classRootFileLocation == null) {
return Collections.emptyList();
}
JarBuilder jarbuilder = new JarBuilder(classRootFileLocation, jarFile);
jarbuilder.setIncludeDir(Collections.singleton(includePath));
jarbuilder.setIncludeRoutines(getRoutineDependince(process, false, includePath));
jarbuilder.setExcludeDir(// remove all
Arrays.asList(// remove all
SYSTEM_ROUTINES_PATH, // remove all
USER_ROUTINES_PATH, USER_BEANS_PATH, USER_PIGUDF_PATH));
jarbuilder.buildJar();
urlList.add(jarFile.toURI().toURL());
return urlList;
} catch (Exception e) {
ExceptionHandler.process(e);
return Collections.emptyList();
}
}
use of org.talend.designer.core.ICamelDesignerCoreService in project tesb-studio-se by Talend.
the class KarafJavaScriptForESBWithMavenManager method analysisMavenModule.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void analysisMavenModule(Item item) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (camelService.isInstanceofCamelRoutes(item)) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<String> mavenModules = getMavenModules();
mavenModules.clear();
talendJobsMap.clear();
EList nodes = ((CamelProcessItem) item).getProcess().getNode();
for (NodeType node : (List<NodeType>) nodes) {
if ("cTalendJob".equals(node.getComponentName())) {
//$NON-NLS-1$
String talendJobId = null;
String talendJobVersion = null;
String talendJobContextGroup = null;
EList elementParameters = node.getElementParameter();
for (ElementParameterType paramType : (List<ElementParameterType>) elementParameters) {
if ("SELECTED_JOB_NAME:PROCESS_TYPE_PROCESS".equals(paramType.getName())) {
//$NON-NLS-1$
talendJobId = paramType.getValue();
} else if ("SELECTED_JOB_NAME:PROCESS_TYPE_VERSION".equals(paramType.getName())) {
//$NON-NLS-1$
talendJobVersion = paramType.getValue();
} else if ("SELECTED_JOB_NAME:PROCESS_TYPE_CONTEXT".equals(paramType.getName())) {
//$NON-NLS-1$
talendJobContextGroup = paramType.getValue();
}
if (talendJobId != null && talendJobVersion != null && talendJobContextGroup != null) {
// found
break;
}
}
if (talendJobId != null) {
if (talendJobVersion == null) {
talendJobVersion = RelationshipItemBuilder.LATEST_VERSION;
}
if (talendJobContextGroup == null) {
talendJobContextGroup = IContext.DEFAULT;
}
IRepositoryViewObject foundObject = null;
try {
if (RelationshipItemBuilder.LATEST_VERSION.equals(talendJobVersion)) {
foundObject = factory.getLastVersion(talendJobId);
} else {
// find out the fixing version
List<IRepositoryViewObject> allVersionObjects = factory.getAllVersion(talendJobId);
if (allVersionObjects != null) {
for (IRepositoryViewObject obj : allVersionObjects) {
if (obj.getVersion().equals(talendJobVersion)) {
foundObject = obj;
break;
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (foundObject != null) {
Property property = foundObject.getProperty();
if (property != null) {
talendJobsMap.put(talendJobId, foundObject);
talendJobContextGroupsMap.put(talendJobId, talendJobContextGroup);
// we do not export the referenced jobs literally,
// but get them for build from the Maven repository.
// Thus, we must not add module declarations for them.
// mavenModules.add(TALEND_JOBS_PATH + property.getLabel());
}
}
}
}
}
}
}
}
use of org.talend.designer.core.ICamelDesignerCoreService in project tdi-studio-se by Talend.
the class ComponentChooseDialog method createComponentOnLink.
private boolean createComponentOnLink(Node node, Point originalPoint) {
boolean executed = false;
RootEditPart rep = editor.getViewer().getRootEditPart().getRoot();
Point viewOriginalPosition = new Point();
if (rep instanceof ScalableFreeformRootEditPart) {
ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep;
Viewport viewport = (Viewport) root.getFigure();
viewOriginalPosition = viewport.getViewLocation();
}
Point point = new Point(originalPoint.x + viewOriginalPosition.x, originalPoint.y + viewOriginalPosition.y);
point.x = (int) (point.x / AnimatableZoomManager.currentZoom);
point.y = (int) (point.y / AnimatableZoomManager.currentZoom);
org.talend.designer.core.ui.editor.connections.Connection targetConnection = null;
if (selectedConnectionPart != null) {
targetConnection = (org.talend.designer.core.ui.editor.connections.Connection) selectedConnectionPart.getModel();
}
if (targetConnection != null) {
IProcess2 p = editor.getProcess();
NodeContainer nodeContainer = ((Process) node.getProcess()).loadNodeContainer(node, false);
// TDI-21099
if (p instanceof Process) {
CreateNodeContainerCommand createCmd = new CreateNodeContainerCommand((Process) p, nodeContainer, point);
execCommandStack(createCmd);
// reconnect the node
Node originalTarget = (Node) targetConnection.getTarget();
EConnectionType connectionType = EConnectionType.FLOW_MAIN;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (camelService.isRouteBuilderNode(node)) {
connectionType = camelService.getTargetConnectionType(node);
}
}
INodeConnector targetConnector = node.getConnectorFromType(connectionType);
for (INodeConnector connector : node.getConnectorsFromType(connectionType)) {
if (connector.getMaxLinkOutput() != 0) {
targetConnector = connector;
break;
}
}
ConnectionCreateCommand.setCreatingConnection(true);
// bug 21411
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null && service.isJobletComponent(targetConnection.getTarget())) {
if (targetConnection.getTarget() instanceof Node) {
NodeContainer jobletContainer = ((Node) targetConnection.getTarget()).getNodeContainer();
// remove the old connection in the container
jobletContainer.getInputs().remove(targetConnection);
}
}
}
ConnectionReconnectCommand cmd2 = new ConnectionReconnectCommand(targetConnection);
cmd2.setNewTarget(node);
execCommandStack(cmd2);
List<Object> nodeArgs = CreateComponentOnLinkHelper.getTargetArgs(targetConnection, node);
ConnectionCreateCommand nodeCmd = new ConnectionCreateCommand(node, targetConnector.getName(), nodeArgs, false);
nodeCmd.setTarget(originalTarget);
execCommandStack(nodeCmd);
// Setting,such as the target is TMap
if (node.getOutgoingConnections().size() > 0) {
if (node.getExternalNode() instanceof MapperExternalNode) {
CreateComponentOnLinkHelper.setupTMap(node);
}
if (originalTarget.getExternalNode() instanceof MapperExternalNode) {
CreateComponentOnLinkHelper.updateTMap(originalTarget, targetConnection, node.getOutgoingConnections().get(0));
}
originalTarget.renameData(targetConnection.getName(), node.getOutgoingConnections().get(0).getName());
}
if (!ConnectionCreateCommand.isCreatingConnection()) {
return true;
}
executed = true;
}
}
return executed;
}
use of org.talend.designer.core.ICamelDesignerCoreService in project tdi-studio-se by Talend.
the class HTMLDocGenerator method generateJobInfo.
/**
* Generates job(process) information in XML base on <code>ProcessItem</code> and project element.
*
* @param item <code>ProcessItem</code>
* @param projectElement <code>Element</code>
* @param version
* @return an instance of <code>Element</code>
*/
private Element generateJobInfo(Item item, Element projectElement, String... version) {
picFilePathMap = new HashMap<String, String>();
// IProcess process = CorePlugin.getDefault().getDesignerCoreService().getProcessFromProcessItem(processItem);
Property property = item.getProperty();
String jobName = property.getLabel();
String jobVersion = property.getVersion();
//$NON-NLS-1$
Element jobElement = projectElement.addElement("job");
//$NON-NLS-1$
jobElement.addAttribute("name", HTMLDocUtils.checkString(jobName));
//$NON-NLS-1$
jobElement.addAttribute("author", HTMLDocUtils.checkString(property.getAuthor().toString()));
if (version != null && version.length == 1) {
jobVersion = version[0];
}
if (isRouteProcess(item)) {
//$NON-NLS-1$//$NON-NLS-2$
jobElement.addAttribute("type", "route");
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
camelService.appendRouteInfo2Doc(item, jobElement);
}
if (generateExtraSetting) {
//$NON-NLS-1$//$NON-NLS-2$
jobElement.addAttribute("i18n.job.extract.settings.type", "i18n.job.extract.settings");
}
if (generateStatsLogsSetting) {
//$NON-NLS-1$//$NON-NLS-2$
jobElement.addAttribute("i18n.job.stats.logs.type", "i18n.job.stats.logs");
}
//$NON-NLS-1$
jobElement.addAttribute("version", HTMLDocUtils.checkString(jobVersion));
//$NON-NLS-1$
jobElement.addAttribute("purpose", HTMLDocUtils.checkString(property.getPurpose()));
//$NON-NLS-1$
jobElement.addAttribute("status", HTMLDocUtils.checkString(property.getStatusCode()));
// jobElement.addAttribute("description", HTMLDocUtils.checkString(property.getDescription())); //$NON-NLS-1$
//$NON-NLS-1$
jobElement.addAttribute("creation", HTMLDocUtils.checkDate(property.getCreationDate()));
//$NON-NLS-1$
jobElement.addAttribute("modification", HTMLDocUtils.checkDate(property.getModificationDate()));
//$NON-NLS-1$
Element descr = jobElement.addElement("description");
// bug 22608
//$NON-NLS-1$ //$NON-NLS-2$
String jobDescriptionStr = HTMLDocUtils.checkString(property.getDescription()).replaceAll("\\r\\n", "<br/>");
StringBuffer sb = new StringBuffer();
if (jobDescriptionStr != null) {
//$NON-NLS-1$
String[] jobDescriptions = jobDescriptionStr.split("<br/>");
for (String str : jobDescriptions) {
String ss = str;
if (str != null && str.length() > 120) {
while (ss.length() > 120) {
int k = ss.length() / 120;
for (int i = 0; i < k; i++) {
//$NON-NLS-1$
sb.append(ss.substring(0, 120) + "<br/>");
ss = ss.substring(120, ss.length());
}
}
sb.append(ss);
} else {
//$NON-NLS-1$
sb.append(str + "<br/>");
}
}
}
descr.addCDATA(sb.toString());
//$NON-NLS-1$
String picName = jobName + "_" + jobVersion + IHTMLDocConstants.JOB_PREVIEW_PIC_SUFFIX;
IPath filePath = null;
if (item instanceof ProcessItem) {
filePath = DocumentationPathProvider.getPathFileName(item, RepositoryConstants.IMG_DIRECTORY_OF_JOB_OUTLINE, picName);
} else if (item instanceof JobletProcessItem) {
filePath = DocumentationPathProvider.getPathFileName(item, RepositoryConstants.IMG_DIRECTORY_OF_JOBLET_OUTLINE, picName);
}
//$NON-NLS-1$
Element previewElement = jobElement.addElement("preview");
//$NON-NLS-1$
previewElement.addAttribute("picture", IHTMLDocConstants.PICTUREFOLDERPATH + picName);
// }
return jobElement;
}
use of org.talend.designer.core.ICamelDesignerCoreService in project tdi-studio-se by Talend.
the class ConfigRoutineLibraryAction method init.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
* org.eclipse.jface.viewers.IStructuredSelection)
*/
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = selection.size() == 1;
if (canWork) {
for (Object o : selection.toArray()) {
if (o instanceof RepositoryNode) {
RepositoryNode node = (RepositoryNode) o;
switch(node.getType()) {
case REPOSITORY_ELEMENT:
ERepositoryObjectType beanType = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService service = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
beanType = service.getBeansType();
}
if (beanType != null && node.getObjectType() == beanType) {
setText("Edit Bean Libraries");
} else if (ERepositoryObjectType.PIG_UDF == node.getObjectType()) {
String label = org.talend.repository.i18n.Messages.getString(//$NON-NLS-1$
"ConfigRoutineLibraryAction.pigudf.actionLabel");
setText(label);
} else {
String label = org.talend.repository.i18n.Messages.getString(//$NON-NLS-1$
"ConfigRoutineLibraryAction.actionLabel");
setText(label);
}
if (node.getObjectType() == ERepositoryObjectType.ROUTINES || node.getObjectType() == ERepositoryObjectType.PIG_UDF || (beanType != null && node.getObjectType() == beanType)) {
// IRepositoryViewObject repObj = node.getObject();
// IProxyRepositoryFactory repFactory = ProxyRepositoryFactory.getInstance();
// ERepositoryStatus status = repFactory.getStatus(repObj);
// boolean isEditable = status.isPotentiallyEditable() || status.isEditable();
canWork = true;
} else {
canWork = false;
}
break;
default:
canWork = false;
break;
}
}
}
}
setEnabled(canWork);
}
Aggregations