Revision: 3649
Author: [email protected]
Date: Mon Jun 28 11:21:31 2010
Log: Added in the timestamp to the column view of profiles. Also added in a row for each column profile that describes the remaining rows not included in the top n value counts. The text of this new row's value comes out in italics.
http://code.google.com/p/power-architect/source/detail?r=3649

Modified:
 /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java
 /trunk/src/main/java/ca/sqlpower/architect/ProjectLoader.java
 /trunk/src/main/java/ca/sqlpower/architect/profile/ColumnProfileResult.java
 /trunk/src/main/java/ca/sqlpower/architect/profile/ColumnValueCount.java
/trunk/src/main/java/ca/sqlpower/architect/profile/LocalReservoirProfileCreator.java /trunk/src/main/java/ca/sqlpower/architect/profile/RemoteDatabaseProfileCreator.java /trunk/src/main/java/ca/sqlpower/architect/swingui/SwingUIProjectLoader.java /trunk/src/main/java/ca/sqlpower/architect/swingui/table/MultiFreqValueCountTableModel.java /trunk/src/main/java/ca/sqlpower/architect/swingui/table/ValueTableCellRenderer.java

=======================================
--- /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java Mon Jun 14 12:44:23 2010 +++ /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java Mon Jun 28 11:21:31 2010
@@ -102,7 +102,7 @@
             cpr.setParent(tpr);
             return cpr;
         } else if (valueType == ColumnValueCount.class) {
- ColumnValueCount cvc = new ColumnValueCount(Integer.MAX_VALUE, 2, 42); + ColumnValueCount cvc = new ColumnValueCount(Integer.MAX_VALUE, 2, 42, false);
             getRootObject().addChild(cvc, 0);
             return cvc;
} else if (valueType == ArchitectSwingProject.class || valueType == ArchitectProject.class ||
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/ProjectLoader.java Tue May 25 07:52:45 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/ProjectLoader.java Mon Jun 28 11:21:31 2010
@@ -1010,17 +1010,23 @@
             }

             String value = attributes.getValue("value");
+
+            String otherValuesString = attributes.getValue("otherValues");
+            if (otherValuesString == null) {
+                otherValuesString = "false";
+            }
+            Boolean otherValues = Boolean.parseBoolean(otherValuesString);

             if (className == null || className.length() == 0 ) {
-                return new ColumnValueCount(null,count, percent);
+ return new ColumnValueCount(null,count, percent, otherValues);
             } else if (className.equals(BigDecimal.class.getName()) ) {
- return new ColumnValueCount(new BigDecimal(value),count, percent); + return new ColumnValueCount(new BigDecimal(value),count, percent, otherValues);
             } else if (className.equals(Timestamp.class.getName()) ) {
- return new ColumnValueCount(new Timestamp( Timestamp.valueOf(value).getTime() ),count, percent); + return new ColumnValueCount(new Timestamp( Timestamp.valueOf(value).getTime() ),count, percent, otherValues);
             } else if (className.equals(String.class.getName()) ) {
- return new ColumnValueCount(new String(value),count, percent); + return new ColumnValueCount(new String(value),count, percent, otherValues);
             } else {
- return new ColumnValueCount(new String(value),count, percent); + return new ColumnValueCount(new String(value),count, percent, otherValues);
             }
         }
     }
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/profile/ColumnProfileResult.java Wed Jun 23 11:55:57 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/profile/ColumnProfileResult.java Mon Jun 28 11:21:31 2010
@@ -211,8 +211,13 @@

     public void addValueCount(Object value, int count) {
         double per =  count/(double)parentResult.getRowCount();
-
- ColumnValueCount columnValueCount = new ColumnValueCount(value,count, per);
+
+        ColumnValueCount columnValueCount;
+        if (value == ColumnValueCount.OTHER_VALUE_OBJECT) {
+ columnValueCount = new ColumnValueCount(value,count, per, true);
+        } else {
+ columnValueCount = new ColumnValueCount(value,count, per, false);
+        }
         if (!topTen.contains(columnValueCount)) {
             addValueCount(columnValueCount);
logger.debug("Added Value Count: Value: " + value + " Count: " + count);
@@ -283,4 +288,19 @@
         return children;
     }

-}
+    @Override
+    @Accessor
+    public TableProfileResult getParent() {
+        return (TableProfileResult) super.getParent();
+    }
+
+    @Override
+    @Mutator
+    public void setParent(SPObject parent) {
+        if (!(parent instanceof TableProfileResult)) {
+ throw new IllegalArgumentException("Parent of " + this + " must be of type " +
+                    TableProfileResult.class);
+        }
+        super.setParent(parent);
+    }
+}
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/profile/ColumnValueCount.java Mon Apr 19 14:18:19 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/profile/ColumnValueCount.java Mon Jun 28 11:21:31 2010
@@ -26,6 +26,7 @@
 import ca.sqlpower.object.annotation.Accessor;
 import ca.sqlpower.object.annotation.Constructor;
 import ca.sqlpower.object.annotation.ConstructorParameter;
