Search in sources :

Example 1 with ModelInfoComparator

use of org.pentaho.platform.dataaccess.metadata.model.impl.ModelInfoComparator 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()]);
}
Also used : ModelInfo(org.pentaho.platform.dataaccess.metadata.model.impl.ModelInfo) ModelInfoComparator(org.pentaho.platform.dataaccess.metadata.model.impl.ModelInfoComparator) ArrayList(java.util.ArrayList) IMetadataDomainRepository(org.pentaho.metadata.repository.IMetadataDomainRepository)

Aggregations

ArrayList (java.util.ArrayList)1 IMetadataDomainRepository (org.pentaho.metadata.repository.IMetadataDomainRepository)1 ModelInfo (org.pentaho.platform.dataaccess.metadata.model.impl.ModelInfo)1 ModelInfoComparator (org.pentaho.platform.dataaccess.metadata.model.impl.ModelInfoComparator)1