Search in sources :

Example 1 with DecoratedObject

use of de.tudarmstadt.ukp.clarin.webanno.support.wicket.DecoratedObject in project webanno by webanno.

the class AnnotationPage method getAllowedProjects.

private IModel<List<DecoratedObject<Project>>> getAllowedProjects() {
    return LambdaModel.of(() -> {
        User user = userRepository.getCurrentUser();
        List<DecoratedObject<Project>> allowedProject = new ArrayList<>();
        for (Project project : projectService.listProjects()) {
            if (isAnnotator(project, projectService, user) && WebAnnoConst.PROJECT_TYPE_ANNOTATION.equals(project.getMode())) {
                allowedProject.add(DecoratedObject.of(project));
            }
        }
        return allowedProject;
    });
}
Also used : Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) DecoratedObject(de.tudarmstadt.ukp.clarin.webanno.support.wicket.DecoratedObject) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) ArrayList(java.util.ArrayList)

Example 2 with DecoratedObject

use of de.tudarmstadt.ukp.clarin.webanno.support.wicket.DecoratedObject in project webanno by webanno.

the class CurationPage method getAllowedProjects.

private IModel<List<DecoratedObject<Project>>> getAllowedProjects() {
    return new LoadableDetachableModel<List<DecoratedObject<Project>>>() {

        private static final long serialVersionUID = -2518743298741342852L;

        @Override
        protected List<DecoratedObject<Project>> load() {
            User user = userRepository.get(SecurityContextHolder.getContext().getAuthentication().getName());
            List<DecoratedObject<Project>> allowedProject = new ArrayList<>();
            List<Project> projectsWithFinishedAnnos = projectService.listProjectsWithFinishedAnnos();
            for (Project project : projectService.listProjects()) {
                if (SecurityUtil.isCurator(project, projectService, user)) {
                    DecoratedObject<Project> dp = DecoratedObject.of(project);
                    if (projectsWithFinishedAnnos.contains(project)) {
                        dp.setColor("green");
                    } else {
                        dp.setColor("red");
                    }
                    allowedProject.add(dp);
                }
            }
            return allowedProject;
        }
    };
}
Also used : Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) DecoratedObject(de.tudarmstadt.ukp.clarin.webanno.support.wicket.DecoratedObject) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) ArrayList(java.util.ArrayList)

Example 3 with DecoratedObject

use of de.tudarmstadt.ukp.clarin.webanno.support.wicket.DecoratedObject in project webanno by webanno.

the class CorrectionPage method getAllowedProjects.

private IModel<List<DecoratedObject<Project>>> getAllowedProjects() {
    return new LoadableDetachableModel<List<DecoratedObject<Project>>>() {

        private static final long serialVersionUID = -2518743298741342852L;

        @Override
        protected List<DecoratedObject<Project>> load() {
            User user = userRepository.get(SecurityContextHolder.getContext().getAuthentication().getName());
            List<DecoratedObject<Project>> allowedProject = new ArrayList<>();
            for (Project project : projectService.listProjects()) {
                if (SecurityUtil.isAnnotator(project, projectService, user) && WebAnnoConst.PROJECT_TYPE_CORRECTION.equals(project.getMode())) {
                    allowedProject.add(DecoratedObject.of(project));
                }
            }
            return allowedProject;
        }
    };
}
Also used : Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) DecoratedObject(de.tudarmstadt.ukp.clarin.webanno.support.wicket.DecoratedObject) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) ArrayList(java.util.ArrayList)

Example 4 with DecoratedObject

use of de.tudarmstadt.ukp.clarin.webanno.support.wicket.DecoratedObject in project webanno by webanno.

the class AutomationPage method getAllowedProjects.

private IModel<List<DecoratedObject<Project>>> getAllowedProjects() {
    return LambdaModel.of(() -> {
        User user = userRepository.getCurrentUser();
        List<DecoratedObject<Project>> allowedProject = new ArrayList<>();
        for (Project project : projectService.listProjects()) {
            if (SecurityUtil.isAnnotator(project, projectService, user) && WebAnnoConst.PROJECT_TYPE_AUTOMATION.equals(project.getMode())) {
                allowedProject.add(DecoratedObject.of(project));
            }
        }
        return allowedProject;
    });
}
Also used : Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) DecoratedObject(de.tudarmstadt.ukp.clarin.webanno.support.wicket.DecoratedObject) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) ArrayList(java.util.ArrayList)

Aggregations

Project (de.tudarmstadt.ukp.clarin.webanno.model.Project)4 User (de.tudarmstadt.ukp.clarin.webanno.security.model.User)4 DecoratedObject (de.tudarmstadt.ukp.clarin.webanno.support.wicket.DecoratedObject)4 ArrayList (java.util.ArrayList)4 LoadableDetachableModel (org.apache.wicket.model.LoadableDetachableModel)2