Search in sources :

Example 1 with IdNameDescription

use of org.pentaho.di.starmodeler.metastore.IdNameDescription in project pentaho-kettle by pentaho.

the class StarModelerPerspective method testMetaStore.

protected void testMetaStore() {
    try {
        // Force repository meta store
        IMetaStore metaStore = Spoon.getInstance().getRepository().getMetaStore();
        LogChannel.GENERAL.logBasic("Active metastore: " + metaStore.getName());
        StarDomainMetaStoreUtil.verifyNamespaceCreated(metaStore, "pentaho");
        IMetaStoreElementType elementType = StarDomainMetaStoreUtil.getStarDomainElementType(metaStore);
        if (elementType == null) {
            throw new KettleException("Unable to find star domain element type");
        }
        LogChannel.GENERAL.logBasic("Found star domain element type: " + elementType.getName() + " : " + elementType.getDescription());
        elementType = metaStore.getElementTypeByName(PentahoDefaults.NAMESPACE, elementType.getName());
        if (elementType == null) {
            throw new KettleException("Unable to find star domain element type by name");
        }
        LogChannel.GENERAL.logBasic("Found element type by name");
        List<IdNameDescription> list = new ArrayList<IdNameDescription>();
        for (IMetaStoreElement element : metaStore.getElements(PentahoDefaults.NAMESPACE, elementType)) {
            IdNameDescription nameDescription = new IdNameDescription(element.getId(), element.getName(), null);
            list.add(nameDescription);
        }
        LogChannel.GENERAL.logBasic("Found " + list.size() + " star domain elements.");
        StarDomainMetaStoreUtil.getStarDomainList(metaStore);
    } catch (Exception e) {
        new ErrorDialog(Spoon.getInstance().getShell(), "ERROR", "Error testing meta store: ", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) ArrayList(java.util.ArrayList) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement) IdNameDescription(org.pentaho.di.starmodeler.metastore.IdNameDescription) IMetaStore(org.pentaho.metastore.api.IMetaStore) XulException(org.pentaho.ui.xul.XulException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleException(org.pentaho.di.core.exception.KettleException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException)

Example 2 with IdNameDescription

use of org.pentaho.di.starmodeler.metastore.IdNameDescription in project pentaho-kettle by pentaho.

the class StarModelerPerspective method open.

public void open() {
    // List all star domains in the metastore
    // 
    Shell shell = Spoon.getInstance().getShell();
    try {
        List<IdNameDescription> starDomainList = StarDomainMetaStoreUtil.getStarDomainList(Spoon.getInstance().getMetaStore());
        List<String> rows = new ArrayList<String>();
        for (IdNameDescription ind : starDomainList) {
            rows.add(ind.getName() + " : " + ind.getDescription());
        }
        EnterSelectionDialog selectionDialog = new EnterSelectionDialog(shell, rows.toArray(new String[rows.size()]), "Select star domain", "Select the star domain to open:");
        selectionDialog.setMulti(false);
        if (selectionDialog.open() != null) {
            int index = selectionDialog.getSelectionNr();
            StarDomain starDomain = StarDomainMetaStoreUtil.loadStarDomain(Spoon.getInstance().getMetaStore(), starDomainList.get(index).getId());
            if (starDomain != null) {
                createTabForDomain(starDomain);
            }
        }
    } catch (Exception e) {
        new ErrorDialog(shell, "Error", "Error getting list of star domains from the MetaStore:", e);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ArrayList(java.util.ArrayList) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) IdNameDescription(org.pentaho.di.starmodeler.metastore.IdNameDescription) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) XulException(org.pentaho.ui.xul.XulException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleException(org.pentaho.di.core.exception.KettleException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException)

Aggregations

ArrayList (java.util.ArrayList)2 KettleException (org.pentaho.di.core.exception.KettleException)2 IdNameDescription (org.pentaho.di.starmodeler.metastore.IdNameDescription)2 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)2 MetaStoreElementExistException (org.pentaho.metastore.api.exceptions.MetaStoreElementExistException)2 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)2 XulException (org.pentaho.ui.xul.XulException)2 Shell (org.eclipse.swt.widgets.Shell)1 EnterSelectionDialog (org.pentaho.di.ui.core.dialog.EnterSelectionDialog)1 LocalizedString (org.pentaho.metadata.model.concept.types.LocalizedString)1 IMetaStore (org.pentaho.metastore.api.IMetaStore)1 IMetaStoreElement (org.pentaho.metastore.api.IMetaStoreElement)1 IMetaStoreElementType (org.pentaho.metastore.api.IMetaStoreElementType)1