+import ca.sqlpower.object.annotation.Mutator;

 /**
  * A simple class for keeping track of a value, the number of occurrences
@@ -38,31 +39,75 @@
     /**
      * Defines an absolute ordering of the child types of this class.
      */
-    @SuppressWarnings("unchecked")
public static final List<Class<? extends SPObject>> allowedChildTypes = Collections.emptyList();

-    private Object value;
-    private int count;
-    private double percent;
+    /**
+ * This class is used to make an object that is used specifically as the value object
+     * in this class when the otherValues flag is true.
+     */
+    public static class OtherValueObject{}
+
+    /**
+ * String name that identifies this column value count as the count of all
+     * other columns in the system not including the top n in the column
+ * profile. The flag in this class for representing other values should be + * checked for the official decision if this value count is all of the other
+     * values.
+     */
+    public static final String OTHER_VALUE_OBJECT = "Other Values";
+
+    private final Object value;
+    private final int count;
+    private final double percent;
+
+    /**
+     * If true this value count is the sum and precent of the values in the
+ * column that does not match with the rest of values already counted for + * the column profile. Each column profile should have only one value count
+     * with this flag set to true.
+     */
+    private final boolean otherValues;

     /**
* Creates a new ColumnValueCount instance that associates the given value - * with the given count. Instances of this class are meant to be immtuable, + * with the given count. Instances of this class are meant to be immtuable,
      * so if the give value object is mutable, you must not modify it.
      *
- * @param value The value to associate the count with. Null is allowed. - * @param count The number of occurrences of <tt>value</tt> in the column
-     * being profiled.
-     * @param percent The percentage of occurrences in the table.
+     * @param value
+     *            The value to associate the count with. Null is allowed.
+     * @param count
+     *            The number of occurrences of <tt>value</tt> in the column
+     *            being profiled.
+     * @param percent
+     *            The percentage of occurrences in the table.
+     * @param otherValues
+ * If true this value count represents the count of all other
+     *            values in the column not accounted for by the rest of the
+     *            value counts under the column profile. The column profile
+ * should have only one value count object with this flag set to
+     *            true. If true the value should be set to
+ * {...@link #OTHER_VALUE_OBJECT}, either way the value will be set
+     *            to {...@link #OTHER_VALUE_OBJECT}.
+     *
      */
     @Constructor
public ColumnValueCount(@ConstructorParameter(propertyName="value") Object value,
             @ConstructorParameter(propertyName="count") int count,
-            @ConstructorParameter(propertyName="percent") double percent) {
+            @ConstructorParameter(propertyName="percent") double percent,
+ @ConstructorParameter(propertyName="otherValues") boolean otherValues) {
         setName("New Column Value Count");
-        this.value = value;
         this.count = count;
         this.percent = percent;
+ //Checking with .equals to reduce complexity in the persistence layer.
+        if (otherValues && !value.equals(OTHER_VALUE_OBJECT)) {
+ throw new IllegalArgumentException("The other values object should equal the static value in this class.");
+        }
+        if (otherValues) {
+            this.value = OTHER_VALUE_OBJECT;
+        } else {
+            this.value = value;
+        }
+        this.otherValues = otherValues;
     }

     public ColumnValueCount(ColumnValueCount cvcToCopy) {
@@ -70,6 +115,7 @@
         this.value = cvcToCopy.value;
         this.count = cvcToCopy.count;
         this.percent = cvcToCopy.percent;
+        this.otherValues = cvcToCopy.isOtherValues();
     }

     @Accessor
@@ -145,4 +191,25 @@
     public void removeDependency(SPObject dependency) {

     }
