Search in sources :

Example 1 with StateMessageType

use of com.qcadoo.mes.states.messages.constants.StateMessageType in project mes by qcadoo.

the class StateChangeViewClientUtil method addStateMessageToComponent.

public void addStateMessageToComponent(final ComponentState component, final Entity stateMessage) {
    final StateMessageType stateMsgType = parseString(stateMessage.getStringField(MessageFields.TYPE));
    if (VALIDATION_ERROR.equals(stateMsgType)) {
        return;
    }
    component.addMessage(getKey(stateMessage), convertViewMessageType(stateMsgType), isAutoClosed(stateMessage), getArgs(stateMessage));
}
Also used : StateMessageType(com.qcadoo.mes.states.messages.constants.StateMessageType)

Example 2 with StateMessageType

use of com.qcadoo.mes.states.messages.constants.StateMessageType in project mes by qcadoo.

the class MessageServiceImpl method addMessage.

@Override
public final void addMessage(final StateChangeContext stateChangeContext, final Entity message) {
    final List<Entity> messages = Lists.newArrayList(stateChangeContext.getAllMessages());
    messages.add(message);
    final String messagesFieldName = stateChangeContext.getDescriber().getMessagesFieldName();
    stateChangeContext.setField(messagesFieldName, messages);
    final StateMessageType type = StateMessageType.parseString(message.getStringField(MessageFields.TYPE));
    if (VALIDATION_ERROR.equals(type) || FAILURE.equals(type)) {
        stateChangeContext.setStatus(StateChangeStatus.FAILURE);
    }
    stateChangeContext.save();
}
Also used : Entity(com.qcadoo.model.api.Entity) StateMessageType(com.qcadoo.mes.states.messages.constants.StateMessageType)

Example 3 with StateMessageType

use of com.qcadoo.mes.states.messages.constants.StateMessageType in project mes by qcadoo.

the class MessagesUtil method messageIsTypeOf.

public static boolean messageIsTypeOf(final Entity message, final StateMessageType typeLookingFor) {
    final String messageStringType = message.getStringField(MessageFields.TYPE);
    final StateMessageType messageType = StateMessageType.parseString(messageStringType);
    return messageType.equals(typeLookingFor);
}
Also used : StateMessageType(com.qcadoo.mes.states.messages.constants.StateMessageType)

Aggregations

StateMessageType (com.qcadoo.mes.states.messages.constants.StateMessageType)3 Entity (com.qcadoo.model.api.Entity)1