From 53bdab8667814f8d3b5abc6b548a18aa7b73c017 Mon Sep 17 00:00:00 2001 From: Frank Maritato Date: Thu, 15 Apr 2010 17:46:47 +0000 Subject: [PATCH] last hooks for getting default values set git-svn-id: https://lwes.svn.sourceforge.net/svnroot/lwes/lwes-java/trunk@437 a2f82657-cdd2-4550-bd36-68a8e7111808 --- src/main/java/org/lwes/Event.java | 18 ++++++++++++++++++ src/main/java/org/lwes/db/EventTemplateDB.java | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/lwes/Event.java b/src/main/java/org/lwes/Event.java index e4539ff..50ecd37 100644 --- a/src/main/java/org/lwes/Event.java +++ b/src/main/java/org/lwes/Event.java @@ -105,6 +105,7 @@ public class Event { validating = validate; setEventName(eventName); setEncoding(encoding); + setDefaultValues(eventTemplateDB); } /** @@ -137,6 +138,23 @@ public class Event { setEventTemplateDB(eventTemplateDB); validating = validate; deserialize(bytes); + setDefaultValues(eventTemplateDB); + } + + protected void setDefaultValues(EventTemplateDB template) throws EventSystemException { + if (template == null) { + return; + } + Map m = template.getBaseTypesForEvent(getEventName()); + for (String key : m.keySet()) { + BaseType b = m.get(key); + if (b.getDefaultValue() != null) { + if (Log.isLogDebug()) { + Log.debug("Setting default value: "+key+"="+b.getDefaultValue()); + } + set(key, b.getDefaultValue()); + } + } } /** diff --git a/src/main/java/org/lwes/db/EventTemplateDB.java b/src/main/java/org/lwes/db/EventTemplateDB.java index fac50eb..d09855b 100644 --- a/src/main/java/org/lwes/db/EventTemplateDB.java +++ b/src/main/java/org/lwes/db/EventTemplateDB.java @@ -196,7 +196,7 @@ public class EventTemplateDB { boolean required) { return addEventAttribute(anEventName, anAttributeName, anAttributeType, size, required, null); } - + /** * Add an attribute to an Event in the EventTemplateDB * @@ -244,6 +244,9 @@ public class EventTemplateDB { BaseType bt = knownTypes.get(anAttributeType).cloneBaseType(); bt.setRequired(required); bt.setSizeRestriction(size); + if (defaultValue != null) { + bt.setDefaultValue(defaultValue); + } evtHash.put(anAttributeName, bt); return true; } -- 2.11.4.GIT