Skip to content

Commit

Permalink
#3611 - Upgrade to Spring 6, Boot 3, Wicket 10, etc.
Browse files Browse the repository at this point in the history
- Remove some deprecated and unused APIs
- Move a DB query to the criteria API as the string-based query no longer worked with Hibernate 6
- Fixed bug in hibernate integer enum type
- Use SnakeYAML 1.33 for some tests because DKPro Core Dataset doesn't work with SnakeYAML 2.0 atm
  • Loading branch information
reckart committed Jun 13, 2023
1 parent d6fccd5 commit 1a3d43a
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,29 +381,6 @@ List<Project> listProjectsWithUserHavingRole(User aUser, PermissionLevel aRole,
*/
List<Project> listManageableProjects(User aUser);

/**
* List projects in which the given user is curator or manager
*
* @return list of projects manageable by the user.
* @deprecated Use
* {{@link #listProjectsWithUserHavingRole(User, PermissionLevel, PermissionLevel...)}}
* instead.
*/
@SuppressWarnings("javadoc")
@Deprecated
List<Project> listManageableCuratableProjects(User aUser);

/**
* @return list of projects that allow calculation of pairwise agreement. That means it lists
* all projects where there are at least two annotators.
*
* @deprecated To be removed without replacement
*/
@Deprecated
List<Project> listProjectsForAgreement();

File getProjectFolder(Project aProject);

/**
* Export the associated project log for this {@link Project} while copying a project
*
Expand Down Expand Up @@ -444,45 +421,6 @@ void savePropertiesFile(Project aProject, InputStream aInputStream, String aFile
*/
public boolean managesAnyProject(User aUser);

/**
* Determine if the user is allowed to update a project.
*
* @param aProject
* the project
* @param aUser
* the user.
* @return if the user may update a project.
* @deprecated Use {@link #hasRole(User, Project, PermissionLevel, PermissionLevel...)}
*/
@Deprecated
boolean isManager(Project aProject, User aUser);

/**
* Determine if the user is a curator or not.
*
* @param aProject
* the project.
* @param aUser
* the user.
* @return if the user is a curator.
* @deprecated Use {@link #hasRole(User, Project, PermissionLevel, PermissionLevel...)}
*/
@Deprecated
boolean isCurator(Project aProject, User aUser);

/**
* Determine if the User is member of a project
*
* @param aProject
* the project.
* @param aUser
* the user.
* @return if the user is a member.
* @deprecated Use {@link #hasRole(User, Project, PermissionLevel, PermissionLevel...)}
*/
@Deprecated
boolean isAnnotator(Project aProject, User aUser);

/**
* Check whether the given user has any role at all in the given project.
*
Expand Down
10 changes: 10 additions & 0 deletions inception/inception-concept-linking/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@
<artifactId>dkpro-core-io-conll-asl</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<!-- DKPro Core Datasets isn't compatible with SnakeYAML 2.0 atm -->
<version>1.33</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
Expand All @@ -242,6 +250,8 @@
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredDependencies>
<!-- DKPro Core Datasets isn't compatible with SnakeYAML 2.0 atm -->
<ignoredDependency>org.yaml:snakeyaml</ignoredDependency>
<!-- Dependency analysis does not get it... -->
<ignoredDependency>org.danekja:jdk-serializable-functional</ignoredDependency>
<ignoredDependency>javax.persistence:javax.persistence-api</ignoredDependency>
Expand Down
26 changes: 26 additions & 0 deletions inception/inception-example-imls-data-majority/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,31 @@
<artifactId>dkpro-core-io-conll-asl</artifactId>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<!-- DKPro Core Datasets isn't compatible with SnakeYAML 2.0 atm -->
<version>1.33</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredDependencies>
<!-- DKPro Core Datasets isn't compatible with SnakeYAML 2.0 atm -->
<ignoredDependency>org.yaml:snakeyaml</ignoredDependency>
</ignoredDependencies>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
10 changes: 10 additions & 0 deletions inception/inception-imls-external/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@
<artifactId>dkpro-core-api-ner-asl</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<!-- DKPro Core Datasets isn't compatible with SnakeYAML 2.0 atm -->
<version>1.33</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -160,6 +168,8 @@
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredDependencies>
<!-- DKPro Core Datasets isn't compatible with SnakeYAML 2.0 atm -->
<ignoredDependency>org.yaml:snakeyaml</ignoredDependency>
<!-- Plugin does not get it -->
<ignoredDependency>com.fasterxml.jackson.core:jackson-core</ignoredDependency>
</ignoredDependencies>
Expand Down
24 changes: 24 additions & 0 deletions inception/inception-imls-opennlp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,29 @@
<artifactId>dkpro-core-api-io-asl</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<!-- DKPro Core Datasets isn't compatible with SnakeYAML 2.0 atm -->
<version>1.33</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredDependencies>
<!-- DKPro Core Datasets isn't compatible with SnakeYAML 2.0 atm -->
<ignored>org.yaml:snakeyaml</ignored>
</ignoredDependencies>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
16 changes: 12 additions & 4 deletions inception/inception-imls-stringmatch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,26 @@
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<!-- DKPro Core Datasets isn't compatible with SnakeYAML 2.0 atm -->
<version>1.33</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredDependencies>
<!-- DKPro Core Datasets isn't compatible with SnakeYAML 2.0 atm -->
<ignored>org.yaml:snakeyaml</ignored>
</ignoredDependencies>
<usedDependencies>
<!-- Testing - used via reflection -->
<usedDependency>org.hsqldb:hsqldb</usedDependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
package de.tudarmstadt.ukp.clarin.webanno.project;

import static de.tudarmstadt.ukp.clarin.webanno.api.ProjectService.withProjectLogger;
import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.ANNOTATOR;
import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.CURATOR;
import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.MANAGER;
import static de.tudarmstadt.ukp.clarin.webanno.model.Project.MAX_PROJECT_SLUG_LENGTH;
import static de.tudarmstadt.ukp.clarin.webanno.model.Project.MIN_PROJECT_SLUG_LENGTH;
Expand Down Expand Up @@ -91,8 +89,10 @@
import de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel;
import de.tudarmstadt.ukp.clarin.webanno.model.Project;
import de.tudarmstadt.ukp.clarin.webanno.model.ProjectPermission;
import de.tudarmstadt.ukp.clarin.webanno.model.ProjectPermission_;
import de.tudarmstadt.ukp.clarin.webanno.model.ProjectState;
import de.tudarmstadt.ukp.clarin.webanno.model.ProjectUserPermissions;
import de.tudarmstadt.ukp.clarin.webanno.model.Project_;
import de.tudarmstadt.ukp.clarin.webanno.project.config.ProjectServiceAutoConfiguration;
import de.tudarmstadt.ukp.clarin.webanno.security.Realm;
import de.tudarmstadt.ukp.clarin.webanno.security.UserDao;
Expand Down Expand Up @@ -231,13 +231,6 @@ public boolean existsProjectPermissionLevel(User aUser, Project aProject,
return hasRole(aUser, aProject, aLevel);
}

@Override
public File getProjectFolder(Project aProject)
{
return new File(repositoryProperties.getPath().getAbsolutePath() + "/" + PROJECT_FOLDER
+ "/" + aProject.getId());
}

@Override
public File getProjectLogFile(Project aProject)
{
Expand Down Expand Up @@ -751,30 +744,6 @@ public boolean managesAnyProject(User user)
return false;
}

@Deprecated
@Transactional
@Override
public boolean isManager(Project aProject, User aUser)
{
return hasRole(aUser, aProject, MANAGER);
}

@Deprecated
@Transactional
@Override
public boolean isCurator(Project aProject, User aUser)
{
return hasRole(aUser, aProject, CURATOR);
}

@Deprecated
@Transactional
@Override
public boolean isAnnotator(Project aProject, User aUser)
{
return hasRole(aUser, aProject, ANNOTATOR);
}

@EventListener
@Transactional
public void onContextRefreshedEvent(ContextRefreshedEvent aEvent)
Expand Down Expand Up @@ -936,31 +905,6 @@ public void initializeProject(Project aProject, List<ProjectInitializer> aInitia
}
}

@Override
@Transactional
@Deprecated
public List<Project> listProjectsForAgreement()
{
String query = String.join("\n", //
"SELECT DISTINCT p FROM Project p, ProjectPermission pp ", //
"WHERE pp.project = p.id ", //
"AND pp.level = :annotator ", //
"GROUP BY p.id HAVING count(*) > 1 ", //
"ORDER BY p.name ASC");
List<Project> projects = entityManager.createQuery(query, Project.class)
.setParameter("annotator", ANNOTATOR) //
.getResultList();
return projects;
}

@Override
@Transactional
@Deprecated
public List<Project> listManageableCuratableProjects(User aUser)
{
return listProjectsWithUserHavingRole(aUser, CURATOR, MANAGER);
}

@Override
@Transactional
public List<Project> listProjectsWithUserHavingRole(User aUser, PermissionLevel aRole,
Expand All @@ -975,17 +919,28 @@ public List<Project> listProjectsWithUserHavingRole(User aUser, PermissionLevel
roles.addAll(asList(aMoreRoles));
}

String query = String.join("\n", //
"SELECT DISTINCT p FROM Project p, ProjectPermission pp ", //
"WHERE pp.project = p.id ", //
"AND pp.user = :username ", //
"AND pp.level IN (:roles) ", //
"ORDER BY p.name ASC");
List<Project> projects = entityManager.createQuery(query, Project.class)
.setParameter("username", aUser.getUsername()) //
.setParameter("roles", roles) //
.getResultList();
return projects;
var cb = entityManager.getCriteriaBuilder();
var cq = cb.createQuery(Project.class);
var permission = cq.from(ProjectPermission.class);
var project = permission.join(ProjectPermission_.project);
cq.select(project).distinct(true);
cq.where(cb.and( //
cb.equal(permission.get(ProjectPermission_.user), aUser.getUsername()), //
permission.get(ProjectPermission_.level).in(roles)));
cq.orderBy(cb.asc(project.get(Project_.name)));
return entityManager.createQuery(cq).getResultList();

// String query = String.join("\n", //
// "SELECT DISTINCT p FROM Project p, ProjectPermission pp ", //
// "WHERE pp.project = p.id ", //
// "AND pp.user = :username ", //
// "AND pp.level IN (:roles) ", //
// "ORDER BY p.name ASC");
// List<Project> projects = entityManager.createQuery(query, Project.class)
// .setParameter("username", aUser.getUsername()) //
// .setParameter("roles", roles) //
// .getResultList();
// return projects;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,29 +139,6 @@ public void tearDown()
testEntityManager.clear();
}

@Deprecated
@Test
public void listProjectsForAgreement_ShouldReturnOneProject()
{
List<Project> foundProjects = sut.listProjectsForAgreement();

assertThat(foundProjects).containsExactly(testProject);
}

@Deprecated
@Test
public void thatListManageableCuratableProjectsReturnsOnlyProjectsWhereUserIsCuratorOrManager()
{
assertThat(sut.listManageableCuratableProjects(beate)) //
.containsExactlyInAnyOrder(testProject, testProject2, testProjectManagedByBeate);

assertThat(sut.listManageableCuratableProjects(kevin)) //
.containsExactlyInAnyOrder(testProjectManagedByKevin);

assertThat(sut.listManageableCuratableProjects(noPermissionUser)) //
.isEmpty();
}

@Test
public void thatListAccessibleProjectsWorks()
{
Expand Down
Loading

0 comments on commit 1a3d43a

Please sign in to comment.