Search in sources :

Example 1 with TimePeriod

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

the class PointValueRestController method getRollupPointValues.

@ApiOperation(value = "Rollup values For 1 Data Point, return in time ascending order", notes = "From time inclusive, To time exclusive.", response = PointValueTimeModel.class, responseContainer = "Array")
@RequestMapping(method = RequestMethod.GET, value = "/time-period/{xid}/{rollup}")
public ResponseEntity<PointValueTimeStream<PointValueTimeModel, ZonedDateTimeRangeQueryInfo>> getRollupPointValues(@ApiParam(value = "Point xid", required = true) @PathVariable String xid, @ApiParam(value = "Rollup type") @PathVariable(value = "rollup") RollupEnum rollup, @ApiParam(value = "Date Time format pattern for timestamps as strings, if not included epoch milli number is used") @RequestParam(value = "dateTimeFormat", required = false) String dateTimeFormat, @ApiParam(value = "From time") @RequestParam(value = "from", required = false) @DateTimeFormat(iso = ISO.DATE_TIME) ZonedDateTime from, @ApiParam(value = "To time") @RequestParam(value = "to", required = false) @DateTimeFormat(iso = ISO.DATE_TIME) ZonedDateTime to, @ApiParam(value = "Time zone") @RequestParam(value = "timezone", required = false) String timezone, @ApiParam(value = "Limit") @RequestParam(value = "limit", required = false) Integer limit, @ApiParam(value = "Time Period Type") @RequestParam(value = "timePeriodType", required = false) TimePeriodType timePeriodType, @ApiParam(value = "Time Periods") @RequestParam(value = "timePeriods", required = false) Integer timePeriods, @ApiParam(value = "Truncate the from time and expand to time based on the time period settings") @RequestParam(value = "truncate", required = false, defaultValue = "false") boolean truncate, @ApiParam(value = "Fields to be included in the returned data, default is TIMESTAMP,VALUE") @RequestParam(required = false) PointValueField[] fields) {
    TimePeriod timePeriod = null;
    if ((timePeriodType != null) && (timePeriods != null)) {
        timePeriod = new TimePeriod(timePeriods, timePeriodType);
    }
    ZonedDateTimeRangeQueryInfo info = new ZonedDateTimeRangeQueryInfo(from, to, dateTimeFormat, timezone, rollup, timePeriod, limit, true, false, true, PointValueTimeCacheControl.NONE, null, null, truncate, fields);
    return generateStream(info, new String[] { xid });
}
Also used : TimePeriod(com.infiniteautomation.mango.rest.latest.model.time.TimePeriod) ZonedDateTimeRangeQueryInfo(com.infiniteautomation.mango.rest.latest.model.pointValue.query.ZonedDateTimeRangeQueryInfo) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with TimePeriod

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

the class PointValueRestController method getRollupPointValuesAsSingleArray.

