use of org.talend.core.model.properties.JobletProcessItem in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method refreshProcess.
/**
* Refresh the editor/process to the given refreshedItem version
*
* @param refreshedItem
* @param force
*/
private void refreshProcess(final Item refreshedItem, boolean force) {
Item currentItem = processEditorInput.getItem();
if (isStorageVersionChanged(refreshedItem, currentItem) || force) {
processEditorInput.setItem(refreshedItem);
final IProcess2 process = processEditorInput.getLoadedProcess();
getSite().getShell().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
process.setProperty(refreshedItem.getProperty());
process.updateProperties();
ProcessType processType = null;
if (refreshedItem instanceof ProcessItem) {
processType = ((ProcessItem) refreshedItem).getProcess();
} else if (refreshedItem instanceof JobletProcessItem) {
processType = ((JobletProcessItem) refreshedItem).getJobletProcess();
} else {
//$NON-NLS-1$
ExceptionHandler.process(new Exception("Mismatched case"));
}
if (processType != null) {
((Process) process).updateProcess(processType);
}
process.refreshProcess();
revisionChanged = true;
setName();
}
});
}
}
use of org.talend.core.model.properties.JobletProcessItem in project tdi-studio-se by Talend.
the class HTMLDocGenerator method generateHTMLFile.
/*
* This method is used for generating HTML file base on an instance of <code>ExportFileResource</code> (non-Javadoc)
*
* @see
* org.talend.repository.documentation.generation.IDocumentationGenerator#generateHTMLFile(org.talend.repository
* .documentation.ExportFileResource)
*/
@Override
public void generateHTMLFile(ExportFileResource resource, String cssFile) {
try {
// Store all pictures' path.
List<URL> picList = new ArrayList<URL>(5);
String jobName = resource.getItem().getProperty().getLabel();
String jobVersion = resource.getItem().getProperty().getVersion();
String tempFolderPath = checkTempDirIsExists(resource);
handleXMLFile(resource, tempFolderPath);
String picFolderPath = checkPicDirIsExists(resource, tempFolderPath);
final Bundle b = Platform.getBundle(IHTMLDocConstants.REPOSITORY_PLUG_IN_ID);
final URL xslFileUrl = FileLocator.toFileURL(FileLocator.find(b, new Path(IHTMLDocConstants.MAIN_XSL_FILE_PATH), null));
// final URL logoFileUrl = FileLocator.toFileURL(FileLocator.find(b,
// new Path(IHTMLDocConstants.LOGO_FILE_PATH), null));
File logoFile = new File(picFolderPath + File.separatorChar + IHTMLDocConstants.TALEND_LOGO_FILE_NAME);
saveLogoImage(SWT.IMAGE_JPEG, logoFile);
String xslFilePath = xslFileUrl.getPath();
// String logoFilePath = logoFileUrl.getPath();
// FileCopyUtils.copy(logoFilePath, picFolderPath + File.separatorChar
// + IHTMLDocConstants.TALEND_LOGO_FILE_NAME);
// if import a css template, generate a new xsl file
String temXslPath = null;
File file = new File(xslFilePath);
temXslPath = HTMLDocUtils.getTmpFolder() + File.separator + file.getName();
generateXslFile(xslFilePath, temXslPath, cssFile, tempFolderPath);
// if no new xls generated, use default xsl
File temFile = new File(temXslPath);
if (!temFile.exists()) {
temXslPath = null;
}
if (temXslPath == null) {
temXslPath = xslFilePath;
}
picList.add(logoFile.toURL());
Set keySet = picFilePathMap.keySet();
for (Object key : keySet) {
String value = picFilePathMap.get(key);
FileCopyUtils.copy(value, picFolderPath + File.separatorChar + key);
picList.add(new File(picFolderPath + File.separatorChar + key).toURL());
}
byte[] innerContent = null;
ProcessType processType = null;
if (resource.getItem() instanceof ProcessItem) {
processType = ((ProcessItem) resource.getItem()).getProcess();
//$NON-NLS-1$
innerContent = (byte[]) processType.getScreenshots().get("process");
} else if (resource.getItem() instanceof JobletProcessItem) {
processType = ((JobletProcessItem) resource.getItem()).getJobletProcess();
//$NON-NLS-1$
innerContent = (byte[]) processType.getScreenshots().get("process");
}
if (innerContent != null) {
ImageDescriptor imagedesc = ImageUtils.createImageFromData(innerContent);
//$NON-NLS-1$
String picName = jobName + "_" + jobVersion + IHTMLDocConstants.JOB_PREVIEW_PIC_SUFFIX;
ImageUtils.save(imagedesc.createImage(), picFolderPath + File.separatorChar + picName, SWT.IMAGE_PNG);
picList.add(new File(picFolderPath + File.separatorChar + picName).toURL());
}
for (NodeType node : (List<NodeType>) processType.getNode()) {
//$NON-NLS-1$
String uniqueName = "";
for (Object o : node.getElementParameter()) {
if (o instanceof ElementParameterType) {
if ("UNIQUE_NAME".equals(((ElementParameterType) o).getName())) {
//$NON-NLS-1$
uniqueName = ((ElementParameterType) o).getValue();
break;
}
}
}
byte[] screenshot = (byte[]) processType.getScreenshots().get(uniqueName);
if (screenshot != null && screenshot.length != 0) {
ImageDescriptor imagedesc = ImageUtils.createImageFromData(screenshot);
String picName = IHTMLDocConstants.EXTERNAL_NODE_PREVIEW + uniqueName + IHTMLDocConstants.JOB_PREVIEW_PIC_SUFFIX;
ImageUtils.save(imagedesc.createImage(), picFolderPath + File.separatorChar + picName, SWT.IMAGE_PNG);
picList.add(new File(picFolderPath + File.separatorChar + picName).toURL());
}
}
//$NON-NLS-1$
List<URL> resultFiles = parseXML2HTML(tempFolderPath, jobName + "_" + jobVersion, temXslPath);
addResources(resource, resultFiles);
resource.addResources(IHTMLDocConstants.PIC_FOLDER_NAME, picList);
// List<URL> externalList = getExternalHtmlPath();
// resource.addResources(IHTMLDocConstants.EXTERNAL_FOLDER_NAME, externalList);
} catch (Exception e) {
e.printStackTrace();
ExceptionHandler.process(e);
}
targetConnectionMap = null;
sourceConnectionMap = null;
}
use of org.talend.core.model.properties.JobletProcessItem in project tdi-studio-se by Talend.
the class HTMLDocGenerator method seperateNodes.
/**
* This method is used for seperating all nodes into internal and external.
*
* @param item
* @return
*/
protected List<List> seperateNodes(Item item) {
List<INode> internalNodeComponentList = new ArrayList<INode>();
List<INode> externalNodeComponentList = new ArrayList<INode>();
List<INode> allNodeComponentList = new ArrayList<INode>();
List<List> componentsList = new ArrayList<List>();
IProcess process = null;
boolean isJobletProcessItem = item instanceof JobletProcessItem;
boolean isProcessItem = item instanceof ProcessItem;
if (isProcessItem) {
process = CorePlugin.getDefault().getDesignerCoreService().getProcessFromProcessItem((ProcessItem) item, true);
}
// }
if (process == null) {
return componentsList;
}
List<INode> graphicalNodeList = (List<INode>) process.getGraphicalNodes();
for (INode node : graphicalNodeList) {
// If component is not activate, do not need to get it's information
if (!node.isActivate()) {
continue;
}
allNodeComponentList.add(node);
if (node.getExternalNode() != null) {
externalNodeComponentList.add(node);
} else {
internalNodeComponentList.add(node);
}
}
// Sorts the component list in alpha-order.
Comparator comparator = getComparator();
Collections.sort(allNodeComponentList, comparator);
Collections.sort(internalNodeComponentList, comparator);
Collections.sort(externalNodeComponentList, comparator);
componentsList.add(allNodeComponentList);
componentsList.add(internalNodeComponentList);
componentsList.add(externalNodeComponentList);
if (process instanceof IProcess2) {
((IProcess2) process).dispose();
}
return componentsList;
}
use of org.talend.core.model.properties.JobletProcessItem in project tdi-studio-se by Talend.
the class HTMLDocGenerator method generateJobSettingInfo.
/**
* DOC qwei Comment method "hideSourcecodePassword".
*/
// private void hidePasswordInSourceCode4Doc(IProcess process) {
// List<? extends IElementParameter> processParam = process.getElementParameters();
// for (IElementParameter elementParameter : processParam) {
// elementParameter.setValue(ParameterValueUtil.getValue4Doc(elementParameter));
// }
// List<? extends INode> nodes = process.getGraphicalNodes();
// for (INode node : nodes) {
// List<? extends IElementParameter> nodeParamList = node.getElementParameters();
// for (IElementParameter nodeParam : nodeParamList) {
// nodeParam.setValue(ParameterValueUtil.getValue4Doc(nodeParam));
// }
// }
// }
/**
* DOC YeXiaowei Comment method "genereateJobSettingInfo".
*
* @return
*/
private void generateJobSettingInfo(final Item item, final Element element) {
//$NON-NLS-1$
Element jobSettingInfoElement = DocumentHelper.createElement("jobSetting");
ParametersType jobDirectParams = null;
if (item instanceof ProcessItem) {
jobDirectParams = ((ProcessItem) item).getProcess().getParameters();
} else if (item instanceof JobletProcessItem) {
jobDirectParams = ((JobletProcessItem) item).getJobletProcess().getParameters();
}
if (jobDirectParams == null || jobDirectParams.getElementParameter() == null || jobDirectParams.getElementParameter().isEmpty()) {
return;
}
EList params = jobDirectParams.getElementParameter();
Map<String, String> nameValueMap = new HashMap<String, String>();
for (int i = 0; i < params.size(); i++) {
ElementParameterType param = (ElementParameterType) params.get(i);
nameValueMap.put(param.getName(), ParameterValueUtil.getValue4Doc(param));
}
// Main settinparam info
// Extra setting
//$NON-NLS-1$
Element extraElement = DocumentHelper.createElement("extra");
jobSettingInfoElement.add(extraElement);
if (item instanceof JobletProcessItem) {
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.STARTABLE);
element.add(jobSettingInfoElement);
return;
}
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.COMP_DEFAULT_FILE_DIR);
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.MULTI_THREAD_EXECATION);
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.IMPLICIT_TCONTEXTLOAD);
if (StringUtils.equals(nameValueMap.get(IJobSettingConstants.IMPLICIT_TCONTEXTLOAD), "true")) {
if (StringUtils.equals(nameValueMap.get(IJobSettingConstants.FROM_FILE_FLAG_IMPLICIT_CONTEXT), "true")) {
//$NON-NLS-1$
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.FROM_FILE_FLAG_IMPLICIT_CONTEXT);
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.IMPLICIT_TCONTEXTLOAD_FILE);
}
if (StringUtils.equals(nameValueMap.get(IJobSettingConstants.FROM_DATABASE_FLAG_IMPLICIT_CONTEXT), "true")) {
//$NON-NLS-1$
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.FROM_DATABASE_FLAG_IMPLICIT_CONTEXT);
// some params about databse setting
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.PROPERTY_TYPE_IMPLICIT_CONTEXT_PROPERTY_TYPE);
if (!StringUtils.equalsIgnoreCase(nameValueMap.get(IJobSettingConstants.PROPERTY_TYPE_IMPLICIT_CONTEXT_PROPERTY_TYPE), "built_in")) {
//$NON-NLS-1$
restConnectionLabelById(nameValueMap, IJobSettingConstants.PROPERTY_TYPE_IMPLICIT_CONTEXT_REPOSITORY_PROPERTY_TYPE);
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.PROPERTY_TYPE_IMPLICIT_CONTEXT_REPOSITORY_PROPERTY_TYPE);
}
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.DB_TYPE_IMPLICIT_CONTEXT);
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.HOST_IMPLICIT_CONTEXT);
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.PORT_IMPLICIT_CONTEXT);
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.DBNAME_IMPLICIT_CONTEXT);
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.SCHEMA_DB_IMPLICIT_CONTEXT);
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.USER_IMPLICIT_CONTEXT);
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.PASS_IMPLICIT_CONTEXT);
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.DBFILE_IMPLICIT_CONTEXT);
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.DBTABLE_IMPLICIT_CONTEXT);
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.QUERY_CONDITION_IMPLICIT_CONTEXT);
}
// print operation
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.PRINT_OPERATIONS);
// diable warnings
createSingleJobParameter(extraElement, nameValueMap, IJobSettingConstants.DISABLE_WARNINGS);
}
// Stats & logs setting
//$NON-NLS-1$
Element statsAndLotsElement = DocumentHelper.createElement("Statslogs");
jobSettingInfoElement.add(statsAndLotsElement);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.ON_STATCATCHER_FLAG);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.ON_LOGCATCHER_FLAG);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.ON_METERCATCHER_FLAG);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.ON_CONSOLE_FLAG);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.ON_FILES_FLAG);
if (StringUtils.equals(nameValueMap.get(IJobSettingConstants.ON_FILES_FLAG), "true")) {
//$NON-NLS-1$
// add on file details
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.FILE_PATH);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.FILENAME_LOGS);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.FILENAME_METTER);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.FILENAME_STATS);
}
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.ON_DATABASE_FLAG);
if (StringUtils.equals(nameValueMap.get(IJobSettingConstants.ON_DATABASE_FLAG), "true")) {
//$NON-NLS-1$
// add on database details
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.PROPERTY_TYPE);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.PROPERTY_TYPE_PROPERTY_TYPE);
if (!StringUtils.equalsIgnoreCase(nameValueMap.get(IJobSettingConstants.PROPERTY_TYPE_PROPERTY_TYPE), "built_in")) {
//$NON-NLS-1$
restConnectionLabelById(nameValueMap, IJobSettingConstants.PROPERTY_TYPE_REPOSITORY_PROPERTY_TYPE);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.PROPERTY_TYPE_REPOSITORY_PROPERTY_TYPE);
}
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.DB_TYPE);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.HOST);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.PORT);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.DBNAME);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.PROPERTIES);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.SCHEMA_DB);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.USER);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.PASS);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.DBFILE);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.TABLE_LOGS);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.TABLE_METER);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.TABLE_STATS);
}
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.CATCH_REALTIME_STATS);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.CATCH_RUNTIME_ERRORS);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.CATCH_USER_ERRORS);
createSingleJobParameter(statsAndLotsElement, nameValueMap, IJobSettingConstants.CATCH_USER_WARNING);
// verson setting see job info
element.add(jobSettingInfoElement);
}
use of org.talend.core.model.properties.JobletProcessItem 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;
}
Aggregations