use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.
the class Spoon method newJobFile.
public void newJobFile() {
try {
JobMeta jobMeta = new JobMeta();
jobMeta.addObserver(this);
// Set the variables that were previously defined in this session on
// the transformation metadata too.
//
setJobMetaVariables(jobMeta);
// Pass repository information
//
jobMeta.setRepository(rep);
jobMeta.setMetaStore(metaStore);
try {
// TODO: MAKE LIKE TRANS
SharedObjects sharedObjects = rep != null ? rep.readJobMetaSharedObjects(jobMeta) : jobMeta.readSharedObjects();
sharedObjectsFileMap.put(sharedObjects.getFilename(), sharedObjects);
if (rep == null) {
jobMeta.setSharedObjects(sharedObjects);
}
jobMeta.importFromMetaStore();
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Message", delegates.tabs.makeTabName(jobMeta, true)), e);
}
// Set the location of the new jobMeta to that of the default location or the last saved location
jobMeta.setRepositoryDirectory(getDefaultSaveLocation(jobMeta));
int nr = 1;
jobMeta.setName(STRING_JOB + " " + nr);
// loaded...
while (findJob(delegates.tabs.makeTabName(jobMeta, false)) != null) {
nr++;
// rename
jobMeta.setName(STRING_JOB + " " + nr);
}
jobMeta.clearChanged();
addJobGraph(jobMeta);
applyVariables();
//
if (setDesignMode()) {
// No refresh done yet, do so
refreshTree();
}
loadPerspective(MainSpoonPerspective.ID);
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Exception.ErrorCreatingNewJob.Title"), BaseMessages.getString(PKG, "Spoon.Exception.ErrorCreatingNewJob.Message"), e);
}
}
use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.
the class Spoon method newTransFile.
public void newTransFile() {
TransMeta transMeta = new TransMeta();
transMeta.addObserver(this);
// Set the variables that were previously defined in this session on the
// transformation metadata too.
//
setTransMetaVariables(transMeta);
// Pass repository information
//
transMeta.setRepository(rep);
transMeta.setMetaStore(metaStore);
try {
SharedObjects sharedObjects = rep != null ? rep.readTransSharedObjects(transMeta) : transMeta.readSharedObjects();
sharedObjectsFileMap.put(sharedObjects.getFilename(), sharedObjects);
if (rep == null) {
transMeta.setSharedObjects(sharedObjects);
}
transMeta.importFromMetaStore();
transMeta.clearChanged();
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingSharedObjects.Message"), e);
}
// Set the location of the new transMeta to that of the default location or the last saved location
transMeta.setRepositoryDirectory(getDefaultSaveLocation(transMeta));
int nr = 1;
transMeta.setName(STRING_TRANSFORMATION + " " + nr);
//
while (findTransformation(delegates.tabs.makeTabName(transMeta, false)) != null) {
nr++;
// rename
transMeta.setName(STRING_TRANSFORMATION + " " + nr);
}
addTransGraph(transMeta);
applyVariables();
//
if (setDesignMode()) {
// No refresh done yet, do so
refreshTree();
}
loadPerspective(MainSpoonPerspective.ID);
try {
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.TransformationCreateNew.id, transMeta);
} catch (KettleException e) {
log.logError("Failed to call extension point", e);
}
}
use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.
the class PrivateDatabasesTestTemplate method doTest_NoPrivate.
protected void doTest_NoPrivate() throws Exception {
T meta = createMeta();
String xml = toXml(meta);
SharedObjects fakeSharedObjects = createFakeSharedObjects();
T loaded = fromXml(xml, fakeSharedObjects);
Set<String> privateDatabases = loaded.getPrivateDatabases();
assertNotNull(privateDatabases);
assertTrue(privateDatabases.isEmpty());
}
use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.
the class PrivateDatabasesTestTemplate method createFakeSharedObjects.
@SuppressWarnings("unchecked")
protected SharedObjects createFakeSharedObjects(DatabaseMeta... shared) throws Exception {
SharedObjects fake = new SharedObjects();
Map map = fake.getObjectsMap();
map.clear();
if (shared != null) {
// hacky solution
for (DatabaseMeta meta : shared) {
map.put(new Object(), meta);
}
}
return fake;
}
use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.
the class PrivateDatabasesTestTemplate method doTest_OnePrivate_NoShared.
protected void doTest_OnePrivate_NoShared() throws Exception {
T meta = createMeta();
DatabaseMeta privateMeta = createDatabase("privateMeta");
meta.addDatabase(privateMeta);
String xml = toXml(meta);
SharedObjects fakeSharedObjects = createFakeSharedObjects();
T loaded = fromXml(xml, fakeSharedObjects);
List<String> loadedDbs = Arrays.asList(loaded.getDatabaseNames());
assertTrue(loadedDbs.contains("privateMeta"));
Set<String> privateDatabases = loaded.getPrivateDatabases();
assertNotNull(privateDatabases);
assertEquals(1, privateDatabases.size());
assertTrue(privateDatabases.contains(privateMeta.getName()));
}
Aggregations