use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class ExportProcessorHelper method exportPigudf.
public void exportPigudf(IProcessor processor, Property property, int statisticsPort, int tracePort) throws ProcessorException {
// build java project
CorePlugin.getDefault().getRunProcessService().buildJavaProject();
Map<ExportChoice, Object> exportChoiceMap = new EnumMap<ExportChoice, Object>(ExportChoice.class);
exportChoiceMap.put(ExportChoice.needPigudf, true);
ProcessItem processItem = (ProcessItem) property.getItem();
ExportFileResource fileResource = new ExportFileResource(processItem, property.getLabel());
ExportFileResource[] exportFileResources = new ExportFileResource[] { fileResource };
JobScriptsManager jobScriptsManager = JobScriptsManagerFactory.createManagerInstance(exportChoiceMap, processor.getContext().getName(), JobScriptsManager.ALL_ENVIRONMENTS, statisticsPort, tracePort, JobExportType.POJO);
URL url = jobScriptsManager.getExportPigudfResources(exportFileResources);
if (url == null) {
return;
}
File file = new File(url.getFile());
File libFolder = JavaProcessorUtilities.getJavaProjectLibFolder();
if (libFolder == null) {
return;
}
File target = new File(libFolder.getAbsolutePath() + property.getLabel() + "_" + property.getVersion() + "_" + file.getName());
try {
FilesUtils.copyFile(file, target);
} catch (IOException e) {
throw new ProcessorException(e.getMessage());
}
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class GenerateDocAsHTMLWizardPage method finish.
/**
* The Finish button was pressed. Try to do the required work now and answer a boolean indicating success. If false
* is returned then the wizard will not close.
*
* @returns boolean
*/
@Override
public boolean finish() {
String topFolder = getRootFolderName();
String destinationFilename = getDestinationValue();
// Save dirty editors if possible but do not stop if not all are saved
saveDirtyEditors();
// about to invoke the operation so save our state
saveWidgetValues();
File file = new File(destinationFilename);
if (file.exists()) {
Boolean open = //$NON-NLS-1$
MessageDialog.openConfirm(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
Messages.getString("GenerateDocAsHTMLWizardPage.Warning"), //$NON-NLS-1$
Messages.getString("GenerateDocAsHTMLWizardPage.OverWrite"));
if (open) {
file.delete();
} else {
return false;
}
}
List<ExportFileResource> resourcesToExport = getExportResources();
setTopFolder(resourcesToExport, topFolder);
ArchiveFileExportOperationFullPath runnable = new ArchiveFileExportOperationFullPath(resourcesToExport, destinationFilename);
// output everything
//$NON-NLS-1$
runnable.setRegEx("*");
boolean ok = executeExportOperation(runnable);
// add for bug TDI-21815
saveLastDirectoryName(runnable);
manager.deleteTempFiles();
return ok;
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class RepositoryService method exportPigudf.
/*
* (non-Javadoc)
*
* @see org.talend.repository.model.IRepositoryService#exportPigudf(org.talend.designer.runprocess.IProcessor,
* org.talend.core.model.properties.Property, int, int)
*/
@Override
public String exportPigudf(IProcessor processor, Property property, boolean isExport) throws ProcessorException {
// build java project
CorePlugin.getDefault().getRunProcessService().buildJavaProject();
Map<ExportChoice, Object> exportChoiceMap = new EnumMap<ExportChoice, Object>(ExportChoice.class);
exportChoiceMap.put(ExportChoice.needPigudf, true);
ProcessItem processItem = (ProcessItem) property.getItem();
ExportFileResource fileResource = new ExportFileResource(processItem, property.getLabel());
ExportFileResource[] exportFileResources = new ExportFileResource[] { fileResource };
IContext context = processor.getContext();
//$NON-NLS-1$
String contextName = "Default";
if (context != null) {
contextName = context.getName();
}
JobScriptsManager jobScriptsManager = JobScriptsManagerFactory.createManagerInstance(exportChoiceMap, contextName, JobScriptsManager.ALL_ENVIRONMENTS, -1, -1, JobExportType.POJO);
URL url = jobScriptsManager.getExportPigudfResources(exportFileResources);
if (url == null) {
return null;
}
File file = new File(url.getFile());
// String librariesPath = LibrariesManagerUtils.getLibrariesPath(ECodeLanguage.JAVA) + "/";
//$NON-NLS-1$
String librariesPath = processor.getCodeProject().getLocation() + "/lib/";
String targetFileName = JobJavaScriptsManager.USERPIGUDF_JAR;
if (!isExport) {
targetFileName = property.getLabel() + '_' + property.getVersion() + '_' + JobJavaScriptsManager.USERPIGUDF_JAR;
}
File target = new File(librariesPath + targetFileName);
try {
FilesUtils.copyFile(file, target);
} catch (IOException e) {
throw new ProcessorException(e.getMessage());
}
return targetFileName;
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class GenerateDocAsHTMLWizardPage method addTreeNode.
private void addTreeNode(RepositoryNode node, String path, List<ExportFileResource> list) {
if (node != null && node.getType() == ENodeType.REPOSITORY_ELEMENT) {
IRepositoryViewObject repositoryObject = node.getObject();
if (repositoryObject.getProperty().getItem() instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) repositoryObject.getProperty().getItem();
ExportFileResource resource = new ExportFileResource(processItem, path);
resource.setNode(node);
list.add(resource);
}
}
Object[] nodes = node.getChildren().toArray();
if (nodes.length <= 0) {
return;
}
for (Object node2 : nodes) {
addTreeNode((RepositoryNode) node2, //$NON-NLS-1$
path + "/" + ((RepositoryNode) node2).getProperties(EProperties.LABEL).toString(), list);
}
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class GenerateDocAsHTMLWizardPage method setTopFolder.
private void setTopFolder(List<ExportFileResource> resourcesToExport, String topFolder) {
for (ExportFileResource fileResource : resourcesToExport) {
String directory = fileResource.getDirectoryName();
//$NON-NLS-1$
fileResource.setDirectoryName(topFolder + "/" + directory);
}
}
Aggregations