Skip to content

Requirements for Adding a New Maintenance Process (Example: Excision)

This document outlines the code changes required to add the Excision process to the system, assuming it hasn't been implemented yet. This serves as a template for adding similar maintenance processes.

1. cis-workflow Module

A. Register the Process Type

File: com.dw.ngms.cis.cisworkflow.enums.ProcessType.java Action: Add a new Enum constant matching the ID from the WORKFLOWPROCESS table (Process ID 366).

public enum ProcessType {
    // ... existing types
    EXCISION_REQUEST(366L), // <--- Add this entry
    // ...
}

B. Update Routing Logic

File: com.dw.ngms.cis.cisworkflow.service.CisBusinessService.java Action: Update the process method to include the new enum in the switch case. This handles the event where the workflow engine links the generic MAN_DRAFT (Maintenance Draft) record to the specific running Workflow ID.

// Inside public void process(...)

switch (processType) {
    // ...
    case EXCISION_REQUEST: // <--- Add this case
    case PROCLAMATION_OF_APPROVED_TOWNSHIP_REQUEST:
    // ...
    {
        log.debug(" updating maintenance request with workflowId [{}] for draftId [{}]", workflowId, draftId);
        // This links the draft to the workflow in the database
        this.jdbcTemplate.update("update MAN_DRAFT set WORKFLOW_ID = ? where DRAFT_ID =  ?", workflowId, draftId);
    }
    break;
}

2. cis-api Module

A. Register Maintenance Reason

File: com.dw.ngms.cis.enums.MaintenanceReason.java Action: Add a new Enum constant. This ID corresponds to the LIST_ITEM table entry for "Excision" (ID 2486).

public enum MaintenanceReason {
    // ...
    EXCISION(2486L); // <--- Add this entry
    // ...
}

B. Configure Parcel Validation (Business Rules)

File: com.dw.ngms.cis.enums.ReasonTypeToRecordTypeList.java Action: Define the specific Record Types that are valid for Excision. For Excision, usually only specific Record Types (e.g., ID 8 for Holdings/Farms) are valid.

public enum ReasonTypeToRecordTypeList {
    // ...
    /**
     *  for excision
     */
    EXCISION(Collections.singletonList(8L)); // <--- Valid Record Type IDs
    // ...
}

C. Update Search & Validation Filter

File: com.dw.ngms.cis.service.maintenance.MaintenanceDraftService.java Action: Update the search method. When a user searches for a parcel to excise, we must apply the specific SQL filters to ensure they only pick valid parcels.

// Inside public Collection<SgdataParcels> search(...)

// ...
if (MaintenanceReason.EXCISION.getMaintenanceReason().equals(reasonItemId)) {
    // Get the valid record types defined in Step 2B
    List<Long> recordTypeItemId = ReasonTypeToRecordTypeList.EXCISION.getRecordTypeItemId();

    // Add specific SQL condition:
    // Excision logic might require checking Parent_RECORD_ID
    sql += "AND SP.Parent_RECORD_ID in (Select RECORD_ID from SGDATA_PARCELS where RECORD_TYPE_ID in (:recordTypeId) )";

    map.put("recordTypeId", recordTypeItemId);
}
// ...

D. Implement Business Outcome Logic

File: com.dw.ngms.cis.service.maintenance.MaintenanceDraftService.java Action: Create the method that finalizes the Excision in the database (e.g., changing parcel status to "EXCISED"). This method is called by the workflow engine when the process reaches the "Update Database" step.

@Transactional
public void setParentParcelStatusToExcised(Long draftId){
    MaintenanceDraft maintenanceDraft = maintenanceDraftRepository.findByDraftId(draftId);
    if (maintenanceDraft != null) {
        // Loop through steps and requests
        for (MaintenanceDraftSteps mds : maintenanceDraft.getMaintenanceDraftSteps()) {
            mds.getMaintenanceDraftRequests().forEach(mdr -> {
                if (mdr.getRecordId() != null) {
                    Long recordId = mdr.getRecordId();

                    // 1. Fetch relevant parcels
                    SgdataParcels sgdataParcel = sgdataParcelsRepository.findByRecordId(mdr.getRecordId());
                    SgdataParcels sgdataParentParcel = sgdataParcelsRepository.findByRecordId(sgdataParcel.getParentRecordId());

                    // 2. Perform updates (Update LPI, Documents, Statuses)
                    // ... (Migration logic for notes/documents) ...

                    if (sgdataParcel != null && sgdataParentParcel != null) {
                        // Set child to APPROVED
                        sgdataParcel.setStatusItemId(DocumentStatus.APPROVED.getDocumentStatus()); 
                        sgdataParcelsRepository.save(sgdataParcel);

                        // Set parent to EXCISED
                        sgdataParentParcel.setStatusItemId(DocumentStatus.EXCISED.getDocumentStatus()); 
                        sgdataParcelsRepository.save(sgdataParentParcel);
                    }
                }
            });
        }
     }
}

3. Database Updates (Non-Code)

  • Workflow Studio: Create the "Excision" process diagram (Process ID 366).
  • List Management: Ensure LIST_ITEM entry 2486 exists for "Excision".
  • Workflow Matrix: Ensure Action definition exists for the final step to call setParentParcelStatusToExcised (mapped via metadata or custom listener).