use of org.pentaho.di.resource.ResourceExportInterface in project pentaho-kettle by pentaho.
the class Spoon method exportAllXMLFile.
/**
* Export this job or transformation including all depending resources to a single zip file.
*/
public void exportAllXMLFile() {
ResourceExportInterface resourceExportInterface = getActiveTransformation();
if (resourceExportInterface == null) {
resourceExportInterface = getActiveJob();
}
if (resourceExportInterface == null) {
// nothing to do here, prevent an NPE
return;
}
//
try {
String zipFilename = null;
while (Utils.isEmpty(zipFilename)) {
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setText(BaseMessages.getString(PKG, "Spoon.ExportResourceSelectZipFile"));
dialog.setFilterExtensions(new String[] { "*.zip;*.ZIP", "*" });
dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.ZIPFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
setFilterPath(dialog);
if (dialog.open() != null) {
lastDirOpened = dialog.getFilterPath();
zipFilename = dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName();
FileObject zipFileObject = KettleVFS.getFileObject(zipFilename);
if (zipFileObject.exists()) {
MessageBox box = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL);
box.setMessage(BaseMessages.getString(PKG, "Spoon.ExportResourceZipFileExists.Message", zipFilename));
box.setText(BaseMessages.getString(PKG, "Spoon.ExportResourceZipFileExists.Title"));
int answer = box.open();
if (answer == SWT.CANCEL) {
return;
}
if (answer == SWT.NO) {
zipFilename = null;
}
}
} else {
return;
}
}
// Export the resources linked to the currently loaded file...
//
TopLevelResource topLevelResource = ResourceUtil.serializeResourceExportInterface(zipFilename, resourceExportInterface, (VariableSpace) resourceExportInterface, rep, metaStore);
String message = ResourceUtil.getExplanation(zipFilename, topLevelResource.getResourceName(), resourceExportInterface);
/*
* // Add the ZIP file as a repository to the repository list... // RepositoriesMeta repositoriesMeta = new
* RepositoriesMeta(); repositoriesMeta.readData();
*
* KettleFileRepositoryMeta fileRepositoryMeta = new KettleFileRepositoryMeta(
* KettleFileRepositoryMeta.REPOSITORY_TYPE_ID, "Export " + baseFileName, "Export to file : " + zipFilename,
* "zip://" + zipFilename + "!"); fileRepositoryMeta.setReadOnly(true); // A ZIP file is read-only int nr = 2;
* String baseName = fileRepositoryMeta.getName(); while
* (repositoriesMeta.findRepository(fileRepositoryMeta.getName()) != null) { fileRepositoryMeta.setName(baseName +
* " " + nr); nr++; }
*
* repositoriesMeta.addRepository(fileRepositoryMeta); repositoriesMeta.writeData();
*/
// Show some information concerning all this work...
EnterTextDialog enterTextDialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ResourceSerialized"), BaseMessages.getString(PKG, "Spoon.Dialog.ResourceSerializedSuccesfully"), message);
enterTextDialog.setReadOnly();
enterTextDialog.open();
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), BaseMessages.getString(PKG, "Spoon.ErrorExportingFile"), e);
}
}
use of org.pentaho.di.resource.ResourceExportInterface in project pentaho-kettle by pentaho.
the class Spoon method exportAllFileRepository.
/**
* Export this job or transformation including all depending resources to a single ZIP file containing a file
* repository.
*/
public void exportAllFileRepository() {
ResourceExportInterface resourceExportInterface = getActiveTransformation();
if (resourceExportInterface == null) {
resourceExportInterface = getActiveJob();
}
if (resourceExportInterface == null) {
// nothing to do here, prevent an NPE
return;
}
//
try {
String zipFilename = null;
while (Utils.isEmpty(zipFilename)) {
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setText(BaseMessages.getString(PKG, "Spoon.ExportResourceSelectZipFile"));
dialog.setFilterExtensions(new String[] { "*.zip;*.ZIP", "*" });
dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.ZIPFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
setFilterPath(dialog);
if (dialog.open() != null) {
lastDirOpened = dialog.getFilterPath();
zipFilename = dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName();
FileObject zipFileObject = KettleVFS.getFileObject(zipFilename);
if (zipFileObject.exists()) {
MessageBox box = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL);
box.setMessage(BaseMessages.getString(PKG, "Spoon.ExportResourceZipFileExists.Message", zipFilename));
box.setText(BaseMessages.getString(PKG, "Spoon.ExportResourceZipFileExists.Title"));
int answer = box.open();
if (answer == SWT.CANCEL) {
return;
}
if (answer == SWT.NO) {
zipFilename = null;
}
}
} else {
return;
}
}
// Export the resources linked to the currently loaded file...
//
TopLevelResource topLevelResource = ResourceUtil.serializeResourceExportInterface(zipFilename, resourceExportInterface, (VariableSpace) resourceExportInterface, rep, metaStore);
String message = ResourceUtil.getExplanation(zipFilename, topLevelResource.getResourceName(), resourceExportInterface);
/*
* // Add the ZIP file as a repository to the repository list... // RepositoriesMeta repositoriesMeta = new
* RepositoriesMeta(); repositoriesMeta.readData();
*
* KettleFileRepositoryMeta fileRepositoryMeta = new KettleFileRepositoryMeta(
* KettleFileRepositoryMeta.REPOSITORY_TYPE_ID, "Export " + baseFileName, "Export to file : " + zipFilename,
* "zip://" + zipFilename + "!"); fileRepositoryMeta.setReadOnly(true); // A ZIP file is read-only int nr = 2;
* String baseName = fileRepositoryMeta.getName(); while
* (repositoriesMeta.findRepository(fileRepositoryMeta.getName()) != null) { fileRepositoryMeta.setName(baseName +
* " " + nr); nr++; }
*
* repositoriesMeta.addRepository(fileRepositoryMeta); repositoriesMeta.writeData();
*/
// Show some information concerning all this work...
//
EnterTextDialog enterTextDialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ResourceSerialized"), BaseMessages.getString(PKG, "Spoon.Dialog.ResourceSerializedSuccesfully"), message);
enterTextDialog.setReadOnly();
enterTextDialog.open();
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), BaseMessages.getString(PKG, "Spoon.ErrorExportingFile"), e);
}
}
Aggregations