use of org.pentaho.di.shared.SharedObjectInterface in project pentaho-kettle by pentaho.
the class PurRepository method loadAndCacheSharedObjects.
protected Map<RepositoryObjectType, List<? extends SharedObjectInterface>> loadAndCacheSharedObjects(final boolean deepCopy) throws KettleException {
if (sharedObjectsByType == null) {
try {
sharedObjectsByType = new EnumMap<RepositoryObjectType, List<? extends SharedObjectInterface>>(RepositoryObjectType.class);
// Slave Servers are referenced by Cluster Schemas so they must be loaded first
readSharedObjects(sharedObjectsByType, RepositoryObjectType.DATABASE, RepositoryObjectType.PARTITION_SCHEMA, RepositoryObjectType.SLAVE_SERVER, RepositoryObjectType.CLUSTER_SCHEMA);
} catch (Exception e) {
sharedObjectsByType = null;
// $NON-NLS-1$
throw new KettleException("Unable to read shared objects from repository", e);
}
}
return deepCopy ? deepCopy(sharedObjectsByType) : sharedObjectsByType;
}
use of org.pentaho.di.shared.SharedObjectInterface in project pentaho-kettle by pentaho.
the class PrivateDatabasesTestTemplate method createInjectingAnswer.
protected Answer<SharedObjects> createInjectingAnswer(final T meta, final SharedObjects fakeSharedObjects) throws Exception {
return new Answer<SharedObjects>() {
@Override
public SharedObjects answer(InvocationOnMock invocation) throws Throwable {
for (SharedObjectInterface value : fakeSharedObjects.getObjectsMap().values()) {
DatabaseMeta db = (DatabaseMeta) value;
meta.addOrReplaceDatabase(db);
}
return fakeSharedObjects;
}
};
}
use of org.pentaho.di.shared.SharedObjectInterface in project pentaho-kettle by pentaho.
the class AbstractMeta method saveSharedObjects.
public void saveSharedObjects() throws KettleException {
try {
// Load all the shared objects...
String soFile = environmentSubstitute(sharedObjectsFile);
SharedObjects sharedObjects = new SharedObjects(soFile);
// in-memory shared objects are supposed to be in sync, discard those on file to allow edit/delete
sharedObjects.setObjectsMap(new Hashtable<>());
for (SharedObjectInterface sharedObject : getAllSharedObjects()) {
if (sharedObject.isShared()) {
sharedObjects.storeObject(sharedObject);
}
}
sharedObjects.saveToFile();
} catch (Exception e) {
throw new KettleException("Unable to save shared ojects", e);
}
}
use of org.pentaho.di.shared.SharedObjectInterface in project pentaho-kettle by pentaho.
the class AbstractMeta method readSharedObjects.
/**
* Read shared objects.
*
* @return the shared objects
* @throws KettleException the kettle exception
*/
public SharedObjects readSharedObjects() throws KettleException {
// Extract the shared steps, connections, etc. using the SharedObjects
// class
//
String soFile = environmentSubstitute(sharedObjectsFile);
SharedObjects sharedObjects = new SharedObjects(soFile);
Map<?, SharedObjectInterface> objectsMap = sharedObjects.getObjectsMap();
//
for (SharedObjectInterface object : objectsMap.values()) {
loadSharedObject(object);
}
return sharedObjects;
}
use of org.pentaho.di.shared.SharedObjectInterface in project pentaho-kettle by pentaho.
the class StarModelDialog method addDimensionsTab.
private void addDimensionsTab() {
wDimensionsTab = new CTabItem(wTabFolder, SWT.NONE);
wDimensionsTab.setText(BaseMessages.getString(PKG, "StarModelDialog.DimensionsTab.Label"));
FormLayout dimensionsLayout = new FormLayout();
dimensionsLayout.marginWidth = Const.MARGIN;
dimensionsLayout.marginHeight = Const.MARGIN;
Composite wDimensionsComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wDimensionsComp);
wDimensionsComp.setLayout(dimensionsLayout);
Label wlTables = new Label(wDimensionsComp, SWT.RIGHT);
wlTables.setText(BaseMessages.getString(PKG, "StarModelDialog.Tables.Label"));
props.setLook(wlTables);
FormData fdlAttributes = new FormData();
fdlAttributes.left = new FormAttachment(0, 0);
fdlAttributes.top = new FormAttachment(0, 0);
wlTables.setLayoutData(fdlAttributes);
// A few buttons to edit the list
//
Button newTableButton = new Button(wDimensionsComp, SWT.PUSH);
newTableButton.setText(BaseMessages.getString(PKG, "StarModelDialog.Button.NewTable"));
newTableButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (newTable(shell, logicalModel)) {
refreshTablesList();
}
}
});
Button copyTableButton = new Button(wDimensionsComp, SWT.PUSH);
copyTableButton.setText(BaseMessages.getString(PKG, "StarModelDialog.Button.CopyTable"));
copyTableButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (wTablesList.getSelectionIndex() < 0)
return;
TableItem item = wTablesList.table.getSelection()[0];
String tableName = item.getText(1);
if (copyTable(shell, logicalModel, tableName)) {
refreshTablesList();
}
}
});
Button editTableButton = new Button(wDimensionsComp, SWT.PUSH);
editTableButton.setText(BaseMessages.getString(PKG, "StarModelDialog.Button.EditTable"));
editTableButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (wTablesList.getSelectionIndex() < 0)
return;
TableItem item = wTablesList.table.getSelection()[0];
String tableName = item.getText(1);
if (editTable(tableName)) {
refreshTablesList();
}
}
});
Button delTableButton = new Button(wDimensionsComp, SWT.PUSH);
delTableButton.setText(BaseMessages.getString(PKG, "StarModelDialog.Button.DeleteTable"));
delTableButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (wTablesList.getSelectionIndex() < 0)
return;
TableItem item = wTablesList.table.getSelection()[0];
String tableName = item.getText(1);
if (deleteTable(tableName)) {
refreshTablesList();
}
}
});
BaseStepDialog.positionBottomButtons(wDimensionsComp, new Button[] { newTableButton, copyTableButton, editTableButton, delTableButton }, margin, null);
final int FieldsRows = logicalModel.getLogicalTables().size();
List<DatabaseMeta> sharedDatabases = new ArrayList<DatabaseMeta>();
try {
SharedObjects sharedObjects = new SharedObjects();
for (SharedObjectInterface sharedObject : sharedObjects.getObjectsMap().values()) {
if (sharedObject instanceof DatabaseMeta) {
sharedDatabases.add((DatabaseMeta) sharedObject);
}
}
} catch (Exception e) {
LogChannel.GENERAL.logError("Unable to load shared objects", e);
}
// The dimensions and fact of the model
//
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.Name.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.Description.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.TableType.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false, true) };
wTablesList = new TableView(new Variables(), wDimensionsComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, null, props);
FormData fdTablesList = new FormData();
fdTablesList.left = new FormAttachment(0, 0);
fdTablesList.top = new FormAttachment(wlTables, margin);
fdTablesList.right = new FormAttachment(100, 0);
fdTablesList.bottom = new FormAttachment(newTableButton, -margin);
wTablesList.setLayoutData(fdTablesList);
wTablesList.setReadonly(true);
wTablesList.table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
if (wTablesList.getSelectionIndex() < 0)
return;
TableItem item = wTablesList.table.getSelection()[0];
String tableName = item.getText(1);
if (editTable(tableName)) {
refreshTablesList();
// refreshRelationshipsList();
}
}
});
FormData fdTablesComp = new FormData();
fdTablesComp.left = new FormAttachment(0, 0);
fdTablesComp.top = new FormAttachment(0, 0);
fdTablesComp.right = new FormAttachment(100, 0);
fdTablesComp.bottom = new FormAttachment(100, 0);
wDimensionsComp.setLayoutData(fdTablesComp);
wDimensionsComp.layout();
wDimensionsTab.setControl(wDimensionsComp);
}
Aggregations