use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class PaletteSettingPage method addUsedComponents.
private void addUsedComponents(Set<IComponent> components, List<IRepositoryViewObject> allProcess, ComponentCategory category) {
for (IRepositoryViewObject object : allProcess) {
Item item = object.getProperty().getItem();
List parameters = null;
ProcessType processType = null;
if (item instanceof ProcessItem) {
processType = ((ProcessItem) item).getProcess();
} else if (item instanceof JobletProcessItem) {
processType = ((JobletProcessItem) item).getJobletProcess();
}
if (processType != null) {
for (Object oNode : processType.getNode()) {
NodeType node = (NodeType) oNode;
IComponent component = ComponentsFactoryProvider.getInstance().get(node.getComponentName(), category.getName());
if (component != null && component.getComponentType() == EComponentType.EMF) {
components.add(component);
}
}
if (processType.getParameters() != null) {
// occurs actually only in joblets
parameters = processType.getParameters().getElementParameter();
}
}
if (parameters != null) {
// used in stats&log and implicite
Set<IComponent> inStatsLogsAndImplicit = getComponentsInStatsLogsAndImplicit(parameters);
if (inStatsLogsAndImplicit != null) {
components.addAll(inStatsLogsAndImplicit);
}
}
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class HTMLDocGenerator method generateDocumentation.
/*
* 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#generateDocumentation(org.talend.repository
* .documentation.ExportFileResource, java.lang.String, java.lang.String[])
*/
@Override
public void generateDocumentation(ExportFileResource resource, String targetPath, String... jobVersion) throws Exception {
// Store all pictures' path.
List<URL> picList = new ArrayList<URL>(5);
String jobName = resource.getItem().getProperty().getLabel();
String jobPath = resource.getItem().getProperty().getItem().getState().getPath();
// Used for generating/updating all jobs' documentaiton only.
String typePath = new Path(this.repositoryObjectType.getFolder()).lastSegment();
if (jobName != null && !(jobName).equals(typePath.toLowerCase()) && targetPath.endsWith(typePath.toLowerCase())) {
targetPath = targetPath + IPath.SEPARATOR + jobPath + IPath.SEPARATOR + jobName;
}
//$NON-NLS-1$
String version = "";
// Checks if the job's version is specified, see it on "Export documentation" Dialog:
if (jobVersion != null && jobVersion.length == 1) {
version = jobVersion[0];
} else {
version = resource.getItem().getProperty().getVersion();
}
//$NON-NLS-1$
targetPath = targetPath + "_" + version;
File file = new File(targetPath);
// Delete if folde is existing.
if (file.exists()) {
FilesUtils.removeFolder(file, true);
}
file.mkdirs();
handleXMLFile(resource, targetPath, jobVersion);
String picFolderPath = checkPicDirIsExists(resource, targetPath);
// Gets the "org.talend.repository" plug-in:
//$NON-NLS-1$
final Bundle b = Platform.getBundle("org.talend.repository");
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 set css file in preference.
boolean isCheck = CorePlugin.getDefault().getPreferenceStore().getBoolean(ITalendCorePrefConstants.USE_CSS_TEMPLATE);
String cssFile = CorePlugin.getDefault().getPreferenceStore().getString(ITalendCorePrefConstants.CSS_FILE_PATH);
String temXslPath = null;
if (isCheck && cssFile != null && !cssFile.equals("")) {
//$NON-NLS-1$
String tempFolderPath = checkTempDirIsExists(resource);
temXslPath = tempFolderPath + File.separator + (new File(xslFilePath)).getName();
File temXslFile = new File(temXslPath);
if (temXslFile.exists()) {
temXslFile.delete();
}
generateXslFile(xslFilePath, temXslPath, cssFile, null);
}
// if no new xls generated, use default xsl
if (temXslPath != null) {
File temFile = new File(temXslPath);
if (!temFile.exists()) {
temXslPath = xslFilePath;
}
} else {
temXslPath = xslFilePath;
}
picList.add(logoFile.toURL());
// Property property = item.getProperty();
// String jobName = property.getLabel();
// String jobVersion = property.getVersion();
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) {
//$NON-NLS-1$
String picName = jobName + "_" + version + IHTMLDocConstants.JOB_PREVIEW_PIC_SUFFIX;
ImageUtils.save(innerContent, picFolderPath + File.separatorChar + picName, SWT.IMAGE_PNG);
picList.add(new File(picFolderPath + File.separatorChar + picName).toURL());
// need to generate another pic for pdf
ByteArrayInputStream bais = new ByteArrayInputStream(innerContent);
Image pdfImage = new Image(null, bais);
int width = pdfImage.getImageData().width;
int percent = 22 * 32 * 100 / width;
//$NON-NLS-1$
ImageUtils.save(//$NON-NLS-1$
ImageUtils.scale(pdfImage, percent), //$NON-NLS-1$
picFolderPath + File.separatorChar + "pdf_" + picName, SWT.IMAGE_PNG);
//$NON-NLS-1$
picList.add(new File(picFolderPath + File.separatorChar + "pdf_" + picName).toURL());
pdfImage.dispose();
}
if (processType != null) {
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) {
String picName = IHTMLDocConstants.EXTERNAL_NODE_PREVIEW + uniqueName + IHTMLDocConstants.JOB_PREVIEW_PIC_SUFFIX;
ImageUtils.save(screenshot, picFolderPath + File.separatorChar + picName, SWT.IMAGE_PNG);
picList.add(new File(picFolderPath + File.separatorChar + picName).toURL());
// need to generate externalNode pic for pdf
ByteArrayInputStream bais = new ByteArrayInputStream(screenshot);
Image pdfImage = new Image(null, bais);
int width = pdfImage.getImageData().width;
int percent = 22 * 32 * 100 / width;
//$NON-NLS-1$
ImageUtils.save(//$NON-NLS-1$
ImageUtils.scale(pdfImage, percent), //$NON-NLS-1$
picFolderPath + File.separatorChar + "pdf_" + picName, SWT.IMAGE_PNG);
picList.add(new File(picFolderPath + File.separatorChar + picName).toURL());
pdfImage.dispose();
}
}
}
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());
}
//$NON-NLS-1$
List<URL> resultFiles = parseXml2HtmlPdf(targetPath, jobName + "_" + version, temXslPath);
resource.addResources(resultFiles);
resource.addResources(IHTMLDocConstants.PIC_FOLDER_NAME, picList);
HTMLDocUtils.deleteTempFiles();
// List<URL> externalList = getExternalHtmlPath();
// resource.addResources(IHTMLDocConstants.EXTERNAL_FOLDER_NAME, externalList);
targetConnectionMap = null;
sourceConnectionMap = null;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class AddConnectorNameInConnections method addConnectorName.
/**
* DOC nrousseau Comment method "addConnectorName".
*
* @param item
* @return
*/
private boolean addConnectorName(Item item) throws PersistenceException {
ProcessType processType = getProcessType(item);
if (processType == null) {
return false;
}
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
for (Object o : processType.getConnection()) {
ConnectionType currentConnection = (ConnectionType) o;
if (currentConnection.getConnectorName() == null) {
EConnectionType connectionType = EConnectionType.getTypeFromId(currentConnection.getLineStyle());
currentConnection.setConnectorName(connectionType.getName());
modified = true;
}
}
if (modified) {
factory.save(item, true);
}
return modified;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class ActivateQueryLogging method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
List<String> filterList = Arrays.asList("tELTTeradataMap", "tTeradataConnection", "tTeradataInput", "tTeradataOutput", "tTeradataRow");
IComponentConversion correctBatchModeForDBComponents = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType queryBand = ComponentUtilities.getNodeProperty(node, "QUERY_BAND");
ElementParameterType activateQueryLogging = ComponentUtilities.getNodeProperty(node, "ACTIVATE_QUERY_LOGGING");
if (activateQueryLogging == null) {
ComponentUtilities.addNodeProperty(node, "ACTIVATE_QUERY_LOGGING", "CHECK");
if (queryBand != null) {
boolean queryBandActived = "true".equalsIgnoreCase(queryBand.getValue());
if (queryBandActived) {
ComponentUtilities.getNodeProperty(node, "ACTIVATE_QUERY_LOGGING").setValue("true");
}
}
}
}
};
for (String componentName : filterList) {
IComponentFilter filter = new NameComponentFilter(componentName);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(correctBatchModeForDBComponents));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class AddNewIgnoreNullSettingForTMicrosoftCrmOutputTask method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
String componentName = "tMicrosoftCrmOutput";
try {
IComponentFilter filter = new NameComponentFilter(componentName);
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
@Override
public void transform(NodeType node) {
if (ComponentUtilities.getNodeProperty(node, "IGNORE_NULL") == null && ComponentUtilities.getNodeProperty(node, "MS_CRM_VERSION") == null) {
ComponentUtilities.addNodeProperty(node, "IGNORE_NULL", "CHECK");
ComponentUtilities.getNodeProperty(node, "IGNORE_NULL").setValue("true");
}
}
}));
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
Aggregations