Search in sources :

Example 6 with JsonLdWebAnnotation

use of de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation in project catma by forTEXT.

the class GitMarkupCollectionHandler method getBothModifiedAnnotationConflict.

private AnnotationConflict getBothModifiedAnnotationConflict(String projectId, String collectionId, String serializedConflictingAnnotation) throws Exception {
    String masterVersion = serializedConflictingAnnotation.replaceAll("\\Q<<<<<<< HEAD\\E(\\r\\n|\\r|\\n)", "").replaceAll("\\Q=======\\E(\\r\\n|\\r|\\n|.)*?\\Q>>>>>>> \\E.+?(\\r\\n|\\r|\\n)", "");
    String devVersion = serializedConflictingAnnotation.replaceAll("\\Q<<<<<<< HEAD\\E(\\r\\n|\\r|\\n|.)*?\\Q=======\\E(\\r\\n|\\r|\\n)", "").replaceAll("\\Q>>>>>>> \\E.+?(\\r\\n|\\r|\\n)", "");
    JsonLdWebAnnotation masterVersionJsonLdWebAnnotation = new SerializationHelper<JsonLdWebAnnotation>().deserialize(masterVersion, JsonLdWebAnnotation.class);
    JsonLdWebAnnotation devVersionJsonLdWebAnnotation = new SerializationHelper<JsonLdWebAnnotation>().deserialize(devVersion, JsonLdWebAnnotation.class);
    List<TagReference> masterTagReferences = masterVersionJsonLdWebAnnotation.toTagReferenceList(projectId, collectionId);
    List<TagReference> devTagReferences = devVersionJsonLdWebAnnotation.toTagReferenceList(projectId, collectionId);
    AnnotationConflict annotationConflict = new AnnotationConflict(devTagReferences.get(0).getTagInstance(), devTagReferences, masterTagReferences.get(0).getTagInstance(), masterTagReferences);
    return annotationConflict;
}
Also used : AnnotationConflict(de.catma.project.conflict.AnnotationConflict) TagReference(de.catma.document.annotation.TagReference) JsonLdWebAnnotation(de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation)

Example 7 with JsonLdWebAnnotation

use of de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation in project catma by forTEXT.

the class GitMarkupCollectionHandler method getDeleteByUsAnnotationConflict.

private AnnotationConflict getDeleteByUsAnnotationConflict(String projectId, String collectionId, String serializedConflictingAnnotation) throws Exception {
    JsonLdWebAnnotation devVersionJsonLdWebAnnotation = new SerializationHelper<JsonLdWebAnnotation>().deserialize(serializedConflictingAnnotation, JsonLdWebAnnotation.class);
    List<TagReference> devTagReferences = devVersionJsonLdWebAnnotation.toTagReferenceList(projectId, collectionId);
    AnnotationConflict annotationConflict = new AnnotationConflict(devTagReferences.get(0).getTagInstance(), devTagReferences, null, Collections.emptyList());
    return annotationConflict;
}
Also used : AnnotationConflict(de.catma.project.conflict.AnnotationConflict) TagReference(de.catma.document.annotation.TagReference) JsonLdWebAnnotation(de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation)

Example 8 with JsonLdWebAnnotation

use of de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation in project catma by forTEXT.

the class GitMarkupCollectionHandler method getDeleteByThemAnnotationConflict.

private AnnotationConflict getDeleteByThemAnnotationConflict(String projectId, String collectionId, String serializedConflictingAnnotation) throws Exception {
    JsonLdWebAnnotation masterVersionJsonLdWebAnnotation = new SerializationHelper<JsonLdWebAnnotation>().deserialize(serializedConflictingAnnotation, JsonLdWebAnnotation.class);
    List<TagReference> masterTagReferences = masterVersionJsonLdWebAnnotation.toTagReferenceList(projectId, collectionId);
    AnnotationConflict annotationConflict = new AnnotationConflict(null, Collections.emptyList(), masterTagReferences.get(0).getTagInstance(), masterTagReferences);
    return annotationConflict;
}
Also used : AnnotationConflict(de.catma.project.conflict.AnnotationConflict) TagReference(de.catma.document.annotation.TagReference) JsonLdWebAnnotation(de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation)

