use of com.serotonin.m2m2.vo.User in project ma-core-public by infiniteautomation.
the class DataPointTagsDao method getTagValuesForKey.
public Set<String> getTagValuesForKey(String tagKey, ASTNode restrictions, User user) {
RQLToConditionWithTagKeys visitor = new RQLToConditionWithTagKeys();
Name tagKeyColumn = visitor.columnNameForTagKey(tagKey);
List<Condition> conditionList = new ArrayList<>();
ConditionSortLimitWithTagKeys conditions = visitor.visit(restrictions);
if (conditions.getCondition() != null) {
conditionList.add(conditions.getCondition());
}
Map<String, Name> tagKeyToColumn = conditions.getTagKeyToColumn();
Table<Record> from = createTagPivotSql(tagKeyToColumn).asTable().as(DATA_POINT_TAGS_PIVOT_ALIAS);
if (!user.isAdmin()) {
from = joinPointPermissions(from, PIVOT_ALIAS_DATA_POINT_ID, user);
}
SelectJoinStep<Record1<String>> query = this.create.selectDistinct(DSL.field(DATA_POINT_TAGS_PIVOT_ALIAS.append(tagKeyColumn), String.class)).from(from);
Select<Record1<String>> result = query;
if (!conditionList.isEmpty()) {
result = query.where(DSL.and(conditionList));
}
try (Stream<Record1<String>> stream = result.stream()) {
return stream.map(r -> r.value1()).collect(Collectors.toSet());
}
}
use of com.serotonin.m2m2.vo.User in project ma-core-public by infiniteautomation.
the class UserDao method saveHomeUrl.
public void saveHomeUrl(int userId, String homeUrl) {
User old = getUser(userId);
ejt.update("UPDATE users SET homeUrl=? WHERE id=?", new Object[] { homeUrl, userId });
User user = getUser(userId);
AuditEventType.raiseChangedEvent(AuditEventType.TYPE_USER, old, user);
userCache.put(user.getUsername(), user);
}
use of com.serotonin.m2m2.vo.User in project ma-core-public by infiniteautomation.
the class UserDao method saveMuted.
public void saveMuted(int userId, boolean muted) {
User old = getUser(userId);
ejt.update("UPDATE users SET muted=? WHERE id=?", new Object[] { boolToChar(muted), userId });
User user = getUser(userId);
AuditEventType.raiseChangedEvent(AuditEventType.TYPE_USER, old, user);
userCache.put(user.getUsername(), user);
}
use of com.serotonin.m2m2.vo.User in project ma-core-public by infiniteautomation.
the class UserDao method deleteUser.
public void deleteUser(final int userId) {
User user = getTransactionTemplate().execute(new TransactionCallback<User>() {
@Override
public User doInTransaction(TransactionStatus status) {
User user = get(userId);
Object[] args = new Object[] { userId };
ejt.update("UPDATE userComments SET userId=null WHERE userId=?", args);
ejt.update("DELETE FROM mailingListMembers WHERE userId=?", args);
ejt.update("DELETE FROM userEvents WHERE userId=?", args);
ejt.update("UPDATE events SET ackUserId=null, alternateAckSource=? WHERE ackUserId=?", new Object[] { new TranslatableMessage("events.ackedByDeletedUser").serialize(), userId });
ejt.update("DELETE FROM users WHERE id=?", args);
return user;
}
});
AuditEventType.raiseDeletedEvent(AuditEventType.TYPE_USER, user);
countMonitor.decrement();
if (handler != null)
handler.notify("delete", user);
// Update User In Session
MangoSecurityConfiguration.sessionRegistry.exireSessionsForUser(user);
userCache.remove(user.getUsername());
}
use of com.serotonin.m2m2.vo.User in project ma-core-public by infiniteautomation.
the class RealTimeDataPointValueCache method createPointHierarchy.
/**
* Create a point hierarchy for this user out of all points they can read
*
* @param translations
* @param user
* @return
*/
private static PointHierarchy createPointHierarchy(Translations translations) {
// Create a point hierarchy for the user.
PointHierarchy ph = DataPointDao.instance.getPointHierarchy(true).copyFoldersOnly();
List<DataPointVO> points = DataPointDao.instance.getDataPoints(DataPointExtendedNameComparator.instance, false);
for (DataPointVO point : points) {
ph.addDataPoint(point.getPointFolderId(), new DataPointSummary(point));
}
ph.parseEmptyFolders();
return ph;
}
Aggregations