diff --git a/app/com/coleji/neptune/Storable/StorableQuery/DateTimeColumnAlias.scala b/app/com/coleji/neptune/Storable/StorableQuery/DateTimeColumnAlias.scala index 7eaeaaa4..2d8dd4fb 100644 --- a/app/com/coleji/neptune/Storable/StorableQuery/DateTimeColumnAlias.scala +++ b/app/com/coleji/neptune/Storable/StorableQuery/DateTimeColumnAlias.scala @@ -4,12 +4,14 @@ import com.coleji.neptune.Core.PermissionsAuthority import com.coleji.neptune.Core.PermissionsAuthority.{PERSISTENCE_SYSTEM_MYSQL, PERSISTENCE_SYSTEM_ORACLE} import com.coleji.neptune.Storable.Fields.{DatabaseField, DateTimeDatabaseField} import com.coleji.neptune.Storable.{Filter, StorableClass, StorableObject} +import com.coleji.neptune.Util.{DATE_<, DATE_<=, DATE_=, DATE_>, DATE_>=, DateComparison} import java.time.format.DateTimeFormatter import java.time.{LocalDate, LocalDateTime} case class DateTimeColumnAlias(override val table: TableAlias[_ <: StorableObject[_ <: StorableClass]], override val field: DateTimeDatabaseField) - extends ColumnAlias[DatabaseField[LocalDateTime]](table, field) { +extends ColumnAlias[DatabaseField[LocalDateTime]](table, field) { + val localDatePattern: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") def isYearConstant(year: Int)(implicit PA: PermissionsAuthority): Filter = PA.systemParams.persistenceSystem match { case PERSISTENCE_SYSTEM_MYSQL => { @@ -21,14 +23,23 @@ case class DateTimeColumnAlias(override val table: TableAlias[_ <: StorableObjec case PERSISTENCE_SYSTEM_ORACLE => Filter(s"TO_CHAR(${table.name}.${field.persistenceFieldName}, 'YYYY') = $year", List.empty) } - def isDateConstant(date: LocalDate)(implicit PA: PermissionsAuthority): Filter = PA.systemParams.persistenceSystem match { - case PERSISTENCE_SYSTEM_MYSQL => - Filter( - s"${table.name}.${field.persistenceFieldName} >= '${date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))}' AND " + - s"${table.name}.${field.persistenceFieldName} < '${date.plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))}'", - List.empty - ) - case PERSISTENCE_SYSTEM_ORACLE => - Filter(s"TRUNC(${table.name}.${field.persistenceFieldName}) = TO_DATE('${date.format(DateTimeFormatter.ofPattern("MM/dd/yyyy"))}','MM/DD/YYYY')", List.empty) + private def dateComparison(date: LocalDate, comp: DateComparison)(implicit PA: PermissionsAuthority): Filter = { + val comparator: String = comp.comparator + PA.systemParams.persistenceSystem match { + case PERSISTENCE_SYSTEM_MYSQL => + Filter(s"${table.name}.${field.persistenceFieldName} $comparator '${date.format(localDatePattern)}'", List.empty) + case PERSISTENCE_SYSTEM_ORACLE => + Filter(s"TRUNC(${table.name}.${field.persistenceFieldName}) $comparator TO_DATE('${date.format(DateTimeFormatter.ofPattern("MM/dd/yyyy"))}','MM/DD/YYYY')", List.empty) + } } + + def isDateConstant(date: LocalDate): Filter = dateComparison(date, DATE_=) + + def greaterThanConstant(date: LocalDate): Filter = dateComparison(date, DATE_>) + + def lessThanConstant(date: LocalDate): Filter = dateComparison(date, DATE_<) + + def greaterEqualConstant(date: LocalDate): Filter = dateComparison(date, DATE_>=) + + def lessEqualConstant(date: LocalDate): Filter = dateComparison(date, DATE_<=) } diff --git a/app/com/coleji/neptune/Util/Initializable.scala b/app/com/coleji/neptune/Util/Initializable.scala index 91068137..62ff6820 100644 --- a/app/com/coleji/neptune/Util/Initializable.scala +++ b/app/com/coleji/neptune/Util/Initializable.scala @@ -35,5 +35,18 @@ class Initializable[T] extends Serializable { def forEach(f: T => Unit): Unit = { if (isInitialized) f(this.get) } + + def findOneInCollection(collection: Traversable[T], find: T => Boolean): T = value match { + case None => { + collection.find(find) match { + case Some(t) => { + value = Some(t) + t + } + case None => throw new Exception("No match found in collection") + } + } + case Some(t) => t + } } diff --git a/app/com/coleji/neptune/Util/InitializableFromCollectionElement.scala b/app/com/coleji/neptune/Util/InitializableFromCollectionElement.scala deleted file mode 100644 index 725280be..00000000 --- a/app/com/coleji/neptune/Util/InitializableFromCollectionElement.scala +++ /dev/null @@ -1,16 +0,0 @@ -package com.coleji.neptune.Util - -class InitializableFromCollectionElement[T](find: (T => Boolean)) extends Initializable[T] { - def findOneInCollection(collection: Traversable[T]): T = value match { - case None => { - collection.find(find) match { - case Some(t) => { - value = Some(t) - t - } - case None => throw new Exception("No match found in collection") - } - } - case Some(t) => t - } -} diff --git a/app/com/coleji/neptune/Util/InitializableFromCollectionSubset.scala b/app/com/coleji/neptune/Util/InitializableFromCollectionSubset.scala deleted file mode 100644 index fd1a6c43..00000000 --- a/app/com/coleji/neptune/Util/InitializableFromCollectionSubset.scala +++ /dev/null @@ -1,12 +0,0 @@ -package com.coleji.neptune.Util - -class InitializableFromCollectionSubset[U <: Traversable[T], T](filter: (T => Boolean)) extends Initializable[U] { - def findAllInCollection(collection: U): U = value match { - case None => { - val ret = collection.filter(filter).asInstanceOf[U] - value = Some(ret) - ret - } - case Some(t) => t - } -} diff --git a/app/com/coleji/neptune/Util/InitializableSeq.scala b/app/com/coleji/neptune/Util/InitializableSeq.scala new file mode 100644 index 00000000..ba29aaf8 --- /dev/null +++ b/app/com/coleji/neptune/Util/InitializableSeq.scala @@ -0,0 +1,12 @@ +package com.coleji.neptune.Util + +class InitializableSeq[U, T <: Seq[U]] extends Initializable[T]{ + def findAllInCollection(collection: T, filter: U => Boolean): T = value match { + case None => { + val ret = collection.filter(filter).asInstanceOf[T] + value = Some(ret) + ret + } + case Some(t) => t + } +} diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ApClassInstance.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ApClassInstance.scala index 00a321dd..7e998167 100644 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ApClassInstance.scala +++ b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ApClassInstance.scala @@ -11,8 +11,8 @@ import play.api.libs.json._ class ApClassInstance extends StorableClass(ApClassInstance) { override object references extends ReferencesObject { val apClassFormat = new Initializable[ApClassFormat] - val apClassSessions = new Initializable[IndexedSeq[ApClassSession]] - val apClassSignups = new Initializable[IndexedSeq[ApClassSignup]] + val apClassSessions = new InitializableSeq[ApClassSession, IndexedSeq[ApClassSession]] + val apClassSignups = new InitializableSeq[ApClassSignup, IndexedSeq[ApClassSignup]] val instructor = new Initializable[Option[Person]] } diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ApClassType.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ApClassType.scala index c1e60e6e..335b1ef5 100644 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ApClassType.scala +++ b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ApClassType.scala @@ -10,7 +10,7 @@ import play.api.libs.json._ class ApClassType extends StorableClass(ApClassType) { override object references extends ReferencesObject { - val apClassFormats = new Initializable[IndexedSeq[ApClassFormat]] + val apClassFormats = new InitializableSeq[ApClassFormat, IndexedSeq[ApClassFormat]] } override object values extends ValuesObject { diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/CriticalError.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/CriticalError.scala deleted file mode 100644 index c36fd2d2..00000000 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/CriticalError.scala +++ /dev/null @@ -1,27 +0,0 @@ -package org.sailcbi.APIServer.Entities.EntityDefinitions - -import com.coleji.neptune.Storable.FieldValues._ -import com.coleji.neptune.Storable.Fields._ -import com.coleji.neptune.Storable._ -import com.coleji.neptune.Util._ -import org.sailcbi.APIServer.Entities.NullableInDatabase -import org.sailcbi.APIServer.Entities.entitycalculations._ -import play.api.libs.json._ - -class CriticalError extends StorableClass(CriticalError) { - override object values extends ValuesObject { - val errorText = new NullableStringFieldValue(self, CriticalError.fields.errorText) - val isMinor = new NullableBooleanFieldValue(self, CriticalError.fields.isMinor) - } -} - -object CriticalError extends StorableObject[CriticalError] { - override val useRuntimeFieldnamesForJson: Boolean = true - - override val entityName: String = "CRITICAL_ERRORS" - - object fields extends FieldsObject { - val errorText = new NullableStringDatabaseField(self, "ERROR_TEXT", 4000) - val isMinor = new NullableBooleanDatabaseField(self, "IS_MINOR") - } -} \ No newline at end of file diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/DonationFund.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/DonationFund.scala index 07309d95..1159551a 100644 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/DonationFund.scala +++ b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/DonationFund.scala @@ -16,11 +16,11 @@ class DonationFund extends StorableClass(DonationFund) { val createdBy = new StringFieldValue(self, DonationFund.fields.createdBy) val updatedOn = new DateTimeFieldValue(self, DonationFund.fields.updatedOn) val updatedBy = new StringFieldValue(self, DonationFund.fields.updatedBy) - val active = new NullableBooleanFieldValue(self, DonationFund.fields.active) + val active = new BooleanFieldValue(self, DonationFund.fields.active) val displayOrder = new NullableDoubleFieldValue(self, DonationFund.fields.displayOrder) val letterText = new NullableStringFieldValue(self, DonationFund.fields.letterText) - val showInCheckout = new NullableBooleanFieldValue(self, DonationFund.fields.showInCheckout) - val isEndowment = new NullableBooleanFieldValue(self, DonationFund.fields.isEndowment) + val showInCheckout = new BooleanFieldValue(self, DonationFund.fields.showInCheckout) + val isEndowment = new BooleanFieldValue(self, DonationFund.fields.isEndowment) val portalDescription = new NullableStringFieldValue(self, DonationFund.fields.portalDescription) } } @@ -42,11 +42,14 @@ object DonationFund extends StorableObject[DonationFund] { val updatedOn = new DateTimeDatabaseField(self, "UPDATED_ON") @NullableInDatabase val updatedBy = new StringDatabaseField(self, "UPDATED_BY", 500) - val active = new NullableBooleanDatabaseField(self, "ACTIVE") + @NullableInDatabase + val active = new BooleanDatabaseField(self, "ACTIVE", true) val displayOrder = new NullableDoubleDatabaseField(self, "DISPLAY_ORDER") val letterText = new NullableStringDatabaseField(self, "LETTER_TEXT", 500) - val showInCheckout = new NullableBooleanDatabaseField(self, "SHOW_IN_CHECKOUT") - val isEndowment = new NullableBooleanDatabaseField(self, "IS_ENDOWMENT") + @NullableInDatabase + val showInCheckout = new BooleanDatabaseField(self, "SHOW_IN_CHECKOUT", true) + @NullableInDatabase + val isEndowment = new BooleanDatabaseField(self, "IS_ENDOWMENT", true) val portalDescription = new NullableStringDatabaseField(self, "PORTAL_DESCRIPTION", 2000) } diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/HighSchool.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/HighSchool.scala index e93ca222..8295c989 100644 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/HighSchool.scala +++ b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/HighSchool.scala @@ -16,7 +16,7 @@ class HighSchool extends StorableClass(HighSchool) { val createdBy = new StringFieldValue(self, HighSchool.fields.createdBy) val updatedOn = new DateTimeFieldValue(self, HighSchool.fields.updatedOn) val updatedBy = new StringFieldValue(self, HighSchool.fields.updatedBy) - val active = new NullableBooleanFieldValue(self, HighSchool.fields.active) + val active = new BooleanFieldValue(self, HighSchool.fields.active) val displayOrder = new NullableDoubleFieldValue(self, HighSchool.fields.displayOrder) } } @@ -38,7 +38,8 @@ object HighSchool extends StorableObject[HighSchool] { val updatedOn = new DateTimeDatabaseField(self, "UPDATED_ON") @NullableInDatabase val updatedBy = new StringDatabaseField(self, "UPDATED_BY", 500) - val active = new NullableBooleanDatabaseField(self, "ACTIVE") + @NullableInDatabase + val active = new BooleanDatabaseField(self, "ACTIVE", true) val displayOrder = new NullableDoubleDatabaseField(self, "DISPLAY_ORDER") } diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/HtmldbPlanTable.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/HtmldbPlanTable.scala deleted file mode 100644 index 4304ba31..00000000 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/HtmldbPlanTable.scala +++ /dev/null @@ -1,93 +0,0 @@ -package org.sailcbi.APIServer.Entities.EntityDefinitions - -import com.coleji.neptune.Storable.FieldValues._ -import com.coleji.neptune.Storable.Fields._ -import com.coleji.neptune.Storable._ -import com.coleji.neptune.Util._ -import org.sailcbi.APIServer.Entities.NullableInDatabase -import org.sailcbi.APIServer.Entities.entitycalculations._ -import play.api.libs.json._ - -class HtmldbPlanTable extends StorableClass(HtmldbPlanTable) { - override object values extends ValuesObject { - val statementId = new NullableStringFieldValue(self, HtmldbPlanTable.fields.statementId) - val planId = new NullableIntFieldValue(self, HtmldbPlanTable.fields.planId) - val timestamp = new NullableDateTimeFieldValue(self, HtmldbPlanTable.fields.timestamp) - val remarks = new NullableStringFieldValue(self, HtmldbPlanTable.fields.remarks) - val operation = new NullableStringFieldValue(self, HtmldbPlanTable.fields.operation) - val options = new NullableStringFieldValue(self, HtmldbPlanTable.fields.options) - val objectNode = new NullableStringFieldValue(self, HtmldbPlanTable.fields.objectNode) - val objectOwner = new NullableStringFieldValue(self, HtmldbPlanTable.fields.objectOwner) - val objectName = new NullableStringFieldValue(self, HtmldbPlanTable.fields.objectName) - val objectAlias = new NullableStringFieldValue(self, HtmldbPlanTable.fields.objectAlias) - val objectInstance = new NullableDoubleFieldValue(self, HtmldbPlanTable.fields.objectInstance) - val objectType = new NullableStringFieldValue(self, HtmldbPlanTable.fields.objectType) - val optimizer = new NullableStringFieldValue(self, HtmldbPlanTable.fields.optimizer) - val searchColumns = new NullableDoubleFieldValue(self, HtmldbPlanTable.fields.searchColumns) - val id = new NullableIntFieldValue(self, HtmldbPlanTable.fields.id) - val parentId = new NullableIntFieldValue(self, HtmldbPlanTable.fields.parentId) - val depth = new NullableDoubleFieldValue(self, HtmldbPlanTable.fields.depth) - val position = new NullableDoubleFieldValue(self, HtmldbPlanTable.fields.position) - val cost = new NullableDoubleFieldValue(self, HtmldbPlanTable.fields.cost) - val cardinality = new NullableDoubleFieldValue(self, HtmldbPlanTable.fields.cardinality) - val bytes = new NullableDoubleFieldValue(self, HtmldbPlanTable.fields.bytes) - val otherTag = new NullableStringFieldValue(self, HtmldbPlanTable.fields.otherTag) - val partitionStart = new NullableStringFieldValue(self, HtmldbPlanTable.fields.partitionStart) - val partitionStop = new NullableStringFieldValue(self, HtmldbPlanTable.fields.partitionStop) - val partitionId = new NullableIntFieldValue(self, HtmldbPlanTable.fields.partitionId) - val other = new NullableDoubleFieldValue(self, HtmldbPlanTable.fields.other) - val distribution = new NullableStringFieldValue(self, HtmldbPlanTable.fields.distribution) - val cpuCost = new NullableDoubleFieldValue(self, HtmldbPlanTable.fields.cpuCost) - val ioCost = new NullableDoubleFieldValue(self, HtmldbPlanTable.fields.ioCost) - val tempSpace = new NullableDoubleFieldValue(self, HtmldbPlanTable.fields.tempSpace) - val accessPredicates = new NullableStringFieldValue(self, HtmldbPlanTable.fields.accessPredicates) - val filterPredicates = new NullableStringFieldValue(self, HtmldbPlanTable.fields.filterPredicates) - val projection = new NullableStringFieldValue(self, HtmldbPlanTable.fields.projection) - val time = new NullableDoubleFieldValue(self, HtmldbPlanTable.fields.time) - val qblockName = new NullableStringFieldValue(self, HtmldbPlanTable.fields.qblockName) - } -} - -object HtmldbPlanTable extends StorableObject[HtmldbPlanTable] { - override val useRuntimeFieldnamesForJson: Boolean = true - - override val entityName: String = "HTMLDB_PLAN_TABLE" - - object fields extends FieldsObject { - val statementId = new NullableStringDatabaseField(self, "STATEMENT_ID", 30) - val planId = new NullableIntDatabaseField(self, "PLAN_ID") - val timestamp = new NullableDateTimeDatabaseField(self, "TIMESTAMP") - val remarks = new NullableStringDatabaseField(self, "REMARKS", 4000) - val operation = new NullableStringDatabaseField(self, "OPERATION", 30) - val options = new NullableStringDatabaseField(self, "OPTIONS", 255) - val objectNode = new NullableStringDatabaseField(self, "OBJECT_NODE", 128) - val objectOwner = new NullableStringDatabaseField(self, "OBJECT_OWNER", 128) - val objectName = new NullableStringDatabaseField(self, "OBJECT_NAME", 128) - val objectAlias = new NullableStringDatabaseField(self, "OBJECT_ALIAS", 261) - val objectInstance = new NullableDoubleDatabaseField(self, "OBJECT_INSTANCE") - val objectType = new NullableStringDatabaseField(self, "OBJECT_TYPE", 128) - val optimizer = new NullableStringDatabaseField(self, "OPTIMIZER", 255) - val searchColumns = new NullableDoubleDatabaseField(self, "SEARCH_COLUMNS") - val id = new NullableIntDatabaseField(self, "ID") - val parentId = new NullableIntDatabaseField(self, "PARENT_ID") - val depth = new NullableDoubleDatabaseField(self, "DEPTH") - val position = new NullableDoubleDatabaseField(self, "POSITION") - val cost = new NullableDoubleDatabaseField(self, "COST") - val cardinality = new NullableDoubleDatabaseField(self, "CARDINALITY") - val bytes = new NullableDoubleDatabaseField(self, "BYTES") - val otherTag = new NullableStringDatabaseField(self, "OTHER_TAG", 255) - val partitionStart = new NullableStringDatabaseField(self, "PARTITION_START", 255) - val partitionStop = new NullableStringDatabaseField(self, "PARTITION_STOP", 255) - val partitionId = new NullableIntDatabaseField(self, "PARTITION_ID") - val other = new NullableDoubleDatabaseField(self, "OTHER") - val distribution = new NullableStringDatabaseField(self, "DISTRIBUTION", 30) - val cpuCost = new NullableDoubleDatabaseField(self, "CPU_COST") - val ioCost = new NullableDoubleDatabaseField(self, "IO_COST") - val tempSpace = new NullableDoubleDatabaseField(self, "TEMP_SPACE") - val accessPredicates = new NullableStringDatabaseField(self, "ACCESS_PREDICATES", 4000) - val filterPredicates = new NullableStringDatabaseField(self, "FILTER_PREDICATES", 4000) - val projection = new NullableStringDatabaseField(self, "PROJECTION", 4000) - val time = new NullableDoubleDatabaseField(self, "TIME") - val qblockName = new NullableStringDatabaseField(self, "QBLOCK_NAME", 128) - } -} \ No newline at end of file diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/JpClassInstance.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/JpClassInstance.scala index d0fdc590..2adcb618 100644 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/JpClassInstance.scala +++ b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/JpClassInstance.scala @@ -9,12 +9,19 @@ import org.sailcbi.APIServer.Entities.entitycalculations._ import play.api.libs.json._ class JpClassInstance extends StorableClass(JpClassInstance) { + + override object calculations extends CalculationsObject { + lazy val firstSession: JpClassSession = references.jpClassSessions.get.sortWith((a: JpClassSession, b: JpClassSession) => { + a.values.sessionDatetime.get.isBefore(b.values.sessionDatetime.get) + }).head + } + override object references extends ReferencesObject { val classLocation = new Initializable[Option[ClassLocation]] val classInstructor = new Initializable[Option[ClassInstructor]] val jpClassType = new Initializable[JpClassType] - val jpClassSessions = new Initializable[IndexedSeq[JpClassSession]] - val jpClassSignups = new Initializable[IndexedSeq[JpClassSignup]] + val jpClassSessions = new InitializableSeq[JpClassSession, IndexedSeq[JpClassSession]] + val jpClassSignups = new InitializableSeq[JpClassSignup, IndexedSeq[JpClassSignup]] } override object values extends ValuesObject { diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/JpClassSession.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/JpClassSession.scala index 6251f633..1ea5cf77 100644 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/JpClassSession.scala +++ b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/JpClassSession.scala @@ -9,6 +9,11 @@ import org.sailcbi.APIServer.Entities.entitycalculations._ import play.api.libs.json._ class JpClassSession extends StorableClass(JpClassSession) { + + override object calculations extends CalculationsObject { + val weekAlias = new Initializable[Option[String]] + } + override object references extends ReferencesObject { val jpClassInstance = new Initializable[JpClassInstance] } diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/JpSpecialNeedsCopy.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/JpSpecialNeedsCopy.scala deleted file mode 100644 index dfbcb6e5..00000000 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/JpSpecialNeedsCopy.scala +++ /dev/null @@ -1,37 +0,0 @@ -package org.sailcbi.APIServer.Entities.EntityDefinitions - -import com.coleji.neptune.Storable.FieldValues._ -import com.coleji.neptune.Storable.Fields._ -import com.coleji.neptune.Storable._ -import com.coleji.neptune.Util._ -import org.sailcbi.APIServer.Entities.NullableInDatabase -import org.sailcbi.APIServer.Entities.entitycalculations._ -import play.api.libs.json._ - -class JpSpecialNeedsCopy extends StorableClass(JpSpecialNeedsCopy) { - override object values extends ValuesObject { - val cardId = new NullableIntFieldValue(self, JpSpecialNeedsCopy.fields.cardId) - val cardNum = new NullableStringFieldValue(self, JpSpecialNeedsCopy.fields.cardNum) - val personId = new NullableIntFieldValue(self, JpSpecialNeedsCopy.fields.personId) - val createdOn = new NullableDateTimeFieldValue(self, JpSpecialNeedsCopy.fields.createdOn) - val createdBy = new NullableStringFieldValue(self, JpSpecialNeedsCopy.fields.createdBy) - val updatedOn = new NullableDateTimeFieldValue(self, JpSpecialNeedsCopy.fields.updatedOn) - val updatedBy = new NullableStringFieldValue(self, JpSpecialNeedsCopy.fields.updatedBy) - } -} - -object JpSpecialNeedsCopy extends StorableObject[JpSpecialNeedsCopy] { - override val useRuntimeFieldnamesForJson: Boolean = true - - override val entityName: String = "JP_SPECIAL_NEEDS_COPY" - - object fields extends FieldsObject { - val cardId = new NullableIntDatabaseField(self, "CARD_ID") - val cardNum = new NullableStringDatabaseField(self, "CARD_NUM", 50) - val personId = new NullableIntDatabaseField(self, "PERSON_ID") - val createdOn = new NullableDateTimeDatabaseField(self, "CREATED_ON") - val createdBy = new NullableStringDatabaseField(self, "CREATED_BY", 500) - val updatedOn = new NullableDateTimeDatabaseField(self, "UPDATED_ON") - val updatedBy = new NullableStringDatabaseField(self, "UPDATED_BY", 500) - } -} \ No newline at end of file diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/MembershipTypeExp.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/MembershipTypeExp.scala index a51425a9..b962a4cc 100644 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/MembershipTypeExp.scala +++ b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/MembershipTypeExp.scala @@ -16,7 +16,7 @@ class MembershipTypeExp extends StorableClass(MembershipTypeExp) { override object values extends ValuesObject { val expirationId = new IntFieldValue(self, MembershipTypeExp.fields.expirationId) val membershipTypeId = new IntFieldValue(self, MembershipTypeExp.fields.membershipTypeId) - val season = new DoubleFieldValue(self, MembershipTypeExp.fields.season) + val season = new IntFieldValue(self, MembershipTypeExp.fields.season) val expirationDate = new DateTimeFieldValue(self, MembershipTypeExp.fields.expirationDate) val createdOn = new DateTimeFieldValue(self, MembershipTypeExp.fields.createdOn) val createdBy = new StringFieldValue(self, MembershipTypeExp.fields.createdBy) @@ -34,7 +34,7 @@ object MembershipTypeExp extends StorableObject[MembershipTypeExp] { object fields extends FieldsObject { val expirationId = new IntDatabaseField(self, "EXPIRATION_ID") val membershipTypeId = new IntDatabaseField(self, "MEMBERSHIP_TYPE_ID") - val season = new DoubleDatabaseField(self, "SEASON") + val season = new IntDatabaseField(self, "SEASON") val expirationDate = new DateTimeDatabaseField(self, "EXPIRATION_DATE") @NullableInDatabase val createdOn = new DateTimeDatabaseField(self, "CREATED_ON") diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/Person.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/Person.scala index 3a22723f..c08ce06a 100644 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/Person.scala +++ b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/Person.scala @@ -15,7 +15,7 @@ class Person extends StorableClass(Person) { } override object references extends ReferencesObject { - val personRatings = new Initializable[IndexedSeq[PersonRating]] + val personRatings = new InitializableSeq[PersonRating, IndexedSeq[PersonRating]] } override object values extends ValuesObject { diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/PersonRelationship.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/PersonRelationship.scala index a93a2d1e..947f7c26 100644 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/PersonRelationship.scala +++ b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/PersonRelationship.scala @@ -16,8 +16,8 @@ class PersonRelationship extends StorableClass(PersonRelationship) { override object values extends ValuesObject { val relationId = new IntFieldValue(self, PersonRelationship.fields.relationId) - val a = new DoubleFieldValue(self, PersonRelationship.fields.a) - val b = new DoubleFieldValue(self, PersonRelationship.fields.b) + val a = new IntFieldValue(self, PersonRelationship.fields.a) + val b = new IntFieldValue(self, PersonRelationship.fields.b) val typeId = new IntFieldValue(self, PersonRelationship.fields.typeId) val createdOn = new DateTimeFieldValue(self, PersonRelationship.fields.createdOn) val createdBy = new NullableStringFieldValue(self, PersonRelationship.fields.createdBy) @@ -34,9 +34,9 @@ object PersonRelationship extends StorableObject[PersonRelationship] { object fields extends FieldsObject { val relationId = new IntDatabaseField(self, "RELATION_ID") @NullableInDatabase - val a = new DoubleDatabaseField(self, "A") + val a = new IntDatabaseField(self, "A") @NullableInDatabase - val b = new DoubleDatabaseField(self, "B") + val b = new IntDatabaseField(self, "B") @NullableInDatabase val typeId = new IntDatabaseField(self, "TYPE_ID") @NullableInDatabase diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/Rating.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/Rating.scala index 26fee25a..99215ebc 100644 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/Rating.scala +++ b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/Rating.scala @@ -10,8 +10,8 @@ import play.api.libs.json._ class Rating extends StorableClass(Rating) { override object references extends ReferencesObject { - val boats = new Initializable[IndexedSeq[BoatRating]] - val programs = new Initializable[IndexedSeq[RatingProgram]] + val boats = new InitializableSeq[BoatRating, IndexedSeq[BoatRating]] + val programs = new InitializableSeq[RatingProgram, IndexedSeq[RatingProgram]] } override object values extends ValuesObject { @@ -23,7 +23,7 @@ class Rating extends StorableClass(Rating) { val updatedBy = new StringFieldValue(self, Rating.fields.updatedBy) val displayOrder = new DoubleFieldValue(self, Rating.fields.displayOrder) val active = new NullableBooleanFieldValue(self, Rating.fields.active) - val overriddenBy = new NullableDoubleFieldValue(self, Rating.fields.overriddenBy) + val overriddenBy = new NullableIntFieldValue(self, Rating.fields.overriddenBy) val testMinCrew = new NullableDoubleFieldValue(self, Rating.fields.testMinCrew) val testMaxCrew = new NullableDoubleFieldValue(self, Rating.fields.testMaxCrew) val testable = new NullableBooleanFieldValue(self, Rating.fields.testable) @@ -51,7 +51,7 @@ object Rating extends StorableObject[Rating] { @NullableInDatabase val displayOrder = new DoubleDatabaseField(self, "DISPLAY_ORDER") val active = new NullableBooleanDatabaseField(self, "ACTIVE") - val overriddenBy = new NullableDoubleDatabaseField(self, "OVERRIDDEN_BY") + val overriddenBy = new NullableIntDatabaseField(self, "OVERRIDDEN_BY") val testMinCrew = new NullableDoubleDatabaseField(self, "TEST_MIN_CREW") val testMaxCrew = new NullableDoubleDatabaseField(self, "TEST_MAX_CREW") val testable = new NullableBooleanDatabaseField(self, "TESTABLE") diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ShoppingCartMembershipsArch.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ShoppingCartMembershipsArch.scala deleted file mode 100644 index 384d2d64..00000000 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ShoppingCartMembershipsArch.scala +++ /dev/null @@ -1,57 +0,0 @@ -package org.sailcbi.APIServer.Entities.EntityDefinitions - -import com.coleji.neptune.Storable.FieldValues._ -import com.coleji.neptune.Storable.Fields._ -import com.coleji.neptune.Storable._ -import com.coleji.neptune.Util._ -import org.sailcbi.APIServer.Entities.NullableInDatabase -import org.sailcbi.APIServer.Entities.entitycalculations._ -import play.api.libs.json._ - -class ShoppingCartMembershipsArch extends StorableClass(ShoppingCartMembershipsArch) { - override object values extends ValuesObject { - val itemId = new NullableIntFieldValue(self, ShoppingCartMembershipsArch.fields.itemId) - val membershipTypeId = new NullableIntFieldValue(self, ShoppingCartMembershipsArch.fields.membershipTypeId) - val price = new DoubleFieldValue(self, ShoppingCartMembershipsArch.fields.price) - val createdOn = new DateTimeFieldValue(self, ShoppingCartMembershipsArch.fields.createdOn) - val createdBy = new NullableStringFieldValue(self, ShoppingCartMembershipsArch.fields.createdBy) - val updatedOn = new DateTimeFieldValue(self, ShoppingCartMembershipsArch.fields.updatedOn) - val updatedBy = new NullableStringFieldValue(self, ShoppingCartMembershipsArch.fields.updatedBy) - val personId = new IntFieldValue(self, ShoppingCartMembershipsArch.fields.personId) - val readyToBuy = new StringFieldValue(self, ShoppingCartMembershipsArch.fields.readyToBuy) - val orderId = new IntFieldValue(self, ShoppingCartMembershipsArch.fields.orderId) - val specNeedsApproved = new NullableBooleanFieldValue(self, ShoppingCartMembershipsArch.fields.specNeedsApproved) - val discountAmt = new NullableDoubleFieldValue(self, ShoppingCartMembershipsArch.fields.discountAmt) - val discountId = new NullableIntFieldValue(self, ShoppingCartMembershipsArch.fields.discountId) - val discountInstanceId = new NullableIntFieldValue(self, ShoppingCartMembershipsArch.fields.discountInstanceId) - val hasJpClassReservations = new NullableBooleanFieldValue(self, ShoppingCartMembershipsArch.fields.hasJpClassReservations) - val requestedDiscountInstanceId = new NullableIntFieldValue(self, ShoppingCartMembershipsArch.fields.requestedDiscountInstanceId) - } -} - -object ShoppingCartMembershipsArch extends StorableObject[ShoppingCartMembershipsArch] { - override val useRuntimeFieldnamesForJson: Boolean = true - - override val entityName: String = "SHOPPING_CART_MEMBERSHIPS_ARCH" - - object fields extends FieldsObject { - val itemId = new NullableIntDatabaseField(self, "ITEM_ID") - val membershipTypeId = new NullableIntDatabaseField(self, "MEMBERSHIP_TYPE_ID") - val price = new DoubleDatabaseField(self, "PRICE") - @NullableInDatabase - val createdOn = new DateTimeDatabaseField(self, "CREATED_ON") - val createdBy = new NullableStringDatabaseField(self, "CREATED_BY", 500) - @NullableInDatabase - val updatedOn = new DateTimeDatabaseField(self, "UPDATED_ON") - val updatedBy = new NullableStringDatabaseField(self, "UPDATED_BY", 500) - val personId = new IntDatabaseField(self, "PERSON_ID") - val readyToBuy = new StringDatabaseField(self, "READY_TO_BUY", 1) - val orderId = new IntDatabaseField(self, "ORDER_ID") - val specNeedsApproved = new NullableBooleanDatabaseField(self, "SPEC_NEEDS_APPROVED") - val discountAmt = new NullableDoubleDatabaseField(self, "DISCOUNT_AMT") - val discountId = new NullableIntDatabaseField(self, "DISCOUNT_ID") - val discountInstanceId = new NullableIntDatabaseField(self, "DISCOUNT_INSTANCE_ID") - val hasJpClassReservations = new NullableBooleanDatabaseField(self, "HAS_JP_CLASS_RESERVATIONS") - val requestedDiscountInstanceId = new NullableIntDatabaseField(self, "REQUESTED_DISCOUNT_INSTANCE_ID") - } -} \ No newline at end of file diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/Signout.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/Signout.scala index 36996d46..b6b8d2da 100644 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/Signout.scala +++ b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/Signout.scala @@ -11,8 +11,8 @@ import play.api.libs.json._ class Signout extends StorableClass(Signout) { override object references extends ReferencesObject { val skipper = new Initializable[Person] - val crew = new Initializable[IndexedSeq[SignoutCrew]] - val tests = new Initializable[IndexedSeq[SignoutTest]] + val crew = new InitializableSeq[SignoutCrew, IndexedSeq[SignoutCrew]] + val tests = new InitializableSeq[SignoutTest, IndexedSeq[SignoutTest]] } override object values extends ValuesObject { diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/TempGc.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/TempGc.scala deleted file mode 100644 index decfb895..00000000 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/TempGc.scala +++ /dev/null @@ -1,27 +0,0 @@ -package org.sailcbi.APIServer.Entities.EntityDefinitions - -import com.coleji.neptune.Storable.FieldValues._ -import com.coleji.neptune.Storable.Fields._ -import com.coleji.neptune.Storable._ -import com.coleji.neptune.Util._ -import org.sailcbi.APIServer.Entities.NullableInDatabase -import org.sailcbi.APIServer.Entities.entitycalculations._ -import play.api.libs.json._ - -class TempGc extends StorableClass(TempGc) { - override object values extends ValuesObject { - val redemptionCode = new NullableStringFieldValue(self, TempGc.fields.redemptionCode) - val certNumber = new NullableDoubleFieldValue(self, TempGc.fields.certNumber) - } -} - -object TempGc extends StorableObject[TempGc] { - override val useRuntimeFieldnamesForJson: Boolean = true - - override val entityName: String = "TEMP_GC" - - object fields extends FieldsObject { - val redemptionCode = new NullableStringDatabaseField(self, "REDEMPTION_CODE", 30) - val certNumber = new NullableDoubleDatabaseField(self, "CERT_NUMBER") - } -} \ No newline at end of file diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/TmpWomensRacing.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/TmpWomensRacing.scala deleted file mode 100644 index d85bda77..00000000 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/TmpWomensRacing.scala +++ /dev/null @@ -1,25 +0,0 @@ -package org.sailcbi.APIServer.Entities.EntityDefinitions - -import com.coleji.neptune.Storable.FieldValues._ -import com.coleji.neptune.Storable.Fields._ -import com.coleji.neptune.Storable._ -import com.coleji.neptune.Util._ -import org.sailcbi.APIServer.Entities.NullableInDatabase -import org.sailcbi.APIServer.Entities.entitycalculations._ -import play.api.libs.json._ - -class TmpWomensRacing extends StorableClass(TmpWomensRacing) { - override object values extends ValuesObject { - val email = new NullableStringFieldValue(self, TmpWomensRacing.fields.email) - } -} - -object TmpWomensRacing extends StorableObject[TmpWomensRacing] { - override val useRuntimeFieldnamesForJson: Boolean = true - - override val entityName: String = "TMP_WOMENS_RACING" - - object fields extends FieldsObject { - val email = new NullableStringDatabaseField(self, "EMAIL", 100) - } -} \ No newline at end of file diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/User.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/User.scala index 5b4597e1..908fe3d8 100644 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/User.scala +++ b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/User.scala @@ -10,7 +10,7 @@ import play.api.libs.json._ class User extends StorableClass(User) { override object references extends ReferencesObject { - val extraRoles = new Initializable[List[UserRole]] + val extraRoles = new InitializableSeq[UserRole, List[UserRole]] } override object values extends ValuesObject { diff --git a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ZKeepalive.scala b/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ZKeepalive.scala deleted file mode 100644 index 812e0d47..00000000 --- a/app/org/sailcbi/APIServer/Entities/EntityDefinitions/ZKeepalive.scala +++ /dev/null @@ -1,25 +0,0 @@ -package org.sailcbi.APIServer.Entities.EntityDefinitions - -import com.coleji.neptune.Storable.FieldValues._ -import com.coleji.neptune.Storable.Fields._ -import com.coleji.neptune.Storable._ -import com.coleji.neptune.Util._ -import org.sailcbi.APIServer.Entities.NullableInDatabase -import org.sailcbi.APIServer.Entities.entitycalculations._ -import play.api.libs.json._ - -class ZKeepalive extends StorableClass(ZKeepalive) { - override object values extends ValuesObject { - val a = new NullableDoubleFieldValue(self, ZKeepalive.fields.a) - } -} - -object ZKeepalive extends StorableObject[ZKeepalive] { - override val useRuntimeFieldnamesForJson: Boolean = true - - override val entityName: String = "Z_KEEPALIVE" - - object fields extends FieldsObject { - val a = new NullableDoubleDatabaseField(self, "A") - } -} \ No newline at end of file diff --git a/app/org/sailcbi/APIServer/Entities/MagicIds.scala b/app/org/sailcbi/APIServer/Entities/MagicIds.scala index 1804976b..5438654b 100644 --- a/app/org/sailcbi/APIServer/Entities/MagicIds.scala +++ b/app/org/sailcbi/APIServer/Entities/MagicIds.scala @@ -77,4 +77,7 @@ object MagicIds { val RIGGING = "G" val RENTAL = "N" } + object TAG_IDS { + val CORPORATION = 5 + } } diff --git a/app/org/sailcbi/APIServer/Entities/dto/PutEventDTO.scala b/app/org/sailcbi/APIServer/Entities/dto/PutEventDTO.scala index 5916d8e4..20261a47 100644 --- a/app/org/sailcbi/APIServer/Entities/dto/PutEventDTO.scala +++ b/app/org/sailcbi/APIServer/Entities/dto/PutEventDTO.scala @@ -15,7 +15,7 @@ case class PutEventDTO ( override def mutateStorableForUpdate(s: Event): Event = { s.update(_.eventName, EVENT_NAME) - s.update(_.eventDateTime, EVENT_DATE) + s.update(_.eventDate, EVENT_DATE) s } diff --git a/app/org/sailcbi/APIServer/Entities/dto/PutGuestPrivDTO.scala b/app/org/sailcbi/APIServer/Entities/dto/PutGuestPrivDTO.scala index c114849b..6295bb1a 100644 --- a/app/org/sailcbi/APIServer/Entities/dto/PutGuestPrivDTO.scala +++ b/app/org/sailcbi/APIServer/Entities/dto/PutGuestPrivDTO.scala @@ -11,7 +11,7 @@ case class PutGuestPrivDTO ( override def getId: Option[Int] = MEMBERSHIP_ID override def mutateStorableForUpdate(s: GuestPriv): GuestPriv = { - s.update(_.price, PRICE) + s.update(_.price, PRICE.get) s } diff --git a/app/org/sailcbi/APIServer/IO/CachedData.scala b/app/org/sailcbi/APIServer/IO/CachedData.scala index d3315fea..a470c78a 100644 --- a/app/org/sailcbi/APIServer/IO/CachedData.scala +++ b/app/org/sailcbi/APIServer/IO/CachedData.scala @@ -68,7 +68,7 @@ class CachedData(rc: UnlockedRequestCache) { MembershipType.fields.programId, MembershipType.fields.price, )).map(m => { - m.references.program.findOneInCollection(programTypes) + m.references.program.findOneInCollection(programTypes, _.values.programId.get == m.values.programId.get) m }) } @@ -80,7 +80,7 @@ class CachedData(rc: UnlockedRequestCache) { MembershipTypeExp.fields.startDate, MembershipTypeExp.fields.expirationDate, )).map(me => { - me.references.membershipType.findOneInCollection(membershipTypes) + me.references.membershipType.findOneInCollection(membershipTypes, _.values.membershipTypeId.get == me.values.membershipTypeId.get) me }) } diff --git a/app/org/sailcbi/APIServer/IO/JP/AllJPClassInstances.scala b/app/org/sailcbi/APIServer/IO/JP/AllJPClassInstances.scala index a3c4d39b..59a9e3e7 100644 --- a/app/org/sailcbi/APIServer/IO/JP/AllJPClassInstances.scala +++ b/app/org/sailcbi/APIServer/IO/JP/AllJPClassInstances.scala @@ -35,12 +35,12 @@ object AllJPClassInstances { val groupedSessions = allSessions.groupBy(_.references.jpClassInstance.get) groupedSessions.map(Function.tupled((instance, sessions) => { - val sorted = sessions.sortWith((a, b) => a.values.sessionDateTime.get.isBefore(b.values.sessionDateTime.get)) - val min = sorted.head.values.sessionDateTime.get - val max = sorted.last.values.sessionDateTime.get + val sorted = sessions.sortWith((a, b) => a.values.sessionDatetime.get.isBefore(b.values.sessionDatetime.get)) + val min = sorted.head.values.sessionDatetime.get + val max = sorted.last.values.sessionDatetime.get val sessionLength = sorted.head.values.lengthOverride.get match { case Some(d) => d - case None => instance.references.jpClassType.get.values.sessionlength.get + case None => instance.references.jpClassType.get.values.sessionLength.get } (instance, min, max, sessionLength) })).toList diff --git a/app/org/sailcbi/APIServer/Logic/JpClassLogic.scala b/app/org/sailcbi/APIServer/Logic/JpClassLogic.scala new file mode 100644 index 00000000..18f450d1 --- /dev/null +++ b/app/org/sailcbi/APIServer/Logic/JpClassLogic.scala @@ -0,0 +1,13 @@ +package org.sailcbi.APIServer.Logic + +import com.coleji.neptune.Core.UnlockedRequestCache +import org.sailcbi.APIServer.Entities.EntityDefinitions.JpClassSession +import org.sailcbi.APIServer.IO.CachedData + +object JpClassLogic { + // TODO: not loving this + def setWeekAlias(session: JpClassSession, rc: UnlockedRequestCache) = { + val cache = new CachedData(rc) + cache.getJpWeekAlias(session.values.sessionDatetime.get.toLocalDate) + } +} diff --git a/app/org/sailcbi/APIServer/Logic/RatingLogic.scala b/app/org/sailcbi/APIServer/Logic/RatingLogic.scala index 5af53a80..85dc6cf7 100644 --- a/app/org/sailcbi/APIServer/Logic/RatingLogic.scala +++ b/app/org/sailcbi/APIServer/Logic/RatingLogic.scala @@ -85,4 +85,12 @@ object RatingLogic { } } } + + def getAllHigherRatingsThanRating(ratings: List[Rating], targetRatingId: Int): List[Rating] = { + val targetRating: Rating = ratings.filter(_.values.ratingId.get == targetRatingId).head + targetRating.values.overriddenBy.get match { + case Some(i: Int) => targetRating :: getAllHigherRatingsThanRating(ratings, i) + case None => targetRating :: Nil + } + } } diff --git a/app/org/sailcbi/APIServer/Reporting/ReportFactories/ReportFactoryJpClassInstance.scala b/app/org/sailcbi/APIServer/Reporting/ReportFactories/ReportFactoryJpClassInstance.scala index dff2347a..dd84ee3f 100644 --- a/app/org/sailcbi/APIServer/Reporting/ReportFactories/ReportFactoryJpClassInstance.scala +++ b/app/org/sailcbi/APIServer/Reporting/ReportFactories/ReportFactoryJpClassInstance.scala @@ -43,7 +43,7 @@ class ReportFactoryJpClassInstance extends ReportFactory[JpClassInstance] { (i: JpClassInstance) => jpClassSessions .filter(_.values.instanceId.get == i.getID) - .map(_.values.sessionDateTime.get) + .map(_.values.sessionDatetime.get) .min .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), "First Session Datetime", diff --git a/app/org/sailcbi/APIServer/Reporting/ReportFactories/ReportFactoryJpClassSignup.scala b/app/org/sailcbi/APIServer/Reporting/ReportFactories/ReportFactoryJpClassSignup.scala index 8303b8f3..e7567fe6 100644 --- a/app/org/sailcbi/APIServer/Reporting/ReportFactories/ReportFactoryJpClassSignup.scala +++ b/app/org/sailcbi/APIServer/Reporting/ReportFactories/ReportFactoryJpClassSignup.scala @@ -3,6 +3,7 @@ package org.sailcbi.APIServer.Reporting.ReportFactories import com.coleji.neptune.Export.{ReportFactory, ReportingField, ReportingFilterFactory} import com.coleji.neptune.Storable.StorableObject import org.sailcbi.APIServer.Entities.EntityDefinitions._ +import org.sailcbi.APIServer.Logic.JpClassLogic import org.sailcbi.APIServer.Reporting.ReportingFilterFactories.JpClassSignup.JpClassSignupFilterFactoryYear import java.time.format.DateTimeFormatter @@ -36,7 +37,7 @@ class ReportFactoryJpClassSignup extends ReportFactory[JpClassSignup] { signups.foreach(s => { val instance = jpClassInstances.find(_.values.instanceId.get == s.values.instanceId.get) s.references.jpClassInstance.set(instance.get) - instance.get.calculatedValues.sessions.findAllInCollection(jpClassSessions) + instance.get.references.jpClassSessions.findAllInCollection(jpClassSessions.toIndexedSeq, _.values.instanceId.get == instance.get.values.instanceId.get) }) } @@ -56,18 +57,18 @@ class ReportFactoryJpClassSignup extends ReportFactory[JpClassSignup] { "Type Name", isDefault = true )), - ("WeekAlias", ReportingField.getReportingFieldFromCalculatedValue[JpClassSignup, JpClassSession]( - (session: JpClassSession) => session.calculatedValues.jpWeekAlias.getWithInput(rc).getOrElse(""), - (signup: JpClassSignup) => signup.references.jpClassInstance.get.calculatedValues.firstSession, - "Week", - isDefault = true - )), - ("FirstSessionDatetime", ReportingField.getReportingFieldFromCalculatedValue[JpClassSignup, JpClassSession]( - (session: JpClassSession) => session.values.sessionDateTime.get.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), - (signup: JpClassSignup) => signup.references.jpClassInstance.get.calculatedValues.firstSession, - "First Session Datetime", - isDefault = true - )), +// ("WeekAlias", ReportingField.getReportingFieldFromCalculatedValue[JpClassSignup, JpClassSession]( +// (session: JpClassSession) => session.calculations.weekAlias.set(JpClassLogic.setWeekAlias(session, rc)).getOrElse(""), +// (signup: JpClassSignup) => signup.references.jpClassInstance.get.calculatedValues.firstSession, +// "Week", +// isDefault = true +// )), +// ("FirstSessionDatetime", ReportingField.getReportingFieldFromCalculatedValue[JpClassSignup, JpClassSession]( +// (session: JpClassSession) => session.values.sessionDatetime.get.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), +// (signup: JpClassSignup) => signup.references.jpClassInstance.get.calculatedValues.firstSession, +// "First Session Datetime", +// isDefault = true +// )), ("SignupType", ReportingField.getReportingFieldFromDatabaseField(JpClassSignup.fields.signupType, "Signup Type", isDefault = true)), ("SignupDatetime", ReportingField.getReportingFieldFromDatabaseField(JpClassSignup.fields.signupDatetime, "Signup Datetime", isDefault = true)) ) diff --git a/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Donation/DonationFilterFactoryDateRange.scala b/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Donation/DonationFilterFactoryDateRange.scala index 8374f3e5..d5d2f2e9 100644 --- a/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Donation/DonationFilterFactoryDateRange.scala +++ b/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Donation/DonationFilterFactoryDateRange.scala @@ -9,13 +9,13 @@ import java.time.LocalDate import java.time.format.DateTimeFormatter class DonationFilterFactoryDateRange extends ReportingFilterFactory[Donation] { - val displayName: String = "Within Date Range" - val argDefinitions = List( + override val displayName: String = "Within Date Range" + override val argDefinitions = List( (ARG_DATE, DateLogic.now.toLocalDate.format(DateTimeFormatter.ofPattern("MM/dd/yyyy"))), (ARG_DATE, DateLogic.now.toLocalDate.format(DateTimeFormatter.ofPattern("MM/dd/yyyy"))) ) - def getFilter(rc: UnlockedRequestCache, arg: String): ReportingFilter[Donation] = new ReportingFilterFunction(rc, (rc: UnlockedRequestCache) => { + override def getFilter(rc: UnlockedRequestCache, arg: String): ReportingFilter[Donation] = new ReportingFilterFunction(rc, (rc: UnlockedRequestCache) => { val split = arg.split(",") val start: LocalDate = LocalDate.parse(split(0), DateTimeFormatter.ofPattern("MM/dd/yyyy")) val end: LocalDate = LocalDate.parse(split(1), DateTimeFormatter.ofPattern("MM/dd/yyyy")) diff --git a/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/JpClassSignup/JpClassSignupFilterFactoryYear.scala b/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/JpClassSignup/JpClassSignupFilterFactoryYear.scala index 503357c8..c8c4656c 100644 --- a/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/JpClassSignup/JpClassSignupFilterFactoryYear.scala +++ b/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/JpClassSignup/JpClassSignupFilterFactoryYear.scala @@ -16,7 +16,7 @@ class JpClassSignupFilterFactoryYear extends ReportingFilterFactory[JpClassSignu implicit val rc: UnlockedRequestCache = _rc val sessions = rc.getObjectsByFilters( JpClassSession, - List(JpClassSession.fields.sessionDateTime.alias.isYearConstant(year)), + List(JpClassSession.fields.sessionDatetime.alias.isYearConstant(year)), Set(JpClassSession.primaryKey), 100 ) diff --git a/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryJpParentSeason.scala b/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryJpParentSeason.scala index c5ba95fd..e70e99d5 100644 --- a/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryJpParentSeason.scala +++ b/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryJpParentSeason.scala @@ -32,7 +32,7 @@ class PersonFilterFactoryJpParentSeason extends ReportingFilterFactory[Person] w val parentIds = rc.getObjectsByFilters( PersonRelationship, List( - PersonRelationship.fields.typeId.alias.equalsConstant(PersonRelationship.specialIDs.TYPE_ID_PARENT_CHILD_ACCT_LINKED), + PersonRelationship.fields.typeId.alias.equalsConstant(MagicIds.PERSON_RELATIONSHIP_TYPE_PARENT_WITH_ACCT_LINK), PersonRelationship.fields.b.alias.inList(juniorsThatYear) ), Set(PersonRelationship.primaryKey) diff --git a/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryMemProgramYear.scala b/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryMemProgramYear.scala index 090e3293..0aa5b0ec 100644 --- a/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryMemProgramYear.scala +++ b/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryMemProgramYear.scala @@ -3,6 +3,7 @@ package org.sailcbi.APIServer.Reporting.ReportingFilterFactories.Person import com.coleji.neptune.Core.UnlockedRequestCache import com.coleji.neptune.Export._ import org.sailcbi.APIServer.Entities.EntityDefinitions._ +import org.sailcbi.APIServer.Entities.MagicIds import org.sailcbi.APIServer.Logic.DateLogic // First arg is program @@ -10,7 +11,7 @@ import org.sailcbi.APIServer.Logic.DateLogic class PersonFilterFactoryMemProgramYear extends ReportingFilterFactory[Person] with ReportingFilterFactoryDropdown { val displayName: String = "Had mem in prog X, year Y" val argDefinitions = List( - (ARG_DROPDOWN, ProgramType.specialIDs.PROGRAM_TYPE_ID_AP.toString), + (ARG_DROPDOWN, MagicIds.PROGRAM_TYPES.ADULT_PROGRAM_ID.toString), (ARG_INT, DateLogic.currentSeason().toString) ) diff --git a/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryRating.scala b/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryRating.scala index 4b87ecb3..b5f731e2 100644 --- a/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryRating.scala +++ b/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryRating.scala @@ -4,11 +4,13 @@ package org.sailcbi.APIServer.Reporting.ReportingFilterFactories.Person import com.coleji.neptune.Core.UnlockedRequestCache import com.coleji.neptune.Export._ import org.sailcbi.APIServer.Entities.EntityDefinitions._ +import org.sailcbi.APIServer.Entities.MagicIds +import org.sailcbi.APIServer.Logic.RatingLogic class PersonFilterFactoryRating extends ReportingFilterFactory[Person] with ReportingFilterFactoryDropdown { val displayName: String = "Has Rating" val argDefinitions = List( - (ARG_DROPDOWN, Rating.specialIDs.RATING_ID_MERC_GREEN.toString), + (ARG_DROPDOWN, MagicIds.RATING_IDS.MERCURY_GREEN.toString), ) def getFilter(rc: UnlockedRequestCache, arg: String): ReportingFilter[Person] = new ReportingFilterFunction(rc, (_rc: UnlockedRequestCache) => { @@ -24,7 +26,7 @@ class PersonFilterFactoryRating extends ReportingFilterFactory[Person] with Repo Rating.fields.overriddenBy, )) - val ratingsToHave: List[Int] = Rating.getAllHigherRatingsThanRating(allRatings, ratingId).map(_.values.ratingId.get) + val ratingsToHave: List[Int] = RatingLogic.getAllHigherRatingsThanRating(allRatings, ratingId).map(_.values.ratingId.get) val personIDs: List[Int] = rc.getObjectsByFilters( PersonRating, diff --git a/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryTag.scala b/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryTag.scala index 8567a7a2..f1ae261c 100644 --- a/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryTag.scala +++ b/app/org/sailcbi/APIServer/Reporting/ReportingFilterFactories/Person/PersonFilterFactoryTag.scala @@ -3,11 +3,12 @@ package org.sailcbi.APIServer.Reporting.ReportingFilterFactories.Person import com.coleji.neptune.Core.UnlockedRequestCache import com.coleji.neptune.Export._ import org.sailcbi.APIServer.Entities.EntityDefinitions._ +import org.sailcbi.APIServer.Entities.MagicIds class PersonFilterFactoryTag extends ReportingFilterFactory[Person] with ReportingFilterFactoryDropdown { val displayName: String = "Has Tag" - val argDefinitions = List( - (ARG_DROPDOWN, Tag.specialIDs.TAG_ID_CORPORATION.toString), + override val argDefinitions = List( + (ARG_DROPDOWN, MagicIds.TAG_IDS.CORPORATION.toString), ) def getFilter(rc: UnlockedRequestCache, arg: String): ReportingFilter[Person] = new ReportingFilterFunction(rc, (_rc: UnlockedRequestCache) => { diff --git a/test/org/sailcbi/APIServer/DBSeedState.scala b/test/org/sailcbi/APIServer/DBSeedState.scala index b7f405e3..6756caa0 100644 --- a/test/org/sailcbi/APIServer/DBSeedState.scala +++ b/test/org/sailcbi/APIServer/DBSeedState.scala @@ -35,8 +35,8 @@ class DBSeedState @Inject()(loader: CBIBootLoaderTest) extends FunSuite { val seedState = List( new User() .update(_.active, true) - .update(_.nameFirst, Some("Bob")) - .update(_.nameLast, Some("Smith")) + .update(_.nameFirst, "Bob") + .update(_.nameLast, "Smith") .update(_.userName, "bsmith") .update(_.email, "bsmith@sdfg.com") .withPK(9998) @@ -48,7 +48,7 @@ class DBSeedState @Inject()(loader: CBIBootLoaderTest) extends FunSuite { val user = users.head println("Seed user has id " + user.getID) val startingValue = user.values.nameLast.get - user.values.nameLast.initialize(Some(user.values.nameLast.get.get + "!")) + user.values.nameLast.initialize(user.values.nameLast.get + "!") rc.commitObjectToDatabase(user) val usersAgain = rc.getAllObjectsOfClass(User, Set(User.fields.userId, User.fields.nameFirst, User.fields.nameLast, User.fields.active))