use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class BuildJobHandler method addDQDependencies.
private void addDQDependencies(IFolder parentFolder, List<Item> items) throws Exception {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQItemService.class)) {
ITDQItemService tdqItemService = (ITDQItemService) GlobalServiceRegister.getDefault().getService(ITDQItemService.class);
for (Item item : items) {
if (tdqItemService != null && tdqItemService.hasProcessItemDependencies(Arrays.asList(new Item[] { item }))) {
setNeedItemDependencies(true);
// add .Talend.definition file
//$NON-NLS-1$
String defIdxFolderName = "TDQ_Libraries";
//$NON-NLS-1$
String defIdxFileName = ".Talend.definition";
Project pro = getProject(processItem);
IFolder itemsProjectFolder = parentFolder.getFolder(pro.getTechnicalLabel().toLowerCase());
File itemsFolderDir = new File(parentFolder.getLocation().toFile().getAbsolutePath());
IProject project = ReponsitoryContextBridge.getRootProject();
String defIdxRelativePath = defIdxFolderName + PATH_SEPARATOR + defIdxFileName;
IFile defIdxFile = project.getFile(defIdxRelativePath);
if (defIdxFile.exists()) {
File defIdxFileSource = new File(project.getLocation().makeAbsolute().append(defIdxFolderName).append(defIdxFileName).toFile().toURI());
File defIdxFileTarget = new File(itemsProjectFolder.getFile(defIdxRelativePath).getLocation().toFile().getAbsolutePath());
FilesUtils.copyFile(defIdxFileSource, defIdxFileTarget);
}
// add report header image & template files
//$NON-NLS-1$
String reportingBundlePath = PluginChecker.getBundlePath("org.talend.dataquality.reporting");
//$NON-NLS-1$
File imageFolder = new File(reportingBundlePath + PATH_SEPARATOR + "images");
if (imageFolder.exists()) {
FilesUtils.copyDirectory(imageFolder, itemsFolderDir);
}
//$NON-NLS-1$
File templateFolder = new File(reportingBundlePath + PATH_SEPARATOR + "reports");
if (templateFolder.exists() && templateFolder.isDirectory()) {
FilesUtils.copyDirectory(templateFolder, itemsFolderDir);
}
}
}
// maven command 'include-survivorship-rules' to export.
if (!isOptionChoosed(ExportChoice.needJobItem)) {
ExportFileResource resouece = new ExportFileResource();
BuildExportManager.getInstance().exportDependencies(resouece, processItem);
if (!resouece.getAllResources().isEmpty()) {
final Iterator<String> relativepath = resouece.getRelativePathList().iterator();
//$NON-NLS-1$
String pathStr = "metadata/survivorship";
IFolder targetFolder = talendProcessJavaProject.getResourcesFolder();
if (targetFolder.exists()) {
IFolder survFolder = targetFolder.getFolder(new Path(pathStr));
// only copy self job rules, clear the 'survivorship' folder before copy.
if (survFolder.exists()) {
survFolder.delete(true, null);
}
while (relativepath.hasNext()) {
String relativePath = relativepath.next();
Set<URL> sources = resouece.getResourcesByRelativePath(relativePath);
for (URL sourceUrl : sources) {
File currentResource = new File(org.talend.commons.utils.io.FilesUtils.getFileRealPath(sourceUrl.getPath()));
if (currentResource.exists()) {
FilesUtils.copyDirectory(currentResource, new File(targetFolder.getLocation().toPortableString() + File.separator + pathStr));
}
}
}
}
}
parentFolder.refreshLocal(IResource.DEPTH_INFINITE, null);
}
}
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class JobJavaScriptOSGIForESBManager method createAnalyzer.
protected Analyzer createAnalyzer(ExportFileResource libResource, ProcessItem processItem) throws IOException {
Analyzer analyzer = new Analyzer();
Jar bin = new Jar(classesLocation);
analyzer.setJar(bin);
final String bundleName = processItem.getProperty().getLabel();
String symbolicName = bundleName;
// http://jira.talendforge.org/browse/TESB-5382 LiXiaopeng
Project project = ProjectManager.getInstance().getCurrentProject();
if (project != null) {
String proName = project.getLabel();
if (proName != null) {
symbolicName = proName.toLowerCase() + '.' + symbolicName;
}
}
analyzer.setProperty(Analyzer.BUNDLE_NAME, bundleName);
analyzer.setProperty(Analyzer.BUNDLE_SYMBOLICNAME, symbolicName);
analyzer.setProperty(Analyzer.BUNDLE_VERSION, getBundleVersion());
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
analyzer.setProperty(Analyzer.BUNDLE_VENDOR, //$NON-NLS-1$
brandingService.getFullProductName() + " (" + brandingService.getAcronym() + '_' + RepositoryPlugin.getDefault().getBundle().getVersion().toString() + //$NON-NLS-1$
")");
addOsgiDependencies(analyzer, libResource, processItem);
//$NON-NLS-1$
final StringBuilder bundleClasspath = new StringBuilder(".");
final StringBuilder bundleNativeCode = new StringBuilder();
Set<String> relativePathList = libResource.getRelativePathList();
for (String path : relativePathList) {
Set<URL> resources = libResource.getResourcesByRelativePath(path);
for (URL url : resources) {
File dependencyFile = new File(FilesUtils.getFileRealPath(url.getPath()));
String relativePath = libResource.getDirectoryName() + PATH_SEPARATOR + dependencyFile.getName();
bundleClasspath.append(MANIFEST_ITEM_SEPARATOR).append(relativePath);
bin.putResource(relativePath, new FileResource(dependencyFile));
// Add dynamic library declaration in manifest
if (relativePath.toLowerCase().endsWith(DLL_FILE) || relativePath.toLowerCase().endsWith(SO_FILE)) {
bundleNativeCode.append(libResource.getDirectoryName() + PATH_SEPARATOR + dependencyFile.getName()).append(OSGI_OS_CODE);
}
}
}
analyzer.setProperty(Analyzer.BUNDLE_CLASSPATH, bundleClasspath.toString());
// TESB-15680: Add Bundle-NativeCode in manifest
if (bundleNativeCode.length() > 0) {
bundleNativeCode.setLength(bundleNativeCode.length() - 1);
analyzer.setProperty(Analyzer.BUNDLE_NATIVECODE, bundleNativeCode.toString());
}
return analyzer;
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class JobJavaScriptsWSManager method getExportResources.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobJavaScriptsManager#getExportResources
* (org.talend.repository.ui.wizards.exportjob.ExportFileResource[], java.util.Map, java.lang.String,
* java.lang.String, int, int, java.lang.String[])
*/
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] process, String... codeOptions) throws ProcessorException {
List<ExportFileResource> list = new ArrayList<ExportFileResource>();
boolean needJob = true;
boolean needSource = isOptionChoosed(ExportChoice.needSourceCode);
boolean needContext = isOptionChoosed(ExportChoice.needContext);
//$NON-NLS-1$
ExportFileResource libResource = new ExportFileResource(null, "WEB-INF/lib");
//$NON-NLS-1$
ExportFileResource contextResource = new ExportFileResource(null, "WEB-INF/classes");
//$NON-NLS-1$
ExportFileResource srcResource = new ExportFileResource(null, "WEB-INF");
if (needJob) {
list.add(libResource);
}
if (needContext) {
list.add(contextResource);
}
if (needSource) {
list.add(srcResource);
}
copyServerConfigFileToTempDir();
// set export config mode now only to be sure that the libraries will be setup for an export mode, and not
// editor mode.
//$NON-NLS-1$
ProcessorUtilities.setExportConfig("java", "", "");
for (ExportFileResource exportResource : process) {
ProcessItem processItem = (ProcessItem) exportResource.getItem();
String selectedJobVersion = processItem.getProperty().getVersion();
if (!isMultiNodes() && this.getSelectedJobVersion() != null) {
selectedJobVersion = this.getSelectedJobVersion();
}
if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS, tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
}
}
// Gets talend libraries
List<URL> talendLibraries = getExternalLibraries(true, process);
libResource.addResources(talendLibraries);
// Add log4j files if needed
if (Log4jPrefsSettingManager.getInstance().isLog4jEnable()) {
addLog4jXmlToRes(contextResource);
}
for (ExportFileResource proces : process) {
ProcessItem processItem = (ProcessItem) proces.getItem();
String selectedJobVersion = processItem.getProperty().getVersion();
if (!isMultiNodes() && this.getSelectedJobVersion() != null) {
selectedJobVersion = this.getSelectedJobVersion();
}
ProcessorUtilities.setExportConfig(proces.getDirectoryName(), true);
// if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
// generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS,
// tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
// }
// generate the WSDL file
ExportFileResource wsdlFile = getWSDLFile(processItem, isOptionChoosed(ExportChoice.needWSDL), talendLibraries);
list.add(wsdlFile);
// edit the WSDD file
editWSDDFile(processItem);
// add children jobs
boolean needChildren = true;
addSubJobResources(process, processItem, needChildren, exportChoice, libResource, contextResource, srcResource, selectedJobVersion);
// generate the context file
getContextScripts(processItem, needContext, contextResource, selectedJobVersion);
// generate jar file for job
libResource.addResources(getJobScripts(processItem, selectedJobVersion, needJob));
// dynamic db xml mapping
addXmlMapping(proces, isOptionChoosed(ExportChoice.needSourceCode));
}
// generate Server Config file
ExportFileResource serverConfigFile = getServerConfigFile(isOptionChoosed(ExportChoice.needCONFIGFILE));
list.add(serverConfigFile);
// generate the WSDD file
ExportFileResource wsddFile = getWSDDFile(isOptionChoosed(ExportChoice.needWSDD));
list.add(wsddFile);
// generate the WEB-INFO folder
ExportFileResource webInfoFolder = getWebXMLFile(isOptionChoosed(ExportChoice.needWEBXML));
list.add(webInfoFolder);
// generate the META-INFO folder
ExportFileResource metaInfoFolder = genMetaInfoFolder(isOptionChoosed(ExportChoice.needMetaInfo));
list.add(metaInfoFolder);
// Gets system routines
List<URL> systemRoutineList = getSystemRoutine(process);
libResource.addResources(systemRoutineList);
// Gets user routines
List<URL> userRoutineList = getUserRoutine(process);
libResource.addResources(userRoutineList);
// Gets axis libraries
List<ModuleNeeded> newAxisLib = new ArrayList<ModuleNeeded>(axisLib);
for (URL libUrl : talendLibraries) {
if (libUrl.getFile() != null) {
newAxisLib.remove(new File(libUrl.getFile()).getName());
}
}
List<URL> axisLibList = getLib(newAxisLib, isOptionChoosed(ExportChoice.needAXISLIB));
libResource.addResources(axisLibList);
return list;
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getExportResources.
/*
* (non-Javadoc)
*
* @see
* org.talend.repository.ui.wizards.exportjob.JobScriptsManager#getExportResources(org.talend.core.model.properties
* .ProcessItem[], boolean, boolean, boolean, boolean, boolean, boolean, boolean, java.lang.String)
*/
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] process, String... codeOptions) throws ProcessorException {
exportFileResource = process;
for (int i = 0; i < process.length; i++) {
ProcessItem processItem = (ProcessItem) process[i].getItem();
String selectedJobVersion = processItem.getProperty().getVersion();
selectedJobVersion = preExportResource(process, i, selectedJobVersion);
IProcess jobProcess = null;
// code is just kept like this to avoid too big changes right now.
if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
if (contextName != null) {
jobProcess = generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS || isOptionChoosed(ExportChoice.addStatistics), tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
}
analysisModules(processItem.getProperty().getId(), selectedJobVersion);
} else {
LastGenerationInfo.getInstance().setModulesNeededWithSubjobPerJob(processItem.getProperty().getId(), processItem.getProperty().getVersion(), Collections.<ModuleNeeded>emptySet());
LastGenerationInfo.getInstance().setLastMainJob(null);
}
List<URL> resources = new ArrayList<URL>();
List<URL> childrenList = new ArrayList<URL>();
if (CommonsPlugin.isHeadless()) {
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, codeOptions);
} else {
String log4jOption = getLog4jLevel() != null ? TalendProcessArgumentConstant.CMD_ARG_LOG4J_LEVEL + getLog4jLevel().toLowerCase() : null;
String[] newCodeOptions = codeOptions;
if (!ArrayUtils.contains(codeOptions, log4jOption)) {
newCodeOptions = (String[]) ArrayUtils.add(codeOptions, log4jOption);
}
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, newCodeOptions);
}
resources.addAll(childrenList);
process[i].addResources(resources);
// Gets job designer resouce
// List<URL> srcList = getSource(processItem, exportChoice.get(ExportChoice.needSource));
// process[i].addResources(JOB_SOURCE_FOLDER_NAME, srcList);
}
// Exports the system libs
List<ExportFileResource> list = new ArrayList<ExportFileResource>(Arrays.asList(process));
// Add the java system libraries
ExportFileResource libResource = getCompiledLibExportFileResource(process);
list.add(libResource);
// Gets jobInfo.properties
// only addClasspathJar not check in preferences ,then export the jobInfo.properties
boolean addClasspathJar = false;
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
addClasspathJar = designerCoreUIService.getPreferenceStore().getBoolean(IRepositoryPrefConstants.ADD_CLASSPATH_JAR);
}
if (!addClasspathJar) {
if (!(process.length > 1)) {
for (ExportFileResource pro : process) {
ExportFileResource jobInfoResource = new ExportFileResource(null, PATH_SEPARATOR);
if (CommonsPlugin.isHeadless()) {
jobInfoResource = new ExportFileResource();
}
list.add(jobInfoResource);
List<URL> jobInfoList = getJobInfoFile(pro, contextName);
jobInfoResource.addResources(jobInfoList);
}
}
}
if (PluginChecker.isRulesPluginLoaded()) {
// hywang add for 6484,add final drl files or xls files to exported job script
//$NON-NLS-1$
ExportFileResource ruleFileResource = new ExportFileResource(null, "Rules/rules/final");
list.add(ruleFileResource);
try {
Map<String, List<URL>> map = initUrlForRulesFiles(process);
Object[] keys = map.keySet().toArray();
for (Object key : keys) {
List<URL> talendDrlFiles = map.get(key.toString());
ruleFileResource.addResources(key.toString(), talendDrlFiles);
}
} catch (CoreException e) {
ExceptionHandler.process(e);
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
return list;
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getLibPath.
public List<File> getLibPath(boolean isSpecialMR) {
List<File> ret = new ArrayList<File>();
if (exportFileResource != null) {
ExportFileResource libResource = getCompiledLibExportFileResource(exportFileResource, isSpecialMR);
Collection<Set<URL>> col = libResource.getAllResources();
// this from org.talend.libraries.apache.storm/lib
URL stormLibUrl = null;
File file = null;
try {
stormLibUrl = FileLocator.toFileURL(FileLocator.find(Platform.getBundle(PLUGIN_ID), new Path("lib"), null));
file = new File(stormLibUrl.getFile());
} catch (IOException e) {
ExceptionHandler.process(e);
}
for (Set<URL> set : col) {
Iterator<URL> it = set.iterator();
while (it.hasNext()) {
URL url = it.next();
// for storm not include the jar from libraries.apache.strom
if (!isSpecialMR && stormLibUrl != null && file != null) {
File[] jars = file.listFiles();
String name = url.getFile().substring(url.getFile().lastIndexOf("/") + 1, url.getFile().length());
boolean isExist = false;
for (File jarFile : jars) {
if (jarFile.getName().equals(name)) {
isExist = true;
}
}
if (!isExist) {
ret.add(new File(url.getFile()));
}
} else {
ret.add(new File(url.getFile()));
}
}
}
}
return ret;
}
Aggregations