Пример #1
0
 /**
  * Selects the given column.
  *
  * @param index
  */
 private void actionColumnSelected(int index) {
   DataHandle handle = getHandle();
   if (handle != null && index < handle.getNumColumns()) {
     final String attr = handle.getAttributeName(index);
     model.setSelectedAttribute(attr);
     table.setSelectedAttribute(attr);
     controller.update(new ModelEvent(this, ModelPart.SELECTED_ATTRIBUTE, attr));
   }
 }
Пример #2
0
  /**
   * Update the view.
   *
   * @param part
   */
  protected void doUpdate(ModelPart part) {

    // Check model
    if (model == null) {
      return;
    }

    // Obtain definition
    DataDefinition definition = model.getOutputDefinition();
    if (definition == null) definition = model.getInputDefinition();

    // Obtain relevant configuration objects;
    ModelConfiguration config = null;
    Metric<?> metric = null;
    if (model.getOutputConfig() != null) {
      config = model.getOutputConfig();
      metric = config.getMetric();

      // We don't need to update in many cases, if we are displaying an output configuration
      if (part == ModelPart.ATTRIBUTE_TYPE
          || part == ModelPart.METRIC
          || part == ModelPart.ATTRIBUTE_WEIGHT
          || part == ModelPart.GS_FACTOR
          || part == ModelPart.MAX_OUTLIERS
          || part == ModelPart.DATA_TYPE
          || part == ModelPart.FINANCIAL_MODEL) {
        return;
      }

    } else {
      config = model.getInputConfig();
      // TODO: This is such an ugly hack
      metric = model.getMetricDescription().createInstance(model.getMetricConfiguration());
    }

    // Check
    if (definition == null || config == null || model.getInputConfig().getInput() == null) {
      reset();
      return;
    }

    // Obtain handle
    DataHandle data = model.getInputConfig().getInput().getHandle();

    // Disable redrawing
    root.setRedraw(false);

    // Clear
    roots.clear();

    // Print basic properties
    new Property(
        Resources.getMessage("PropertiesView.9"),
        new String[] {String.valueOf(data.getNumRows())}); // $NON-NLS-1$
    new Property(
        Resources.getMessage("PropertiesView.10"),
        new String[] {
          SWTUtil.getPrettyString(config.getAllowedOutliers() * 100d)
              + Resources.getMessage("PropertiesView.11")
        }); //$NON-NLS-1$ //$NON-NLS-2$

    // Utility measure
    Property m =
        new Property(
            Resources.getMessage("PropertiesView.114"),
            new String[] {metric.getDescription().getName()}); // $NON-NLS-1$

    // Properties of the utility measure
    if (metric.getAggregateFunction() != null) {
      new Property(
          m,
          Resources.getMessage("PropertiesView.149"),
          new String[] {metric.getAggregateFunction().toString()}); // $NON-NLS-1$
    }
    if (metric.isGSFactorSupported()) {
      new Property(
          m,
          Resources.getMessage("PropertiesView.151"),
          new String[] {
            SWTUtil.getPrettyString(metric.getGeneralizationSuppressionFactor())
          }); //$NON-NLS-1$
      new Property(
          m,
          Resources.getMessage("PropertiesView.152"),
          new String[] {SWTUtil.getPrettyString(metric.getGeneralizationFactor())}); // $NON-NLS-1$
      new Property(
          m,
          Resources.getMessage("PropertiesView.153"),
          new String[] {SWTUtil.getPrettyString(metric.getSuppressionFactor())}); // $NON-NLS-1$
    }
    new Property(
        m,
        Resources.getMessage("PropertiesView.155"),
        new String[] {SWTUtil.getPrettyString(metric.isMonotonic())}); // $NON-NLS-1$
    new Property(
        m,
        Resources.getMessage("PropertiesView.156"),
        new String[] {SWTUtil.getPrettyString(metric.isWeighted())}); // $NON-NLS-1$
    new Property(
        m,
        Resources.getMessage("PropertiesView.157"),
        new String[] {SWTUtil.getPrettyString(metric.isPrecomputed())}); // $NON-NLS-1$
    new Property(
        m,
        Resources.getMessage("PropertiesView.158"),
        new String[] {
          SWTUtil.getPrettyString(metric.isAbleToHandleMicroaggregation())
        }); //$NON-NLS-1$

    // Financial configuration
    if (metric instanceof MetricSDNMPublisherPayout) {

      // Obtain for output data
      ARXFinancialConfiguration financial =
          ((MetricSDNMPublisherPayout) metric).getFinancialConfiguration();

      // Obtain for input only. This is a bit ugly.
      if (financial == null) {
        financial = ARXFinancialConfiguration.create();
        financial
            .setAdversaryCost(config.getAdversaryCost())
            .setAdversaryGain(config.getAdversaryGain())
            .setPublisherBenefit(config.getPublisherBenefit())
            .setPublisherLoss(config.getPublisherLoss());
      }

      // Render
      new Property(
          m,
          Resources.getMessage("PropertiesView.135"),
          new String[] {SWTUtil.getPrettyString(financial.getPublisherBenefit())}); // $NON-NLS-1$
      new Property(
          m,
          Resources.getMessage("PropertiesView.136"),
          new String[] {SWTUtil.getPrettyString(financial.getPublisherLoss())}); // $NON-NLS-1$
      new Property(
          m,
          Resources.getMessage("PropertiesView.137"),
          new String[] {SWTUtil.getPrettyString(financial.getAdversaryGain())}); // $NON-NLS-1$
      new Property(
          m,
          Resources.getMessage("PropertiesView.138"),
          new String[] {SWTUtil.getPrettyString(financial.getAdversaryCost())}); // $NON-NLS-1$
      if (((MetricSDNMPublisherPayout) metric).isProsecutorAttackerModel()) {
        new Property(
            m,
            Resources.getMessage("PropertiesView.139"),
            new String[] {Resources.getMessage("PropertiesView.160")}); // $NON-NLS-1$ //$NON-NLS-2$
      }
      if (((MetricSDNMPublisherPayout) metric).isJournalistAttackerModel()) {
        new Property(
            m,
            Resources.getMessage("PropertiesView.139"),
            new String[] {Resources.getMessage("PropertiesView.161")}); // $NON-NLS-1$ //$NON-NLS-2$
      }
    }

    // Attributes
    final Property attributes =
        new Property(
            Resources.getMessage("PropertiesView.12"),
            new String[] {String.valueOf(data.getNumColumns())}); // $NON-NLS-1$

    // Print identifying attributes
    final Property identifying =
        new Property(
            attributes,
            Resources.getMessage("PropertiesView.13"),
            new String[] {
              String.valueOf(definition.getIdentifyingAttributes().size())
            }); //$NON-NLS-1$
    int index = 0;
    for (int i = 0; i < data.getNumColumns(); i++) {
      final String s = data.getAttributeName(i);
      if (definition.getIdentifyingAttributes().contains(s)) {
        final String[] values =
            new String[] {
              "", "", "", "", ""
            }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
        values[0] = s;
        values[1] = definition.getDataType(s).toString();
        new Property(
            identifying,
            Resources.getMessage("PropertiesView.19") + (index++),
            values); //$NON-NLS-1$
      }
    }

    // Print quasi-identifying attributes
    final Property quasiIdentifying =
        new Property(
            attributes,
            Resources.getMessage("PropertiesView.20"),
            new String[] {
              String.valueOf(definition.getQuasiIdentifyingAttributes().size())
            }); //$NON-NLS-1$
    index = 0;
    for (int i = 0; i < data.getNumColumns(); i++) {
      final String s = data.getAttributeName(i);
      if (definition.getQuasiIdentifyingAttributes().contains(s)) {
        final String[] values =
            new String[] {
              "", "", "", "", "", "", "", ""
            }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
        // //$NON-NLS-7$ //$NON-NLS-8$
        values[0] = s;
        if (definition.getHierarchy(s) != null) {
          DataType<?> type = definition.getDataType(s);
          values[1] = type.getDescription().getLabel();
          if (type.getDescription().hasFormat()
              && ((DataTypeWithFormat) type).getFormat() != null) {
            values[2] = ((DataTypeWithFormat) type).getFormat();
          }

          // Determine height of hierarchy
          int height = 0;
          String[][] hierarchy = definition.getHierarchy(s);
          if (hierarchy != null && hierarchy.length != 0 && hierarchy[0] != null) {
            height = hierarchy[0].length;
          }
          values[3] = String.valueOf(height);
          values[4] = String.valueOf(definition.getMinimumGeneralization(s));
          values[5] = String.valueOf(definition.getMaximumGeneralization(s));
        }
        if (definition.getMicroAggregationFunction(s) != null) {
          values[7] = definition.getMicroAggregationFunction(s).getLabel();
        }
        values[6] = SWTUtil.getPrettyString(config.getAttributeWeight(s));
        new Property(
            quasiIdentifying,
            Resources.getMessage("PropertiesView.26") + (index++),
            values); //$NON-NLS-1$
      }
    }

    // Print sensitive attributes
    final Property sensitive =
        new Property(
            attributes,
            Resources.getMessage("PropertiesView.27"),
            new String[] {
              String.valueOf(definition.getSensitiveAttributes().size())
            }); //$NON-NLS-1$
    index = 0;
    for (int i = 0; i < data.getNumColumns(); i++) {
      final String s = data.getAttributeName(i);
      if (definition.getSensitiveAttributes().contains(s)) {
        final String[] values =
            new String[] {
              "", "", "", "", ""
            }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
        values[0] = s;
        if (config.getHierarchy(s) != null && config.getHierarchy(s).getHierarchy() != null) {
          int height = 0;
          if (config.getHierarchy(s).getHierarchy().length > 0) {
            height = config.getHierarchy(s).getHierarchy()[0].length;
          }
          values[1] = definition.getDataType(s).toString();
          values[2] = String.valueOf(height);
        }
        new Property(
            sensitive,
            Resources.getMessage("PropertiesView.33") + (index++),
            values); //$NON-NLS-1$
      }
    }

    // Print insensitive attributes
    final Property insensitive =
        new Property(
            attributes,
            Resources.getMessage("PropertiesView.34"),
            new String[] {
              String.valueOf(definition.getInsensitiveAttributes().size())
            }); //$NON-NLS-1$

    index = 0;
    for (int i = 0; i < data.getNumColumns(); i++) {
      final String s = data.getAttributeName(i);
      if (definition.getInsensitiveAttributes().contains(s)) {
        final String[] values =
            new String[] {
              "", "", "", "", ""
            }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
        values[0] = s;
        values[1] = definition.getDataType(s).toString();
        new Property(
            insensitive,
            Resources.getMessage("PropertiesView.40") + (index++),
            values); //$NON-NLS-1$
      }
    }

    // Refresh and initialize
    refresh();

    // Redraw
    root.setRedraw(true);
  }