Example 9 with JsonLdWebAnnotation

use of de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation in project catma by forTEXT.

the class GitProjectHandler method resolveAnnotationConflict.

public void resolveAnnotationConflict(String collectionId, AnnotationConflict annotationConflict, TagLibrary tagLibrary) throws Exception {
    try (ILocalGitRepositoryManager localRepoManager = this.localGitRepositoryManager) {
        GitMarkupCollectionHandler gitMarkupCollectionHandler = new GitMarkupCollectionHandler(localRepoManager, this.remoteGitServerManager, this.credentialsProvider);
        if (annotationConflict.getResolvedTagReferences().isEmpty()) {
            TagInstance tagInstance = annotationConflict.getDismissedTagInstance();
            gitMarkupCollectionHandler.removeTagInstances(projectId, collectionId, Collections.singleton(tagInstance.getUuid()));
        } else {
            JsonLdWebAnnotation annotation = new JsonLdWebAnnotation(CATMAPropertyKey.GitLabServerUrl.getValue(), projectId, annotationConflict.getResolvedTagReferences(), tagLibrary);
            gitMarkupCollectionHandler.createTagInstance(projectId, collectionId, annotation);
        }
    }
}
Also used : ILocalGitRepositoryManager(de.catma.repository.git.interfaces.ILocalGitRepositoryManager) JsonLdWebAnnotation(de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation)

Example 10 with JsonLdWebAnnotation

use of de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation in project catma by forTEXT.

the class GitProjectHandler method addOrUpdate.

public void addOrUpdate(String collectionId, Collection<TagReference> tagReferenceList, TagLibrary tagLibrary) throws IOException {
    try (ILocalGitRepositoryManager localRepoManager = this.localGitRepositoryManager) {
        GitMarkupCollectionHandler gitMarkupCollectionHandler = new GitMarkupCollectionHandler(localRepoManager, this.remoteGitServerManager, this.credentialsProvider);
        JsonLdWebAnnotation annotation = new JsonLdWebAnnotation(CATMAPropertyKey.GitLabServerUrl.getValue(), projectId, tagReferenceList, tagLibrary);
        gitMarkupCollectionHandler.createTagInstance(projectId, collectionId, annotation);
    }
}
Also used : ILocalGitRepositoryManager(de.catma.repository.git.interfaces.ILocalGitRepositoryManager) JsonLdWebAnnotation(de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation)

Aggregations

JsonLdWebAnnotation (de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation)10 TagReference (de.catma.document.annotation.TagReference)5 ILocalGitRepositoryManager (de.catma.repository.git.interfaces.ILocalGitRepositoryManager)4 File (java.io.File)4 AnnotationConflict (de.catma.project.conflict.AnnotationConflict)3 GitLabServerManagerTest (de.catma.repository.git.managers.GitLabServerManagerTest)2 JGitRepoManager (de.catma.repository.git.managers.JGitRepoManager)2 JsonLdWebAnnotationTest (de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotationTest)2 Test (org.junit.Test)2 Range (de.catma.document.Range)1 AnnotationCollection (de.catma.document.annotation.AnnotationCollection)1 ContentInfoSet (de.catma.document.source.ContentInfoSet)1 UserMarkupCollection (de.catma.document.standoffmarkup.usermarkup.UserMarkupCollection)1 SerializationHelper (de.catma.repository.git.serialization.SerializationHelper)1 GitMarkupCollectionHeader (de.catma.repository.git.serialization.models.GitMarkupCollectionHeader)1 Property (de.catma.tag.Property)1 TagInstance (de.catma.tag.TagInstance)1 TagsetDefinition (de.catma.tag.TagsetDefinition)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1