Changeset 1103 for contrib/psync
- Timestamp:
- 07/08/09 19:14:32 (15 years ago)
- Location:
- contrib/psync
- Files:
-
- 15 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/psync/build/build.properties
r1009 r1103 2 2 3 3 # version dependant jar files 4 common-pim.jar= funambol-common-pim-6.0.3.jar4 common-pim.jar=pim-framework-7.0.6.jar 5 5 6 6 psync.name=funambol-psync 7 psync.release.major= 17 psync.release.major=7 8 8 psync.release.minor=0 9 psync.build.number= 09 psync.build.number=1 -
contrib/psync/build/build.xml
r1009 r1103 189 189 <pathelement location="${dir.lib}/commons-codec-1.3.jar" /> 190 190 <pathelement location="${dir.lib}/commons-lang-2.2.jar" /> 191 <pathelement location="${dir.lib}/funambol-framework.jar"/> 192 <pathelement location="${dir.lib}/funambol-admin-dev.jar"/> 191 <pathelement location="${dir.lib}/ds-server-7.0.4.jar"/> 192 <pathelement location="${dir.lib}/core-framework-7.0.1.jar"/> 193 <pathelement location="${dir.lib}/server-framework-7.0.4.jar"/> 194 <pathelement location="${dir.lib}/admin-framework-7.0.0.jar"/> 193 195 <pathelement location="${dir.lib}/joda-time-1.4.jar" /> 194 196 <pathelement location="${dir.lib}/${pim-common.lib}" /> -
contrib/psync/src/main/java/br/com/prognus/psync/admin/PIMSyncSourceConfigPanel.java
r1009 r1103 167 167 /** 168 168 * Set preferredSize of the panel 169 * 169 * 170 170 * @return preferredSize of the panel 171 171 */ … … 179 179 * Checks if the values provided by the user are all valid. If they are, the 180 180 * method ends regularly. 181 * 181 * 182 182 * @throws IllegalArgumentException 183 183 * if name, uri, type or directory are empty (null or … … 236 236 /** 237 237 * Checks whether a SIF content type is selected. 238 * 238 * 239 239 * @return true if in the combo box the selected string starts with "SIF" 240 240 */ … … 249 249 /** 250 250 * Adds extra components just above the confirm button. 251 * 251 * 252 252 * @param x 253 253 * horizontal position … … 268 268 /** 269 269 * Returns the panel name 270 * 270 * 271 271 * @return the panel name 272 272 */ … … 277 277 /** 278 278 * Returns the available types 279 * 279 * 280 280 * @return the available types; 281 281 */ … … 284 284 /** 285 285 * Returns the type to select based on the given syncsource 286 * 286 * 287 287 * @return the type to select based on the given syncsource 288 288 */ … … 292 292 * Sets the source info of the given syncsource based on the given 293 293 * selectedType 294 * 294 * 295 295 * @param syncSource 296 296 * the source … … 305 305 /** 306 306 * Creates the panel's components and layout. 307 * 307 * 308 308 * @todo adjust layout 309 309 */ -
contrib/psync/src/main/java/br/com/prognus/psync/engine/source/PIMCalendarSyncSource.java
r1009 r1103 74 74 public void beginSync(SyncContext context) { 75 75 76 this.manager = new PIMCalendarManager(JNDI_DATA_SOURCE_NAME, context 77 .getPrincipal()); 76 try { 77 this.manager = new PIMCalendarManager(JNDI_DATA_SOURCE_NAME, context.getPrincipal(), context.getSourceQuery()); 78 } catch (Exception e) { 79 // TODO Auto-generated catch block 80 e.printStackTrace(); 81 } 78 82 super.manager = this.manager; 79 83 super.beginSync(context); 80 84 } 85 86 81 87 82 88 /** -
contrib/psync/src/main/java/br/com/prognus/psync/engine/source/PIMSyncSource.java
r1009 r1103 106 106 log.trace("PIMSyncSource beginSync start"); 107 107 108 this.sourceQuery = context.getSourceQuery(); 109 108 110 principal = context.getPrincipal(); 109 111 userId = principal.getUsername(); … … 148 150 /** 149 151 * Gets the status of the SyncItem with the given key. 150 * 152 * 151 153 * @param syncItemKey 152 154 * as a SyncItemKey object … … 214 216 /** 215 217 * Extracts the content from a syncItem. 216 * 218 * 217 219 * @param syncItem 218 220 * @return as a String object -
contrib/psync/src/main/java/br/com/prognus/psync/items/dao/PIMCalendarDAO.java
r1009 r1103 135 135 private Sync4jPrincipal principal = null; 136 136 137 private Boolean sourceQuery = false; 138 private Timestamp date1 = null; 139 private Timestamp date2 = null; 140 137 141 /* 138 142 * @see PIMEntityDAO#PIMEntityDAO(String, String) 139 143 */ 140 public PIMCalendarDAO(String jndiDataSourceName, Sync4jPrincipal principal ){144 public PIMCalendarDAO(String jndiDataSourceName, Sync4jPrincipal principal, String sourceQuery) throws Exception { 141 145 142 146 super(jndiDataSourceName, principal.getUsername()); 143 147 log.info("\n\n=> Created new PIMCalendarDAO for data source " + jndiDataSourceName + " and user ID " + userId); 144 148 this.principal = principal; 149 150 if(sourceQuery != null){ 151 this.sourceQuery = true; 152 findDates(sourceQuery); 153 } 145 154 } 146 155 … … 178 187 long id_cal = 0; 179 188 189 long datea1 = 0; 190 long datea2 = 0; 191 long dateb1 = 0; 192 180 193 try { 181 194 … … 202 215 } 203 216 204 rp = c.getRecurrencePattern(); // Recebe a repetição do alarme 205 reminder = c.getReminder(); // Recebe o alarme do evento 206 body = stringFrom(c.getDescription()); // Descricao completa do evento 207 location = stringFrom(c.getLocation()); // Localizacao do evento 208 is_public = (stringFrom(c.getAccessClass())).equals("2") ? "0" : "1"; // Evento particular ou publico 209 subject = stringFrom(c.getSummary()); // Titulo do evento 210 category = stringFrom(c.getCategories()); 211 212 // Verifica o parametro uid necessario para o expresso 213 ps = con.prepareStatement("select config_value from phpgw_config WHERE config_name = 'hostname' AND config_app = 'phpgwapi'"); 214 rs = ps.executeQuery(); 215 String uid = rs.next() ? ("-@" + rs.getString(1)) : ""; 216 217 // Verifica a categoria do evento 218 if(category != null && (!category.equals(""))){ 219 category = addCategory(category); 220 } 221 222 // Prepara os dados para inserir o evento no banco de dados 223 ps = con.prepareStatement(SQL_INSERT_INTO_EXP_PIM_CALENDAR); 224 ps.setString(1, uid); // -@hostname 225 ps.setLong(2, Long.parseLong(userId)); // owner 226 ps.setString(3, category); // category 227 ps.setLong(4, new Long(Long.toString(dtstart.getTime()).substring(0, 10))); // datetime 228 ps.setLong(5, new Long(Long.toString(lastUpdate.getTime()).substring(0, 10))); // mdatetime 229 ps.setLong(6, new Long(Long.toString(dend.getTime()).substring(0, 10))); // edatetime 230 ps.setString(7, (rp == null) ? "E" : "M"); // cal_type 231 ps.setLong(8, Long.parseLong(is_public)); // is_plublic 232 ps.setString(9, truncate(subject, SQL_SUBJECT_DIM)); // title 233 ps.setString(10, truncate(body, SQL_BODY_DIM)); // body of event, a little description of it 234 ps.setString(11, truncate(location, SQL_LOCATION_DIM)); // location of the event 235 ps.setString(12, ""); // Participants outside 236 ps.setLong(13, lastUpdate.getTime()); // last update 237 ps.setString(14, String.valueOf(Def.PIM_STATE_NEW)); // status 238 ps.executeUpdate(); 239 240 // Verifica o id maximo do evento inserido 241 ps = con.prepareStatement("select max(cal_id) from phpgw_cal limit 1"); 242 rs = ps.executeQuery(); 243 244 if (rs.next()) { 245 long id = rs.getInt(1); 246 id_cal = (id == 0) ? 1 : id; 247 } 248 249 cw.setId(Long.toString(id_cal)); 250 251 ps = con.prepareStatement(SQL_INSERT_INTO_EXP_PIM_CALENDAR_USER); 252 ps.setLong(1, id_cal); 253 ps.setLong(2, Long.parseLong(userId)); // owner 254 ps.executeUpdate(); 255 256 // Evento com repetição 257 if (rp != null) { 258 addRecurrencePattern(rp, id_cal, sd); 259 } 260 261 // Evento com Alarme 262 if (reminder != null && reminder.isActive()) { 263 addReminder(reminder, id_cal); 264 } 265 266 con.commit(); 267 con.setAutoCommit(true); 217 // datea1 = this.date1.getTime(); // 23 218 // datea2 = this.date2.getTime(); // 29 219 // dateb1 = dtstart.getTime(); // 28 220 // 221 // if(dateb1 >= datea1 && dateb1 <= datea2){ 222 223 rp = c.getRecurrencePattern(); // Recebe a repetição do alarme 224 reminder = c.getReminder(); // Recebe o alarme do evento 225 body = stringFrom(c.getDescription()); // Descricao completa do evento 226 location = stringFrom(c.getLocation()); // Localizacao do evento 227 is_public = (stringFrom(c.getAccessClass())).equals("2") ? "0" : "1"; // Evento particular ou publico 228 subject = stringFrom(c.getSummary()); // Titulo do evento 229 category = stringFrom(c.getCategories()); 230 231 // Verifica o parametro uid necessario para o expresso 232 ps = con.prepareStatement("select config_value from phpgw_config WHERE config_name = 'hostname' AND config_app = 'phpgwapi'"); 233 rs = ps.executeQuery(); 234 String uid = rs.next() ? ("-@" + rs.getString(1)) : ""; 235 236 // Verifica a categoria do evento 237 if(category != null && (!category.equals(""))){ 238 category = addCategory(category); 239 } 240 241 // Prepara os dados para inserir o evento no banco de dados 242 ps = con.prepareStatement(SQL_INSERT_INTO_EXP_PIM_CALENDAR); 243 ps.setString(1, uid); // -@hostname 244 ps.setLong(2, Long.parseLong(userId)); // owner 245 ps.setString(3, category); // category 246 ps.setLong(4, new Long(Long.toString(dtstart.getTime()).substring(0, 10))); // datetime 247 ps.setLong(5, new Long(Long.toString(lastUpdate.getTime()).substring(0, 10))); // mdatetime 248 ps.setLong(6, new Long(Long.toString(dend.getTime()).substring(0, 10))); // edatetime 249 ps.setString(7, (rp == null) ? "E" : "M"); // cal_type 250 ps.setLong(8, Long.parseLong(is_public)); // is_plublic 251 ps.setString(9, truncate(subject, SQL_SUBJECT_DIM)); // title 252 ps.setString(10, truncate(body, SQL_BODY_DIM)); // body of event, a little description of it 253 ps.setString(11, truncate(location, SQL_LOCATION_DIM)); // location of the event 254 ps.setString(12, ""); // Participants outside 255 ps.setLong(13, lastUpdate.getTime()); // last update 256 ps.setString(14, String.valueOf(Def.PIM_STATE_NEW)); // status 257 ps.executeUpdate(); 258 259 // Verifica o id maximo do evento inserido 260 ps = con.prepareStatement("select max(cal_id) from phpgw_cal limit 1"); 261 rs = ps.executeQuery(); 262 263 if (rs.next()) { 264 long id = rs.getInt(1); 265 id_cal = (id == 0) ? 1 : id; 266 } 267 268 cw.setId(Long.toString(id_cal)); 269 270 ps = con.prepareStatement(SQL_INSERT_INTO_EXP_PIM_CALENDAR_USER); 271 ps.setLong(1, id_cal); 272 ps.setLong(2, Long.parseLong(userId)); // owner 273 ps.executeUpdate(); 274 275 // Evento com repetição 276 if (rp != null) { 277 addRecurrencePattern(rp, id_cal, sd); 278 } 279 280 // Evento com Alarme 281 if (reminder != null && reminder.isActive()) { 282 addReminder(reminder, id_cal); 283 } 284 285 con.commit(); 286 con.setAutoCommit(true); 287 288 // } 268 289 269 290 } catch (Exception e) { 270 throw new PIMDBAccessException("Error adding a calendar item: " 271 + e.getMessage()); 291 throw new PIMDBAccessException("Error adding a calendar item: " + e.getMessage()); 272 292 } finally { 273 293 DBTools.close(con, ps, rs); … … 810 830 dtStart = getDateFromString(stringFrom(c.getCalendarContent().getDtStart())); 811 831 dtEnd = getDateFromString(stringFrom(c.getCalendarContent().getDtEnd())); 832 833 long hj = System.currentTimeMillis(); 834 if(dtStart.getTime() > hj){ 835 return twins; 836 } 812 837 813 838 StringBuffer sqlGetCalendarTwinList = new StringBuffer(SQL_GET_EXP_PIM_CALENDAR_ID_LIST_BY_USER); … … 1437 1462 } 1438 1463 1464 private void findDates(String source) throws Exception { 1465 1466 String aux = null; 1467 StringTokenizer tokens = null; 1468 String primeira = null; 1469 String segunda = null; 1470 1471 int i = 0; 1472 int j = 0; 1473 1474 java.util.Calendar calendar1 = null; 1475 java.util.Calendar calendar2 = null; 1476 1477 try { 1478 1479 aux = source.substring(source.indexOf("(")+1, source.indexOf(")")); 1480 tokens = new StringTokenizer(aux, ","); 1481 1482 primeira = tokens.nextToken(); 1483 segunda = tokens.nextToken(); 1484 1485 i = Integer.parseInt(primeira); 1486 j = Integer.parseInt(segunda); 1487 1488 calendar1 = java.util.Calendar.getInstance(); 1489 calendar2 = java.util.Calendar.getInstance(); 1490 1491 calendar1.add(java.util.Calendar.DAY_OF_MONTH, i); 1492 calendar2.add(java.util.Calendar.DAY_OF_MONTH, j); 1493 1494 this.date1 = new Timestamp(calendar1.getTimeInMillis()); 1495 this.date2 = new Timestamp(calendar2.getTimeInMillis()); 1496 1497 } catch (Exception e) { 1498 throw new PIMDBAccessException("Error convert dates findDates " + e.getMessage()); 1499 } 1500 } 1501 1439 1502 } -
contrib/psync/src/main/java/br/com/prognus/psync/items/dao/PIMContactDAO.java
r1009 r1103 68 68 + "WHERE (id_owner = ?) " 69 69 + "AND ((given_names is null AND (?) = '') " 70 + "OR ( lower(given_names)= ?)) "70 + "OR (given_names = ?)) " 71 71 + "AND ((family_names is null AND (?) = '') " 72 + "OR ( lower(family_names)= ?)) ";72 + "OR (family_names = ?)) "; 73 73 74 74 private static final String SQL_INSERT_INTO_FNBL_PIM_CONTACT = "INSERT INTO phpgw_cc_contact " … … 1006 1006 } 1007 1007 1008 String fnSearch = (firstName.length() == 0 ? "<N/A>" : firstName 1009 .toLowerCase()); 1010 String lnSearch = (lastName.length() == 0 ? "<N/A>" : lastName 1011 .toLowerCase()); 1008 String fnSearch = (firstName.length() == 0 ? "<N/A>" : firstName); 1009 String lnSearch = (lastName.length() == 0 ? "<N/A>" : lastName); 1012 1010 StringBuilder sb = new StringBuilder(100); 1013 1011 1014 sb.append("\n\nLooking for items having: ").append( 1015 "\n> first name : '").append(fnSearch).append('\'') 1016 .append("\n> last name : '").append(lnSearch).append( 1017 '\'').append("\n"); 1012 sb.append("\n\nLooking for items having: ") 1013 .append("\n> first name : '") 1014 .append(fnSearch).append('\'') 1015 .append("\n> last name : '") 1016 .append(lnSearch).append('\'').append("\n"); 1018 1017 1019 1018 log.info(sb.toString()); … … 1022 1021 + SQL_ORDER_BY_ID); 1023 1022 ps.setLong(1, Long.parseLong(userId)); 1024 ps.setString(2, firstName .toLowerCase());1025 ps.setString(3, firstName .toLowerCase());1026 ps.setString(4, lastName .toLowerCase());1027 ps.setString(5, lastName .toLowerCase());1023 ps.setString(2, firstName); 1024 ps.setString(3, firstName); 1025 ps.setString(4, lastName); 1026 ps.setString(5, lastName); 1028 1027 rs = ps.executeQuery(); 1029 1028 -
contrib/psync/src/main/java/br/com/prognus/psync/items/dao/PIMEntityDAO.java
r1009 r1103 70 70 * Creates a new instance of PIMEntityDAO, ready to be linked to a given 71 71 * DataSource. 72 * 72 * 73 73 * @param jndiDataSourceName 74 74 * the jndiname of the datasource to use … … 197 197 * Looks up the data source, making some guess attempts based on 198 198 * jndiDataSourceName. 199 * 199 * 200 200 * @throws Exception 201 201 */ … … 216 216 * Retrieves the UID list of the new items belonging to the user filtered 217 217 * according to the given time interval. 218 * 218 * 219 219 * @param since 220 220 * the earliest allowed last-update Timestamp … … 234 234 * Retrieves the UID list of the deleted items belonging to the user 235 235 * filtered according to the given time interval. 236 * 236 * 237 237 * @param since 238 238 * the earliest allowed last-update Timestamp … … 252 252 * Retrieves the UID list of the updated items belonging to the user 253 253 * filtered according to the given time interval. 254 * 254 * 255 255 * @param since 256 256 * the earliest allowed last-update Timestamp … … 273 273 * Retrieves the UID list of the items belonging to the user filtered 274 274 * according to the given time interval and status. 275 * 275 * 276 276 * @param since 277 277 * the earliest allowed last-update Timestamp … … 289 289 /** 290 290 * Checks (safely) whether the property is unset. 291 * 291 * 292 292 * @param property 293 293 * may be null 294 294 * @return false only if the property value is a non-null, but possibly 295 295 * empty (""), string 296 * 296 * 297 297 * @see PIMEntityDAO#stringFrom(Property) 298 298 */ … … 304 304 /** 305 305 * Checks (safely) whether the property is unset or set to an empty string. 306 * 306 * 307 307 * @param property 308 308 * may be null 309 309 * @return false only if the property value is a non-null non-empty string 310 * 310 * 311 311 * @see PIMEntityDAO#stringFrom(Property, boolean) 312 312 */ … … 327 327 * considered as an acceptable value for the property: in such a case, an 328 328 * empty String object will be returned. 329 * 329 * 330 330 * @param property 331 331 * may be null … … 349 349 * stringFrom(..., false) will be considered as explicitly kept blank if its 350 350 * value is "". This means that single field deletions can be made tunable. 351 * 351 * 352 352 * @param property 353 353 * may be null … … 356 356 * null; otherwise, in such a case an empty String object will be 357 357 * returned 358 * 358 * 359 359 * @return if existing (and not empty if emptyImpliesNull is true), the 360 360 * property value will be returned as a String object … … 380 380 /** 381 381 * Gets a substring in a safe way. 382 * 382 * 383 383 * @param string 384 384 * may be null or longer than maxLength -
contrib/psync/src/main/java/br/com/prognus/psync/items/manager/PIMCalendarManager.java
r1009 r1103 43 43 44 44 /** 45 * @throws Exception 45 46 * @see PIMEntityDAO#PIMEntityDAO(String, String) 46 47 */ 47 public PIMCalendarManager(String jndiDataSourceName, 48 Sync4jPrincipal principal) { 48 public PIMCalendarManager(String jndiDataSourceName, Sync4jPrincipal principal, String sourceQuery) { 49 49 50 this.dao = new PIMCalendarDAO(jndiDataSourceName, principal); 50 try { 51 this.dao = new PIMCalendarDAO(jndiDataSourceName, principal, sourceQuery); 52 } catch (Exception e) { 53 } 51 54 super.dao = this.dao; 52 55 … … 60 63 /** 61 64 * Updates a calendar. 62 * 65 * 63 66 * @param uid 64 67 * the UID of the calendar -
contrib/psync/src/main/sql/postgresql/create_schema.sql
r1009 r1103 1 ALTER TABLE phpgw_cal ALTER title TYPE character varying(255); 1 2 ALTER TABLE phpgw_cal ADD COLUMN last_status char(1) DEFAULT 'N'::bpchar; 2 3 ALTER TABLE phpgw_cal ADD COLUMN last_update int8 DEFAULT (date_part('epoch'::text, ('now'::text)::timestamp(3) with time zone) * (1000)::double precision); … … 5 6 ALTER TABLE phpgw_cc_contact ADD COLUMN last_update int8 DEFAULT (date_part('epoch'::text, ('now'::text)::timestamp(3) with time zone) * (1000)::double precision); 6 7 ALTER TABLE phpgw_cc_contact ADD COLUMN category character varying(20); 8
Note: See TracChangeset
for help on using the changeset viewer.