Search in sources :

Example 1 with WorkspaceSettings

use of fi.otavanopisto.muikku.model.workspace.WorkspaceSettings in project muikku by otavanopisto.

the class WorkspaceSettingsDAO method findByWorkspaceEntity.

public WorkspaceSettings findByWorkspaceEntity(WorkspaceEntity workspaceEntity) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<WorkspaceSettings> criteria = criteriaBuilder.createQuery(WorkspaceSettings.class);
    Root<WorkspaceSettings> root = criteria.from(WorkspaceSettings.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.equal(root.get(WorkspaceSettings_.workspaceEntity), workspaceEntity));
    return getSingleResult(entityManager.createQuery(criteria));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) WorkspaceSettings(fi.otavanopisto.muikku.model.workspace.WorkspaceSettings)

Example 2 with WorkspaceSettings

use of fi.otavanopisto.muikku.model.workspace.WorkspaceSettings in project muikku by otavanopisto.

the class WorkspaceSettingsDAO method create.

public WorkspaceSettings create(WorkspaceEntity workspaceEntity, WorkspaceRoleEntity defaultUserRole) {
    WorkspaceSettings courseSettings = new WorkspaceSettings();
    courseSettings.setWorkspaceEntity(workspaceEntity);
    courseSettings.setDefaultWorkspaceUserRole(defaultUserRole);
    getEntityManager().persist(courseSettings);
    return courseSettings;
}
Also used : WorkspaceSettings(fi.otavanopisto.muikku.model.workspace.WorkspaceSettings)

Example 3 with WorkspaceSettings

use of fi.otavanopisto.muikku.model.workspace.WorkspaceSettings in project muikku by otavanopisto.

the class WorkspaceController method deleteWorkspaceEntity.

private void deleteWorkspaceEntity(WorkspaceEntity workspaceEntity) {
    // Delete settings
    WorkspaceSettings workspaceSettings = findWorkspaceSettings(workspaceEntity);
    if (workspaceSettings != null) {
        workspaceSettingsDAO.delete(workspaceSettings);
    }
    // Workspace Users
    List<WorkspaceUserEntity> workspaceUserEntities = workspaceUserEntityDAO.listByWorkspaceEntity(workspaceEntity);
    for (WorkspaceUserEntity workspaceUserEntity : workspaceUserEntities) {
        workspaceUserEntityDAO.delete(workspaceUserEntity);
    }
    workspaceEntityDAO.delete(workspaceEntity);
}
Also used : WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceSettings(fi.otavanopisto.muikku.model.workspace.WorkspaceSettings)

Aggregations

WorkspaceSettings (fi.otavanopisto.muikku.model.workspace.WorkspaceSettings)3 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)1 EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1