Search in sources :

Example 1 with EventTypeAlarmLevelModel

use of com.infiniteautomation.mango.rest.latest.model.datasource.EventTypeAlarmLevelModel in project ma-modules-public by infiniteautomation.

the class AbstractPublisherModel method fromVO.

@Override
public void fromVO(PUBLISHER vo) {
    super.fromVO(vo);
    this.connectionDescription = vo.getConfigDescription();
    this.description = new TranslatableMessage(vo.getDefinition().getDescriptionKey());
    this.enabled = vo.isEnabled();
    this.eventAlarmLevels = new ArrayList<>();
    ExportCodes eventCodes = vo.getEventCodes();
    for (EventTypeVO evt : vo.getEventTypes()) {
        PublisherEventType dsEvt = (PublisherEventType) evt.getEventType();
        EventTypeAlarmLevelModel model = new EventTypeAlarmLevelModel(eventCodes.getCode(dsEvt.getReferenceId2()), dsEvt.getDuplicateHandling(), evt.getAlarmLevel(), evt.getDescription());
        this.eventAlarmLevels.add(model);
    }
    this.publishType = PublisherVO.PUBLISH_TYPE_CODES.getCode(vo.getPublishType());
    this.cacheWarningSize = vo.getCacheWarningSize();
    this.cacheDiscardSize = vo.getCacheDiscardSize();
    this.sendSnapshot = vo.isSendSnapshot();
    this.snapshotSendPeriod = new TimePeriod(vo.getSnapshotSendPeriods(), TimePeriodType.convertTo(vo.getSnapshotSendPeriodType()));
    this.publishAttributeChanges = vo.isPublishAttributeChanges();
}
Also used : ExportCodes(com.serotonin.m2m2.util.ExportCodes) TimePeriod(com.infiniteautomation.mango.rest.latest.model.time.TimePeriod) EventTypeAlarmLevelModel(com.infiniteautomation.mango.rest.latest.model.datasource.EventTypeAlarmLevelModel) PublisherEventType(com.serotonin.m2m2.rt.event.type.PublisherEventType) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage) EventTypeVO(com.serotonin.m2m2.vo.event.EventTypeVO)

Example 2 with EventTypeAlarmLevelModel

use of com.infiniteautomation.mango.rest.latest.model.datasource.EventTypeAlarmLevelModel in project ma-modules-public by infiniteautomation.

the class AbstractPublisherModel method toVO.

@Override
public PUBLISHER toVO() {
    PUBLISHER vo = super.toVO();
    vo.setEnabled(enabled);
    if (eventAlarmLevels != null) {
        for (EventTypeAlarmLevelModel eval : eventAlarmLevels) {
            vo.setAlarmLevel(eval.getEventType(), eval.getLevel());
        }
    }
    vo.setPublishType(PublisherVO.PUBLISH_TYPE_CODES.getId(publishType));
    vo.setCacheWarningSize(cacheWarningSize);
    vo.setCacheDiscardSize(cacheDiscardSize);
    vo.setSendSnapshot(sendSnapshot);
    if (snapshotSendPeriod != null) {
        vo.setSnapshotSendPeriods(snapshotSendPeriod.getPeriods());
        vo.setSnapshotSendPeriodType(TimePeriodType.convertFrom(snapshotSendPeriod.getType()));
    }
    vo.setPublishAttributeChanges(publishAttributeChanges);
    return vo;
}
Also used : EventTypeAlarmLevelModel(com.infiniteautomation.mango.rest.latest.model.datasource.EventTypeAlarmLevelModel)

Aggregations

EventTypeAlarmLevelModel (com.infiniteautomation.mango.rest.latest.model.datasource.EventTypeAlarmLevelModel)2 TimePeriod (com.infiniteautomation.mango.rest.latest.model.time.TimePeriod)1 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)1 PublisherEventType (com.serotonin.m2m2.rt.event.type.PublisherEventType)1 ExportCodes (com.serotonin.m2m2.util.ExportCodes)1 EventTypeVO (com.serotonin.m2m2.vo.event.EventTypeVO)1