Search in sources :

Example 16 with IMetaStoreElementType

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

the class StarDomainMetaStoreUtil method loadStarDomain.

public static StarDomain loadStarDomain(DelegatingMetaStore metaStore, String id) throws MetaStoreException {
    IMetaStoreElementType elementType = getStarDomainElementType(metaStore);
    IMetaStoreElement element = metaStore.getElement(namespace, elementType, id);
    if (element == null) {
        return null;
    }
    StarDomain starDomain = new StarDomain();
    starDomain.setObjectId(new StringObjectId(id));
    starDomain.setName(element.getName());
    starDomain.setDescription(getChildString(element, Attribute.ID_STAR_DOMAIN_DESCRIPTION.id));
    return starDomain;
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) StarDomain(org.pentaho.di.starmodeler.StarDomain) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement) StringObjectId(org.pentaho.di.repository.StringObjectId)

Example 17 with IMetaStoreElementType

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

the class StarDomainMetaStoreUtil method getStarDomainList.

public static List<IdNameDescription> getStarDomainList(IMetaStore metaStore) throws MetaStoreException {
    IMetaStoreElementType elementType = getStarDomainElementType(metaStore);
    List<IdNameDescription> list = new ArrayList<IdNameDescription>();
    for (IMetaStoreElement element : metaStore.getElements(namespace, elementType)) {
        IdNameDescription nameDescription = new IdNameDescription(element.getId(), element.getName(), getChildString(element, Attribute.ID_STAR_DOMAIN_DESCRIPTION.id));
        list.add(nameDescription);
    }
    return list;
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) ArrayList(java.util.ArrayList) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement)

Example 18 with IMetaStoreElementType

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

the class StarDomainMetaStoreUtil method createStarDomainElementType.

public static IMetaStoreElementType createStarDomainElementType(IMetaStore metaStore) throws MetaStoreElementTypeExistsException, MetaStoreException {
    IMetaStoreElementType elementType = metaStore.newElementType(namespace);
    elementType.setName(METASTORE_STAR_DOMAIN_TYPE_NAME);
    elementType.setDescription(METASTORE_STAR_DOMAIN_TYPE_DESCRIPTION);
    metaStore.createElementType(namespace, elementType);
    return elementType;
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType)

Example 19 with IMetaStoreElementType

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

the class PurRepositoryMetaStore method getElementTypes.

@Override
public List<IMetaStoreElementType> getElementTypes(String namespace) throws MetaStoreException {
    List<IMetaStoreElementType> elementTypes = new ArrayList<IMetaStoreElementType>();
    RepositoryFile namespaceFile = validateNamespace(namespace);
    List<RepositoryFile> children = getChildren(namespaceFile.getId());
    for (RepositoryFile child : children) {
        if (!child.isHidden()) {
            elementTypes.add(getElementType(namespace, child.getId().toString()));
        }
    }
    return elementTypes;
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) ArrayList(java.util.ArrayList) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile)

Example 20 with IMetaStoreElementType

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

the class PurRepositoryMetaStore method createElementType.

// The element types
@Override
public void createElementType(String namespace, IMetaStoreElementType elementType) throws MetaStoreException {
    RepositoryFile namespaceFile = validateNamespace(namespace);
    IMetaStoreElementType existingType = getElementTypeByName(namespace, elementType.getName());
    if (existingType != null) {
        throw new MetaStoreElementTypeExistsException(Collections.singletonList(existingType), "Can not create element type with id '" + elementType.getId() + "' because it already exists");
    }
    RepositoryFile elementTypeFile = new RepositoryFile.Builder(elementType.getName()).folder(true).versioned(false).build();
    RepositoryFile folder = pur.createFolder(namespaceFile.getId(), elementTypeFile, null);
    elementType.setId(folder.getId().toString());
    // In this folder there is a hidden file which contains the description
    // and the other future properties of the element type
    // 
    RepositoryFile detailsFile = new RepositoryFile.Builder(ELEMENT_TYPE_DETAILS_FILENAME).folder(false).title(ELEMENT_TYPE_DETAILS_FILENAME).description(elementType.getDescription()).hidden(true).build();
    DataNode dataNode = getElementTypeDataNode(elementType);
    pur.createFile(folder.getId(), detailsFile, new NodeRepositoryFileData(dataNode), null);
    elementType.setMetaStoreName(getName());
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile)

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