use of org.pentaho.platform.dataaccess.metadata.model.impl.Model in project data-access by pentaho.
the class MetadataService method loadModelJson.
/**
* Returns a JSON Model object for the requested model. The model will include the basic metadata - categories and
* columns.
*
* @param domainId
* @param modelId
* @return JSON string of the model
*/
public String loadModelJson(String domainId, String modelId) {
Model model = loadModel(domainId, modelId);
JSONSerializer serializer = new JSONSerializer();
String json = serializer.deepSerialize(model);
return json;
}
use of org.pentaho.platform.dataaccess.metadata.model.impl.Model in project data-access by pentaho.
the class MetadataServiceUtil method createThinModel.
/**
* Creates a lightweight, serializable model object from a logical model
*
* @param m
* @param domainId
* @return
*/
public Model createThinModel(LogicalModel m, String domainId) {
// create the model object
Model model = new Model();
model.setName(m.getName(getLocale()));
model.setId(m.getId());
model.setDomainId(domainId);
model.setDescription(m.getDescription(getLocale()));
// add the categories to the model
List<Category> categories = new ArrayList<Category>();
for (org.pentaho.metadata.model.Category cat : m.getCategories()) {
categories.add(createCategory(m, cat));
}
model.setCategories(categories.toArray(new Category[categories.size()]));
return model;
}
use of org.pentaho.platform.dataaccess.metadata.model.impl.Model in project data-access by pentaho.
the class MetadataServiceTest method testLoadModel.
@Test
public void testLoadModel() {
when(metadataService.loadModel(anyString(), anyString())).thenCallRealMethod();
Model model = metadataService.loadModel(DOMAIN_ID, LOGICAL_MODEL_ID);
// Test if the name of the model returned is correct
Assert.assertTrue(model.getName() == LOGICAL_MODEL_NAME);
}
use of org.pentaho.platform.dataaccess.metadata.model.impl.Model in project data-access by pentaho.
the class MetadataService method loadModel.
/**
* Returns a Model object for the requested model. The model will include the basic metadata - categories and
* columns.
*
* @param domainId
* @param modelId
* @return
*/
public Model loadModel(String domainId, String modelId) {
if (domainId == null) {
// we can't do this without a model
// $NON-NLS-1$
error(Messages.getErrorString("MetadataService.ERROR_0003_NULL_DOMAIN"));
return null;
}
if (modelId == null) {
// we can't do this without a model
// $NON-NLS-1$
error(Messages.getErrorString("MetadataService.ERROR_0004_NULL_Model"));
return null;
}
// because it's lighter weight, check the thin model
Domain domain = getMetadataRepository().getDomain(domainId);
if (domain == null) {
// $NON-NLS-1$
error(Messages.getErrorString("MetadataService.ERROR_0005_DOMAIN_NOT_FOUND", domainId));
return null;
}
LogicalModel model = domain.findLogicalModel(modelId);
if (model == null) {
// the model cannot be found or cannot be loaded
// $NON-NLS-1$
error(Messages.getErrorString("MetadataService.ERROR_0006_MODEL_NOT_FOUND", modelId));
return null;
}
// create the thin metadata model and return it
MetadataServiceUtil util = getMetadataServiceUtil();
util.setDomain(domain);
Model thinModel = util.createThinModel(model, domainId);
return thinModel;
}
Aggregations