private Optional<Project> getProjectFromParameters(StringValue projectParam) { if (projectParam == null || projectParam.isEmpty()) { return Optional.empty(); } try { return Optional.of(projectService.getProject(projectParam.toLong())); } catch (NoResultException e) { return Optional.empty(); } }
private Optional<Project> getProjectFromParameters(StringValue projectParam) { if (projectParam == null || projectParam.isEmpty()) { return Optional.empty(); } try { return Optional.of(projectService.getProject(projectParam.toLong())); } catch (NoResultException e) { return Optional.empty(); } }
private Optional<Project> getProjectFromParameters(StringValue projectParam) { if (projectParam == null || projectParam.isEmpty()) { return Optional.empty(); } try { return Optional.of(projectService.getProject(projectParam.toLong())); } catch (NoResultException e) { return Optional.empty(); } } }
private Optional<Project> getProjectFromParameters(StringValue projectParam) { if (projectParam == null || projectParam.isEmpty()) { return Optional.empty(); } try { return Optional.of(projectService.getProject(projectParam.toLong())); } catch (NoResultException e) { return Optional.empty(); } } }
private Project getProjectFromParameters(StringValue projectParam) { Project project = null; if (projectParam != null && !projectParam.isEmpty()) { long projectId = projectParam.toLong(); project = projectService.getProject(projectId); } return project; }
private Project getProjectFromParameters(StringValue projectParam) { Project project = null; if (projectParam != null && !projectParam.isEmpty()) { long projectId = projectParam.toLong(); project = projectService.getProject(projectId); } return project; }
private Project getProjectFromParameters(StringValue projectParam) { Project project = null; if (projectParam != null && !projectParam.isEmpty()) { long projectId = projectParam.toLong(); project = projectService.getProject(projectId); } return project; }
@Override public boolean applies() { Project sessionProject = Session.get().getMetaData(SessionMetaData.CURRENT_PROJECT); if (sessionProject == null) { return false; } // The project object stored in the session is detached from the persistence context and // cannot be used immediately in DB interactions. Fetch a fresh copy from the DB. Project project = projectService.getProject(sessionProject.getId()); return !externalSearchService.listDocumentRepositories(project).isEmpty(); }
@Override public boolean applies() { Project sessionProject = Session.get().getMetaData(SessionMetaData.CURRENT_PROJECT); if (sessionProject == null) { return false; } // The project object stored in the session is detached from the persistence context and // cannot be used immediately in DB interactions. Fetch a fresh copy from the DB. Project project = projectService.getProject(sessionProject.getId()); return !externalSearchService.listDocumentRepositories(project).isEmpty(); }
/** * Look up project in session but get fresh info from the DB in case the session object is * stale (e.g. if the title/description has changed). */ private Project getProject() { Project project = Session.get().getMetaData(SessionMetaData.CURRENT_PROJECT); if (project == null) { return null; } else { return projectService.getProject(project.getId()); } }
/** * Look up project in session but get fresh info from the DB in case the session object is * stale (e.g. if the title/description has changed). */ private Project getProject() { Project project = Session.get().getMetaData(SessionMetaData.CURRENT_PROJECT); if (project == null) { return null; } else { return projectService.getProject(project.getId()); } }
project = projectRepository.getProject(aProjectId);
public MtasUimaParser(MtasConfiguration config) { super(config); // Perform dependency injection AutowireCapableBeanFactory factory = ApplicationContextProvider.getApplicationContext() .getAutowireCapableBeanFactory(); factory.autowireBean(this); factory.initializeBean(this, "transientParser"); // Process configuration // Read parser argument that contains the projectId JSONObject jsonParserConfiguration = new JSONObject( config.attributes.get(MtasTokenizerFactory.ARGUMENT_PARSER_ARGS)); project = projectService.getProject(jsonParserConfiguration.getInt("projectId")); // Initialize and populate the hash maps for the layers and features initLayerAndFeatureCache(); }
@Override public boolean applies() { Project sessionProject = Session.get().getMetaData(SessionMetaData.CURRENT_PROJECT); if (sessionProject == null) { return false; } // The project object stored in the session is detached from the persistence context and // cannot be used immediately in DB interactions. Fetch a fresh copy from the DB. Project project = projectService.getProject(sessionProject.getId()); // Not visible if the current user is not an annotator User user = userRepo.getCurrentUser(); if (!(projectService.isAnnotator(project, user) && WebAnnoConst.PROJECT_TYPE_ANNOTATION.equals(project.getMode()))) { return false; } // not visible if the current project does not have knowledge bases return !kbService.getKnowledgeBases(project).isEmpty(); }
@Override public boolean applies() { Project sessionProject = Session.get().getMetaData(SessionMetaData.CURRENT_PROJECT); if (sessionProject == null) { return false; } // The project object stored in the session is detached from the persistence context and // cannot be used immediately in DB interactions. Fetch a fresh copy from the DB. Project project = projectService.getProject(sessionProject.getId()); // Not visible if the current user is not an annotator User user = userRepo.getCurrentUser(); if (!(projectService.isAnnotator(project, user) && WebAnnoConst.PROJECT_TYPE_ANNOTATION.equals(project.getMode()))) { return false; } // not visible if the current project does not have knowledge bases return !kbService.getKnowledgeBases(project).isEmpty(); }
project = projectRepository.getProject(aProjectId);
private Project getProject(long aProjectId) throws ObjectNotFoundException, AccessForbiddenException { // Get current user - this will throw an exception if the current user does not exit User user = getCurrentUser(); // Get project Project project; try { project = projectService.getProject(aProjectId); } catch (NoResultException e) { throw new ObjectNotFoundException("Project [" + aProjectId + "] not found."); } // Check for the access assertPermission( "User [" + user.getUsername() + "] is not allowed to access project [" + aProjectId + "]", projectService.isManager(project, user) || userRepository.isAdministrator(user)); return project; }
private Project getProject(long aProjectId) throws ObjectNotFoundException, AccessForbiddenException { // Get current user - this will throw an exception if the current user does not exit User user = getCurrentUser(); // Get project Project project; try { project = projectService.getProject(aProjectId); } catch (NoResultException e) { throw new ObjectNotFoundException("Project [" + aProjectId + "] not found."); } // Check for the access assertPermission( "User [" + user.getUsername() + "] is not allowed to access project [" + aProjectId + "]", projectService.isManager(project, user) || userRepository.isAdministrator(user)); return project; }
public KnowledgeBasePage(PageParameters aPageParameters) { super(aPageParameters); User user = userRepository.getCurrentUser(); // Project has been specified when the page was opened Project project = null; StringValue projectParam = aPageParameters.get(PAGE_PARAM_PROJECT_ID); if (!projectParam.isEmpty()) { long projectId = projectParam.toLong(); try { project = projectService.getProject(projectId); // Check access to project if (!projectService.isAnnotator(project, user)) { error("You have no permission to access project [" + project.getId() + "]"); abort(); } } catch (NoResultException e) { error("Project [" + projectId + "] does not exist"); abort(); } } commonInit(project); }
public KnowledgeBasePage(PageParameters aPageParameters) { super(aPageParameters); User user = userRepository.getCurrentUser(); // Project has been specified when the page was opened Project project = null; StringValue projectParam = aPageParameters.get(PAGE_PARAM_PROJECT_ID); if (!projectParam.isEmpty()) { long projectId = projectParam.toLong(); try { project = projectService.getProject(projectId); // Check access to project if (!projectService.isAnnotator(project, user)) { error("You have no permission to access project [" + project.getId() + "]"); abort(); } } catch (NoResultException e) { error("Project [" + projectId + "] does not exist"); abort(); } } commonInit(project); }