Search in sources :

Example 81 with XmlBuilder

use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.

the class SchedulerAdapter method jobDataMapToXmlBuilder.

public XmlBuilder jobDataMapToXmlBuilder(Scheduler theScheduler, String jobName, String groupName) {
    XmlBuilder xbRoot = new XmlBuilder("jobDataMap");
    try {
        JobDataMap jd = theScheduler.getJobDetail(jobName, groupName).getJobDataMap();
        xbRoot.addAttribute("containsTransientData", (jd.containsTransientData() ? "True" : "False"));
        xbRoot.addAttribute("allowsTransientData", (jd.getAllowsTransientData() ? "True" : "False"));
        xbRoot.addAttribute("jobName", jobName);
        xbRoot.addAttribute("groupName", groupName);
        String[] keys = jd.getKeys();
        for (int i = 0; i < keys.length; i++) {
            String name = keys[i];
            String value = "";
            if (jd.get(keys[i]) != null) {
                value = jd.get(keys[i]).toString();
            }
            Object obj = jd.get(keys[i]);
            XmlBuilder ds = new XmlBuilder("property");
            ds.addAttribute("key", name);
            if (obj != null) {
                ds.addAttribute("className", obj.getClass().getName());
            } else
                ds.addAttribute("className", "null");
            ds.setValue(value);
            xbRoot.addSubElement(ds);
        }
    } catch (org.quartz.SchedulerException se) {
        log.error(se);
    }
    return xbRoot;
}
Also used : JobDataMap(org.quartz.JobDataMap) SchedulerException(org.quartz.SchedulerException) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 82 with XmlBuilder

use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.

the class SchedulerAdapter method triggerToXmlBuilder.

