Jennifer Chao 5 years ago
parent
commit
7fdb38cbe7

+ 1
- 0
.idea/compiler.xml View File

@@ -6,6 +6,7 @@
6 6
         <sourceOutputDir name="target/generated-sources/annotations" />
7 7
         <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
8 8
         <outputRelativeToContentRoot value="true" />
9
+        <module name="lab" />
9 10
         <module name="ORM_Lab" />
10 11
       </profile>
11 12
     </annotationProcessing>

+ 124
- 0
.idea/uiDesigner.xml View File

@@ -0,0 +1,124 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="Palette2">
4
+    <group name="Swing">
5
+      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
6
+        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
7
+      </item>
8
+      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
9
+        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
10
+      </item>
11
+      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
12
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
13
+      </item>
14
+      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
15
+        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
16
+      </item>
17
+      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
18
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
19
+        <initial-values>
20
+          <property name="text" value="Button" />
21
+        </initial-values>
22
+      </item>
23
+      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
24
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
25
+        <initial-values>
26
+          <property name="text" value="RadioButton" />
27
+        </initial-values>
28
+      </item>
29
+      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
30
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
31
+        <initial-values>
32
+          <property name="text" value="CheckBox" />
33
+        </initial-values>
34
+      </item>
35
+      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
36
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
37
+        <initial-values>
38
+          <property name="text" value="Label" />
39
+        </initial-values>
40
+      </item>
41
+      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
42
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
43
+          <preferred-size width="150" height="-1" />
44
+        </default-constraints>
45
+      </item>
46
+      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
47
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
48
+          <preferred-size width="150" height="-1" />
49
+        </default-constraints>
50
+      </item>
51
+      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
52
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
53
+          <preferred-size width="150" height="-1" />
54
+        </default-constraints>
55
+      </item>
56
+      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
57
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
58
+          <preferred-size width="150" height="50" />
59
+        </default-constraints>
60
+      </item>
61
+      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
62
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
63
+          <preferred-size width="150" height="50" />
64
+        </default-constraints>
65
+      </item>
66
+      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
67
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
68
+          <preferred-size width="150" height="50" />
69
+        </default-constraints>
70
+      </item>
71
+      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
72
+        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
73
+      </item>
74
+      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
75
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
76
+          <preferred-size width="150" height="50" />
77
+        </default-constraints>
78
+      </item>
79
+      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
80
+        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
81
+          <preferred-size width="150" height="50" />
82
+        </default-constraints>
83
+      </item>
84
+      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
85
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
86
+          <preferred-size width="150" height="50" />
87
+        </default-constraints>
88
+      </item>
89
+      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
90
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
91
+          <preferred-size width="200" height="200" />
92
+        </default-constraints>
93
+      </item>
94
+      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
95
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
96
+          <preferred-size width="200" height="200" />
97
+        </default-constraints>
98
+      </item>
99
+      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
100
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
101
+      </item>
102
+      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
103
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
104
+      </item>
105
+      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
106
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
107
+      </item>
108
+      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
109
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
110
+      </item>
111
+      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
112
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
113
+          <preferred-size width="-1" height="20" />
114
+        </default-constraints>
115
+      </item>
116
+      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
117
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
118
+      </item>
119
+      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
120
+        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
121
+      </item>
122
+    </group>
123
+  </component>
124
+</project>

+ 6
- 0
.idea/vcs.xml View File

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="VcsDirectoryMappings">
4
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+  </component>
6
+</project>

+ 305
- 53
.idea/workspace.xml View File

@@ -1,7 +1,23 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4
-    <list default="true" id="76ef3434-85fd-4aed-92dd-942905803ede" name="Default Changelist" comment="" />
4
+    <list default="true" id="76ef3434-85fd-4aed-92dd-942905803ede" name="Default Changelist" comment="">
5
+      <change afterPath="$PROJECT_DIR$/.idea/uiDesigner.xml" afterDir="false" />
6
+      <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
7
+      <change afterPath="$PROJECT_DIR$/src/main/java/AcctService.java" afterDir="false" />
8
+      <change afterPath="$PROJECT_DIR$/src/main/java/Console.java" afterDir="false" />
9
+      <change afterPath="$PROJECT_DIR$/src/test/java/AcctServiceTest.java" afterDir="false" />
10
+      <change afterPath="$PROJECT_DIR$/src/test/java/MockDao.java" afterDir="false" />
11
+      <change afterPath="$PROJECT_DIR$/target/classes/AcctService.class" afterDir="false" />
12
+      <change afterPath="$PROJECT_DIR$/target/classes/Console.class" afterDir="false" />
13
+      <change afterPath="$PROJECT_DIR$/target/test-classes/AcctServiceTest.class" afterDir="false" />
14
+      <change afterPath="$PROJECT_DIR$/target/test-classes/MockDao.class" afterDir="false" />
15
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
16
+      <change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
17
+      <change beforePath="$PROJECT_DIR$/src/main/java/AccountApp.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/AccountApp.java" afterDir="false" />
18
+      <change beforePath="$PROJECT_DIR$/target/classes/Account.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/Account.class" afterDir="false" />
19
+      <change beforePath="$PROJECT_DIR$/target/classes/AccountApp.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/AccountApp.class" afterDir="false" />
20
+    </list>
5 21
     <ignored path="$PROJECT_DIR$/out/" />
6 22
     <ignored path="$PROJECT_DIR$/target/" />
7 23
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -14,41 +30,50 @@
14 30
     <session id="-1963640883">
15 31
       <usages-collector id="statistics.lifecycle.project">
16 32
         <counts>
17
-          <entry key="project.open.time.1" value="1" />
18
-          <entry key="project.opened" value="1" />
33
+          <entry key="project.closed" value="7" />
34
+          <entry key="project.open.time.1" value="3" />
35
+          <entry key="project.open.time.14" value="1" />
36
+          <entry key="project.open.time.15" value="1" />
37
+          <entry key="project.open.time.2" value="2" />
38
+          <entry key="project.open.time.21" value="1" />
39
+          <entry key="project.opened" value="8" />
19 40
         </counts>
20 41
       </usages-collector>
21 42
       <usages-collector id="statistics.file.extensions.edit">
22 43
         <counts>
23
-          <entry key="java" value="133" />
24
-          <entry key="xml" value="19" />
44
+          <entry key="dummy" value="12" />
45
+          <entry key="java" value="8460" />
46
+          <entry key="xml" value="21" />
25 47
         </counts>
26 48
       </usages-collector>
27 49
       <usages-collector id="statistics.file.types.edit">
28 50
         <counts>
29
-          <entry key="JAVA" value="133" />
30
-          <entry key="XML" value="19" />
51
+          <entry key="JAVA" value="8460" />
52
+          <entry key="PLAIN_TEXT" value="12" />
53
+          <entry key="XML" value="21" />
31 54
         </counts>
32 55
       </usages-collector>
33 56
       <usages-collector id="statistics.file.extensions.open">
34 57
         <counts>
35
-          <entry key="java" value="2" />
58
+          <entry key="class" value="1" />
59
+          <entry key="java" value="14" />
36 60
         </counts>
37 61
       </usages-collector>
38 62
       <usages-collector id="statistics.file.types.open">
39 63
         <counts>
40
-          <entry key="JAVA" value="2" />
64
+          <entry key="CLASS" value="1" />
65
+          <entry key="JAVA" value="14" />
41 66
         </counts>
42 67
       </usages-collector>
