Commits

Anonymous committed 188090b

Corrected a startup exception involving an un-used constraint in Client.

Comments (0)

Files changed (5)

application.properties

 #utf-8
-#Thu Aug 20 17:45:09 EDT 2009
+#Sun Aug 23 18:29:55 EDT 2009
 app.version=0.1
 plugins.runtime-logging=0.3
 app.servlet.version=2.4

grails-app/domain/com/koyanainc/bc/Client.groovy

     String uuid = ""
 
     //clientOf
-    static belongsTo = [firm:Firm]
+    //static belongsTo = [account:Account]
 
     static hasMany = [people:Person]
 
     static constraints = {
         name(nullable:false)
-        clientOfFirm(nullable:false)
     }
 
 

grails-app/services/ImportFirmService.groovy

       }
     }
 
-    def leafMap = xmlToMap(firmLeafs)
+    def leafMap = XMLUtil.xmlToMap(firmLeafs)
 
     def f = new Firm(leafMap)
     f.id = leafMap.id.toInteger()
     }
 
     peopleList.each{
-      def pm = xmlToMap(it.children())
+      def pm = XMLUtil.xmlToMap(it.children())
 
       def p = new Person(pm)
       p.id = pm.id.toInteger()
       f.addToPeople(p)
     }
   }
-
+/**
   Map xmlToMap(xml)
   {
     Map m = [:]
 
     r
   }
-}
+**/
+  }

grails-app/services/ImportXMLService.groovy

 
     def importFromFile(String pathAndFilename) {
 
-        def xml = XML.parse(new FileInputStream(pathAndFilename), "UTF-8")
+        def accountXML = XML.parse(new FileInputStream(pathAndFilename), "UTF-8")
 
-        importFirmService.importXML(xml.firm)
+        importFirmService.importXML(accountXML.firm)
 
     }
 }

src/groovy/XMLUtil.groovy

+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author rob
+ */
+class XMLUtil {
+  static String xmlToCamel(String xmlString)
+  {
+    def b = xmlString.split("-")
+
+    String r = b[0]
+    b.eachWithIndex{v,i->
+      StringBuffer sb = new StringBuffer(v)
+      if(i!=0){
+        Character c = v[0].toUpperCase()
+        sb.setCharAt(0,c)
+
+        r += sb
+      }
+    }
+    r
+  }
+
+  static Map xmlToMap(xml)
+  {
+    Map m = [:]
+    xml.each{
+
+      m[XMLUtil.xmlToCamel(it.name())] = it.text()
+    }
+
+    m
+  }
+	
+}
+