diff --git a/Jenkinsfile b/Jenkinsfile index e6a4c44155a..22bba2d0697 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -155,7 +155,7 @@ pipeline { } post { - success { + always { script { if (params.wipeWorkspaceAfterBuild) { echo "Wiping workspace..." diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/BeforeDocumentOpenedEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/BeforeDocumentOpenedEvent.java index 9161db21c16..d17ce5a7668 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/BeforeDocumentOpenedEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/BeforeDocumentOpenedEvent.java @@ -21,6 +21,7 @@ import org.springframework.context.ApplicationEvent; import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument; +import de.tudarmstadt.ukp.clarin.webanno.support.wicket.event.HybridApplicationUIEvent; /** * Fire BeforeDocumentOpenedEvent to give listeners a chance to look at or even modify the CAS @@ -29,6 +30,7 @@ */ public class BeforeDocumentOpenedEvent extends ApplicationEvent + implements HybridApplicationUIEvent { private static final long serialVersionUID = -4644605041626140906L; diff --git a/inception/inception-api/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/DocumentService.java b/inception/inception-api/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/DocumentService.java index 97e40767d4d..379e6e94c30 100644 --- a/inception/inception-api/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/DocumentService.java +++ b/inception/inception-api/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/DocumentService.java @@ -74,6 +74,15 @@ public interface DocumentService @PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_USER','ROLE_REMOTE')") SourceDocument createSourceDocument(SourceDocument document); + /** + * Check if any source document exist in the project. + * + * @param project + * the project. + * @return if any source document exists. + */ + boolean existsSourceDocument(Project project); + /** * Check if a Source document with this same name exist in the project. The caller method then * can decide to override or throw an exception/message to the client diff --git a/inception/inception-app-webapp/pom.xml b/inception/inception-app-webapp/pom.xml index f0269cea0c3..0f243f1f5f1 100644 --- a/inception/inception-app-webapp/pom.xml +++ b/inception/inception-app-webapp/pom.xml @@ -124,6 +124,10 @@ de.tudarmstadt.ukp.inception.app inception-project-initializers-sentencelabeling + + de.tudarmstadt.ukp.inception.app + inception-project-initializers-ud + de.tudarmstadt.ukp.inception.app inception-project-initializers-wikidatalinking @@ -926,6 +930,7 @@ de.tudarmstadt.ukp.inception.app:inception-project-initializers-basic de.tudarmstadt.ukp.inception.app:inception-project-initializers-doclabeling de.tudarmstadt.ukp.inception.app:inception-project-initializers-sentencelabeling + de.tudarmstadt.ukp.inception.app:inception-project-initializers-ud de.tudarmstadt.ukp.inception.app:inception-project-initializers-wikidatalinking de.tudarmstadt.ukp.inception.app:inception-brat-editor diff --git a/inception/inception-bom/pom.xml b/inception/inception-bom/pom.xml index 7c69053b404..20290df21f3 100644 --- a/inception/inception-bom/pom.xml +++ b/inception/inception-bom/pom.xml @@ -518,6 +518,11 @@ inception-project-initializers-sentencelabeling 30.0-SNAPSHOT + + de.tudarmstadt.ukp.inception.app + inception-project-initializers-ud + 30.0-SNAPSHOT + de.tudarmstadt.ukp.inception.app inception-project-initializers-wikidatalinking diff --git a/inception/inception-dependencies/pom.xml b/inception/inception-dependencies/pom.xml index b443d49ebe6..c576af31664 100644 --- a/inception/inception-dependencies/pom.xml +++ b/inception/inception-dependencies/pom.xml @@ -150,7 +150,7 @@ com.nimbusds nimbus-jose-jwt - 9.35 + 9.36 org.awaitility @@ -651,12 +651,12 @@ net.bytebuddy byte-buddy - 1.14.8 + 1.14.9 net.bytebuddy byte-buddy-agent - 1.14.8 + 1.14.9 org.wicketstuff diff --git a/inception/inception-documents/src/main/java/de/tudarmstadt/ukp/inception/documents/DocumentServiceImpl.java b/inception/inception-documents/src/main/java/de/tudarmstadt/ukp/inception/documents/DocumentServiceImpl.java index 42184519ae7..86c8b317ffe 100644 --- a/inception/inception-documents/src/main/java/de/tudarmstadt/ukp/inception/documents/DocumentServiceImpl.java +++ b/inception/inception-documents/src/main/java/de/tudarmstadt/ukp/inception/documents/DocumentServiceImpl.java @@ -122,6 +122,7 @@ import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument; import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocumentState; import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocumentStateTransition; +import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument_; import de.tudarmstadt.ukp.clarin.webanno.security.model.User; import de.tudarmstadt.ukp.clarin.webanno.support.logging.BaseLoggers; import de.tudarmstadt.ukp.inception.annotation.storage.CasStorageSession; @@ -321,6 +322,21 @@ public boolean existsCas(AnnotationDocument aAnnotationDocument) throws IOExcept return existsCas(aAnnotationDocument.getDocument(), aAnnotationDocument.getUser()); } + @Override + @Transactional + public boolean existsSourceDocument(Project aProject) + { + Validate.notNull(aProject, "Project must be specified"); + + var cb = entityManager.getCriteriaBuilder(); + var query = cb.createQuery(Long.class); + var doc = query.from(SourceDocument.class); + + query.select(cb.count(doc)).where(cb.equal(doc.get(SourceDocument_.project), aProject)); + + return entityManager.createQuery(query).getSingleResult() > 0; + } + @Override @Transactional public boolean existsSourceDocument(Project aProject, String aFileName) diff --git a/inception/inception-project-initializers-basic/pom.xml b/inception/inception-project-initializers-basic/pom.xml index b6975b2db8f..0e8af8c0039 100644 --- a/inception/inception-project-initializers-basic/pom.xml +++ b/inception/inception-project-initializers-basic/pom.xml @@ -58,6 +58,11 @@ inception-project-initializers + + org.apache.wicket + wicket-core + + org.springframework diff --git a/inception/inception-project-initializers-basic/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/basic/BasicProjectInitializer.java b/inception/inception-project-initializers-basic/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/basic/BasicProjectInitializer.java index b438bf5e5df..773c9293b56 100644 --- a/inception/inception-project-initializers-basic/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/basic/BasicProjectInitializer.java +++ b/inception/inception-project-initializers-basic/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/basic/BasicProjectInitializer.java @@ -18,9 +18,13 @@ package de.tudarmstadt.ukp.inception.project.initializers.basic; import java.io.IOException; +import java.lang.invoke.MethodHandles; import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import org.apache.wicket.request.resource.PackageResourceReference; +import org.apache.wicket.request.resource.ResourceReference; import org.springframework.context.ApplicationContext; import de.tudarmstadt.ukp.clarin.webanno.api.project.ProjectInitializer; @@ -37,6 +41,9 @@ public class BasicProjectInitializer implements QuickProjectInitializer { + private static final PackageResourceReference THUMBNAIL = new PackageResourceReference( + MethodHandles.lookup().lookupClass(), "thumbnail.svg"); + private final ApplicationContext context; public BasicProjectInitializer(ApplicationContext aContext) @@ -50,6 +57,18 @@ public String getName() return "Basic annotation (span/relation)"; } + @Override + public Optional getDescription() + { + return Optional.of("Create annotations on words and connect them using relations."); + } + + @Override + public Optional getThumbnail() + { + return Optional.of(THUMBNAIL); + } + @Override public boolean alreadyApplied(Project aProject) { diff --git a/inception/inception-project-initializers-basic/src/main/resources/de/tudarmstadt/ukp/inception/project/initializers/basic/thumbnail.svg b/inception/inception-project-initializers-basic/src/main/resources/de/tudarmstadt/ukp/inception/project/initializers/basic/thumbnail.svg new file mode 100644 index 00000000000..94d46694cee --- /dev/null +++ b/inception/inception-project-initializers-basic/src/main/resources/de/tudarmstadt/ukp/inception/project/initializers/basic/thumbnail.svg @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + I + like + Actor + Target + INCEpTION + + + + + diff --git a/inception/inception-project-initializers-doclabeling/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/doclabeling/BasicDocumentLabelingProjectInitializer.java b/inception/inception-project-initializers-doclabeling/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/doclabeling/BasicDocumentLabelingProjectInitializer.java index e731d5964d7..7bb54619f53 100644 --- a/inception/inception-project-initializers-doclabeling/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/doclabeling/BasicDocumentLabelingProjectInitializer.java +++ b/inception/inception-project-initializers-doclabeling/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/doclabeling/BasicDocumentLabelingProjectInitializer.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.List; +import java.util.Optional; import de.tudarmstadt.ukp.clarin.webanno.api.project.ProjectInitializer; import de.tudarmstadt.ukp.clarin.webanno.model.Project; @@ -64,7 +65,7 @@ public BasicDocumentLabelingProjectInitializer(PreferencesService aPreferencesSe @Override public String getName() { - return "Basic document labeling"; + return "Document classification"; } @Override @@ -114,4 +115,10 @@ public void configure(Project aProject) throws IOException matrixWorkloadExtension.writeTraits(traits, aProject); workloadManagementService.saveConfiguration(manager); } + + @Override + public Optional getDescription() + { + return Optional.of("Create document-classification annotations."); + } } diff --git a/inception/inception-project-initializers-sentencelabeling/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/sentencelabeling/SentenceLabelingProjectInitializer.java b/inception/inception-project-initializers-sentencelabeling/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/sentencelabeling/SentenceLabelingProjectInitializer.java index ce2feaa114b..f74e58b0721 100644 --- a/inception/inception-project-initializers-sentencelabeling/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/sentencelabeling/SentenceLabelingProjectInitializer.java +++ b/inception/inception-project-initializers-sentencelabeling/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/sentencelabeling/SentenceLabelingProjectInitializer.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.net.URL; import java.util.List; +import java.util.Optional; import org.apache.commons.io.IOUtils; @@ -44,7 +45,7 @@ public class SentenceLabelingProjectInitializer @Override public String getName() { - return "Basic sentence labeling"; + return "Sentence classification"; } @Override @@ -72,4 +73,10 @@ public void configure(Project aProject) throws IOException // project overview "\n" + IOUtils.toString(descriptionUrl, UTF_8)); } + + @Override + public Optional getDescription() + { + return Optional.of("Annotate documents at the sentence level."); + } } diff --git a/inception/inception-project-initializers-ud/LICENSE.txt b/inception/inception-project-initializers-ud/LICENSE.txt new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/inception/inception-project-initializers-ud/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/inception/inception-project-initializers-ud/pom.xml b/inception/inception-project-initializers-ud/pom.xml new file mode 100644 index 00000000000..f3b33a17a91 --- /dev/null +++ b/inception/inception-project-initializers-ud/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + + de.tudarmstadt.ukp.inception.app + inception-app + 30.0-SNAPSHOT + + inception-project-initializers-ud + INCEpTION - Core - Project initializers - Universal Dependencies + + + de.tudarmstadt.ukp.inception.app + inception-model + + + de.tudarmstadt.ukp.inception.app + inception-api + + + de.tudarmstadt.ukp.inception.app + inception-project-initializers + + + + org.springframework + spring-context + + + diff --git a/inception/inception-project-initializers-ud/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/ud/UniversalDependenciesProjectInitializer.java b/inception/inception-project-initializers-ud/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/ud/UniversalDependenciesProjectInitializer.java new file mode 100644 index 00000000000..03e9f6524e5 --- /dev/null +++ b/inception/inception-project-initializers-ud/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/ud/UniversalDependenciesProjectInitializer.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Technische Universität Darmstadt under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The Technische Universität Darmstadt + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.tudarmstadt.ukp.inception.project.initializers.ud; + +import static java.util.Arrays.asList; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import de.tudarmstadt.ukp.clarin.webanno.api.project.ProjectInitializer; +import de.tudarmstadt.ukp.clarin.webanno.model.Project; +import de.tudarmstadt.ukp.clarin.webanno.project.initializers.DependencyLayerInitializer; +import de.tudarmstadt.ukp.clarin.webanno.project.initializers.LemmaLayerInitializer; +import de.tudarmstadt.ukp.clarin.webanno.project.initializers.MorphologicalFeaturesLayerInitializer; +import de.tudarmstadt.ukp.clarin.webanno.project.initializers.PartOfSpeechLayerInitializer; +import de.tudarmstadt.ukp.clarin.webanno.project.initializers.QuickProjectInitializer; +import de.tudarmstadt.ukp.clarin.webanno.project.initializers.SurfaceFormLayerInitializer; +import de.tudarmstadt.ukp.clarin.webanno.project.initializers.TokenLayerInitializer; +import de.tudarmstadt.ukp.clarin.webanno.project.initializers.config.ProjectInitializersAutoConfiguration; + +/** + *

+ * This class is exposed as a Spring Component via + * {@link ProjectInitializersAutoConfiguration#standardProjectInitializer}. + *

+ */ +public class UniversalDependenciesProjectInitializer + implements QuickProjectInitializer +{ + @Override + public String getName() + { + return "Universal Dependencies"; + } + + @Override + public boolean alreadyApplied(Project aProject) + { + return false; + } + + @Override + public List> getDependencies() + { + return asList( + // Because all projects should have a Token layer + TokenLayerInitializer.class, // + LemmaLayerInitializer.class, // + PartOfSpeechLayerInitializer.class, // + MorphologicalFeaturesLayerInitializer.class, // + DependencyLayerInitializer.class, // + SurfaceFormLayerInitializer.class); + } + + @Override + public void configure(Project aProject) throws IOException + { + // Nothing to do - all initialization is already done by the dependencies + } + + @Override + public Optional getDescription() + { + return Optional + .of(""" + Comes pre-configured for linguistic annotation tasks according to the Universal Dependencies + guidelines. These include part-of-speech tagging, dependency parsing, morphological features, + lemmas, and surface forms. Importing and exporting these layers in the CoNLL-U format is + possible."""); + } +} diff --git a/inception/inception-ui-core/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/core/login/LoginPageCssResourceReference.java b/inception/inception-project-initializers-ud/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/ud/config/UniversalDependenciesProjectInitializersAutoConfiguration.java similarity index 52% rename from inception/inception-ui-core/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/core/login/LoginPageCssResourceReference.java rename to inception/inception-project-initializers-ud/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/ud/config/UniversalDependenciesProjectInitializersAutoConfiguration.java index 31fb099891f..03fcb7b8f79 100644 --- a/inception/inception-ui-core/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/core/login/LoginPageCssResourceReference.java +++ b/inception/inception-project-initializers-ud/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/ud/config/UniversalDependenciesProjectInitializersAutoConfiguration.java @@ -15,32 +15,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package de.tudarmstadt.ukp.clarin.webanno.ui.core.login; +package de.tudarmstadt.ukp.inception.project.initializers.ud.config; -import org.apache.wicket.request.resource.CssResourceReference; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; -public class LoginPageCssResourceReference - extends CssResourceReference -{ - private static final long serialVersionUID = 1L; - - private static final LoginPageCssResourceReference INSTANCE = new LoginPageCssResourceReference(); - - /** - * Gets the instance of the resource reference - * - * @return the single instance of the resource reference - */ - public static LoginPageCssResourceReference get() - { - return INSTANCE; - } +import de.tudarmstadt.ukp.inception.project.initializers.ud.UniversalDependenciesProjectInitializer; - /** - * Private constructor - */ - private LoginPageCssResourceReference() +@Configuration +public class UniversalDependenciesProjectInitializersAutoConfiguration +{ + @Bean + public UniversalDependenciesProjectInitializer universalDependenciesProjectInitializer() { - super(LoginPageCssResourceReference.class, "LoginPage.css"); + return new UniversalDependenciesProjectInitializer(); } } diff --git a/inception/inception-project-initializers-ud/src/main/resources/META-INF/spring.factories b/inception/inception-project-initializers-ud/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000000..15adaffec16 --- /dev/null +++ b/inception/inception-project-initializers-ud/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +de.tudarmstadt.ukp.inception.project.initializers.ud.config.UniversalDependenciesProjectInitializersAutoConfiguration diff --git a/inception/inception-project-initializers-wikidatalinking/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/wikidatalinking/EntityLinkingProjectInitializer.java b/inception/inception-project-initializers-wikidatalinking/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/wikidatalinking/EntityLinkingProjectInitializer.java index 7e568cc07d9..26bd1593ab3 100644 --- a/inception/inception-project-initializers-wikidatalinking/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/wikidatalinking/EntityLinkingProjectInitializer.java +++ b/inception/inception-project-initializers-wikidatalinking/src/main/java/de/tudarmstadt/ukp/inception/project/initializers/wikidatalinking/EntityLinkingProjectInitializer.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.springframework.context.ApplicationContext; @@ -90,4 +91,10 @@ public void configure(Project aProject) throws IOException valueFeature.setEnabled(false); annotationService.createFeature(valueFeature); } + + @Override + public Optional getDescription() + { + return Optional.of("Link entity mentions to WikiData."); + } } diff --git a/inception/inception-project-initializers/pom.xml b/inception/inception-project-initializers/pom.xml index 8f533045532..31fde127d25 100644 --- a/inception/inception-project-initializers/pom.xml +++ b/inception/inception-project-initializers/pom.xml @@ -46,6 +46,11 @@ inception-support
+ + org.apache.wicket + wicket-core + + org.springframework diff --git a/inception/inception-project-initializers/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/initializers/QuickProjectInitializer.java b/inception/inception-project-initializers/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/initializers/QuickProjectInitializer.java index 16e6deb4923..e283bec5cb1 100644 --- a/inception/inception-project-initializers/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/initializers/QuickProjectInitializer.java +++ b/inception/inception-project-initializers/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/initializers/QuickProjectInitializer.java @@ -17,6 +17,10 @@ */ package de.tudarmstadt.ukp.clarin.webanno.project.initializers; +import java.util.Optional; + +import org.apache.wicket.request.resource.ResourceReference; + import de.tudarmstadt.ukp.clarin.webanno.api.project.ProjectInitializer; public interface QuickProjectInitializer @@ -27,4 +31,14 @@ default boolean applyByDefault() { return false; } + + default Optional getDescription() + { + return Optional.empty(); + } + + default Optional getThumbnail() + { + return Optional.empty(); + } } diff --git a/inception/inception-project-initializers/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/initializers/StandardProjectInitializer.java b/inception/inception-project-initializers/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/initializers/StandardProjectInitializer.java index ca47879dbbb..666c592ad35 100644 --- a/inception/inception-project-initializers/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/initializers/StandardProjectInitializer.java +++ b/inception/inception-project-initializers/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/initializers/StandardProjectInitializer.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; @@ -49,7 +50,7 @@ public StandardProjectInitializer(@Lazy ProjectService aProjectService) @Override public String getName() { - return "Standard project"; + return "Everything but the kitchen sink"; } @Override @@ -73,4 +74,10 @@ public void configure(Project aProject) throws IOException { // Nothing to do - all initialization is already done by the dependencies } + + @Override + public Optional getDescription() + { + return Optional.of("Comes pre-configured for many linguistic annotation tasks."); + } } diff --git a/inception/inception-project-initializers/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/initializers/empty/EmptyProjectInitializer.java b/inception/inception-project-initializers/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/initializers/empty/EmptyProjectInitializer.java index 9b114352d71..c5d387798ab 100644 --- a/inception/inception-project-initializers/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/initializers/empty/EmptyProjectInitializer.java +++ b/inception/inception-project-initializers/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/initializers/empty/EmptyProjectInitializer.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.List; +import java.util.Optional; import de.tudarmstadt.ukp.clarin.webanno.api.project.ProjectInitializer; import de.tudarmstadt.ukp.clarin.webanno.model.Project; @@ -41,7 +42,7 @@ public class EmptyProjectInitializer @Override public String getName() { - return "Empty project (no layers)"; + return "Blank project (no layers)"; } @Override @@ -67,7 +68,13 @@ public List> getDependencies() @Override public void configure(Project aProject) throws IOException { - aProject.setDescription("This project has no pre-defined layers. You will only be able to " + aProject.setDescription(getDescription().get()); + } + + @Override + public Optional getDescription() + { + return Optional.of("This project has no pre-defined layers. You will only be able to " + "annotate after you have defined annotation layers in the project settings."); } } diff --git a/inception/inception-support/src/main/java/de/tudarmstadt/ukp/clarin/webanno/support/wicket/event/HybridApplicationUIEventRouter.java b/inception/inception-support/src/main/java/de/tudarmstadt/ukp/clarin/webanno/support/wicket/event/HybridApplicationUIEventRouter.java index 64a622fe7f9..7ce951b4da8 100644 --- a/inception/inception-support/src/main/java/de/tudarmstadt/ukp/clarin/webanno/support/wicket/event/HybridApplicationUIEventRouter.java +++ b/inception/inception-support/src/main/java/de/tudarmstadt/ukp/clarin/webanno/support/wicket/event/HybridApplicationUIEventRouter.java @@ -23,6 +23,7 @@ import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.event.Broadcast; import org.apache.wicket.feedback.IFeedback; +import org.apache.wicket.request.RequestHandlerExecutor.ReplaceHandlerException; import org.apache.wicket.request.cycle.RequestCycle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,12 +67,18 @@ public void routeEvent(HybridApplicationUIEvent aEvent) try { page.send(page, Broadcast.BREADTH, aEvent); } + catch (ReplaceHandlerException e) { + throw e; + } catch (Throwable e) { log.error("Exception while processing UI-routed event", e); page.error("Exception while processing UI-routed event: " + e.getMessage()); handler.get().addChildren(page, IFeedback.class); } } + catch (ReplaceHandlerException e) { + throw e; + } catch (Throwable e) { log.error("Unable to route event to UI", e); } diff --git a/inception/inception-support/src/main/java/de/tudarmstadt/ukp/inception/support/svelte/SvelteBehavior.java b/inception/inception-support/src/main/java/de/tudarmstadt/ukp/inception/support/svelte/SvelteBehavior.java index 45ea5910bfc..bcb3f26cb48 100644 --- a/inception/inception-support/src/main/java/de/tudarmstadt/ukp/inception/support/svelte/SvelteBehavior.java +++ b/inception/inception-support/src/main/java/de/tudarmstadt/ukp/inception/support/svelte/SvelteBehavior.java @@ -51,37 +51,56 @@ public class SvelteBehavior private ResourceReference jsRef; private ResourceReference cssRef; + private Component markupHost; private Component host; public SvelteBehavior() { - this(null); + this(null, null); } - public SvelteBehavior(ResourceReference aRef) + public SvelteBehavior(Component aHost) { - jsRef = aRef; + host = aHost; + host.setOutputMarkupId(true); + var componentClass = host.getClass(); + jsRef = new PackageResourceReference(componentClass, + componentClass.getSimpleName() + ".min.js"); + cssRef = new PackageResourceReference(componentClass, + componentClass.getSimpleName() + ".min.css"); + } + + public SvelteBehavior(ResourceReference aJsRef, ResourceReference aCssRef) + { + jsRef = aJsRef; + cssRef = aCssRef; } @Override public void bind(Component aComponent) { - if (host != null && host != aComponent) { + if (markupHost != null && markupHost != aComponent) { throw new IllegalStateException("Behavior already bound to another component"); } - host = aComponent; + markupHost = aComponent; - aComponent.setOutputMarkupId(true); + if (host != null) { + return; + } + + host = aComponent; + host.setOutputMarkupId(true); - var componentClass = aComponent.getClass(); + var componentClass = host.getClass(); if (jsRef == null) { jsRef = new PackageResourceReference(componentClass, componentClass.getSimpleName() + ".min.js"); } - if (componentClass.getResource(componentClass.getSimpleName() + ".min.css") != null) { + if (cssRef == null + & componentClass.getResource(componentClass.getSimpleName() + ".min.css") != null) { cssRef = new PackageResourceReference(componentClass, componentClass.getSimpleName() + ".min.css"); } @@ -114,7 +133,7 @@ private CharSequence initScript(Component aComponent) IRequestHandler handler = new ResourceReferenceRequestHandler(jsRef); String url = RequestCycle.get().urlFor(handler).toString(); - Object model = aComponent.getDefaultModelObject(); + Object model = host.getDefaultModelObject(); String propsJson; try { propsJson = model != null ? toInterpretableJsonString(model) : "{}"; diff --git a/inception/inception-ui-core/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/core/login/LoginPage.html b/inception/inception-ui-core/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/core/login/LoginPage.html index a46de32ba17..27d1a71dca1 100644 --- a/inception/inception-ui-core/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/core/login/LoginPage.html +++ b/inception/inception-ui-core/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/core/login/LoginPage.html @@ -17,48 +17,85 @@ limitations under the License. --> - - -
-
-