4040@ Getter
4141@ Setter
4242public class ReportControlBlock extends ControlBlock {
43+ public static final long RPT_ENABLED_MAX_DEFAULT = 4L ;
44+
4345 //TODO this is a DTO object; it's meant to be used for carry information; he must be created be the one responsible for carying the info
44- private TReportControl .OptFields optFields = newDefaultOptFields () ;
45- protected TTrgOps trgOps = newDefaultTrgOps () ;
46- protected long intgPd = 60000L ;
47- private Long rptEnabledMax = 1L ;
46+ private TReportControl .OptFields optFields ;
47+ protected TTrgOps trgOps ;
48+ protected long intgPd ;
49+ private Long rptEnabledMax ;
4850 private String rptEnabledDesc ;
49- private boolean buffered = true ;
50- private long bufTime = 0 ;
51- private boolean indexed = true ;
51+ private boolean buffered ;
52+ private long bufTime ;
53+ private boolean indexed ;
5254
5355 /**
56+ * Constructor.
5457 * Create ReportControlBlock with default values
5558 *
5659 * @param name name of the ReportControlBlock
5760 * @param id rptId of the ReportControlBlock
5861 * @param dataSetRef datSet of the ReportControlBlock
5962 */
6063 public ReportControlBlock (String name , String id , String dataSetRef ) {
61- confRev = 1L ;
6264 this .name = name ;
6365 this .dataSetRef = dataSetRef ;
6466 this .id = id ;
67+
68+ // Default value
69+ this .confRev = 1L ;
70+ this .optFields = newDefaultOptFields ();
71+ this .trgOps = newDefaultTrgOps ();
72+ this .intgPd = 60000L ;
73+ this .rptEnabledMax = RPT_ENABLED_MAX_DEFAULT ;
74+ this .buffered = true ;
75+ this .bufTime = 0 ;
76+ this .indexed = true ;
77+ }
78+
79+ /**
80+ * Constructor.
81+ * Create ReportControlBlock from TReportControl
82+ *
83+ * @param reportControl input
84+ */
85+ public ReportControlBlock (TReportControl reportControl ) {
86+ super ();
87+ id = reportControl .getRptID ();
88+ desc = reportControl .getDesc ();
89+ name = reportControl .getName ();
90+ if (reportControl .isSetConfRev ()) {
91+ confRev = reportControl .getConfRev ();
92+ }
93+ dataSetRef = reportControl .getDatSet ();
94+ indexed = reportControl .isIndexed ();
95+ intgPd = reportControl .getIntgPd ();
96+ buffered = reportControl .isBuffered ();
97+ bufTime = reportControl .getBufTime ();
98+ optFields = copyOptFields (reportControl .getOptFields ());
99+ trgOps = copyTTrgOps (reportControl .getTrgOps ());
100+ if (reportControl .isSetRptEnabled ()) {
101+ rptEnabledMax = reportControl .getRptEnabled ().getMax ();
102+ rptEnabledDesc = reportControl .getRptEnabled ().getDesc ();
103+ targets = reportControl .getRptEnabled ().getClientLN ().stream ().map (ControlBlockTarget ::from ).collect (Collectors .toCollection (ArrayList ::new ));
104+ }
65105 }
66106
67107 /**
68108 * Create a new TTrgOps with default values
109+ *
69110 * @return new instance of TTrgOps
70111 */
71112 private static TTrgOps newDefaultTrgOps () {
@@ -80,6 +121,7 @@ private static TTrgOps newDefaultTrgOps() {
80121
81122 /**
82123 * Create a new TReportControl.OptFields with default values
124+ *
83125 * @return new instance of TReportControl.OptFields
84126 */
85127 private static TReportControl .OptFields newDefaultOptFields () {
@@ -95,32 +137,6 @@ private static TReportControl.OptFields newDefaultOptFields() {
95137 return newDefaultOptFields ;
96138 }
97139
98- /**
99- * Constructor
100- * @param reportControl input
101- */
102- public ReportControlBlock (TReportControl reportControl ) {
103- super ();
104- id = reportControl .getRptID ();
105- desc = reportControl .getDesc ();
106- name = reportControl .getName ();
107- if (reportControl .isSetConfRev ()) {
108- confRev = reportControl .getConfRev ();
109- }
110- dataSetRef = reportControl .getDatSet ();
111- indexed = reportControl .isIndexed ();
112- intgPd = reportControl .getIntgPd ();
113- buffered = reportControl .isBuffered ();
114- bufTime = reportControl .getBufTime ();
115- optFields = copyOptFields (reportControl .getOptFields ());
116- trgOps = copyTTrgOps (reportControl .getTrgOps ());
117- if (reportControl .isSetRptEnabled ()){
118- rptEnabledMax = reportControl .getRptEnabled ().getMax ();
119- rptEnabledDesc = reportControl .getRptEnabled ().getDesc ();
120- targets = reportControl .getRptEnabled ().getClientLN ().stream ().map (ControlBlockTarget ::from ).collect (Collectors .toCollection (ArrayList ::new ));
121- }
122- }
123-
124140 @ Override
125141 public ControlBlockEnum getControlBlockEnum () {
126142 return ControlBlockEnum .REPORT ;
@@ -129,6 +145,7 @@ public ControlBlockEnum getControlBlockEnum() {
129145 /**
130146 * Implementation is required by superclass but ReportControl blocks has no SecurityEnabled attributes.
131147 * This implementation does nothing.
148+ *
132149 * @param tServices Service object
133150 * @throws ScdException never (this is just to comply with superclass)
134151 */
@@ -139,6 +156,7 @@ protected void validateSecurityEnabledValue(TServices tServices) throws ScdExcep
139156
140157 /**
141158 * Creates Report Control Block
159+ *
142160 * @return TReportControl object
143161 */
144162 @ Override
@@ -168,13 +186,14 @@ public TReportControl toTControl() {
168186
169187 /**
170188 * Validates Report Control Block
189+ *
171190 * @throws ScdException when required fields are missing
172191 */
173192 @ Override
174193 public void validateCB () throws ScdException {
175194 super .validateCB ();
176195
177- if (dataSetRef != null && dataSetRef .isBlank ()){
196+ if (dataSetRef != null && dataSetRef .isBlank ()) {
178197 throw new ScdException ("A required field is missing: datSet" );
179198 }
180199 }
@@ -187,7 +206,7 @@ public TReportControl addToLN(TAnyLN tAnyLN) {
187206 }
188207
189208 private static TReportControl .OptFields copyOptFields (TReportControl .OptFields optFields ) {
190- if (optFields == null ){
209+ if (optFields == null ) {
191210 return null ;
192211 }
193212 TReportControl .OptFields newOptFields = new TReportControl .OptFields ();
@@ -203,7 +222,7 @@ private static TReportControl.OptFields copyOptFields(TReportControl.OptFields o
203222 }
204223
205224 private static TTrgOps copyTTrgOps (TTrgOps tTrgOps ) {
206- if (tTrgOps == null ){
225+ if (tTrgOps == null ) {
207226 return null ;
208227 }
209228 TTrgOps newTTrgOps = new TTrgOps ();
0 commit comments