use of org.talend.core.model.properties.ProcessItem in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSAction method exportAllReferenceRoutelets.
@SuppressWarnings("unchecked")
protected final void exportAllReferenceRoutelets(String routeName, ProcessItem routeProcess, Set<String> routelets) throws InvocationTargetException, InterruptedException {
for (NodeType node : (Collection<NodeType>) routeProcess.getProcess().getNode()) {
if (!EmfModelUtils.isComponentActive(node)) {
continue;
}
final ElementParameterType routeletId = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_PROCESS.getName(), node);
if (null != routeletId) {
final IRepositoryNode referencedRouteletNode;
try {
referencedRouteletNode = getJobRepositoryNode(routeletId.getValue(), CamelRepositoryNodeType.repositoryRouteletType);
// getRouteletRepositoryNode(routeletId);
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
}
final ProcessItem routeletProcess = (ProcessItem) referencedRouteletNode.getObject().getProperty().getItem();
final String className = RouteJavaScriptOSGIForESBManager.getClassName(routeletProcess);
String idSuffix = "-" + routeName;
if (!routelets.add(className + idSuffix)) {
continue;
}
String routeletVersion = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_VERSION.getName(), node).getValue();
if (RelationshipItemBuilder.LATEST_VERSION.equals(routeletVersion)) {
routeletVersion = referencedRouteletNode.getObject().getVersion();
}
final File routeletFile;
try {
routeletFile = File.createTempFile("routelet", FileConstants.JAR_FILE_SUFFIX, //$NON-NLS-1$
new File(getTempDir()));
} catch (IOException e) {
throw new InvocationTargetException(e);
}
String routeletName = referencedRouteletNode.getObject().getLabel();
String routeletBundleName = routeName + "_" + routeletName;
String routeletBundleSymbolicName = routeletBundleName;
Project project = ProjectManager.getInstance().getCurrentProject();
if (project != null) {
String projectName = project.getLabel();
if (projectName != null && projectName.length() > 0) {
routeletBundleSymbolicName = projectName.toLowerCase() + '.' + routeletBundleSymbolicName;
}
}
BundleModel routeletModel = new BundleModel(getGroupId(), routeletBundleName, getArtifactVersion(), routeletFile);
if (featuresModel.addBundle(routeletModel)) {
exportRouteBundle(referencedRouteletNode, routeletFile, routeletVersion, routeletBundleName, routeletBundleSymbolicName, bundleVersion, idSuffix, null, EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_CONTEXT.getName(), node).getValue());
CamelFeatureUtil.addFeatureAndBundles(routeletProcess, featuresModel);
exportAllReferenceRoutelets(routeName, routeletProcess, routelets);
}
}
}
}
use of org.talend.core.model.properties.ProcessItem in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWithMavenAction method getReferenceRoutlets.
private Collection<String> getReferenceRoutlets() {
ProcessItem routeProcess = (ProcessItem) routeNode.getObject().getProperty().getItem();
String routeName = routeNode.getObject().getProperty().getDisplayName();
Set<String> routelets = new HashSet<>();
try {
exportAllReferenceRoutelets(routeName, routeProcess, routelets);
} catch (InvocationTargetException e) {
return new HashSet<>();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return routelets;
}
use of org.talend.core.model.properties.ProcessItem in project tesb-studio-se by Talend.
the class LocalESBRunContainerServiceTest method testCreateJavaProcessor.
/**
* Test method for
* {@link org.talend.designer.esb.runcontainer.core.LocalESBRunContainerService#createJavaProcessor(org.talend.core.model.process.IProcess, Property, boolean)}
*/
@Test
public void testCreateJavaProcessor() {
IESBRunContainerService service = (IESBRunContainerService) GlobalServiceRegister.getDefault().getService(IESBRunContainerService.class);
String[] esbComponents = { "tESBProviderRequest", "tRESTClient", "tRESTRequest", "tRESTResponse", "tESBConsumer", "tESBProviderFault", "tESBProviderRequest", "tESBProviderResponse" };
for (String esbComponent : esbComponents) {
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setVersion("0.1");
property.setId("property1");
property.setLabel("ESBArtifact");
ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
processItem.setProperty(property);
property.setItem(processItem);
ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
processItem.setProcess(process);
NodeType node = TalendFileFactory.eINSTANCE.createNodeType();
process.getNode().add(node);
node.setComponentName(esbComponent);
IComponent tESBComponent = ComponentsFactoryProvider.getInstance().get(esbComponent, ComponentCategory.CATEGORY_4_DI.getName());
Process esbJob = new Process(property);
Node tESBComponent_1 = new Node(tESBComponent, esbJob);
esbJob.addNodeContainer(new NodeContainer(tESBComponent_1));
Assert.assertNotNull(service.createJavaProcessor(esbJob, property, false));
}
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class ProcessController method updateContextList.
/**
*
* ggu Comment method "updateContextList".
*
* @param processParam
*/
private void updateContextList(IElementParameter processParam) {
if (processParam == null || (processParam.getFieldType() != EParameterFieldType.PROCESS_TYPE && processParam.getFieldType() != EParameterFieldType.ROUTE_INPUT_PROCESS_TYPE)) {
return;
}
// for context type
List<String> contextNameList = new ArrayList<String>();
List<String> contextValueList = new ArrayList<String>();
// for version type
List<String> versionNameList = new ArrayList<String>();
List<String> versionValueList = new ArrayList<String>();
versionNameList.add(ItemCacheManager.LATEST_VERSION);
versionValueList.add(ItemCacheManager.LATEST_VERSION);
IElementParameter jobNameParam = processParam.getChildParameters().get(EParameterName.PROCESS_TYPE_PROCESS.getName());
// feature 19312
Item item = null;
StringBuffer labels = new StringBuffer("");
List<IRepositoryViewObject> allVersion = new ArrayList<IRepositoryViewObject>();
final String strJobId = (String) jobNameParam.getValue();
String[] strJobIds = strJobId.split(ProcessController.COMMA);
for (int i = 0; i < strJobIds.length; i++) {
String id = strJobIds[i];
if (StringUtils.isNotEmpty(id)) {
allVersion = ProcessorUtilities.getAllVersionObjectById(id);
// IRepositoryObject lastVersionObject = null;
String label = null;
if (allVersion != null) {
String oldVersion = null;
for (IRepositoryViewObject obj : allVersion) {
String version = obj.getVersion();
if (oldVersion == null) {
oldVersion = version;
}
if (VersionUtils.compareTo(version, oldVersion) >= 0) {
item = obj.getProperty().getItem();
// lastVersionObject = obj;
}
oldVersion = version;
versionNameList.add(version);
versionValueList.add(version);
}
label = item.getProperty().getLabel();
if (i > 0) {
labels.append(ProcessController.COMMA);
}
labels.append(label);
// IPath path = RepositoryNodeUtilities.getPath(lastVersionObject);
// if (path != null) {
// label = path.toString() + IPath.SEPARATOR + label;
// }
} else {
// FIXME TUP-5524, don't set empty, keep the id value instead.
// final String parentName = processParam.getName() + ":"; //$NON-NLS-1$
// if (elem != null) {
// // can be called in multi-thread, dispose method may be already called before executing this
// method
//elem.setPropertyValue(parentName + jobNameParam.getName(), ""); //$NON-NLS-1$
// }
}
}
}
jobNameParam.setLabelFromRepository(labels.toString());
// set default context
String defalutValue = null;
if (item != null && item instanceof ProcessItem) {
for (Object o : ((ProcessItem) item).getProcess().getContext()) {
if (o instanceof ContextType) {
ContextType context = (ContextType) o;
contextNameList.add(context.getName());
contextValueList.add(context.getName());
}
}
defalutValue = ((ProcessItem) item).getProcess().getDefaultContext();
}
setProcessTypeRelatedValues(processParam, contextNameList, contextValueList, EParameterName.PROCESS_TYPE_CONTEXT.getName(), defalutValue);
setProcessTypeRelatedValues(processParam, versionNameList, versionValueList, EParameterName.PROCESS_TYPE_VERSION.getName(), null);
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class ImageController method createControl.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
*/
@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
// String fileName = (String) param.getValue();
// IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
// String filePath = service.getPathFileName(RepositoryConstants.IMG_DIRECTORY, fileName).toPortableString();
boolean hasScreenshots = false;
byte[] screenshot = null;
if (param.getElement() instanceof INode && ((INode) param.getElement()).getExternalNode() != null) {
String componentType = ((INode) param.getElement()).getComponent().getName();
if ("tMap".equals(componentType)) {
IProcess process = ((INode) param.getElement()).getProcess();
if (process instanceof IProcess2) {
IProcess2 processtmp = (IProcess2) process;
Item item = processtmp.getProperty().getItem();
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
screenshot = (byte[]) processItem.getProcess().getScreenshots().get(((INode) param.getElement()).getUniqueName());
if (screenshot != null) {
hasScreenshots = true;
}
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobletItem = (JobletProcessItem) item;
screenshot = (byte[]) jobletItem.getJobletProcess().getScreenshots().get(((INode) param.getElement()).getUniqueName());
if (screenshot != null) {
hasScreenshots = true;
}
}
}
}
}
if (hasScreenshots) {
ImageDescriptor imageDesc = ImageUtils.createImageFromData(screenshot);
((INode) param.getElement()).getExternalNode().setScreenshot(imageDesc);
// ImageDescriptor imageDesc = ((INode) param.getElement()).getExternalNode().getScreenshot();
// File fileOrFolder = new java.io.File(filePath);
// if (!fileOrFolder.isFile() || !fileOrFolder.canRead()) {
// return lastControl;
// }
final Composite compositeImage = new Composite(subComposite, SWT.BORDER);
final Image image = imageDesc.createImage();
addResourceDisposeListener(compositeImage, image);
//$NON-NLS-1$
CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName() + " :");
FormData formDataLabel = new FormData();
labelLabel.setVisible(true);
if (numInRow != 1) {
labelLabel.setAlignment(SWT.RIGHT);
}
if (lastControl != null) {
formDataLabel.left = new FormAttachment(lastControl, 0);
} else {
formDataLabel.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
formDataLabel.top = new FormAttachment(0, top);
}
labelLabel.setLayoutData(formDataLabel);
compositeImage.setToolTipText(param.getDisplayName());
Point size = new Point(image.getImageData().width, image.getImageData().height);
FormData formData = new FormData((int) (size.x * 0.8), (int) (size.y * 0.8));
formData.top = new FormAttachment(0, top);
formData.left = new FormAttachment(labelLabel);
ImageData data = image.getImageData();
compositeImage.setLayoutData(formData);
data = data.scaledTo((int) (size.x * 0.8), (int) (size.y * 0.8));
Image im = new Image(image.getDevice(), data);
compositeImage.setBackgroundImage(im);
return compositeImage;
} else {
return lastControl;
}
}
Aggregations