DCAE-D be initial commit
[sdc/dcae-d/dt-be-main.git] / dcaedt_be / src / main / java / org / onap / sdc / dcae / rule / editor / translators / DateFormatterTranslator.java
1 package org.onap.sdc.dcae.rule.editor.translators;
2
3 import org.onap.sdc.common.onaplog.Enums.LogLevel;
4 import java.util.List;
5
6 import org.onap.sdc.dcae.composition.restmodels.ruleeditor.DateFormatterAction;
7
8 public class DateFormatterTranslator extends CopyActionTranslator<DateFormatterAction> {
9
10         private static DateFormatterTranslator dateFormatterTranslator = new DateFormatterTranslator();
11
12         public static DateFormatterTranslator getInstance() {
13                 return dateFormatterTranslator;
14         }
15
16         private DateFormatterTranslator(){}
17
18         private class DateFormatterTranslation extends ProcessorTranslation {
19                 private String fromFormat;
20                 private String fromTz;
21                 private String toField;
22                 private String toFormat;
23                 private String toTz;
24                 private String value;
25
26                 private DateFormatterTranslation(DateFormatterAction action){
27                         clazz = "DateFormatter";
28                         fromFormat = action.getFromFormat();
29                         fromTz = action.getFromTz();
30                         toField = action.getTarget();
31                         toFormat = action.getToFormat();
32                         toTz = action.getToTz();
33                         value = action.getFromValue();
34                 }
35         }
36
37         @Override
38         public boolean addToHpJsonProcessors(DateFormatterAction action, List<Translation> processors, boolean asNewProcessor) {
39                 debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Translating date formatter action");
40                 addToHpJsonProcessors(action, processors);
41                 return true;
42         }
43
44         @Override
45         public Translation translateToHpJson(DateFormatterAction action){
46                 return new DateFormatterTranslation(action);
47         }
48
49 }