-}
+
+    @Override
+    @Accessor
+    public ColumnProfileResult getParent() {
+        return (ColumnProfileResult) super.getParent();
+    }
+
+    @Override
+    @Mutator
+    public void setParent(SPObject parent) {
+        if (!(parent instanceof ColumnProfileResult)) {
+ throw new IllegalArgumentException("The parent of " + this + " must be a " +
+                    ColumnProfileResult.class + " object.");
+        }
+        super.setParent(parent);
+    }
+
+    @Accessor
+    public boolean isOtherValues() {
+        return otherValues;
+    }
+}
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/profile/LocalReservoirProfileCreator.java Thu Jan 29 12:02:55 2009 +++ /trunk/src/main/java/ca/sqlpower/architect/profile/LocalReservoirProfileCreator.java Mon Jun 28 11:21:31 2010
@@ -196,10 +196,14 @@
List<Map.Entry<Object, Integer>> topNList = new ArrayList<Entry<Object,Integer>>(valueCounts.entrySet());
                 Collections.sort(topNList, new TopNValuesComparator());

+                int sumOfTopNCount = 0;
for (int i = 0; i < settings.getTopNCount() && i < topNList.size(); i++) {
                     Entry<Object, Integer> entry = topNList.get(i);
cpr.addValueCount(entry.getKey(), entry.getValue().intValue());
-                }
+                    sumOfTopNCount += entry.getValue().intValue();
+                }
+
+ cpr.addValueCount(ColumnValueCount.OTHER_VALUE_OBJECT, sample.length - sumOfTopNCount);

                 cpr.setCreateEndTime(System.currentTimeMillis());

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/profile/RemoteDatabaseProfileCreator.java Mon Dec 21 08:27:43 2009 +++ /trunk/src/main/java/ca/sqlpower/architect/profile/RemoteDatabaseProfileCreator.java Mon Jun 28 11:21:31 2010
@@ -214,8 +214,8 @@
             createProfileFunctions(dsType);
             for (SQLColumn col : table.getColumns()) {
ColumnProfileResult columnResult = new ColumnProfileResult(col, tpr);
-                doColumnProfile(columnResult, pm);
                 tpr.addColumnProfileResult(columnResult);
+                doColumnProfile(columnResult, pm);
                 pm.setProgress(pm.getProgress() + 1);
             }

@@ -470,8 +470,14 @@
                 lastSQL = sql.toString();
                 rs = stmt.executeQuery(lastSQL);
                 int topNCount = settings.getTopNCount();
+                int topNSum = 0;
                 for (int n = 0; rs.next() && n < topNCount; n++) {
cpr.addValueCount(rs.getObject("MYVALUE"), rs.getInt("COUNT1"));
+                    topNSum += rs.getInt("COUNT1");
+                }
+ int remainingCount = cpr.getParent().getRowCount() - topNSum;
+                if (remainingCount > 0) {
+ cpr.addValueCount(ColumnValueCount.OTHER_VALUE_OBJECT, remainingCount);
                 }
                 rs.close();
                 rs = null;
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/SwingUIProjectLoader.java Mon Jun 14 09:32:54 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/SwingUIProjectLoader.java Mon Jun 28 11:21:31 2010
@@ -1250,7 +1250,9 @@
                                 "\" value=\""+ //$NON-NLS-1$
SQLPowerUtils.escapeXML(String.valueOf(count.getValue()))+
                                 "\" percent=\"" +  //$NON-NLS-1$
- count.getPercent() + "\"/>" ); //$NON-NLS-1$
+                                count.getPercent() +
+                                "\" otherValues=\"" +
+ Boolean.toString(count.isOtherValues()) + "/>" ); //$NON-NLS-1$
                     }
                 }
                 ioo.indent--;
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/table/MultiFreqValueCountTableModel.java Tue Jun 22 15:19:40 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/table/MultiFreqValueCountTableModel.java Mon Jun 28 11:21:31 2010
@@ -30,6 +30,7 @@
 import ca.sqlpower.architect.profile.ColumnProfileResult;
 import ca.sqlpower.architect.profile.ColumnValueCount;
 import ca.sqlpower.architect.profile.TableProfileResult;
+import ca.sqlpower.swingui.table.DateTableCellRenderer;
 import ca.sqlpower.swingui.table.PercentTableCellRenderer;

 /**
@@ -63,7 +64,7 @@
* This is the list of currently selected table profile results to display
      * in this table model.
      */
