Skip to content

Commit

Permalink
Merge pull request #4234 from inception-project/feature/4229-Better-p…
Browse files Browse the repository at this point in the history
…roject-template-selection

#4229 - Better project template selection
  • Loading branch information
reckart authored Oct 8, 2023
2 parents 82fe61f + 0232978 commit a8cd50e
Show file tree
Hide file tree
Showing 39 changed files with 1,253 additions and 209 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pipeline {
}

post {
success {
always {
script {
if (params.wipeWorkspaceAfterBuild) {
echo "Wiping workspace..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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
Expand Down
5 changes: 5 additions & 0 deletions inception/inception-app-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@
<groupId>de.tudarmstadt.ukp.inception.app</groupId>
<artifactId>inception-project-initializers-sentencelabeling</artifactId>
</dependency>
<dependency>
<groupId>de.tudarmstadt.ukp.inception.app</groupId>
<artifactId>inception-project-initializers-ud</artifactId>
</dependency>
<dependency>
<groupId>de.tudarmstadt.ukp.inception.app</groupId>
<artifactId>inception-project-initializers-wikidatalinking</artifactId>
Expand Down Expand Up @@ -926,6 +930,7 @@
<usedDependency>de.tudarmstadt.ukp.inception.app:inception-project-initializers-basic</usedDependency>
<usedDependency>de.tudarmstadt.ukp.inception.app:inception-project-initializers-doclabeling</usedDependency>
<usedDependency>de.tudarmstadt.ukp.inception.app:inception-project-initializers-sentencelabeling</usedDependency>
<usedDependency>de.tudarmstadt.ukp.inception.app:inception-project-initializers-ud</usedDependency>
<usedDependency>de.tudarmstadt.ukp.inception.app:inception-project-initializers-wikidatalinking</usedDependency>
<!-- INCEpTION annotation editor modules - used via Spring -->
<usedDependency>de.tudarmstadt.ukp.inception.app:inception-brat-editor</usedDependency>
Expand Down
5 changes: 5 additions & 0 deletions inception/inception-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,11 @@
<artifactId>inception-project-initializers-sentencelabeling</artifactId>
<version>30.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.tudarmstadt.ukp.inception.app</groupId>
<artifactId>inception-project-initializers-ud</artifactId>
<version>30.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.tudarmstadt.ukp.inception.app</groupId>
<artifactId>inception-project-initializers-wikidatalinking</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,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;
Expand Down Expand Up @@ -322,6 +323,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)
Expand Down
5 changes: 5 additions & 0 deletions inception/inception-project-initializers-basic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
<artifactId>inception-project-initializers</artifactId>
</dependency>

<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
</dependency>

<!-- Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -50,6 +57,18 @@ public String getName()
return "Basic annotation (span/relation)";
}

@Override
public Optional<String> getDescription()
{
return Optional.of("Create annotations on words and connect them using relations.");
}

@Override
public Optional<ResourceReference> getThumbnail()
{
return Optional.of(THUMBNAIL);
}

@Override
public boolean alreadyApplied(Project aProject)
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -64,7 +65,7 @@ public BasicDocumentLabelingProjectInitializer(PreferencesService aPreferencesSe
@Override
public String getName()
{
return "Basic document labeling";
return "Document classification";
}

@Override
Expand Down Expand Up @@ -114,4 +115,10 @@ public void configure(Project aProject) throws IOException
matrixWorkloadExtension.writeTraits(traits, aProject);
workloadManagementService.saveConfiguration(manager);
}

@Override
public Optional<String> getDescription()
{
return Optional.of("Create document-classification annotations.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -44,7 +45,7 @@ public class SentenceLabelingProjectInitializer
@Override
public String getName()
{
return "Basic sentence labeling";
return "Sentence classification";
}

@Override
Expand Down Expand Up @@ -72,4 +73,10 @@ public void configure(Project aProject) throws IOException
// project overview
"\n" + IOUtils.toString(descriptionUrl, UTF_8));
}

@Override
public Optional<String> getDescription()
{
return Optional.of("Annotate documents at the sentence level.");
}
}
Loading

0 comments on commit a8cd50e

Please sign in to comment.