use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class XMLOutputMetaTest method testLoadAndGetXml.
@Test
public void testLoadAndGetXml() throws Exception {
XMLOutputMeta xmlOutputMeta = new XMLOutputMeta();
Node stepnode = getTestNode();
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
IMetaStore metaStore = mock(IMetaStore.class);
xmlOutputMeta.loadXML(stepnode, Collections.singletonList(dbMeta), metaStore);
assertXmlOutputMeta(xmlOutputMeta);
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class XMLOutputMetaTest method testGetFields.
@Test
public void testGetFields() throws Exception {
XMLOutputMeta xmlOutputMeta = new XMLOutputMeta();
xmlOutputMeta.setDefault();
XMLField xmlField = new XMLField();
xmlField.setFieldName("aField");
xmlField.setLength(10);
xmlField.setPrecision(3);
xmlOutputMeta.setOutputFields(new XMLField[] { xmlField });
RowMetaInterface row = mock(RowMetaInterface.class);
RowMetaInterface rmi = mock(RowMetaInterface.class);
StepMeta nextStep = mock(StepMeta.class);
Repository repo = mock(Repository.class);
IMetaStore metastore = mock(IMetaStore.class);
ValueMetaInterface vmi = mock(ValueMetaInterface.class);
when(row.searchValueMeta("aField")).thenReturn(vmi);
xmlOutputMeta.getFields(row, "", new RowMetaInterface[] { rmi }, nextStep, new Variables(), repo, metastore);
verify(vmi).setLength(10, 3);
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class XMLOutputMetaTest method testClone.
@Test
public void testClone() throws Exception {
XMLOutputMeta xmlOutputMeta = new XMLOutputMeta();
Node stepnode = getTestNode();
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
IMetaStore metaStore = mock(IMetaStore.class);
xmlOutputMeta.loadXML(stepnode, Collections.singletonList(dbMeta), metaStore);
XMLOutputMeta cloned = (XMLOutputMeta) xmlOutputMeta.clone();
assertNotSame(cloned, xmlOutputMeta);
assertXmlOutputMeta(cloned);
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class StarModelerPerspective method createSharedDatabase.
protected void createSharedDatabase(CCombo targetDatabase) {
Shell shell = Spoon.getInstance().getShell();
boolean retry = true;
while (retry) {
try {
DatabaseMeta dbMeta = new DatabaseMeta();
DatabaseDialog databaseDialog = new DatabaseDialog(shell, dbMeta);
if (databaseDialog.open() != null) {
// Add dbMeta to the shared databases...
//
IMetaStore metaStore = Spoon.getInstance().getMetaStore();
DatabaseMetaStoreUtil.createDatabaseElement(metaStore, dbMeta);
// Refresh the list...
//
final List<DatabaseMeta> sharedDatabases = DatabaseMetaStoreUtil.getDatabaseElements(metaStore);
String[] databaseNames = SharedDatabaseUtil.getSortedDatabaseNames(sharedDatabases);
targetDatabase.setItems(databaseNames);
targetDatabase.setText(dbMeta.getName());
}
retry = false;
} catch (MetaStoreElementExistException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "StarModelerPerspective.Exception.UnableToCreateSharedDB.Title"), BaseMessages.getString(PKG, "StarModelerPerspective.Exception.UnableToCreateSharedDB.Message"), e);
} catch (MetaStoreException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "StarModelerPerspective.Exception.UnableToCreateSharedDB.Title"), BaseMessages.getString(PKG, "StarModelerPerspective.Exception.UnableToCreateSharedDB.Message"), e);
retry = false;
}
}
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class StarModelerPerspective method save.
@Override
public boolean save(EngineMetaInterface meta, String fname, boolean isExport) {
try {
//
if (meta instanceof StarDomain) {
StarDomain starDomain = (StarDomain) meta;
// Make sure we pick the active MetaStore to save to, otherwise it's hard to verify
//
IMetaStore metaStore = Spoon.getInstance().metaStore.getActiveMetaStore();
LogChannel.GENERAL.logBasic("Saving star domain to meta store: " + metaStore.getName());
// Save the name and description of the shared dimension in the metastore
//
StarDomainMetaStoreUtil.saveStarDomain(metaStore, starDomain);
//
for (LogicalTable sharedDimension : starDomain.getSharedDimensions()) {
SharedDimensionMetaStoreUtil.saveSharedDimension(metaStore, sharedDimension, defaultLocale);
}
meta.clearChanged();
Spoon.getInstance().enableMenus();
return true;
}
} catch (Exception e) {
new ErrorDialog(Spoon.getInstance().getShell(), "Error saving model", "There was an error while saving the model:", e);
}
return false;
}
Aggregations