summaryrefslogtreecommitdiffstats
path: root/dcaedt_be/src/main/java/org/onap/sdc/dcae/rule/editor/translators/DateFormatterTranslator.java
blob: 89f0def5fb75580bc135ea5e511e8fdcfce98188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package org.onap.sdc.dcae.rule.editor.translators;

import org.onap.sdc.common.onaplog.Enums.LogLevel;
import java.util.List;

import org.onap.sdc.dcae.composition.restmodels.ruleeditor.DateFormatterAction;

public class DateFormatterTranslator extends CopyActionTranslator<DateFormatterAction> {

	private static DateFormatterTranslator dateFormatterTranslator = new DateFormatterTranslator();

	public static DateFormatterTranslator getInstance() {
		return dateFormatterTranslator;
	}

	private DateFormatterTranslator(){}

	private class DateFormatterTranslation extends ProcessorTranslation {
		private String fromFormat;
		private String fromTz;
		private String toField;
		private String toFormat;
		private String toTz;
		private String value;

		private DateFormatterTranslation(DateFormatterAction action){
			clazz = "DateFormatter";
			fromFormat = action.getFromFormat();
			fromTz = action.getFromTz();
			toField = action.getTarget();
			toFormat = action.getToFormat();
			toTz = action.getToTz();
			value = action.getFromValue();
		}
	}

	@Override
	public boolean addToHpJsonProcessors(DateFormatterAction action, List<Translation> processors, boolean asNewProcessor) {
		debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Translating date formatter action");
		addToHpJsonProcessors(action, processors);
		return true;
	}

	@Override
	public Translation translateToHpJson(DateFormatterAction action){
		return new DateFormatterTranslation(action);
	}

}