private void exportSourceDocuments(Project aProject, ExportedProject exProject) { List<ExportedSourceDocument> sourceDocuments = new ArrayList<>(); // add source documents to a project List<SourceDocument> documents = documentService.listSourceDocuments(aProject); for (SourceDocument sourceDocument : documents) { ExportedSourceDocument exDocument = new ExportedSourceDocument(); exDocument.setFormat(sourceDocument.getFormat()); exDocument.setName(sourceDocument.getName()); exDocument.setState(sourceDocument.getState()); exDocument.setTimestamp(sourceDocument.getTimestamp()); exDocument.setSentenceAccessed(sourceDocument.getSentenceAccessed()); exDocument.setCreated(sourceDocument.getCreated()); exDocument.setUpdated(sourceDocument.getUpdated()); sourceDocuments.add(exDocument); } exProject.setSourceDocuments(sourceDocuments); }
@Override public void exportData(ProjectExportRequest aRequest, ExportedProject aExProject, File aStage) throws Exception { List<ExportedTagSet> extTagSets = new ArrayList<>(); for (TagSet tagSet : annotationService.listTagSets(aRequest.getProject())) { ExportedTagSet exTagSet = new ExportedTagSet(); exTagSet.setCreateTag(tagSet.isCreateTag()); exTagSet.setDescription(tagSet.getDescription()); exTagSet.setLanguage(tagSet.getLanguage()); exTagSet.setName(tagSet.getName()); List<ExportedTag> exTags = new ArrayList<>(); for (Tag tag : annotationService.listTags(tagSet)) { ExportedTag exTag = new ExportedTag(); exTag.setDescription(tag.getDescription()); exTag.setName(tag.getName()); exTags.add(exTag); } exTagSet.setTags(exTags); extTagSets.add(exTagSet); } aExProject.setTagSets(extTagSets); }
private void exportAnnotationDocuments(Project aProject, ExportedProject aExProject) { List<ExportedAnnotationDocument> annotationDocuments = new ArrayList<>(); // add source documents to a project List<SourceDocument> documents = documentService.listSourceDocuments(aProject); for (SourceDocument sourceDocument : documents) { // add annotation document to Project for (AnnotationDocument annotationDocument : documentService .listAnnotationDocuments(sourceDocument)) { ExportedAnnotationDocument exAnnotationDocument = new ExportedAnnotationDocument(); exAnnotationDocument.setName(annotationDocument.getName()); exAnnotationDocument.setState(annotationDocument.getState()); exAnnotationDocument.setUser(annotationDocument.getUser()); exAnnotationDocument.setTimestamp(annotationDocument.getTimestamp()); exAnnotationDocument.setSentenceAccessed(annotationDocument.getSentenceAccessed()); exAnnotationDocument.setCreated(annotationDocument.getCreated()); exAnnotationDocument.setUpdated(annotationDocument.getUpdated()); annotationDocuments.add(exAnnotationDocument); } } aExProject.setAnnotationDocuments(annotationDocuments); }
private void importTagSet(TagSet aTagSet, ExportedTagSet aExTagSet, Project aProject) throws IOException { // aTagSet is a parameter because we want to use this also in the project settings // panel and have the ability there to merge imported tags into an existing tagset aTagSet.setCreateTag(aExTagSet.isCreateTag()); aTagSet.setDescription(aExTagSet.getDescription()); aTagSet.setLanguage(aExTagSet.getLanguage()); aTagSet.setName(aExTagSet.getName()); aTagSet.setProject(aProject); annotationService.createTagSet(aTagSet); for (ExportedTag exTag : aExTagSet.getTags()) { // do not duplicate tag if (annotationService.existsTag(exTag.getName(), aTagSet)) { continue; } Tag tag = new Tag(); tag.setDescription(exTag.getDescription()); tag.setTagSet(aTagSet); tag.setName(exTag.getName()); annotationService.createTag(tag); } } }
for (ExportedAnnotationLayer exLayer : aExProject.getLayers()) { if (annotationService.existsLayer(exLayer.getName(), exLayer.getType(), aProject)) { AnnotationLayer layer = annotationService.getLayer(exLayer.getName(), aProject); importLayer(layer, exLayer, aProject); for (ExportedAnnotationFeature exfeature : exLayer.getFeatures()) { if (annotationService.existsFeature(exfeature.getName(), layer)) { AnnotationFeature feature = annotationService.getFeature( exfeature.getName(), layer); importFeature(feature, exfeature, aProject); continue; AnnotationLayer layer = new AnnotationLayer(); importLayer(layer, exLayer, aProject); for (ExportedAnnotationFeature exfeature : exLayer.getFeatures()) { AnnotationFeature feature = new AnnotationFeature(); feature.setLayer(layer); for (ExportedAnnotationLayer exLayer : aExProject.getLayers()) { if (exLayer.getAttachType() != null) { AnnotationLayer layer = annotationService.getLayer(exLayer.getName(), aProject); AnnotationLayer attachLayer = annotationService.getLayer(exLayer.getAttachType() .getName(), aProject); layer.setAttachType(attachLayer); if (exLayer.getAttachFeature() != null) { AnnotationFeature attachFeature = annotationService .getFeature(exLayer.getAttachFeature().getName(), attachLayer); layer.setAttachFeature(attachFeature);
/** * Create s {@link SourceDocument} from the exported {@link SourceDocument} * * @param aImportedProjectSetting * the exported project. * @param aImportedProject * the project. * @throws IOException * if an I/O error occurs. */ private void importSourceDocuments(ExportedProject aImportedProjectSetting, Project aImportedProject) throws IOException { for (ExportedSourceDocument importedSourceDocument : aImportedProjectSetting .getSourceDocuments()) { SourceDocument sourceDocument = new SourceDocument(); sourceDocument.setFormat(importedSourceDocument.getFormat()); sourceDocument.setName(importedSourceDocument.getName()); sourceDocument.setState(importedSourceDocument.getState()); sourceDocument.setProject(aImportedProject); sourceDocument.setTimestamp(importedSourceDocument.getTimestamp()); sourceDocument.setSentenceAccessed(importedSourceDocument.getSentenceAccessed()); sourceDocument.setCreated(importedSourceDocument.getCreated()); sourceDocument.setUpdated(importedSourceDocument.getUpdated()); documentService.createSourceDocument(sourceDocument); } }
.getAnnotationDocuments()) { AnnotationDocument annotationDocument = new AnnotationDocument(); annotationDocument.setName(exAnnotationDocument.getName()); annotationDocument.setState(exAnnotationDocument.getState()); annotationDocument.setProject(aProject); annotationDocument.setUser(exAnnotationDocument.getUser()); annotationDocument.setTimestamp(exAnnotationDocument.getTimestamp()); annotationDocument.setDocument(documentService.getSourceDocument(aProject, exAnnotationDocument.getName())); annotationDocument.setSentenceAccessed(exAnnotationDocument.getSentenceAccessed()); annotationDocument.setCreated(exAnnotationDocument.getCreated()); annotationDocument.setUpdated(exAnnotationDocument.getUpdated()); documentService.createAnnotationDocument(annotationDocument);
layerToExLayers.get(layer).setAttachType( new ExportedAnnotationLayerReference(layer.getAttachType().getName())); layerToExLayers.get(layer).setAttachFeature( new ExportedAnnotationFeatureReference(layer.getAttachFeature())); aExProject.setLayers(exLayers);
/** * Create {@link ProjectPermission} from the exported * {@link de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedProjectPermission} * * @param aImportedProjectSetting * the imported project. * @param aImportedProject * the project. * @throws IOException * if an I/O error occurs. */ @Deprecated private void createProjectPermission( de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedProject aImportedProjectSetting, Project aImportedProject) throws IOException { for (ExportedProjectPermission importedPermission : aImportedProjectSetting .getProjectPermissions()) { ProjectPermission permission = new ProjectPermission(); permission.setLevel(importedPermission.getLevel()); permission.setProject(aImportedProject); permission.setUser(importedPermission.getUser()); createProjectPermission(permission); } }
@Override public void importData(ProjectImportRequest aRequest, Project aProject, ExportedProject aExProject, ZipFile aZip) throws Exception { // this is projects prior to version 2.0 if (aExProject.getVersion() == 0) { importTagSetsV0(aProject, aExProject); } else { for (ExportedTagSet exTagSet : aExProject.getTagSets()) { importTagSet(new TagSet(), exTagSet, aProject); } } }
@Override public void exportData(ProjectExportRequest aRequest, ExportedProject aExProject, File aStage) throws Exception { List<ExportedTagSet> extTagSets = new ArrayList<>(); for (TagSet tagSet : annotationService.listTagSets(aRequest.getProject())) { ExportedTagSet exTagSet = new ExportedTagSet(); exTagSet.setCreateTag(tagSet.isCreateTag()); exTagSet.setDescription(tagSet.getDescription()); exTagSet.setLanguage(tagSet.getLanguage()); exTagSet.setName(tagSet.getName()); List<ExportedTag> exTags = new ArrayList<>(); for (Tag tag : annotationService.listTags(tagSet)) { ExportedTag exTag = new ExportedTag(); exTag.setDescription(tag.getDescription()); exTag.setName(tag.getName()); exTags.add(exTag); } exTagSet.setTags(exTags); extTagSets.add(exTagSet); } aExProject.setTagSets(extTagSets); }
private void importTagSet(TagSet aTagSet, ExportedTagSet aExTagSet, Project aProject) throws IOException { // aTagSet is a parameter because we want to use this also in the project settings // panel and have the ability there to merge imported tags into an existing tagset aTagSet.setCreateTag(aExTagSet.isCreateTag()); aTagSet.setDescription(aExTagSet.getDescription()); aTagSet.setLanguage(aExTagSet.getLanguage()); aTagSet.setName(aExTagSet.getName()); aTagSet.setProject(aProject); annotationService.createTagSet(aTagSet); for (ExportedTag exTag : aExTagSet.getTags()) { // do not duplicate tag if (annotationService.existsTag(exTag.getName(), aTagSet)) { continue; } Tag tag = new Tag(); tag.setDescription(exTag.getDescription()); tag.setTagSet(aTagSet); tag.setName(exTag.getName()); annotationService.createTag(tag); } } }
private void exportSourceDocuments(Project aProject, ExportedProject exProject) { List<ExportedSourceDocument> sourceDocuments = new ArrayList<>(); // add source documents to a project List<SourceDocument> documents = documentService.listSourceDocuments(aProject); for (SourceDocument sourceDocument : documents) { ExportedSourceDocument exDocument = new ExportedSourceDocument(); exDocument.setFormat(sourceDocument.getFormat()); exDocument.setName(sourceDocument.getName()); exDocument.setState(sourceDocument.getState()); exDocument.setTimestamp(sourceDocument.getTimestamp()); exDocument.setSentenceAccessed(sourceDocument.getSentenceAccessed()); exDocument.setCreated(sourceDocument.getCreated()); exDocument.setUpdated(sourceDocument.getUpdated()); sourceDocuments.add(exDocument); } exProject.setSourceDocuments(sourceDocuments); }
/** * Create s {@link SourceDocument} from the exported {@link SourceDocument} * * @param aImportedProjectSetting * the exported project. * @param aImportedProject * the project. * @throws IOException * if an I/O error occurs. */ private void importSourceDocuments(ExportedProject aImportedProjectSetting, Project aImportedProject) throws IOException { for (ExportedSourceDocument importedSourceDocument : aImportedProjectSetting .getSourceDocuments()) { SourceDocument sourceDocument = new SourceDocument(); sourceDocument.setFormat(importedSourceDocument.getFormat()); sourceDocument.setName(importedSourceDocument.getName()); sourceDocument.setState(importedSourceDocument.getState()); sourceDocument.setProject(aImportedProject); sourceDocument.setTimestamp(importedSourceDocument.getTimestamp()); sourceDocument.setSentenceAccessed(importedSourceDocument.getSentenceAccessed()); sourceDocument.setCreated(importedSourceDocument.getCreated()); sourceDocument.setUpdated(importedSourceDocument.getUpdated()); documentService.createSourceDocument(sourceDocument); } }
.getAnnotationDocuments()) { AnnotationDocument annotationDocument = new AnnotationDocument(); annotationDocument.setName(exAnnotationDocument.getName()); annotationDocument.setState(exAnnotationDocument.getState()); annotationDocument.setProject(aProject); annotationDocument.setUser(exAnnotationDocument.getUser()); annotationDocument.setTimestamp(exAnnotationDocument.getTimestamp()); annotationDocument.setDocument(documentService.getSourceDocument(aProject, exAnnotationDocument.getName())); annotationDocument.setSentenceAccessed(exAnnotationDocument.getSentenceAccessed()); annotationDocument.setCreated(exAnnotationDocument.getCreated()); annotationDocument.setUpdated(exAnnotationDocument.getUpdated()); documentService.createAnnotationDocument(annotationDocument);
/** * Create {@link ProjectPermission} from the exported * {@link de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedProjectPermission} * * @param aImportedProjectSetting * the imported project. * @param aImportedProject * the project. * @throws IOException * if an I/O error occurs. */ @Deprecated private void createProjectPermission( de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedProject aImportedProjectSetting, Project aImportedProject) throws IOException { for (ExportedProjectPermission importedPermission : aImportedProjectSetting .getProjectPermissions()) { ProjectPermission permission = new ProjectPermission(); permission.setLevel(importedPermission.getLevel()); permission.setProject(aImportedProject); permission.setUser(importedPermission.getUser()); createProjectPermission(permission); } }
@Override public void importData(ProjectImportRequest aRequest, Project aProject, ExportedProject aExProject, ZipFile aZip) throws Exception { // this is projects prior to version 2.0 if (aExProject.getVersion() == 0) { importTagSetsV0(aProject, aExProject); } else { for (ExportedTagSet exTagSet : aExProject.getTagSets()) { importTagSet(new TagSet(), exTagSet, aProject); } } }
@Deprecated public static void createTagSet(TagSet aTagSet, ExportedTagSet aExTagSet, Project aProject, User aUser, AnnotationSchemaService aAnnotationService) throws IOException { aTagSet.setCreateTag(aExTagSet.isCreateTag()); aTagSet.setDescription(aExTagSet.getDescription()); aTagSet.setLanguage(aExTagSet.getLanguage()); aTagSet.setName(aExTagSet.getName()); aTagSet.setProject(aProject); aAnnotationService.createTagSet(aTagSet); for (ExportedTag exTag : aExTagSet.getTags()) { // do not duplicate tag if (aAnnotationService.existsTag(exTag.getName(), aTagSet)) { continue; } Tag tag = new Tag(); tag.setDescription(exTag.getDescription()); tag.setTagSet(aTagSet); tag.setName(exTag.getName()); aAnnotationService.createTag(tag); } }
private static TagSet replaceTagSet(Project project, ExportedTagSet importedTagSet, AnnotationSchemaService aAnnotationService) throws IOException { String importedTagSetName = importedTagSet.getName(); de.tudarmstadt.ukp.clarin.webanno.model.TagSet tagsetInUse = aAnnotationService .getTagSet(importedTagSetName, project); // Remove all tags associated with Tagset aAnnotationService.removeAllTags(tagsetInUse); // Copy and update TagSet Information from imported tagset tagsetInUse.setDescription(importedTagSet.getDescription()); tagsetInUse.setName(importedTagSetName); tagsetInUse.setLanguage(importedTagSet.getLanguage()); tagsetInUse.setProject(project); aAnnotationService.createTagSet(tagsetInUse); // Add all tags from imported tagset for (ExportedTag tag : importedTagSet.getTags()) { Tag newTag = new Tag(); newTag.setDescription(tag.getDescription()); newTag.setName(tag.getName()); newTag.setTagSet(tagsetInUse); aAnnotationService.createTag(newTag); } return tagsetInUse; }
private static TagSet replaceTagSet(Project project, ExportedTagSet importedTagSet, AnnotationSchemaService aAnnotationService) throws IOException { String importedTagSetName = importedTagSet.getName(); de.tudarmstadt.ukp.clarin.webanno.model.TagSet tagsetInUse = aAnnotationService .getTagSet(importedTagSetName, project); // Remove all tags associated with Tagset aAnnotationService.removeAllTags(tagsetInUse); // Copy and update TagSet Information from imported tagset tagsetInUse.setDescription(importedTagSet.getDescription()); tagsetInUse.setName(importedTagSetName); tagsetInUse.setLanguage(importedTagSet.getLanguage()); tagsetInUse.setProject(project); aAnnotationService.createTagSet(tagsetInUse); // Add all tags from imported tagset for (ExportedTag tag : importedTagSet.getTags()) { Tag newTag = new Tag(); newTag.setDescription(tag.getDescription()); newTag.setName(tag.getName()); newTag.setTagSet(tagsetInUse); aAnnotationService.createTag(newTag); } return tagsetInUse; }