@ApiOperation(value = "Rollup values for multiple data points, return in time ascending order", notes = "From time inclusive, To time exclusive. Return in single array.", response = PointValueTimeModel.class, responseContainer = "Array")
@RequestMapping(method = RequestMethod.GET, value = "/single-array/time-period/{xids}/{rollup}")
public ResponseEntity<PointValueTimeStream<PointValueTimeModel, ZonedDateTimeRangeQueryInfo>> getRollupPointValuesAsSingleArray(@ApiParam(value = "Point xids", required = true, allowMultiple = true) @PathVariable String[] xids, @ApiParam(value = "Rollup type") @PathVariable(value = "rollup") RollupEnum rollup, @ApiParam(value = "From time") @RequestParam(value = "from", required = false) @DateTimeFormat(iso = ISO.DATE_TIME) ZonedDateTime from, @ApiParam(value = "To time") @RequestParam(value = "to", required = false) @DateTimeFormat(iso = ISO.DATE_TIME) ZonedDateTime to, @ApiParam(value = "Time Period Type") @RequestParam(value = "timePeriodType", required = false) TimePeriodType timePeriodType, @ApiParam(value = "Time Periods") @RequestParam(value = "timePeriods", required = false) Integer timePeriods, @ApiParam(value = "Time zone") @RequestParam(value = "timezone", required = false) String timezone, @ApiParam(value = "Limit") @RequestParam(value = "limit", required = false) Integer limit, @ApiParam(value = "Date Time format pattern for timestamps as strings, if not included epoch milli number is used") @RequestParam(value = "dateTimeFormat", required = false) String dateTimeFormat, @ApiParam(value = "Truncate the from time and expand to time based on the time period settings") @RequestParam(value = "truncate", required = false, defaultValue = "false") boolean truncate, @ApiParam(value = "Fields to be included in the returned data, default is TIMESTAMP,VALUE") @RequestParam(required = false) PointValueField[] fields) {
    TimePeriod timePeriod = null;
    if ((timePeriodType != null) && (timePeriods != null)) {
        timePeriod = new TimePeriod(timePeriods, timePeriodType);
    }
    ZonedDateTimeRangeQueryInfo info = new ZonedDateTimeRangeQueryInfo(from, to, dateTimeFormat, timezone, rollup, timePeriod, limit, true, true, true, PointValueTimeCacheControl.NONE, null, null, truncate, fields);
    return generateStream(info, xids);
}
Also used : TimePeriod(com.infiniteautomation.mango.rest.latest.model.time.TimePeriod) ZonedDateTimeRangeQueryInfo(com.infiniteautomation.mango.rest.latest.model.pointValue.query.ZonedDateTimeRangeQueryInfo) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with TimePeriod

use of com.infiniteautomation.mango.rest.latest.model.time.TimePeriod 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 4 with TimePeriod

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

the class PointValueRestController method getRollupPointValuesAsMultipleArrays.

@ApiOperation(value = "Rollup values for multiple data points, return in time ascending order", notes = "From time inclusive, To time exclusive.  Returns a map of xid to point value time arrays.", response = PointValueTimeModel.class, responseContainer = "Object")
@RequestMapping(method = RequestMethod.GET, value = "/multiple-arrays/time-period/{xids}/{rollup}")
public ResponseEntity<PointValueTimeStream<Map<String, List<PointValueTime>>, ZonedDateTimeRangeQueryInfo>> getRollupPointValuesAsMultipleArrays(@ApiParam(value = "Point xids", required = true, allowMultiple = true) @PathVariable String[] xids, @ApiParam(value = "Rollup type") @PathVariable(value = "rollup") RollupEnum rollup, @ApiParam(value = "From time") @RequestParam(value = "from", required = false) @DateTimeFormat(iso = ISO.DATE_TIME) ZonedDateTime from, @ApiParam(value = "To time") @RequestParam(value = "to", required = false) @DateTimeFormat(iso = ISO.DATE_TIME) ZonedDateTime to, @ApiParam(value = "Time Period Type") @RequestParam(value = "timePeriodType", required = false) TimePeriodType timePeriodType, @ApiParam(value = "Time Periods") @RequestParam(value = "timePeriods", required = false) Integer timePeriods, @ApiParam(value = "Time zone") @RequestParam(value = "timezone", required = false) String timezone, @ApiParam(value = "Limit (per series)") @RequestParam(value = "limit", required = false) Integer limit, @ApiParam(value = "Date Time format pattern for timestamps as strings, if not included epoch milli number is used") @RequestParam(value = "dateTimeFormat", required = false) String dateTimeFormat, @ApiParam(value = "Truncate the from time and expand to time based on the time period settings") @RequestParam(value = "truncate", required = false, defaultValue = "false") boolean truncate, @ApiParam(value = "Fields to be included in the returned data, default is TIMESTAMP,VALUE") @RequestParam(required = false) PointValueField[] fields) {
    TimePeriod timePeriod = null;
    if ((timePeriodType != null) && (timePeriods != null)) {
        timePeriod = new TimePeriod(timePeriods, timePeriodType);
    }
    ZonedDateTimeRangeQueryInfo info = new ZonedDateTimeRangeQueryInfo(from, to, dateTimeFormat, timezone, rollup, timePeriod, limit, true, false, false, PointValueTimeCacheControl.NONE, null, null, truncate, fields);
    return generateStream(info, xids);
}
Also used : TimePeriod(com.infiniteautomation.mango.rest.latest.model.time.TimePeriod) ZonedDateTimeRangeQueryInfo(com.infiniteautomation.mango.rest.latest.model.pointValue.query.ZonedDateTimeRangeQueryInfo) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with TimePeriod

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

