use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.
the class LineageWriterTest method setUp.
@Before
public void setUp() throws Exception {
LineageWriter fslw = new LineageWriter();
writer = spy(fslw);
holder = new LineageHolder();
IExecutionProfile profile = new ExecutionProfile();
profile.setName("test");
IExecutionData data = new ExecutionData();
data.setStartTime(now);
profile.setExecutionData(data);
holder.setExecutionProfile(profile);
}
use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.
the class VfsLineageWriterTest method setUp.
@Before
public void setUp() throws Exception {
String basePath = new File(".").getCanonicalPath();
writer = new VfsLineageWriter();
writer = spy(writer);
holder = new LineageHolder();
IExecutionProfile profile = new ExecutionProfile();
profile.setName("test");
IExecutionData data = new ExecutionData();
data.setStartTime(now);
profile.setExecutionData(data);
holder.setExecutionProfile(profile);
BAD_OUTPUT_FOLDER = FilenameUtils.separatorsToSystem("file://" + basePath + BAD_OUTPUT_FOLDER_DEFAULT + random.nextInt());
GOOD_OUTPUT_FOLDER = FilenameUtils.separatorsToSystem("file://" + basePath + GOOD_OUTPUT_FOLDER_DEFAULT + random.nextInt());
writer.setOutputFolder(GOOD_OUTPUT_FOLDER);
}
use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.
the class FileSystemLineageWriter method getOutputDirectoryAsFile.
protected File getOutputDirectoryAsFile(LineageHolder holder) {
File rootFolder = getDateFolder(outputFolder, holder);
boolean rootFolderExists = rootFolder.exists();
if (!rootFolderExists) {
rootFolderExists = rootFolder.mkdirs();
}
if (rootFolderExists) {
IExecutionProfile profile = holder.getExecutionProfile();
String id = holder.getId() == null ? "unknown_artifact" : holder.getId();
try {
// strip off the colon from C:\path\to\file on windows
if (isWindows()) {
id = replaceColonInPath(id);
}
File folder = new File(rootFolder, id);
if (!folder.exists()) {
boolean result = folder.mkdirs();
if (!result) {
log.error("Couldn't create folder: " + folder.getAbsolutePath());
}
} else if (folder.isFile()) {
// must be a folder
throw new IllegalStateException("Output folder must be a folder, not a file. [" + folder.getAbsolutePath() + "]");
}
return folder;
} catch (Exception e) {
log.error("Couldn't create output file", e);
return null;
}
}
return null;
}
use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.
the class FileSystemLineageWriter method createOutputStream.
protected OutputStream createOutputStream(LineageHolder holder, String extension) {
if (holder != null) {
try {
IExecutionProfile profile = holder.getExecutionProfile();
String timestampString = Long.toString(profile.getExecutionData().getStartTime().getTime());
File destFolder = getOutputDirectoryAsFile(holder);
String name = Const.NVL(profile.getName(), "unknown");
File file = new File(destFolder, timestampString + "_" + name + extension);
try {
return new FileOutputStream(file);
} catch (FileNotFoundException e) {
log.error("Couldn't find file: " + file.getAbsolutePath(), e);
return null;
}
} catch (Exception e) {
log.error("Couldn't get output stream", e);
return null;
}
} else {
return null;
}
}
use of org.pentaho.metaverse.api.model.IExecutionProfile in project pentaho-metaverse by pentaho.
the class VfsLineageWriter method getDateFolder.
protected FileObject getDateFolder(LineageHolder holder) throws KettleFileException, FileSystemException {
String dir = "";
if (holder != null && holder.getExecutionProfile() != null) {
IExecutionProfile profile = holder.getExecutionProfile();
dir += dateFolderFormat.format(profile.getExecutionData().getStartTime());
} else {
dir += dateFolderFormat.format(new Date());
}
FileObject lineageRootFolder = KettleVFS.getFileObject(getOutputFolder());
FileObject dateFolder = lineageRootFolder.resolveFile(dir);
return dateFolder;
}
Aggregations