43 68
     </session>
44 69
   </component>
45 70
   <component name="FileEditorManager">
46
-    <leaf>
47
-      <file pinned="false" current-in-tab="true">
71
+    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
72
+      <file pinned="false" current-in-tab="false">
48 73
         <entry file="file://$PROJECT_DIR$/pom.xml">
49 74
           <provider selected="true" editor-type-id="text-editor">
50
-            <state relative-caret-position="278">
51
-              <caret line="29" column="21" lean-forward="true" selection-start-line="25" selection-start-column="7" selection-end-line="29" selection-end-column="21" />
75
+            <state relative-caret-position="225">
76
+              <caret line="15" column="21" selection-start-line="15" selection-start-column="21" selection-end-line="15" selection-end-column="21" />
52 77
             </state>
53 78
           </provider>
54 79
         </entry>
@@ -56,8 +81,8 @@
56 81
       <file pinned="false" current-in-tab="false">
57 82
         <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
58 83
           <provider selected="true" editor-type-id="text-editor">
59
-            <state relative-caret-position="195">
60
-              <caret line="13" column="24" selection-start-line="13" selection-start-column="24" selection-end-line="13" selection-end-column="24" />
84
+            <state relative-caret-position="570">
85
+              <caret line="38" selection-start-line="38" selection-end-line="38" />
61 86
               <folding>
62 87
                 <element signature="imports" expanded="true" />
63 88
                 <element signature="e#668#669#0" expanded="true" />
@@ -82,8 +107,55 @@
82 107
       <file pinned="false" current-in-tab="false">
83 108
         <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
84 109
           <provider selected="true" editor-type-id="text-editor">
85
-            <state relative-caret-position="150">
86
-              <caret line="10" column="48" selection-start-line="10" selection-start-column="48" selection-end-line="10" selection-end-column="48" />
110
+            <state relative-caret-position="48">
111
+              <caret line="10" selection-start-line="10" selection-end-line="10" />
112
+              <folding>
113
+                <element signature="imports" expanded="true" />
114
+              </folding>
115
+            </state>
116
+          </provider>
117
+        </entry>
118
+      </file>
119
+      <file pinned="false" current-in-tab="false">
120
+        <entry file="file://$PROJECT_DIR$/src/main/java/AcctService.java">
121
+          <provider selected="true" editor-type-id="text-editor">
122
+            <state relative-caret-position="45">
123
+              <caret line="3" column="22" selection-start-line="3" selection-start-column="22" selection-end-line="3" selection-end-column="22" />
124
+              <folding>
125
+                <element signature="imports" expanded="true" />
126
+              </folding>
127
+            </state>
128
+          </provider>
129
+        </entry>
130
+      </file>
131
+      <file pinned="false" current-in-tab="false">
132
+        <entry file="file://$PROJECT_DIR$/src/test/java/MockDao.java">
133
+          <provider selected="true" editor-type-id="text-editor">
134
+            <state relative-caret-position="350">
135
+              <caret line="42" column="38" selection-start-line="42" selection-start-column="28" selection-end-line="42" selection-end-column="38" />
136
+              <folding>
137
+                <element signature="imports" expanded="true" />
138
+                <element signature="e#6317#6318#0" expanded="true" />
139
+                <element signature="e#6345#6346#0" expanded="true" />
140
+              </folding>
141
+            </state>
142
+          </provider>
143
+        </entry>
144
+      </file>
145
+      <file pinned="false" current-in-tab="true">
146
+        <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
147
+          <provider selected="true" editor-type-id="text-editor">
148
+            <state relative-caret-position="615">
149
+              <caret line="45" lean-forward="true" selection-start-line="45" selection-end-line="45" />
150
+            </state>
151
+          </provider>
152
+        </entry>
153
+      </file>
154
+      <file pinned="false" current-in-tab="false">
155
+        <entry file="file://$PROJECT_DIR$/src/test/java/AcctServiceTest.java">
156
+          <provider selected="true" editor-type-id="text-editor">
157
+            <state relative-caret-position="270">
158
+              <caret line="18" column="41" selection-start-line="18" selection-start-column="41" selection-end-line="18" selection-end-column="41" />
87 159
               <folding>
88 160
                 <element signature="imports" expanded="true" />
89 161
               </folding>
@@ -96,16 +168,39 @@
96 168
   <component name="FileTemplateManagerImpl">
97 169
     <option name="RECENT_TEMPLATES">
98 170
       <list>
171
+        <option value="Interface" />
99 172
         <option value="Class" />
100 173
       </list>
101 174
     </option>
102 175
   </component>
176
+  <component name="FindInProjectRecents">
177
+    <findStrings>
178
+      <find>create</find>
179
+      <find>update</find>
180
+      <find>query</find>
181
+      <find>delete</find>
182
+      <find>queryForId</find>
183
+    </findStrings>
184
+  </component>
185
+  <component name="Git.Settings">
186
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
187
+  </component>
103 188
   <component name="IdeDocumentHistory">
104 189
     <option name="CHANGED_PATHS">
105 190
       <list>
106 191
         <option value="$PROJECT_DIR$/src/main/java/Account.java" />
107
-        <option value="$PROJECT_DIR$/src/main/java/AccountApp.java" />
192
+        <option value="$PROJECT_DIR$/src/main/java/Service.java" />
193
+        <option value="$PROJECT_DIR$/src/main/java/Connection.java" />
194
+        <option value="$PROJECT_DIR$/src/main/java/MyConnection.java" />
195
+        <option value="$PROJECT_DIR$/src/main/java/MyDao.java" />
196
+        <option value="$PROJECT_DIR$/src/test/AcctServiceTest.java" />
108 197
         <option value="$PROJECT_DIR$/pom.xml" />
198
+        <option value="$PROJECT_DIR$/src/main/java/MockDao.java" />
199
+        <option value="$PROJECT_DIR$/src/main/java/Console.java" />
200
+        <option value="$PROJECT_DIR$/src/test/java/MockDao.java" />
201
+        <option value="$PROJECT_DIR$/src/main/java/AccountApp.java" />
202
+        <option value="$PROJECT_DIR$/src/test/java/AcctServiceTest.java" />
203
+        <option value="$PROJECT_DIR$/src/main/java/AcctService.java" />
109 204
       </list>
110 205
     </option>
111 206
   </component>
@@ -115,17 +210,25 @@
115 210
     <detection-done>true</detection-done>
116 211
     <sorting>DEFINITION_ORDER</sorting>
117 212
   </component>
118
-  <component name="ProjectFrameBounds" fullScreen="true">
213
+  <component name="MavenImportPreferences">
214
+    <option name="importingSettings">
215
+      <MavenImportingSettings>
216
+        <option name="importAutomatically" value="true" />
217
+      </MavenImportingSettings>
218
+    </option>
219
+  </component>
220
+  <component name="ProjectFrameBounds">
221
+    <option name="y" value="23" />
119 222
     <option name="width" value="1280" />
120
-    <option name="height" value="800" />
223
+    <option name="height" value="712" />
121 224
   </component>
122 225
   <component name="ProjectView">
123 226
     <navigator proportions="" version="1">
124 227
       <foldersAlwaysOnTop value="true" />
125 228
     </navigator>
126 229
     <panes>
127
-      <pane id="PackagesPane" />
128 230
       <pane id="Scope" />
231
+      <pane id="PackagesPane" />
129 232
       <pane id="ProjectPane">
130 233
         <subPane>
