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(",")));
}
}
}
}
Aggregations