use of org.pentaho.platform.dataaccess.metadata.model.impl.ModelInfo in project data-access by pentaho.
the class MetadataService method getModelInfos.
/**
* Returns a list of ModelInfo objects for the specified domain. These objects are small and this list is intended to
* allow a client to provide a list of models to a user so the user can pick which one they want to work with.
*
* @param domain
* @param models
*/
private void getModelInfos(final String domain, List<ModelInfo> models) {
IMetadataDomainRepository repo = getMetadataRepository();
Domain domainObject = repo.getDomain(domain);
// find the best locale
String locale = LocaleHelper.getClosestLocale(LocaleHelper.getLocale().toString(), domainObject.getLocaleCodes());
// iterate over all of the models in this domain
for (LogicalModel model : domainObject.getLogicalModels()) {
// create a new ModelInfo object and give it the envelope information about the model
ModelInfo modelInfo = new ModelInfo();
modelInfo.setDomainId(domain);
modelInfo.setModelId(model.getId());
modelInfo.setModelName(model.getName(locale));
if (model.getDescription() != null) {
String modelDescription = model.getDescription(locale);
modelInfo.setModelDescription(modelDescription);
}
models.add(modelInfo);
}
return;
}
use of org.pentaho.platform.dataaccess.metadata.model.impl.ModelInfo in project data-access by pentaho.
the class MetadataService method listBusinessModels.
/**
* Returns a list of the available business models
*
* @param domainName optional domain to limit the results
* @return list of ModelInfo objects representing the available models
* @throws IOException
*/
public ModelInfo[] listBusinessModels(String domainName) throws IOException {
List<ModelInfo> models = new ArrayList<ModelInfo>();
// get hold of the metadata repository
IMetadataDomainRepository repo = getMetadataRepository();
if (repo == null) {
// $NON-NLS-1$
error(Messages.getErrorString("MetadataService.ERROR_0001_BAD_REPO"));
return null;
}
try {
if (domainName == null) {
// if no domain has been specified, loop over all of them
for (String domain : getMetadataRepository().getDomainIds()) {
getModelInfos(domain, models);
}
} else {
// get the models for the specified domain
getModelInfos(domainName, models);
}
} catch (Throwable t) {
// $NON-NLS-1$
error(Messages.getErrorString("MetadataService.ERROR_0002_BAD_MODEL_LIST"), t);
}
Collections.sort(models, new ModelInfoComparator());
return models.toArray(new ModelInfo[models.size()]);
}
use of org.pentaho.platform.dataaccess.metadata.model.impl.ModelInfo in project data-access by pentaho.
the class MetadataService method listBusinessModelsJson.
/**
* Returns a JSON list of the available business models
*
* @param domainName optional domain to limit the results
* @return JSON string of list of ModelInfo objects representing the available models
* @throws IOException
*/
public String listBusinessModelsJson(String domainName) throws IOException {
ModelInfo[] models = listBusinessModels(domainName);
JSONSerializer serializer = new JSONSerializer();
String json = serializer.deepSerialize(models);
return json;
}
Aggregations