use of org.pentaho.di.trans.TransMeta in project pentaho-kettle by pentaho.
the class SpoonMenuABSController method updateMenu.
public void updateMenu(Document doc) {
try {
Spoon spoon = Spoon.getInstance();
boolean createPermitted = true;
boolean executePermitted = true;
// If we are working with an Enterprise Repository
if ((spoon != null) && (spoon.getRepository() != null) && (spoon.getRepository() instanceof PurRepository)) {
Repository repo = spoon.getRepository();
// Check for ABS Security
if (repo.hasService(IAbsSecurityProvider.class)) {
IAbsSecurityProvider securityProvider = (IAbsSecurityProvider) repo.getService(IAbsSecurityProvider.class);
// Get create & execute permission
createPermitted = securityProvider.isAllowed(IAbsSecurityProvider.CREATE_CONTENT_ACTION);
executePermitted = securityProvider.isAllowed(IAbsSecurityProvider.EXECUTE_CONTENT_ACTION);
EngineMetaInterface meta = spoon.getActiveMeta();
// If (meta is not null) and (meta is either a Transformation or Job)
if ((meta != null) && ((meta instanceof JobMeta) || (meta instanceof TransMeta))) {
// Main spoon toolbar
// $NON-NLS-1$
((XulToolbarbutton) doc.getElementById("toolbar-file-new")).setDisabled(!createPermitted);
// $NON-NLS-1$
((XulToolbarbutton) doc.getElementById("toolbar-file-save")).setDisabled(!createPermitted);
// $NON-NLS-1$
((XulToolbarbutton) doc.getElementById("toolbar-file-save-as")).setDisabled(!createPermitted);
// Popup menus
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-class-new")).setDisabled(!createPermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("job-class-new")).setDisabled(!createPermitted);
// Main spoon menu
// $NON-NLS-1$
((XulMenu) doc.getElementById("file-new")).setDisabled(!createPermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("file-save")).setDisabled(!createPermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("file-save-as")).setDisabled(!createPermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("file-close")).setDisabled(!createPermitted);
}
// Handle Execute permissions
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("process-run")).setDisabled(!executePermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-preview")).setDisabled(!executePermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-debug")).setDisabled(!executePermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-replay")).setDisabled(!executePermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-verify")).setDisabled(!executePermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-impact")).setDisabled(!executePermitted);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-get-sql")).setDisabled(!executePermitted);
// Disable Show Last menu under the Action menu. Disable without execute permissions.
// $NON-NLS-1$
((XulMenu) doc.getElementById("trans-last")).setDisabled(!executePermitted);
boolean exportAllowed = createPermitted && executePermitted;
// $NON-NLS-1$
((XulMenu) doc.getElementById("file-export")).setDisabled(!exportAllowed);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("repository-export-all")).setDisabled(!exportAllowed);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("file-save-as-vfs")).setDisabled(!exportAllowed);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("edit-cut-steps")).setDisabled(!exportAllowed);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("edit-copy-steps")).setDisabled(!exportAllowed);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("edit.copy-file")).setDisabled(!exportAllowed);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("edit-paste-steps")).setDisabled(!exportAllowed);
// Schedule is a plugin
if (doc.getElementById("trans-schedule") != null) {
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("trans-schedule")).setDisabled(!executePermitted);
}
TransGraph transGraph = Spoon.getInstance().getActiveTransGraph();
if (transGraph != null) {
XulToolbar toolbar = transGraph.getToolbar();
XulToolbarbutton runButton = (XulToolbarbutton) toolbar.getElementById("trans-run");
XulToolbarbutton debugButton = (XulToolbarbutton) toolbar.getElementById("trans-debug");
XulToolbarbutton previewButton = (XulToolbarbutton) toolbar.getElementById("trans-preview");
XulToolbarbutton replayButton = (XulToolbarbutton) toolbar.getElementById("trans-replay");
XulToolbarbutton verifyButton = (XulToolbarbutton) toolbar.getElementById("trans-verify");
XulToolbarbutton impactButton = (XulToolbarbutton) toolbar.getElementById("trans-impact");
XulToolbarbutton generateSqlButton = (XulToolbarbutton) toolbar.getElementById("trans-get-sql");
if ((runButton != null) && (runButton.isDisabled() ^ !executePermitted)) {
runButton.setDisabled(!executePermitted);
}
if ((debugButton != null) && (debugButton.isDisabled() ^ !executePermitted)) {
debugButton.setDisabled(!executePermitted);
}
if ((previewButton != null) && (previewButton.isDisabled() ^ !executePermitted)) {
previewButton.setDisabled(!executePermitted);
}
if ((replayButton != null) && (replayButton.isDisabled() ^ !executePermitted)) {
replayButton.setDisabled(!executePermitted);
}
if ((verifyButton != null) && (verifyButton.isDisabled() ^ !executePermitted)) {
verifyButton.setDisabled(!executePermitted);
}
if ((impactButton != null) && (impactButton.isDisabled() ^ !executePermitted)) {
impactButton.setDisabled(!executePermitted);
}
if ((generateSqlButton != null) && (generateSqlButton.isDisabled() ^ !executePermitted)) {
generateSqlButton.setDisabled(!executePermitted);
}
}
JobGraph jobGraph = Spoon.getInstance().getActiveJobGraph();
if (jobGraph != null) {
XulToolbar toolbar = jobGraph.getToolbar();
XulToolbarbutton runButton = (XulToolbarbutton) toolbar.getElementById("job-run");
XulToolbarbutton generateSqlButton = (XulToolbarbutton) toolbar.getElementById("job-get-sql");
if ((runButton != null) && (runButton.isDisabled() ^ !executePermitted)) {
runButton.setDisabled(!executePermitted);
}
if ((generateSqlButton != null) && (generateSqlButton.isDisabled() ^ !executePermitted)) {
generateSqlButton.setDisabled(!executePermitted);
}
}
}
}
EESpoonPlugin.updateChangedWarningDialog(createPermitted);
} catch (Exception e) {
// don't let this bomb all the way out, otherwise we'll get stuck: PDI-4670
log.logError(e.getMessage(), e);
}
}
use of org.pentaho.di.trans.TransMeta in project pentaho-kettle by pentaho.
the class TrashBrowseController method undelete.
public void undelete() {
// make a copy because the selected trash items changes as soon as trashService.undelete is called
List<UIDeletedObject> selectedTrashFileItemsSnapshot = new ArrayList<UIDeletedObject>(selectedTrashFileItems);
if (selectedTrashFileItemsSnapshot != null && selectedTrashFileItemsSnapshot.size() > 0) {
List<ObjectId> ids = new ArrayList<ObjectId>();
for (UIDeletedObject uiObj : selectedTrashFileItemsSnapshot) {
ids.add(uiObj.getId());
}
try {
trashService.undelete(ids);
setTrash(trashService.getTrash());
for (UIDeletedObject uiObj : selectedTrashFileItemsSnapshot) {
// find the closest UIRepositoryDirectory that is in the dirMap
RepositoryDirectoryInterface dir = repository.findDirectory(uiObj.getOriginalParentPath());
while (dir != null && dirMap.get(dir.getObjectId()) == null) {
dir = dir.getParent();
}
// now refresh that UIRepositoryDirectory so that the file/folders deck instantly refreshes on undelete
if (dir != null) {
dirMap.get(dir.getObjectId()).refresh();
}
// if transformation or directory with transformations call extension to restore data services references.
if (RepositoryObjectType.TRANSFORMATION.name().equals(uiObj.getType())) {
TransMeta transMeta = repository.loadTransformation(uiObj.getId(), null);
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta);
transMeta.clearChanged();
} else if (!RepositoryObjectType.JOB.name().equals(uiObj.getType())) {
// if not a transformation and not a job then is a Directory
RepositoryDirectoryInterface actualDir = repository.findDirectory(uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj.getName());
if (actualDir != null) {
List<RepositoryElementMetaInterface> transformations = new ArrayList<>();
getAllTransformations(actualDir, transformations);
for (RepositoryElementMetaInterface repositoryElementMetaInterface : transformations) {
TransMeta transMeta = repository.loadTransformation(repositoryElementMetaInterface.getObjectId(), null);
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta);
transMeta.clearChanged();
}
} else {
displayExceptionMessage(BaseMessages.getString(PKG, "TrashBrowseController.UnableToRestoreDirectory", uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj.getName()));
}
}
}
deck.setSelectedIndex(1);
} catch (Throwable th) {
if (mainController == null || !mainController.handleLostRepository(th)) {
displayExceptionMessage(BaseMessages.getString(PKG, "TrashBrowseController.UnableToRestoreFile", // $NON-NLS-1$
th.getLocalizedMessage()));
}
}
} else {
// ui probably allowed the button to be enabled when it shouldn't have been enabled
throw new RuntimeException();
}
}
use of org.pentaho.di.trans.TransMeta in project pentaho-kettle by pentaho.
the class StarModelerPerspective method generateDomainJobButton.
protected void generateDomainJobButton(StarDomain starDomain) {
final Spoon spoon = Spoon.getInstance();
List<DatabaseMeta> sharedDatabases = SharedDatabaseUtil.loadSharedDatabases();
JobGenerator jobGenerator = new JobGenerator(starDomain, spoon.rep, new RepositoryDirectory(), sharedDatabases, defaultLocale);
try {
List<TransMeta> transMetas = jobGenerator.generateDimensionTransformations();
for (TransMeta transMeta : transMetas) {
spoon.addTransGraph(transMeta);
}
SpoonPerspectiveManager.getInstance().activatePerspective(MainSpoonPerspective.class);
} catch (Exception e) {
new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "StarModelerPerspective.ErrorGeneratingSqlJob.Title"), BaseMessages.getString(PKG, "StarModelerPerspective.ErrorGeneratingSqlJob.Message"), e);
}
}
use of org.pentaho.di.trans.TransMeta in project pentaho-kettle by pentaho.
the class JobGenerator method generateDimensionTransformation.
/**
* Generates a template
* @param databaseMeta
* @param logicalModel
* @return
*/
public TransMeta generateDimensionTransformation(DatabaseMeta databaseMeta, LogicalTable logicalTable) {
TransMeta transMeta = new TransMeta();
String tableName = ConceptUtil.getName(logicalTable, locale);
String tableDescription = ConceptUtil.getDescription(logicalTable, locale);
DimensionType dimensionType = ConceptUtil.getDimensionType(logicalTable);
transMeta.setName("Update dimension '" + tableName + "'");
transMeta.setDescription(tableDescription);
// Let's not forget to add the target database
//
transMeta.addDatabase(databaseMeta);
Point location = new Point(GRAPH_LEFT, GRAPH_TOP);
// Find all the source columns and source tables and put them into a table input step...
//
StepMeta inputStep = generateTableInputStepFromLogicalTable(logicalTable);
DatabaseMeta sourceDatabaseMeta = ((TableInputMeta) inputStep.getStepMetaInterface()).getDatabaseMeta();
if (sourceDatabaseMeta != null)
transMeta.addOrReplaceDatabase(sourceDatabaseMeta);
inputStep.setLocation(location.x, location.y);
nextLocation(location);
transMeta.addStep(inputStep);
StepMeta lastStep = inputStep;
// Generate an dimension lookup/update step for each table
//
StepMeta dimensionStep;
if (dimensionType == DimensionType.SLOWLY_CHANGING_DIMENSION) {
dimensionStep = generateDimensionLookupStepFromLogicalTable(databaseMeta, logicalTable);
} else {
dimensionStep = generateCombinationLookupStepFromLogicalTable(databaseMeta, logicalTable);
}
dimensionStep.setLocation(location.x, location.y);
nextLocation(location);
transMeta.addStep(dimensionStep);
TransHopMeta transHop = new TransHopMeta(lastStep, dimensionStep);
transMeta.addTransHop(transHop);
return transMeta;
}
use of org.pentaho.di.trans.TransMeta in project pentaho-kettle by pentaho.
the class JobGenerator method generateDimensionTransformations.
/**
* This method generates a list of transformations: one for each dimension.
*
* @return the list of generated transformations
*/
public List<TransMeta> generateDimensionTransformations() throws KettleException {
DatabaseMeta databaseMeta = findTargetDatabaseMeta();
List<TransMeta> transMetas = new ArrayList<TransMeta>();
List<LogicalTable> logicalTables = getUniqueLogicalTables();
for (LogicalTable logicalTable : logicalTables) {
TableType tableType = ConceptUtil.getTableType(logicalTable);
DimensionType dimensionType = ConceptUtil.getDimensionType(logicalTable);
if (tableType == TableType.DIMENSION) {
switch(dimensionType) {
case SLOWLY_CHANGING_DIMENSION:
case JUNK_DIMENSION:
{
TransMeta transMeta = generateDimensionTransformation(databaseMeta, logicalTable);
transMetas.add(transMeta);
}
break;
case // TODO: generate a standard date transformation
DATE:
{
TransMeta transMeta = generateDateTransformation(databaseMeta, logicalTable);
transMetas.add(transMeta);
}
break;
case // TODO: generate a standard time transformation
TIME:
{
TransMeta transMeta = generateTimeTransformation(databaseMeta, logicalTable);
transMetas.add(transMeta);
}
break;
default:
break;
}
}
}
return transMetas;
}
Aggregations