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);
}
}
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;
}
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;
}
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;
}
}
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());
}
Aggregations