Search in sources :

Example 11 with LocalizedString

use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.

the class StarModelDialog method copyTable.

protected boolean copyTable(Shell shell, LogicalModel logicalModel, String tableName) {
    LogicalTable originalTable = findLogicalTable(tableName);
    if (originalTable != null) {
        // Copy
        // 
        LogicalTable logicalTable = new LogicalTable();
        logicalTable.setId(UUID.randomUUID().toString());
        logicalTable.setName(new LocalizedString(locale, ConceptUtil.getName(originalTable, locale) + " (Copy)"));
        logicalTable.setDescription(new LocalizedString(locale, ConceptUtil.getDescription(originalTable, locale) + " (Copy)"));
        logicalTable.setProperty(DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME, originalTable.getProperty(DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME));
        logicalTable.setProperty(DefaultPropertyID.TABLE_TYPE.getId(), originalTable.getProperty(DefaultPropertyID.TABLE_TYPE.getId()));
        for (LogicalColumn column : originalTable.getLogicalColumns()) {
            logicalTable.getLogicalColumns().add((LogicalColumn) column.clone());
        }
        DimensionTableDialog dialog = new DimensionTableDialog(shell, logicalTable, locale);
        if (dialog.open() != null) {
            logicalModel.addLogicalTable(logicalTable);
            return true;
        }
    }
    return false;
}
Also used : LogicalColumn(org.pentaho.metadata.model.LogicalColumn) LogicalTable(org.pentaho.metadata.model.LogicalTable) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString)

Example 12 with LocalizedString

use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.

the class StarModelerPerspective method newSharedDimension.

/**
 * Create a new shared dimension in the domain
 *
 * @param domain the domain to create the new model in
 */
private boolean newSharedDimension(Shell shell, StarDomain starDomain) {
    LogicalTable dimensionTable = new LogicalTable();
    dimensionTable.setName(new LocalizedString(defaultLocale, "Shared dimension"));
    DimensionTableDialog dialog = new DimensionTableDialog(shell, dimensionTable, defaultLocale);
    if (dialog.open() != null) {
        starDomain.getSharedDimensions().add(dimensionTable);
        starDomain.setChanged(true);
        return true;
    }
    return false;
}
Also used : LogicalTable(org.pentaho.metadata.model.LogicalTable) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString)

Example 13 with LocalizedString

use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.

the class StarModelerPerspective method addModelsGroupToDomainTab.

