Search in sources :

Example 26 with SchoolDataSource

use of fi.otavanopisto.muikku.model.base.SchoolDataSource in project muikku by otavanopisto.

the class WorkspaceEntityController method findWorkspaceEntityIdsByIdentifiers.

public Set<Long> findWorkspaceEntityIdsByIdentifiers(Collection<SchoolDataIdentifier> identifiers) {
    Set<Long> result = new HashSet<>();
    Map<String, Set<String>> groupedIdentifiers = new HashMap<>();
    for (SchoolDataIdentifier identifier : identifiers) {
        Set<String> groupIdentifiers = groupedIdentifiers.get(identifier.getDataSource());
        if (groupIdentifiers == null) {
            groupIdentifiers = new HashSet<>();
            groupedIdentifiers.put(identifier.getDataSource(), groupIdentifiers);
        }
        groupIdentifiers.add(identifier.getIdentifier());
    }
    for (String dataSource : groupedIdentifiers.keySet()) {
        Set<String> groupIdentifiers = groupedIdentifiers.get(dataSource);
        SchoolDataSource schoolDataSource = schoolDataSourceDAO.findByIdentifier(dataSource);
        if (schoolDataSource != null) {
            result.addAll(workspaceEntityDAO.listIdsByDataSourceAndIdentifiers(schoolDataSource, groupIdentifiers));
        } else {
            logger.severe("Could not find school data source: " + dataSource);
        }
    }
    return result;
}
Also used : SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 27 with SchoolDataSource

use of fi.otavanopisto.muikku.model.base.SchoolDataSource in project muikku by otavanopisto.

the class WorkspaceSchoolDataController method findWorkspaceEntity.

/* Workspace Entities */
public WorkspaceEntity findWorkspaceEntity(Workspace workspace) {
    SchoolDataSource schoolDataSource = schoolDataSourceDAO.findByIdentifier(workspace.getSchoolDataSource());
    WorkspaceEntity workspaceEntity = workspaceEntityDAO.findByDataSourceAndIdentifier(schoolDataSource, workspace.getIdentifier());
    return workspaceEntity;
}
Also used : SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)

Example 28 with SchoolDataSource

use of fi.otavanopisto.muikku.model.base.SchoolDataSource in project muikku by otavanopisto.

the class WorkspaceSchoolDataController method createWorkspace.

/* Workspaces */
public Workspace createWorkspace(String schoolDataSourceIdentifier, String name, String description, WorkspaceType type, String courseIdentifierIdentifier) {
    SchoolDataSource schoolDataSource = schoolDataSourceDAO.findByIdentifier(schoolDataSourceIdentifier);
    WorkspaceSchoolDataBridge workspaceBridge = getWorkspaceBridge(schoolDataSource);
    if (workspaceBridge != null) {
        return workspaceBridge.createWorkspace(name, description, type, courseIdentifierIdentifier);
    } else {
        logger.log(Level.SEVERE, "School Data Bridge not found: " + schoolDataSource);
    }
    return null;
}
Also used : SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource)

Example 29 with SchoolDataSource

use of fi.otavanopisto.muikku.model.base.SchoolDataSource in project muikku by otavanopisto.

the class GradingSchoolDataController method listWorkspaceAssessmentRequests.

public List<WorkspaceAssessmentRequest> listWorkspaceAssessmentRequests(String schoolDataSource, String workspaceIdentifier, String studentIdentifier) {
    SchoolDataSource dataSource = schoolDataSourceDAO.findByIdentifier(schoolDataSource);
    GradingSchoolDataBridge schoolDataBridge = getGradingBridge(dataSource);
    if (schoolDataBridge != null) {
        return schoolDataBridge.listWorkspaceAssessmentRequests(workspaceIdentifier, studentIdentifier);
    } else {
        logger.log(Level.SEVERE, "School Data Bridge could not be found for data source: " + dataSource.getIdentifier());
    }
    return null;
}
Also used : SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource)

Example 30 with SchoolDataSource

use of fi.otavanopisto.muikku.model.base.SchoolDataSource in project muikku by otavanopisto.

the class GradingSchoolDataController method updateWorkspaceAssessmentRequest.

public WorkspaceAssessmentRequest updateWorkspaceAssessmentRequest(String schoolDataSource, String identifier, String workspaceUserIdentifier, String workspaceUserSchoolDataSource, String workspaceIdentifier, String studentIdentifier, String requestText, Date date, Boolean archived, Boolean handled) {
    SchoolDataSource dataSource = schoolDataSourceDAO.findByIdentifier(schoolDataSource);
    GradingSchoolDataBridge schoolDataBridge = getGradingBridge(dataSource);
    if (schoolDataBridge != null) {
        return schoolDataBridge.updateWorkspaceAssessmentRequest(identifier, workspaceUserIdentifier, workspaceUserSchoolDataSource, workspaceIdentifier, studentIdentifier, requestText, date, archived, handled);
    } else {
        logger.log(Level.SEVERE, "School Data Bridge could not be found for data source: " + dataSource.getIdentifier());
    }
    return null;
}
Also used : SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource)

Aggregations

SchoolDataSource (fi.otavanopisto.muikku.model.base.SchoolDataSource)35 RoleSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier)4 RoleEntity (fi.otavanopisto.muikku.model.users.RoleEntity)3 WorkspaceRoleEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity)3 EnvironmentRoleEntity (fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity)2 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)2 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)2 LoginEvent (fi.otavanopisto.muikku.events.LoginEvent)1 CourseIdentifierEntity (fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierEntity)1 CourseIdentifierSchoolDataIdentifier (fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierSchoolDataIdentifier)1 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)1 UserPendingPasswordChange (fi.otavanopisto.muikku.plugins.user.UserPendingPasswordChange)1 RESTPermitUnimplemented (fi.otavanopisto.muikku.rest.RESTPermitUnimplemented)1 SchoolDataBridgeUnauthorizedException (fi.otavanopisto.muikku.schooldata.SchoolDataBridgeUnauthorizedException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 Set (java.util.Set)1 EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1