Search in sources :

Example 1 with MaintenanceEventType

use of com.qcadoo.mes.cmmsMachineParts.constants.MaintenanceEventType in project mes by qcadoo.

the class EventListeners method validateIssueOrProposal.

public void validateIssueOrProposal(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity event = form.getPersistedEntityWithIncludedFormValues();
    if (event.getId() == null || MaintenanceEventState.of(event) == MaintenanceEventState.NEW || MaintenanceEventState.of(event) == MaintenanceEventState.IN_PROGRESS) {
        MaintenanceEventType type = MaintenanceEventType.from(event);
        if (type.compareTo(MaintenanceEventType.ISSUE) == 0 || type.compareTo(MaintenanceEventType.PROPOSAL) == 0) {
            List<Entity> existingEvents = maintenanceEventService.getExistingEventsForEvent(event, MaintenanceEventType.ISSUE.getStringValue());
            existingEvents.addAll(maintenanceEventService.getExistingEventsForEvent(event, MaintenanceEventType.PROPOSAL.getStringValue()));
            if (!existingEvents.isEmpty()) {
                view.addMessage("cmmsMachineParts.error.existsOpenIssuesOrProposals", ComponentState.MessageType.INFO, false, existingEvents.stream().map(e -> e.getStringField(MaintenanceEventFields.NUMBER)).collect(Collectors.joining(",")));
            }
        }
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) MaintenanceEventType(com.qcadoo.mes.cmmsMachineParts.constants.MaintenanceEventType)

Aggregations

MaintenanceEventType (com.qcadoo.mes.cmmsMachineParts.constants.MaintenanceEventType)1 Entity (com.qcadoo.model.api.Entity)1 FormComponent (com.qcadoo.view.api.components.FormComponent)1