Skip to content
Browse files

generate default arg for optional/multiple/nillable params. fixes #113

adds `= None`, `= Nil`, `= None` to optional,
multiple, and nillble parameters.
  • Loading branch information...
1 parent f8948df commit df17143f111d479afba69026a206ba4c19cec7ec @eed3si9n committed Nov 10, 2011
View
14 cli/src/main/resources/soapenvelope11.scala.template
@@ -2,17 +2,17 @@
package soapenvelope11
-case class Envelope(Header: Option[soapenvelope11.Header],
+case class Envelope(Header: Option[soapenvelope11.Header] = None,
Body: soapenvelope11.Body,
- any: Seq[scalaxb.DataRecord[Any]],
+ any: Seq[scalaxb.DataRecord[Any]] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]])
-case class Header(any: Seq[scalaxb.DataRecord[Any]],
+case class Header(any: Seq[scalaxb.DataRecord[Any]] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]])
-case class Body(any: Seq[scalaxb.DataRecord[Any]],
+case class Body(any: Seq[scalaxb.DataRecord[Any]] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]])
@@ -22,11 +22,11 @@ case class Body(any: Seq[scalaxb.DataRecord[Any]],
*/
case class Fault(faultcode: javax.xml.namespace.QName,
faultstring: String,
- faultactor: Option[java.net.URI],
- detail: Option[soapenvelope11.Detail])
+ faultactor: Option[java.net.URI] = None,
+ detail: Option[soapenvelope11.Detail] = None)
-case class Detail(any: Seq[scalaxb.DataRecord[Any]],
+case class Detail(any: Seq[scalaxb.DataRecord[Any]] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]])
View
18 cli/src/main/resources/soapenvelope12.scala.template
@@ -2,7 +2,7 @@
package soapenvelope12
-case class Envelope(Header: Option[soapenvelope12.Header],
+case class Envelope(Header: Option[soapenvelope12.Header] = None,
Body: soapenvelope12.Body,
attributes: Map[String, scalaxb.DataRecord[Any]])
@@ -11,11 +11,11 @@ case class Envelope(Header: Option[soapenvelope12.Header],
Elements replacing the wildcard MUST be namespace qualified, but can be in the targetNamespace
*/
-case class Header(any: Seq[scalaxb.DataRecord[Any]],
+case class Header(any: Seq[scalaxb.DataRecord[Any]] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]])
-case class Body(any: Seq[scalaxb.DataRecord[Any]],
+case class Body(any: Seq[scalaxb.DataRecord[Any]] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]])
@@ -25,9 +25,9 @@ case class Body(any: Seq[scalaxb.DataRecord[Any]],
*/
case class Fault(Code: soapenvelope12.Faultcode,
Reason: soapenvelope12.Faultreason,
- Node: Option[java.net.URI],
- Role: Option[java.net.URI],
- Detail: Option[soapenvelope12.Detail])
+ Node: Option[java.net.URI] = None,
+ Role: Option[java.net.URI] = None,
+ Detail: Option[soapenvelope12.Detail] = None)
case class Faultreason(Text: soapenvelope12.Reasontext*)
@@ -38,7 +38,7 @@ case class Reasontext(value: String,
case class Faultcode(Value: soapenvelope12.FaultcodeEnum,
- Subcode: Option[soapenvelope12.Subcode])
+ Subcode: Option[soapenvelope12.Subcode] = None)
trait FaultcodeEnum
@@ -61,10 +61,10 @@ case object TnsVersionMismatch extends FaultcodeEnum { override def toString = "
case class Subcode(Value: javax.xml.namespace.QName,
- Subcode: Option[soapenvelope12.Subcode])
+ Subcode: Option[soapenvelope12.Subcode] = None)
-case class Detail(any: Seq[scalaxb.DataRecord[Any]],
+case class Detail(any: Seq[scalaxb.DataRecord[Any]] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]])
View
4 cli/src/main/resources/soapenvelope12_xmlprotocol.scala.template
@@ -293,7 +293,7 @@ trait XMLProtocol extends scalaxb.XMLStandardTypes {
override def writesAttribute(__obj: soapenvelope12.NotUnderstoodType, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
- attr = scala.xml.Attribute(null, "qname", __obj.qname.toString, attr)
+ attr = scala.xml.Attribute(null, "qname", scalaxb.Helper.toString(__obj.qname, __scope), attr)
attr
}
@@ -313,7 +313,7 @@ trait XMLProtocol extends scalaxb.XMLStandardTypes {
override def writesAttribute(__obj: soapenvelope12.SupportedEnvType, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
- attr = scala.xml.Attribute(null, "qname", __obj.qname.toString, attr)
+ attr = scala.xml.Attribute(null, "qname", scalaxb.Helper.toString(__obj.qname, __scope), attr)
attr
}
View
4 cli/src/main/scala/scalaxb/compiler/xsd/Params.scala
@@ -84,7 +84,9 @@ trait Params extends Lookup {
def toScalaCode: String =
toTraitScalaCode + (cardinality match {
case Single if typeSymbol == XsLongAttribute => " = Map()"
- case Optional if attribute => " = None"
+ case Optional => " = None"
+ case Multiple => " = Nil"
+ case Single if nillable => " = None"
case _ => ""
})
View
4 cli/src_managed/scalaxb/scalaxb.scala
@@ -753,6 +753,10 @@ object Helper {
val XSI_URL = "http://www.w3.org/2001/XMLSchema-instance"
val XSI_PREFIX = "xsi"
+ def toString(value: QName, scope: NamespaceBinding): String =
+ Option[String](scope.getPrefix(value.getNamespaceURI)) map {
+ "%s:%s" format (_, value.getLocalPart)} getOrElse {value.getLocalPart}
+
def toCalendar(value: String): XMLGregorianCalendar = {
import javax.xml.datatype._
val typeFactory = javax.xml.datatype.DatatypeFactory.newInstance()
View
78 cli/src_managed/wsdl11/wsdl11.scala
@@ -2,7 +2,7 @@
package wsdl11
-case class XDocumentation(mixed: Seq[scalaxb.DataRecord[Any]],
+case class XDocumentation(mixed: Seq[scalaxb.DataRecord[Any]] = Nil,
attributes: Map[String, scalaxb.DataRecord[Any]])
trait XDocumentationOption
@@ -23,56 +23,56 @@ trait XOpenAtts {
}
-case class XDefinitionsType(documentation: Option[wsdl11.XDocumentation],
- importValue: Seq[wsdl11.XImportType],
- types: Option[wsdl11.XTypesType],
- message: Seq[wsdl11.XMessageType],
- portType: Seq[wsdl11.XPortTypeType],
- binding: Seq[wsdl11.XBindingType],
- service: Seq[wsdl11.XServiceType],
- any: Seq[scalaxb.DataRecord[Any]],
+case class XDefinitionsType(documentation: Option[wsdl11.XDocumentation] = None,
+ importValue: Seq[wsdl11.XImportType] = Nil,
+ types: Option[wsdl11.XTypesType] = None,
+ message: Seq[wsdl11.XMessageType] = Nil,
+ portType: Seq[wsdl11.XPortTypeType] = Nil,
+ binding: Seq[wsdl11.XBindingType] = Nil,
+ service: Seq[wsdl11.XServiceType] = Nil,
+ any: Seq[scalaxb.DataRecord[Any]] = Nil,
targetNamespace: Option[java.net.URI] = None,
name: Option[String] = None) extends XDocumented
-case class XImportType(documentation: Option[wsdl11.XDocumentation],
+case class XImportType(documentation: Option[wsdl11.XDocumentation] = None,
namespace: java.net.URI,
location: java.net.URI) extends XDocumented
-case class XTypesType(documentation: Option[wsdl11.XDocumentation],
- any: Seq[scalaxb.DataRecord[Any]]) extends XDocumented
+case class XTypesType(documentation: Option[wsdl11.XDocumentation] = None,
+ any: Seq[scalaxb.DataRecord[Any]] = Nil) extends XDocumented
-case class XMessageType(documentation: Option[wsdl11.XDocumentation],
- part: Seq[wsdl11.XPartType],
+case class XMessageType(documentation: Option[wsdl11.XDocumentation] = None,
+ part: Seq[wsdl11.XPartType] = Nil,
name: String) extends XDocumented
-case class XPartType(documentation: Option[wsdl11.XDocumentation],
+case class XPartType(documentation: Option[wsdl11.XDocumentation] = None,
name: Option[String] = None,
typeValue: Option[javax.xml.namespace.QName] = None,
element: Option[javax.xml.namespace.QName] = None,
attributes: Map[String, scalaxb.DataRecord[Any]]) extends XOpenAtts
-case class XPortTypeType(documentation: Option[wsdl11.XDocumentation],
- operation: Seq[wsdl11.XOperationType],
+case class XPortTypeType(documentation: Option[wsdl11.XDocumentation] = None,
+ operation: Seq[wsdl11.XOperationType] = Nil,
name: String) extends XDocumented
-case class XOperationType(documentation: Option[wsdl11.XDocumentation],
+case class XOperationType(documentation: Option[wsdl11.XDocumentation] = None,
xoperationtypeoption: scalaxb.DataRecord[Any],
name: String) extends XDocumented
trait XOperationTypeOption
-case class XParamType(documentation: Option[wsdl11.XDocumentation],
+case class XParamType(documentation: Option[wsdl11.XDocumentation] = None,
name: Option[String] = None,
message: javax.xml.namespace.QName) extends XDocumented
-case class XFaultType(documentation: Option[wsdl11.XDocumentation],
+case class XFaultType(documentation: Option[wsdl11.XDocumentation] = None,
name: String,
message: javax.xml.namespace.QName) extends XDocumented
@@ -83,48 +83,48 @@ trait XStartWithExtensionsTypable extends XDocumented {
}
-case class XStartWithExtensionsType(documentation: Option[wsdl11.XDocumentation],
- any: Seq[scalaxb.DataRecord[Any]]) extends XStartWithExtensionsTypable
+case class XStartWithExtensionsType(documentation: Option[wsdl11.XDocumentation] = None,
+ any: Seq[scalaxb.DataRecord[Any]] = Nil) extends XStartWithExtensionsTypable
-case class XBindingType(documentation: Option[wsdl11.XDocumentation],
- any: Seq[scalaxb.DataRecord[Any]],
- operation: Seq[wsdl11.XBinding_operationType],
+case class XBindingType(documentation: Option[wsdl11.XDocumentation] = None,
+ any: Seq[scalaxb.DataRecord[Any]] = Nil,
+ operation: Seq[wsdl11.XBinding_operationType] = Nil,
name: String,
typeValue: javax.xml.namespace.QName) extends XStartWithExtensionsTypable
-case class XFault(documentation: Option[wsdl11.XDocumentation],
- any: Seq[scalaxb.DataRecord[Any]],
+case class XFault(documentation: Option[wsdl11.XDocumentation] = None,
+ any: Seq[scalaxb.DataRecord[Any]] = Nil,
name: String) extends XStartWithExtensionsTypable
-case class XBinding_operationType(documentation: Option[wsdl11.XDocumentation],
- any: Seq[scalaxb.DataRecord[Any]],
- input: Option[wsdl11.XStartWithExtensionsTypable],
- output: Option[wsdl11.XStartWithExtensionsTypable],
- fault: Seq[wsdl11.XFault],
+case class XBinding_operationType(documentation: Option[wsdl11.XDocumentation] = None,
+ any: Seq[scalaxb.DataRecord[Any]] = Nil,
+ input: Option[wsdl11.XStartWithExtensionsTypable] = None,
+ output: Option[wsdl11.XStartWithExtensionsTypable] = None,
+ fault: Seq[wsdl11.XFault] = Nil,
name: String) extends XStartWithExtensionsTypable
-case class XServiceType(documentation: Option[wsdl11.XDocumentation],
- port: Seq[wsdl11.XPortType],
- any: Option[scalaxb.DataRecord[Any]],
+case class XServiceType(documentation: Option[wsdl11.XDocumentation] = None,
+ port: Seq[wsdl11.XPortType] = Nil,
+ any: Option[scalaxb.DataRecord[Any]] = None,
name: String) extends XDocumented
-case class XPortType(documentation: Option[wsdl11.XDocumentation],
- any: Option[scalaxb.DataRecord[Any]],
+case class XPortType(documentation: Option[wsdl11.XDocumentation] = None,
+ any: Option[scalaxb.DataRecord[Any]] = None,
name: String,
binding: javax.xml.namespace.QName) extends XDocumented
case class XNotificationoperationSequence(output: wsdl11.XParamType)
case class XSolicitresponseoperationSequence(output: wsdl11.XParamType,
input: wsdl11.XParamType,
- fault: Seq[wsdl11.XFaultType])
+ fault: Seq[wsdl11.XFaultType] = Nil)
case class XRequestresponseoperationSequence(input: wsdl11.XParamType,
output: wsdl11.XParamType,
- fault: Seq[wsdl11.XFaultType])
+ fault: Seq[wsdl11.XFaultType] = Nil)
case class XOnewayoperationSequence(input: wsdl11.XParamType)
View
12 cli/src_managed/wsdl11/wsdl11_xmlprotocol.scala
@@ -275,8 +275,8 @@ trait XXMLProtocol extends scalaxb.XMLStandardTypes {
override def writesAttribute(__obj: wsdl11.XPartType, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.name foreach { x => attr = scala.xml.Attribute(null, "name", x.toString, attr) }
- __obj.typeValue foreach { x => attr = scala.xml.Attribute(null, "type", x.toString, attr) }
- __obj.element foreach { x => attr = scala.xml.Attribute(null, "element", x.toString, attr) }
+ __obj.typeValue foreach { x => attr = scala.xml.Attribute(null, "type", scalaxb.Helper.toString(x, __scope), attr) }
+ __obj.element foreach { x => attr = scala.xml.Attribute(null, "element", scalaxb.Helper.toString(x, __scope), attr) }
__obj.attributes.toList map {
case (key, x) => attr = scala.xml.Attribute((x.namespace map { __scope.getPrefix(_) }).orNull, x.key.orNull, x.value.toString, attr) }
attr
@@ -355,7 +355,7 @@ trait XXMLProtocol extends scalaxb.XMLStandardTypes {
override def writesAttribute(__obj: wsdl11.XParamType, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
__obj.name foreach { x => attr = scala.xml.Attribute(null, "name", x.toString, attr) }
- attr = scala.xml.Attribute(null, "message", __obj.message.toString, attr)
+ attr = scala.xml.Attribute(null, "message", scalaxb.Helper.toString(__obj.message, __scope), attr)
attr
}
@@ -379,7 +379,7 @@ trait XXMLProtocol extends scalaxb.XMLStandardTypes {
override def writesAttribute(__obj: wsdl11.XFaultType, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
attr = scala.xml.Attribute(null, "name", __obj.name.toString, attr)
- attr = scala.xml.Attribute(null, "message", __obj.message.toString, attr)
+ attr = scala.xml.Attribute(null, "message", scalaxb.Helper.toString(__obj.message, __scope), attr)
attr
}
@@ -445,7 +445,7 @@ trait XXMLProtocol extends scalaxb.XMLStandardTypes {
override def writesAttribute(__obj: wsdl11.XBindingType, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
attr = scala.xml.Attribute(null, "name", __obj.name.toString, attr)
- attr = scala.xml.Attribute(null, "type", __obj.typeValue.toString, attr)
+ attr = scala.xml.Attribute(null, "type", scalaxb.Helper.toString(__obj.typeValue, __scope), attr)
attr
}
@@ -558,7 +558,7 @@ trait XXMLProtocol extends scalaxb.XMLStandardTypes {
override def writesAttribute(__obj: wsdl11.XPortType, __scope: scala.xml.NamespaceBinding): scala.xml.MetaData = {
var attr: scala.xml.MetaData = scala.xml.Null
attr = scala.xml.Attribute(null, "name", __obj.name.toString, attr)
- attr = scala.xml.Attribute(null, "binding", __obj.binding.toString, attr)
+ attr = scala.xml.Attribute(null, "binding", scalaxb.Helper.toString(__obj.binding, __scope), attr)
attr
}
View
3 notes/0.6.6.markdown
@@ -11,6 +11,7 @@
- Adds handling of `xs:include` without `targetNamespace`. [#102][#102] reported by [@berntan][@berntan]
- Adds handling of locally declared namespace binding. [#105][#105] reporetd by gerri
- Fixes round trip of parsed QName. [#114][#114]
+- Adds default argument to optional, multiple, and nillable params. [#113][#113] requested by [@OlegYch]
- Fixes handling of wsdl when soap bindings is not the first element. [#104][#104]
- Adds handling of soap messages with attributes. [#99][#99] reported by [@berntan][@berntan]
- Adds handling of soap messages with soap headers. [#100][#100] reported by [@berntan][@berntan]
@@ -34,9 +35,11 @@
[#104]: https://github.com/eed3si9n/scalaxb/issues/104
[#105]: https://github.com/eed3si9n/scalaxb/issues/105
[#106]: https://github.com/eed3si9n/scalaxb/issues/106
+ [#113]: https://github.com/eed3si9n/scalaxb/issues/113
[#114]: https://github.com/eed3si9n/scalaxb/issues/114
[@martiell]: https://github.com/martiell
[@mbroue]: https://github.com/mbroue
[@deanhiller]: https://github.com/deanhiller
[@dkhenry]: https://github.com/dkhenry
[@berntan]: https://github.com/berntan
+ [@OlegYch]: https://github.com/OlegYch
View
43 project/build.scala
@@ -2,10 +2,6 @@ import sbt._
object Builds extends Build {
import Keys._
- import ScriptedPlugin._
- import sbtappengine.Plugin._
- import sbtscalaxb.Plugin._
- import ScalaxbKeys._
lazy val buildSettings = Defaults.defaultSettings ++ Seq(
version := "0.6.6-SNAPSHOT",
@@ -27,6 +23,8 @@ object Builds extends Build {
parallelExecution in Test := false
)
+ import sbtscalaxb.Plugin._
+ import ScalaxbKeys._
val Xsd = config("xsd") extend(Compile)
val Wsdl = config("wsdl") extend(Compile)
val Soap11 = config("soap11") extend(Compile)
@@ -46,7 +44,7 @@ object Builds extends Build {
trait Version { val version = "%s" }
""".format(version))
Seq(file)
- }) ++
+ }) ++
inConfig(Xsd)(baseScalaxbSettings ++ inTask(scalaxb)(customScalaxbSettings("xmlschema"))) ++
inConfig(Wsdl)(baseScalaxbSettings ++ inTask(scalaxb)(customScalaxbSettings("wsdl11"))) ++
inConfig(Soap11)(baseScalaxbSettings ++ inTask(scalaxb)(soapSettings("soapenvelope11"))) ++
@@ -85,24 +83,14 @@ trait Version { val version = "%s" }
}
) ++ noPublish
+// import ScriptedPlugin._
lazy val pluginSettings = buildSettings ++ Seq(
sbtPlugin := true,
crossScalaVersions := Seq("2.9.1"),
- publishMavenStyle := true) ++
- ScriptedPlugin.scriptedSettings ++ Seq(
- scriptedBufferLog := false
- )
-
- lazy val webSettings = buildSettings ++
- appengineSettings ++ Seq(
- scalaVersion := "2.9.0-1",
- crossScalaVersions := Seq("2.9.0-1", "2.8.1"),
- libraryDependencies ++= Seq(
- "net.databinder" %% "unfiltered-filter" % "0.4.0",
- "net.databinder" %% "unfiltered-uploads" % "0.4.0",
- "javax.servlet" % "servlet-api" % "2.3" % "provided"
- )
- ) ++ noPublish
+ publishMavenStyle := true) // ++
+// ScriptedPlugin.scriptedSettings ++ Seq(
+// scriptedBufferLog := false
+// )
lazy val noPublish: Seq[Project.Setting[_]] = Seq(
publish := {},
@@ -125,6 +113,17 @@ trait Version { val version = "%s" }
settings = itSettings) dependsOn(cli % "test->compile")
lazy val scalaxbPlugin = Project("sbt-scalaxb", file("sbt-scalaxb"),
settings = pluginSettings) dependsOn(cli)
- lazy val appengine = Project("web", file("web"),
- settings = webSettings) dependsOn(cli)
+// lazy val appengine = Project("web", file("web"),
+// settings = webSettings) dependsOn(cli)
+
+// lazy val webSettings = buildSettings ++
+// appengineSettings ++ Seq(
+// scalaVersion := "2.9.0-1",
+// crossScalaVersions := Seq("2.9.0-1", "2.8.1"),
+// libraryDependencies ++= Seq(
+// "net.databinder" %% "unfiltered-filter" % "0.4.0",
+// "net.databinder" %% "unfiltered-uploads" % "0.4.0",
+// "javax.servlet" % "servlet-api" % "2.3" % "provided"
+// )
+// ) ++ noPublish
}
View
20 project/plugins.sbt
@@ -1,15 +1,15 @@
// addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.6")
-resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"
-
-addSbtPlugin("com.github.siasia" % "xsbt-web-plugin" % "0.1.2")
-
-addSbtPlugin("com.eed3si9n" % "sbt-appengine" % "0.3.0")
-
-libraryDependencies <++= (sbtVersion) { sv =>
- Seq("org.scala-tools.sbt" %% "scripted-plugin" % sv,
- "org.scala-tools.sbt" %% "scripted-sbt" % sv)
-}
+// libraryDependencies <++= (sbtVersion) { sv =>
+// Seq("org.scala-tools.sbt" %% "scripted-plugin" % sv,
+// "org.scala-tools.sbt" %% "scripted-sbt" % sv)
+// }
// comment this out for production otherwise chicken-egg will entail.
addSbtPlugin("org.scalaxb" % "sbt-scalaxb" % "0.6.6-SNAPSHOT")
+
+// resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"
+//
+// addSbtPlugin("com.github.siasia" % "xsbt-web-plugin" % "0.1.2")
+//
+// addSbtPlugin("com.eed3si9n" % "sbt-appengine" % "0.3.0")

0 comments on commit df17143

Please sign in to comment.
Something went wrong with that request. Please try again.