Skip to content

Commit

Permalink
everyhting is compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
coleji committed Nov 24, 2023
1 parent 6939b09 commit a8c7c00
Show file tree
Hide file tree
Showing 40 changed files with 153 additions and 391 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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_<=)
}
13 changes: 13 additions & 0 deletions app/com/coleji/neptune/Util/Initializable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

This file was deleted.

This file was deleted.

12 changes: 12 additions & 0 deletions app/com/coleji/neptune/Util/InitializableSeq.scala
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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")
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down

This file was deleted.

Loading

0 comments on commit a8c7c00

Please sign in to comment.