All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openurp.edu.teach.model.mapping.scala Maven / Gradle / Ivy

There is a newer version: 0.0.3
Show newest version
/*
 * OpenURP, Agile Development Scaffold and Toolkit
 *
 * Copyright (c) 2014-2015, OpenURP Software.
 *
 * OpenURP is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * OpenURP is distributed in the hope that it will be useful.
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OpenURP.  If not, see .
 */
package org.openurp.edu.teach.model

import scala.reflect.runtime.universe
import org.beangle.commons.lang.annotation.beta
import org.beangle.data.model.annotation.{ code, config }
import org.beangle.data.model.bind.Mapping
import org.openurp.edu.teach.code.model.{ CourseTakeType, ElectionMode, ExamForm, ExamType, GradeType, LessonTag, TeachLangType }
import org.openurp.edu.teach.exam.model.{ ExamActivity, ExamMonitor, ExamRoom, ExamTake }
import org.openurp.edu.teach.grade.course.model.{ CourseGrade, CourseGradeState, ExamGrade, ExamGradeState, GaGrade }
import org.openurp.edu.teach.grade.model.{ AbstractGradeState, Grade }
import org.openurp.edu.teach.grade.course.model.GaGradeState
import org.openurp.edu.teach.grade.course.model.StdGpa
import org.openurp.edu.teach.grade.course.model.StdSemesterGpa
import org.openurp.edu.teach.grade.course.model.StdYearGpa
import org.openurp.edu.teach.grade.exchange.model.ExchangeCourse
import org.openurp.edu.teach.grade.exchange.model.ExchangeSchool
import org.openurp.edu.teach.grade.model.GradeRateConfig
import org.openurp.edu.teach.grade.model.GradeRateItem
import org.openurp.edu.teach.grade.moral.model.MoralGrade
import org.openurp.edu.teach.lesson.model.CourseTake
import org.openurp.edu.teach.lesson.model.Lesson
import org.openurp.edu.teach.lesson.model.LessonLimitGroup
import org.openurp.edu.teach.lesson.model.LessonLimitItem
import org.openurp.edu.teach.plan.model.MajorCourseGroup
import org.openurp.edu.teach.plan.model.MajorPlanCourse
import org.openurp.edu.teach.plan.model.MajorPlan
import org.openurp.edu.teach.plan.model.ShareCourseGroup
import org.openurp.edu.teach.plan.model.SharePlanCourse
import org.openurp.edu.teach.plan.model.SharePlan
import org.openurp.edu.teach.plan.model.AbstractCourseGroup
import org.openurp.edu.teach.plan.model.CoursePlan
import org.openurp.edu.teach.plan.model.PlanCourse
import org.openurp.edu.teach.plan.model.StdPlanCourse
import org.openurp.edu.teach.plan.model.StdCourseGroup
import org.openurp.edu.teach.plan.model.StdPlan
import org.openurp.edu.teach.schedule.model.CourseActivity
import org.openurp.edu.teach.schedule.model.LessonGroup
import org.openurp.edu.teach.plan.model.Terms
import org.openurp.edu.teach.lesson.LessonLimitMeta
import org.openurp.edu.teach.util.SchedulePublishStates

class DefaultMapping extends Mapping {

