001package jmri.jmrit.logixng.actions.configurexml; 002 003import jmri.*; 004import jmri.configurexml.JmriConfigureXmlException; 005import jmri.jmrit.logixng.DigitalActionManager; 006import jmri.jmrit.logixng.actions.TriggerRoute; 007import jmri.jmrit.logixng.util.configurexml.LogixNG_SelectEnumXml; 008import jmri.jmrit.logixng.util.configurexml.LogixNG_SelectNamedBeanXml; 009import org.jdom2.Element; 010 011/** 012 * Handle XML configuration for ActionLightXml objects. 013 * 014 * @author Bob Jacobsen Copyright: Copyright (c) 2004, 2008, 2010 015 * @author Daniel Bergqvist Copyright (C) 2021 016 */ 017public class TriggerRouteXml extends jmri.managers.configurexml.AbstractNamedBeanManagerConfigXML { 018 019 public TriggerRouteXml() { 020 } 021 022 /** 023 * Default implementation for storing the contents of a TriggerRoute 024 * 025 * @param o Object to store, of type TriggerRoute 026 * @return Element containing the complete info 027 */ 028 @Override 029 public Element store(Object o) { 030 TriggerRoute p = (TriggerRoute) o; 031 032 Element element = new Element("TriggerRoute"); 033 element.setAttribute("class", this.getClass().getName()); 034 element.addContent(new Element("systemName").addContent(p.getSystemName())); 035 036 storeCommon(p, element); 037 038 var selectNamedBeanXml = new LogixNG_SelectNamedBeanXml<Route>(); 039 var selectEnumXml = new LogixNG_SelectEnumXml<TriggerRoute.Operation>(); 040 041 element.addContent(selectNamedBeanXml.store(p.getSelectNamedBean(), "namedBean")); 042 element.addContent(selectEnumXml.store(p.getSelectEnum(), "operation")); 043 044 return element; 045 } 046 047 @Override 048 public boolean load(Element shared, Element perNode) throws JmriConfigureXmlException { // Test class that inherits this class throws exception 049 String sys = getSystemName(shared); 050 String uname = getUserName(shared); 051 TriggerRoute h = new TriggerRoute(sys, uname); 052 053 loadCommon(h, shared); 054 055 var selectNamedBeanXml = new LogixNG_SelectNamedBeanXml<Route>(); 056 var selectEnumXml = new LogixNG_SelectEnumXml<TriggerRoute.Operation>(); 057 058 selectNamedBeanXml.load(shared.getChild("namedBean"), h.getSelectNamedBean()); 059 selectNamedBeanXml.loadLegacy(shared, h.getSelectNamedBean(), "route"); 060 061 selectEnumXml.load(shared.getChild("operation"), h.getSelectEnum()); 062 selectEnumXml.loadLegacy( 063 shared, h.getSelectEnum(), 064 "operationAddressing", 065 "operationDirect", 066 "operationReference", 067 "operationLocalVariable", 068 "operationFormula"); 069 070 InstanceManager.getDefault(DigitalActionManager.class).registerAction(h); 071 return true; 072 } 073 074// private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TriggerRouteXml.class); 075}