131 234
           <expand>
@@ -151,6 +254,12 @@
151 254
               <item name="main" type="462c0819:PsiDirectoryNode" />
152 255
               <item name="java" type="462c0819:PsiDirectoryNode" />
153 256
             </path>
257
+            <path>
258
+              <item name="ORM_Lab" type="b2602c69:ProjectViewProjectNode" />
259
+              <item name="ORM_Lab" type="462c0819:PsiDirectoryNode" />
260
+              <item name="src" type="462c0819:PsiDirectoryNode" />
261
+              <item name="test" type="462c0819:PsiDirectoryNode" />
262
+            </path>
154 263
           </expand>
155 264
           <select />
156 265
         </subPane>
@@ -160,13 +269,23 @@
160 269
   <component name="PropertiesComponent">
161 270
     <property name="WebServerToolWindowFactoryState" value="false" />
162 271
     <property name="aspect.path.notification.shown" value="true" />
163
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542238112165" />
272
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542594402583" />
273
+    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
164 274
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
165 275
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
166
-    <property name="project.structure.last.edited" value="Facets" />
167
-    <property name="project.structure.proportion" value="0.0" />
276
+    <property name="project.structure.last.edited" value="Project" />
277
+    <property name="project.structure.proportion" value="0.15" />
168 278
     <property name="project.structure.side.proportion" value="0.2" />
169 279
   </component>
280
+  <component name="RecentsManager">
281
+    <key name="MoveClassesOrPackagesDialog.RECENTS_KEY">
282
+      <recent name="" />
283
+    </key>
284
+    <key name="MoveFile.RECENT_KEYS">
285
+      <recent name="$PROJECT_DIR$/src/test/java" />
286
+      <recent name="$PROJECT_DIR$/src/test" />
287
+    </key>
288
+  </component>
170 289
   <component name="RunDashboard">
171 290
     <option name="ruleStates">
172 291
       <list>
@@ -179,17 +298,66 @@
179 298
       </list>
180 299
     </option>
181 300
   </component>
182
-  <component name="RunManager">
301
+  <component name="RunManager" selected="Application.AccountApp">
183 302
     <configuration name="AccountApp" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
184 303
       <option name="MAIN_CLASS_NAME" value="AccountApp" />
304
+      <module name="lab" />
305
+      <method v="2">
306
+        <option name="Make" enabled="true" />
307
+      </method>
308
+    </configuration>
309
+    <configuration name="AcctServiceTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
310
+      <module name="ORM_Lab" />
311
+      <option name="PACKAGE_NAME" value="" />
312
+      <option name="MAIN_CLASS_NAME" value="AcctServiceTest" />
313
+      <method v="2">
314
+        <option name="Make" enabled="true" />
315
+      </method>
316
+    </configuration>
317
+    <configuration name="AcctServiceTest.testDelete" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
318
+      <module name="ORM_Lab" />
319
+      <option name="PACKAGE_NAME" value="" />
320
+      <option name="MAIN_CLASS_NAME" value="AcctServiceTest" />
321
+      <option name="METHOD_NAME" value="testDelete" />
322
+      <option name="TEST_OBJECT" value="method" />
323
+      <method v="2">
324
+        <option name="Make" enabled="true" />
325
+      </method>
326
+    </configuration>
327
+    <configuration name="AcctServiceTest.testRead" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
185 328
       <module name="ORM_Lab" />
329
+      <option name="PACKAGE_NAME" value="" />
330
+      <option name="MAIN_CLASS_NAME" value="AcctServiceTest" />
331
+      <option name="METHOD_NAME" value="testRead" />
332
+      <option name="TEST_OBJECT" value="method" />
186 333
       <method v="2">
187 334
         <option name="Make" enabled="true" />
188 335
       </method>
189 336
     </configuration>
337
+    <configuration name="AcctServiceTest.testUpdate" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
338
+      <module name="ORM_Lab" />
339
+      <option name="PACKAGE_NAME" value="" />
340
+      <option name="MAIN_CLASS_NAME" value="AcctServiceTest" />
341
+      <option name="METHOD_NAME" value="testUpdate" />
342
+      <option name="TEST_OBJECT" value="method" />
343
+      <method v="2">
344
+        <option name="Make" enabled="true" />
345
+      </method>
346
+    </configuration>
347
+    <list>
348
+      <item itemvalue="Application.AccountApp" />
349
+      <item itemvalue="JUnit.AcctServiceTest.testUpdate" />
350
+      <item itemvalue="JUnit.AcctServiceTest.testRead" />
351
+      <item itemvalue="JUnit.AcctServiceTest.testDelete" />
352
+      <item itemvalue="JUnit.AcctServiceTest" />
353
+    </list>
190 354
     <recent_temporary>
191 355
       <list>
192 356
         <item itemvalue="Application.AccountApp" />
357
+        <item itemvalue="JUnit.AcctServiceTest" />
358
+        <item itemvalue="JUnit.AcctServiceTest.testDelete" />
359
+        <item itemvalue="JUnit.AcctServiceTest.testRead" />
360
+        <item itemvalue="JUnit.AcctServiceTest.testUpdate" />
193 361
       </list>
194 362
     </recent_temporary>
195 363
   </component>
@@ -203,45 +371,78 @@
203 371
       <option name="number" value="Default" />
204 372
       <option name="presentableId" value="Default" />
205 373
       <updated>1542236229831</updated>
206
-      <workItem from="1542236231335" duration="1178000" />
374
+      <workItem from="1542236231335" duration="1413000" />
375
+      <workItem from="1542239761668" duration="63000" />
376
+      <workItem from="1542309848640" duration="2016000" />
377
+      <workItem from="1542392881913" duration="4129000" />
378
+      <workItem from="1542401625311" duration="7476000" />
379
+      <workItem from="1542448654564" duration="172000" />
380
+      <workItem from="1542584165793" duration="9543000" />
381
+      <workItem from="1542594135985" duration="31000" />
207 382
     </task>
208 383
     <servers />
209 384
   </component>
385
+  <component name="TestHistory">
386
+    <history-entry file="AcctServiceTest_testCreate - 2018.11.16 at 16h 41m 19s.xml">
387
+      <configuration name="AcctServiceTest.testCreate" configurationId="JUnit" />
388
+    </history-entry>
389
+    <history-entry file="AcctServiceTest_testUpdate - 2018.11.16 at 16h 42m 46s.xml">
390
+      <configuration name="AcctServiceTest.testUpdate" configurationId="JUnit" />
391
+    </history-entry>
392
+    <history-entry file="AcctServiceTest_testCreate - 2018.11.16 at 16h 42m 49s.xml">
393
+      <configuration name="AcctServiceTest.testCreate" configurationId="JUnit" />
394
+    </history-entry>
395
+    <history-entry file="AcctServiceTest_testUpdate - 2018.11.16 at 16h 42m 59s.xml">
396
+      <configuration name="AcctServiceTest.testUpdate" configurationId="JUnit" />
397
+    </history-entry>
398
+    <history-entry file="AcctServiceTest_testRead - 2018.11.18 at 20h 57m 14s.xml">
399
+      <configuration name="AcctServiceTest.testRead" configurationId="JUnit" />
400
+    </history-entry>
401
+    <history-entry file="AcctServiceTest_testDelete - 2018.11.18 at 21h 12m 58s.xml">
402
+      <configuration name="AcctServiceTest.testDelete" configurationId="JUnit" />
403
+    </history-entry>
404
+    <history-entry file="AcctServiceTest - 2018.11.18 at 21h 16m 42s.xml">
405
+      <configuration name="AcctServiceTest" configurationId="JUnit" />
406
+    </history-entry>
407
+    <history-entry file="AcctServiceTest - 2018.11.18 at 21h 17m 35s.xml">
408
+      <configuration name="AcctServiceTest" configurationId="JUnit" />
409
+    </history-entry>
410
+  </component>
210 411
   <component name="TimeTrackingManager">
211
-    <option name="totallyTimeSpent" value="1178000" />
412
+    <option name="totallyTimeSpent" value="24843000" />
212 413
   </component>
213 414
   <component name="ToolWindowManager">
214
-    <frame x="0" y="0" width="1280" height="800" extended-state="0" />
415
+    <frame x="0" y="23" width="1280" height="712" extended-state="0" />
215 416
     <editor active="true" />
216 417
     <layout>
217
-      <window_info id="Image Layers" />
218
-      <window_info id="Designer" />
219
-      <window_info id="UI Designer" />
220
-      <window_info id="Capture Tool" />
221
-      <window_info id="Favorites" side_tool="true" />
222
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24959612" />
418
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.1825525" />
223 419
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
224
-      <window_info anchor="bottom" id="Messages" weight="0.32876712" />
225
-      <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
226
-      <window_info anchor="bottom" id="Version Control" show_stripe_button="false" />
227
-      <window_info anchor="bottom" id="Terminal" />
228
-      <window_info anchor="bottom" id="Event Log" side_tool="true" />
420
+      <window_info id="Image Layers" order="2" />
421
+      <window_info id="Designer" order="3" />
422
+      <window_info id="UI Designer" order="4" />
423
+      <window_info id="Capture Tool" order="5" />
424
+      <window_info id="Favorites" order="6" side_tool="true" />
229 425
       <window_info anchor="bottom" id="Message" order="0" />
230 426
       <window_info anchor="bottom" id="Find" order="1" />
231
-      <window_info anchor="bottom" id="Run" order="2" visible="true" weight="0.32876712" />
427
+      <window_info anchor="bottom" id="Run" order="2" weight="0.29452056" />
232 428
       <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
233 429
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
234 430
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
235 431
       <window_info anchor="bottom" id="TODO" order="6" />
236
-      <window_info anchor="right" id="Palette" />
237
-      <window_info anchor="right" id="Theme Preview" />
238
-      <window_info anchor="right" id="Capture Analysis" />
239
-      <window_info anchor="right" id="Palette&#9;" />
240
-      <window_info anchor="right" id="Database" />
241
-      <window_info anchor="right" id="Maven Projects" />
432
+      <window_info anchor="bottom" id="Version Control" order="7" show_stripe_button="false" />
433
+      <window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
434
+      <window_info anchor="bottom" id="Terminal" order="9" visible="true" weight="0.13548388" />
435
+      <window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
436
+      <window_info anchor="bottom" id="Messages" order="11" weight="0.32739726" />
242 437
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
243 438
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
244 439
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
440
+      <window_info anchor="right" id="Palette" order="3" />
441
+      <window_info anchor="right" id="Capture Analysis" order="4" />
442
+      <window_info anchor="right" id="Database" order="5" />
443
+      <window_info anchor="right" id="Theme Preview" order="6" />
444
+      <window_info anchor="right" id="Palette&#9;" order="7" />
445
+      <window_info anchor="right" id="Maven Projects" order="8" />
245 446
     </layout>
246 447
   </component>
247 448
   <component name="TypeScriptGeneratedFilesManager">
@@ -251,10 +452,29 @@
251 452
     <option name="myLimit" value="2678400000" />
252 453
   </component>
253 454
   <component name="editorHistoryManager">
455
+    <entry file="file://$PROJECT_DIR$/src/main/java/Service.java" />
456
+    <entry file="file://$PROJECT_DIR$/src/test/java/ServiceTest.java" />
457
+    <entry file="file://$PROJECT_DIR$/src/main/java/Connection.java" />
458
+    <entry file="file://$PROJECT_DIR$/src/main/java/MyConnection.java" />
459
+    <entry file="file://$PROJECT_DIR$/src/main/java/MyDao.java" />
460
+    <entry file="jar://$MAVEN_REPOSITORY$/com/j256/ormlite/ormlite-core/4.48/ormlite-core-4.48.jar!/com/j256/ormlite/dao/Dao.class">
461
+      <provider selected="true" editor-type-id="text-editor">
462
+        <state relative-caret-position="225">
463
+          <caret line="35" column="52" selection-start-line="35" selection-start-column="52" selection-end-line="35" selection-end-column="52" />
464
+        </state>
465
+      </provider>
466
+    </entry>
467
+    <entry file="file://$PROJECT_DIR$/pom.xml">
468
+      <provider selected="true" editor-type-id="text-editor">
469
+        <state relative-caret-position="225">
470
+          <caret line="15" column="21" selection-start-line="15" selection-start-column="21" selection-end-line="15" selection-end-column="21" />
471
+        </state>
472
+      </provider>
473
+    </entry>
254 474
     <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
255 475
       <provider selected="true" editor-type-id="text-editor">
256
-        <state relative-caret-position="195">
257
-          <caret line="13" column="24" selection-start-line="13" selection-start-column="24" selection-end-line="13" selection-end-column="24" />
476
+        <state relative-caret-position="570">
477
+          <caret line="38" selection-start-line="38" selection-end-line="38" />
258 478
           <folding>
259 479
             <element signature="imports" expanded="true" />
260 480
             <element signature="e#668#669#0" expanded="true" />
@@ -277,18 +497,50 @@
277 497
     </entry>
278 498
     <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
279 499
       <provider selected="true" editor-type-id="text-editor">
280
-        <state relative-caret-position="150">
281
-          <caret line="10" column="48" selection-start-line="10" selection-start-column="48" selection-end-line="10" selection-end-column="48" />
500
+        <state relative-caret-position="48">
501
+          <caret line="10" selection-start-line="10" selection-end-line="10" />
282 502
           <folding>
283 503
             <element signature="imports" expanded="true" />
284 504
           </folding>
285 505
         </state>
286 506
       </provider>
287 507
     </entry>
288
-    <entry file="file://$PROJECT_DIR$/pom.xml">
508
+    <entry file="file://$PROJECT_DIR$/src/main/java/AcctService.java">
509
+      <provider selected="true" editor-type-id="text-editor">
510
+        <state relative-caret-position="45">
511
+          <caret line="3" column="22" selection-start-line="3" selection-start-column="22" selection-end-line="3" selection-end-column="22" />
512
+          <folding>
513
+            <element signature="imports" expanded="true" />
514
+          </folding>
515
+        </state>
516
+      </provider>
517
+    </entry>
518
+    <entry file="file://$PROJECT_DIR$/src/test/java/MockDao.java">
519
+      <provider selected="true" editor-type-id="text-editor">
520
+        <state relative-caret-position="350">
521
+          <caret line="42" column="38" selection-start-line="42" selection-start-column="28" selection-end-line="42" selection-end-column="38" />
522
+          <folding>
523
+            <element signature="imports" expanded="true" />
524
+            <element signature="e#6317#6318#0" expanded="true" />
525
+            <element signature="e#6345#6346#0" expanded="true" />
526
+          </folding>
527
+        </state>
528
+      </provider>
529
+    </entry>
530
+    <entry file="file://$PROJECT_DIR$/src/test/java/AcctServiceTest.java">
531
+      <provider selected="true" editor-type-id="text-editor">
532
+        <state relative-caret-position="270">
533
+          <caret line="18" column="41" selection-start-line="18" selection-start-column="41" selection-end-line="18" selection-end-column="41" />
534
+          <folding>
535
+            <element signature="imports" expanded="true" />
536
+          </folding>
537
+        </state>
538
+      </provider>
539
+    </entry>
540
+    <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
289 541
       <provider selected="true" editor-type-id="text-editor">
290
-        <state relative-caret-position="278">
291
-          <caret line="29" column="21" lean-forward="true" selection-start-line="25" selection-start-column="7" selection-end-line="29" selection-end-column="21" />
542
+        <state relative-caret-position="615">
543
+          <caret line="45" lean-forward="true" selection-start-line="45" selection-end-line="45" />
292 544
         </state>
293 545
       </provider>
294 546
     </entry>

+ 211
- 0
README.md View File

@@ -0,0 +1,211 @@
1
+# Part 1 - Create MySQL Database
2
+1. Start MySQL from console
3
+2. Create a new Database named 'orm_lab'
4
+3. Inside that database create a new table name 'account'
5
+4. the schema should be as folllow
6
+
7
+
8
+		*	id INT NOT NULL AUTO_INCREMENT
9
+		* 	name VARCHAR(20)
10
+		*  password VARCHAR(20)
11
+		*  PRIMARY KEY = id
12
+
13
+# PART 2 - Create Java App
14
+
15
+## Adding dependencies
16
+1 Create a new Java Maven project
17
+
18
+2 Update the pom.xml file by adding the following dependencies. These are the dependencies for the ORM library we will be using.
19
+
20
+```
21
+        <!-- https://mvnrepository.com/artifact/com.j256.ormlite/ormlite-core -->
22
+        <dependency>
23
+            <groupId>com.j256.ormlite</groupId>
24
+            <artifactId>ormlite-core</artifactId>
25
+            <version>4.48</version>
26
+        </dependency>
27
+
28
+        <!-- https://mvnrepository.com/artifact/com.j256.ormlite/ormlite-jdbc -->
29
+        <dependency>
30
+            <groupId>com.j256.ormlite</groupId>
31
+            <artifactId>ormlite-jdbc</artifactId>
32
+            <version>4.48</version>
33
+        </dependency>
34
+```
35
+
36
+
37
+3 Then also add the following. This is a dependency that allows us to connect our Java code to MySql
38
+
39
+```
40
+        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
41
+        <dependency>
42
+            <groupId>mysql</groupId>
43
+            <artifactId>mysql-connector-java</artifactId>
44
+            <version>5.1.6</version>
45
+        </dependency>
46
+
47
+```
48
+## Create Application Model
49
+Create a new Java class name 'Account'
50
+
51
+```
52
+import com.j256.ormlite.field.DatabaseField;
53
+import com.j256.ormlite.table.DatabaseTable;
54
+
55
+@DatabaseTable(tableName = "account")
56
+public class Account {
57
+
58
+    public static final String NAME_FIELD_NAME = "name";
59
+    public static final String PASSWORD_FIELD_NAME = "password";
60
+
61
+    @DatabaseField(columnName = "id", generatedId = true)
62
+    private int id;
63
+
64
+    @DatabaseField(columnName = "name", canBeNull = false)
65
+    private String name;
66
+
67
+    @DatabaseField(columnName = "password")
68
+    private String password;
69
+
70
+    Account() {
71
+        // all persisted classes must define a no-arg constructor with at least package visibility
72
+    }
73
+
74
+    public Account(String name) {
75
+        this.name = name;
76
+    }
77
+
78
+    public Account(String name, String password) {
79
+        this.name = name;
80
+        this.password = password;
81
+    }
82
+
83
+    public int getId() {
84
+        return id;
85
+    }
86
+
87
+    public String getName() {
88
+        return name;
89
+    }
90
+
91
+    public void setName(String name) {
92
+        this.name = name;
93
+    }
94
+
95
+    public String getPassword() {
96
+        return password;
97
+    }
98
+
99
+    public void setPassword(String password) {
100
+        this.password = password;
101
+    }
102
+
103
+    @Override
104
+    public int hashCode() {
105
+        return name.hashCode();
106
+    }
107
+
108
+    @Override
109
+    public boolean equals(Object other) {
110
+        if (other == null || other.getClass() != getClass()) {
111
+            return false;
112
+        }
113
+        return name.equals(((Account) other).name);
114
+    }
115
+}
116
+```
117
+The things to notice here are the annotations. These annotations tell OrmLite how to relate our Java Objects to the records in MySQL
118
+
119
+## Implement the ORM
120
+
121
+Create a Java class name 'AccountApp'
122
+
123
+```
124
+import com.j256.ormlite.dao.Dao;
125
+import com.j256.ormlite.dao.DaoManager;
126
+import com.j256.ormlite.jdbc.JdbcConnectionSource;
127
+import com.j256.ormlite.support.ConnectionSource;
128
+
129
+public class AccountApp {
130
+
131
+    // we are using a MySQl database
132
+    private final static String DATABASE_URL = "jdbc:mysql://localhost:3306/orm_lab?useUnicode=true";
133
+
134
+    private Dao<Account, Integer> accountDao;
135
+
136
+    public static void main(String[] args) throws Exception {
137
+        // turn our static method into an instance of Main
138
+        new AccountApp().doMain(args);
139
+    }
140
+
141
+    private void doMain(String[] args) throws Exception {
142
+        ConnectionSource connectionSource = null;
143
+        try {
144
+            // create our data-source for the database
145
+            connectionSource = new JdbcConnectionSource(DATABASE_URL, YOURUSERNAME, YOURPASSWORD);
146
+            // setup our  DAOs
147
+            setupDao(connectionSource);
148
+            // read, write and delete some data
149
+            processData();
150
+
151
+            System.out.println("\n\nIt seems to have worked\n\n");
152
+        } finally {
153
+            // destroy the data source which should close underlying connections
154
+            if (connectionSource != null) {
155
+                connectionSource.close();
156
+            }
157
+        }
158
+    }
159
+
160
+    /**
161
+     * Read and write some example data.
162
+     */
163
+    private void processData() throws Exception {
164
+        // create an instance of Account
165
+        String name = "Jim Coakley";
166
+        Account account = new Account(name);
167
+
168
+        // persist the account object to the database
169
+        accountDao.create(account);
170
+        int id = account.getId();
171
+        System.out.println(id);
172
+        // assign a password
173
+         account.setPassword("_secret");
174
+        // update the database after changing the object
175
+        accountDao.update(account);
176
+        // delete the account
177
+        //accountDao.deleteById(id);
178
+    }
179
+
180
+    /**
181
+     * Setup our  DAOs
182
+     */
183
+    private void setupDao(ConnectionSource connectionSource) throws Exception {
184
+
185
+        accountDao = DaoManager.createDao(connectionSource, Account.class);
186
+
187
+    }
188
+}
189
+```
190
+Some of the things in this class to take notice are the objects that the imported libraries offer us:
191
+
192
+* JdbcConnectionSource from the JDBC library
193
+* Dao and DaoManager from the OrmLite
194
+
195
+! Links to the above APIs are listed below
196
+
197
+Now if we run this we should see some info in the console of IntelliJ telling us that the program ran ok. And if we look over to MySQL we can query the table and see that our code has create and updated a record in out database
198
+
199
+! Remember MySQL needs to be up and running
200
+
201
+# Part 3
202
+
203
+If you have made it this far and you're able to run the program properly, Congratulations!
204
+
205
+The program this far only runs through a few lines of code before it exits. Upgrade the program so that it enters a control loop and allows the user to interact with your database until they quit the program. You will need to impletment CRUD functionality in the form of an account service. Dont forget to visit the ORMLite api as a reference for what you can do with the library
206
+
207
+### References
208
+* [OrmLite core API](http://ormlite.com/javadoc/ormlite-core/)
209
+* [OrmLite JDBC](http://ormlite.com/javadoc/ormlite-jdbc/)
210
+* [JdbcConnectionSource](http://ormlite.com/javadoc/ormlite-jdbc/com/j256/ormlite/jdbc/JdbcConnectionSource.html)
211
+* [What is CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete)

+ 9
- 0
pom.xml View File

@@ -29,6 +29,15 @@
29 29
             <version>8.0.12</version>
30 30
         </dependency>
31 31
 
32
+        <!-- https://mvnrepository.com/artifact/junit/junit -->
33
+        <dependency>
34
+            <groupId>junit</groupId>
35
+            <artifactId>junit</artifactId>
36
+            <version>4.12</version>
37
+            <scope>test</scope>
38
+        </dependency>
39
+
40
+
32 41
     </dependencies>
33 42
 
34 43
 

+ 37
- 14
src/main/java/AccountApp.java View File

@@ -3,6 +3,10 @@ import com.j256.ormlite.dao.DaoManager;
3 3
 import com.j256.ormlite.jdbc.JdbcConnectionSource;
4 4
 import com.j256.ormlite.support.ConnectionSource;
5 5
 
6
+import java.sql.SQLDataException;
7
+import java.sql.SQLException;
8
+import java.util.Scanner;
9
+
6 10
 public class AccountApp {
7 11
 
8 12
     // we are using a MySQl database
@@ -11,6 +15,7 @@ public class AccountApp {
11 15
     private final static String YOURPASSWORD = "";
12 16
 
13 17
     private Dao<Account, Integer> accountDao;
18
+    private Console console = new Console();
14 19
 
15 20
     public static void main(String[] args) throws Exception {
16 21
         // turn our static method into an instance of Main
@@ -27,7 +32,7 @@ public class AccountApp {
27 32
             // read, write and delete some data
28 33
             processData();
29 34
 
30
-            System.out.println("\n\nIt seems to have worked\n\n");
35
+            System.out.println("\n\nGoodbye!\n\n");
31 36
         } finally {
32 37
             // destroy the data source which should close underlying connections
33 38
             if (connectionSource != null) {
@@ -40,20 +45,38 @@ public class AccountApp {
40 45
      * Read and write some example data.
41 46
      */
42 47
     private void processData() throws Exception {
43
-        // create an instance of Account
44
-        String name = "Jim Coakley";
45
-        Account account = new Account(name);
48
+        boolean flag = true;
49
+        AcctService acctService = new AcctService(accountDao);
50
+
51
+        while (flag) {
52
+            String input = console.inputMenu();
46 53
 
47
-        // persist the account object to the database
48
-        accountDao.create(account);
49
-        int id = account.getId();
50
-        System.out.println(id);
51
-        // assign a password
52
-        account.setPassword("_secret");
53
-        // update the database after changing the object
54
-        accountDao.update(account);
55
-        // delete the account
56
-        //accountDao.deleteById(id);
54
+            switch (input) {
55
+                case "CREATE":
56
+                    acctService.createAccount();
57
+                    console.successMessage(input);
58
+                    break;
59
+                case "READ":
60
+                    acctService.readAccounts(acctService.read());
61
+                    console.successMessage(input);
62
+                    break;
63
+                case "UPDATE":
64
+                    acctService.updateAccount();
65
+                    console.successMessage(input);
66
+                    break;
67
+                case "DELETE":
68
+                    acctService.delete(console.deleteAccount());
69
+                    console.successMessage(input);
70
+                    break;
71
+                case "QUIT":
72
+                    flag = false;
73
+                    break;
74
+                default:
75
+                    console.errorMessage();
76
+                    break;
77
+            }
78
+
79
+        }
57 80
     }
58 81
 
59 82
     /**

+ 76
- 0
src/main/java/AcctService.java View File

@@ -0,0 +1,76 @@
1
+import com.j256.ormlite.dao.Dao;
2
+
3
+import java.sql.SQLException;
4
+import java.util.List;
5
+
6
+public class AcctService {
7
+
8
+    private Dao<Account, Integer> dao;
9
+    private Console console = new Console();
10
+
11
+
12
+    public AcctService(Dao<Account, Integer> dao) {
13
+        this.dao = dao;
14
+    }
15
+
16
+    public int create(Account account) throws SQLException {
17
+        return dao.create(account);
18
+    }
19
+
20
+    public void createAccount() throws SQLException {
21
+        String name = "ACCOUNT_NAME";
22
+        String password = "ACCOUNT_PASSWORD";
23
+        Account account = new Account(name, password);
24
+
25
+        create(account);
26
+    }
27
+
28
+    public List<Account> read() throws SQLException {
29
+        return dao.queryForAll();
30
+    }
31
+
32
+    public void readAccounts(List<Account> accounts) throws SQLException {
33
+        console.tableHeader();
34
+        for (Account account : accounts) {
35
+            console.getAccountInfo(account);
36
+        }
37
+    }
38
+
39
+    public int update(Account account) throws SQLException {
40
+        return dao.update(account);
41
+    }
42
+
43
+    public void updateAccount() throws SQLException {
44
+        Integer ID = console.getAccountID();
45
+        Account account = getByID(ID);
46
+
47
+        String input = console.updateMenu();
48
+
49
+        if ("NAME".equals(input)) {
50
+            String name = console.updateName();
51
+            updateName(account, name);
52
+        } else if ("PASSWORD".equals(input)) {
53
+            String password = console.updatePassword();
54
+            updatePassword(account, password);
55
+        }
56
+    }
57
+
58
+    public int delete(int id) throws SQLException {
59
+        return dao.deleteById(id);
60
+    }
61
+
62
+    public Account getByID(Integer ID) throws SQLException {
63
+        return dao.queryForId(ID);
64
+    }
65
+
66
+    public void updateName(Account account, String name) throws SQLException {
67
+        account.setName(name);
68
+        update(account);
69
+    }
70
+
71
+    public void updatePassword(Account account, String password) throws SQLException {
72
+        account.setPassword(password);
73
+        update(account);
74
+    }
75
+
76
+}

+ 59
- 0
src/main/java/Console.java View File

@@ -0,0 +1,59 @@
1
+import java.util.Scanner;
2
+
3
+public class Console {
4
+
5
+    public Scanner scanner = new Scanner(System.in);
6
+
7
+    public String inputMenu() {
8
+        System.out.println("\nWhat would you like to do?");
9
+        System.out.println("<< Create - Read - Update - Delete - Quit >>");
10
+        return scanner.nextLine().toUpperCase();
11
+    }
12
+
13
+    public Integer getAccountID() {
14
+        System.out.println("\nWhat is the ID of the account you want to update?");
15
+        return scanner.nextInt();
16
+    }
17
+
18
+    public String updateMenu() {
19
+        System.out.println("\nWhat would you like to update?");
20
+        System.out.println("<< Name - Password - Back >>");
21
+        return scanner.next().toUpperCase();
22
+    }
23
+
24
+    public void getAccountInfo(Account account) {
25
+        System.out.println(accountInfoFormat(account));
26
+    }
27
+
28
+    public String accountInfoFormat(Account account) {
29
+        return String.format("%5s | %20s | %20s", account.getId(), account.getName(), account.getPassword());
30
+    }
31
+
32
+    public void tableHeader() {
33
+        System.out.println(String.format("\n%5s | %20s | %20s", "ID", "NAME", "PASSWORD"));
34
+    }
35
+
36
+    public String updateName() {
37
+        System.out.println("\nWhat is the updated name for the account?");
38
+        scanner.nextLine();
39
+        return scanner.nextLine();
40
+    }
41
+
42
+    public String updatePassword() {
43
+        System.out.println("\nWhat is the updated password for the account?");
44
+        return scanner.next();
45
+    }
46
+
47
+    public Integer deleteAccount() {
48
+        System.out.println("\nWhat is the ID of the account you want to delete?");
49
+        return scanner.nextInt();
50
+    }
51
+
52
+    public void errorMessage() {
53
+        System.out.println("\nThat's not a valid input, please try again.");
54
+    }
55
+
56
+    public void successMessage(String input) {
57
+        System.out.println("\n" + input + " completed successfully.");
58
+    }
59
+}

+ 56
- 0
src/test/java/AcctServiceTest.java View File

@@ -0,0 +1,56 @@
1
+import com.j256.ormlite.dao.Dao;
2
+import org.junit.Assert;
3
+import org.junit.Test;
4
+
5
+import java.sql.SQLException;
6
+import java.util.List;
7
+
8
+public class AcctServiceTest {
9
+
10
+    // just testing that the connection has actually been made
11
+    Dao<Account, Integer> dao = new MockDao();
12
+    AcctService testService = new AcctService(dao);
13
+
14
+    @Test
15
+    public void testCreate() throws SQLException {
16
+        int exp = 100;
17
+        int actual = testService.create(new Account("MOCKACCOUNT", "MOCKPASSWORD"));
18
+
19
+        Assert.assertEquals(exp, actual);
20
+    }
21
+
22
+    @Test
23
+    public void testRead() throws SQLException{
24
+        List<Account> testList = testService.read();
25
+
26
+        String expected = "READACCOUNTS";
27
+        String actual = testList.get(0).getName();
28
+
29
+        Assert.assertEquals(expected, actual);
30
+    }
31
+
32
+    @Test
33
+    public void testUpdate() throws SQLException {
34
+        int exp = 200;
35
+        int actual = testService.update(new Account("MOCKACCOUNT", "MOCKPASSWORD"));
36
+
37
+        Assert.assertEquals(exp, actual);
38
+    }
39
+
40
+    @Test
41
+    public void testDelete() throws SQLException{
42
+        int expected = 300;
43
+        int actual = testService.delete(999);
44
+
45
+        Assert.assertEquals(expected, actual);
46
+    }
47
+
48
+    @Test
49
+    public void testGetById() throws SQLException{
50
+        String expected = "QUERYFORID";
51
+        String actual = testService.getByID(999).getName();
52
+
53
+        Assert.assertEquals(expected, actual);
54
+    }
55
+
56
+}

+ 380
- 0
src/test/java/MockDao.java View File

@@ -0,0 +1,380 @@
1
+import com.j256.ormlite.dao.*;
2
+import com.j256.ormlite.field.DataType;
3
+import com.j256.ormlite.field.FieldType;
4
+import com.j256.ormlite.stmt.*;
5
+import com.j256.ormlite.support.ConnectionSource;
6
+import com.j256.ormlite.support.DatabaseConnection;
7
+import com.j256.ormlite.support.DatabaseResults;
8
+import com.j256.ormlite.table.ObjectFactory;
9
+
10
+import java.sql.SQLException;
11
+import java.util.ArrayList;
12
+import java.util.Collection;
13
+import java.util.List;
14
+import java.util.Map;
15
+import java.util.concurrent.Callable;
16
+
17
+public class MockDao implements Dao<Account, Integer> {
18
+
19
+    @Override
20
+    public int create(Account account) throws SQLException {
21
+        return 100;
22
+    }
23
+
24
+    @Override
25
+    public List<Account> queryForAll() throws SQLException {
26
+        List<Account> accounts = new ArrayList<>();
27
+        accounts.add(new Account("READACCOUNTS", "MOCKPASSWORD"));
28
+        return accounts;
29
+    }
30
+
31
+    @Override
32
+    public int update(Account account) throws SQLException {
33
+        return 200;
34
+    }
35
+
36
+    @Override
37
+    public int deleteById(Integer integer) throws SQLException {
38
+        return 300;
39
+    }
40
+
41
+    @Override
42
+    public Account queryForId(Integer integer) throws SQLException {
43
+        return new Account("QUERYFORID", "MOCKPASSWORD");
44
+    }
45
+
46
+
47
+    ////////////// UNUSED METHODS
48
+
49
+
50
+    @Override
51
+    public Account queryForFirst(PreparedQuery<Account> preparedQuery) throws SQLException {
52
+        return null;
53
+    }
54
+
55
+    @Override
56
+    public List<Account> queryForEq(String s, Object o) throws SQLException {
57
+        return null;
58
+    }
59
+
60
+    @Override
61
+    public List<Account> queryForMatching(Account account) throws SQLException {
62
+        return null;
63
+    }
64
+
65
+    @Override
66
+    public List<Account> queryForMatchingArgs(Account account) throws SQLException {
67
+        return null;
68
+    }
69
+
70
+    @Override
71
+    public List<Account> queryForFieldValues(Map<String, Object> map) throws SQLException {
72
+        return null;
73
+    }
74
+
75
+    @Override
76
+    public List<Account> queryForFieldValuesArgs(Map<String, Object> map) throws SQLException {
77
+        return null;
78
+    }
79
+
80
+    @Override
81
+    public Account queryForSameId(Account account) throws SQLException {
82
+        return null;
83
+    }
84
+
85
+    @Override
86
+    public QueryBuilder<Account, Integer> queryBuilder() {
87
+        return null;
88
+    }
89
+
90
+    @Override
91
+    public UpdateBuilder<Account, Integer> updateBuilder() {
92
+        return null;
93
+    }
94
+
95
+    @Override
96
+    public DeleteBuilder<Account, Integer> deleteBuilder() {
97
+        return null;
98
+    }
99
+
100
+    @Override
101
+    public List<Account> query(PreparedQuery<Account> preparedQuery) throws SQLException {
102
+        return null;
103
+    }
104
+
105
+    @Override
106
+    public Account createIfNotExists(Account account) throws SQLException {
107
+        return null;
108
+    }
109
+
110
+    @Override
111
+    public CreateOrUpdateStatus createOrUpdate(Account account) throws SQLException {
112
+        return null;
113
+    }
114
+
115
+
116
+    @Override
117
+    public int updateId(Account account, Integer integer) throws SQLException {
118
+        return 0;
119
+    }
120
+
121
+    @Override
122
+    public int update(PreparedUpdate<Account> preparedUpdate) throws SQLException {
123
+        return 0;
124
+    }
125
+
126
+    @Override
127
+    public int refresh(Account account) throws SQLException {
128
+        return 0;
129
+    }
130
+
131
+    @Override
132
+    public int delete(Account account) throws SQLException {
133
+        return 0;
134
+    }
135
+
136
+    @Override
137
+    public int delete(Collection<Account> collection) throws SQLException {
138
+        return 0;
139
+    }
140
+
141
+    @Override
142
+    public int deleteIds(Collection<Integer> collection) throws SQLException {
143
+        return 0;
144
+    }
145
+
146
+    @Override
147
+    public int delete(PreparedDelete<Account> preparedDelete) throws SQLException {
148
+        return 0;
149
+    }
150
+
151
+    @Override
152
+    public CloseableIterator<Account> iterator() {
153
+        return null;
154
+    }
155
+
156
+    @Override
157
+    public CloseableIterator<Account> iterator(int i) {
158
+        return null;
159
+    }
160
+
161
+    @Override
162
+    public CloseableIterator<Account> iterator(PreparedQuery<Account> preparedQuery) throws SQLException {
163
+        return null;
164
+    }
165
+
166
+    @Override
167
+    public CloseableIterator<Account> iterator(PreparedQuery<Account> preparedQuery, int i) throws SQLException {
168
+        return null;
169
+    }
170
+
171
+    @Override
172
+    public CloseableWrappedIterable<Account> getWrappedIterable() {
173
+        return null;
174
+    }
175
+
176
+    @Override
177
+    public CloseableWrappedIterable<Account> getWrappedIterable(PreparedQuery<Account> preparedQuery) {
178
+        return null;
179
+    }
180
+
181
+    @Override
182
+    public void closeLastIterator() throws SQLException {
183
+
184
+    }
185
+
186
+    @Override
187
+    public GenericRawResults<String[]> queryRaw(String s, String... strings) throws SQLException {
188
+        return null;
189
+    }
190
+
191
+    @Override
192
+    public <UO> GenericRawResults<UO> queryRaw(String s, RawRowMapper<UO> rawRowMapper, String... strings) throws SQLException {
193
+        return null;
194
+    }
195
+
196
+    @Override
197
+    public <UO> GenericRawResults<UO> queryRaw(String s, DataType[] dataTypes, RawRowObjectMapper<UO> rawRowObjectMapper, String... strings) throws SQLException {
198
+        return null;
199
+    }
200
+
201
+    @Override
202
+    public GenericRawResults<Object[]> queryRaw(String s, DataType[] dataTypes, String... strings) throws SQLException {
203
+        return null;
204
+    }
205
+
206
+    @Override
207
+    public long queryRawValue(String s, String... strings) throws SQLException {
208
+        return 0;
209
+    }
210
+
211
+    @Override
212
+    public int executeRaw(String s, String... strings) throws SQLException {
213
+        return 0;
214
+    }
215
+
216
+    @Override
217
+    public int executeRawNoArgs(String s) throws SQLException {
218
+        return 0;
219
+    }
220
+
221
+    @Override
222
+    public int updateRaw(String s, String... strings) throws SQLException {
223
+        return 0;
224
+    }
225
+
226
+    @Override
227
+    public <CT> CT callBatchTasks(Callable<CT> callable) throws Exception {
228
+        return null;
229
+    }
230
+
231
+    @Override
232
+    public String objectToString(Account account) {
233
+        return null;
234
+    }
235
+
236
+    @Override
237
+    public boolean objectsEqual(Account account, Account t1) throws SQLException {
238
+        return false;
239
+    }
240
+
241
+    @Override
242
+    public Integer extractId(Account account) throws SQLException {
243
+        return null;
244
+    }
245
+
246
+    @Override
247
+    public Class<Account> getDataClass() {
248
+        return null;
249
+    }
250
+
251
+    @Override
252
+    public FieldType findForeignFieldType(Class<?> aClass) {
253
+        return null;
254
+    }
255
+
256
+    @Override
257
+    public boolean isUpdatable() {
258
+        return false;
259
+    }
260
+
261
+    @Override
262
+    public boolean isTableExists() throws SQLException {
263
+        return false;
264
+    }
265
+
266
+    @Override
267
+    public long countOf() throws SQLException {
268
+        return 0;
269
+    }
270
+
271
+    @Override
272
+    public long countOf(PreparedQuery<Account> preparedQuery) throws SQLException {
273
+        return 0;
274
+    }
275
+
276
+    @Override
277
+    public void assignEmptyForeignCollection(Account account, String s) throws SQLException {
278
+
279
+    }
280
+
281
+    @Override
282
+    public <FT> ForeignCollection<FT> getEmptyForeignCollection(String s) throws SQLException {
283
+        return null;
284
+    }
285
+
286
+    @Override
287
+    public void setObjectCache(boolean b) throws SQLException {
288
+
289
+    }
290
+
291
+    @Override
292
+    public void setObjectCache(ObjectCache objectCache) throws SQLException {
293
+
294
+    }
295
+
296
+    @Override
297
+    public ObjectCache getObjectCache() {
298
+        return null;
299
+    }
300
+
301
+    @Override
302
+    public void clearObjectCache() {
303
+
304
+    }
305
+
306
+    @Override
307
+    public Account mapSelectStarRow(DatabaseResults databaseResults) throws SQLException {
308
+        return null;
309
+    }
310
+
311
+    @Override
312
+    public GenericRowMapper<Account> getSelectStarRowMapper() throws SQLException {
313
+        return null;
314
+    }
315
+
316
+    @Override
317
+    public RawRowMapper<Account> getRawRowMapper() {
318
+        return null;
319
+    }
320
+
321
+    @Override
322
+    public boolean idExists(Integer integer) throws SQLException {
323
+        return false;
324
+    }
325
+
326
+    @Override
327
+    public DatabaseConnection startThreadConnection() throws SQLException {
328
+        return null;
329
+    }
330
+
331
+    @Override
332
+    public void endThreadConnection(DatabaseConnection databaseConnection) throws SQLException {
333
+
334
+    }
335
+
336
+    @Override
337
+    public void setAutoCommit(boolean b) throws SQLException {
338
+
339
+    }
340
+
341
+    @Override
342
+    public void setAutoCommit(DatabaseConnection databaseConnection, boolean b) throws SQLException {
343
+
344
+    }
345
+
346
+    @Override
347
+    public boolean isAutoCommit() throws SQLException {
348
+        return false;
349
+    }
350
+
351
+    @Override
352
+    public boolean isAutoCommit(DatabaseConnection databaseConnection) throws SQLException {
353
+        return false;
354
+    }
355
+
356
+    @Override
357
+    public void commit(DatabaseConnection databaseConnection) throws SQLException {
358
+
359
+    }
360
+
361
+    @Override
362
+    public void rollBack(DatabaseConnection databaseConnection) throws SQLException {
363
+
364
+    }
365
+
366
+    @Override
367
+    public ConnectionSource getConnectionSource() {
368
+        return null;
369
+    }
370
+
371
+    @Override
372
+    public void setObjectFactory(ObjectFactory<Account> objectFactory) {
373
+
374
+    }
375
+
376
+    @Override
377
+    public CloseableIterator<Account> closeableIterator() {
378
+        return null;
379
+    }
380
+}

BIN
target/classes/Account.class View File


BIN
target/classes/AccountApp.class View File


BIN
target/classes/AcctService.class View File


BIN
target/classes/Console.class View File


BIN
target/test-classes/AcctServiceTest.class View File


BIN
target/test-classes/MockDao.class View File