Search in sources :

Example 11 with IMetaStoreElementType

use of org.pentaho.metastore.api.IMetaStoreElementType 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 12 with IMetaStoreElementType

use of org.pentaho.metastore.api.IMetaStoreElementType in project pentaho-kettle by pentaho.

the class ModelMetaStoreUtil method getLogicalTableElementType.

public static IMetaStoreElementType getLogicalTableElementType(IMetaStore metaStore) throws MetaStoreException {
    verifyNamespaceCreated(metaStore, PentahoDefaults.NAMESPACE);
    IMetaStoreElementType elementType = metaStore.getElementTypeByName(PentahoDefaults.NAMESPACE, METASTORE_LOGICAL_TABLE_TYPE_NAME);
    if (elementType == null) {
        // create the type
        // 
        elementType = metaStore.newElementType(PentahoDefaults.NAMESPACE);
        elementType.setName(METASTORE_LOGICAL_TABLE_TYPE_NAME);
        elementType.setDescription(METASTORE_LOGICAL_TABLE_TYPE_DESCRIPTION);
        metaStore.createElementType(PentahoDefaults.NAMESPACE, elementType);
    }
    return elementType;
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType)

Example 13 with IMetaStoreElementType

use of org.pentaho.metastore.api.IMetaStoreElementType in project pentaho-kettle by pentaho.

the class ModelMetaStoreUtil method getLogicalModelElementType.

public static IMetaStoreElementType getLogicalModelElementType(IMetaStore metaStore) throws MetaStoreException {
    verifyNamespaceCreated(metaStore, PentahoDefaults.NAMESPACE);
    IMetaStoreElementType elementType = metaStore.getElementTypeByName(PentahoDefaults.NAMESPACE, METASTORE_STAR_MODEL_TYPE_NAME);
    if (elementType == null) {
        // create the type
        // 
        elementType = metaStore.newElementType(PentahoDefaults.NAMESPACE);
        elementType.setName(METASTORE_STAR_MODEL_TYPE_NAME);
        elementType.setDescription(METASTORE_STAR_MODEL_TYPE_DESCRIPTION);
        metaStore.createElementType(PentahoDefaults.NAMESPACE, elementType);
    }
    return elementType;
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType)

Example 14 with IMetaStoreElementType

use of org.pentaho.metastore.api.IMetaStoreElementType in project pentaho-kettle by pentaho.

the class ModelMetaStoreUtil method saveLogicalModel.

public static IMetaStoreElement saveLogicalModel(IMetaStore metaStore, LogicalModel model) throws MetaStoreException {
    IMetaStoreElementType elementType = getLogicalModelElementType(metaStore);
    IMetaStoreElement oldElement = metaStore.getElementByName(PentahoDefaults.NAMESPACE, elementType, model.getName(defaultLocale));
    if (oldElement == null) {
        // populate and create...
        // 
        IMetaStoreElement newElement = populateElement(metaStore, model);
        metaStore.createElement(PentahoDefaults.NAMESPACE, elementType, newElement);
        return newElement;
    } else {
        // The element exists, update...
        // 
        IMetaStoreElement newElement = populateElement(metaStore, model);
        metaStore.updateElement(PentahoDefaults.NAMESPACE, elementType, oldElement.getId(), newElement);
        return newElement;
    }
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement)

Example 15 with IMetaStoreElementType

use of org.pentaho.metastore.api.IMetaStoreElementType in project pentaho-kettle by pentaho.

the class SharedDimensionMetaStoreUtil method saveSharedDimension.

public static void saveSharedDimension(IMetaStore metaStore, LogicalTable sharedDimension, String locale) throws MetaStoreException {
    IMetaStoreElementType elementType = getSharedDimensionElementType(metaStore);
    IMetaStoreElement element = null;
    if (sharedDimension.getId() != null) {
        element = metaStore.getElement(namespace, elementType, sharedDimension.getId());
    }
    if (element != null) {
        // Update the shared dimension!
        // 
        populateElementWithSharedDimension(metaStore, sharedDimension, locale, elementType, element);
        metaStore.updateElement(namespace, elementType, sharedDimension.getId(), element);
    } else {
        // New shared dimension
        // 
        element = metaStore.newElement();
        populateElementWithSharedDimension(metaStore, sharedDimension, locale, elementType, element);
        metaStore.createElement(namespace, elementType, element);
    }
    sharedDimension.setId(element.getId());
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement)

Aggregations

IMetaStoreElementType (org.pentaho.metastore.api.IMetaStoreElementType)40 IMetaStoreElement (org.pentaho.metastore.api.IMetaStoreElement)19 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)12 MetaStoreDependenciesExistsException (org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException)10 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 IMetaStore (org.pentaho.metastore.api.IMetaStore)9 MetaStoreElementTypeExistsException (org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)9 StringObjectId (org.pentaho.di.repository.StringObjectId)7 MetaStoreElementExistException (org.pentaho.metastore.api.exceptions.MetaStoreElementExistException)7 LongObjectId (org.pentaho.di.repository.LongObjectId)6 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)6 Matchers.anyString (org.mockito.Matchers.anyString)4 List (java.util.List)3 ObjectId (org.pentaho.di.repository.ObjectId)3 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)2 StarDomain (org.pentaho.di.starmodeler.StarDomain)2