/**
   * Shows results of the clipping for selected attributes
   *
   * @param schema schema where result transformation view resides
   * @param xformResult name of the resulting transformation view
   * @param attribute name of the attribute for which transformation was performed
   * @param clippingType type of clipping which was performed, i.e. trimming or winsorising
   */
  public static void displayClippingResults(
      String schema, String xformResult, String attribute, OraClippingType clippingType) {
    System.out.println("\nShowing results of the clipping transformation");
    System.out.println(
        "\tClipping type: "
            + (true == clippingType.equals(OraClippingType.trim) ? "trim" : "winsorize"));
    System.out.println(
        "\tMinimum and maximum values for:" + attribute + " before clipping transformation");

    String sqlQuery =
        MessageFormat.format(
            "SELECT MIN ({0}) MIN_VALUE, MAX ({0}) MAX_VALUE FROM ({1})",
            new String[] {"\"" + attribute + "\"", schema + "." + "MINING_DATA_BUILD_V"});
    getMinMax(sqlQuery);

    System.out.println(
        "\tMinimum and maximum values for:" + attribute + " after clipping transformation.");
    sqlQuery =
        MessageFormat.format(
            "SELECT MIN ({0}) MIN_VALUE, MAX ({0}) MAX_VALUE FROM ({1})",
            new String[] {"\"" + attribute + "\"", schema + "." + xformResult});
    getMinMax(sqlQuery);
  }
  /**
   * Illustrates how to perform data clipping
   *
   * @param clippingType type of clipping to perform
   * @param xformResult name of the result transformation view
   * @throws JDMException if transformation failed
   */
  public static void clipData(OraClippingType clippingType, String xformResult)
      throws JDMException {
    // Schema where the original data and resulting transformations reside
    String schema = (m_dmeConn.getConnectionSpec().getName()).toUpperCase();

    OraClippingTransform oct = m_xformFactory.createClippingTransform();
    oct.setTransformInputData(schema + "." + "MINING_DATA_BUILD_V");
    oct.setTransformOutputData(schema + "." + xformResult);

    // Specify the list of excluded attributes
    String[] excludedList = new String[] {"CUST_ID", "CUST_GENDER"};
    oct.setExcludeColumnList(excludedList);

    // Specify the type of clipping: trim of winsorize ( default is trimming).
    oct.setClippingType(clippingType);

    // Specify the tail fraction as 3% of values on both ends
    oct.setTailFraction(0.03);

    ArrayList xformList = new ArrayList();
    xformList.add(oct);
    // Create a transformation sequence object
    OraTransformationSequence xformSeq =
        m_xformFactory.createTransformationSequence(
            schema + "." + "MINING_DATA_BUILD_V", // name of the input data set
            xformList, // List of transformations. In this case only one type of transformation
            // i.e., supervised binning
            schema + "." + xformResult // name of the transformation result
            );
    String xformSeqName = "clp_" + clippingType.name() + "_xfSeq";
    m_dmeConn.saveObject(xformSeqName, xformSeq, true);

    OraTransformationTask xformTask = m_xformTaskFactory.create(xformSeqName, false);
    executeTask(xformTask, "xfromClip_jdm");

    displayClippingResults(schema, xformResult, "AGE", clippingType);
  }