|
1 | | -/* |
2 | | - * To change this license header, choose License Headers in Project Properties. |
3 | | - * To change this template file, choose Tools | Templates |
4 | | - * and open the template in the editor. |
5 | | - */ |
6 | | -package de.bundesbank.jdemetra.exceladapter.handler; |
7 | | - |
8 | | -import de.bundesbank.jdemetra.exceladapter.ExcelMetaDataHelper; |
9 | | -import ec.satoolkit.DecompositionMode; |
10 | | -import ec.satoolkit.x11.X11Kernel; |
11 | | -import ec.tss.Ts; |
12 | | -import ec.tss.TsFactory; |
13 | | -import ec.tss.sa.SaItem; |
14 | | -import ec.tstoolkit.algorithm.CompositeResults; |
15 | | -import ec.tstoolkit.modelling.ModellingDictionary; |
16 | | -import ec.tstoolkit.timeseries.simplets.TsData; |
17 | | -import java.util.ArrayList; |
18 | | -import java.util.List; |
19 | | -import org.openide.util.lookup.ServiceProvider; |
20 | | - |
21 | | -/** |
22 | | - * |
23 | | - * @author Thomas Witthohn |
24 | | - */ |
25 | | -@ServiceProvider(service = AbstractHandler.class) |
26 | | -public class D10Handler extends AbstractHandler { |
27 | | - |
28 | | - public static final String SUFFIX = "-D10"; |
29 | | - private static final String NAME = "D10", |
30 | | - OPTION_ID = "exceladapter.d10"; |
31 | | - private static final boolean DEFAULT = true; |
32 | | - |
33 | | - @Override |
34 | | - protected List<Ts> extractData(List<SaItem> items) { |
35 | | - List<Ts> list = new ArrayList<>(); |
36 | | - |
37 | | - items.forEach((saItem) -> { |
38 | | - String name = ExcelMetaDataHelper.getItemName(saItem);; |
39 | | - CompositeResults result = saItem.process(); |
40 | | - if (result == null || result.getData(ModellingDictionary.MODE, DecompositionMode.class) == null) { |
41 | | - return; |
42 | | - } |
43 | | - boolean isMultiplicative = result.getData(ModellingDictionary.MODE, DecompositionMode.class).isMultiplicative(); |
44 | | - TsData d10 = result.getData(X11Kernel.D10, TsData.class); |
45 | | - if (d10 != null) { |
46 | | - TsData d10a = result.getData(X11Kernel.D10a, TsData.class); |
47 | | - Ts seasonalfactor = TsFactory.instance.createTs(name, null, isMultiplicative ? d10.update(d10a).times(100) : d10.update(d10a)); |
48 | | - list.add(seasonalfactor); |
49 | | - } |
50 | | - }); |
51 | | - |
52 | | - return list; |
53 | | - |
54 | | - } |
55 | | - |
56 | | - @Override |
57 | | - public String getSuffix() { |
58 | | - return SUFFIX; |
59 | | - } |
60 | | - @Override |
61 | | - public String getName() { |
62 | | - return NAME; |
63 | | - } |
64 | | - |
65 | | - @Override |
66 | | - public String getOptionID() { |
67 | | - return OPTION_ID; |
68 | | - } |
69 | | - |
70 | | - @Override |
71 | | - public boolean getDefault() { |
72 | | - return DEFAULT; |
73 | | - } |
74 | | -} |
| 1 | +/* |
| 2 | + * To change this license header, choose License Headers in Project Properties. |
| 3 | + * To change this template file, choose Tools | Templates |
| 4 | + * and open the template in the editor. |
| 5 | + */ |
| 6 | +package de.bundesbank.jdemetra.exceladapter.handler; |
| 7 | + |
| 8 | +import de.bundesbank.jdemetra.exceladapter.ExcelMetaDataHelper; |
| 9 | +import ec.satoolkit.DecompositionMode; |
| 10 | +import ec.satoolkit.x11.X11Kernel; |
| 11 | +import ec.tss.Ts; |
| 12 | +import ec.tss.TsFactory; |
| 13 | +import ec.tss.sa.SaItem; |
| 14 | +import ec.tstoolkit.algorithm.CompositeResults; |
| 15 | +import ec.tstoolkit.modelling.ModellingDictionary; |
| 16 | +import ec.tstoolkit.timeseries.simplets.TsData; |
| 17 | +import java.util.ArrayList; |
| 18 | +import java.util.List; |
| 19 | +import org.openide.util.lookup.ServiceProvider; |
| 20 | + |
| 21 | +/** |
| 22 | + * |
| 23 | + * @author Thomas Witthohn |
| 24 | + */ |
| 25 | +@ServiceProvider(service = AbstractHandler.class) |
| 26 | +public class D10Handler extends AbstractHandler { |
| 27 | + |
| 28 | + public static final String SUFFIX = "-D10"; |
| 29 | + private static final String NAME = "D10", |
| 30 | + OPTION_ID = "exceladapter.d10"; |
| 31 | + private static final boolean DEFAULT = true; |
| 32 | + |
| 33 | + @Override |
| 34 | + protected List<Ts> extractData(List<SaItem> items) { |
| 35 | + List<Ts> list = new ArrayList<>(); |
| 36 | + |
| 37 | + items.forEach((saItem) -> { |
| 38 | + String name = ExcelMetaDataHelper.getItemName(saItem); |
| 39 | + CompositeResults result = saItem.process(); |
| 40 | + if (result == null || result.getData(ModellingDictionary.MODE, DecompositionMode.class) == null) { |
| 41 | + return; |
| 42 | + } |
| 43 | + boolean isMultiplicative = result.getData(ModellingDictionary.MODE, DecompositionMode.class).isMultiplicative(); |
| 44 | + TsData d10 = result.getData(X11Kernel.D10, TsData.class); |
| 45 | + if (d10 != null) { |
| 46 | + TsData d10a = result.getData(X11Kernel.D10a, TsData.class); |
| 47 | + Ts seasonalfactor = TsFactory.instance.createTs(name, null, isMultiplicative ? d10.update(d10a).times(100) : d10.update(d10a)); |
| 48 | + list.add(seasonalfactor); |
| 49 | + } |
| 50 | + }); |
| 51 | + |
| 52 | + return list; |
| 53 | + |
| 54 | + } |
| 55 | + |
| 56 | + @Override |
| 57 | + public String getSuffix() { |
| 58 | + return SUFFIX; |
| 59 | + } |
| 60 | + |
| 61 | + @Override |
| 62 | + public String getName() { |
| 63 | + return NAME; |
| 64 | + } |
| 65 | + |
| 66 | + @Override |
| 67 | + public String getOptionID() { |
| 68 | + return OPTION_ID; |
| 69 | + } |
| 70 | + |
| 71 | + @Override |
| 72 | + public boolean getDefault() { |
| 73 | + return DEFAULT; |
| 74 | + } |
| 75 | +} |
0 commit comments