Search in sources :

Example 46 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.

the class EventInstanceDwr method acknowledgeEvents.

/**
 * Acknowledge all events from the current User Event Query
 * @return
 */
@DwrPermission(user = true)
public ProcessResult acknowledgeEvents() {
    ProcessResult response = new ProcessResult();
    final User user = Common.getHttpUser();
    if (user != null) {
        final long now = Common.timer.currentTimeMillis();
        final ResultSetCounter counter = new ResultSetCounter();
        QueryDefinition queryData = (QueryDefinition) user.getAttribute("eventInstanceExportDefinition");
        DojoQueryCallback<EventInstanceVO> callback = new DojoQueryCallback<EventInstanceVO>(false) {

            @Override
            public void row(EventInstanceVO vo, int rowIndex) {
                if (!vo.isAcknowledged()) {
                    EventInstance event = Common.eventManager.acknowledgeEventById(vo.getId(), now, user, null);
                    if (event != null && event.isAcknowledged()) {
                        counter.increment();
                    }
                }
            }
        };
        EventInstanceDao.instance.exportQuery(queryData.getQuery(), queryData.getSort(), null, null, queryData.isOr(), callback);
        resetLastAlarmLevelChange();
        response.addGenericMessage("events.acknowledgedEvents", counter.getCount());
    } else {
        response.addGenericMessage("events.acknowledgedEvents", 0);
    }
    return response;
}
Also used : EventInstance(com.serotonin.m2m2.rt.event.EventInstance) User(com.serotonin.m2m2.vo.User) EventInstanceVO(com.serotonin.m2m2.vo.event.EventInstanceVO) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DojoQueryCallback(com.serotonin.m2m2.db.dao.DojoQueryCallback) ResultSetCounter(com.serotonin.m2m2.db.dao.ResultSetCounter) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 47 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.

the class EventInstanceDwr method getEventTypeLink.

/**
 * @param divId - Id of div to place the link
 * @param type
 * @param subtype
 * @param ref1
 * @param ref2
 * @return
 */
@DwrPermission(user = true)
public static ProcessResult getEventTypeLink(String divId, String type, String subtype, int ref1, int ref2) {
    ProcessResult result = new ProcessResult();
    result.addData("divId", divId);
    EventTypeDefinition def = ModuleRegistry.getEventTypeDefinition(type);
    if (def != null)
        result.addData("link", def.getEventListLink(subtype, ref1, ref2, Common.getTranslations()));
    return result;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) SystemEventTypeDefinition(com.serotonin.m2m2.module.SystemEventTypeDefinition) AuditEventTypeDefinition(com.serotonin.m2m2.module.AuditEventTypeDefinition) EventTypeDefinition(com.serotonin.m2m2.module.EventTypeDefinition) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 48 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.

the class EventInstanceDwr method getSystemEventTypeLink.

// Utility Methods for help with rendering some strings
/**
 * @param divId - Id of link to place div on return
 * @param subtype
 * @param ref1
 * @param ref2
 * @return
 */
@DwrPermission(user = true)
public static ProcessResult getSystemEventTypeLink(String divId, String subtype, int ref1, int ref2) {
    ProcessResult result = new ProcessResult();
    result.addData("divId", divId);
    SystemEventTypeDefinition def = ModuleRegistry.getSystemEventTypeDefinition(subtype);
    if (def != null)
        result.addData("link", def.getEventListLink(ref1, ref2, Common.getTranslations()));
    return result;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) SystemEventTypeDefinition(com.serotonin.m2m2.module.SystemEventTypeDefinition) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 49 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.

the class MailingListsDwr method saveMailingList.

@DwrPermission(admin = true)
public ProcessResult saveMailingList(int id, String xid, String name, int receiveAlarmEmails, List<RecipientListEntryBean> entryBeans, List<Integer> inactiveIntervals) {
    ProcessResult response = new ProcessResult();
    MailingListDao mailingListDao = MailingListDao.instance;
    // Validate the given information. If there is a problem, return an appropriate error message.
    MailingList ml = createMailingList(id, xid, name, receiveAlarmEmails, entryBeans);
    ml.getInactiveIntervals().addAll(inactiveIntervals);
    if (StringUtils.isBlank(xid))
        response.addContextualMessage("xid", "validate.required");
    else if (!mailingListDao.isXidUnique(xid, id))
        response.addContextualMessage("xid", "validate.xidUsed");
    ml.validate(response);
    if (!response.getHasMessages()) {
        // Save the mailing list
        mailingListDao.saveMailingList(ml);
        response.addData("mlId", ml.getId());
    }
    if (!AlarmLevels.CODES.isValidId(receiveAlarmEmails))
        response.addContextualMessage("receiveAlarmEmails", "validate.invalidValue");
    return response;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) MailingList(com.serotonin.m2m2.vo.mailingList.MailingList) MailingListDao(com.serotonin.m2m2.db.dao.MailingListDao) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 50 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.

the class MiscDwr method setLocale.

@DwrPermission(anonymous = true)
public void setLocale(String locale) {
    WebContext webContext = WebContextFactory.get();
    LocaleResolver localeResolver = new SessionLocaleResolver();
    LocaleEditor localeEditor = new LocaleEditor();
    localeEditor.setAsText(locale);
    localeResolver.setLocale(webContext.getHttpServletRequest(), webContext.getHttpServletResponse(), (Locale) localeEditor.getValue());
}
Also used : LocaleResolver(org.springframework.web.servlet.LocaleResolver) SessionLocaleResolver(org.springframework.web.servlet.i18n.SessionLocaleResolver) SessionLocaleResolver(org.springframework.web.servlet.i18n.SessionLocaleResolver) WebContext(org.directwebremoting.WebContext) LocaleEditor(org.springframework.beans.propertyeditors.LocaleEditor) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Aggregations

DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)220 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)126 User (com.serotonin.m2m2.vo.User)56 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)47 ArrayList (java.util.ArrayList)35 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)24 HashMap (java.util.HashMap)21 StringStringPair (com.serotonin.db.pair.StringStringPair)11 SystemSettingsDao (com.serotonin.m2m2.db.dao.SystemSettingsDao)11 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)10 IOException (java.io.IOException)9 DateTime (org.joda.time.DateTime)9 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)9 AbstractVO (com.serotonin.m2m2.vo.AbstractVO)8 AnonymousUser (com.serotonin.m2m2.vo.AnonymousUser)8 LinkedHashMap (java.util.LinkedHashMap)8 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)7 ShareUser (com.serotonin.m2m2.view.ShareUser)7 ResultsWithTotal (com.serotonin.m2m2.db.dao.ResultsWithTotal)6 ReportVO (com.serotonin.m2m2.reports.vo.ReportVO)6