66import java .time .format .DateTimeFormatter ;
77import java .util .ArrayList ;
88import java .util .Arrays ;
9+ import java .util .Iterator ;
10+ import java .util .LinkedList ;
911import java .util .List ;
1012import java .util .function .Function ;
1113import java .util .stream .Collectors ;
1214
1315import javax .annotation .PostConstruct ;
1416
1517import od .exception .MethodNotImplementedException ;
18+ import od .framework .model .EventAlias ;
1619import od .framework .model .Tenant ;
1720import od .providers .ProviderData ;
1821import od .providers .ProviderException ;
1922import od .providers .matthews .MatthewsClient ;
2023import od .providers .matthews .MatthewsProvider ;
24+ import od .repository .mongo .MongoEventAliasRepository ;
2125import od .repository .mongo .MongoTenantRepository ;
2226
2327import org .apereo .lai .Event ;
2428import org .apereo .lai .impl .EventImpl ;
2529import org .apereo .openlrs .model .event .v2 .ClassEventStatistics ;
30+
2631import org .slf4j .Logger ;
2732import org .slf4j .LoggerFactory ;
2833import org .springframework .beans .factory .annotation .Autowired ;
@@ -52,6 +57,7 @@ public class MatthewsEventProvider extends MatthewsProvider implements EventProv
5257 private static final String NAME = String .format ("%s_NAME" , BASE );
5358 private static final String DESC = String .format ("%s_DESC" , BASE );
5459 @ Autowired private MongoTenantRepository mongoTenantRepository ;
60+ @ Autowired private MongoEventAliasRepository mongoEventAliasRepository ;
5561
5662 @ PostConstruct
5763 public void init () {
@@ -137,6 +143,8 @@ public Page<Event> getEventsForCourseAndUser(String tenantId, String courseId, S
137143
138144 unicon .matthews .caliper .Event [] events = response .getBody ();
139145
146+ List <EventAlias > eventAliases = mongoEventAliasRepository .findByTenantId (tenantId );
147+
140148 Function <unicon .matthews .caliper .Event , Event > myFunction = new Function <unicon .matthews .caliper .Event , Event >() {
141149 public Event apply (unicon .matthews .caliper .Event t ) {
142150 EventImpl event = new EventImpl ();
@@ -168,6 +176,12 @@ public Event apply(unicon.matthews.caliper.Event t) {
168176 timestamp = t .getEventTime ().format (dtf );
169177
170178 verb = t .getAction ();
179+ for (EventAlias eventAlias : eventAliases ) {
180+ if (eventAlias .getVerb ().equals (verb ) && eventAlias .isDisplay ()) {
181+ verb = verb .substring (0 , verb .lastIndexOf ("#" )+1 ) + eventAlias .getAlias ();
182+ //events.put(array[i], events.remove(verb));
183+ }
184+ }
171185
172186 event .setActor (actor );
173187 event .setContext (context );
@@ -186,10 +200,26 @@ public Event apply(unicon.matthews.caliper.Event t) {
186200 };
187201
188202 if (events != null && events .length > 0 ) {
203+
189204 List <Event > eventconverted = Arrays .asList (events ).stream ()
190205 .map (myFunction )
191206 .collect (Collectors .<Event > toList ());
192207
208+
209+ for (EventAlias eventAlias : eventAliases ) {
210+ //remove the ones to NOT display
211+ if (!eventAlias .isDisplay ()) {
212+ Iterator <Event > mongoEventIter = eventconverted .iterator ();
213+ while (mongoEventIter .hasNext ()) {
214+ if (mongoEventIter .next ().getVerb ().equals (eventAlias .getVerb ())) {
215+ mongoEventIter .remove ();
216+ //break;
217+ }
218+ }
219+ }
220+ }
221+
222+
193223 return new PageImpl <>(eventconverted );
194224 }
195225 else {
0 commit comments