private Control addModelsGroupToDomainTab(final StarDomain starDomain, final XulTabAndPanel tabAndPanel, Composite parentComposite) {
    PropsUI props = PropsUI.getInstance();
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Add a group for the logical stars
    // 
    final Group logicalGroup = new Group(parentComposite, SWT.SHADOW_NONE);
    props.setLook(logicalGroup);
    logicalGroup.setText(BaseMessages.getString(PKG, "StarModelerPerspective.LogicalGroup.Label"));
    FormLayout groupLayout = new FormLayout();
    groupLayout.marginLeft = 10;
    groupLayout.marginRight = 10;
    groupLayout.marginTop = 10;
    groupLayout.marginBottom = 10;
    groupLayout.spacing = margin;
    logicalGroup.setLayout(groupLayout);
    FormData fdLogicalGroup = new FormData();
    fdLogicalGroup.top = new FormAttachment(0, 0);
    fdLogicalGroup.left = new FormAttachment(0, 0);
    fdLogicalGroup.right = new FormAttachment(100, 0);
    logicalGroup.setLayoutData(fdLogicalGroup);
    // Add a line to edit the name of the logical domain
    // 
    Label nameLabel = new Label(logicalGroup, SWT.RIGHT);
    props.setLook(nameLabel);
    nameLabel.setText(BaseMessages.getString(PKG, "StarModelerPerspective.DomainName.Label"));
    FormData fdNameLabel = new FormData();
    fdNameLabel.left = new FormAttachment(0, 0);
    fdNameLabel.right = new FormAttachment(middle, 0);
    fdNameLabel.top = new FormAttachment(0, 0);
    nameLabel.setLayoutData(fdNameLabel);
    final Text nameText = new Text(logicalGroup, SWT.BORDER | SWT.SINGLE);
    props.setLook(nameText);
    nameText.setText(Const.NVL(starDomain.getDomain().getName(defaultLocale), ""));
    FormData fdNameText = new FormData();
    fdNameText.left = new FormAttachment(middle, margin);
    fdNameText.right = new FormAttachment(100, 0);
    fdNameText.top = new FormAttachment(0, 0);
    nameText.setLayoutData(fdNameText);
    nameText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            starDomain.getDomain().setName(new LocalizedString(defaultLocale, nameText.getText()));
            setNameForTab(tabAndPanel.tab, starDomain.getDomain().getName(defaultLocale));
        }
    });
    Control lastControl = nameText;
    // Add a line to edit the name of the logical domain
    // 
    Label descriptionLabel = new Label(logicalGroup, SWT.RIGHT);
    props.setLook(descriptionLabel);
    descriptionLabel.setText(BaseMessages.getString(PKG, "StarModelerPerspective.DomainDescription.Label"));
    FormData fdDescriptionLabel = new FormData();
    fdDescriptionLabel.left = new FormAttachment(0, 0);
    fdDescriptionLabel.right = new FormAttachment(middle, 0);
    fdDescriptionLabel.top = new FormAttachment(lastControl, margin);
    descriptionLabel.setLayoutData(fdDescriptionLabel);
    final Text descriptionText = new Text(logicalGroup, SWT.BORDER | SWT.SINGLE);
    props.setLook(descriptionText);
    descriptionText.setText(Const.NVL(starDomain.getDomain().getDescription(defaultLocale), ""));
    FormData fdDescriptionText = new FormData();
    fdDescriptionText.left = new FormAttachment(middle, 5);
    fdDescriptionText.right = new FormAttachment(100, 0);
    fdDescriptionText.top = new FormAttachment(lastControl, margin);
    descriptionText.setLayoutData(fdDescriptionText);
    descriptionText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            starDomain.getDomain().setDescription(new LocalizedString(defaultLocale, descriptionText.getText()));
        }
    });
    lastControl = descriptionText;
    // Then we'll add a table view of all the models and their descriptions
    // 
    Label modelsLabel = new Label(logicalGroup, SWT.RIGHT);
    props.setLook(modelsLabel);
    modelsLabel.setText(BaseMessages.getString(PKG, "StarModelerPerspective.DomainModels.Label"));
    FormData fdModelsLabel = new FormData();
    fdModelsLabel.left = new FormAttachment(0, 0);
    fdModelsLabel.right = new FormAttachment(middle, 0);
    fdModelsLabel.top = new FormAttachment(lastControl, margin);
    modelsLabel.setLayoutData(fdModelsLabel);
    ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "StarModelerPerspective.ModelName.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "StarModelerPerspective.ModelDescription.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false, true) };
    final TableView modelsList = new TableView(new Variables(), logicalGroup, SWT.BORDER, colinf, 1, null, props);
    modelsList.setReadonly(true);
    modelsList.table.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            if (modelsList.getSelectionIndex() < 0)
                return;
            TableItem item = modelsList.table.getSelection()[0];
            String name = item.getText(1);
            if (editModel(logicalGroup.getShell(), starDomain, defaultLocale, name)) {
                refreshModelsList(starDomain, modelsList);
            }
        }
    });
    refreshModelsList(starDomain, modelsList);
    FormData fdModelsList = new FormData();
    fdModelsList.top = new FormAttachment(lastControl, margin);
    fdModelsList.bottom = new FormAttachment(lastControl, 250);
    fdModelsList.left = new FormAttachment(middle, margin);
    fdModelsList.right = new FormAttachment(100, 0);
    modelsList.setLayoutData(fdModelsList);
    lastControl = modelsList;
    // A few buttons to edit the list
    // 
    Button newModelButton = new Button(logicalGroup, SWT.PUSH);
    newModelButton.setText(BaseMessages.getString(PKG, "StarModelerPerspective.Button.NewModel"));
    FormData fdNewModelButton = new FormData();
    fdNewModelButton.top = new FormAttachment(lastControl, margin);
    fdNewModelButton.left = new FormAttachment(middle, margin);
    newModelButton.setLayoutData(fdNewModelButton);
    newModelButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (newModel(logicalGroup.getShell(), starDomain)) {
                refreshModelsList(starDomain, modelsList);
            }
        }
    });
    Button editModelButton = new Button(logicalGroup, SWT.PUSH);
    editModelButton.setText(BaseMessages.getString(PKG, "StarModelerPerspective.Button.EditModel"));
    FormData fdEditModelButton = new FormData();
    fdEditModelButton.top = new FormAttachment(lastControl, margin);
    fdEditModelButton.left = new FormAttachment(newModelButton, margin);
    editModelButton.setLayoutData(fdEditModelButton);
    editModelButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (modelsList.getSelectionIndex() < 0)
                return;
            TableItem item = modelsList.table.getSelection()[0];
            String name = item.getText(1);
            if (editModel(logicalGroup.getShell(), starDomain, defaultLocale, name)) {
                refreshModelsList(starDomain, modelsList);
            }
        }
    });
    Button delModelButton = new Button(logicalGroup, SWT.PUSH);
    delModelButton.setText(BaseMessages.getString(PKG, "StarModelerPerspective.Button.DeleteModel"));
    FormData fdDelModelButton = new FormData();
    fdDelModelButton.top = new FormAttachment(lastControl, margin);
    fdDelModelButton.left = new FormAttachment(editModelButton, margin);
    delModelButton.setLayoutData(fdDelModelButton);
    delModelButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (modelsList.getSelectionIndex() < 0)
                return;
            TableItem item = modelsList.table.getSelection()[0];
            String name = item.getText(1);
            if (deleteModel(logicalGroup.getShell(), starDomain, defaultLocale, name)) {
                refreshModelsList(starDomain, modelsList);
            }
        }
    });
    return logicalGroup;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) Text(org.eclipse.swt.widgets.Text) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) PropsUI(org.pentaho.di.ui.core.PropsUI) Variables(org.pentaho.di.core.variables.Variables) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 14 with LocalizedString

