mirror of
https://github.com/jlengrand/exposed-imdb.git
synced 2026-03-10 00:11:16 +00:00
Create repository
This commit is contained in:
62
.gitignore
vendored
Normal file
62
.gitignore
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
.DS_Store
|
||||
.idea/shelf
|
||||
/confluence/target
|
||||
/dependencies/repo
|
||||
/android.tests.dependencies
|
||||
/dependencies/android.tests.dependencies
|
||||
/dist
|
||||
/local
|
||||
/gh-pages
|
||||
/ideaSDK
|
||||
/clionSDK
|
||||
/android-studio/sdk
|
||||
out/
|
||||
/tmp
|
||||
workspace.xml
|
||||
*.versionsBackup
|
||||
/idea/testData/debugger/tinyApp/classes*
|
||||
/jps-plugin/testData/kannotator
|
||||
/js/js.translator/testData/out/
|
||||
/js/js.translator/testData/out-min/
|
||||
/js/js.translator/testData/out-pir/
|
||||
.gradle/
|
||||
build/
|
||||
!**/src/**/build
|
||||
!**/test/**/build
|
||||
*.iml
|
||||
!**/testData/**/*.iml
|
||||
.idea/libraries/Gradle*.xml
|
||||
.idea/libraries/Maven*.xml
|
||||
.idea/artifacts/PILL_*.xml
|
||||
.idea/artifacts/KotlinPlugin.xml
|
||||
.idea/modules
|
||||
.idea/runConfigurations/JPS_*.xml
|
||||
.idea/runConfigurations/PILL_*.xml
|
||||
.idea/libraries
|
||||
.idea/modules.xml
|
||||
.idea/gradle.xml
|
||||
.idea/compiler.xml
|
||||
.idea/inspectionProfiles/profiles_settings.xml
|
||||
.idea/.name
|
||||
.idea/artifacts/dist_auto_*
|
||||
.idea/artifacts/dist.xml
|
||||
.idea/artifacts/ideaPlugin.xml
|
||||
.idea/artifacts/kotlinc.xml
|
||||
.idea/artifacts/kotlin_compiler_jar.xml
|
||||
.idea/artifacts/kotlin_plugin_jar.xml
|
||||
.idea/artifacts/kotlin_jps_plugin_jar.xml
|
||||
.idea/artifacts/kotlin_daemon_client_jar.xml
|
||||
.idea/artifacts/kotlin_imports_dumper_compiler_plugin_jar.xml
|
||||
.idea/artifacts/kotlin_main_kts_jar.xml
|
||||
.idea/artifacts/kotlin_compiler_client_embeddable_jar.xml
|
||||
.idea/artifacts/kotlin_reflect_jar.xml
|
||||
.idea/jarRepositories.xml
|
||||
kotlin-ultimate/
|
||||
node_modules/
|
||||
.rpt2_cache/
|
||||
libraries/tools/kotlin-test-js-runner/lib/
|
||||
libraries/tools/kotlin-source-map-loader/lib/
|
||||
local.properties
|
||||
|
||||
datasets/*
|
||||
!datasets/.gitkeep
|
||||
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
10
.idea/codeStyles/Project.xml
generated
Normal file
10
.idea/codeStyles/Project.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
||||
14
.idea/misc.xml
generated
Normal file
14
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ElmWorkspace">
|
||||
<elmProjects />
|
||||
<settings binDirPath="" />
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<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">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<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">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
1
LICENSE
Normal file
1
LICENSE
Normal file
@@ -0,0 +1 @@
|
||||
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
|
||||
22
README.md
Normal file
22
README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Exposed Imdb
|
||||
|
||||
A simple project to learn more about [exposed](https://github.com/JetBrains/Exposed), using the [imdb datasets](https://datasets.imdbws.com/).
|
||||
|
||||
Please note that if you use this project, you have to comply with the [Imbd license](https://www.imdb.com/interfaces/).
|
||||
|
||||
## LICENSE
|
||||
|
||||
In short, [CC BY-NC-SA 4.0](https://tldrlegal.com/license/creative-commons-attribution-noncommercial-sharealike-4.0-international-(cc-by-nc-sa-4.0)).
|
||||
|
||||
See [LICENSE](/LICENSE)
|
||||
|
||||
## Learnings
|
||||
|
||||
|
||||
* Use `;DB_CLOSE_DELAY=-1` if you want to persist the in-memory database information over more than a single transaction.
|
||||
* `Database.connect("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", driver = "org.h2.Driver", user = "root", password = "")`
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
* [Julien Lengrand-Lambert](https://github.com/jlengrand/)
|
||||
71
README_imdb
Normal file
71
README_imdb
Normal file
@@ -0,0 +1,71 @@
|
||||
IMDb Datasets
|
||||
|
||||
Subsets of IMDb data are available for access to customers for personal and non-commercial use. You can hold local copies of this data, and it is subject to our terms and conditions. Please refer to the Non-Commercial Licensing and copyright/license and verify compliance.
|
||||
|
||||
Data Location
|
||||
|
||||
The dataset files can be accessed and downloaded from https://datasets.imdbws.com/. The data is refreshed daily.
|
||||
|
||||
IMDb Dataset Details
|
||||
|
||||
Each dataset is contained in a gzipped, tab-separated-values (TSV) formatted file in the UTF-8 character set. The first line in each file contains headers that describe what is in each column. A ‘\N’ is used to denote that a particular field is missing or null for that title/name. The available datasets are as follows:
|
||||
|
||||
title.akas.tsv.gz - Contains the following information for titles:
|
||||
|
||||
titleId (string) - a tconst, an alphanumeric unique identifier of the title
|
||||
ordering (integer) – a number to uniquely identify rows for a given titleId
|
||||
title (string) – the localized title
|
||||
region (string) - the region for this version of the title
|
||||
language (string) - the language of the title
|
||||
types (array) - Enumerated set of attributes for this alternative title. One or more of the following: "alternative", "dvd", "festival", "tv", "video", "working", "original", "imdbDisplay". New values may be added in the future without warning
|
||||
attributes (array) - Additional terms to describe this alternative title, not enumerated
|
||||
isOriginalTitle (boolean) – 0: not original title; 1: original title
|
||||
|
||||
title.basics.tsv.gz - Contains the following information for titles:
|
||||
|
||||
tconst (string) - alphanumeric unique identifier of the title
|
||||
titleType (string) – the type/format of the title (e.g. movie, short, tvseries, tvepisode, video, etc)
|
||||
primaryTitle (string) – the more popular title / the title used by the filmmakers on promotional materials at the point of release
|
||||
originalTitle (string) - original title, in the original language
|
||||
isAdult (boolean) - 0: non-adult title; 1: adult title
|
||||
startYear (YYYY) – represents the release year of a title. In the case of TV Series, it is the series start year
|
||||
endYear (YYYY) – TV Series end year. ‘\N’ for all other title types
|
||||
runtimeMinutes – primary runtime of the title, in minutes
|
||||
genres (string array) – includes up to three genres associated with the title
|
||||
|
||||
title.crew.tsv.gz – Contains the director and writer information for all the titles in IMDb. Fields include:
|
||||
|
||||
tconst (string) - alphanumeric unique identifier of the title
|
||||
directors (array of nconsts) - director(s) of the given title
|
||||
writers (array of nconsts) – writer(s) of the given title
|
||||
|
||||
title.episode.tsv.gz – Contains the tv episode information. Fields include:
|
||||
|
||||
tconst (string) - alphanumeric identifier of episode
|
||||
parentTconst (string) - alphanumeric identifier of the parent TV Series
|
||||
seasonNumber (integer) – season number the episode belongs to
|
||||
episodeNumber (integer) – episode number of the tconst in the TV series
|
||||
|
||||
title.principals.tsv.gz – Contains the principal cast/crew for titles
|
||||
|
||||
tconst (string) - alphanumeric unique identifier of the title
|
||||
ordering (integer) – a number to uniquely identify rows for a given titleId
|
||||
nconst (string) - alphanumeric unique identifier of the name/person
|
||||
category (string) - the category of job that person was in
|
||||
job (string) - the specific job title if applicable, else '\N'
|
||||
characters (string) - the name of the character played if applicable, else '\N'
|
||||
|
||||
title.ratings.tsv.gz – Contains the IMDb rating and votes information for titles
|
||||
|
||||
tconst (string) - alphanumeric unique identifier of the title
|
||||
averageRating – weighted average of all the individual user ratings
|
||||
numVotes - number of votes the title has received
|
||||
|
||||
name.basics.tsv.gz – Contains the following information for names:
|
||||
|
||||
nconst (string) - alphanumeric unique identifier of the name/person
|
||||
primaryName (string)– name by which the person is most often credited
|
||||
birthYear – in YYYY format
|
||||
deathYear – in YYYY format if applicable, else '\N'
|
||||
primaryProfession (array of strings)– the top-3 professions of the person
|
||||
knownForTitles (array of tconsts) – titles the person is known for
|
||||
28
build.gradle
Normal file
28
build.gradle
Normal file
@@ -0,0 +1,28 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.3.70-eap-42'
|
||||
}
|
||||
|
||||
group 'org.example'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
|
||||
// maven { url 'https://dl.bintray.com/kotlin/exposed' }
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
compile "org.jetbrains.exposed:exposed-core:0.21.1"
|
||||
compile "org.jetbrains.exposed:exposed-dao:0.21.1"
|
||||
compile "org.jetbrains.exposed:exposed-jdbc:0.21.1"
|
||||
compile "com.h2database:h2:1.4.200"
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
compileTestKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
0
datasets/.gitkeep
Normal file
0
datasets/.gitkeep
Normal file
11
docker-compose.yml
Normal file
11
docker-compose.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
|
||||
mysql-development:
|
||||
image: mysql:8.0.19
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: aRootPassword
|
||||
MYSQL_DATABASE: imdb
|
||||
ports:
|
||||
- "3308:3306"
|
||||
1
gradle.properties
Normal file
1
gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
kotlin.code.style=official
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#Wed Feb 26 17:28:32 CET 2020
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
183
gradlew
vendored
Executable file
183
gradlew
vendored
Executable file
@@ -0,0 +1,183 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
100
gradlew.bat
vendored
Normal file
100
gradlew.bat
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
11
settings.gradle
Normal file
11
settings.gradle
Normal file
@@ -0,0 +1,11 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
|
||||
|
||||
mavenCentral()
|
||||
|
||||
maven { url 'https://plugins.gradle.org/m2/' }
|
||||
}
|
||||
}
|
||||
rootProject.name = 'exposed-imdb'
|
||||
|
||||
33
src/main/kotlin/dsl/Titles.kt
Normal file
33
src/main/kotlin/dsl/Titles.kt
Normal file
@@ -0,0 +1,33 @@
|
||||
package dsl
|
||||
|
||||
import org.jetbrains.exposed.dao.IntEntity
|
||||
import org.jetbrains.exposed.dao.IntEntityClass
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
import org.jetbrains.exposed.sql.Column
|
||||
|
||||
object Titles : IntIdTable(){
|
||||
val tconst : Column<String> = varchar("tconst", 10).uniqueIndex()
|
||||
val titleType : Column<String> = varchar("titleType", 50) // Own Table?
|
||||
val primaryTitle : Column<String> = varchar("primaryTitle", 50)
|
||||
val originalTitle : Column<String> = varchar("originalTitle", 50)
|
||||
val isAdult : Column<Boolean> = bool("isAdult")
|
||||
val startYear : Column<Int> = integer("startYear")
|
||||
val endYear : Column<Int?> = integer("endYear").nullable()
|
||||
val runtimeMinutes : Column<Long> = long("runtimeMinutes")
|
||||
val genres : Column<String> = varchar("genres", 50) // Own Table?
|
||||
}
|
||||
|
||||
class Title(id: EntityID<Int>) : IntEntity(id) {
|
||||
companion object : IntEntityClass<Title>(Titles)
|
||||
|
||||
var tconst by Titles.tconst
|
||||
var titleType by Titles.titleType
|
||||
var primaryTitle by Titles.primaryTitle
|
||||
var originalTitle by Titles.originalTitle
|
||||
var isAdult by Titles.isAdult
|
||||
var startYear by Titles.startYear
|
||||
var endYear by Titles.endYear
|
||||
var runtimeMinutes by Titles.runtimeMinutes
|
||||
var genres by Titles.genres
|
||||
}
|
||||
9
src/main/kotlin/loader/LoadImdb.kt
Normal file
9
src/main/kotlin/loader/LoadImdb.kt
Normal file
@@ -0,0 +1,9 @@
|
||||
package loader
|
||||
|
||||
import org.jetbrains.exposed.sql.Database
|
||||
|
||||
fun main(){
|
||||
|
||||
var db = Database.connect("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", driver = "org.h2.Driver", user = "root", password = "")
|
||||
println("Running loader")
|
||||
}
|
||||
66
src/main/kotlin/loader/Titlebasics.kt
Normal file
66
src/main/kotlin/loader/Titlebasics.kt
Normal file
@@ -0,0 +1,66 @@
|
||||
package loader
|
||||
|
||||
import dsl.Titles
|
||||
import org.jetbrains.exposed.dao.IntEntity
|
||||
import org.jetbrains.exposed.dao.IntEntityClass
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import java.io.File
|
||||
|
||||
val NO_DATA = "\\N";
|
||||
|
||||
class Titlebasics(private val db: Database) {
|
||||
|
||||
fun createTable(){
|
||||
transaction(db) { SchemaUtils.create (Titles) }
|
||||
}
|
||||
|
||||
fun loadData(){
|
||||
val nameBasicsReader = File("./datasets/title.basics.tsv").bufferedReader()
|
||||
nameBasicsReader.readLine()
|
||||
|
||||
println("Title.Basics loaded")
|
||||
|
||||
for (ptr in 1..10){
|
||||
val line = nameBasicsReader.readLine()
|
||||
val items = line.split("\t")
|
||||
println(items)
|
||||
|
||||
transaction {
|
||||
Titles.insert {
|
||||
it[tconst] = items[0]
|
||||
it[titleType] = items[1]
|
||||
it[primaryTitle] = items[2]
|
||||
it[originalTitle] = items[3]
|
||||
it[isAdult] = items[4].toBoolean()
|
||||
it[startYear] = items[5].toInt()
|
||||
it[endYear] = if (items[6] != NO_DATA) items[6].toInt() else null
|
||||
it[runtimeMinutes] = items[7].toLong()
|
||||
it[genres] = items[8]
|
||||
}
|
||||
}
|
||||
|
||||
// transaction {
|
||||
// loader.Title.new {
|
||||
// tconst = items[0]
|
||||
// titleType = items[1]
|
||||
// primaryTitle = items[2]
|
||||
// originalTitle = items[3]
|
||||
// isAdult = items[4].toBoolean()
|
||||
// startYear = items[5].toInt()
|
||||
// endYear = if (items[6] != dsl.getNO_DATA) items[6].toInt() else null
|
||||
// runtimeMinutes = items[7].toLong()
|
||||
// genres = items[8]
|
||||
// }
|
||||
// }
|
||||
|
||||
println("--------")
|
||||
}
|
||||
}
|
||||
|
||||
fun showAll() {
|
||||
transaction(db) { Titles.selectAll().map { println(it) } }
|
||||
}
|
||||
}
|
||||
120
src/main/kotlin/test.kt
Normal file
120
src/main/kotlin/test.kt
Normal file
@@ -0,0 +1,120 @@
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
||||
object Users : Table() {
|
||||
val id = varchar("id", 10) // Column<String>
|
||||
val name = varchar("name", length = 50) // Column<String>
|
||||
val cityId = (integer("city_id") references Cities.id).nullable() // Column<Int?>
|
||||
|
||||
override val primaryKey = PrimaryKey(id, name = "PK_User_ID") // name is optional here
|
||||
}
|
||||
|
||||
object Cities : Table() {
|
||||
val id = integer("id").autoIncrement() // Column<Int>
|
||||
val name = varchar("name", 50) // Column<String>
|
||||
|
||||
override val primaryKey = PrimaryKey(id, name = "PK_Cities_ID")
|
||||
}
|
||||
|
||||
fun main() {
|
||||
Database.connect("jdbc:h2:mem:test", driver = "org.h2.Driver", user = "root", password = "")
|
||||
|
||||
transaction {
|
||||
addLogger(StdOutSqlLogger)
|
||||
|
||||
SchemaUtils.create (Cities, Users)
|
||||
|
||||
val saintPetersburgId = Cities.insert {
|
||||
it[name] = "St. Petersburg"
|
||||
} get Cities.id
|
||||
|
||||
val munichId = Cities.insert {
|
||||
it[name] = "Munich"
|
||||
} get Cities.id
|
||||
|
||||
val pragueId = Cities.insert {
|
||||
it.update(name, stringLiteral(" Prague ").trim().substring(1, 2))
|
||||
}[Cities.id]
|
||||
|
||||
val pragueName = Cities.select { Cities.id eq pragueId }.single()[Cities.name]
|
||||
|
||||
Users.insert {
|
||||
it[id] = "andrey"
|
||||
it[name] = "Andrey"
|
||||
it[Users.cityId] = saintPetersburgId
|
||||
}
|
||||
|
||||
Users.insert {
|
||||
it[id] = "sergey"
|
||||
it[name] = "Sergey"
|
||||
it[Users.cityId] = munichId
|
||||
}
|
||||
|
||||
Users.insert {
|
||||
it[id] = "eugene"
|
||||
it[name] = "Eugene"
|
||||
it[Users.cityId] = munichId
|
||||
}
|
||||
|
||||
Users.insert {
|
||||
it[id] = "alex"
|
||||
it[name] = "Alex"
|
||||
it[Users.cityId] = null
|
||||
}
|
||||
|
||||
Users.insert {
|
||||
it[id] = "smth"
|
||||
it[name] = "Something"
|
||||
it[Users.cityId] = null
|
||||
}
|
||||
|
||||
Users.update({ Users.id eq "alex"}) {
|
||||
it[name] = "Alexey"
|
||||
}
|
||||
|
||||
Users.deleteWhere{ Users.name like "%thing"}
|
||||
|
||||
println("All cities:")
|
||||
|
||||
for (city in Cities.selectAll()) {
|
||||
println("${city[Cities.id]}: ${city[Cities.name]}")
|
||||
}
|
||||
|
||||
println("Manual join:")
|
||||
(Users innerJoin Cities).slice(Users.name, Cities.name).
|
||||
select {(Users.id.eq("andrey") or Users.name.eq("Sergey")) and
|
||||
Users.id.eq("sergey") and Users.cityId.eq(Cities.id)}.forEach {
|
||||
println("${it[Users.name]} lives in ${it[Cities.name]}")
|
||||
}
|
||||
|
||||
println("Join with foreign key:")
|
||||
|
||||
|
||||
(Users innerJoin Cities).slice(Users.name, Users.cityId, Cities.name).
|
||||
select { Cities.name.eq("St. Petersburg") or Users.cityId.isNull()}.forEach {
|
||||
if (it[Users.cityId] != null) {
|
||||
println("${it[Users.name]} lives in ${it[Cities.name]}")
|
||||
}
|
||||
else {
|
||||
println("${it[Users.name]} lives nowhere")
|
||||
}
|
||||
}
|
||||
|
||||
println("Functions and group by:")
|
||||
|
||||
((Cities innerJoin Users).slice(Cities.name, Users.id.count()).selectAll().groupBy(Cities.name)).forEach {
|
||||
val cityName = it[Cities.name]
|
||||
val userCount = it[Users.id.count()]
|
||||
|
||||
if (userCount > 0) {
|
||||
println("$userCount user(s) live(s) in $cityName")
|
||||
} else {
|
||||
println("Nobody lives in $cityName")
|
||||
}
|
||||
}
|
||||
|
||||
SchemaUtils.drop (Users, Cities)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user