LDEV-4609 Calculate dates and status for archived progress Methods which calculate LearnerProgress dates and status use ugly instanceof constructs. There seem to be no good alternatives, though.
LearnerProgressArchive can inherit from LearnerProgress and we use table-per-subclass Hibernate strategy. But then queries for LearnerProgress would fetch also LearnerProgressArchive entities unless in each HQL query we put "WHERE lp.class = LearnerProgress". It is easy to forget plus generic methods like findAll() will not work well anyway.
LearnerProgress and LearnerProgressArchive can extend a new AbstractLearnerProgress and we use table-per-concrete-class Hibernate strategy. Same with CompletedActivityProgress and CompletedActivityProgressArchive. But then AbstractLearnerProgress.completedActivities will not let use both of them due to lack of polymorphism in collections. Neither Map<Activty, AbstractCompletedActivityProgress> nor Map<Activity, ? extends AbstractCompletedActivityProgress> will not work. And this collection is the main reason why to do inheritance in the first place.
Looking how the above solutions add complexity and little gain, these few methods with instanceof seem to be a fine trade off.