<commit_before>package org.pentaho.agilebi.spoon;

import org.eclipse.swt.widgets.Display;
import org.pentaho.agilebi.modeler.BaseModelerWorkspaceHelper;
import org.pentaho.agilebi.modeler.IModelerWorkspaceHelper;
import org.pentaho.agilebi.modeler.ModelerException;
import org.pentaho.agilebi.modeler.ModelerWorkspace;
import org.pentaho.agilebi.modeler.nodes.*;
import org.pentaho.agilebi.modeler.util.ModelerWorkspaceHelper;
import org.pentaho.metadata.model.concept.types.DataType;
import org.pentaho.metadata.model.concept.types.LocalizedString;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * User: nbaker
 * Date: Jul 14, 2010
 */
public class SpoonModelerWorkspaceHelper extends BaseModelerWorkspaceHelper implements IModelerWorkspaceHelper {

  ModelerWorkspaceHelper helper;

  public SpoonModelerWorkspaceHelper() {
    super(LocalizedString.DEFAULT_LOCALE);
    helper = new ModelerWorkspaceHelper(LocalizedString.DEFAULT_LOCALE);
  }

  /**
   * Builds an OLAP model that is attribute based.
   * @param workspace
   */
  public void autoModelFlat( ModelerWorkspace workspace ) throws ModelerException {
    helper.autoModelFlat(workspace);
  }


  /**
   * Builds an OLAP model that is attribute based.
   * @param workspace
   */
  public void autoModelFlatInBackground( final ModelerWorkspace workspace ) throws ModelerException {

    final Display display = Display.findDisplay(Thread.currentThread());
    Runnable worker = new Runnable(){

      public void run() {
        MainModelNode mainModel = new MainModelNode();
        mainModel.setName(workspace.getModelName());
        workspace.setModel(mainModel);
        final boolean prevChangeState = workspace.isModelChanging();
        workspace.setModelIsChanging(true);

        List<AvailableField> fields = workspace.getAvailableOlapFields();
        for( AvailableField field : fields ) {
          DataType dataType = field.getLogicalColumn().getDataType();
          if( dataType == DataType.NUMERIC) {
            // create a measure
            MeasureMetaData measure = workspace.createMeasureForNode(field);
            workspace.getModel().getMeasures().add(measure);
          }
          // create a dimension
          workspace.addDimensionFromNode(field);
        }
        display.syncExec(new Runnable(){

          public void run() {

            workspace.setModelIsChanging(prevChangeState);
            workspace.setSelectedNode(workspace.getModel());
          }
        });
      }
    };
    new Thread(worker).start();


  }

  /**
   * Builds a Relational Model that is attribute based, all available fields are added into a single Category
   * @param workspace
   * @throws ModelerException
   */
  @Override
  public void autoModelRelationalFlat(ModelerWorkspace workspace) throws ModelerException {
    helper.autoModelRelationalFlat(workspace);
  }

