TechnologyRediscovery / codenforce

municipal code enforcement database application
GNU General Public License v3.0
2 stars 3 forks source link

Occupancy inspection method call chain #219

Open edarsow opened 2 years ago

edarsow commented 2 years ago

The management of the inspection related objects during an inspection are all prefixed with inspectionAction_ in the occInspectionCoordinator: inspectionactions

Step 1: Pull out the OccSpaceTypeChecklistified which has in it a List<OccSpaceElement> and send these to the method

public OccInspectedSpace inspectionAction_commenceInspectionOfSpaceTypeChecklistified  (OccInspection inspection,
                                                                                        User user,
                                                                                        OccSpaceTypeChecklistified tpe,
                                                                                        OccInspectionStatusEnum initialStatus,
                                                                                        OccLocationDescriptor locDesc) 
                                                                                throws IntegrationException {

which takes these in and will return OccInspectedSpace object which has inside of it now a List<OccInspectedSpaceElement> which are ready to be marked with one of these these combinations of timestamps

Step 2: Now are are ready to record inspection of one or more of the OccSpaceElements in the OccSpaceTypeChecklistified by calling

public void inspectionAction_recordElementInspectionByStatusEnum(OccInspectedSpaceElement oise,
                                                                     UserAuthorized ua,
                                                                     OccInspection oi,
                                                                     boolean useDefFindOnFail) throws AuthorizationException, BObStatusException, IntegrationException{

This method expects the code calling it to have set the desired enum value in the OccInspectedSpaceElement which you pass in when you call. The logic in here will use the enum to decide on one of these conditions. You'll need to call this method once for each element that is inspected. This method will write all that's needed to the database. 0) Before any inspecting has happened, there are nulls in complianceGrantedTS and lastInspectedTS (and their User ID fields) 1)If the element passed, then timestamp both lastInspectedTS and complianceGrantedTS (and the user IDS) 2) If the element failed then only write a timestamp to lastInspectedTS

UI Notes

The JSF version of this process manages the UI by looking at the inspection status enum on each element to figure out what to show the user:

public enum OccInspectionStatusEnum {

    NOTINSPECTED("Not inspected", 0, "inspectionStatusIcon_notinspected"),
    PASS("Passed", 1, "inspectionStatusIcon_pass"),
    VIOLATION("Violated", 2, "inspectionStatusIcon_fail");

    private final String label;
    private final int phaseOrder;
    private final String iconPropertyLookup;

And by setting this enum correctly based on the user actions, then you just have to pass the InspectedSpaceElement to the Coordinator methods and the Database will be written to reflect that status.