3434import java .util .concurrent .ThreadLocalRandom ;
3535import java .util .stream .Collectors ;
3636
37+ import org .slf4j .Logger ;
38+ import org .slf4j .LoggerFactory ;
39+
3740import com .vaadin .data .Binder ;
3841import com .vaadin .data .converter .StringToIntegerConverter ;
3942import com .vaadin .icons .VaadinIcons ;
4548import com .vaadin .ui .DateField ;
4649import com .vaadin .ui .HorizontalLayout ;
4750import com .vaadin .ui .Label ;
51+ import com .vaadin .ui .Notification ;
4852import com .vaadin .ui .TextField ;
4953import com .vaadin .ui .VerticalLayout ;
5054
5963import de .symeda .sormas .api .contact .ContactDto ;
6064import de .symeda .sormas .api .contact .ContactLogic ;
6165import de .symeda .sormas .api .contact .FollowUpStatus ;
66+ import de .symeda .sormas .api .contact .QuarantineType ;
6267import de .symeda .sormas .api .facility .FacilityCriteria ;
6368import de .symeda .sormas .api .facility .FacilityDto ;
6469import de .symeda .sormas .api .i18n .Captions ;
@@ -92,6 +97,8 @@ public class DevModeView extends AbstractConfigurationView {
9297
9398 public static final String VIEW_NAME = ROOT_VIEW_NAME + "/devMode" ;
9499
100+ private final transient Logger logger = LoggerFactory .getLogger (getClass ());
101+
95102 private VerticalLayout contentLayout ;
96103
97104 private Binder <CaseGenerationConfig > caseGeneratorConfigBinder = new Binder <>();
@@ -436,6 +443,8 @@ private void generateCases() {
436443 List <FacilityDto > healthFacilities = FacadeProvider .getFacilityFacade ()
437444 .getIndexList (facilityCriteria , 0 , Math .min (config .getCaseCount () * 2 , 300 ), Arrays .asList (new SortProperty (FacilityDto .NAME )));
438445
446+ long dt = System .nanoTime ();
447+
439448 for (int i = 0 ; i < config .getCaseCount (); i ++) {
440449 Disease disease = config .getDisease ();
441450 if (disease == null ) {
@@ -460,6 +469,13 @@ private void generateCases() {
460469 caze .setDiseaseDetails ("RD " + (random ().nextInt (20 ) + 1 ));
461470 }
462471
472+ if (!QuarantineType .isQuarantineInEffect (caze .getQuarantine ())) {
473+ caze .setQuarantineFrom (null );
474+ caze .setQuarantineTo (null );
475+ caze .setQuarantineExtended (false );
476+ caze .setQuarantineReduced (false );
477+ }
478+
463479 // report
464480 UserReferenceDto userReference = UserProvider .getCurrent ().getUserReference ();
465481 caze .setReportingUser (userReference );
@@ -479,6 +495,12 @@ private void generateCases() {
479495 FacadeProvider .getPersonFacade ().savePerson (person );
480496 FacadeProvider .getCaseFacade ().saveCase (caze );
481497 }
498+
499+ dt = System .nanoTime () - dt ;
500+ long perCase = dt / config .getCaseCount ();
501+ String msg = String .format ("Generating %,d cases took %,d ms (%,d ms per case)" , config .getCaseCount (), dt / 1_000_000 , perCase / 1_000_000 );
502+ logger .info (msg );
503+ Notification .show ("" , msg , Notification .Type .TRAY_NOTIFICATION );
482504 }
483505
484506 private void generateContacts () {
0 commit comments