1+ package org .roda .wui .client .browse .tabs ;
2+
3+ import com .google .gwt .core .client .GWT ;
4+ import com .google .gwt .i18n .client .DateTimeFormat ;
5+ import com .google .gwt .safehtml .shared .SafeHtmlUtils ;
6+ import com .google .gwt .user .client .ui .Widget ;
7+ import config .i18n .client .ClientMessages ;
8+ import org .roda .core .data .common .RodaConstants ;
9+ import org .roda .core .data .v2 .disposal .schedule .DisposalActionCode ;
10+ import org .roda .core .data .v2 .disposal .schedule .RetentionPeriodCalculation ;
11+ import org .roda .core .data .v2 .index .filter .DateIntervalFilterParameter ;
12+ import org .roda .core .data .v2 .index .filter .EmptyKeyFilterParameter ;
13+ import org .roda .core .data .v2 .index .filter .Filter ;
14+ import org .roda .core .data .v2 .index .filter .SimpleFilterParameter ;
15+ import org .roda .core .data .v2 .ip .AIPState ;
16+ import org .roda .core .data .v2 .ip .IndexedAIP ;
17+ import org .roda .wui .client .common .actions .DisposalCreateConfirmationDestroyActions ;
18+ import org .roda .wui .client .common .actions .DisposalCreateConfirmationReviewActions ;
19+ import org .roda .wui .client .common .lists .utils .AsyncTableCellOptions ;
20+ import org .roda .wui .client .common .lists .utils .ConfigurableAsyncTableCell ;
21+ import org .roda .wui .client .common .lists .utils .ListBuilder ;
22+ import org .roda .wui .client .common .search .SearchWrapper ;
23+
24+ import java .util .Date ;
25+
26+ public class DisposalOverdueRecordsTabs extends Tabs {
27+
28+ private static final DateTimeFormat formatter = DateTimeFormat .getFormat (RodaConstants .SIMPLE_DATE_FORMATTER );
29+
30+ private static final Filter SHOW_RECORDS_TO_REVIEW = new Filter (
31+ new SimpleFilterParameter (RodaConstants .AIP_DISPOSAL_ACTION , DisposalActionCode .REVIEW .name ()),
32+ new SimpleFilterParameter (RodaConstants .AIP_STATE , AIPState .ACTIVE .name ()),
33+ new DateIntervalFilterParameter (RodaConstants .AIP_OVERDUE_DATE , RodaConstants .AIP_OVERDUE_DATE , null ,
34+ formatter .parse (formatter .format (new Date ()))),
35+ new SimpleFilterParameter (RodaConstants .AIP_DISPOSAL_HOLD_STATUS , Boolean .FALSE .toString ()),
36+ new EmptyKeyFilterParameter (RodaConstants .AIP_DISPOSAL_CONFIRMATION_ID ));
37+
38+ private static final Filter SHOW_RECORDS_TO_DESTROY = new Filter (
39+ new SimpleFilterParameter (RodaConstants .AIP_DISPOSAL_ACTION , DisposalActionCode .DESTROY .name ()),
40+ new SimpleFilterParameter (RodaConstants .AIP_STATE , AIPState .ACTIVE .name ()),
41+ new DateIntervalFilterParameter (RodaConstants .AIP_OVERDUE_DATE , RodaConstants .AIP_OVERDUE_DATE , null ,
42+ formatter .parse (formatter .format (new Date ()))),
43+ new SimpleFilterParameter (RodaConstants .AIP_DISPOSAL_HOLD_STATUS , Boolean .FALSE .toString ()),
44+ new EmptyKeyFilterParameter (RodaConstants .AIP_DISPOSAL_CONFIRMATION_ID ));
45+
46+ private static final Filter SHOW_RECORDS_WITH_RETENTION_PERIOD_ERRORS = new Filter (new SimpleFilterParameter (
47+ RodaConstants .AIP_DISPOSAL_RETENTION_PERIOD_CALCULATION , RetentionPeriodCalculation .ERROR .name ()));
48+
49+ private static final ClientMessages messages = GWT .create (ClientMessages .class );
50+
51+ public void init () {
52+
53+ ListBuilder <IndexedAIP > overdueRecordsListBuilder = new ListBuilder <>(() -> new ConfigurableAsyncTableCell <>(),
54+ new AsyncTableCellOptions <>(IndexedAIP .class , "DisposalOverdueRecords_aip" ).withSummary (messages .listOfAIPs ())
55+ .withFilter (SHOW_RECORDS_TO_DESTROY ).withActionable (DisposalCreateConfirmationDestroyActions .get ())
56+ .withJustActive (true ).bindOpener ());
57+
58+ createAndAddTab (SafeHtmlUtils .fromSafeConstant (messages .disposalConfirmationShowRecordsToDestroy ()),
59+ new TabContentBuilder () {
60+ @ Override
61+ public Widget buildTabWidget () {
62+ return new SearchWrapper (false ).createListAndSearchPanel (overdueRecordsListBuilder );
63+ }
64+ });
65+
66+ ListBuilder <IndexedAIP > overdueRecordsToReviewListBuilder = new ListBuilder <>(
67+ () -> new ConfigurableAsyncTableCell <>(),
68+ new AsyncTableCellOptions <>(IndexedAIP .class , "DisposalOverdueRecords_aip" ).withSummary (messages .listOfAIPs ())
69+ .withFilter (SHOW_RECORDS_TO_REVIEW ).withActionable (DisposalCreateConfirmationReviewActions .get ())
70+ .withJustActive (true ).bindOpener ());
71+
72+ createAndAddTab (SafeHtmlUtils .fromSafeConstant (messages .disposalConfirmationShowRecordsToReview ()),
73+ new TabContentBuilder () {
74+ @ Override
75+ public Widget buildTabWidget () {
76+ return new SearchWrapper (false ).createListAndSearchPanel (overdueRecordsToReviewListBuilder );
77+ }
78+ });
79+
80+ ListBuilder <IndexedAIP > recordsWithErrorListBuilder = new ListBuilder <>(() -> new ConfigurableAsyncTableCell <>(),
81+ new AsyncTableCellOptions <>(IndexedAIP .class , "DisposalOverdueRecords_aip" ).withSummary (messages .listOfAIPs ())
82+ .withFilter (SHOW_RECORDS_WITH_RETENTION_PERIOD_ERRORS ).withJustActive (true ).bindOpener ());
83+
84+ createAndAddTab (SafeHtmlUtils .fromSafeConstant (messages .disposalConfirmationShowRecordsRetentionPeriodCalculationError ()), new TabContentBuilder () {
85+ @ Override
86+ public Widget buildTabWidget () {
87+ return new SearchWrapper (false ).createListAndSearchPanel (recordsWithErrorListBuilder );
88+ }
89+ });
90+
91+ }
92+ }
0 commit comments