use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class TagsManager method setProjectTags.
/**
* Sets the tags for the project that this manager is associated with.
*/
public void setProjectTags(@Nonnull Collection<TagData> newProjectTags) {
checkNotNull(newProjectTags);
Collection<Tag> currentProjectTags = getProjectTags();
Set<OWLEntity> modifiedEntityTags = new HashSet<>();
try {
writeLock.lock();
projectTags = null;
Set<TagId> tagIds = newProjectTags.stream().map(TagData::getTagId).filter(Optional::isPresent).map(Optional::get).collect(toSet());
// Remove current tags
currentProjectTags.stream().map(Tag::getTagId).peek(tagId -> {
if (!tagIds.contains(tagId)) {
// Record modified entity tags
entityTagsRepository.findByTagId(tagId).stream().map(EntityTags::getEntity).forEach(modifiedEntityTags::add);
// Remove tag from entity
entityTagsRepository.removeTag(projectId, tagId);
}
}).forEach(tagRepository::deleteTag);
// Set fresh tags
List<Tag> tags = newProjectTags.stream().map(tagData -> new Tag(tagData.getTagId().orElse(createTagId()), projectId, tagData.getLabel(), tagData.getDescription(), tagData.getColor(), tagData.getBackgroundColor())).peek(tag -> {
// Find the modified entities for this tag
entityTagsRepository.findByTagId(tag.getTagId()).stream().map(EntityTags::getEntity).forEach(modifiedEntityTags::add);
}).collect(toList());
tagRepository.saveTags(tags);
} finally {
writeLock.unlock();
}
Set<Tag> oldProjectTags = new HashSet<>(currentProjectTags);
Set<Tag> projectTags = new HashSet<>(getProjectTags());
if (!oldProjectTags.equals(projectTags)) {
List<ProjectEvent<?>> events = new ArrayList<>();
for (OWLEntity entity : modifiedEntityTags) {
EntityTagsChangedEvent event = new EntityTagsChangedEvent(projectId, entity, getTags(entity));
events.add(event);
}
events.add(new ProjectTagsChangedEvent(projectId, projectTags));
eventBus.postEvents(events);
}
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class GetEntityTagsActionHandler method execute.
@Nonnull
@Override
public GetEntityTagsResult execute(@Nonnull GetEntityTagsAction action, @Nonnull ExecutionContext executionContext) {
ProjectId projectId = action.getProjectId();
OWLEntity entity = action.getEntity();
return new GetEntityTagsResult(tagsManager.getTags(entity), tagsManager.getProjectTags());
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class ProjectTagsPlaceTokenizer method getPlace.
@Override
public ProjectTagsPlace getPlace(String token) {
MatchResult matchResult = regExp.exec(token);
if (matchResult == null) {
return null;
}
String projectIdString = matchResult.getGroup(1);
if (ProjectId.isWelFormedProjectId(projectIdString)) {
ProjectId projectId = ProjectId.get(projectIdString);
return new ProjectTagsPlace(projectId, Optional.empty());
} else {
return null;
}
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class ProjectSettingsPlaceTokenizer method getPlace.
@Override
public ProjectSettingsPlace getPlace(String token) {
MatchResult matchResult = regExp.exec(token);
if (matchResult == null) {
return null;
}
String projectIdString = matchResult.getGroup(1);
if (ProjectId.isWelFormedProjectId(projectIdString)) {
ProjectId projectId = ProjectId.get(projectIdString);
return new ProjectSettingsPlace(projectId, empty());
} else {
return null;
}
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class ProjectDownloadServlet method startProjectDownload.
private void startProjectDownload(HttpServletResponse resp, UserId userId, FileDownloadParameters downloadParameters) throws IOException {
ProjectId projectId = downloadParameters.getProjectId();
RevisionNumber revisionNumber = downloadParameters.getRequestedRevision();
DownloadFormat format = downloadParameters.getFormat();
projectDownloadService.downloadProject(userId, projectId, revisionNumber, format, resp);
}
Aggregations