All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openl.rules.ui.copy.DimensionalPropertiesTableCopier Maven / Gradle / Ivy

There is a newer version: 5.27.9
Show newest version
package org.openl.rules.ui.copy;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.openl.rules.table.IOpenLTable;
import org.openl.rules.table.properties.def.DefaultPropertyDefinitions;
import org.openl.rules.table.properties.def.TablePropertyDefinition;
import org.openl.rules.table.properties.inherit.InheritanceLevel;
import org.openl.rules.table.properties.inherit.PropertiesChecker;
import org.openl.rules.tableeditor.renderkit.TableProperty;
import org.openl.rules.webstudio.WebStudioFormats;

/**
 * @author Andrei Astrouski
 */
public class DimensionalPropertiesTableCopier extends TableCopier {

    public DimensionalPropertiesTableCopier(IOpenLTable table) {
        super(table);
        checkPropertiesExistance();
    }

    private void checkPropertiesExistance() {
        TablePropertyDefinition[] propDefinitions = DefaultPropertyDefinitions.getDefaultDefinitions();
        for (TablePropertyDefinition propDefinition : propDefinitions) {
            if (propDefinition.isDimensional() && getProperty(propDefinition.getName()) == null) {
                TableProperty property = new TableProperty(propDefinition, WebStudioFormats.getInstance());
                getPropertiesManager().addProperty(property);
            }
        }
    }

    @Override
    public List getPropertiesToDisplay() {
        IOpenLTable table = getTable();
        if (table == null) {
            // reset() was invoked for the wizard.
            return Collections.emptyList();
        }

        List properties = new ArrayList<>();

        for (TableProperty property : getPropertiesManager().getProperties()) {
            if (property.isDimensional() && PropertiesChecker.isPropertySuitableForTableType(property.getName(),
                    table.getType()) && PropertiesChecker.isPropertySuitableForLevel(InheritanceLevel.TABLE,
                    property.getName())) {
                properties.add(property);
            }
        }

        return properties;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy