sws 0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/doc/DOC.otl +34 -0
- data/doc/Makefile +13 -0
- data/doc/architecture.dia +0 -0
- data/doc/docbook/architecture.png +0 -0
- data/doc/docbook/concepts.docbook +474 -0
- data/doc/docbook/installation.docbook +57 -0
- data/doc/docbook/introduction.docbook +130 -0
- data/doc/docbook/sws_manual.docbook +35 -0
- data/doc/docbook/todo.docbook +38 -0
- data/doc/docbook/tutorial.docbook +594 -0
- data/examples/README +1 -0
- data/examples/addressbook/CardBrowse/CardBrowse.html +43 -0
- data/examples/addressbook/CardBrowse/CardBrowse.rb +65 -0
- data/examples/addressbook/CardBrowse/CardBrowse.sws +92 -0
- data/examples/addressbook/Login/LoginPage.html +12 -0
- data/examples/addressbook/Login/LoginPage.rb +19 -0
- data/examples/addressbook/Login/LoginPage.sws +15 -0
- data/examples/addressbook/README +1 -0
- data/examples/addressbook/addressbook.rb +70 -0
- data/examples/addressbook/application.yaml +8 -0
- data/examples/addressbook/db.yaml +7 -0
- data/examples/component_demo/CheckBoxDemo/CheckBoxDemo.html +11 -0
- data/examples/component_demo/CheckBoxDemo/CheckBoxDemo.rb +21 -0
- data/examples/component_demo/CheckBoxDemo/CheckBoxDemo.sws +25 -0
- data/examples/component_demo/ComponentDemo.rb +21 -0
- data/examples/component_demo/ConditionalDemo/ConditionalDemo.html +18 -0
- data/examples/component_demo/ConditionalDemo/ConditionalDemo.rb +2 -0
- data/examples/component_demo/ConditionalDemo/ConditionalDemo.sws +22 -0
- data/examples/component_demo/FileUploadDemo/FileUploadDemo.html +10 -0
- data/examples/component_demo/FileUploadDemo/FileUploadDemo.rb +9 -0
- data/examples/component_demo/FileUploadDemo/FileUploadDemo.sws +33 -0
- data/examples/component_demo/FormFieldsDemo/FormFieldsDemo.html +12 -0
- data/examples/component_demo/FormFieldsDemo/FormFieldsDemo.rb +21 -0
- data/examples/component_demo/FormFieldsDemo/FormFieldsDemo.sws +40 -0
- data/examples/component_demo/FormListsDemo/FormListsDemo.html +11 -0
- data/examples/component_demo/FormListsDemo/FormListsDemo.rb +37 -0
- data/examples/component_demo/FormListsDemo/FormListsDemo.sws +47 -0
- data/examples/component_demo/GenericDemo/GenericDemo.html +4 -0
- data/examples/component_demo/GenericDemo/GenericDemo.rb +2 -0
- data/examples/component_demo/GenericDemo/GenericDemo.sws +10 -0
- data/examples/component_demo/HyperlinkDemo/HyperlinkDemo.html +8 -0
- data/examples/component_demo/HyperlinkDemo/HyperlinkDemo.rb +20 -0
- data/examples/component_demo/HyperlinkDemo/HyperlinkDemo.sws +19 -0
- data/examples/component_demo/ImageLinkDemo/ImageLinkDemo.html +11 -0
- data/examples/component_demo/ImageLinkDemo/ImageLinkDemo.rb +2 -0
- data/examples/component_demo/ImageLinkDemo/ImageLinkDemo.sws +14 -0
- data/examples/component_demo/PageWrapper/PageWrapper.html +23 -0
- data/examples/component_demo/PageWrapper/PageWrapper.rb +2 -0
- data/examples/component_demo/PageWrapper/PageWrapper.sws +42 -0
- data/examples/component_demo/README +1 -0
- data/examples/component_demo/RepetitionDemo/RepetitionDemo.html +13 -0
- data/examples/component_demo/RepetitionDemo/RepetitionDemo.rb +19 -0
- data/examples/component_demo/RepetitionDemo/RepetitionDemo.sws +20 -0
- data/examples/component_demo/StringDemo/StringDemo.html +5 -0
- data/examples/component_demo/StringDemo/StringDemo.rb +16 -0
- data/examples/component_demo/StringDemo/StringDemo.sws +14 -0
- data/examples/component_demo/application.yaml +28 -0
- data/examples/component_demo/poweredby.jpg +0 -0
- data/examples/component_demo/style.css +1 -0
- data/examples/movies/Menu/Menu.html +3 -0
- data/examples/movies/Menu/Menu.rb +7 -0
- data/examples/movies/Menu/Menu.sws +7 -0
- data/examples/movies/MovieBrowse/MovieBrowse.html +68 -0
- data/examples/movies/MovieBrowse/MovieBrowse.rb +178 -0
- data/examples/movies/MovieBrowse/MovieBrowse.sws +127 -0
- data/examples/movies/README +1 -0
- data/examples/movies/UserBrowse/UserBrowse.html +50 -0
- data/examples/movies/UserBrowse/UserBrowse.rb +69 -0
- data/examples/movies/UserBrowse/UserBrowse.sws +49 -0
- data/examples/movies/application.yaml +11 -0
- data/examples/movies/da.rb +36 -0
- data/examples/movies/dbmovies.rb +44 -0
- data/examples/movies/frameworks/TestFramework/framework.yaml +4 -0
- data/examples/movies/frameworks/TestFramework/resources/im1.jpg +0 -0
- data/examples/movies/images/pbr1b.jpg +0 -0
- data/examples/movies/movies.rb +28 -0
- data/examples/movies/movies.sds +119 -0
- data/examples/movies/movies.sqlite +0 -0
- data/examples/movies/movies_mysql.sql +28 -0
- data/examples/movies/movies_postgres.sql +27 -0
- data/examples/movies/movies_sqlite.sql +28 -0
- data/lib/sws.rb +89 -0
- data/lib/sws/Core/components/CheckBox/CheckBox.api +5 -0
- data/lib/sws/Core/components/CheckBox/CheckBox.rb +45 -0
- data/lib/sws/Core/components/CheckBoxList/CheckBoxList.api +13 -0
- data/lib/sws/Core/components/CheckBoxList/CheckBoxList.rb +54 -0
- data/lib/sws/Core/components/Conditional/Conditional.api +3 -0
- data/lib/sws/Core/components/Conditional/Conditional.html +1 -0
- data/lib/sws/Core/components/Conditional/Conditional.rb +39 -0
- data/lib/sws/Core/components/Conditional/Conditional.sws +2 -0
- data/lib/sws/Core/components/Content/Content.rb +18 -0
- data/lib/sws/Core/components/ExceptionPage/ExceptionPage.html +13 -0
- data/lib/sws/Core/components/ExceptionPage/ExceptionPage.rb +18 -0
- data/lib/sws/Core/components/ExceptionPage/ExceptionPage.sws +16 -0
- data/lib/sws/Core/components/FileUpload/FileUpload.api +16 -0
- data/lib/sws/Core/components/FileUpload/FileUpload.rb +62 -0
- data/lib/sws/Core/components/Form/Form.api +9 -0
- data/lib/sws/Core/components/Form/Form.html +3 -0
- data/lib/sws/Core/components/Form/Form.rb +55 -0
- data/lib/sws/Core/components/Form/Form.sws +12 -0
- data/lib/sws/Core/components/GenericContainer/GenericContainer.api +10 -0
- data/lib/sws/Core/components/GenericContainer/GenericContainer.html +1 -0
- data/lib/sws/Core/components/GenericContainer/GenericContainer.rb +39 -0
- data/lib/sws/Core/components/GenericContainer/GenericContainer.sws +12 -0
- data/lib/sws/Core/components/GenericElement/GenericElement.api +10 -0
- data/lib/sws/Core/components/GenericElement/GenericElement.rb +34 -0
- data/lib/sws/Core/components/HiddenField/HiddenField.api +7 -0
- data/lib/sws/Core/components/HiddenField/HiddenField.rb +37 -0
- data/lib/sws/Core/components/Hyperlink/Hyperlink.api +13 -0
- data/lib/sws/Core/components/Hyperlink/Hyperlink.html +1 -0
- data/lib/sws/Core/components/Hyperlink/Hyperlink.rb +102 -0
- data/lib/sws/Core/components/Hyperlink/Hyperlink.sws +12 -0
- data/lib/sws/Core/components/Image/Image.api +11 -0
- data/lib/sws/Core/components/Image/Image.rb +49 -0
- data/lib/sws/Core/components/ImageButton/ImageButton.api +16 -0
- data/lib/sws/Core/components/ImageButton/ImageButton.rb +76 -0
- data/lib/sws/Core/components/Link/Link.api +11 -0
- data/lib/sws/Core/components/Link/Link.rb +39 -0
- data/lib/sws/Core/components/PasswordField/PasswordField.api +7 -0
- data/lib/sws/Core/components/PasswordField/PasswordField.rb +41 -0
- data/lib/sws/Core/components/RadioButton/RadioButton.api +7 -0
- data/lib/sws/Core/components/RadioButton/RadioButton.rb +44 -0
- data/lib/sws/Core/components/RadioButtonList/RadioButtonList.api +20 -0
- data/lib/sws/Core/components/RadioButtonList/RadioButtonList.rb +76 -0
- data/lib/sws/Core/components/Repetition/Repetition.api +10 -0
- data/lib/sws/Core/components/Repetition/Repetition.html +1 -0
- data/lib/sws/Core/components/Repetition/Repetition.rb +137 -0
- data/lib/sws/Core/components/Repetition/Repetition.sws +2 -0
- data/lib/sws/Core/components/ResetButton/ResetButton.api +5 -0
- data/lib/sws/Core/components/ResetButton/ResetButton.rb +28 -0
- data/lib/sws/Core/components/Select/Select.api +24 -0
- data/lib/sws/Core/components/Select/Select.rb +57 -0
- data/lib/sws/Core/components/String/String.api +5 -0
- data/lib/sws/Core/components/String/String.rb +28 -0
- data/lib/sws/Core/components/SubmitButton/SubmitButton.api +6 -0
- data/lib/sws/Core/components/SubmitButton/SubmitButton.rb +53 -0
- data/lib/sws/Core/components/TextArea/TextArea.api +9 -0
- data/lib/sws/Core/components/TextArea/TextArea.rb +28 -0
- data/lib/sws/Core/components/TextField/TextField.api +9 -0
- data/lib/sws/Core/components/TextField/TextField.rb +46 -0
- data/lib/sws/Core/framework.yaml +25 -0
- data/lib/sws/JSComponents/components/JSMenu/JSMenu.api +5 -0
- data/lib/sws/JSComponents/components/JSMenu/JSMenu.html +58 -0
- data/lib/sws/JSComponents/components/JSMenu/JSMenu.rb +34 -0
- data/lib/sws/JSComponents/components/JSMenu/JSMenu.sws +37 -0
- data/lib/sws/JSComponents/framework.yaml +3 -0
- data/lib/sws/adaptor.rb +334 -0
- data/lib/sws/application.rb +604 -0
- data/lib/sws/component.rb +656 -0
- data/lib/sws/cookie.rb +27 -0
- data/lib/sws/direct_action.rb +38 -0
- data/lib/sws/extensions.rb +49 -0
- data/lib/sws/parsers.rb +374 -0
- data/lib/sws/request.rb +308 -0
- data/lib/sws/response.rb +70 -0
- data/lib/sws/session.rb +195 -0
- data/lib/sws/slot.rb +198 -0
- metadata +263 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is quite a complicated example, which uses SDS database access and O-R mapping library (available at http://www.starware.one.pl/software/sds/index.html). The application goal is to manage a database of movie CDs. While it is far from complete, it gives an overview of SWS/SDS database applications.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>Folks browsing</title>
|
|
4
|
+
</head>
|
|
5
|
+
<body>
|
|
6
|
+
<!-- menu component -->
|
|
7
|
+
<span sws="menu"/>
|
|
8
|
+
|
|
9
|
+
<!-- main browsing table -->
|
|
10
|
+
<form sws="browse_form">
|
|
11
|
+
<table align="center" border="1">
|
|
12
|
+
<!-- header row -->
|
|
13
|
+
<tr>
|
|
14
|
+
<th>Name</th>
|
|
15
|
+
<th>Rented movies</th>
|
|
16
|
+
<th>Actions</th>
|
|
17
|
+
</tr>
|
|
18
|
+
<!-- user data row - wrapped in repetition, so it will appear several times -->
|
|
19
|
+
<span sws="user_repetition">
|
|
20
|
+
<tr>
|
|
21
|
+
<!-- name and number of movies rented by user -->
|
|
22
|
+
<td><span sws="cursor_name"/></td>
|
|
23
|
+
<td><span sws="cursor_rental_count"/></td>
|
|
24
|
+
<td>
|
|
25
|
+
<!-- action buttons -->
|
|
26
|
+
<input type="submit" sws="submit_delete"/>
|
|
27
|
+
<input type="submit" sws="submit_edit"/>
|
|
28
|
+
</td>
|
|
29
|
+
</tr>
|
|
30
|
+
</span>
|
|
31
|
+
<tr><td colspan="6" align="center"><input type="submit" sws="submit_add"/></td></tr>
|
|
32
|
+
</table>
|
|
33
|
+
|
|
34
|
+
</form>
|
|
35
|
+
|
|
36
|
+
<!-- edit form - appears only if @current_user is set -->
|
|
37
|
+
<span sws="conditional_current">
|
|
38
|
+
<form sws="edit_form">
|
|
39
|
+
<table align="center" border="1">
|
|
40
|
+
|
|
41
|
+
<!-- text field for user name -->
|
|
42
|
+
<tr><th>Name</th><td><input type="text" sws="current_name"/></td></tr>
|
|
43
|
+
<!-- save button -->
|
|
44
|
+
<tr><th></th><td><input type="submit" sws="submit_confirm"/></td></tr>
|
|
45
|
+
</table>
|
|
46
|
+
</form>
|
|
47
|
+
</span>
|
|
48
|
+
|
|
49
|
+
</body>
|
|
50
|
+
</html>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Component representing user browsing page. You can also add, edit and delete users here
|
|
2
|
+
|
|
3
|
+
class UserBrowse < SWS::Component
|
|
4
|
+
|
|
5
|
+
attr_accessor :users, :user_cursor, :current_user
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Create new instance of component. Note that all args should be passed to super
|
|
9
|
+
def initialize (*args)
|
|
10
|
+
|
|
11
|
+
super( *args )
|
|
12
|
+
@context = SDS::Context.new( app().store )
|
|
13
|
+
@users = @context.fetch( "User" )
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Delete @user_cursor - this is the user in the line in which the "Delete" button
|
|
19
|
+
# was clicked. The method returns self, so the same component will serve the next
|
|
20
|
+
# request in this session
|
|
21
|
+
def delete_user ()
|
|
22
|
+
|
|
23
|
+
puts "Deleting user #{@user_cursor.name}"
|
|
24
|
+
@user_cursor.rentals.each { |rental| rental.movie.rented = 0 }
|
|
25
|
+
@context.delete( @user_cursor )
|
|
26
|
+
@context.save()
|
|
27
|
+
@users.delete( @user_cursor )# = @context.fetch( "User" )
|
|
28
|
+
return self
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# Schedules a user for editing. Causes the edit table to appear. Returns self -
|
|
34
|
+
# serves next request
|
|
35
|
+
def edit_user ()
|
|
36
|
+
|
|
37
|
+
@current_user = @user_cursor
|
|
38
|
+
return self
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# Creates new user - causes the edit table to appear. Note the new user is not
|
|
44
|
+
# immediately saved.
|
|
45
|
+
def add_user ()
|
|
46
|
+
|
|
47
|
+
@current_user = User.create( @context )
|
|
48
|
+
return self
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# Returns true if a user has been selected
|
|
54
|
+
def has_current? ()
|
|
55
|
+
return @current_user != nil
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# Saves the user being edited into database
|
|
60
|
+
def confirm_changes ()
|
|
61
|
+
|
|
62
|
+
@context.save()
|
|
63
|
+
@users = @context.fetch( "User" )
|
|
64
|
+
@current_user = nil
|
|
65
|
+
return self
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
menu:
|
|
2
|
+
_class: Menu
|
|
3
|
+
|
|
4
|
+
browse_form:
|
|
5
|
+
_class: SWS::Form
|
|
6
|
+
|
|
7
|
+
user_repetition:
|
|
8
|
+
_class: SWS::Repetition
|
|
9
|
+
list: users
|
|
10
|
+
item: user_cursor
|
|
11
|
+
|
|
12
|
+
cursor_name:
|
|
13
|
+
_class: SWS::String
|
|
14
|
+
value: user_cursor.name
|
|
15
|
+
|
|
16
|
+
cursor_rental_count:
|
|
17
|
+
_class: SWS::String
|
|
18
|
+
value: user_cursor.rentals.size
|
|
19
|
+
|
|
20
|
+
submit_delete:
|
|
21
|
+
_class: SWS::SubmitButton
|
|
22
|
+
value: "'Delete'"
|
|
23
|
+
action: delete_user
|
|
24
|
+
|
|
25
|
+
submit_edit:
|
|
26
|
+
_class: SWS::SubmitButton
|
|
27
|
+
value: "'Edit'"
|
|
28
|
+
action: edit_user
|
|
29
|
+
|
|
30
|
+
submit_add:
|
|
31
|
+
_class: SWS::SubmitButton
|
|
32
|
+
value: "'New user'"
|
|
33
|
+
action: add_user
|
|
34
|
+
|
|
35
|
+
conditional_current:
|
|
36
|
+
_class: SWS::Conditional
|
|
37
|
+
condition: has_current?
|
|
38
|
+
|
|
39
|
+
edit_form:
|
|
40
|
+
_class: SWS::Form
|
|
41
|
+
|
|
42
|
+
current_name:
|
|
43
|
+
_class: SWS::TextField
|
|
44
|
+
value: current_user.name
|
|
45
|
+
|
|
46
|
+
submit_confirm:
|
|
47
|
+
_class: SWS::SubmitButton
|
|
48
|
+
value: "'Save'"
|
|
49
|
+
action: confirm_changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
components:
|
|
2
|
+
UserBrowse: UserBrowse
|
|
3
|
+
MovieBrowse: MovieBrowse
|
|
4
|
+
Menu: Menu
|
|
5
|
+
frameworks:
|
|
6
|
+
Core: SYSTEM/sws/Core
|
|
7
|
+
TestFramework: frameworks/TestFramework
|
|
8
|
+
adaptor_class: SWS::Adaptor::Standalone
|
|
9
|
+
session_class: Session
|
|
10
|
+
default_component_class: MovieBrowse
|
|
11
|
+
default_encoding: iso-8859-2
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
class PageAction < SWS::DirectAction
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def movie_action ( request )
|
|
5
|
+
|
|
6
|
+
component = SWS::Component.create( "MovieBrowse", request )
|
|
7
|
+
return component.process_request( request )
|
|
8
|
+
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def user_action ( request )
|
|
13
|
+
|
|
14
|
+
component = SWS::Component.create( "UserBrowse", request )
|
|
15
|
+
return component.process_request( request )
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def simple_action ( request )
|
|
21
|
+
|
|
22
|
+
response = SWS::Response.new( request )
|
|
23
|
+
response << <<-END
|
|
24
|
+
<html>
|
|
25
|
+
<head><title>Simple Action</title></head>
|
|
26
|
+
<body>
|
|
27
|
+
This is a result of a simple DirectAction
|
|
28
|
+
</body>
|
|
29
|
+
</html>
|
|
30
|
+
END
|
|
31
|
+
|
|
32
|
+
return nil, response
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
SDS::Store.get( "movies.sds" )
|
|
4
|
+
|
|
5
|
+
class Movie
|
|
6
|
+
|
|
7
|
+
include SDS::Object
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def rented? ()
|
|
11
|
+
return self.rented == 1
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def rental_state ()
|
|
16
|
+
|
|
17
|
+
if rented?
|
|
18
|
+
return "#{rentals.last.user.name}, at #{rentals.last.rental_date}"
|
|
19
|
+
else
|
|
20
|
+
return "Available"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def initialize ()
|
|
27
|
+
@rented = 0 if (@rented == nil)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class User
|
|
34
|
+
|
|
35
|
+
include SDS::Object
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class Rental
|
|
41
|
+
|
|
42
|
+
include SDS::Object
|
|
43
|
+
|
|
44
|
+
end
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "sws"
|
|
4
|
+
require "sds"
|
|
5
|
+
|
|
6
|
+
require "dbmovies"
|
|
7
|
+
require "English"
|
|
8
|
+
require "da"
|
|
9
|
+
|
|
10
|
+
class Application < SWS::Application
|
|
11
|
+
|
|
12
|
+
attr_reader :store
|
|
13
|
+
|
|
14
|
+
def initialize ()
|
|
15
|
+
super()
|
|
16
|
+
@store = SDS::Store.get("movies.sds")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class Session < SWS::Session
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
application = Application.new()
|
|
27
|
+
application.run()
|
|
28
|
+
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
name: mysql
|
|
2
|
+
connection:
|
|
3
|
+
url: "DBI:SQLite:movies.sqlite"
|
|
4
|
+
user: "filmy"
|
|
5
|
+
password: "filmy"
|
|
6
|
+
adaptor: SQLite
|
|
7
|
+
entities:
|
|
8
|
+
Movie:
|
|
9
|
+
ruby_class: Movie
|
|
10
|
+
table_name: movie
|
|
11
|
+
attributes:
|
|
12
|
+
id_movie:
|
|
13
|
+
column_name: id
|
|
14
|
+
primary_key: true
|
|
15
|
+
ruby_type: Fixnum
|
|
16
|
+
column_type: integer
|
|
17
|
+
generate_value: true
|
|
18
|
+
size: 10
|
|
19
|
+
polish_title:
|
|
20
|
+
column_name: polish_title
|
|
21
|
+
ruby_type: String
|
|
22
|
+
column_type: varchar
|
|
23
|
+
size: 50
|
|
24
|
+
allows_null: false
|
|
25
|
+
english_title:
|
|
26
|
+
column_name: english_title
|
|
27
|
+
ruby_type: String
|
|
28
|
+
column_type: varchar
|
|
29
|
+
size: 50
|
|
30
|
+
allows_null: false
|
|
31
|
+
cd_count:
|
|
32
|
+
column_name: cd_count
|
|
33
|
+
ruby_type: Fixnum
|
|
34
|
+
column_type: integer
|
|
35
|
+
size: 2
|
|
36
|
+
allows_null: false
|
|
37
|
+
description:
|
|
38
|
+
column_name: description
|
|
39
|
+
ruby_type: String
|
|
40
|
+
column_type: varchar
|
|
41
|
+
allows_null: true
|
|
42
|
+
size: 250
|
|
43
|
+
rented:
|
|
44
|
+
column_name: rented
|
|
45
|
+
column_type: integer
|
|
46
|
+
ruby_type: Fixnum
|
|
47
|
+
allows_null: false
|
|
48
|
+
relationships:
|
|
49
|
+
rentals:
|
|
50
|
+
type: to-many
|
|
51
|
+
source_attribute: id_movie
|
|
52
|
+
destination_attribute: id_movie
|
|
53
|
+
destination_entity: Rental
|
|
54
|
+
delete_rule: cascade
|
|
55
|
+
User:
|
|
56
|
+
ruby_class: User
|
|
57
|
+
table_name: user
|
|
58
|
+
attributes:
|
|
59
|
+
id_user:
|
|
60
|
+
column_name: id
|
|
61
|
+
column_type: integer
|
|
62
|
+
ruby_type: Fixnum
|
|
63
|
+
primary_key: true
|
|
64
|
+
generate_value: true
|
|
65
|
+
size: 10
|
|
66
|
+
name:
|
|
67
|
+
column_name: name
|
|
68
|
+
column_type: varchar
|
|
69
|
+
ruby_type: String
|
|
70
|
+
size: 100
|
|
71
|
+
allows_null: false
|
|
72
|
+
relationships:
|
|
73
|
+
rentals:
|
|
74
|
+
type: to-many
|
|
75
|
+
source_attribute: id_user
|
|
76
|
+
destination_attribute: id_user
|
|
77
|
+
destination_entity: Rental
|
|
78
|
+
delete_rule: cascade
|
|
79
|
+
Rental:
|
|
80
|
+
ruby_class: Rental
|
|
81
|
+
table_name: rental
|
|
82
|
+
attributes:
|
|
83
|
+
id_user:
|
|
84
|
+
column_name: id_user
|
|
85
|
+
column_type: integer
|
|
86
|
+
ruby_type: Fixnum
|
|
87
|
+
size: 10
|
|
88
|
+
allows_null: false
|
|
89
|
+
primary_key: true
|
|
90
|
+
id_movie:
|
|
91
|
+
column_name: id_movie
|
|
92
|
+
column_type: integer
|
|
93
|
+
ruby_type: Fixnum
|
|
94
|
+
size: 10
|
|
95
|
+
allows_null: false
|
|
96
|
+
primary_key: true
|
|
97
|
+
rental_date:
|
|
98
|
+
column_name: rental_date
|
|
99
|
+
column_type: date
|
|
100
|
+
ruby_type: Date
|
|
101
|
+
allows_null: false
|
|
102
|
+
return_date:
|
|
103
|
+
column_name: return_date
|
|
104
|
+
column_type: date
|
|
105
|
+
ruby_type: Date
|
|
106
|
+
allows_null: true
|
|
107
|
+
relationships:
|
|
108
|
+
movie:
|
|
109
|
+
type: to-one
|
|
110
|
+
source_attribute: id_movie
|
|
111
|
+
destination_attribute: id_movie
|
|
112
|
+
destination_entity: Movie
|
|
113
|
+
delete_rule: nullify
|
|
114
|
+
user:
|
|
115
|
+
type: to-one
|
|
116
|
+
source_attribute: id_user
|
|
117
|
+
destination_attribute: id_user
|
|
118
|
+
destination_entity: User
|
|
119
|
+
delete_rule: nullify
|
|
Binary file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
create table _pk_support (table_name varchar(250), pk integer(10)) type=InnoDB;
|
|
2
|
+
create table rental (
|
|
3
|
+
id_movie integer(10) NOT NULL,
|
|
4
|
+
id_user integer(10) NOT NULL,
|
|
5
|
+
return_date date,
|
|
6
|
+
rental_date date NOT NULL,
|
|
7
|
+
primary key ( id_movie,id_user )
|
|
8
|
+
) TYPE = InnoDB;
|
|
9
|
+
create table user (
|
|
10
|
+
name varchar(100) NOT NULL,
|
|
11
|
+
id integer(10) NOT NULL,
|
|
12
|
+
primary key ( id )
|
|
13
|
+
) TYPE = InnoDB;
|
|
14
|
+
insert into _pk_support (table_name,pk) values ('user',1);
|
|
15
|
+
create table movie (
|
|
16
|
+
id integer(10) NOT NULL,
|
|
17
|
+
english_title varchar(50) NOT NULL,
|
|
18
|
+
rented integer NOT NULL,
|
|
19
|
+
description varchar(250) NOT NULL,
|
|
20
|
+
cd_count integer(2) NOT NULL,
|
|
21
|
+
polish_title varchar(50) NOT NULL,
|
|
22
|
+
primary key ( id )
|
|
23
|
+
) TYPE = InnoDB;
|
|
24
|
+
insert into _pk_support (table_name,pk) values ('movie',1);
|
|
25
|
+
create index rental_user on rental (id_user);
|
|
26
|
+
alter table rental add constraint fk_rental_user foreign key (id_user) references user (id);
|
|
27
|
+
create index rental_movie on rental (id_movie);
|
|
28
|
+
alter table rental add constraint fk_rental_movie foreign key (id_movie) references movie (id);
|