Permalink
Browse files

created ServiceFactory and minor changes in project structure

  • Loading branch information...
1 parent 2880632 commit b7ec21a79cd49b836ee656dd7a9efe81ac184072 mfranic committed Apr 8, 2012
View
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="HighlightingAdvisor">
+ <option name="SUGGEST_TYPE_AWARE_HIGHLIGHTING" value="false" />
+ <option name="TYPE_AWARE_HIGHLIGHTING_ENABLED" value="true" />
+ </component>
+</project>
+
@@ -0,0 +1,13 @@
+<component name="libraryTable">
+ <library name="Maven: com.google.code.findbugs:jsr305:1.3.9">
+ <CLASSES>
+ <root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9-sources.jar!/" />
+ </SOURCES>
+ </library>
+</component>
@@ -0,0 +1,13 @@
+<component name="libraryTable">
+ <library name="Maven: com.google.guava:guava:10.0.1">
+ <CLASSES>
+ <root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/10.0.1/guava-10.0.1.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/10.0.1/guava-10.0.1-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/10.0.1/guava-10.0.1-sources.jar!/" />
+ </SOURCES>
+ </library>
+</component>
@@ -0,0 +1,13 @@
+<component name="libraryTable">
+ <library name="Maven: joda-time:joda-time:2.0">
+ <CLASSES>
+ <root url="jar://$MAVEN_REPOSITORY$/joda-time/joda-time/2.0/joda-time-2.0.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$MAVEN_REPOSITORY$/joda-time/joda-time/2.0/joda-time-2.0-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$MAVEN_REPOSITORY$/joda-time/joda-time/2.0/joda-time-2.0-sources.jar!/" />
+ </SOURCES>
+ </library>
+</component>
@@ -0,0 +1,13 @@
+<component name="libraryTable">
+ <library name="Maven: org.joda:joda-convert:1.1">
+ <CLASSES>
+ <root url="jar://$MAVEN_REPOSITORY$/org/joda/joda-convert/1.1/joda-convert-1.1.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$MAVEN_REPOSITORY$/org/joda/joda-convert/1.1/joda-convert-1.1-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$MAVEN_REPOSITORY$/org/joda/joda-convert/1.1/joda-convert-1.1-sources.jar!/" />
+ </SOURCES>
+ </library>
+</component>
@@ -0,0 +1,9 @@
+<component name="libraryTable">
+ <library name="Maven: spj:spj-remoting:v0.5">
+ <CLASSES>
+ <root url="jar://$PROJECT_DIR$/lib/spj-remoting-v0.5.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+</component>
View
Oops, something went wrong.
View
@@ -58,6 +58,8 @@
<orderEntry type="library" scope="TEST" name="Maven: org.mortbay.jetty:servlet-api:2.5-20081211" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" />
<orderEntry type="library" name="Maven: org.joda:joda-convert:1.1" level="project" />
+ <orderEntry type="library" name="Maven: com.google.guava:guava:10.0.1" level="project" />
+ <orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" name="Maven: spj:spj-remoting:v0.5" level="project" />
</component>
</module>
View
@@ -122,6 +122,11 @@
<artifactId>joda-convert</artifactId>
<version>1.1</version>
</dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>10.0.1</version>
+ </dependency>
<dependency>
@@ -40,13 +40,13 @@ class Boot
Menu("SPJ") / "service/spj/index" >> loggedIn,
Menu("Šifrarnici") / "service/sifrarnici/index" >> loggedIn
submenus(Menu("Razdjel i glava") / "service/sifrarnici/razdjel"
- submenus(Menu("Dodaj novi") /"service/sifrarnici/dodaj",
- Menu("Pregled i izmjena") / "service/sifrarnici/pregled"),
- Menu("Pozicija") /"service/sifrarnici/pozicija"
- submenus(Menu("Dodaj novi") /"service/sifrarnici/dodaj_poziciju",
+ submenus(Menu("Dodaj novi") / "sifrarnici/glavarazdjel/create",
+ Menu("Pregled i izmjena") / "sifrarnici/glavarazdjel/view"),
+ Menu("Pozicija") / "service/sifrarnici/pozicija"
+ submenus(Menu("Dodaj novi") / "service/sifrarnici/dodaj_poziciju",
Menu("Pregled i izmjena") / "service/sifrarnici/pregled_pozicija"),
- Menu("Računski plan") /"service/sifrarnici/plan"),
- Menu ("Form") /"service/form/index" >> loggedIn) :::
+ Menu("Računski plan") / "service/sifrarnici/plan"),
+ Menu ("Form") / "service/form/index" >> loggedIn) :::
User.sitemap: _*
)
@@ -0,0 +1,19 @@
+package service
+
+import net.liftweb.util.Props
+import spj.shared.configuration.SpjRemotingClientConfiguration
+import spj.shared.remoting.service.SpjRemotingService
+
+object ServiceFactory
+{
+ private lazy val spjService =
+ {
+ val spjRemotingServiceUrl = Props.get("spj-remoting-url").open_!
+ val config = new SpjRemotingClientConfiguration()
+ config.setServerUrl(Props.get("spj-remoting-url").open_!)
+ println("created spjRemotingService")
+ config.getService
+ }
+
+ def getSpjRemotingService: SpjRemotingService = spjService
+}
@@ -1,46 +0,0 @@
-package sppp.snippet
-
-import net.liftweb.http.{S, SHtml, StatefulSnippet}
-import net.liftweb.util.Helpers._
-import net.liftweb.util.{Props, Helpers}
-import spj.shared.configuration.SpjRemotingClientConfiguration
-import spj.shared.domain.GlavaRazdjel
-
-
-class CodeBooks extends StatefulSnippet {
-
- val spjRemotingServiceUrl = Props.get("spj-remoting-url").open_!
- val config = new SpjRemotingClientConfiguration()
- config.setServerUrl(spjRemotingServiceUrl)
- val service = config.getService
-
- override def dispatch = {case _ => render}
- var head = ""
- var split = ""
- var code = 0
- var glavaRazdjel = new GlavaRazdjel()
- def render =
- ".head" #> SHtml.text(head, head = _) &
- ".split" #> SHtml.text(split, split = _) &
- ".code" #> SHtml.text(code.toString,
- s => code = Helpers.asInt(s) openOr 0) &
- ":submit" #> SHtml.onSubmitUnit(() =>
- {if (code.toString.length() > 6) S.error("Pogrešan unos šifre!") else
- if (head.isEmpty && split.isEmpty) {
- S.notice("Uspješno ste unijeli novi zapis!")
- glavaRazdjel.setImeGlave(head)
- glavaRazdjel.setImeRazdjela(split)
- glavaRazdjel.setSifraGlavaRazdjel(code)
- service.create(glavaRazdjel)
- S.redirectTo("/")
- } else {S.error("Pogrešan unos glave/razdjela!")}
- })
-
-
-
-
-
-
-
-
-}
@@ -0,0 +1,6 @@
+package sppp.snippet
+
+trait SpppSnippet
+{
+
+}
@@ -0,0 +1,48 @@
+package sppp.snippet
+
+import net.liftweb.http.{S, SHtml, StatefulSnippet}
+import net.liftweb.util.Helpers._
+import net.liftweb.util.Helpers
+import service.ServiceFactory
+import spj.shared.domain.GlavaRazdjel
+import com.google.common.collect.ImmutableList
+
+class CreateGlavaRazdjel extends StatefulSnippet with SpppSnippet
+{
+ val spjRemotingService = ServiceFactory.getSpjRemotingService
+
+ override def dispatch =
+ {
+ case _ => render
+ }
+
+ def render =
+ {
+ var head = ""
+ var split = ""
+ var code = 0
+ var glavaRazdjel = new GlavaRazdjel()
+ ".head" #> SHtml.text(head, head = _) &
+ ".split" #> SHtml.text(split, split = _) &
+ ".code" #> SHtml.text(code.toString,
+ s => code = Helpers.asInt(s) openOr 0) &
+ ":submit" #> SHtml.onSubmitUnit(() =>
+ {
+ if (code.toString.length() > 6) S.error("Pogrešan unos šifre!")
+ else
+ if (!head.isEmpty && !split.isEmpty)
+ {
+ S.notice("Uspješno ste unijeli novi zapis!")
+ glavaRazdjel.setImeGlave(head)
+ glavaRazdjel.setImeRazdjela(split)
+ glavaRazdjel.setSifraGlavaRazdjel(code)
+ spjRemotingService.create(glavaRazdjel)
+ S.redirectTo("/")
+ }
+ else
+ {
+ S.error("Pogrešan unos glave/razdjela!")
+ }
+ })
+ }
+}
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
- <title>Novi unos:</title>
-</head>
-<body class="lift:content_id=main">
-<div id="main" class="foo bar lift:surround?with=default;at=content">
- <div class="lift:CodeBooks?form=post">
- Šifra: <input class="code"/> <br />
- Glava: <input class="head"/> <br />
- Razdjel: <input class="split"/> <br />
- <input type="submit" value="Dodaj"/>
- </div>
-</div>
-</body>
-</html>
@@ -1,10 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
- <title></title>
-</head>
-<body>
-
-</body>
-</html>
@@ -1,3 +1,7 @@
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:lift="http://liftweb.net/">
+
<lift:surround with="default" at="content">
- <div class="lift:CodeBooks"></div>
-</lift:surround>
+ <div class="lift:CreateGlavaRazdjel"></div>
+</lift:surround>
+
+</html>
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:lift="http://liftweb.net/">
+<head>
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
+ <title>Novi unos:</title>
+</head>
+<body class="lift:content_id=main">
+<div id="main" class="lift:surround?with=default;at=content">
+ <div class="lift:CreateGlavaRazdjel?form=post">
+ Šifra: <input class="code"/> <br/>
+ Glava: <input class="head"/> <br/>
+ Razdjel: <input class="split"/> <br/>
+ <input type="submit" value="Dodaj"/>
+ </div>
+</div>
+</body>
+</html>
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
+ <title>Pregled:</title>
+</head>
+<body class="lift:content_id=main">
+<div id="main" class="lift:surround?with=default;at=content">
+ <div class="lift:CreateGlavaRazdjel?form=post">
+ Šifra: <input class="code"/> <br/>
+ Glava: <input class="head"/> <br/>
+ Razdjel: <input class="split"/> <br/>
+ <input type="submit" value="Dodaj"/>
+ </div>
+</div>
+</body>
+</html>

0 comments on commit b7ec21a

Please sign in to comment.