use of com.infiniteautomation.mango.rest.latest.model.permissions.MangoPermissionModel in project ma-modules-public by infiniteautomation.
the class MailingListModelMapping method map.
@Override
public MailingListModel map(Object from, PermissionHolder user, RestModelMapper mapper) {
MailingList vo = (MailingList) from;
MailingListModel model;
if (mailingListService.hasRecipientViewPermission(user, vo)) {
model = new MailingListWithRecipientsModel(vo);
if (vo.getEntries() != null && vo.getEntries().size() > 0) {
List<EmailRecipientModel> recipients = new ArrayList<>();
((MailingListWithRecipientsModel) model).setRecipients(recipients);
for (MailingListRecipient entry : vo.getEntries()) {
recipients.add(mapper.map(entry, EmailRecipientModel.class, user));
}
}
} else {
model = new MailingListModel(vo);
}
model.setReadPermissions(new MangoPermissionModel(vo.getReadPermission()));
model.setEditPermissions(new MangoPermissionModel(vo.getEditPermission()));
return model;
}
use of com.infiniteautomation.mango.rest.latest.model.permissions.MangoPermissionModel 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());
}
use of com.infiniteautomation.mango.rest.latest.model.permissions.MangoPermissionModel in project ma-modules-public by infiniteautomation.
the class FileStoreModel method fromVO.
@Override
public void fromVO(FileStore vo) {
super.fromVO(vo);
this.readPermission = new MangoPermissionModel(vo.getReadPermission());
this.writePermission = new MangoPermissionModel(vo.getWritePermission());
this.builtIn = vo.isBuiltIn();
}
use of com.infiniteautomation.mango.rest.latest.model.permissions.MangoPermissionModel in project ma-modules-public by infiniteautomation.
the class JsonDataModel method fromVO.
@Override
public void fromVO(JsonDataVO vo) {
super.fromVO(vo);
this.readPermission = new MangoPermissionModel(vo.getReadPermission());
this.editPermission = new MangoPermissionModel(vo.getEditPermission());
this.jsonData = vo.getJsonData();
}
use of com.infiniteautomation.mango.rest.latest.model.permissions.MangoPermissionModel in project ma-modules-public by infiniteautomation.
the class AbstractDataSourceModel method fromVO.
@Override
public void fromVO(T vo) {
super.fromVO(vo);
this.connectionDescription = vo.getConnectionDescription();
this.description = new TranslatableMessage(vo.getDefinition().getDescriptionKey());
this.enabled = vo.isEnabled();
this.eventAlarmLevels = new ArrayList<>();
ExportCodes eventCodes = vo.getEventCodes();
for (EventTypeVO evt : vo.getEventTypes()) {
DataSourceEventType dsEvt = (DataSourceEventType) evt.getEventType();
EventTypeAlarmLevelModel model = new EventTypeAlarmLevelModel(eventCodes.getCode(dsEvt.getReferenceId2()), dsEvt.getDuplicateHandling(), dsEvt.getAlarmLevel(), evt.getDescription());
this.eventAlarmLevels.add(model);
}
this.purgeSettings = new PurgeSettings(vo);
this.editPermission = new MangoPermissionModel(vo.getEditPermission());
this.readPermission = new MangoPermissionModel(vo.getReadPermission());
this.data = vo.getData();
try {
DataSourceRT<?> rt = Common.runtimeManager.getRunningDataSource(getId());
this.lifecycleState = rt.getLifecycleState();
} catch (RTException e) {
this.lifecycleState = ILifecycleState.TERMINATED;
}
}
Aggregations