  def binding(): Unit = {
    defaultIdGenerator("date")

    //code
    bind[ElectionMode]
    bind[ExamType]
    bind[CourseTakeType]
    bind[GradeType]
    bind[LessonTag]
    bind[TeachLangType]
    bind[ExamForm]

    //exam
    bind[ExamActivity].on(e => declare(
      e.lesson & e.examOn & e.examType & e.beginAt & e.endAt & e.semester are notnull,
      e.remark is length(100))).generator("date")

    bind[ExamMonitor].on(e => declare(
      e.examRoom & e.department is notnull))

    bind[ExamRoom].on(e => declare(
      e.classroom & e.semester are notnull,
      e.monitors is depends("examRoom")))

    bind[ExamTake].on(e => declare(
      e.lesson & e.std & e.examType & e.examStatus are notnull,
      e.remark is length(100)))

    //grade
    bind[CourseGrade].on(e => declare(
      e.lessonNo is length(20),
      e.course & e.courseTakeType & e.project & e.courseType & e.semester & e.markStyle are notnull,
      e.operator is length(100),
      e.scoreText is length(5),
      e.remark is length(200),
      e.examGrades & e.gaGrades are depends("courseGrade")))

    bind[AbstractGradeState].on(e => declare(
      e.markStyle & e.beginOn are notnull,
      e.operator is length(100)))

    bind[CourseGradeState].on(e => declare(
      e.lesson is notnull,
      e.examStates is depends("courseGradeState"),
      e.gaStates is depends("courseGradeState")))

    bind[Grade].on(e => declare(
      e.markStyle is notnull,
      e.scoreText is length(5),
      e.operator is length(100)))

    bind[ExamGrade].on(e => declare(
      e.gradeType & e.examStatus & e.courseGrade are notnull))

    bind[ExamGradeState].on(e => declare(
      e.gradeState & e.gradeType are notnull))

    bind[GaGrade].on(e => declare(
      e.gradeType & e.courseGrade is notnull))

    bind[GaGradeState].on(e => declare(
      e.gradeState is notnull,
      e.remark is length(50)))

    bind[StdGpa].on(e => declare(
      e.project & e.std & e.updatedAt are notnull,
      e.semesterGpas is depends("stdGpa"),
      e.yearGpas is depends("stdGpa")))

    bind[StdSemesterGpa].on(e => declare(
      e.semester & e.stdGpa are notnull))

    bind[StdYearGpa].on(e => declare(
      e.schoolYear & e.stdGpa are notnull))

    bind[ExchangeCourse].on(e => declare(
      e.school is notnull,
      e.remark is length(100)))
    bind[ExchangeSchool].on(e => declare(
      e.code & e.name & e.beginOn & e.country & e.updatedAt are notnull))

    bind[GradeRateConfig].on(e => declare(
      e.scoreMarkStyle is notnull,
      e.items is depends("config")))

    bind[GradeRateItem].on(e => declare(
      e.config is notnull))

    bind[MoralGrade].on(e => declare(
      e.std & e.semester & e.markStyle are notnull,
      e.scoreText is length(5),
      e.operator is length(100)))

    //lesson
    bind[CourseTake].on(e => declare(
      e.lesson & e.course & e.std & e.takeType & e.electionMode & e.semester & e.updatedAt are notnull,
      e.remark is length(100)))

    bind[Lesson].on(e => declare(
      e.no is length(32),
      e.project & e.course & e.courseType & e.teachDepart & e.semester & e.langType are notnull,
      e.teachers is ordered,
      e.teachclass.name is length(500),
      e.teachclass.courseTakes & e.teachclass.examTakes & e.teachclass.groups &
        e.schedule.activities & e.exam.activities are depends("lesson"),
      e.state & e.updatedAt & e.schedule.publishState are notnull))

    bind[LessonLimitGroup].on(e => declare(
      e.lesson is notnull,
      e.items is depends("group"),
      e.children is depends("parent")))

    bind[LessonLimitItem].on(e => declare(
      e.meta & e.group & e.content are notnull))

    //plan
    bind[AbstractCourseGroup].on(e => declare(
      e.indexno is (notnull, length(20)),
      e.courseType is notnull,
      e.remark is length(200)))

    bind[PlanCourse].on(e => declare(
      e.course is notnull,
      e.remark is length(200)))

    bind[MajorCourseGroup].on(e => declare(
      e.plan is target[MajorPlan],
      e.parent is target[MajorCourseGroup],
      e.children is depends(classOf[MajorCourseGroup], "parent"),
      e.planCourses is depends(classOf[MajorPlanCourse], "group"),
      e.termCredits is (notnull, length(40)),
      e.alias is length(100)))

    bind[MajorPlan].on(e => declare(
      e.program & e.beginOn & e.endOn are notnull,
      e.groups is depends(classOf[MajorCourseGroup], "plan"),
      e.remark is length(200)))

    bind[MajorPlanCourse].on(e => declare(
      e.group is target[MajorCourseGroup]))

    bind[ShareCourseGroup].on(e => declare(
      e.plan is target[SharePlan],
      e.parent is target[ShareCourseGroup],
      e.children is depends(classOf[ShareCourseGroup], "parent"),
      e.planCourses is depends(classOf[SharePlanCourse], "group")))

    bind[SharePlan].on(e => declare(
      e.project & e.education & e.fromGrade & e.toGrade & e.beginOn & e.endOn are notnull,
      e.groups is depends(classOf[ShareCourseGroup], "plan"),
      e.remark is length(200)))

    bind[SharePlanCourse].on(e => declare(
      e.group is target[ShareCourseGroup]))

    bind[StdCourseGroup].on(e => declare(
      e.plan is target[StdPlan],
      e.parent is target[StdCourseGroup],
      e.children is depends(classOf[StdCourseGroup], "parent"),
      e.planCourses is depends(classOf[StdPlanCourse], "group")))

    bind[StdPlan].on(e => declare(
      e.std & e.beginOn & e.endOn are notnull,
      e.groups is depends(classOf[StdCourseGroup], "plan"),
      e.remark is length(200)))

    bind[StdPlanCourse].on(e => declare(
      e.group is target[StdCourseGroup]))

    //schedule
    bind[CourseActivity].on(e => declare(
      e.lesson & e.time.startOn & e.time.weekday & e.time.beginAt & e.time.endAt & e.time.weekstate are notnull,
      e.remark is length(200)))

    bind[LessonGroup].on(e => declare(
      e.lessons is one2many("group"),
      e.name & e.teachDepart & e.semester are notnull))
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy