import play.api._
import play.api.mvc._
import models.services._
+import models.services.impl._
+import com.google.inject._
+import modules._
object Autocomplete extends Controller{
+ val inject = Guice.createInjector(new ServiceModules)
+ val projectManager = inject.getInstance(classOf[ProjectManager])
+
def projectList() = Action {
request => {
- Ok(ProjectManager().getProjectList(request))
+ Ok(projectManager.getProjectList(request))
}
}
import org.squeryl.PrimitiveTypeMode._
import models._
import models.services._
+import models.services.impl._
import beans._
import forms._
import controllers.services._
import models.services._
import scala.collection.immutable.Map
import scala.collection.immutable.Seq
+import com.google.inject._
+import modules._
object PartsListController extends Controller{
-
- val Home = Redirect(routes.PartsListController.index(0,0,"",""))
- val Home2 = Redirect(routes.PartsListController.relationRegistration(""))
- val relationForm = Form(
+ val inject = Guice.createInjector(new ServiceModules)
+ val projectManager = inject.getInstance(classOf[ProjectManager])
+ val Home = Redirect(routes.PartsListController.index(0,0,"",""))
+ val Home2 = Redirect(routes.PartsListController.relationRegistration(""))
+ val relationForm = Form(
mapping(
"parent" -> nonEmptyText,
"child" -> nonEmptyText,
var matrixPartsListBeans = Map[Part, Seq[beans.MultiPartsListBean]]()
inTransaction {
if(project != "") {
- val models = ProjectManager().getByName(project).parts
+ val models = projectManager.getByName(project).parts
// 各モデルに対し、部品表抽出処理を実施。
for(model <- models) {
// 部品表の1レベル展開。
import forms._
import models._
import models.services._
+import models.services.impl._
import org.squeryl._
import org.squeryl.PrimitiveTypeMode._
+import com.google.inject._
+import modules._
+
object ProjectController extends Controller{
val Home = Redirect(routes.ProjectController.list(0,""))
+ val inject = Guice.createInjector(new ServiceModules)
+ val projectManager = inject.getInstance(classOf[ProjectManager])
val projectRegistForm = Form(
mapping(
"name" -> nonEmptyText,
project => {
inTransaction {
val user = UserManager().getByName(project.users.name)
- val newProject = ProjectManager().insert(project)
+ val newProject = projectManager.insert(project)
newProject.users.associate(user)
Home.flashing("success" -> "Project %s has been created".format(project.name))
}
Ok(views.html.errors.errorNotAuthentication())
} else {
inTransaction {
- val project = ProjectManager().getById(id)
+ val project = projectManager.getById(id)
val projectForm = ProjectForm(project.name, null)
Ok(views.html.updateProjectForm(projectRegistForm.fill(projectForm), id, project))
}
formWithErrors => BadRequest(views.html.updateProjectForm(formWithErrors, id, null)),
project => {
inTransaction {
- ProjectManager().update(project, id)
+ projectManager.update(project, id)
Home.flashing("success" -> "Project %s has been update".format(project.name))
}
}
Ok(views.html.errors.errorNotAuthentication())
} else {
inTransaction {
- ProjectManager().deleteMember(projectId, memberId)
+ projectManager.deleteMember(projectId, memberId)
Home.flashing("success" -> "Project %s has been update".format("ID=" +memberId))
}
}
} else {
inTransaction {
val row = Integer.decode(Messages("list.row"))
- val buff = ProjectManager().list(key)
+ val buff = projectManager.list(key)
Ok(views.html.projectlist(buff.page(page*row, row), buff.size, key, page))
}
}
package models.services
import models._
+import models.services.impl._
import forms._
import models.services._
import org.squeryl._
import org.squeryl.PrimitiveTypeMode._
+import com.google.inject._
+import modules._
case class PartManager() extends AbstractManager{
+ val inject = Guice.createInjector(new ServiceModules)
+ val projectManager = inject.getInstance(classOf[ProjectManager])
+
def insert(part: PartForm):Part = {
- val project = ProjectManager().getByName(part.projectName)
+ val project = projectManager.getByName(part.projectName)
val newPart = project.parts.associate(Part(part.name, part.atach, part.price))
return newPart
}
def update(part: PartForm, id: Long):Part = {
- val project =ProjectManager().getByName(part.projectName)
+ val project = projectManager.getByName(part.projectName)
val updPart = getById(id)
updPart.name = part.name
updPart.projectId = project.id
package models.services
import models._
import forms._
-import org.squeryl._
-import org.squeryl.PrimitiveTypeMode._
-
-case class ProjectManager() {
+trait ProjectManager {
- def insert(project: ProjectForm):Project = {
- PartsListDb.projects.insert(Project(project.name))
- }
+ def insert(project: ProjectForm):Project
- def update(project: ProjectForm, id: Long) = {
- val updProject = getById(id)
- updProject.name = project.name
- if(!project.users.name.isEmpty()) {
- val user =UserManager().getByName(project.users.name)
- updProject.users.associate(user)
- }
- }
+ def update(project: ProjectForm, id: Long):Unit
- def deleteMember(projectId: Long, memberId: Long) = {
- val project = getById(projectId)
- val member = UserManager().getById(memberId)
- project.users.dissociate(member)
- }
+ def deleteMember(projectId: Long, memberId: Long):Unit
- def list(key: String): org.squeryl.Query[Project] = {
- PartsListDb.projects.where(pr => pr.name like key + "%")
- }
+ def list(key: String): org.squeryl.Query[Project]
- def getByName(name: String):Project = {
- PartsListDb.projects.where(p => p.name === name).head
- }
+ def getByName(name: String):Project
- def getById(id: Long) = {
- PartsListDb.projects.where(pr => pr.id === id).head
- }
+ def getById(id: Long):Project
- def getProjectList(request: play.api.mvc.Request[play.api.mvc.AnyContent]): String = {
- var projectList:String=""
- inTransaction {
- val projects =PartsListDb.projects.where(p => p.name like request.getQueryString("q").get + "%")
- for(project <- projects) {
- projectList = projectList.concat(project.name)
- projectList = projectList.concat("\n")
- }
- }
- return projectList
- }
+ def getProjectList(request: play.api.mvc.Request[play.api.mvc.AnyContent]): String
}
\ No newline at end of file
--- /dev/null
+package models.services.impl
+import models._
+import models.services._
+import forms._
+import org.squeryl._
+import org.squeryl.PrimitiveTypeMode._
+
+case class ProjectManagerImpl() extends ProjectManager{
+
+ def insert(project: ProjectForm):Project = {
+ PartsListDb.projects.insert(Project(project.name))
+ }
+
+ def update(project: ProjectForm, id: Long) = {
+ val updProject = getById(id)
+ updProject.name = project.name
+ if(!project.users.name.isEmpty()) {
+ val user = UserManager().getByName(project.users.name)
+ updProject.users.associate(user)
+ }
+ }
+
+ def deleteMember(projectId: Long, memberId: Long) = {
+ val project = getById(projectId)
+ val member = UserManager().getById(memberId)
+ project.users.dissociate(member)
+ }
+
+ def list(key: String): org.squeryl.Query[Project] = {
+ PartsListDb.projects.where(pr => pr.name like key + "%")
+ }
+
+ def getByName(name: String):Project = {
+ PartsListDb.projects.where(p => p.name === name).head
+ }
+
+ def getById(id: Long) = {
+ PartsListDb.projects.where(pr => pr.id === id).head
+ }
+
+ def getProjectList(request: play.api.mvc.Request[play.api.mvc.AnyContent]): String = {
+ var projectList:String=""
+ inTransaction {
+ val projects =PartsListDb.projects.where(p => p.name like request.getQueryString("q").get + "%")
+ for(project <- projects) {
+ projectList = projectList.concat(project.name)
+ projectList = projectList.concat("\n")
+ }
+ }
+ return projectList
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package modules
+import com.google.inject._
+import models.services._
+import models.services.impl._
+class ServiceModules extends com.google.inject.AbstractModule{
+ @Override
+ protected def configure() {
+ bind(classOf[ProjectManager]).to(classOf[ProjectManagerImpl])
+ }
+
+}
\ No newline at end of file
@main("Error") {
<h1>@Messages("auth.error")</h1>
<br />
- <a href="http://127.0.0.1/partslist">@Messages("list.link25")</a>
+ <a href="http://localhost:82/partslist">@Messages("list.link25")</a>
}
\ No newline at end of file
<void property="text">
<string>id:Long
name:String
-</string>
+parts:Part[0..N]</string>
</void>
</void>
<void property="name">
<string>x</string>
<void method="set">
<object idref="Point2D$Double0"/>
- <double>264.0</double>
+ <double>90.0</double>
</void>
</void>
<void class="java.awt.geom.Point2D$Double" method="getField">
<string>y</string>
<void method="set">
<object idref="Point2D$Double0"/>
- <double>87.0</double>
+ <double>93.0</double>
</void>
</void>
<void method="setLocation">
- <double>264.0</double>
- <double>87.0</double>
+ <double>90.0</double>
+ <double>93.0</double>
</void>
</object>
</void>
<string>x</string>
<void method="set">
<object idref="Point2D$Double1"/>
- <double>547.0</double>
+ <double>373.0</double>
</void>
</void>
<void class="java.awt.geom.Point2D$Double" method="getField">
<string>y</string>
<void method="set">
<object idref="Point2D$Double1"/>
- <double>75.0</double>
+ <double>81.0</double>
</void>
</void>
<void method="setLocation">
- <double>547.0</double>
- <double>75.0</double>
+ <double>373.0</double>
+ <double>81.0</double>
</void>
</object>
</void>
<string>x</string>
<void method="set">
<object idref="Point2D$Double2"/>
- <double>550.0</double>
+ <double>376.0</double>
</void>
</void>
<void class="java.awt.geom.Point2D$Double" method="getField">
<string>y</string>
<void method="set">
<object idref="Point2D$Double2"/>
- <double>220.0</double>
+ <double>226.0</double>
</void>
</void>
<void method="setLocation">
- <double>550.0</double>
- <double>220.0</double>
+ <double>376.0</double>
+ <double>226.0</double>
</void>
</object>
</void>
<string>x</string>
<void method="set">
<object idref="Point2D$Double3"/>
- <double>262.0</double>
+ <double>88.0</double>
</void>
</void>
<void class="java.awt.geom.Point2D$Double" method="getField">
<string>y</string>
<void method="set">
<object idref="Point2D$Double3"/>
- <double>401.0</double>
+ <double>407.0</double>
</void>
</void>
<void method="setLocation">
- <double>262.0</double>
- <double>401.0</double>
+ <double>88.0</double>
+ <double>407.0</double>
</void>
</object>
</void>
<string>x</string>
<void method="set">
<object idref="Point2D$Double4"/>
- <double>731.0</double>
+ <double>557.0</double>
</void>
</void>
<void class="java.awt.geom.Point2D$Double" method="getField">
<string>y</string>
<void method="set">
<object idref="Point2D$Double4"/>
- <double>220.0</double>
+ <double>226.0</double>
</void>
</void>
<void method="setLocation">
- <double>731.0</double>
- <double>220.0</double>
+ <double>557.0</double>
+ <double>226.0</double>
</void>
</object>
</void>
<string>x</string>
<void method="set">
<object idref="Point2D$Double5"/>
- <double>555.0</double>
+ <double>381.0</double>
</void>
</void>
<void class="java.awt.geom.Point2D$Double" method="getField">
<string>y</string>
<void method="set">
<object idref="Point2D$Double5"/>
- <double>407.0</double>
- </void>
- </void>
- <void method="setLocation">
- <double>555.0</double>
- <double>407.0</double>
- </void>
- </object>
- </void>
- <void method="addNode">
- <object class="com.horstmann.violet.ClassNode" id="ClassNode6">
- <void property="attributes">
- <void property="text">
- <string>quantity: Long
-dcSeq: Long</string>
- </void>
- </void>
- <void property="name">
- <void property="text">
- <string>PartRelation</string>
- </void>
- </void>
- </object>
- <object class="java.awt.geom.Point2D$Double" id="Point2D$Double6">
- <void class="java.awt.geom.Point2D$Double" method="getField">
- <string>x</string>
- <void method="set">
- <object idref="Point2D$Double6"/>
- <double>47.0</double>
- </void>
- </void>
- <void class="java.awt.geom.Point2D$Double" method="getField">
- <string>y</string>
- <void method="set">
- <object idref="Point2D$Double6"/>
- <double>87.0</double>
- </void>
- </void>
- <void method="setLocation">
- <double>47.0</double>
- <double>87.0</double>
- </void>
- </object>
- </void>
- <void method="addNode">
- <object class="com.horstmann.violet.ClassNode" id="ClassNode7">
- <void property="attributes">
- <void property="text">
- <string>id: Long
-dcNo: String
-dcDescription: String
-dcSeq: Long</string>
- </void>
- </void>
- <void property="name">
- <void property="text">
- <string>DesignChange</string>
- </void>
- </void>
- </object>
- <object class="java.awt.geom.Point2D$Double" id="Point2D$Double7">
- <void class="java.awt.geom.Point2D$Double" method="getField">
- <string>x</string>
- <void method="set">
- <object idref="Point2D$Double7"/>
- <double>42.0</double>
- </void>
- </void>
- <void class="java.awt.geom.Point2D$Double" method="getField">
- <string>y</string>
- <void method="set">
- <object idref="Point2D$Double7"/>
- <double>289.0</double>
+ <double>413.0</double>
</void>
</void>
<void method="setLocation">
- <double>42.0</double>
- <double>289.0</double>
+ <double>381.0</double>
+ <double>413.0</double>
</void>
</object>
</void>
<void property="bentStyle">
<object class="com.horstmann.violet.BentStyle" field="HVH"/>
</void>
- <void property="endLabel">
- <string>N</string>
- </void>
- <void property="startArrowHead">
- <object class="com.horstmann.violet.ArrowHead" field="V"/>
- </void>
- <void property="startLabel">
- <string>1</string>
- </void>
- </object>
- <object idref="ClassNode5"/>
- <object idref="ClassNode2"/>
- </void>
- <void method="connect">
- <object class="com.horstmann.violet.ClassRelationshipEdge">
- <void property="bentStyle">
- <object class="com.horstmann.violet.BentStyle" field="HVH"/>
- </void>
<void property="endArrowHead">
<object class="com.horstmann.violet.ArrowHead" field="V"/>
</void>
</void>
</object>
<object idref="ClassNode5"/>
- <object idref="ClassNode4"/>
- </void>
- <void method="connect">
- <object class="com.horstmann.violet.ClassRelationshipEdge">
- <void property="bentStyle">
- <object class="com.horstmann.violet.BentStyle" field="HVH"/>
- </void>
- <void property="endArrowHead">
- <object class="com.horstmann.violet.ArrowHead" field="V"/>
- </void>
- <void property="endLabel">
- <string>N</string>
- </void>
- <void property="startLabel">
- <string>1</string>
- </void>
- </object>
- <object idref="ClassNode0"/>
- <object idref="ClassNode6"/>
+ <object idref="ClassNode2"/>
</void>
<void method="connect">
<object class="com.horstmann.violet.ClassRelationshipEdge">
<string>1</string>
</void>
</object>
- <object idref="ClassNode7"/>
- <object idref="ClassNode6"/>
- </void>
- <void method="connect">
- <object class="com.horstmann.violet.ClassRelationshipEdge">
- <void property="bentStyle">
- <object class="com.horstmann.violet.BentStyle" field="HV"/>
- </void>
- <void property="endArrowHead">
- <object class="com.horstmann.violet.ArrowHead" field="V"/>
- </void>
- <void property="startLabel">
- <string>0..1</string>
- </void>
- </object>
- <object idref="ClassNode7"/>
- <object idref="ClassNode2"/>
+ <object idref="ClassNode5"/>
+ <object idref="ClassNode4"/>
</void>
</object>
</java>
-<html>
+ <html>
<head>
<title>PDM by play 2.1</title>
</head>
</iframe>
</body>
</html>
-
-#user nobody;
-worker_processes 1;
-
-#error_log logs/error.log;
-#error_log logs/error.log notice;
-#error_log logs/error.log info;
-
-#pid logs/nginx.pid;
-
-
+#user nobody;
+worker_processes 1;
+#error_log logs/error.log;
+#error_log logs/error.log notice;
+#error_log logs/error.log info;
+#pid logs/nginx.pid;
events {
- worker_connections 1024;
+worker_connections 1024;
}
-
-
http {
- include mime.types;
- default_type application/octet-stream;
-
-# auth_ldap_url ldap://localhost/ou=People,dc=nodomain?uid?sub;
-# auth_ldap_binffn cn=admin,dc=nodomain;
-# auth_ldap_binddn_passwd 'uyaji';
- #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $body_bytes_sent "$http_referer" '
- # '"$http_user_agent" "$http_x_forwarded_for"';
-
- #access_log logs/access.log main;
-
- sendfile on;
- #tcp_nopush on;
-
- #keepalive_timeout 0;
- keepalive_timeout 65;
-
- #gzip on;
-
- server {
- listen 80;
- server_name localhost;
-
- #charset koi8-r;
-
- #access_log logs/host.access.log main;
-
- location / {
- root /var/www/docs;
- index index.html index.htm;
- }
-
- #error_page 404 /404.html;
-
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- }
-
- server {
- listen 80;
- server_name 127.0.0.1;
- location / {
- proxy_pass http://127.0.0.1:9000;
- allow all;
-# auth_ldap 'Authentication Required';
-# auth_ldap_require valid_user;
-# auth_ldap_satisfy any;
- }
- }
- # proxy the PHP scripts to Apache listening on 127.0.0.1:80
- #
- #location ~ \.php$ {
- # proxy_pass http://127.0.0.1;
- #}
-
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- #location ~ \.php$ {
- # root html;
- # fastcgi_pass 127.0.0.1:9000;
- # fastcgi_index index.php;
- # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- # include fastcgi_params;
- #}
-
- # deny access to .htaccess files, if Apache's document root
- # concurs with nginx's one
- #
- #location ~ /\.ht {
- # deny all;
- #}
-
-
- # another virtual host using mix of IP-, name-, and port-based configuration
- #
- #server {
- # listen 8000;
- # listen somename:8080;
- # server_name somename alias another.alias;
-
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
-
-
- # HTTPS server
- #
- #server {
- # listen 443;
- # server_name localhost;
-
- # ssl on;
- # ssl_certificate cert.pem;
- # ssl_certificate_key cert.key;
-
- # ssl_session_timeout 5m;
-
- # ssl_protocols SSLv2 SSLv3 TLSv1;
- # ssl_ciphers HIGH:!aNULL:!MD5;
- # ssl_prefer_server_ciphers on;
-
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
-
+include mime.types;
+default_type application/octet-stream;
+# auth_ldap_url ldap://localhost/ou=People,dc=nodomain?uid?sub;
+# auth_ldap_binffn cn=admin,dc=nodomain;
+# auth_ldap_binddn_passwd 'uyaji';
+#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
+# '$status $body_bytes_sent "$http_referer" '
+# '"$http_user_agent" "$http_x_forwarded_for"';
+#access_log logs/access.log main;
+sendfile on;
+#tcp_nopush on;
+#keepalive_timeout 0;
+keepalive_timeout 65;
+#gzip on;
+server {
+listen 80;
+server_name localhost;
+#charset koi8-r;
+#access_log logs/host.access.log main;
+location / {
+root /var/www/docs;
+index index.html index.htm;
+}
+#error_page 404 /404.html;
+# redirect server error pages to the static page /50x.html
+#
+error_page 500 502 503 504 /50x.html;
+location = /50x.html {
+root html;
+}
+}
+server {
+listen 80;
+server_name 127.0.0.1;
+location / {
+proxy_pass http://127.0.0.1:9000;
+allow all;
+# auth_ldap 'Authentication Required';
+# auth_ldap_require valid_user;
+# auth_ldap_satisfy any;
+}
+}
+# proxy the PHP scripts to Apache listening on 127.0.0.1:80
+#
+#location ~ \.php$ {
+# proxy_pass http://127.0.0.1;
+#}
+# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
+#
+#location ~ \.php$ {
+# root html;
+# fastcgi_pass 127.0.0.1:9000;
+# fastcgi_index index.php;
+# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
+# include fastcgi_params;
+#}
+# deny access to .htaccess files, if Apache's document root
+# concurs with nginx's one
+#
+#location ~ /\.ht {
+# deny all;
+#}
+# another virtual host using mix of IP-, name-, and port-based configuration
+#
+#server {
+# listen 8000;
+# listen somename:8080;
+# server_name somename alias another.alias;
+# location / {
+# root html;
+# index index.html index.htm;
+# }
+#}
+# HTTPS server
+#
+#server {
+# listen 443;
+# server_name localhost;
+# ssl on;
+# ssl_certificate cert.pem;
+# ssl_certificate_key cert.key;
+# ssl_session_timeout 5m;
+# ssl_protocols SSLv2 SSLv3 TLSv1;
+# ssl_ciphers HIGH:!aNULL:!MD5;
+# ssl_prefer_server_ciphers on;
+# location / {
+# root html;
+# index index.html index.htm;
+# }
+#}
}