public XmlBuilder triggerToXmlBuilder(Scheduler theScheduler, String triggerName, String groupName) {
    XmlBuilder xbRoot = new XmlBuilder("triggerDetail");
    try {
        Trigger trigger = theScheduler.getTrigger(triggerName, groupName);
        xbRoot.addAttribute("fullName", trigger.getFullName());
        xbRoot.addAttribute("triggerName", trigger.getName());
        xbRoot.addAttribute("triggerGroup", trigger.getGroup());
        String cn = trigger.getCalendarName();
        xbRoot.addAttribute("calendarName", (cn == null ? "none" : cn));
        Date date;
        try {
            date = trigger.getEndTime();
            xbRoot.addAttribute("endTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
        } catch (Exception e) {
            log.debug(e);
        }
        ;
        try {
            date = trigger.getFinalFireTime();
            xbRoot.addAttribute("finalFireTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
        } catch (Exception e) {
            log.debug(e);
        }
        ;
        try {
            date = trigger.getPreviousFireTime();
            xbRoot.addAttribute("previousFireTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
        } catch (Exception e) {
            log.debug(e);
        }
        ;
        try {
            date = trigger.getNextFireTime();
            xbRoot.addAttribute("nextFireTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
        } catch (Exception e) {
            log.debug(e);
        }
        ;
        try {
            date = trigger.getStartTime();
            xbRoot.addAttribute("startTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
        } catch (Exception e) {
            log.debug(e);
        }
        ;
        xbRoot.addAttribute("misfireInstruction", Integer.toString(trigger.getMisfireInstruction()));
        if (trigger instanceof CronTrigger) {
            xbRoot.addAttribute("triggerType", "cron");
            xbRoot.addAttribute("cronExpression", ((CronTrigger) trigger).getCronExpression());
        } else if (trigger instanceof SimpleTrigger) {
            xbRoot.addAttribute("triggerType", "simple");
            xbRoot.addAttribute("repeatInterval", ((SimpleTrigger) trigger).getRepeatInterval());
        } else {
            xbRoot.addAttribute("triggerType", "unknown");
        }
        xbRoot.addAttribute("jobGroup", trigger.getJobGroup());
        xbRoot.addAttribute("jobName", trigger.getJobName());
        xbRoot.addAttribute("isVolatile", (trigger.isVolatile() ? "True" : "False"));
    } catch (SchedulerException se) {
        log.error(se);
    }
    return xbRoot;
}
Also used : CronTrigger(org.quartz.CronTrigger) Trigger(org.quartz.Trigger) SimpleTrigger(org.quartz.SimpleTrigger) CronTrigger(org.quartz.CronTrigger) SchedulerException(org.quartz.SchedulerException) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) SimpleTrigger(org.quartz.SimpleTrigger) Date(java.util.Date) SchedulerException(org.quartz.SchedulerException)

Example 83 with XmlBuilder

use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.

the class SchedulerAdapter method getJobTriggers.

public XmlBuilder getJobTriggers(Scheduler theScheduler, String jobName, String groupName) {
    XmlBuilder xbRoot = new XmlBuilder("triggersForJob");
    xbRoot.addAttribute("jobName", jobName);
    xbRoot.addAttribute("groupName", groupName);
    try {
        String[] tgnames = theScheduler.getTriggerGroupNames();
        for (int i = 0; i < tgnames.length; i++) {
            String[] triggerNames = theScheduler.getTriggerNames(tgnames[i]);
            for (int s = 0; s < triggerNames.length; s++) {
                Trigger trigger = theScheduler.getTrigger(triggerNames[s], tgnames[i]);
                if ((trigger.getJobName().equals(jobName)) && (trigger.getJobGroup().equals(groupName))) {
                    XmlBuilder tr = triggerToXmlBuilder(theScheduler, triggerNames[s], tgnames[i]);
                    xbRoot.addSubElement(tr);
                }
            }
        }
    } catch (org.quartz.SchedulerException se) {
        log.error(se);
    }
    return xbRoot;
}
Also used : Trigger(org.quartz.Trigger) SimpleTrigger(org.quartz.SimpleTrigger) CronTrigger(org.quartz.CronTrigger) SchedulerException(org.quartz.SchedulerException) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 84 with XmlBuilder

use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.

the class PercentileEstimatorBase method getSample.

public XmlBuilder getSample(int index, long count, long min, long max) {
    XmlBuilder sample = new XmlBuilder("sample");
    sample.addAttribute("percentile", "" + (100 * index) / values.length);
    sample.addAttribute("value", "" + values[index]);
    return sample;
}
Also used : XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 85 with XmlBuilder

use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.

the class PercentileEstimatorRanked method getSample.

public XmlBuilder getSample(int index, long count, long min, long max) {
    long value;
    long rank;
    if (index <= 0) {
        value = min;
        rank = 1;
    } else {
        if (index >= local_count + 1) {
            value = max;
            rank = count;
        } else {
            value = values[index - 1];
            rank = ranks[index - 1];
        }
    }
    XmlBuilder sample = new XmlBuilder("sample");
    sample.addAttribute("value", "" + value);
    sample.addAttribute("rank", "" + rank);
    sample.addAttribute("percentile", "" + ((100 * rank) - 50) / count);
    return sample;
}
Also used : XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Aggregations

XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)108 IOException (java.io.IOException)18 Iterator (java.util.Iterator)17 ArrayList (java.util.ArrayList)12 Date (java.util.Date)12 SenderException (nl.nn.adapterframework.core.SenderException)12 DomBuilderException (nl.nn.adapterframework.util.DomBuilderException)10 Configuration (nl.nn.adapterframework.configuration.Configuration)9 SchedulerException (org.quartz.SchedulerException)8 ServletException (javax.servlet.ServletException)7 TransformerException (javax.xml.transform.TransformerException)7 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)6 PipeRunException (nl.nn.adapterframework.core.PipeRunException)6 JdbcException (nl.nn.adapterframework.jdbc.JdbcException)6 JmsException (nl.nn.adapterframework.jms.JmsException)6 HashMap (java.util.HashMap)5 List (java.util.List)5 Adapter (nl.nn.adapterframework.core.Adapter)5 SimpleDateFormat (java.text.SimpleDateFormat)4 Map (java.util.Map)4