Search in sources :

Example 46 with XmlBuilder

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

the class StatisticsKeeperXmlBuilder method handleScalar.

public void handleScalar(Object data, String scalarName, String value) {
    XmlBuilder context = (XmlBuilder) data;
    addNumber(context, scalarName, value);
}
Also used : XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 47 with XmlBuilder

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

the class StatisticsKeeperXmlBuilder method openGroup.

public Object openGroup(Object parentData, String name, String type) {
    XmlBuilder context = (XmlBuilder) parentData;
    XmlBuilder group = new XmlBuilder(GROUP_ELEMENT);
    group.addAttribute("name", name);
    group.addAttribute("type", type);
    context.addSubElement(group);
    return group;
}
Also used : XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 48 with XmlBuilder

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

the class StatisticsKeeperXmlBuilder method statisticsKeeperToXmlBuilder.

public XmlBuilder statisticsKeeperToXmlBuilder(StatisticsKeeper sk, String elementName) {
    if (sk == null) {
        return null;
    }
    String name = sk.getName();
    XmlBuilder container = new XmlBuilder(elementName);
    if (name != null)
        container.addAttribute("name", name);
    XmlBuilder cumulativeStats = new XmlBuilder(STATKEEPER_SUMMARY_ELEMENT);
    for (int i = 0; i < sk.getItemCount(); i++) {
        Object item = sk.getItemValue(i);
        if (item == null) {
            addNumber(cumulativeStats, sk.getItemName(i), "-");
        } else {
            switch(sk.getItemType(i)) {
                case StatisticsKeeper.ITEM_TYPE_INTEGER:
                    addNumber(cumulativeStats, sk.getItemName(i), "" + (Long) item);
                    break;
                case StatisticsKeeper.ITEM_TYPE_TIME:
                    addNumber(cumulativeStats, sk.getItemName(i), df.format(item));
                    break;
                case StatisticsKeeper.ITEM_TYPE_FRACTION:
                    addNumber(cumulativeStats, sk.getItemName(i), "" + pf.format(((Double) item).doubleValue() * 100) + "%");
                    break;
            }
        }
    }
    container.addSubElement(cumulativeStats);
    XmlBuilder intervalStats = new XmlBuilder(STATKEEPER_INTERVAL_ELEMENT);
    for (int i = 0; i < sk.getIntervalItemCount(); i++) {
        Object item = sk.getIntervalItemValue(i);
        if (item == null) {
            addNumber(intervalStats, sk.getIntervalItemName(i), "-");
        } else {
            switch(sk.getIntervalItemType(i)) {
                case StatisticsKeeper.ITEM_TYPE_INTEGER:
                    addNumber(intervalStats, sk.getIntervalItemName(i), "" + (Long) item);
                    break;
                case StatisticsKeeper.ITEM_TYPE_TIME:
                    addNumber(intervalStats, sk.getIntervalItemName(i), df.format(item));
                    break;
                case StatisticsKeeper.ITEM_TYPE_FRACTION:
                    addNumber(intervalStats, sk.getIntervalItemName(i), "" + pf.format(((Double) item).doubleValue() * 100) + "%");
                    break;
            }
        }
    }
    container.addSubElement(intervalStats);
    return container;
}
Also used : XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 49 with XmlBuilder

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

the class StatisticsKeeperXmlBuilder method start.

public Object start(Date now, Date mainMark, Date detailMark) {
    log.debug("StatisticsKeeperXmlBuilder.start()");
    long freeMem = Runtime.getRuntime().freeMemory();
    long totalMem = Runtime.getRuntime().totalMemory();
    XmlBuilder root = new XmlBuilder(ROOT_ELEMENT);
    root.addAttribute("version", STATISTICS_XML_VERSION);
    root.addAttribute("heapSize", Long.toString(totalMem - freeMem));
    root.addAttribute("totalMemory", Long.toString(totalMem));
    root.addAttribute("timestamp", DateUtils.format(now, DateUtils.FORMAT_GENERICDATETIME));
    root.addAttribute("intervalStart", DateUtils.format(mainMark, DateUtils.FORMAT_GENERICDATETIME));
    root.addAttribute("host", Misc.getHostname());
    root.addAttribute("instance", AppConstants.getInstance().getProperty("instance.name"));
    addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_HOUR, PERIOD_FORMAT_DATEHOUR }, PERIOD_ALLOWED_LENGTH_HOUR, "", mainMark);
    addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_DAY, PERIOD_FORMAT_DATE, PERIOD_FORMAT_WEEKDAY }, PERIOD_ALLOWED_LENGTH_DAY, "", mainMark);
    addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_WEEK, PERIOD_FORMAT_YEARWEEK }, PERIOD_ALLOWED_LENGTH_WEEK, "", mainMark);
    addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_MONTH, PERIOD_FORMAT_YEARMONTH }, PERIOD_ALLOWED_LENGTH_MONTH, "", mainMark);
    addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_YEAR }, PERIOD_ALLOWED_LENGTH_YEAR, "", mainMark);
    if (detailMark != null) {
        root.addAttribute("intervalStartDetail", DateUtils.format(detailMark, DateUtils.FORMAT_GENERICDATETIME));
        addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_HOUR, PERIOD_FORMAT_DATEHOUR }, PERIOD_ALLOWED_LENGTH_HOUR, "Detail", detailMark);
        addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_DAY, PERIOD_FORMAT_DATE, PERIOD_FORMAT_WEEKDAY }, PERIOD_ALLOWED_LENGTH_DAY, "Detail", detailMark);
        addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_WEEK, PERIOD_FORMAT_YEARWEEK }, PERIOD_ALLOWED_LENGTH_WEEK, "Detail", detailMark);
        addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_MONTH, PERIOD_FORMAT_YEARMONTH }, PERIOD_ALLOWED_LENGTH_MONTH, "Detail", detailMark);
        addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_YEAR }, PERIOD_ALLOWED_LENGTH_YEAR, "Detail", detailMark);
    }
    return root;
}
Also used : XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 50 with XmlBuilder

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

the class StatisticsKeeperXmlBuilder method handleStatisticsKeeper.

public void handleStatisticsKeeper(Object data, StatisticsKeeper sk) {
    XmlBuilder context = (XmlBuilder) data;
    XmlBuilder item = statisticsKeeperToXmlBuilder(sk, STATKEEPER_ELEMENT);
    if (item != null) {
        context.addSubElement(item);
    }
}
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