Search in sources :

Example 1 with Category

use of org.pentaho.platform.dataaccess.metadata.model.impl.Category 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;
}
Also used : Category(org.pentaho.platform.dataaccess.metadata.model.impl.Category) LogicalModel(org.pentaho.metadata.model.LogicalModel) Model(org.pentaho.platform.dataaccess.metadata.model.impl.Model) ArrayList(java.util.ArrayList)

Example 2 with Category

use of org.pentaho.platform.dataaccess.metadata.model.impl.Category in project data-access by pentaho.

the class MetadataServiceUtil method createCategory.

/**
 * Creates a lightweight, serializable category objects from a logical model category
 *
 * @param m
 * @param c
 * @return
 */
private Category createCategory(LogicalModel m, org.pentaho.metadata.model.Category c) {
    // create a thin category object
    Category cat = new Category();
    cat.setName(c.getName(getLocale()));
    cat.setId(c.getId());
    List<Column> columns = new ArrayList<Column>();
    for (LogicalColumn col : c.getLogicalColumns()) {
        columns.add(createColumn(m, col, c));
    }
    cat.setColumns(columns.toArray(new Column[columns.size()]));
    return cat;
}
Also used : LogicalColumn(org.pentaho.metadata.model.LogicalColumn) Category(org.pentaho.platform.dataaccess.metadata.model.impl.Category) LogicalColumn(org.pentaho.metadata.model.LogicalColumn) IPhysicalColumn(org.pentaho.metadata.model.IPhysicalColumn) Column(org.pentaho.platform.dataaccess.metadata.model.impl.Column) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 Category (org.pentaho.platform.dataaccess.metadata.model.impl.Category)2 IPhysicalColumn (org.pentaho.metadata.model.IPhysicalColumn)1 LogicalColumn (org.pentaho.metadata.model.LogicalColumn)1 LogicalModel (org.pentaho.metadata.model.LogicalModel)1 Column (org.pentaho.platform.dataaccess.metadata.model.impl.Column)1 Model (org.pentaho.platform.dataaccess.metadata.model.impl.Model)1