/
Report.java
executable file
·713 lines (594 loc) · 24.2 KB
/
Report.java
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
package net.datenwerke.rs.core.service.reportmanager.entities.reports;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.function.Function;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.Type;
import org.hibernate.envers.Audited;
import com.google.common.base.MoreObjects;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Provider;
import net.datenwerke.dtoservices.dtogenerator.annotations.AdditionalField;
import net.datenwerke.dtoservices.dtogenerator.annotations.ExposeToClient;
import net.datenwerke.dtoservices.dtogenerator.annotations.GenerateDto;
import net.datenwerke.dtoservices.dtogenerator.annotations.PropertyValidator;
import net.datenwerke.dtoservices.dtogenerator.annotations.StringValidator;
import net.datenwerke.gf.base.service.annotations.Field;
import net.datenwerke.gxtdto.client.dtomanager.DtoView;
import net.datenwerke.hookhandler.shared.hookhandler.HookHandlerService;
import net.datenwerke.rs.core.client.datasourcemanager.dto.DatasourceContainerProviderDto;
import net.datenwerke.rs.core.client.reportmanager.dto.reports.ReportPropertyDto;
import net.datenwerke.rs.core.client.reportmanager.locale.ReportmanagerMessages;
import net.datenwerke.rs.core.service.datasourcemanager.DatasourceService;
import net.datenwerke.rs.core.service.datasourcemanager.entities.DatasourceContainer;
import net.datenwerke.rs.core.service.datasourcemanager.entities.DatasourceContainerProvider;
import net.datenwerke.rs.core.service.datasourcemanager.entities.DatasourceDefinitionConfig;
import net.datenwerke.rs.core.service.parameters.entities.ParameterDefinition;
import net.datenwerke.rs.core.service.parameters.entities.ParameterInstance;
import net.datenwerke.rs.core.service.reportmanager.ReportService;
import net.datenwerke.rs.core.service.reportmanager.entities.AbstractReportManagerNode;
import net.datenwerke.rs.core.service.reportmanager.entities.reports.post.Dto2ReportPostProcessor;
import net.datenwerke.rs.core.service.reportmanager.entities.reports.post.Report2DtoPostProcessor;
import net.datenwerke.rs.core.service.reportmanager.entities.reports.supervisor.Dto2ReportSupervisor;
import net.datenwerke.rs.core.service.reportmanager.hooks.VariantCreatorHook;
import net.datenwerke.rs.core.service.reportmanager.interfaces.ReportVariant;
import net.datenwerke.rs.core.service.reportmanager.parameters.ParameterContainerNode;
import net.datenwerke.rs.keyutils.service.keyutils.KeyNameGeneratorService;
import net.datenwerke.rs.utils.entitycloner.EntityClonerService;
import net.datenwerke.rs.utils.entitycloner.annotation.EnclosedEntity;
import net.datenwerke.rs.utils.entitycloner.annotation.EntityClonerIgnore;
import net.datenwerke.rs.utils.entitydiff.EntityDiffService;
import net.datenwerke.rs.utils.entitydiff.annotations.EntityDiffGuide;
import net.datenwerke.rs.utils.entitydiff.annotations.EntityDiffGuides;
import net.datenwerke.rs.utils.entitymerge.service.annotations.EntityMergeCollection;
import net.datenwerke.rs.utils.entitymerge.service.annotations.EntityMergeField;
import net.datenwerke.rs.utils.instancedescription.annotations.Description;
import net.datenwerke.rs.utils.instancedescription.annotations.Title;
import net.datenwerke.rs.utils.validator.shared.SharedRegex;
import net.datenwerke.treedb.service.treedb.AbstractNode;
/**
*
*
*/
@Entity
@Table(name = "REPORT")
@Audited
@Inheritance(strategy = InheritanceType.JOINED)
@GenerateDto(
dtoPackage = "net.datenwerke.rs.core.client.reportmanager.dto.reports",
createDecorator = true,
dtoImplementInterfaces = DatasourceContainerProviderDto.class,
poso2DtoPostProcessors = Report2DtoPostProcessor.class,
dto2PosoSupervisor = Dto2ReportSupervisor.class,
dto2PosoPostProcessors = Dto2ReportPostProcessor.class,
typeDescriptionMsg = ReportmanagerMessages.class,
typeDescriptionKey = "reportLabel",
additionalFields = {
@AdditionalField(
name = "temporaryUid",
type = String.class
),
@AdditionalField(
name = "parentReportKey",
type = String.class
),
@AdditionalField(
name = "parentReportName",
type = String.class
),
@AdditionalField(
name = "parentReportDescription",
type = String.class
),
@AdditionalField(
name = "parentReportProperties",
type = HashSet.class,
generics = ReportPropertyDto.class
)
}
)
@EntityDiffGuides(
guides = {
@EntityDiffGuide(
name = Report.ENTITY_DIFF_IDENTITCAL_FOR_EXECUTION,
ignoreId = true,
ignoreVersion = true,
whitelist = {
"parameterDefinitions", "parameterInstances", "datasourceContainer"
}
)
}
)
abstract public class Report extends AbstractReportManagerNode
implements ParameterContainerNode, DatasourceContainerProvider {
public static final String ENTITY_DIFF_IDENTITCAL_FOR_EXECUTION = "report_identicalForExecution";
/**
*
*/
private static final long serialVersionUID = 3350868658886100690L;
@Inject
protected static Provider<EntityClonerService> entityCloner;
@Inject
protected static Provider<EntityDiffService> entityDiffService;
@Inject
protected static Provider<HookHandlerService> hookHandlerServiceProvider;
@Inject
protected static Provider<KeyNameGeneratorService> keyGeneratorServiceProvider;
@JoinTable(name = "REPORT_2_METADATA")
@ExposeToClient(mergeDtoValueBack = false)
@EnclosedEntity
@OneToMany(cascade = CascadeType.ALL)
@EntityMergeCollection(defaultMerge = false)
private Set<ReportMetadata> reportMetadata = new HashSet<ReportMetadata>();
@JoinTable(name = "REPORT_2_PROPERTY")
@ExposeToClient(mergeDtoValueBack = false)
@EnclosedEntity
@OneToMany(cascade = CascadeType.ALL)
@EntityMergeCollection(defaultMerge = false)
private Set<ReportProperty> reportProperties = new HashSet<ReportProperty>();
@ExposeToClient(displayTitle = true, view = DtoView.LIST)
@Field
@Column(length = 128)
@Title
@EntityMergeField
private String name;
@ExposeToClient(view = DtoView.MINIMAL)
@Lob
@Type(type = "net.datenwerke.rs.utils.hibernate.RsClobType")
@Field
@Description
@EntityMergeField
private String description;
@ExposeToClient(
view = DtoView.LIST,
validateDtoProperty = @PropertyValidator(
string = @StringValidator(
regex = SharedRegex.KEY_REGEX
)
)
)
@Field
@Column(
length = KeyNameGeneratorService.KEY_LENGTH,
unique = true,
nullable = false
)
private String key;
@ExposeToClient
@EnclosedEntity
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true)
@EntityMergeField(toClone = true)
private DatasourceContainer datasourceContainer = new DatasourceContainer();
@JoinTable(name = "REPORT_2_PARAM_DEF")
@ExposeToClient
@OneToMany(cascade = { CascadeType.ALL }, orphanRemoval = true)
@OrderBy("n")
@EnclosedEntity
@EntityMergeCollection(defaultMerge = false)
private List<ParameterDefinition> parameterDefinitions = new ArrayList<>();
@JoinTable(name = "REPORT_2_PARAM_INST")
@ExposeToClient
@EnclosedEntity
@OneToMany(cascade = { CascadeType.ALL }, orphanRemoval = true)
@EntityMergeCollection(defaultMerge = false)
private Set<ParameterInstance> parameterInstances = new HashSet<>();
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@EntityMergeField(defaultMerge = false)
private PreviewImage previewImage;
/**
* Wherever it is used it will soon be replaced with the
* key attribute as a unique identifier
*/
@ExposeToClient(view = DtoView.LIST, mergeDtoValueBack = false)
@Column(unique = true)
@EntityClonerIgnore
@Deprecated
private String uuid = UUID.randomUUID().toString();
@Transient
/**
* When creating a new temporary variant, the report's class is lost. We cannot
* identify if it belonged to a variant or to a (base) report. This field allows
* us to fetch the original report's class.
*/
private Class<?> temporaryVariantType;
/**
* Returns the Report's type (the classes simple name).
*/
public String getType() {
return getClass().getSimpleName();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getKey() {
return key;
}
public void setKey(String key) {
if (null != key && "".equals(key.trim()))
key = null;
this.key = key;
}
public void setReportMetadata(Set<ReportMetadata> reportMetadata) {
this.reportMetadata = reportMetadata;
}
public Set<ReportMetadata> getReportMetadata() {
return reportMetadata;
}
public void addReportMetadata(ReportMetadata metadata) {
this.reportMetadata.add(metadata);
}
public boolean hasReportMetadata(ReportMetadata metadata) {
return this.reportMetadata.contains(metadata);
}
public ReportMetadata getReportMetadataByName(String key) {
if (null == reportMetadata || null == key)
return null;
for (ReportMetadata rm : reportMetadata)
if (key.equals(rm.getName()))
return rm;
return null;
}
/**
* Do not call this method directly (use ReportService instead)
*
* @param metadata
* @see ReportService#remove(Report, ReportMetadata)
*/
public void removeReportMetadata(ReportMetadata metadata) {
this.reportMetadata.remove(metadata);
}
public Set<ReportProperty> getReportProperties() {
return reportProperties;
}
public void setReportProperties(Set<ReportProperty> complexProperties) {
this.reportProperties = complexProperties;
}
public void addReportProperty(ReportProperty property) {
this.reportProperties.add(property);
}
public boolean hasReportProperty(ReportProperty property) {
return this.reportProperties.contains(property);
}
/**
* Returns the report property effective for the current report. I.e., If the
* report is a variant, if returns the variant's property if found. If not
* found, it returns the parent's property if found. If the report is not a
* variant, returns the report's property if found.
*
* @param name the name of the property
* @return the report property applicable for the report
*/
public ReportProperty getEffectiveReportProperty(String name) {
ReportProperty property = getReportProperty(name);
if (null == property && this instanceof ReportVariant)
property = ((Report) getParent()).getReportProperty(name);
return property;
}
public Object getEffectiveReportStringPropertyValue(String name, Object defaultValue,
Function<ReportStringProperty, Object> f) {
ReportProperty property = getEffectiveReportProperty(name);
if (!(property instanceof ReportStringProperty))
return defaultValue;
return f.apply((ReportStringProperty) property);
}
/**
* Do not call this method directly (use ReportService instead)
*
* @param property
* @see ReportService#remove(Report, ReportProperty)
*/
public void removeReportProperty(ReportProperty property) {
this.reportProperties.remove(property);
}
public DatasourceContainer getDatasourceContainer() {
return datasourceContainer;
}
public void setDatasourceContainer(DatasourceContainer datasourceContainer) {
this.datasourceContainer = datasourceContainer;
}
public List<ParameterDefinition> getParameterDefinitions() {
return parameterDefinitions;
}
/**
* {@link #getParameterDefinitions()} may fail when in an unmanaged report
*
*/
public Set<ParameterDefinition> getParameterDefinitionsSafe() {
Set<ParameterDefinition> defs = new HashSet<ParameterDefinition>();
for (ParameterInstance instance : getParameterInstances())
defs.add(instance.getDefinition());
return defs;
}
public void setParameterDefinitions(List<ParameterDefinition> parameters) {
if (null == parameters)
parameters = new ArrayList<ParameterDefinition>();
this.parameterDefinitions.clear();
this.parameterDefinitions.addAll(parameters);
/* update position */
int i = 0;
for (ParameterDefinition pd : parameterDefinitions)
pd.setN(i++);
}
/**
* Do not call directly
*/
public void addParameterDefinition(ParameterDefinition definition) {
/* add parameter */
this.parameterDefinitions.add(definition);
definition.setN(parameterDefinitions.size() - 1);
}
public void removeParameterDefinition(ParameterDefinition paramter) {
this.parameterDefinitions.remove(paramter);
int i = 0;
for (ParameterDefinition pd : parameterDefinitions)
pd.setN(i++);
}
public Set<ParameterInstance> getParameterInstances() {
return parameterInstances;
}
public void setParameterInstances(Set<ParameterInstance> parameterInstances) {
if (null == parameterInstances)
parameterInstances = new HashSet<ParameterInstance>();
this.parameterInstances.clear();
this.parameterInstances.addAll(parameterInstances);
}
public void addParameterInstance(ParameterInstance instance) {
this.parameterInstances.add(instance);
}
public PreviewImage getPreviewImage() {
return previewImage;
}
public void setPreviewImage(PreviewImage previewImage) {
this.previewImage = previewImage;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
/**
* Creates a new variant of this report (or variant) with the changes given by
* adjustedReport.
*
* <p>
* This method should only be called if you mean to store the variant as it is
* added to the parent's list of children
* </p>
*
* @param adjustedReport
* @see Report#createTemporaryVariant(Report)
*/
public Report createNewVariant(Report adjustedReport) {
Report variant = createTemporaryVariant(adjustedReport);
/* set parent to either this (base report) or to my parent */
if (this instanceof ReportVariant)
getParent().addChild(variant);
else
addChild(variant);
for (VariantCreatorHook hooker : hookHandlerServiceProvider.get().getHookers(VariantCreatorHook.class))
hooker.newVariantCreated(this, adjustedReport, variant);
return variant;
}
public Report createTemporaryVariant() {
return createTemporaryVariant(this);
}
/**
* Do not try to convert a temporary variant into a persistent one (rather
* create a new one).
*
* @param adjustedReport the unmanaged report.
* @see Report#createNewVariant(Report)
*/
public Report createTemporaryVariant(Report adjustedReport) {
Report variant = createVariant(adjustedReport);
/* set parent to either this (base report) or to my parent */
variant.setParent(this instanceof ReportVariant ? getParent() : this);
/* original type */
variant.setTemporaryVariantType(adjustedReport.getClass());
if (null != adjustedReport.getId())
variant.setOldTransientId(adjustedReport.getId());
else if (null != adjustedReport.getOldTransientId())
variant.setOldTransientId(adjustedReport.getOldTransientId());
if (null != adjustedReport.getKey())
variant.setOldTransientKey(adjustedReport.getKey());
else if (null != adjustedReport.getOldTransientKey())
variant.setOldTransientKey(adjustedReport.getOldTransientKey());
for (VariantCreatorHook hooker : hookHandlerServiceProvider.get().getHookers(VariantCreatorHook.class))
hooker.temporaryVariantCreated(this, adjustedReport, variant);
return variant;
}
abstract protected Report createVariant(Report adjustedReport);
protected void initVariant(ReportVariant variant, Report adjustedReport) {
if (!(variant instanceof Report))
throw new IllegalArgumentException("Variant is not a report"); //$NON-NLS-1$
/* base properties */
((Report) variant).setName(adjustedReport.getName());
((Report) variant).setDescription(adjustedReport.getDescription());
((Report) variant).setKey(keyGeneratorServiceProvider.get().generateDefaultKey());
/* handle parameters */
Set<ParameterInstance> clonedParameterInstances = new HashSet<ParameterInstance>();
for (ParameterDefinition definition : getParameterDefinitions()) {
ParameterInstance instance = adjustedReport.getParameterInstanceFor(definition);
if (definition.isEditable() && null != instance && !instance.isStillDefault()) {
ParameterInstance clonedInstance = instance.cloneInstanceForReportVariant();
clonedInstance.setDefinition(definition);
clonedParameterInstances.add(clonedInstance);
} else {
clonedParameterInstances.add(definition.createParameterInstance());
}
}
((Report) variant).setParameterInstances(clonedParameterInstances);
/* handle report metadata */
Set<ReportMetadata> metadataSet = new HashSet<ReportMetadata>();
for (ReportMetadata metadata : adjustedReport.getReportMetadata())
metadataSet.add(entityCloner.get().cloneEntity(metadata));
((Report) variant).setReportMetadata(metadataSet);
/* handle properties */
Set<ReportProperty> propertiesSet = new HashSet<ReportProperty>();
for (ReportProperty property : adjustedReport.getReportProperties())
propertiesSet.add(entityCloner.get().cloneEntity(property));
((Report) variant).setReportProperties(propertiesSet);
/* Flags */
if (variant instanceof AbstractNode && adjustedReport instanceof AbstractNode) {
((AbstractNode) variant).setWriteProtection(((AbstractNode) adjustedReport).isWriteProtected());
((AbstractNode) variant)
.setConfigurationProtection(((AbstractNode) adjustedReport).isConfigurationProtected());
}
}
public void replaceWith(Report report, Injector injector) {
ReportService reportService = injector.getInstance(ReportService.class);
DatasourceService datasourceService = injector.getInstance(DatasourceService.class);
setName(report.getName());
setDescription(report.getDescription());
/* parameters */
reportService.updateParameterDefinitions(this, report.getParameterDefinitions(), true);
/* remove metadata */
Set<ReportMetadata> metadataSet = new HashSet<ReportMetadata>(getReportMetadata());
Iterator<ReportMetadata> metaIt = metadataSet.iterator();
while (metaIt.hasNext())
reportService.remove(this, metaIt.next());
/* remove properties */
Set<ReportProperty> propertiesSet = new HashSet<ReportProperty>(getReportProperties());
Iterator<ReportProperty> it = propertiesSet.iterator();
while (it.hasNext())
reportService.remove(this, it.next());
/* set metadata */
for (ReportMetadata rm : report.getReportMetadata())
addReportMetadata(rm);
/* set proeprties */
for (ReportProperty prop : report.getReportProperties())
addReportProperty(prop);
/* datasource */
if (null != datasourceContainer) {
DatasourceDefinitionConfig oldConfig = datasourceContainer.getDatasourceConfig();
datasourceService.remove(oldConfig);
} else
datasourceContainer = new DatasourceContainer();
if (null != report.getDatasourceContainer()) {
datasourceContainer.setDatasource(report.getDatasourceContainer().getDatasource());
datasourceContainer.setDatasourceConfig(report.getDatasourceContainer().getDatasourceConfig());
}
}
public ParameterInstance<?> getParamInstanceByDefinitionId(Long id) {
if (null == id)
return null;
for (ParameterInstance<?> instance : getParameterInstances())
if (id.equals(instance.getDefinition().getId()) || id.equals(instance.getDefinition().getOldTransientId()))
return instance;
return null;
}
@Transient
public ParameterInstance getParameterInstanceFor(ParameterDefinition definition) {
Set<ParameterInstance> instances = getParameterInstances();
if (null == instances)
return null;
Long idA = definition.getId();
if (null == idA)
idA = definition.getOldTransientId();
for (ParameterInstance instance : instances) {
if (null == instance.getDefinition())
throw new IllegalStateException("Instances should always have a definition"); //$NON-NLS-1$
ParameterDefinition toCompare = instance.getDefinition();
/* check ids */
Long idB = toCompare.getId();
if (null == idB)
idB = toCompare.getOldTransientId();
if (null != idA && null != idB && idA.equals(idB))
return instance;
if (toCompare.equals(definition))
return instance;
}
return null;
}
public void removeParameterInstance(ParameterInstance instance) {
parameterInstances.remove(instance);
}
@Transient
public ParameterDefinition getParameterDefinitionByKey(String name) {
for (ParameterDefinition def : getParameterDefinitionsSafe())
if (name.equals(def.getKey()))
return def;
return null;
}
public <T extends ParameterDefinition<?>> List<T> getParameterDefinitionsOfType(Class<T> type) {
List<T> definitions = new ArrayList<T>();
for (ParameterDefinition def : getParameterDefinitionsSafe())
if (type.isAssignableFrom(def.getClass()))
definitions.add((T) def);
return definitions;
}
public boolean usesParameter(String key) {
return true;
}
public boolean isIdenticalForExecution(Report report) {
if (null == report)
return false;
return entityDiffService.get().isEqual(this, report, ENTITY_DIFF_IDENTITCAL_FOR_EXECUTION);
}
@Deprecated
public void setUuid(String uuid) {
this.uuid = uuid;
}
@Deprecated
public String getUuid() {
return uuid;
}
public ReportProperty getReportPropertyByName(String name) {
return getReportProperty(name);
}
public ReportProperty getReportProperty(String name) {
if (null == name)
return null;
for (ReportProperty property : reportProperties)
if (name.equals(property.getName()))
return property;
return null;
}
public String getReportProperty(String propertyName, String defaultValue) {
ReportProperty prop = getReportPropertyByName(propertyName);
if (null != prop && prop instanceof ReportStringProperty)
return ((ReportStringProperty) prop).getStrValue();
if (this instanceof ReportVariant) {
prop = ((ReportVariant) this).getBaseReport().getReportPropertyByName(propertyName);
if (null != prop && prop instanceof ReportStringProperty)
return ((ReportStringProperty) prop).getStrValue();
}
return defaultValue;
}
public Class<?> getTemporaryVariantType() {
return temporaryVariantType;
}
public void setTemporaryVariantType(Class<?> temporaryVariantType) {
this.temporaryVariantType = temporaryVariantType;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("ID", getIdOrOldTransient())
.add("Key", key)
.add("Name", name)
.add("Variant", this instanceof ReportVariant)
.toString();
}
}