use of de.catma.util.IDGenerator in project catma by forTEXT.
the class GitlabManagerRestricted method getCommentReplies.
@Override
public List<Reply> getCommentReplies(String projectId, Comment comment) throws IOException {
String resourceId = comment.getDocumentId();
String projectPath = projectId + "/" + resourceId;
NotesApi notesApi = restrictedGitLabApi.getNotesApi();
List<Reply> result = new ArrayList<Reply>();
try {
List<Note> notes = notesApi.getIssueNotes(projectPath, comment.getIid());
for (Note note : notes.stream().filter(n -> !n.getSystem()).collect(Collectors.toList())) {
// filter system notes
String noteBody = note.getBody();
Reply reply = null;
try {
reply = new SerializationHelper<Reply>().deserialize(noteBody, Reply.class);
reply.setCommentUuid(comment.getUuid());
reply.setId(note.getId());
reply.setUserId(note.getAuthor().getId());
reply.setUsername(note.getAuthor().getName());
} catch (Exception e) {
logger.log(Level.SEVERE, String.format("Error deserializing Reply #%1$d %2$s", note.getId(), noteBody), e);
IDGenerator idGenerator = new IDGenerator();
reply = new Reply(idGenerator.generate(), noteBody, note.getAuthor().getUsername(), note.getAuthor().getId(), comment.getUuid(), note.getId());
}
result.add(reply);
}
comment.setReplies(result);
return result;
} catch (GitLabApiException e) {
throw new IOException(String.format("Failed to retrieve Replies for Comment %1$s %2$d for resource %3$s in group %4$s!", comment.getUuid(), comment.getIid(), resourceId, projectId), e);
}
}
use of de.catma.util.IDGenerator in project catma by forTEXT.
the class CollectionXMLExportStreamSource method getStream.
@Override
public InputStream getStream() {
final UI ui = UI.getCurrent();
final Project project = projectSupplier.get();
final Corpus corpus = new Corpus();
final Collection<SourceDocument> documents = documentSupplier.get();
final Collection<AnnotationCollectionReference> collectionReferences = collectionReferenceSupplier.get();
try {
Set<String> documentIds = documents.stream().map(doc -> doc.getUuid()).collect(Collectors.toSet());
collectionReferences.stream().forEach(ref -> documentIds.add(ref.getSourceDocumentId()));
for (String documentId : documentIds) {
corpus.addSourceDocument(project.getSourceDocument(documentId));
}
if (corpus.getSourceDocuments().size() == 0) {
return null;
}
collectionReferences.forEach(ref -> corpus.addUserMarkupCollectionReference(ref));
File tempFile = File.createTempFile(new IDGenerator().generate() + "_AnnotationCollection_Export", "tgz");
try (FileOutputStream fos = new FileOutputStream(tempFile)) {
new CorpusExporter(project, true).export(project.getName(), corpus, fos);
}
return new FileInputStream(tempFile);
} catch (Exception e) {
((ErrorHandler) ui).showAndLogError("Error exporting Documents and Collections!", e);
}
return null;
}
use of de.catma.util.IDGenerator in project catma by forTEXT.
the class TagInstance method addSystemProperty.
public void addSystemProperty(Property property) {
String propertyDefinitionId = property.getPropertyDefinitionId();
IDGenerator idGenerator = new IDGenerator();
String authorId = idGenerator.generate(SystemPropertyName.catma_markupauthor.name());
String timestampId = idGenerator.generate(SystemPropertyName.catma_markuptimestamp.name());
if (authorId.equals(propertyDefinitionId)) {
this.author = property.getFirstValue();
} else if (timestampId.equals(propertyDefinitionId)) {
this.timestamp = property.getFirstValue();
}
}
use of de.catma.util.IDGenerator in project catma by forTEXT.
the class TaggerView method addComment.
@Override
public void addComment(List<Range> absoluteRanges, int x, int y) {
User user = project.getUser();
IDGenerator idGenerator = new IDGenerator();
CommentDialog commentDialog = new CommentDialog(commentBody -> {
try {
project.addComment(new Comment(idGenerator.generate(), user.getName(), user.getUserId(), commentBody, absoluteRanges, this.sourceDocument.getUuid()));
} catch (IOException e) {
errorHandler.showAndLogError("Error adding Comment!", e);
}
});
commentDialog.show(x, y);
}
use of de.catma.util.IDGenerator in project catma by forTEXT.
the class TagInstance method getSystemProperties.
/**
* @return non modifiable collection of system properties
* @see PropertyDefinition.SystemPropertyName
*/
public Collection<Property> getSystemProperties() {
Collection<Property> systemProperties = new HashSet<>();
IDGenerator idGenerator = new IDGenerator();
String authorId = idGenerator.generate(SystemPropertyName.catma_markupauthor.name());
systemProperties.add(new Property(authorId, Collections.singleton(author)));
String timestampId = idGenerator.generate(SystemPropertyName.catma_markuptimestamp.name());
systemProperties.add(new Property(timestampId, Collections.singleton(timestamp)));
return Collections.unmodifiableCollection(systemProperties);
}
Aggregations