1717
1818import org .apache .logging .log4j .LogManager ;
1919import org .apache .logging .log4j .Logger ;
20- import org .json .JSONArray ;
2120import org .json .JSONObject ;
2221import org .labkey .api .data .ColumnInfo ;
2322import org .labkey .api .data .Container ;
2423import org .labkey .api .data .PropertyManager ;
2524import org .labkey .api .data .TableInfo ;
25+ import org .labkey .api .laboratory .query .TabbedReportFilterProvider ;
2626import org .labkey .api .query .FieldKey ;
2727import org .labkey .api .security .User ;
28- import org .labkey .api .util .PageFlowUtil ;
2928
29+ import java .util .HashMap ;
3030import java .util .Map ;
3131
3232/**
@@ -43,10 +43,11 @@ public class TabbedReportItem extends AbstractNavItem
4343
4444 protected FieldKey _subjectIdFieldKey = null ;
4545 protected FieldKey _sampleDateFieldKey = null ;
46- protected FieldKey _overlappingProjectsFieldKey = null ;
47- protected FieldKey _allProjectsFieldKey = null ;
46+ private final Map <String , FieldKey > _additionalKeys = new HashMap <>();
4847
4948 public static final String OVERRIDES_PROP_KEY = "laboratory.tabItemOverride" ;
49+ public static final String FILTER_PROP_KEY = "laboratory.tabItemFilterOverride" ;
50+
5051 protected static final Logger _log = LogManager .getLogger (TabbedReportItem .class );
5152
5253 public TabbedReportItem (DataProvider provider , String name , String label , String reportCategory )
@@ -94,24 +95,18 @@ public JSONObject toJSON(Container c, User u)
9495 if (_sampleDateFieldKey != null )
9596 json .put ("dateFieldName" , _sampleDateFieldKey );
9697
97- if (_overlappingProjectsFieldKey != null )
98- {
99- json .put ("overlappingProjectsFieldName" , _overlappingProjectsFieldKey .toString ());
100- json .put ("overlappingProjectsFieldKeyArray" , new JSONArray (_overlappingProjectsFieldKey .getParts ()));
101- }
102-
103- if (_allProjectsFieldKey != null )
104- {
105- json .put ("allProjectsFieldName" , _allProjectsFieldKey .toString ());
106- json .put ("allProjectsFieldKeyArray" , new JSONArray (_allProjectsFieldKey .getParts ()));
107- }
98+ JSONObject keys = new JSONObject ();
99+ _additionalKeys .forEach ((name , fk ) -> {
100+ keys .put (name , fk .toString ());
101+ });
102+ json .put ("additionalFieldKeys" , keys );
108103
109104 json .put ("reportType" , getReportType ());
110105
111106 return json ;
112107 }
113108
114- protected void inferColumnsFromTable (TableInfo ti )
109+ protected void inferColumnsFromTable (TableInfo ti , Container c , User u )
115110 {
116111 for (ColumnInfo ci : ti .getColumns ())
117112 {
@@ -125,17 +120,9 @@ else if (_sampleDateFieldKey == null && LaboratoryService.SAMPLEDATE_CONCEPT_URI
125120 }
126121 }
127122
128- if ( _overlappingProjectsFieldKey == null || _allProjectsFieldKey == null )
123+ for ( TabbedReportFilterProvider p : LaboratoryService . get (). getTabbedReportFilterProviderProviders ( c , u ) )
129124 {
130- FieldKey overlapKey = FieldKey .fromString ("overlappingProjectsPivot" );
131- FieldKey allKey = FieldKey .fromString ("allProjectsPivot" );
132-
133- Map <FieldKey , ColumnInfo > colMap = _queryCache .getColumns (ti , PageFlowUtil .set (overlapKey , allKey ));
134- if (_overlappingProjectsFieldKey == null && colMap .containsKey (overlapKey ))
135- _overlappingProjectsFieldKey = colMap .get (overlapKey ).getFieldKey ();
136-
137- if (_allProjectsFieldKey == null && colMap .containsKey (allKey ))
138- _allProjectsFieldKey = colMap .get (allKey ).getFieldKey ();
125+ _additionalKeys .putAll (p .getAdditionalFieldKeys (ti , this , _additionalKeys ));
139126 }
140127 }
141128
@@ -169,24 +156,9 @@ public void setSampleDateFieldKey(FieldKey sampleDateFieldKey)
169156 _sampleDateFieldKey = sampleDateFieldKey ;
170157 }
171158
172- public FieldKey getOverlappingProjectsFieldKey ()
173- {
174- return _overlappingProjectsFieldKey ;
175- }
176-
177- public void setOverlappingProjectsFieldKey (FieldKey overlappingProjectsFieldKey )
178- {
179- _overlappingProjectsFieldKey = overlappingProjectsFieldKey ;
180- }
181-
182- public FieldKey getAllProjectsFieldKey ()
183- {
184- return _allProjectsFieldKey ;
185- }
186-
187- public void setAllProjectsFieldKey (FieldKey allProjectsFieldKey )
159+ public void setKeyOverride (String name , FieldKey key )
188160 {
189- _allProjectsFieldKey = allProjectsFieldKey ;
161+ _additionalKeys . put ( name , key ) ;
190162 }
191163
192164 public void setVisible (boolean visible )
0 commit comments