Skip to content

Commit

Permalink
BC-5180 Rename school entity (#4418)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyedwiper authored Sep 20, 2023
1 parent d0aac38 commit f13eb0e
Show file tree
Hide file tree
Showing 52 changed files with 243 additions and 233 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ObjectId } from '@mikro-orm/mongodb';
import { ConfigService } from '@nestjs/config';
import { Test, TestingModule } from '@nestjs/testing';
import { EntityNotFoundError } from '@shared/common';
import { Account, EntityId, Permission, Role, RoleName, School, User } from '@shared/domain';
import { Account, EntityId, Permission, Role, RoleName, SchoolEntity, User } from '@shared/domain';
import { IdentityManagementService } from '@shared/infra/identity-management/identity-management.service';
import { accountFactory, schoolFactory, setupEntities, userFactory } from '@shared/testing';
import { AccountEntityToDtoMapper } from '@src/modules/account/mapper';
Expand All @@ -25,7 +25,7 @@ describe('AccountDbService', () => {

const defaultPassword = 'DummyPasswd!1';

let mockSchool: School;
let mockSchool: SchoolEntity;

let mockTeacherUser: User;
let mockStudentUser: User;
Expand Down
8 changes: 4 additions & 4 deletions apps/server/src/modules/account/uc/account.uc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
PermissionService,
Role,
RoleName,
School,
SchoolEntity,
SchoolRolePermission,
SchoolRoles,
User,
Expand Down Expand Up @@ -42,9 +42,9 @@ describe('AccountUc', () => {
let accountValidationService: AccountValidationService;
let configService: DeepMocked<ConfigService>;

let mockSchool: School;
let mockOtherSchool: School;
let mockSchoolWithStudentVisibility: School;
let mockSchool: SchoolEntity;
let mockOtherSchool: SchoolEntity;
let mockSchoolWithStudentVisibility: SchoolEntity;

let mockSuperheroUser: User;
let mockAdminUser: User;
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/account/uc/account.uc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ForbiddenOperationError,
ValidationError,
} from '@shared/common/error';
import { Account, EntityId, Permission, PermissionService, Role, RoleName, School, User } from '@shared/domain';
import { Account, EntityId, Permission, PermissionService, Role, RoleName, SchoolEntity, User } from '@shared/domain';
import { UserRepo } from '@shared/repo';
import { AccountService } from '@src/modules/account/services/account.service';
import { AccountDto } from '@src/modules/account/services/dto/account.dto';
Expand Down Expand Up @@ -409,7 +409,7 @@ export class AccountUc {
);
}

private schoolPermissionExists(roles: string[], school: School, permissions: string[]): boolean {
private schoolPermissionExists(roles: string[], school: SchoolEntity, permissions: string[]): boolean {
if (
roles.find((role) => role === RoleName.TEACHER) &&
permissions.find((permission) => permission === Permission.STUDENT_LIST)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EntityManager } from '@mikro-orm/core';
import { HttpStatus, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { Account, RoleName, School, System, User } from '@shared/domain';
import { Account, RoleName, SchoolEntity, System, User } from '@shared/domain';
import { accountFactory, roleFactory, schoolFactory, systemFactory, userFactory } from '@shared/testing';
import { SSOErrorCode } from '@src/modules/oauth/error/sso-error-code.enum';
import { OauthTokenResponse } from '@src/modules/oauth/service/dto';
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('Login Controller (api)', () => {
describe('loginLdap', () => {
let account: Account;
let user: User;
let school: School;
let school: SchoolEntity;
let system: System;

beforeAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpModule } from '@nestjs/axios';
import { DynamicModule, Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { Account, Role, School, SchoolYear, System, User } from '@shared/domain';
import { Account, Role, SchoolEntity, SchoolYear, System, User } from '@shared/domain';
import { MongoMemoryDatabaseModule } from '@shared/infra/database';
import { MongoDatabaseModuleOptions } from '@shared/infra/database/mongo-memory-database/types';
import { RabbitMQWrapperTestModule } from '@shared/infra/rabbitmq';
Expand All @@ -16,7 +16,7 @@ import { config, s3Config } from './fwu-learning-contents.config';
import { FwuLearningContentsUc } from './uc/fwu-learning-contents.uc';

const imports = [
MongoMemoryDatabaseModule.forRoot({ entities: [User, Account, Role, School, System, SchoolYear] }),
MongoMemoryDatabaseModule.forRoot({ entities: [User, Account, Role, SchoolEntity, System, SchoolYear] }),
AuthorizationModule,
AuthenticationModule,
ConfigModule.forRoot(createConfigModuleOptions(config)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MikroOrmModule, MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs';
import { HttpModule } from '@nestjs/axios';
import { Module, NotFoundException } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { Account, Role, School, SchoolYear, System, User } from '@shared/domain';
import { Account, Role, SchoolEntity, SchoolYear, System, User } from '@shared/domain';
import { RabbitMQWrapperModule } from '@shared/infra/rabbitmq';
import { S3ClientModule } from '@shared/infra/s3-client';
import { DB_PASSWORD, DB_URL, DB_USERNAME, createConfigModuleOptions } from '@src/config';
Expand Down Expand Up @@ -36,7 +36,7 @@ const defaultMikroOrmOptions: MikroOrmModuleSyncOptions = {
clientUrl: DB_URL,
password: DB_PASSWORD,
user: DB_USERNAME,
entities: [User, Account, Role, School, System, SchoolYear],
entities: [User, Account, Role, SchoolEntity, System, SchoolYear],

// debug: true, // use it for locally debugging of querys
}),
Expand Down
8 changes: 4 additions & 4 deletions apps/server/src/modules/group/entity/group.entity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Embedded, Entity, Enum, ManyToOne, Property } from '@mikro-orm/core';
import { BaseEntityWithTimestamps } from '@shared/domain/entity/base.entity';
import { ExternalSourceEntity } from '@shared/domain/entity/external-source.entity';
import { School } from '@shared/domain/entity/school.entity';
import { SchoolEntity } from '@shared/domain/entity/school.entity';
import { EntityId } from '@shared/domain/types';
import { GroupUserEntity } from './group-user.entity';
import { GroupValidPeriodEntity } from './group-valid-period.entity';
Expand All @@ -23,7 +23,7 @@ export interface GroupEntityProps {

users: GroupUserEntity[];

organization?: School;
organization?: SchoolEntity;
}

@Entity({ tableName: 'groups' })
Expand All @@ -43,8 +43,8 @@ export class GroupEntity extends BaseEntityWithTimestamps {
@Embedded(() => GroupUserEntity, { array: true })
users: GroupUserEntity[];

@ManyToOne(() => School, { nullable: true })
organization?: School;
@ManyToOne(() => SchoolEntity, { nullable: true })
organization?: SchoolEntity;

constructor(props: GroupEntityProps) {
super();
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/group/repo/group-domain.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EntityManager } from '@mikro-orm/mongodb';
import { ExternalSource, ExternalSourceEntity, Role, School, System, User } from '@shared/domain';
import { ExternalSource, ExternalSourceEntity, Role, SchoolEntity, System, User } from '@shared/domain';
import { Group, GroupProps, GroupTypes, GroupUser } from '../domain';
import { GroupEntity, GroupEntityProps, GroupEntityTypes, GroupUserEntity, GroupValidPeriodEntity } from '../entity';

Expand Down Expand Up @@ -34,7 +34,7 @@ export class GroupDomainMapper {
(groupUser): GroupUserEntity => GroupDomainMapper.mapGroupUserToGroupUserEntity(groupUser, em)
),
validPeriod,
organization: props.organizationId ? em.getReference(School, props.organizationId) : undefined,
organization: props.organizationId ? em.getReference(SchoolEntity, props.organizationId) : undefined,
};

return mapped;
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/h5p-editor/h5p-editor-test.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DynamicModule, Module } from '@nestjs/common';
import { Account, Role, School, SchoolYear, User } from '@shared/domain';
import { Account, Role, SchoolEntity, SchoolYear, User } from '@shared/domain';
import { MongoMemoryDatabaseModule } from '@shared/infra/database';
import { MongoDatabaseModuleOptions } from '@shared/infra/database/mongo-memory-database/types';
import { RabbitMQWrapperTestModule } from '@shared/infra/rabbitmq';
Expand All @@ -12,7 +12,7 @@ import { H5PEditorModule } from './h5p-editor.module';

const imports = [
H5PEditorModule,
MongoMemoryDatabaseModule.forRoot({ entities: [Account, Role, School, SchoolYear, User] }),
MongoMemoryDatabaseModule.forRoot({ entities: [Account, Role, SchoolEntity, SchoolYear, User] }),
AuthenticationApiModule,
AuthorizationModule,
AuthenticationModule,
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/h5p-editor/h5p-editor.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Dictionary, IPrimaryKey } from '@mikro-orm/core';
import { MikroOrmModule, MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs';
import { Module, NotFoundException } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { Account, Role, School, SchoolYear, System, User } from '@shared/domain';
import { Account, Role, SchoolEntity, SchoolYear, System, User } from '@shared/domain';
import { DB_PASSWORD, DB_URL, DB_USERNAME, createConfigModuleOptions } from '@src/config';
import { CoreModule } from '@src/core';
import { Logger } from '@src/core/logger';
Expand All @@ -28,7 +28,7 @@ const imports = [
clientUrl: DB_URL,
password: DB_PASSWORD,
user: DB_USERNAME,
entities: [User, Account, Role, School, System, SchoolYear],
entities: [User, Account, Role, SchoolEntity, System, SchoolYear],

// debug: true, // use it for locally debugging of querys
}),
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/modules/news/mapper/news.mapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
CourseNews,
INewsProperties,
News,
School,
SchoolEntity,
SchoolNews,
TeamEntity,
TeamNews,
Expand Down Expand Up @@ -43,7 +43,7 @@ const date = new Date(2021, 1, 1, 0, 0, 0);
const createNews = <T extends News>(
newsProps,
NewsType: { new (props: INewsProperties): T },
school: School,
school: SchoolEntity,
creator: User,
target: NewsTarget
): T => {
Expand All @@ -70,7 +70,7 @@ const createNews = <T extends News>(
};

const getExpectedNewsResponse = (
school: School,
school: SchoolEntity,
creator: User,
news: News,
newsProps: { title: string; content: string },
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/news/mapper/school-info.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { School } from '@shared/domain';
import { SchoolEntity } from '@shared/domain';
import { SchoolInfoResponse } from '../controller/dto';

export class SchoolInfoMapper {
static mapToResponse(schoolInfo: School): SchoolInfoResponse {
static mapToResponse(schoolInfo: SchoolEntity): SchoolInfoResponse {
const dto = new SchoolInfoResponse({ id: schoolInfo.id, name: schoolInfo.name });
return dto;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib';
import { EntityManager, ObjectId } from '@mikro-orm/mongodb';
import { ExecutionContext, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { Account, EntityId, School, System, User } from '@shared/domain';
import { Account, EntityId, SchoolEntity, System, User } from '@shared/domain';
import { UserLoginMigration } from '@shared/domain/entity/user-login-migration.entity';
import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy';
import { KeycloakAdministrationService } from '@shared/infra/identity-management/keycloak-administration/service/keycloak-administration.service';
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('OAuth SSO Controller (API)', () => {
const setup = async () => {
const externalUserId = 'externalUserId';
const system: System = systemFactory.withOauthConfig().buildWithId();
const school: School = schoolFactory.buildWithId({ systems: [system] });
const school: SchoolEntity = schoolFactory.buildWithId({ systems: [system] });
const user: User = userFactory.buildWithId({ externalId: externalUserId, school });
const account: Account = accountFactory.buildWithId({ systemId: system.id, userId: user.id });

Expand Down Expand Up @@ -325,7 +325,7 @@ describe('OAuth SSO Controller (API)', () => {
.withOauthConfig()
.buildWithId({ provisioningStrategy: SystemProvisioningStrategy.ISERV }, new ObjectId().toHexString(), {});

const sourceSchool: School = schoolFactory.buildWithId({
const sourceSchool: SchoolEntity = schoolFactory.buildWithId({
systems: [sourceSystem],
officialSchoolNumber: '11111',
externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713',
Expand Down Expand Up @@ -404,7 +404,7 @@ describe('OAuth SSO Controller (API)', () => {
.withOauthConfig()
.buildWithId({ provisioningStrategy: SystemProvisioningStrategy.ISERV }, new ObjectId().toHexString(), {});

const sourceSchool: School = schoolFactory.buildWithId({
const sourceSchool: SchoolEntity = schoolFactory.buildWithId({
systems: [sourceSystem],
officialSchoolNumber: '11110',
externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713',
Expand Down Expand Up @@ -452,7 +452,7 @@ describe('OAuth SSO Controller (API)', () => {
.withOauthConfig()
.buildWithId({ provisioningStrategy: SystemProvisioningStrategy.ISERV }, new ObjectId().toHexString(), {});

const sourceSchool: School = schoolFactory.buildWithId({
const sourceSchool: SchoolEntity = schoolFactory.buildWithId({
systems: [sourceSystem],
officialSchoolNumber: '11111',
externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713',
Expand Down Expand Up @@ -508,7 +508,7 @@ describe('OAuth SSO Controller (API)', () => {
.withOauthConfig()
.buildWithId({ provisioningStrategy: SystemProvisioningStrategy.ISERV }, new ObjectId().toHexString(), {});

const sourceSchool: School = schoolFactory.buildWithId({
const sourceSchool: SchoolEntity = schoolFactory.buildWithId({
systems: [sourceSystem],
officialSchoolNumber: '11111',
externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713',
Expand All @@ -521,7 +521,7 @@ describe('OAuth SSO Controller (API)', () => {
startedAt: new Date('2022-12-17T03:24:00'),
});

const targetSchool: School = schoolFactory.buildWithId({
const targetSchool: SchoolEntity = schoolFactory.buildWithId({
systems: [targetSystem],
officialSchoolNumber: '22222',
externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EntityManager, MikroORM } from '@mikro-orm/core';
import { HttpStatus, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { Account, Course, Permission, School, User } from '@shared/domain';
import { Account, Course, Permission, SchoolEntity, User } from '@shared/domain';
import {
accountFactory,
contextExternalToolEntityFactory,
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('ToolContextController (API)', () => {
describe('[POST] tools/context-external-tools', () => {
describe('when creation of contextExternalTool is successfully', () => {
const setup = async () => {
const school: School = schoolFactory.buildWithId();
const school: SchoolEntity = schoolFactory.buildWithId();
const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [
Permission.CONTEXT_TOOL_ADMIN,
]);
Expand Down Expand Up @@ -158,7 +158,7 @@ describe('ToolContextController (API)', () => {
describe('[DELETE] tools/context-external-tools/:contextExternalToolId', () => {
describe('when deletion of contextExternalTool is successfully', () => {
const setup = async () => {
const school: School = schoolFactory.buildWithId();
const school: SchoolEntity = schoolFactory.buildWithId();
const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [
Permission.CONTEXT_TOOL_ADMIN,
]);
Expand Down Expand Up @@ -240,8 +240,8 @@ describe('ToolContextController (API)', () => {

describe('[GET] tools/context-external-tools/:contextType/:contextId', () => {
const setup = async () => {
const school: School = schoolFactory.buildWithId();
const otherSchool: School = schoolFactory.buildWithId();
const school: SchoolEntity = schoolFactory.buildWithId();
const otherSchool: SchoolEntity = schoolFactory.buildWithId();

const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [
Permission.CONTEXT_TOOL_ADMIN,
Expand Down Expand Up @@ -410,7 +410,7 @@ describe('ToolContextController (API)', () => {
describe('[GET] tools/context-external-tools/:contextExternalToolId', () => {
describe('when the tool exists', () => {
const setup = async () => {
const school: School = schoolFactory.buildWithId();
const school: SchoolEntity = schoolFactory.buildWithId();

const { teacherUser, teacherAccount } = UserAndAccountTestFactory.buildTeacher({ school }, [
Permission.CONTEXT_TOOL_ADMIN,
Expand Down Expand Up @@ -474,7 +474,7 @@ describe('ToolContextController (API)', () => {

describe('when the tool does not exist', () => {
const setup = async () => {
const school: School = schoolFactory.buildWithId();
const school: SchoolEntity = schoolFactory.buildWithId();

const { teacherUser, teacherAccount } = UserAndAccountTestFactory.buildTeacher({ school }, [
Permission.CONTEXT_TOOL_ADMIN,
Expand Down Expand Up @@ -504,7 +504,7 @@ describe('ToolContextController (API)', () => {

describe('when user is not authorized', () => {
const setup = async () => {
const school: School = schoolFactory.buildWithId();
const school: SchoolEntity = schoolFactory.buildWithId();

const course: Course = courseFactory.buildWithId({
school,
Expand Down Expand Up @@ -543,7 +543,7 @@ describe('ToolContextController (API)', () => {

describe('when user has not the required permission', () => {
const setup = async () => {
const school: School = schoolFactory.buildWithId();
const school: SchoolEntity = schoolFactory.buildWithId();

const { studentUser, studentAccount } = UserAndAccountTestFactory.buildStudent({ school });

Expand Down Expand Up @@ -598,7 +598,7 @@ describe('ToolContextController (API)', () => {
describe('[PUT] tools/context-external-tools/:contextExternalToolId', () => {
describe('when update of contextExternalTool is successfully', () => {
const setup = async () => {
const school: School = schoolFactory.buildWithId();
const school: SchoolEntity = schoolFactory.buildWithId();

const { teacherUser, teacherAccount } = UserAndAccountTestFactory.buildTeacher({ school }, [
Permission.CONTEXT_TOOL_ADMIN,
Expand Down Expand Up @@ -694,7 +694,7 @@ describe('ToolContextController (API)', () => {

teacherUser.roles.set([roleWithoutPermission]);

const school: School = schoolFactory.buildWithId();
const school: SchoolEntity = schoolFactory.buildWithId();

const course: Course = courseFactory.buildWithId({ teachers: [teacherUser], school });

Expand Down Expand Up @@ -766,7 +766,7 @@ describe('ToolContextController (API)', () => {
describe('when the user is not authenticated', () => {
const setup = async () => {
const { teacherUser } = UserAndAccountTestFactory.buildTeacher();
const school: School = schoolFactory.buildWithId();
const school: SchoolEntity = schoolFactory.buildWithId();
const course: Course = courseFactory.buildWithId({ teachers: [teacherUser], school });

const contextParameter = customParameterEntityFactory.build({
Expand Down
Loading

0 comments on commit f13eb0e

Please sign in to comment.