the class UserModel method fromVO.

@Override
public void fromVO(User vo) {
    super.fromVO(vo);
    this.username = vo.getUsername();
    this.password = vo.getPassword();
    this.email = vo.getEmail();
    this.phone = vo.getPhone();
    this.disabled = vo.isDisabled();
    this.homeUrl = vo.getHomeUrl();
    this.lastLogin = vo.getLastLogin() == 0 ? null : new Date(vo.getLastLogin());
    this.lastPasswordChange = new Date(vo.getPasswordChangeTimestamp());
    this.receiveAlarmEmails = vo.getReceiveAlarmEmails();
    this.timezone = StringUtils.isBlank(vo.getTimezone()) ? null : vo.getTimezone();
    this.muted = vo.isMuted();
    this.receiveOwnAuditEvents = vo.isReceiveOwnAuditEvents();
    this.roles = new HashSet<>();
    for (Role role : vo.getRoles()) {
        roles.add(role.getXid());
    }
    // TODO move this into the model mapper and use map/unmap anywhere
    // a user model is needed
    PermissionService permissionService = Common.getBean(PermissionService.class);
    this.inheritedRoles = new HashSet<>();
    Set<Role> getAllInheritedRoles = permissionService.getAllInheritedRoles(vo);
    for (Role role : getAllInheritedRoles) {
        this.inheritedRoles.add(role.getXid());
    }
    this.systemPermissions = permissionService.getSystemPermissions(vo);
    this.locale = StringUtils.isBlank(vo.getLocale()) ? null : vo.getLocale();
    this.passwordLocked = vo.isPasswordLocked();
    this.sessionExpirationOverride = vo.isSessionExpirationOverride();
    if (sessionExpirationOverride)
        this.sessionExpirationPeriod = new TimePeriod(vo.getSessionExpirationPeriods(), TimePeriodType.valueOf(vo.getSessionExpirationPeriodType()));
    this.organization = vo.getOrganization();
    this.organizationalRole = vo.getOrganizationalRole();
    this.created = vo.getCreated();
    this.emailVerified = vo.getEmailVerifiedDate();
    this.data = vo.getData();
    this.editPermission = new MangoPermissionModel(vo.getEditPermission());
    this.readPermission = new MangoPermissionModel(vo.getReadPermission());
}
Also used : Role(com.serotonin.m2m2.vo.role.Role) PermissionService(com.infiniteautomation.mango.spring.service.PermissionService) TimePeriod(com.infiniteautomation.mango.rest.latest.model.time.TimePeriod) MangoPermissionModel(com.infiniteautomation.mango.rest.latest.model.permissions.MangoPermissionModel) Date(java.util.Date)

Aggregations

TimePeriod (com.infiniteautomation.mango.rest.latest.model.time.TimePeriod)9 ZonedDateTimeRangeQueryInfo (com.infiniteautomation.mango.rest.latest.model.pointValue.query.ZonedDateTimeRangeQueryInfo)3 ApiOperation (io.swagger.annotations.ApiOperation)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 EventTypeAlarmLevelModel (com.infiniteautomation.mango.rest.latest.model.datasource.EventTypeAlarmLevelModel)1 MangoPermissionModel (com.infiniteautomation.mango.rest.latest.model.permissions.MangoPermissionModel)1 PermissionService (com.infiniteautomation.mango.spring.service.PermissionService)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 Role (com.serotonin.m2m2.vo.role.Role)1 Date (java.util.Date)1