*/
trait DSL {
- /**An empty time frame*/
- val emptyTimeFrame = DSLTimeFrame(new Date(0), None, List())
-
- /**An empty resource*/
- val emptyResource = DSLSimpleResource("", "", OnOffCostPolicy)
-
- /**An empty algorithm */
- val emptyAlgorithm = DSLAlgorithm("", None, Map(), emptyTimeFrame)
-
- /**An empty pricelist */
- val emptyPriceList = DSLPriceList("", None, Map(), emptyTimeFrame)
-
- /**An empty creditplan */
- val emptyCreditPlan = DSLCreditPlan("", None, 0,
- List(DSLTimeSpec(0, 0, -1, -1, -1)), emptyTimeFrame)
-
- /**An empty agreement*/
- val emptyAgreement = DSLAgreement("", None, emptyAlgorithm, emptyPriceList, emptyCreditPlan)
-
- /**An empty policy*/
- val emptyPolicy = DSLPolicy(List(emptyAlgorithm), List(emptyPriceList),
- List(emptyResource), List(emptyCreditPlan), List(emptyAgreement))
-
/**
* Parse an InputStream containing an Aquarium DSL algorithm.
*/
case Some(x) => x
case None => throw new DSLParseException("Cannot find super algorithm %s".format(superName))
}
- case YAMLEmptyNode => emptyAlgorithm
+ case YAMLEmptyNode => DSLAlgorithm.emptyAlgorithm
case _ => throw new DSLParseException("Super algorithm name %s not a string".format())
}
val algo = algorithm / r.name match {
case x: YAMLStringNode => x.string
case y: YAMLIntNode => y.int.toString
- case YAMLEmptyNode => algoTmpl.equals(emptyAlgorithm) match {
+ case YAMLEmptyNode => algoTmpl.equals(DSLAlgorithm.emptyAlgorithm) match {
case false => algoTmpl.algorithms.getOrElse(r,
throw new DSLParseException(("Superalgo does not specify an algorithm for resource:%s").format(r.name)))
case true => throw new DSLParseException(("Cannot find calculation algorithm for resource %s in either " +
val timeframe = algorithm / Vocabulary.effective match {
case x: YAMLMapNode => parseTimeFrame(x)
- case YAMLEmptyNode => algoTmpl.equals(emptyAlgorithm) match {
+ case YAMLEmptyNode => algoTmpl.equals(DSLAlgorithm.emptyAlgorithm) match {
case false => algoTmpl.effective
case true => throw new DSLParseException(("Cannot find effectivity period for algorithm %s ").format(name))
}
case Some(x) => x
case None => throw new DSLParseException("Cannot find super pricelist %s".format(superName))
}
- case YAMLEmptyNode => emptyPriceList
+ case YAMLEmptyNode => DSLPriceList.emptyPriceList
case _ => throw new DSLParseException("Super pricelist name %s not a string".format())
}
case y: YAMLIntNode => y.int.toFloat
case z: YAMLDoubleNode => z.double.toFloat
case a: YAMLStringNode => a.string.toFloat
- case YAMLEmptyNode => tmpl.equals(emptyAlgorithm) match {
+ case YAMLEmptyNode => tmpl.equals(DSLAlgorithm.emptyAlgorithm) match {
case false => tmpl.prices.getOrElse(r,
throw new DSLParseException(("Superpricelist does not specify a price for resource:%s").format(r.name)))
case true => throw new DSLParseException(("Cannot find price for resource %s in either pricelist %s or " +
val timeframe = pl / Vocabulary.effective match {
case x: YAMLMapNode => parseTimeFrame(x)
- case YAMLEmptyNode => tmpl.equals(emptyAlgorithm) match {
+ case YAMLEmptyNode => tmpl.equals(DSLAlgorithm.emptyAlgorithm) match {
case false => tmpl.effective
case true => throw new DSLParseException(("Cannot find effectivity period for pricelist %s").format(name))
}
case Some(x) => x
case None => throw new DSLParseException("Cannot find super credit plan %s".format(superName))
}
- case YAMLEmptyNode => emptyCreditPlan
+ case YAMLEmptyNode => DSLCreditPlan.emptyCreditPlan
case _ => throw new DSLParseException("Super credit plan name %s not a string".format())
}
"Credit plan does not define repetition specifier")
}
+ val atCron = (plan / Vocabulary.at).asInstanceOf[YAMLStringNode]
+
val credits = plan / Vocabulary.credits match {
case x: YAMLIntNode => x.int.toFloat
case y: YAMLDoubleNode => y.double.toFloat
val timeframe = plan / Vocabulary.effective match {
case x: YAMLMapNode => parseTimeFrame(x)
- case YAMLEmptyNode => tmpl.equals(emptyCreditPlan) match {
+ case YAMLEmptyNode => tmpl.equals(DSLCreditPlan.emptyCreditPlan) match {
case false => tmpl.effective
case true => throw new DSLParseException(
("Cannot find effectivity period for creditplan %s").format(name))
}
}
- DSLCreditPlan(name, overr, credits, at, timeframe)
+ DSLCreditPlan(name, overr, credits, at, atCron.string, timeframe)
}
/** Parse top level agreements */
case Some(x) => x
case None => throw new DSLParseException("Cannot find super agreement %s".format(superName))
}
- case YAMLEmptyNode => emptyAgreement
+ case YAMLEmptyNode => DSLAgreement.emptyAgreement
case _ => throw new DSLParseException("Super agreement name %s not a string".format(superName))
}
case Some(y) => y
case None => throw new DSLParseException(("Cannot find algorithm named %s").format(x))
}
- case y: YAMLMapNode => tmpl.equals(emptyAgreement) match {
+ case y: YAMLMapNode => tmpl.equals(DSLAgreement.emptyAgreement) match {
case true => throw new DSLParseException(("Incomplete algorithm definition for agreement %s").format(name))
case false =>
y.map += ("name" -> YAMLStringNode("/","%s-algorithm".format(name)))
constructAlgorithm(y, tmpl.algorithm, resources)
}
- case YAMLEmptyNode => tmpl.equals(emptyAgreement) match {
+ case YAMLEmptyNode => tmpl.equals(DSLAgreement.emptyAgreement) match {
case true => throw new DSLParseException(("No algorithm for agreement %s").format(name))
case false => tmpl.algorithm
}
case Some(y) => y
case None => throw new DSLParseException(("Cannot find pricelist named %s").format(x))
}
- case y: YAMLMapNode => tmpl.equals(emptyAgreement) match {
+ case y: YAMLMapNode => tmpl.equals(DSLAgreement.emptyAgreement) match {
case true => throw new DSLParseException(("Incomplete pricelist definition for agreement %s").format(name))
case false =>
y.map += ("name" -> YAMLStringNode("/","%s-pricelist".format(name)))
constructPriceList(y, tmpl.pricelist, resources)
}
- case YAMLEmptyNode => tmpl.equals(emptyAgreement) match {
+ case YAMLEmptyNode => tmpl.equals(DSLAgreement.emptyAgreement) match {
case true => throw new DSLParseException(("No algorithm for agreement %s").format(name))
case false => tmpl.pricelist
}
case Some(y) => y
case None => throw new DSLParseException(("Cannot find crediplan named %s").format(x))
}
- case y: YAMLMapNode => tmpl.equals(emptyAgreement) match {
+ case y: YAMLMapNode => tmpl.equals(DSLAgreement.emptyAgreement) match {
case true => throw new DSLParseException(("Incomplete creditplan definition for agreement %s").format(name))
case false =>
y.map += ("name" -> YAMLStringNode("/","%s-pricelist".format(name)))
constructCreditPlan(y, tmpl.creditplan)
}
- case YAMLEmptyNode => tmpl.equals(emptyAgreement) match {
+ case YAMLEmptyNode => tmpl.equals(DSLAgreement.emptyAgreement) match {
case true => throw new DSLParseException(("No creditplan for agreement %s").format(name))
case false => tmpl.creditplan
}
}
- val overrides = tmpl.equals(emptyAgreement) match {
+ val overrides = tmpl.equals(DSLAgreement.emptyAgreement) match {
case true => Some(tmpl)
case false => None
}