[Schmitzm-commits] r1752 - in trunk/schmitzm-core/src/main/java/de/schmitzm: lang postgres swing/input

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 11 13:51:39 CEST 2011


Author: mojays
Date: 2011-10-11 13:51:38 +0200 (Tue, 11 Oct 2011)
New Revision: 1752

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/postgres/PGUtil.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/DateInputOption.java
Log:
LangUtil: handle null-time in combineDate(.)
DateInputOption.DateTime: handle null-time
PGUtil: BugFix in addIndex(.) in FillFactor-Condition; optional Parameters for createRole(.) to grand other roles to new role


Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2011-10-10 09:46:39 UTC (rev 1751)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2011-10-11 11:51:38 UTC (rev 1752)
@@ -215,7 +215,8 @@
 	 * @param date
 	 *            date the date information is taken from
 	 * @param time
-	 *            date the time information is taken from
+	 *            date the time information is taken from (if {@code null} the time 00:00:00.000
+	 *            is set)
 	 */
 	public static Date combineDate(Date date, Date time) {
 		Calendar dateCal = GregorianCalendar.getInstance();
@@ -226,10 +227,10 @@
 		Calendar combinedDateCal = GregorianCalendar.getInstance();
 
 		// combine date and time for new date object
-		combinedDateCal.set(Calendar.HOUR_OF_DAY, timeCal.get(Calendar.HOUR_OF_DAY));
-		combinedDateCal.set(Calendar.MINUTE, timeCal.get(Calendar.MINUTE));
-		combinedDateCal.set(Calendar.SECOND, timeCal.get(Calendar.SECOND));
-		combinedDateCal.set(Calendar.MILLISECOND, timeCal.get(Calendar.MILLISECOND));
+		combinedDateCal.set(Calendar.HOUR_OF_DAY, time == null ? 0 : timeCal.get(Calendar.HOUR_OF_DAY));
+		combinedDateCal.set(Calendar.MINUTE, time == null ? 0 : timeCal.get(Calendar.MINUTE));
+		combinedDateCal.set(Calendar.SECOND, time == null ? 0 : timeCal.get(Calendar.SECOND));
+		combinedDateCal.set(Calendar.MILLISECOND, time == null ? 0 : timeCal.get(Calendar.MILLISECOND));
 
 		combinedDateCal.set(Calendar.DATE, dateCal.get(Calendar.DATE));
 		combinedDateCal.set(Calendar.MONTH, dateCal.get(Calendar.MONTH));

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/postgres/PGUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/postgres/PGUtil.java	2011-10-10 09:46:39 UTC (rev 1751)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/postgres/PGUtil.java	2011-10-11 11:51:38 UTC (rev 1752)
@@ -82,19 +82,25 @@
 
 	/**
 	 * Erstellt eine neue Rolle
+	 * @param rolename Name der neuen Rolle
+	 * @param inhRoles Rollen in denen die neue Rolle Mitglied ist
 	 */
-	public static void createRole(Connection c, String rolename) throws SQLException {
+	public static void createRole(Connection c, String rolename, String... inhRoles) throws SQLException {
 		String sql = "CREATE ROLE " + rolename;
 		c.createStatement().executeUpdate(sql);
+		for (String inhRole : inhRoles)
+		  c.createStatement().executeUpdate("GRANT "+inhRole+" TO "+rolename);
 	}
 
 	/**
 	 * Erstellt eine neue Rolle, wenn diese noch nicht existiert.
+     * @param rolename Name der neuen Rolle
+     * @param inhRoles Rollen in denen die neue Rolle Mitglied ist
 	 */
-	public static void createRoleIfNotExists(Connection c, String rolename) throws SQLException {
+	public static void createRoleIfNotExists(Connection c, String rolename, String... inhRoles) throws SQLException {
 		if (existsRole(c, rolename))
 			return;
-		createRole(c, rolename);
+		createRole(c, rolename, inhRoles);
 	}
 
 	/**
@@ -457,7 +463,7 @@
 
 		Statement s = c.createStatement();
 
-		if (fillFactor != null && fillFactor <= 0. || fillFactor > 1.)
+		if (fillFactor != null && (fillFactor <= 0. || fillFactor > 1.))
 			throw new IllegalArgumentException("fillFactor muss großer 0 und kleinergleich 1 sein.");
 
 		String sqlFillFactor = "";

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/DateInputOption.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/DateInputOption.java	2011-10-10 09:46:39 UTC (rev 1751)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/DateInputOption.java	2011-10-11 11:51:38 UTC (rev 1752)
@@ -305,8 +305,7 @@
         this.formatPlaceholder = formatPlaceholder;
         this.timeFormatPattern = timeFormatPattern;
         init(label, inputNeeded, false);
-        dateChooser.setDate(defValue);
-        timeSpinner.setValue(defValue);
+        performSetValue(defValue);
     }
 
     /**
@@ -417,6 +416,11 @@
      */
     @Override
     protected boolean performSetValue(Date newValue) {
+      if ( newValue == null ) {
+        dateChooser.setDate(null);
+        timeSpinner.setValue(LangUtil.combineDate(new Date(), null));
+        return true;
+      }
       dateChooser.setDate(newValue);
       timeSpinner.setValue(newValue);
       return true;



More information about the Schmitzm-commits mailing list