use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.

the class StarModelerPerspective method newModel.

/**
 * Create a new model in the domain
 *
 * @param domain the domain to create the new model in
 */
private boolean newModel(Shell shell, StarDomain starDomain) {
    LogicalModel model = new LogicalModel();
    model.setName(new LocalizedString(defaultLocale, "Model"));
    StarModelDialog dialog = new StarModelDialog(shell, model, defaultLocale);
    if (dialog.open() != null) {
        starDomain.getDomain().getLogicalModels().add(model);
        starDomain.setChanged(true);
        return true;
    }
    return false;
}
Also used : LogicalModel(org.pentaho.metadata.model.LogicalModel) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString)

Example 15 with LocalizedString

use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.

the class MetadataGenerator method extractId.

private String extractId(Concept item) {
    LocalizedString localizedName = item.getName();
    Set<String> locales = localizedName.getLocales();
    if (locales.isEmpty())
        return "";
    // Just grab the first locale we come across
    // This should normally only one for the star modeler
    // 
    String locale = locales.iterator().next();
    String id = localizedName.getLocalizedString(locale);
    id = id.toUpperCase().replace(" ", "_");
    return id;
}
Also used : LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString)

Aggregations

LocalizedString (org.pentaho.metadata.model.concept.types.LocalizedString)25 LogicalColumn (org.pentaho.metadata.model.LogicalColumn)11 LogicalTable (org.pentaho.metadata.model.LogicalTable)10 LogicalModel (org.pentaho.metadata.model.LogicalModel)8 Domain (org.pentaho.metadata.model.Domain)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)4 Category (org.pentaho.metadata.model.Category)4 SqlDataSource (org.pentaho.metadata.model.SqlDataSource)4 SqlPhysicalColumn (org.pentaho.metadata.model.SqlPhysicalColumn)4 SqlPhysicalModel (org.pentaho.metadata.model.SqlPhysicalModel)4 SqlPhysicalTable (org.pentaho.metadata.model.SqlPhysicalTable)4 TableItem (org.eclipse.swt.widgets.TableItem)3 Matchers.anyString (org.mockito.Matchers.anyString)3 List (java.util.List)2 MessageBox (org.eclipse.swt.widgets.MessageBox)2 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)2 DatabaseConnection (org.pentaho.database.model.DatabaseConnection)2 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)2 Concept (org.pentaho.metadata.model.concept.Concept)2