From 9e4033f229fb89c5574c545ee6ee856d91d6ec39 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Sat, 22 Dec 2012 21:16:22 +0100 Subject: [PATCH] fix for event starter: delete start time when event is removed --- htroot/Table_API_p.java | 5 ++++- source/net/yacy/data/WorkTables.java | 6 +++++- source/net/yacy/search/Switchboard.java | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/htroot/Table_API_p.java b/htroot/Table_API_p.java index ee031b17a..9b787e72b 100644 --- a/htroot/Table_API_p.java +++ b/htroot/Table_API_p.java @@ -93,7 +93,10 @@ public class Table_API_p { } if (post.containsKey("event_kind_" + current_pk) ) { - row.put(WorkTables.TABLE_API_COL_APICALL_EVENT_KIND, post.get("event_kind_" + current_pk, "off")); + if ("off".equals(action = post.get("event_kind_" + current_pk, "off"))) { + row.put(WorkTables.TABLE_API_COL_DATE_NEXT_EXEC, ""); + } + row.put(WorkTables.TABLE_API_COL_APICALL_EVENT_KIND, action); } if (post.containsKey("event_action_" + current_pk) ) { diff --git a/source/net/yacy/data/WorkTables.java b/source/net/yacy/data/WorkTables.java index 6069ce98b..d7bf82424 100644 --- a/source/net/yacy/data/WorkTables.java +++ b/source/net/yacy/data/WorkTables.java @@ -292,6 +292,7 @@ public class WorkTables extends Tables { public static void calculateAPIScheduler(Tables.Data row, boolean update) { Date date = row.containsKey(WorkTables.TABLE_API_COL_DATE) ? row.get(WorkTables.TABLE_API_COL_DATE, (Date) null) : null; date = update ? row.get(WorkTables.TABLE_API_COL_DATE_NEXT_EXEC, date) : row.get(WorkTables.TABLE_API_COL_DATE_LAST_EXEC, date); + if (date == null) return; long d = date.getTime(); final String kind = row.get(WorkTables.TABLE_API_COL_APICALL_EVENT_KIND, "off"); @@ -313,7 +314,10 @@ public class WorkTables extends Tables { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmm"); d = dateFormat.parse(dateFormat.format(new Date()).substring(0, 8) + action).getTime(); if (d < System.currentTimeMillis()) d += day; - } catch (ParseException e) {} + } catch (ParseException e) {} else { + row.put(WorkTables.TABLE_API_COL_DATE_NEXT_EXEC, ""); + return; + } } row.put(WorkTables.TABLE_API_COL_DATE_NEXT_EXEC, new Date(d)); } diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java index 0464ee970..7d7a6aa8b 100644 --- a/source/net/yacy/search/Switchboard.java +++ b/source/net/yacy/search/Switchboard.java @@ -2266,6 +2266,7 @@ public final class Switchboard extends serverSwitch { pks.add(UTF8.String(row.getPK())); if ("once".equals(kind)) { row.put(WorkTables.TABLE_API_COL_APICALL_EVENT_KIND, "off"); + row.put(WorkTables.TABLE_API_COL_DATE_NEXT_EXEC, ""); sb.tables.update(WorkTables.TABLE_API_NAME, row); } }