  /**
   * Builds a Relational Model that is attribute based, all available fields are added into a single Category
   * @param workspace
   * @throws ModelerException
   */
  @Override
  public void autoModelRelationalFlatInBackground(final ModelerWorkspace workspace) throws ModelerException {

    final Display display = Display.findDisplay(Thread.currentThread());
    Runnable worker = new Runnable(){

      public void run() {
        RelationalModelNode relationalModelNode = new RelationalModelNode();

        relationalModelNode.setName(workspace.getRelationalModelName());

        workspace.setRelationalModel(relationalModelNode);
        final boolean prevChangeState = workspace.isModelChanging();
        workspace.setModelIsChanging(true);

        CategoryMetaData category = new CategoryMetaData("Category");

        List<AvailableField> fields = workspace.getAvailableFields();
        for( AvailableField field : fields ) {
          category.add(workspace.createFieldForParentWithNode(category, field));
        }
        relationalModelNode.getCategories().add(category);

        display.syncExec(new Runnable(){

          public void run() {

            workspace.setModelIsChanging(prevChangeState);
            workspace.setSelectedRelationalNode(workspace.getRelationalModel());
          }
        });
      }<commit_msg>fixed compile issues<commit_after>package org.pentaho.agilebi.spoon;

import org.eclipse.swt.widgets.Display;
import org.pentaho.agilebi.modeler.BaseModelerWorkspaceHelper;
import org.pentaho.agilebi.modeler.IModelerWorkspaceHelper;
import org.pentaho.agilebi.modeler.ModelerException;
import org.pentaho.agilebi.modeler.ModelerWorkspace;
import org.pentaho.agilebi.modeler.nodes.*;
import org.pentaho.agilebi.modeler.util.ModelerWorkspaceHelper;
import org.pentaho.metadata.model.concept.types.DataType;
import org.pentaho.metadata.model.concept.types.LocalizedString;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * User: nbaker
 * Date: Jul 14, 2010
 */
public class SpoonModelerWorkspaceHelper extends BaseModelerWorkspaceHelper implements IModelerWorkspaceHelper {

  ModelerWorkspaceHelper helper;

  public SpoonModelerWorkspaceHelper() {
    super(LocalizedString.DEFAULT_LOCALE);
    helper = new ModelerWorkspaceHelper(LocalizedString.DEFAULT_LOCALE);
  }

  /**
   * Builds an OLAP model that is attribute based.
   * @param workspace
   */
  public void autoModelFlat( ModelerWorkspace workspace ) throws ModelerException {
    helper.autoModelFlat(workspace);
  }


  /**
   * Builds an OLAP model that is attribute based.
   * @param workspace
   */
  public void autoModelFlatInBackground( final ModelerWorkspace workspace ) throws ModelerException {

    final Display display = Display.findDisplay(Thread.currentThread());
    Runnable worker = new Runnable(){

      public void run() {
        MainModelNode mainModel = new MainModelNode();
        mainModel.setName(workspace.getModelName());
        workspace.setModel(mainModel);
        final boolean prevChangeState = workspace.isModelChanging();
        workspace.setModelIsChanging(true);

        List<AvailableField> fields = workspace.getAvailableOlapFields();
        for( AvailableField field : fields ) {
          DataType dataType = field.getLogicalColumn().getDataType();
          if( dataType == DataType.NUMERIC) {
            // create a measure
            MeasureMetaData measure = workspace.createMeasureForNode(field);
            workspace.getModel().getMeasures().add(measure);
          }
          // create a dimension
          workspace.addDimensionFromNode(field);
        }
        display.syncExec(new Runnable(){

          public void run() {

            workspace.setModelIsChanging(prevChangeState);
            workspace.setSelectedNode(workspace.getModel());
          }
        });
      }
    };
    new Thread(worker).start();


  }

  /**
   * Builds a Relational Model that is attribute based, all available fields are added into a single Category
   * @param workspace
   * @throws ModelerException
   */
  public void autoModelRelationalFlat(ModelerWorkspace workspace) throws ModelerException {
    helper.autoModelRelationalFlat(workspace);
  }

  /**
   * Builds a Relational Model that is attribute based, all available fields are added into a single Category
   * @param workspace
   * @throws ModelerException
   */
  public void autoModelRelationalFlatInBackground(final ModelerWorkspace workspace) throws ModelerException {

    final Display display = Display.findDisplay(Thread.currentThread());
    Runnable worker = new Runnable(){

      public void run() {
        RelationalModelNode relationalModelNode = new RelationalModelNode();

        relationalModelNode.setName(workspace.getRelationalModelName());

        workspace.setRelationalModel(relationalModelNode);
        final boolean prevChangeState = workspace.isModelChanging();
        workspace.setModelIsChanging(true);

        CategoryMetaData category = new CategoryMetaData("Category");

        List<AvailableField> fields = workspace.getAvailableFields();
        for( AvailableField field : fields ) {
          category.add(workspace.createFieldForParentWithNode(category, field));
        }
        relationalModelNode.getCategories().add(category);

        display.syncExec(new Runnable(){

          public void run() {

            workspace.setModelIsChanging(prevChangeState);
            workspace.setSelectedRelationalNode(workspace.getRelationalModel());
          }
        });
      }
{'fraction_non_alphanumeric': 0.08805179517363154, 'fraction_numerical': 0.0014125956444967628, 'mean_word_length': 3.5023847376788555, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1087030', 'n_tokens_mistral': 2277, 'n_tokens_neox': 2253, 'n_words': 478}