- private final List<TableProfileResult> tprList = new ArrayList<TableProfileResult>(); + private final List<ColumnValueCount> cvcList = new ArrayList<ColumnValueCount>();

     /**
      * @param tm
@@ -77,23 +78,21 @@
     }

     public void refresh() {
-        tprList.clear();
-        tprList.addAll(tm.getTableResultsToScan());
+        cvcList.clear();
+        for (TableProfileResult tpr : tm.getTableResultsToScan()) {
+            for (ColumnProfileResult cpr : tpr.getColumnProfileResults()) {
+                cvcList.addAll(cpr.getValueCount());
+            }
+        }
         fireTableDataChanged();
     }

     public int getColumnCount() {
-        return 5;
+        return 6;
     }

     public int getRowCount() {
-        int rowCount = 0;
-        for (TableProfileResult tpr : tprList) {
-            for (ColumnProfileResult cpr : tpr.getColumnProfileResults()) {
-                rowCount += cpr.getValueCount().size();
-            }
-        }
-        return rowCount;
+        return cvcList.size();
     }

     @Override
@@ -109,36 +108,31 @@
                 return "Count";
             case 4:
                 return "%";
+            case 5:
+                return "Creation Time";
             default:
throw new IllegalArgumentException("Column " + column + " does not exist.");
         }
     }

     public Object getValueAt(int rowIndex, int columnIndex) {
-        int rowCount = 0;
-        for (TableProfileResult tpr : tprList) {
-            for (ColumnProfileResult cpr : tpr.getColumnProfileResults()) {
-                if (rowCount + cpr.getValueCount().size() > rowIndex) {
- ColumnValueCount cvc = cpr.getValueCount().get(rowIndex - rowCount);
-                    switch (columnIndex) {
-                        case 0:
-                            return tpr.getProfiledObject();
-                        case 1:
-                            return cpr.getProfiledObject();
-                        case 2:
-                            return cvc.getValue();
-                        case 3:
-                            return cvc.getCount();
-                        case 4:
-                            return cvc.getPercent();
-                        default:
- throw new IllegalArgumentException("Column at index " + columnIndex + " does not exist.");
-                    }
-                }
-                rowCount += cpr.getValueCount().size();
-            }
-        }
-        throw new IllegalStateException("No value for row " + rowIndex);
+        ColumnValueCount cvc = cvcList.get(rowIndex);
+        switch (columnIndex) {
+        case 0:
+            return cvc.getParent().getParent().getProfiledObject();
+        case 1:
+            return cvc.getParent().getProfiledObject();
+        case 2:
+            return cvc.getValue();
+        case 3:
+            return cvc.getCount();
+        case 4:
+            return cvc.getPercent();
+        case 5:
+            return cvc.getParent().getParent().getCreateStartTime();
+        default:
+ throw new IllegalArgumentException("Column at index " + columnIndex + " does not exist.");
+        }
     }

     /**
@@ -160,6 +154,8 @@
                 return new ValueTableCellRenderer();
             case 4:
                 return new PercentTableCellRenderer();
+            case 5:
+                return new DateTableCellRenderer();
             default:
throw new IllegalArgumentException("No cell renderer for column " + colIndex);
         }
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/table/ValueTableCellRenderer.java Tue Mar 25 07:38:28 2008 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/table/ValueTableCellRenderer.java Mon Jun 28 11:21:31 2010
@@ -50,12 +50,16 @@
         } else if (value instanceof Number) {
             formattedValue = aldf.format(value);
         } else if ( value instanceof List ) {
-            if ( ((List) value).size() > 0 )
+            if ( ((List) value).size() > 0 ) {
+ final ColumnValueCount valueCount = (ColumnValueCount)((List) value).get(0);
                 formattedValue = String.valueOf(
- ((ColumnValueCount)((List) value).get(0)).getValue());
-            else
+                        valueCount.getValue());
+                if (valueCount.isOtherValues()) {
+ formattedValue = "<html><i>" + formattedValue + "</i></html>";
+                }
+            } else {
                 formattedValue = "";
-
+            }

             StringBuffer toolTip = new StringBuffer();
             toolTip.append("<html><table>");
@@ -65,7 +69,11 @@
                 if ( v.getValue() == null ) {
                     toolTip.append("null");
                 } else {
-                    toolTip.append(v.getValue().toString());
+                    if (v.isOtherValues()) {
+ toolTip.append("<i>" + v.getValue().toString() + "</i>");
+                    } else {
+                        toolTip.append(v.getValue().toString());
+                    }
                 }
                 toolTip.append("</td>");
                 toolTip.append("<td>&nbsp;&nbsp;&nbsp;</td>");
@@ -77,7 +85,11 @@
             toolTip.append("</table></html>");
             setToolTipText(toolTip.toString());
         } else {
-            formattedValue = value.toString();
+            if (value == ColumnValueCount.OTHER_VALUE_OBJECT) {
+ formattedValue = "<html><i>" + value.toString() + "</i></html>";
+            } else {
+                formattedValue = value.toString();
+            }
         }
return super.getTableCellRendererComponent(table, formattedValue, isSelected, hasFocus, row, column);
     }

Reply via email to