Start describing the User state. Modeling it as snapshots.
authorChristos KK Loverdos <loverdos@gmail.com>
Tue, 13 Dec 2011 10:04:04 +0000 (12:04 +0200)
committerChristos KK Loverdos <loverdos@gmail.com>
Tue, 13 Dec 2011 10:04:04 +0000 (12:04 +0200)
logic/src/main/scala/gr/grnet/aquarium/DataSnapshot.scala [new file with mode: 0644]
logic/src/main/scala/gr/grnet/aquarium/user/UserDataSnapshot.scala [new file with mode: 0644]
logic/src/main/scala/gr/grnet/aquarium/user/UserState.scala [new file with mode: 0644]

diff --git a/logic/src/main/scala/gr/grnet/aquarium/DataSnapshot.scala b/logic/src/main/scala/gr/grnet/aquarium/DataSnapshot.scala
new file mode 100644 (file)
index 0000000..3aff65f
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2011 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+
+package gr.grnet.aquarium
+
+/**
+ * Timely snapshots of data.
+ *
+ * @author Christos KK Loverdos <loverdos@gmail.com>
+ */
+trait DataSnapshot[T] {
+  /**
+   * The unix time (millis) when the data was actually calculated.
+   */
+  val snapshotTime: Long
+
+  /**
+   * The actual data/payload.
+   */
+  val data: T
+}
\ No newline at end of file
diff --git a/logic/src/main/scala/gr/grnet/aquarium/user/UserDataSnapshot.scala b/logic/src/main/scala/gr/grnet/aquarium/user/UserDataSnapshot.scala
new file mode 100644 (file)
index 0000000..4b470e0
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+
+package gr.grnet.aquarium
+package user
+
+import gr.grnet.aquarium.logic.accounting.dsl.DSLAgreement
+
+/**
+ * Snapshot of data that are user-related.
+ *
+ * @author Christos KK Loverdos <loverdos@gmail.com>
+ */
+
+sealed trait UserDataSnapshot[T] extends DataSnapshot[T]
+
+case class CreditSnapshot(data: Double, snapshotTime: Long) extends UserDataSnapshot[Long]
+
+case class AgreementSnapshot(data: DSLAgreement, snapshotTime: Long) extends UserDataSnapshot[DSLAgreement]
+
+case class RolesSnapshot(data: List[String], snapshotTime: Long) extends UserDataSnapshot[List[String]]
+
+case class PaymentOrdersSnapshot(data: List[AnyRef], snapshotTime: Long) extends UserDataSnapshot[List[AnyRef]]
+
+case class OwnedGroupsSnapshot(data: List[String], snapshotTime: Long) extends UserDataSnapshot[List[String]]
+
+case class GroupMembershipsSnapshot(data: List[String], snapshotTime: Long) extends UserDataSnapshot[List[String]]
\ No newline at end of file
diff --git a/logic/src/main/scala/gr/grnet/aquarium/user/UserState.scala b/logic/src/main/scala/gr/grnet/aquarium/user/UserState.scala
new file mode 100644 (file)
index 0000000..a910c52
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2011 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+
+package gr.grnet.aquarium.user
+
+/**
+ * A comprehensive representation of the User's state.
+ *
+ * Note that it is made of autonomous parts that are actually data snapshots.
+ *
+ * The different snapshots need not agree on the snapshot time, ie. some state
+ * part may be stale, while other may be fresh.
+ *
+ * @author Christos KK Loverdos <loverdos@gmail.com>
+ */
+
+case class UserState(
+  credits: CreditSnapshot,
+  agreement: AgreementSnapshot,
+  roles: RolesSnapshot,
+  paymentOrders: PaymentOrdersSnapshot,
+  ownedGroups: OwnedGroupsSnapshot,
+  groupMemberships: GroupMembershipsSnapshot)
\ No newline at end of file