use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.
the class EntitySearcher method invoke.
/**
* Invokes the entity searcher to perform a search.
*/
public void invoke() {
Stopwatch stopwatch = Stopwatch.createStarted();
matchCounter.reset();
searchCounter.reset();
results.clear();
tagsByLabel.clear();
tagsManager.getProjectTags().forEach(tag -> tagsByLabel.put(tag.getLabel(), tag));
tagsByEntity.clear();
tagsByEntity.putAll(tagsManager.getTags(projectId));
Pattern searchPattern = compileSearchPattern(searchWords);
entityStreamSupplier.get().filter(this::isRequiredEntityType).peek(this::incrementSearchCounter).map(this::performMatch).filter(Objects::nonNull).peek(this::incrementMatchCounter).sorted().skip(skip).limit(limit).map(m -> toSearchResult(searchPattern, m)).forEach(results::add);
logger.info(BROWSING, "{} {} Performed entity search for \"{}\". Found {} matches in {} entities in {} ms.", projectId, userId, searchString, matchCounter.getCounter(), searchCounter.getCounter(), stopwatch.elapsed(TimeUnit.MILLISECONDS));
}
use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.
the class SetEntityWatchesActionHandler method execute.
@Nonnull
@Override
public SetEntityWatchesResult execute(@Nonnull SetEntityWatchesAction action, @Nonnull ExecutionContext executionContext) {
EventTag startTag = eventManager.getCurrentTag();
UserId userId = action.getUserId();
Set<Watch> watches = watchManager.getDirectWatches(action.getEntity(), userId);
for (Watch watch : watches) {
watchManager.removeWatch(watch);
}
for (Watch watch : action.getWatches()) {
watchManager.addWatch(watch);
}
return new SetEntityWatchesResult(eventManager.getEventsFromTag(startTag));
}
use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.
the class WatchTriggeredHandlerImpl method handleWatchTriggered.
@Override
public void handleWatchTriggered(@Nonnull Set<UserId> usersToNotify, @Nonnull OWLEntity modifiedEntity, @Nonnull UserId byUser) {
List<String> emailAddresses = usersToNotify.stream().filter(u -> accessManager.hasPermission(forUser(u), forProject(projectId), VIEW_PROJECT)).map(userDetailsManager::getEmail).filter(Optional::isPresent).map(Optional::get).distinct().collect(toList());
OWLEntityData modifiedEntityData = renderingManager.getRendering(modifiedEntity);
Map<String, Object> templateObjects = TemplateObjectsBuilder.builder().withUserId(byUser).withEntity(modifiedEntityData).withProjectDetails(projectDetailsManager.getProjectDetails(projectId)).withApplicationName(applicationNameSupplier.get()).withProjectUrl(placeUrl.getProjectUrl(projectId)).build();
String displayName = projectDetailsManager.getProjectDetails(projectId).getDisplayName();
String emailSubject = String.format("[%s] Changes made to %s in %s by %s", displayName, modifiedEntityData.getBrowserText(), displayName, userDetailsManager.getUserDetails(byUser).map(d -> "by " + d.getDisplayName()).orElse(""));
String emailBody = templateEngine.populateTemplate(watchTemplate.getContents(), templateObjects);
logger.info("{} Watch triggered by {} on {}. Notifying {}", projectId, byUser, modifiedEntity, usersToNotify);
sendMail.sendMail(emailAddresses, emailSubject, emailBody, MessageHeader.inReplyTo(projectId.getId()), MessageHeader.references(projectId.getId()));
}
use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.
the class LogOutUserActionHandler method execute.
@Nonnull
@Override
public LogOutUserResult execute(@Nonnull LogOutUserAction action, @Nonnull ExecutionContext executionContext) {
WebProtegeSession session = executionContext.getSession();
UserId userId = session.getUserInSession();
session.clearUserInSession();
if (!userId.isGuest()) {
userActivityManager.setLastLogout(userId, System.currentTimeMillis());
}
return new LogOutUserResult(userInSessionFactory.getUserInSession(UserId.getGuest()));
}
use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.
the class IssueBuilder_TestCase method shouldBuildIssueWithAssignedEvent.
@Test
public void shouldBuildIssueWithAssignedEvent() {
UserId assignee = mock(UserId.class);
builder.assignTo(assignee, userId, TIMESTAMP);
Issue issue = builder.build(mentionParser);
assertThat(issue.getEvents(), hasItem(new IssueAssigned(userId, TIMESTAMP, assignee)));
}
Aggregations