diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..fe39f35 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# top-most EditorConfig file +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + + + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 0204465..3cbf699 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,20 @@ ### Changelog ### +#### v0.6.0 - 24.05.2019 + + * Fixed: + * (Major) Issue with some changes not being persisted in the database (#21). + * Changed: + * Default backup format to JSON + * Removed: + * Support for `Storable` backup + * (Internal) Support for build-in in-memory cache `SmartLayer`. + #### v0.5.4 - 04.05.2019 +This version supports backups in format: `Storable` and `JSON`. +Use it to migrate your data from `0.5.x` to `0.6.x`. + * Added: * Support for Mojolicious `>7.55` by changing route placeholders from `()` to `<>` (#38) * Official Docker image with Dockerhub build (#39) @@ -12,17 +25,19 @@ #### v0.5.3 - 07.2018 -This version is probably the only one that supports both types of backups: Storable and JSON. -Use it to migrate your data from 0.5.x to 0.6.x. - -* Deprecation: Storable backups are marked as deprecated now. Use JSON backup instead. -* Feature: Add support for independent JSON backup and restore +This version supports backups in format: `Storable` and `JSON`. +Use it to migrate your data from `0.5.x` to `0.6.x`. -* Fix: Non-ANSI usernames are now properly encoded with UTF-8 on the Publications page -* Fix: External link to DateTime formats uses now permalink to CPAN -* Fix: Show recenlty added/modified works correctly for less than 10 objects in system -* Fix: Harden tests for less than 10 objects in system -* Internal: Add SerializableBase to BibSpace Entities +* Added: + * Support for independent JSON backup and restore + * (Internal) Add SerializableBase to BibSpace Entities +* Fixed: + * Non-ANSI usernames are now properly encoded with UTF-8 on the Publications page + * External link to DateTime formats uses now permalink to CPAN + * Show recently added/modified works correctly for less than 10 objects in system + * Tests for less than 10 objects in system +* Deprecated: + * Storable backups. Use JSON backup instead. #### v0.5.2 - 08.2017 #### @@ -71,7 +86,7 @@ Use it to migrate your data from 0.5.x to 0.6.x. #### v0.4.5 - 08.10.2016 #### * Code refactoring - towards OO design and getting rid of core.pm - edit_author, authors, tags -* Various bugfixes, e.g., showing publications with no tag for autor no longer returns 404. +* Various bugfixes, e.g., showing publications with no tag for author no longer returns 404. #### v0.4.4 - 18.09.2016 #### @@ -85,7 +100,7 @@ Use it to migrate your data from 0.5.x to 0.6.x. #### v0.4.1 - 31.05.2016 #### -* Add function to change download urls from direct file paths to file serving function +* Add function to change download URLs from direct file paths to file serving function * Add function to remove attachments * Fixing multiple minor bugs diff --git a/Dockerfile b/Dockerfile index 20c04d4..e8fef94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,7 @@ RUN apk update \ && rm -rf /var/cache/apk/* RUN echo "Europe/Berlin" > /config/etc/timezone -LABEL version="0.5.4" +LABEL version="0.6.0" EXPOSE 8083 HEALTHCHECK --interval=30s --timeout=15s CMD curl --fail http://localhost:8083/system_status || exit 1 diff --git a/cpanfile b/cpanfile index 86bb5ac..86cc1cc 100644 --- a/cpanfile +++ b/cpanfile @@ -20,14 +20,16 @@ requires 'Module::CPANfile' , '>= 0.0'; requires 'Mojolicious' , '>= 8.0'; requires 'Mojolicious::Plugin::RenderFile' , '>= 0.0'; requires 'Moose' , '>= 2.0604'; +requires 'MooseX::Role::Parameterized' , '>= 1.00'; # Required for Moose 2.2011 +requires 'MooseX::Types' , '>= 0.19'; # Required for Moose 2.2011 requires 'MooseX::ClassAttribute' , '>= 0.0'; +requires 'MooseX::Privacy' , '>=0.0'; requires 'MooseX::Singleton' , '>= 0.0'; requires 'MooseX::Storage' , '>= 0.0'; requires 'MooseX::StrictConstructor' , '>= 0.0'; requires 'Path::Tiny' , '>= 0.0'; requires 'Scalar::Util' , '>= 0.0'; requires 'Session::Token' , '>= 0.0'; -requires 'Storable' , '>= 0.0'; requires 'TeX::Encode' , '>= 0.0'; requires 'Text::ASCIIMathML' , '>= 0.0'; requires 'Text::BibTeX' , '== 0.88'; # 0.86 and 0.87 are broken - use 0.85 or 0.88 diff --git a/fixture/bibspace_fixture.dat b/fixture/bibspace_fixture.dat deleted file mode 100644 index ee65549..0000000 Binary files a/fixture/bibspace_fixture.dat and /dev/null differ diff --git a/fixture/bibspace_fixture.json b/fixture/bibspace_fixture.json new file mode 100644 index 0000000..7b6021e --- /dev/null +++ b/fixture/bibspace_fixture.json @@ -0,0 +1,1288 @@ +{ + "data" : { + "User" : [ + { + "old_mysql_id" : 2, + "pass2" : "gabQ/Wh1O4X/rxFyw1MN9.", + "real_name" : "James Bond", + "rank" : 1, + "tennant_id" : 0, + "login" : "j.bond007", + "email" : "test@example.com", + "pass" : "$2a$08$gabQ/Wh1O4X/rxFyw1MN9.JAW7fpGkgnqL4n1MBn0Fke3trEwIFEK", + "master_id" : 0, + "registration_time" : "2017-02-08T18:20:18", + "id" : 2, + "pass3" : null, + "last_login" : "2017-02-08T18:20:27" + }, + { + "real_name" : "Admin", + "old_mysql_id" : 1, + "pass2" : "RjsJK5.hcmqMphocOzVsUO", + "login" : "pub_admin", + "tennant_id" : 0, + "rank" : 2, + "id" : 1, + "registration_time" : "2017-02-08T14:21:41", + "master_id" : 0, + "email" : "pub_admin@example.com", + "pass" : "$2a$08$RjsJK5.hcmqMphocOzVsUOAbdhZBdl9gNlGDzl69AyApzIQO2P7TK", + "last_login" : "2017-12-10T19:32:04", + "pass3" : null + } + ], + "Tag" : [ + { + "name" : "Networking", + "permalink" : "N", + "id" : 4, + "old_mysql_id" : 4, + "type" : 1 + }, + { + "type" : 1, + "id" : 6, + "old_mysql_id" : 6, + "permalink" : null, + "name" : "Virtualization" + }, + { + "name" : "Simulation", + "permalink" : null, + "old_mysql_id" : 8, + "id" : 8, + "type" : 1 + }, + { + "id" : 9, + "old_mysql_id" : 9, + "type" : 1, + "name" : "Meta-models", + "permalink" : null + }, + { + "id" : 10, + "old_mysql_id" : 10, + "type" : 1, + "name" : "Performance", + "permalink" : null + }, + { + "type" : 1, + "old_mysql_id" : 11, + "id" : 11, + "permalink" : null, + "name" : "Prediction" + }, + { + "name" : "QPME_Bibliography", + "permalink" : null, + "old_mysql_id" : 15, + "id" : 15, + "type" : 3 + }, + { + "permalink" : null, + "name" : "Cloud", + "type" : 1, + "id" : 19, + "old_mysql_id" : 19 + }, + { + "type" : 1, + "old_mysql_id" : 20, + "id" : 20, + "permalink" : null, + "name" : "QPN" + }, + { + "name" : "BUNGEE", + "permalink" : null, + "old_mysql_id" : 21, + "id" : 21, + "type" : 1 + }, + { + "name" : "DML", + "permalink" : null, + "id" : 22, + "old_mysql_id" : 22, + "type" : 1 + }, + { + "name" : "DQL", + "permalink" : null, + "id" : 23, + "old_mysql_id" : 23, + "type" : 1 + }, + { + "old_mysql_id" : 28, + "id" : 28, + "type" : 1, + "name" : "SDN", + "permalink" : null + }, + { + "id" : 30, + "old_mysql_id" : 30, + "type" : 1, + "name" : "SPEC", + "permalink" : null + }, + { + "old_mysql_id" : 31, + "id" : 31, + "type" : 1, + "name" : "Award", + "permalink" : null + }, + { + "id" : 33, + "old_mysql_id" : 33, + "type" : 1, + "name" : "Elasticity", + "permalink" : null + }, + { + "old_mysql_id" : 36, + "id" : 36, + "type" : 1, + "name" : "Isolation", + "permalink" : null + }, + { + "old_mysql_id" : 41, + "id" : 41, + "type" : 1, + "name" : "Power", + "permalink" : null + }, + { + "id" : 43, + "old_mysql_id" : 43, + "type" : 1, + "name" : "Reliability", + "permalink" : null + }, + { + "name" : "Security", + "permalink" : null, + "old_mysql_id" : 44, + "id" : 44, + "type" : 1 + }, + { + "permalink" : null, + "name" : "Tool", + "type" : 1, + "old_mysql_id" : 49, + "id" : 49 + }, + { + "type" : 1, + "id" : 51, + "old_mysql_id" : 51, + "permalink" : null, + "name" : "QPME" + }, + { + "permalink" : null, + "name" : "Optimization", + "type" : 1, + "id" : 52, + "old_mysql_id" : 52 + }, + { + "old_mysql_id" : 53, + "id" : 53, + "type" : 2, + "name" : "Design_of_enterprise_system_architectures", + "permalink" : "A1" + }, + { + "name" : "Formal_architecture_modeling", + "permalink" : "A2", + "id" : 54, + "old_mysql_id" : 54, + "type" : 2 + }, + { + "type" : 2, + "id" : 55, + "old_mysql_id" : 55, + "permalink" : "A3", + "name" : "Analytical_and_simulation-based_analysis" + }, + { + "id" : 56, + "old_mysql_id" : 56, + "type" : 2, + "name" : "Model_extraction,_calibration_and_maintenance", + "permalink" : "A4" + }, + { + "id" : 57, + "old_mysql_id" : 57, + "type" : 2, + "name" : "Metrics_and_benchmarking_methodologies", + "permalink" : "B1" + }, + { + "type" : 2, + "id" : 58, + "old_mysql_id" : 58, + "permalink" : "B2", + "name" : "Instrumentation_profiling_and_workload_characterization" + }, + { + "permalink" : "B3", + "name" : "Statistical_estimation_and_machine_learning", + "type" : 2, + "id" : 59, + "old_mysql_id" : 59 + }, + { + "name" : "Online_monitoring_and_forecasting", + "permalink" : "B4", + "old_mysql_id" : 60, + "id" : 60, + "type" : 2 + }, + { + "permalink" : "C1", + "name" : "Data_center_resource_management", + "type" : 2, + "old_mysql_id" : 61, + "id" : 61 + }, + { + "type" : 2, + "id" : 62, + "old_mysql_id" : 62, + "permalink" : "C2", + "name" : "Application_quality_of_service_management" + }, + { + "type" : 2, + "id" : 63, + "old_mysql_id" : 63, + "permalink" : "C3", + "name" : "Power-energy_efficient_computing" + }, + { + "type" : 2, + "old_mysql_id" : 64, + "id" : 64, + "permalink" : "C4", + "name" : "Multi-criteria_optimization" + }, + { + "type" : 1, + "id" : 65, + "old_mysql_id" : 65, + "permalink" : null, + "name" : "Self-adaptive-systems" + }, + { + "permalink" : null, + "name" : "Self-aware-computing", + "type" : 1, + "old_mysql_id" : 66, + "id" : 66 + }, + { + "permalink" : "DNI", + "name" : "DNI", + "type" : 3, + "old_mysql_id" : 67, + "id" : 67 + }, + { + "name" : "HInjector", + "permalink" : null, + "old_mysql_id" : 68, + "id" : 68, + "type" : 1 + }, + { + "id" : 69, + "old_mysql_id" : 69, + "type" : 3, + "name" : "Supervised_by_Nikolas_Herbst", + "permalink" : null + }, + { + "old_mysql_id" : 70, + "id" : 70, + "type" : 3, + "name" : "Thesis_supervised_by_SE_member", + "permalink" : null + }, + { + "name" : "Thesis_supervised_by_Simon_Spinner", + "permalink" : null, + "old_mysql_id" : 71, + "id" : 71, + "type" : 3 + }, + { + "name" : "Talks", + "permalink" : "talks", + "old_mysql_id" : 72, + "id" : 72, + "type" : 3 + }, + { + "id" : 73, + "old_mysql_id" : 73, + "type" : 3, + "name" : "Thesis_supervised_by_Nikolaus_Huber", + "permalink" : null + }, + { + "permalink" : null, + "name" : "Thesis_supervised_by_Fabian_Brosig", + "type" : 3, + "id" : 74, + "old_mysql_id" : 74 + }, + { + "permalink" : null, + "name" : "Thesis_supervised_by_Juergen_Walter", + "type" : 3, + "old_mysql_id" : 75, + "id" : 75 + }, + { + "permalink" : null, + "name" : "Thesis_supervised_by_Joakim_vonKistowski", + "type" : 3, + "id" : 76, + "old_mysql_id" : 76 + }, + { + "permalink" : null, + "name" : "Supervised_PhD_Thesis", + "type" : 3, + "old_mysql_id" : 77, + "id" : 77 + }, + { + "id" : 78, + "old_mysql_id" : 78, + "type" : 3, + "name" : "Interpolation", + "permalink" : null + }, + { + "type" : 3, + "id" : 81, + "old_mysql_id" : 81, + "permalink" : null, + "name" : "Thesis_supervised_by_Aleksandar_Milenkoski" + }, + { + "name" : "Media-coverage", + "permalink" : null, + "old_mysql_id" : 230, + "id" : 230, + "type" : 3 + }, + { + "type" : 3, + "id" : 231, + "old_mysql_id" : 231, + "permalink" : null, + "name" : "Thesis_supervised_by_Piotr_Rygielski" + }, + { + "permalink" : null, + "name" : "Thesis_supervised_by_Lukas_Ifflaender", + "type" : 3, + "id" : 240, + "old_mysql_id" : 240 + } + ], + "Labeling" : [ + { + "tag_id" : 4, + "entry_id" : 675 + }, + { + "entry_id" : 202, + "tag_id" : 6 + }, + { + "tag_id" : 6, + "entry_id" : 435 + }, + { + "entry_id" : 1105, + "tag_id" : 6 + }, + { + "tag_id" : 8, + "entry_id" : 1077 + }, + { + "entry_id" : 435, + "tag_id" : 10 + }, + { + "entry_id" : 1077, + "tag_id" : 10 + }, + { + "entry_id" : 1099, + "tag_id" : 10 + }, + { + "tag_id" : 11, + "entry_id" : 1077 + }, + { + "tag_id" : 11, + "entry_id" : 1111 + }, + { + "entry_id" : 202, + "tag_id" : 19 + }, + { + "entry_id" : 435, + "tag_id" : 19 + }, + { + "tag_id" : 19, + "entry_id" : 1105 + }, + { + "tag_id" : 30, + "entry_id" : 588 + }, + { + "entry_id" : 781, + "tag_id" : 30 + }, + { + "tag_id" : 33, + "entry_id" : 202 + }, + { + "entry_id" : 435, + "tag_id" : 43 + }, + { + "entry_id" : 435, + "tag_id" : 44 + }, + { + "tag_id" : 49, + "entry_id" : 435 + }, + { + "entry_id" : 1111, + "tag_id" : 52 + }, + { + "tag_id" : 52, + "entry_id" : 1159 + }, + { + "entry_id" : 1105, + "tag_id" : 53 + }, + { + "tag_id" : 54, + "entry_id" : 1077 + }, + { + "entry_id" : 1077, + "tag_id" : 55 + }, + { + "entry_id" : 202, + "tag_id" : 57 + }, + { + "tag_id" : 57, + "entry_id" : 435 + }, + { + "tag_id" : 58, + "entry_id" : 435 + }, + { + "entry_id" : 1159, + "tag_id" : 58 + }, + { + "entry_id" : 1159, + "tag_id" : 59 + }, + { + "tag_id" : 60, + "entry_id" : 1111 + }, + { + "entry_id" : 1099, + "tag_id" : 61 + }, + { + "entry_id" : 1111, + "tag_id" : 61 + }, + { + "tag_id" : 61, + "entry_id" : 1159 + }, + { + "entry_id" : 1159, + "tag_id" : 64 + }, + { + "entry_id" : 1159, + "tag_id" : 65 + }, + { + "tag_id" : 66, + "entry_id" : 1111 + }, + { + "entry_id" : 435, + "tag_id" : 68 + }, + { + "tag_id" : 69, + "entry_id" : 1159 + }, + { + "tag_id" : 70, + "entry_id" : 1159 + }, + { + "tag_id" : 71, + "entry_id" : 1159 + }, + { + "tag_id" : 77, + "entry_id" : 1166 + } + ], + "Author" : [ + { + "uid" : "RygielskiPiotr", + "name" : "RygielskiPiotr", + "old_mysql_id" : 527, + "display" : 1, + "id" : 527, + "master_id" : 527 + }, + { + "master_id" : 591, + "old_mysql_id" : 591, + "id" : 591, + "display" : 1, + "uid" : "SPEC", + "name" : "SPEC" + }, + { + "name" : "HerbstNikolas", + "uid" : "HerbstNikolas", + "display" : 1, + "id" : 1121, + "old_mysql_id" : 1121, + "master_id" : 1121 + }, + { + "name" : "MilenkoskiAleksandar", + "uid" : "MilenkoskiAleksandar", + "id" : 1389, + "display" : 1, + "old_mysql_id" : 1389, + "master_id" : 1389 + }, + { + "uid" : "GrohmannJohannes", + "name" : "GrohmannJohannes", + "master_id" : 1486, + "old_mysql_id" : 1486, + "display" : 1, + "id" : 1486 + }, + { + "name" : "ExampleJohny", + "uid" : "ExampleJohny", + "display" : 1, + "id" : 1487, + "old_mysql_id" : 1487, + "master_id" : 1487 + }, + { + "master_id" : 1121, + "id" : 1488, + "display" : 0, + "old_mysql_id" : 1488, + "name" : "HerbstNikolasRoman", + "uid" : "HerbstNikolasRoman" + }, + { + "old_mysql_id" : 1489, + "id" : 1489, + "display" : 0, + "master_id" : 1489, + "uid" : "InvisibleHenry", + "name" : "InvisibleHenry" + }, + { + "master_id" : 1490, + "display" : 0, + "id" : 1490, + "old_mysql_id" : 1490, + "name" : "TestMaster", + "uid" : "TestMaster" + }, + { + "display" : 0, + "id" : 1491, + "old_mysql_id" : 1491, + "master_id" : 1491, + "name" : "TestMinion", + "uid" : "TestMinion" + } + ], + "Type" : [ + { + "id" : null, + "onLanding" : 0, + "old_mysql_id" : null, + "our_type" : "incollection", + "description" : null, + "bibtexTypes" : [ + "incollection" + ] + }, + { + "onLanding" : 1, + "id" : null, + "old_mysql_id" : null, + "our_type" : "techreport", + "description" : null, + "bibtexTypes" : [ + "techreport" + ] + }, + { + "bibtexTypes" : [ + "mastersthesis" + ], + "description" : null, + "id" : null, + "onLanding" : 0, + "old_mysql_id" : null, + "our_type" : "mastersthesis" + }, + { + "bibtexTypes" : [ + "inbook" + ], + "description" : null, + "onLanding" : 0, + "id" : null, + "old_mysql_id" : null, + "our_type" : "inbook" + }, + { + "onLanding" : 1, + "id" : null, + "old_mysql_id" : null, + "our_type" : "inproceedings", + "description" : null, + "bibtexTypes" : [ + "incollection", + "inproceedings" + ] + }, + { + "old_mysql_id" : null, + "our_type" : "unpublished", + "id" : null, + "onLanding" : 0, + "bibtexTypes" : [ + "unpublished" + ], + "description" : null + }, + { + "id" : null, + "onLanding" : 1, + "our_type" : "manual", + "old_mysql_id" : null, + "bibtexTypes" : [ + "manual" + ], + "description" : null + }, + { + "old_mysql_id" : null, + "our_type" : "theses", + "onLanding" : 1, + "id" : null, + "bibtexTypes" : [ + "mastersthesis", + "phdthesis" + ], + "description" : null + }, + { + "bibtexTypes" : [ + "incollection" + ], + "description" : null, + "old_mysql_id" : null, + "our_type" : "bibtex-incollection", + "id" : null, + "onLanding" : 0 + }, + { + "description" : null, + "bibtexTypes" : [ + "book", + "inbook", + "proceedings" + ], + "our_type" : "book", + "old_mysql_id" : null, + "onLanding" : 0, + "id" : null + }, + { + "old_mysql_id" : null, + "our_type" : "article", + "onLanding" : 1, + "id" : null, + "bibtexTypes" : [ + "article" + ], + "description" : null + }, + { + "description" : null, + "bibtexTypes" : [ + "misc" + ], + "onLanding" : 1, + "id" : null, + "our_type" : "misc", + "old_mysql_id" : null + }, + { + "bibtexTypes" : [ + "phdthesis" + ], + "description" : null, + "id" : null, + "onLanding" : 0, + "old_mysql_id" : null, + "our_type" : "phdthesis" + }, + { + "bibtexTypes" : [ + "mastersthesis", + "phdthesis" + ], + "description" : null, + "onLanding" : 0, + "id" : null, + "our_type" : "supervised_theses", + "old_mysql_id" : null + }, + { + "old_mysql_id" : null, + "our_type" : "proceedings", + "onLanding" : 0, + "id" : null, + "bibtexTypes" : [ + "proceedings" + ], + "description" : null + }, + { + "description" : null, + "bibtexTypes" : [ + "inproceedings" + ], + "id" : null, + "onLanding" : 0, + "old_mysql_id" : null, + "our_type" : "bibtex-inproceedings" + }, + { + "bibtexTypes" : [ + "book", + "phdthesis", + "proceedings" + ], + "description" : null, + "our_type" : "volumes", + "old_mysql_id" : null, + "onLanding" : 0, + "id" : null + } + ], + "Membership" : [ + { + "stop" : 0, + "author_id" : 527, + "start" : 0, + "team_id" : 1 + }, + { + "team_id" : 3, + "start" : 2009, + "author_id" : 527, + "stop" : 2012 + }, + { + "stop" : 0, + "author_id" : 1486, + "start" : 0, + "team_id" : 1 + } + ], + "Entry" : [ + { + "creation_time" : "2017-02-08T17:53:52", + "abstract" : "{Elasticity is the ability of a software system to dynamically adapt the amount of the resources it provides to clients as their workloads increase or decrease. In the context of cloud computing, automated resizing of a virtual machine's resources can be considered as a key step towards optimisation of a system's cost and energy efficiency. Existing work on cloud computing is limited to the technical view of implementing elastic systems, and definitions of scalability have not been extended to cover elasticity. This study thesis presents a detailed discussion of elasticity, proposes metrics as well as measurement techniques, and outlines next steps for enabling comparisons between cloud computing offerings on the basis of elasticity. I discuss results of our work on measuring elasticity of thread pools provided by the Java virtual machine, as well as an experiment setup for elastic CPU time slice resizing in a virtualized environment. An experiment setup is presented as future work for dynamically adding and removing z/VM Linux virtual machine instances to a performance relevant group of virtualized servers.}", + "hidden" : 0, + "html_bib" : "
\n@mastersthesis{Herbst2011a,\n abstract = {{Elasticity is the ability of a software system to dynamically adapt the amount of the resources it provides to clients as their workloads increase or decrease. In the context of cloud computing, automated resizing of a virtual machine's resources can be considered as a key step towards optimisation of a system's cost and energy efficiency. Existing work on cloud computing is limited to the technical view of implementing elastic systems, and definitions of scalability have not been extended to cover elasticity. This study thesis presents a detailed discussion of elasticity, proposes metrics as well as measurement techniques, and outlines next steps for enabling comparisons between cloud computing offerings on the basis of elasticity. I discuss results of our work on measuring elasticity of thread pools provided by the Java virtual machine, as well as an experiment setup for elastic CPU time slice resizing in a virtualized environment. An experiment setup is presented as future work for dynamically adding and removing z/VM Linux virtual machine instances to a performance relevant group of virtualized servers.}},\n address = {Am Fasanengarten 5, 76131 Karlsruhe, Germany},\n author = {Nikolas Roman Herbst},\n keywords = {Cloud, Resource Elasticity},\n pdf = {http://se2.informatik.uni-wuerzburg.de/pa/publications/download/paper/202.pdf},\n school = {{Karlsruhe Institute of Technology (KIT)}},\n title = {{Quantifying the Impact of Configuration Space for Elasticity Benchmarking}},\n type = {{Study Thesis}},\n year = {2011}\n}\n\n\n", + "year" : 2011, + "old_mysql_id" : 202, + "html" : "Nikolas Roman Herbst.\nQuantifying the Impact of Configuration Space for Elasticity Benchmarking.\nStudy Thesis, Karlsruhe Institute of Technology (KIT), Am Fasanengarten 5, 76131 Karlsruhe, Germany, 2011.\n[ bib | Abstract\n | pdf\n ]\n \n ", + "bib" : "@mastersthesis{Herbst2011a,\n abstract = {{Elasticity is the ability of a software system to dynamically adapt the amount of the resources it provides to clients as their workloads increase or decrease. In the context of cloud computing, automated resizing of a virtual machine's resources can be considered as a key step towards optimisation of a system's cost and energy efficiency. Existing work on cloud computing is limited to the technical view of implementing elastic systems, and definitions of scalability have not been extended to cover elasticity. This study thesis presents a detailed discussion of elasticity, proposes metrics as well as measurement techniques, and outlines next steps for enabling comparisons between cloud computing offerings on the basis of elasticity. I discuss results of our work on measuring elasticity of thread pools provided by the Java virtual machine, as well as an experiment setup for elastic CPU time slice resizing in a virtualized environment. An experiment setup is presented as future work for dynamically adding and removing z/VM Linux virtual machine instances to a performance relevant group of virtualized servers.}},\n address = {Am Fasanengarten 5, 76131 Karlsruhe, Germany},\n author = {Nikolas Roman Herbst},\n keywords = {Cloud, Resource Elasticity},\n school = {{Karlsruhe Institute of Technology (KIT)}},\n title = {{Quantifying the Impact of Configuration Space for Elasticity Benchmarking}},\n type = {{Study Thesis}},\n year = {2011},\n pdf = {http://localhost:8083/publications/download/paper/202.pdf},\n}\n\n", + "bibtex_key" : "Herbst2011a", + "id" : 202, + "entry_type" : "paper", + "_bibtex_type" : "mastersthesis", + "need_html_regen" : 0, + "title" : "{Quantifying the Impact of Configuration Space for Elasticity Benchmarking}", + "month" : 0, + "modified_time" : "2017-12-10T19:35:01" + }, + { + "html" : "Aleksandar Milenkoski, Bryan D. Payne, Nuno Antunes, Marco Vieira, and Samuel Kounev.\nHInjector: Injecting Hypercall Attacks for Evaluating VMI-based Intrusion Detection Systems (Poster Paper).\nIn The 2013 Annual Computer Security Applications Conference (ACSAC 2013), New Orleans, Louisiana, USA, March 2013. Applied Computer Security Associates (ACSA), Maryland, USA.\nMarch 2013.\n[ bib | pdf\n ]\n ", + "bib" : "@inproceedings{MiPaAnViKo2013-ACSAC-HInjector,\n address = {Maryland, USA},\n author = {Aleksandar Milenkoski and Bryan D. Payne and Nuno Antunes and Marco Vieira and Samuel Kounev},\n booktitle = {The 2013 Annual Computer Security Applications Conference (ACSAC 2013)},\n publisher = {{Applied Computer Security Associates (ACSA)}},\n location = {New Orleans, Louisiana, USA},\n title = {{HInjector: Injecting Hypercall Attacks for Evaluating VMI-based Intrusion Detection Systems}},\n titleaddon = {{(Poster Paper)}},\n year = {2013},\n month = {March},\n pdf = {http://localhost:8083/publications/download/paper/435.pdf},\n}\n\n", + "bibtex_key" : "MiPaAnViKo2013-ACSAC-HInjector", + "entry_type" : "paper", + "need_html_regen" : 0, + "_bibtex_type" : "inproceedings", + "id" : 435, + "month" : 3, + "title" : "{HInjector: Injecting Hypercall Attacks for Evaluating VMI-based Intrusion Detection Systems}", + "modified_time" : "2017-12-10T19:35:01", + "creation_time" : "2017-02-08T17:53:53", + "hidden" : 0, + "abstract" : null, + "year" : 2013, + "html_bib" : "
\n@inproceedings{MiPaAnViKo2013-ACSAC-HInjector,\n address = {Maryland, USA},\n author = {Aleksandar Milenkoski and Bryan D. Payne and Nuno Antunes and Marco Vieira and Samuel Kounev},\n booktitle = {The 2013 Annual Computer Security Applications Conference (ACSAC 2013)},\n publisher = {{Applied Computer Security Associates (ACSA)}},\n location = {New Orleans, Louisiana, USA},\n pdf = {http://se2.informatik.uni-wuerzburg.de/pa/publications/download/paper/435.pdf},\n title = {{HInjector: Injecting Hypercall Attacks for Evaluating VMI-based Intrusion Detection Systems}},\n titleaddon = {{(Poster Paper)}},\n year = {2013},\n month = {March}\n}\n\n\n", + "old_mysql_id" : 435 + }, + { + "month" : 11, + "title" : "{SPECjAppServer2002 - Industry-standard enterprise Java application server benchmark (J2EE 1.3).}", + "modified_time" : "2017-02-08T02:00:03", + "bib" : "@misc{sp2002-SPEC-SPECjAppServer2002,\n abstract = {SPECjAppServer2002 (Java Application Server) is a client/server benchmark for measuring the performance of Java Enterprise Application Servers using a subset of J2EE APIs in a complete end-to-end web application. It is the same as SPECjAppServer2001 (released in September 2002) except that the Enterprise Java Beans (EJBs) are defined using the EJB 2.0 specification instead of the EJB 1.1 specification. SPECjAppServer2002 can therefore take advantage of several EJB 2.0 features such as local interfaces, the EJB-QL query language, and Container Managed Relationships (CMR) between entity beans. Joining the client-side SPECjvm98 and the server side SPECjbb2000, SPECjAppServer2002 and SPECjAppServer2001 continue the SPEC tradition of giving Java users the most objective and representative benchmarks for measuring a system's ability to run Java applications. SPEC has designed the SPECjAppServer2002 benchmark to exercise the Java Enterprise Application Server, the Java Virtual Machine (JVM), as well as the server Systems Under Test (SUT). As a true J2EE application the benchmark will require a functional RDBMS (for JDBC) and a Web Server, but the benchmark has been designed so that the SUT can be a single system. Please note that while the SPECjAppServer2002 suite is still available for purchase, the suite has been retired, no further results are being accepted for publication, and support is no longer provided.},\n author = {SPEC},\n howpublished = {Standard Performance Evaluation Corporation},\n month = {November},\n title = {{SPECjAppServer2002 - Industry-standard enterprise Java application server benchmark (J2EE 1.3).}},\n url = {http://www.spec.org/jAppServer2002/},\n year = {2002},\n}\n\n", + "bibtex_key" : "sp2002-SPEC-SPECjAppServer2002", + "html" : "SPEC.\nSPECjAppServer2002 - Industry-standard enterprise Java application server benchmark (J2EE 1.3).\nStandard Performance Evaluation Corporation, November 2002.\n[ bib | abstract\n | http\n ]\n \n ", + "id" : 588, + "need_html_regen" : 0, + "_bibtex_type" : "misc", + "entry_type" : "paper", + "year" : 2002, + "html_bib" : "
\n@misc{sp2002-SPEC-SPECjAppServer2002,\n abstract = {SPECjAppServer2002 (Java Application Server) is a client/server benchmark for measuring the performance of Java Enterprise Application Servers using a subset of J2EE APIs in a complete end-to-end web application. It is the same as SPECjAppServer2001 (released in September 2002) except that the Enterprise Java Beans (EJBs) are defined using the EJB 2.0 specification instead of the EJB 1.1 specification. SPECjAppServer2002 can therefore take advantage of several EJB 2.0 features such as local interfaces, the EJB-QL query language, and Container Managed Relationships (CMR) between entity beans. Joining the client-side SPECjvm98 and the server side SPECjbb2000, SPECjAppServer2002 and SPECjAppServer2001 continue the SPEC tradition of giving Java users the most objective and representative benchmarks for measuring a system's ability to run Java applications. SPEC has designed the SPECjAppServer2002 benchmark to exercise the Java Enterprise Application Server, the Java Virtual Machine (JVM), as well as the server Systems Under Test (SUT). As a true J2EE application the benchmark will require a functional RDBMS (for JDBC) and a Web Server, but the benchmark has been designed so that the SUT can be a single system. Please note that while the SPECjAppServer2002 suite is still available for purchase, the suite has been retired, no further results are being accepted for publication, and support is no longer provided.},\n author = {SPEC},\n howpublished = {Standard Performance Evaluation Corporation},\n month = {November},\n title = {{SPECjAppServer2002 - Industry-standard enterprise Java application server benchmark (J2EE 1.3).}},\n url = {http://www.spec.org/jAppServer2002/},\n year = {2002}\n}\n\n\n", + "old_mysql_id" : 588, + "creation_time" : "2017-02-08T17:53:53", + "abstract" : "SPECjAppServer2002 (Java Application Server) is a client/server benchmark for measuring the performance of Java Enterprise Application Servers using a subset of J2EE APIs in a complete end-to-end web application. It is the same as SPECjAppServer2001 (released in September 2002) except that the Enterprise Java Beans (EJBs) are defined using the EJB 2.0 specification instead of the EJB 1.1 specification. SPECjAppServer2002 can therefore take advantage of several EJB 2.0 features such as local interfaces, the EJB-QL query language, and Container Managed Relationships (CMR) between entity beans. Joining the client-side SPECjvm98 and the server side SPECjbb2000, SPECjAppServer2002 and SPECjAppServer2001 continue the SPEC tradition of giving Java users the most objective and representative benchmarks for measuring a system's ability to run Java applications. SPEC has designed the SPECjAppServer2002 benchmark to exercise the Java Enterprise Application Server, the Java Virtual Machine (JVM), as well as the server Systems Under Test (SUT). As a true J2EE application the benchmark will require a functional RDBMS (for JDBC) and a Web Server, but the benchmark has been designed so that the SUT can be a single system. Please note that while the SPECjAppServer2002 suite is still available for purchase, the suite has been retired, no further results are being accepted for publication, and support is no longer provided.", + "hidden" : 0 + }, + { + "year" : 2011, + "html_bib" : "
\n@article{SwRyGr2011-EAT,\n address = {Pozna{\\'n}, Poland},\n author = {Pawel \\'{S}wi\\k{a}tek and Piotr Rygielski and Adam Grzech},\n isbn = {2081-8580},\n journal = {Advances in Electronics and Telecommunications},\n month = {November},\n number = {3},\n pages = {50--54},\n publisher = {Pozna{\\'n} University of Technology Press},\n title = {{Resources Management and Services Personalization in Future Internet Applications}},\n url = {http://www.advances.et.put.poznan.pl/},\n volume = {2},\n year = {2011}\n}\n\n\n", + "old_mysql_id" : 675, + "creation_time" : "2017-02-08T17:53:54", + "abstract" : null, + "hidden" : 1, + "title" : "{Resources Management and Services Personalization in Future Internet Applications}", + "month" : 11, + "modified_time" : "2017-02-08T02:00:03", + "html" : "Pawel Świątek, Piotr Rygielski, and Adam Grzech.\nResources Management and Services Personalization in Future Internet Applications.\n Advances in Electronics and Telecommunications, 2(3):50–54, November 2011, Poznań University of Technology Press, Poznań, Poland.\n[ bib | http\n ]\n ", + "bib" : "@article{SwRyGr2011-EAT,\n address = {Pozna{\\'n}, Poland},\n author = {Pawel \\'{S}wi\\k{a}tek and Piotr Rygielski and Adam Grzech},\n isbn = {2081-8580},\n journal = {Advances in Electronics and Telecommunications},\n month = {November},\n number = {3},\n pages = {50--54},\n publisher = {Pozna{\\'n} University of Technology Press},\n title = {{Resources Management and Services Personalization in Future Internet Applications}},\n url = {http://www.advances.et.put.poznan.pl/},\n volume = {2},\n year = {2011},\n}\n\n", + "bibtex_key" : "SwRyGr2011-EAT", + "id" : 675, + "entry_type" : "paper", + "need_html_regen" : 0, + "_bibtex_type" : "article" + }, + { + "bibtex_key" : "SPEC-RG-NEWSLETTER-4", + "bib" : "@misc{SPEC-RG-NEWSLETTER-4,\n author = {Samuel Kounev and Kai Sachs and Piotr Rygielski},\n month = {January},\n note = {Published by Standard Performance Evaluation Corporation (SPEC)},\n title = {{SPEC Research Group Newsletter, vol. 1 no. 4}},\n url = {http://research.spec.org/en/newsletter.html},\n year = {2015},\n pdf = {http://localhost:8083/publications/download/paper/781.pdf},\n}\n\n", + "html" : "\n\nSamuel Kounev, Kai Sachs, and Piotr Rygielski.\nSPEC Research Group Newsletter, vol. 1 no. 4, January 2015.\nPublished by Standard Performance Evaluation Corporation (SPEC).\n[ bib | .html | .pdf ] \n", + "_bibtex_type" : "misc", + "need_html_regen" : 0, + "entry_type" : "paper", + "id" : 781, + "title" : "{SPEC Research Group Newsletter, vol. 1 no. 4}", + "month" : 1, + "modified_time" : "2017-12-10T19:35:01", + "creation_time" : "2017-02-08T17:53:54", + "hidden" : 0, + "abstract" : null, + "html_bib" : "
\n@misc{SPEC-RG-NEWSLETTER-4,\n author = {Samuel Kounev and Kai Sachs and Piotr Rygielski},\n month = {January},\n note = {Published by Standard Performance Evaluation Corporation (SPEC)},\n title = {{SPEC Research Group Newsletter, vol. 1 no. 4}},\n url = {http://research.spec.org/en/newsletter.html},\n year = {2015},\n pdf = {http://se2.informatik.uni-wuerzburg.de/pa/publications/download/paper/781.pdf}\n}\n\n\n", + "year" : 2015, + "old_mysql_id" : 781 + }, + { + "bibtex_key" : "KoBrMeBeKoKoRy2016-SE-tradeoffs_perf_prediction_approaches", + "bib" : "@inproceedings{KoBrMeBeKoKoRy2016-SE-tradeoffs_perf_prediction_approaches,\n author = {Samuel Kounev and Fabian Brosig and Philipp Meier and Steffen Becker and Anne Koziolek and Heiko Koziolek and Piotr Rygielski},\n title = {{Analysis of the Trade-offs in Different Modeling Approaches for Performance Prediction of Software Systems}},\n booktitle = {Software Engineering 2016 (SE 2016), Fachtagung des GI-Fachbereichs Softwaretechnik, 23.-26. M\\\"{a}rz 2016, Vienna, Austria},\n publisher = {GI},\n series = {Lecture Notes in Informatics (LNI)},\n address = {Vienna, Austria},\n days = {23-26},\n month = {February},\n year = {2016},\n pages = {47--48},\n titleaddon = {{(Talk Extended Abstract)}},\n http = {http://subs.emis.de/LNI/Proceedings/Proceedings252/article3.html},\n pdf = {http://localhost:8083/publications/download/paper/1077.pdf},\n slides = {http://localhost:8083/publications/download/slides/1077},\n}\n\n", + "html" : "\n\nSamuel Kounev, Fabian Brosig, Philipp Meier, Steffen Becker, Anne Koziolek,\nHeiko Koziolek, and Piotr Rygielski.\nAnalysis of the Trade-offs in Different Modeling Approaches for\nPerformance Prediction of Software Systems (Talk Extended Abstract).\nIn Software Engineering 2016 (SE 2016), Fachtagung des\nGI-Fachbereichs Softwaretechnik, 23.-26. März 2016, Vienna, Austria,\nFebruary 2016, Lecture Notes in Informatics (LNI), pages 47-48. GI, Vienna,\nAustria.\nFebruary 2016.\n[ bib | slides | .html | .pdf ] \n", + "_bibtex_type" : "inproceedings", + "need_html_regen" : 0, + "entry_type" : "talk", + "id" : 1077, + "title" : "{Analysis of the Trade-offs in Different Modeling Approaches for Performance Prediction of Software Systems}", + "month" : 2, + "modified_time" : "2017-12-10T19:35:02", + "creation_time" : "2016-02-24T18:09:58", + "hidden" : 0, + "abstract" : null, + "html_bib" : "
\n@inproceedings{KoBrMeBeKoKoRy2016-SE-tradeoffs_perf_prediction_approaches,\n author = {Samuel Kounev and Fabian Brosig and Philipp Meier and Steffen Becker and Anne Koziolek and Heiko Koziolek and Piotr Rygielski},\n title = {{Analysis of the Trade-offs in Different Modeling Approaches for Performance Prediction of Software Systems}},\n booktitle = {Software Engineering 2016 (SE 2016), Fachtagung des GI-Fachbereichs Softwaretechnik, 23.-26. M\\\"{a}rz 2016, Vienna, Austria},\n publisher = {GI},\n series = {Lecture Notes in Informatics (LNI)},\n address = {Vienna, Austria},\n days = {23-26},\n month = {February},\n year = {2016},\n pages = {47--48},\n titleaddon = {{(Talk Extended Abstract)}},\n http = {http://subs.emis.de/LNI/Proceedings/Proceedings252/article3.html},\n pdf = {http://se2.informatik.uni-wuerzburg.de/pa/publications/download/paper/1077.pdf},\n slides = {http://se2.informatik.uni-wuerzburg.de/pa/publications/download/slides/1077}\n}\n\n\n", + "year" : 2016, + "old_mysql_id" : 1077 + }, + { + "old_mysql_id" : 1099, + "year" : 2015, + "html_bib" : "
\n@inproceedings{SpinnerZLUGHK-2015-RADIO-MemoryScaling,\n author = {Simon Spinner and Xiaoyun Zhu and Lei Lu and Mustafa Uysal and Rean Griffith and Nikolas Herbst and Samuel Kounev},\n title = {{Proactive Memory Scaling of Virtualized Applications}},\n booktitle = {VMware R&D Innovation Offsite (RADIO)},\n year = {2015},\n month = {July}\n}\n\n\n", + "abstract" : null, + "hidden" : 1, + "creation_time" : "2016-04-20T17:12:15", + "modified_time" : "2017-02-08T02:00:03", + "month" : 7, + "title" : "{Proactive Memory Scaling of Virtualized Applications}", + "id" : 1099, + "need_html_regen" : 0, + "_bibtex_type" : "inproceedings", + "entry_type" : "paper", + "bibtex_key" : "SpinnerZLUGHK-2015-RADIO-MemoryScaling", + "bib" : "@inproceedings{SpinnerZLUGHK-2015-RADIO-MemoryScaling,\n author = {Simon Spinner and Xiaoyun Zhu and Lei Lu and Mustafa Uysal and Rean Griffith and Nikolas Herbst and Samuel Kounev},\n title = {{Proactive Memory Scaling of Virtualized Applications}},\n booktitle = {VMware R&D Innovation Offsite (RADIO)},\n year = {2015},\n month = {July},\n}\n\n", + "html" : "\n\nSimon Spinner, Xiaoyun Zhu, Lei Lu, Mustafa Uysal, Rean Griffith, Nikolas\nHerbst, and Samuel Kounev.\nProactive Memory Scaling of Virtualized Applications.\nIn VMware R&D Innovation Offsite (RADIO), July 2015.\n[ bib ] \n" + }, + { + "entry_type" : "paper", + "need_html_regen" : 0, + "_bibtex_type" : "article", + "id" : 1105, + "html" : "\n\nAleksandar Milenkoski, Alexandru Iosup, Samuel Kounev, Kai Sachs, Diane E.\nMularz, Jonathan A. Curtiss, Jason J. Ding, Florian Rosenberg, and Piotr\nRygielski.\nCUP: A Formalism for Expressing Cloud Usage Patterns for Experts and\nNon-Experts.\nIEEE Cloud Computing, 2016.\nTo Appear.\n[ bib ] \n", + "bib" : "@article{MiIoKoSaMuCuDiRoRy2016-IEEECC-cup,\n author = {Aleksandar Milenkoski and Alexandru Iosup and Samuel Kounev and Kai Sachs and Diane E. Mularz and Jonathan A. Curtiss and Jason J. Ding and Florian Rosenberg and Piotr Rygielski},\n title = {{CUP: A Formalism for Expressing Cloud Usage Patterns for Experts and Non-Experts}},\n journal = {IEEE Cloud Computing},\n publisher = {IEEE},\n year = {2016},\n note = {To Appear},\n}\n\n", + "bibtex_key" : "MiIoKoSaMuCuDiRoRy2016-IEEECC-cup", + "modified_time" : "2017-02-08T02:00:03", + "title" : "{CUP: A Formalism for Expressing Cloud Usage Patterns for Experts and Non-Experts}", + "month" : 0, + "hidden" : 0, + "abstract" : null, + "creation_time" : "2016-05-09T11:05:03", + "old_mysql_id" : 1105, + "year" : 2016, + "html_bib" : "
\n@article{MiIoKoSaMuCuDiRoRy2016-IEEECC-cup,\n author = {Aleksandar Milenkoski and Alexandru Iosup and Samuel Kounev and Kai Sachs and Diane E. Mularz and Jonathan A. Curtiss and Jason J. Ding and Florian Rosenberg and Piotr Rygielski},\n title = {{CUP: A Formalism for Expressing Cloud Usage Patterns for Experts and Non-Experts}},\n journal = {IEEE Cloud Computing},\n year = {2016},\n note = {To Appear}\n}\n\n\n" + }, + { + "html_bib" : "
\n@incollection{HeAmAnGrMeSuKo2016-self,\n title = {{Online Workload Forecasting}},\n editor = {Samuel Kounev and Jeffrey O. Kephart and Xiaoyun Zhu and Aleksandar Milenkoski},\n author = {Nikolas Herbst and Ayman Amin and Artur Andrzejak and Lars Grunske and Ole J. Mengshoel and Priya Sundararajan and Samuel Kounev},\n booktitle = {{Self-Aware Computing Systems}},\n publisher = {{Springer Verlag}},\n address = {{Berlin Heidelberg, Germany}},\n year = {2016},\n note = {{To Appear}}\n}\n\n\n", + "year" : 2017, + "old_mysql_id" : 1111, + "creation_time" : "2016-05-10T15:48:15", + "abstract" : "{This chapter gives a summary of the state-of-the-art approaches from different research fields that can be applied to continuously forecast future developments of time series data streams. More specifically, the input time series data contains continuously monitored metrics that quantify the amount of incoming workload units to a self-aware system. It is the goal of this chapter to identify and present approaches for online workload forecasting that are required for a self-aware system to act proactively in terms of problem prevention and optimization inferred from likely changes in their usage. The research fields covered are machine learning and time series analysis. We describe explicit limitations and advantages for each forecasting method.}", + "hidden" : 0, + "title" : "{Online Workload Forecasting}", + "month" : 0, + "modified_time" : "2017-02-08T02:00:03", + "bibtex_key" : "HeAmAnGrMeSuKo2016-self", + "bib" : "@incollection{HeAmAnGrMeSuKo2016-self,\r\n title = {{Online Workload Forecasting}},\r\n editor = {Samuel Kounev and Jeffrey O. Kephart and Xiaoyun Zhu and Aleksandar Milenkoski},\r\n author = {Nikolas Herbst and Ayman Amin and Artur Andrzejak and Lars Grunske and Samuel Kounev and Ole J. Mengshoel and Priya Sundararajan},\r\n booktitle = {{Self-Aware Computing Systems}},\r\n publisher = {{Springer Verlag}},\r\n address = {{Berlin Heidelberg, Germany}},\r\n year = {2017},\r\n note = {{To Appear}},\r\nabstract={{This chapter gives a summary of the state-of-the-art approaches from different research fields that can be applied to continuously forecast future developments of time series data streams. More specifically, the input time series data contains continuously monitored metrics that quantify the amount of incoming workload units to a self-aware system. It is the goal of this chapter to identify and present approaches for online workload forecasting that are required for a self-aware system to act proactively in terms of problem prevention and optimization inferred from likely changes in their usage. The research fields covered are machine learning and time series analysis. We describe explicit limitations and advantages for each forecasting method.}}\r\n}", + "html" : "Nikolas Herbst, Ayman Amin, Artur Andrzejak, Lars Grunske, Samuel Kounev, Ole J. Mengshoel, and Priya Sundararajan.\nOnline Workload Forecasting.\nIn Self-Aware Computing Systems, Samuel Kounev, Jeffrey O. Kephart, Xiaoyun Zhu, and Aleksandar Milenkoski, editors. Springer Verlag, Berlin Heidelberg, Germany, 2017.\nTo Appear.\n[ bib | Abstract\n ]\n \n ", + "id" : 1111, + "_bibtex_type" : "incollection", + "need_html_regen" : 0, + "entry_type" : "paper" + }, + { + "title" : "{Reliable Resource Demand Estimation}", + "month" : 10, + "modified_time" : "2017-12-10T19:35:02", + "bibtex_key" : "grohmann16", + "bib" : "@mastersthesis{grohmann16,\n author = {Johannes Grohmann},\n abstract = {Resource demands are key parameters of performance models used to predict the behavior of data centers. They define the amount of time a request spends obtaining a limited resource like the CPU. Requests can be grouped into different workload classes. Measuring these resource demands is usually unfeasible in practice. Therefore, several different approaches to estimate the resource demands of different workload classes exist. However, different use-cases with individual properties influence the accuracy of the estimators. Among others the number of different workload classes to estimate is known to have an impact on the solution quality, but affects some approaches more than others. Additionally, most approaches offer specific parameters to configure and optimize the estimators. Nevertheless, in order to optimize the parameters of one estimation approach or to choose the best estimator for a given scenario either expert knowledge or exhaustive testing is required. While some works on comparing different approaches and configurations exist, we extend this by learning on a given training set and specially adapting the estimation approaches in order to optimize performance for the required target scenario. We simplify automated resource demand estimation by designing a framework for ready-to-use reliable resource demand estimation. In order to do so, we develop generic algorithms that can be used to autonomously optimize parameter configurations of black-box estimation approaches on a given training set. Secondly, machine learning algorithms analyze the behavior of the resource demand estimators on different training traces and automatically pick the best approach for a prior unseen trace. The framework is modularized and configurable and can be trained on any kind of trace data. We implement different algorithms for optimization as well as machine learning and evaluate them on a training set containing measurements of a real system. The results show that parameter optimization is very promising and can increase the accuracy of single approaches of up to 10%. When recommending one approach as opposed to running all simultaneously, comparable results can be achieved, while saving more than 50% of the runtime. However, a combination of both approaches does not seem useful on our data set.},\n title = {{Reliable Resource Demand Estimation}},\n year = {2016},\n month = {October},\n school = {University of W\\\"{u}rzburg},\n address = {Am Hubland, Informatikgeb\\\"aude, 97074 W\\\"urzburg, Germany},\n type = {{Master Thesis}},\n keywords = {Resource Demand Estimation, Machine Learning, Optimization, Meta-Learning},\n pdf = {http://localhost:8083/publications/download/paper/1159.pdf},\n slides = {http://localhost:8083/publications/download/slides/1159},\n}\n\n", + "html" : "Johannes Grohmann.\nReliable Resource Demand Estimation.\nMaster Thesis, University of Würzburg, Am Hubland, Informatikgebäude, 97074 Würzburg, Germany, October 2016.\n[ bib | Abstract\n | pdf\n | slides\n ]\n \n ", + "_bibtex_type" : "mastersthesis", + "need_html_regen" : 0, + "entry_type" : "paper", + "id" : 1159, + "html_bib" : null, + "year" : 2016, + "old_mysql_id" : 1159, + "creation_time" : "2016-11-07T14:22:45", + "hidden" : 0, + "abstract" : "Resource demands are key parameters of performance models used to predict the behavior of data centers. They define the amount of time a request spends obtaining a limited resource like the CPU. Requests can be grouped into different workload classes. Measuring these resource demands is usually unfeasible in practice. Therefore, several different approaches to estimate the resource demands of different workload classes exist. However, different use-cases with individual properties influence the accuracy of the estimators. Among others the number of different workload classes to estimate is known to have an impact on the solution quality, but affects some approaches more than others. Additionally, most approaches offer specific parameters to configure and optimize the estimators. Nevertheless, in order to optimize the parameters of one estimation approach or to choose the best estimator for a given scenario either expert knowledge or exhaustive testing is required. While some works on comparing different approaches and configurations exist, we extend this by learning on a given training set and specially adapting the estimation approaches in order to optimize performance for the required target scenario. We simplify automated resource demand estimation by designing a framework for ready-to-use reliable resource demand estimation. In order to do so, we develop generic algorithms that can be used to autonomously optimize parameter configurations of black-box estimation approaches on a given training set. Secondly, machine learning algorithms analyze the behavior of the resource demand estimators on different training traces and automatically pick the best approach for a prior unseen trace. The framework is modularized and configurable and can be trained on any kind of trace data. We implement different algorithms for optimization as well as machine learning and evaluate them on a training set containing measurements of a real system. The results show that parameter optimization is very promising and can increase the accuracy of single approaches of up to 10%. When recommending one approach as opposed to running all simultaneously, comparable results can be achieved, while saving more than 50% of the runtime. However, a combination of both approaches does not seem useful on our data set." + }, + { + "hidden" : 1, + "abstract" : null, + "creation_time" : "2016-12-07T10:20:56", + "old_mysql_id" : 1166, + "year" : 2017, + "html_bib" : null, + "entry_type" : "paper", + "_bibtex_type" : "phdthesis", + "need_html_regen" : 0, + "id" : 1166, + "html" : "Piotr Rygielski.\n Flexible Modeling Data Center Networks for Capacity Management.\nPhD thesis, University of Würzburg, Germany, 2017.\n[ bib ]\n ", + "bibtex_key" : "Rygielski2017-phd", + "bib" : "@phdthesis{Rygielski2017-phd,\r\nauthor = {Piotr Rygielski},\r\ntitle = {Flexible Modeling Data Center Networks for Capacity Management},\r\nyear = {2017},\r\nmonth = {},\r\nschool = {University of W\\\"{u}rzburg, Germany},\r\n}", + "modified_time" : "2017-02-08T02:00:03", + "title" : "Flexible Modeling Data Center Networks for Capacity Management", + "month" : 0 + }, + { + "id" : 1173, + "_bibtex_type" : "article", + "need_html_regen" : 0, + "entry_type" : "paper", + "bib" : "@article{key2017,\r\n author = {Johny Example},\r\n journal = {Journal of this and that},\r\n publisher = {Printer-at-home publishing},\r\n title = {{Selected aspects of some methods}},\r\n year = {2017},\r\n month = {August},\r\n day = {1--31},\r\n }", + "bibtex_key" : "key2017", + "html" : "Johny Example.\nSelected aspects of some methods.\n Journal of this and that, August 2017, Printer-at-home publishing.\n[ bib ]\n ", + "modified_time" : "2017-08-08T08:19:26", + "title" : "{Selected aspects of some methods}", + "month" : 8, + "abstract" : null, + "hidden" : 0, + "creation_time" : "2017-08-08T08:19:26", + "old_mysql_id" : 1173, + "html_bib" : null, + "year" : 2017 + }, + { + "month" : 8, + "title" : "{Selected aspects of some methods}", + "modified_time" : "2018-07-15T17:36:02", + "bib" : "@article{key2018-invisible,\r\n author = {Johny Example and Henry Invisible},\r\n journal = {Journal of this and that},\r\n publisher = {Printer-at-home publishing},\r\n title = {{Selected aspects of some methods}},\r\n year = {2018},\r\n month = {August},\r\n day = {1--31},\r\n }", + "bibtex_key" : "key2018-invisible", + "html" : "Johny Example, and Henry Invisible.\nSelected aspects of some methods.\n Journal of this and that, August 2018, Printer-at-home publishing.\n[ bib ]\n ", + "id" : 1174, + "_bibtex_type" : "article", + "need_html_regen" : 0, + "entry_type" : "paper", + "year" : 2018, + "html_bib" : null, + "old_mysql_id" : 1174, + "creation_time" : "2018-07-15T17:36:02", + "abstract" : null, + "hidden" : 0 + }, + { + "creation_time" : "2018-07-15T21:14:47", + "abstract" : null, + "hidden" : 0, + "html_bib" : null, + "year" : 2018, + "old_mysql_id" : 1175, + "html" : "Master Test, and Minion Test.\nSelected aspects of some methods.\n Journal of this and that, July 2018, Printer-at-home publishing.\n[ bib ]\n ", + "bib" : "@article{key2018-master-minion,\r\n author = {Master Test and Minion Test},\r\n journal = {Journal of this and that},\r\n publisher = {Printer-at-home publishing},\r\n title = {{Selected aspects of some methods}},\r\n year = {2018},\r\n month = {July},\r\n day = {1--31},\r\n }", + "bibtex_key" : "key2018-master-minion", + "id" : 1175, + "entry_type" : "paper", + "need_html_regen" : 0, + "_bibtex_type" : "article", + "month" : 7, + "title" : "{Selected aspects of some methods}", + "modified_time" : "2018-07-15T21:14:47" + }, + { + "bib" : "@article{key2018-master-only,\r\n author = {Master Test},\r\n journal = {Journal of this and that},\r\n publisher = {Printer-at-home publishing},\r\n title = {{Selected aspects of some methods}},\r\n year = {2018},\r\n month = {July},\r\n day = {1--31},\r\n }", + "bibtex_key" : "key2018-master-only", + "html" : "Master Test.\nSelected aspects of some methods.\n Journal of this and that, July 2018, Printer-at-home publishing.\n[ bib ]\n ", + "need_html_regen" : 0, + "_bibtex_type" : "article", + "entry_type" : "paper", + "id" : 1176, + "month" : 7, + "title" : "{Selected aspects of some methods}", + "modified_time" : "2018-07-15T21:15:03", + "creation_time" : "2018-07-15T21:15:03", + "hidden" : 0, + "abstract" : null, + "html_bib" : null, + "year" : 2018, + "old_mysql_id" : 1176 + }, + { + "abstract" : null, + "hidden" : 0, + "creation_time" : "2018-07-15T21:15:17", + "old_mysql_id" : 1177, + "html_bib" : null, + "year" : 2018, + "id" : 1177, + "need_html_regen" : 0, + "_bibtex_type" : "article", + "entry_type" : "paper", + "bibtex_key" : "key2018-minion-only", + "bib" : "@article{key2018-minion-only,\r\n author = {Minion Test},\r\n journal = {Journal of this and that},\r\n publisher = {Printer-at-home publishing},\r\n title = {{Selected aspects of some methods}},\r\n year = {2018},\r\n month = {July},\r\n day = {1--31},\r\n }", + "html" : "Minion Test.\nSelected aspects of some methods.\n Journal of this and that, July 2018, Printer-at-home publishing.\n[ bib ]\n ", + "modified_time" : "2018-07-15T21:15:17", + "month" : 7, + "title" : "{Selected aspects of some methods}" + } + ], + "Team" : [ + { + "old_mysql_id" : 1, + "id" : 1, + "parent" : null, + "name" : "SE-WUERZBURG" + }, + { + "name" : "PiotrPL", + "parent" : null, + "id" : 3, + "old_mysql_id" : 3 + }, + { + "old_mysql_id" : 4, + "id" : 4, + "name" : "DESCARTES_ALUMNI", + "parent" : null + }, + { + "parent" : null, + "name" : "DESCARTES", + "id" : 6, + "old_mysql_id" : 6 + } + ], + "Authorship" : [ + { + "entry_id" : 435, + "author_id" : 1389 + }, + { + "author_id" : 591, + "entry_id" : 588 + }, + { + "author_id" : 527, + "entry_id" : 675 + }, + { + "entry_id" : 781, + "author_id" : 527 + }, + { + "entry_id" : 1077, + "author_id" : 527 + }, + { + "entry_id" : 1099, + "author_id" : 1121 + }, + { + "entry_id" : 1105, + "author_id" : 527 + }, + { + "author_id" : 1389, + "entry_id" : 1105 + }, + { + "entry_id" : 1111, + "author_id" : 1121 + }, + { + "entry_id" : 1159, + "author_id" : 1486 + }, + { + "entry_id" : 1166, + "author_id" : 527 + }, + { + "author_id" : 1487, + "entry_id" : 1173 + }, + { + "entry_id" : 1174, + "author_id" : 1487 + }, + { + "entry_id" : 1174, + "author_id" : 1489 + }, + { + "author_id" : 1490, + "entry_id" : 1175 + }, + { + "author_id" : 1491, + "entry_id" : 1175 + }, + { + "entry_id" : 1176, + "author_id" : 1490 + }, + { + "entry_id" : 1177, + "author_id" : 1491 + } + ], + "Exception" : [ + { + "entry_id" : 588, + "team_id" : 1 + }, + { + "team_id" : 6, + "entry_id" : 588 + }, + { + "team_id" : 6, + "entry_id" : 1173 + } + ], + "TagType" : [ + { + "old_mysql_id" : 1, + "id" : 1, + "name" : "Tag", + "comment" : "keyword" + }, + { + "comment" : "12 categories defined as in research agenda", + "name" : "Category", + "id" : 2, + "old_mysql_id" : 2 + }, + { + "name" : "Other", + "comment" : "Reserved for other grouppings of papers (e.g., QPME_Bibliography)", + "id" : 3, + "old_mysql_id" : 3 + }, + { + "id" : 4, + "old_mysql_id" : 4, + "name" : "Imported", + "comment" : "Tags Imported from Bibtex" + } + ] + }, + "dateTimeFormat" : "%Y-%m-%dT%T", + "formatVersion" : "1" +} diff --git a/lib/BibSpace.pm b/lib/BibSpace.pm index b78ce37..df80e79 100644 --- a/lib/BibSpace.pm +++ b/lib/BibSpace.pm @@ -1,4 +1,4 @@ -package BibSpace v0.5.3; +package BibSpace v0.6.0; # ABSTRACT: BibSpace is a system to manage Bibtex references for authors and research groups web page. @@ -15,35 +15,27 @@ use Mojo::Base 'Mojolicious::Plugin::Config'; use Data::Dumper; -# use File::Slurp; use POSIX qw/strftime/; use Try::Tiny; use Path::Tiny; # for creating directories use Mojo::Home; use File::Spec; -use BibSpace::Backend::SmartArray; -use BibSpace::Backend::SmartHash; -use BibSpace::Backend::SmartBackendHelper; use BibSpace::Util::SimpleLogger; -use BibSpace::Util::SmartUidProvider; -use BibSpace::Util::DummyUidProvider; use BibSpace::Util::Statistics; use BibSpace::Model::User; use BibSpace::DAO::DAOFactory; -use BibSpace::Repository::LayeredRepository; +use BibSpace::Repository::FlatRepository; use BibSpace::Repository::RepositoryLayer; -use BibSpace::Repository::RepositoryFacade; +use BibSpace::Repository::FlatRepositoryFacade; use BibSpace::Converter::IHtmlBibtexConverter; use BibSpace::Converter::Bibtex2HtmlConverter; use BibSpace::Converter::BibStyleConverter; -use Storable; - use BibSpace::Util::Preferences; use BibSpace::Util::EntityFactory; @@ -121,106 +113,54 @@ has get_log_dir => sub { # }; has version => sub { - return $BibSpace::VERSION // "0.5.0"; -}; - -has quick_load_fixture_filename => sub { - my $self = shift; - return $self->app->home->rel_file('bibspace.dat'); -}; - -# don't want to read data form DB and wait to link them every reload? -# use quick_load_fixture! Useful for development and testing. -# better disable it for production -has use_quick_load_fixture => sub { - my $self = shift; - return if $self->mode eq 'production'; - - return 1 if defined $ENV{BIBSPACE_USE_DUMP} and $ENV{BIBSPACE_USE_DUMP} == 1; - return; + return $BibSpace::VERSION // "0.6.0"; }; -# please use only a single type of logger at once. -# Using multiple may not be supported currently -# if you really want to use multiple different loggers or state-full loggers (please don't), -# then you need to move the object construction INTO the LayeredReposity and provide a helper to access it for everywhere. +# Using multiple is not be supported currently. +# Use only stateless loggers. has logger => sub { state $logger = SimpleLogger->new() }; -has smartArrayBackend => sub { - my $self = shift; - return SmartArray->new(logger => $self->logger); -}; - ## I moved this to helpers as app->attr for a while -has layeredRepository => sub { +has flatRepository => sub { my $self = shift; - $self->app->logger->info("Building layeredRepository"); + $self->app->logger->info("Building flatRepository"); + + my $mySQLLayer = RepositoryLayer->new( + name => 'mysql', + priority => 99, + creates_on_read => 1, + backendFactoryName => "MySQLDAOFactory", + logger => $self->logger, + handle => $self->db, + reset_data_callback => \&reset_db_data, + reset_data_callback_arguments => [$self->db], + ); - my $LR = LayeredRepository->new( + return FlatRepository->new( logger => $self->logger, preferences => $self->preferences, - - # id_provider_class => 'DummyUidProvider', - id_provider_class => 'IntegerUidProvider', + layer => $mySQLLayer ); - - my $smartArrayLayer = RepositoryLayer->new( - name => 'smart', - priority => 1, - creates_on_read => undef, - backendFactoryName => "SmartArrayDAOFactory", - logger => $self->logger, - handle => $self->smartArrayBackend, - -# reset_data_callback must be undef if you want to create and restore backups using Storable. - reset_data_callback => undef, - is_read => 1 - ); - $LR->add_layer($smartArrayLayer); - - if (!$self->db) { - $self->logger->error( - "You add SQL layer, but there is no connection to the database! Skipping this layer." - . " You need to start MySQL server and restart BibSpace to use this layer" - ); - } - else { - my $mySQLLayer = RepositoryLayer->new( - name => 'mysql', - priority => 99, - creates_on_read => 1, - backendFactoryName => "MySQLDAOFactory", - logger => $self->logger, - handle => $self->db, - reset_data_callback => \&reset_db_data, - reset_data_callback_arguments => [$self->db], - ); - $LR->add_layer($mySQLLayer); - } - return $LR; }; -# layeredRepository will not change at runtime => repo neither. has repo => sub { my $self = shift; - return RepositoryFacade->new(lr => $self->layeredRepository); - + return FlatRepositoryFacade->new(lr => $self->flatRepository); }; sub startup { my $self = shift; $self->app->logger->info("*** Starting BibSpace ***"); - $self->setup_config; $self->setup_plugins; + create_main_db($self->app->db); $self->app->preferences->local_time_zone( DateTime::TimeZone->new(name => 'local')->name); $self->setup_routes; $self->setup_hooks; - $self->setup_repositories; $self->insert_admin; $self->app->logger->info("Setup done."); @@ -260,57 +200,6 @@ sub insert_admin { return; } -sub setup_repositories { - my $self = shift; - - $self->app->logger->info("Setup repositories..."); - - if (-e $self->quick_load_fixture_filename and $self->use_quick_load_fixture) { - -# $self->app->logger->info("Retrieving dump from '".$self->quick_load_fixture_filename."'."); - my $layer = retrieve($self->quick_load_fixture_filename); - - # reser read layer = not needed, layer empty by start of the app - # $self->app->logger->info("Replacing layer 'smart' with the dump."); - $self->repo->lr->replace_layer('smart', $layer); - -# $self->app->logger->debug("State after replacement:".$self->repo->lr->get_summary_table); - } - else { - $self->app->logger->info( - "We do not use dump file '" . $self->quick_load_fixture_filename . "'."); - } - - # no data, no fun = no need to copy, link, and store - if ($self->repo->entries_empty) { - $self->app->logger->info("Repo has no entries. Reseting read_layer."); - - $self->repo->lr->copy_data({from => 'mysql', to => 'smart'}); - - # Entities and Relations in the smart layer must be linked! - $self->link_data; - - $self->app->logger->info("Storing current state to dump file '" - . $self->quick_load_fixture_filename - . "'."); - - # store current state to file - store $self->repo->lr->get_read_layer, $self->quick_load_fixture_filename; - } - return; -} - -sub link_data { - my $self = shift; - $self->app->logger->info("Linking data..."); - BibSpace::Backend::SmartBackendHelper::linkData($self->app); - - # BackendHelper::linkData($self->app); - # linkData($self->app); - $self->app->logger->info("Linking Finished."); - return; -} - sub setup_config { my $self = shift; my $app = $self; @@ -377,9 +266,9 @@ sub setup_routes { my $anyone = $self->routes; $anyone->get('/')->to('display#index')->name('start'); - $anyone->get('/forgot')->to('login#forgot'); + $anyone->get('/forgot')->to('login#forgot')->name('forgot_password'); $anyone->post('/forgot/gen')->to('login#post_gen_forgot_token'); - $anyone->get('/forgot/reset/:token')->to('login#token_clicked') + $anyone->get('/forgot/reset/<:token>')->to('login#token_clicked') ->name("token_clicked"); $anyone->post('/forgot/store')->to('login#store_password'); @@ -397,7 +286,8 @@ sub setup_routes { $anyone->get('/register')->to('login#register')->name('register'); $anyone->post('/register')->to('login#post_do_register') ->name('post_do_register'); - $anyone->any('/noregister')->to('login#register_disabled'); + $anyone->any('/noregister')->to('login#register_disabled') + ->name('registration_disabled'); my $logged_user = $anyone->under->to('login#check_is_logged_in'); my $manager_user = $logged_user->under->to('login#under_check_is_manager'); @@ -418,13 +308,7 @@ sub setup_routes { ->name('load_fixture'); $admin_user->get('/persistence/save')->to('persistence#save_fixture') ->name('save_fixture'); - $admin_user->get('/persistence/copy_mysql_to_smart') - ->to('persistence#copy_mysql_to_smart')->name('copy_mysql_to_smart'); - $admin_user->get('/persistence/copy_smart_to_mysql') - ->to('persistence#copy_smart_to_mysql')->name('copy_smart_to_mysql'); - $admin_user->get('/persistence/persistence_status') - ->to('persistence#persistence_status')->name('persistence_status'); $admin_user->get('/persistence/persistence_status_ajax') ->to('persistence#persistence_status_ajax') ->name('persistence_status_ajax'); @@ -436,23 +320,20 @@ sub setup_routes { $admin_user->get('/persistence/reset_all')->to('persistence#reset_all') ->name('reset_all'); - $admin_user->get('/persistence/insert_random_data') - ->to('persistence#insert_random_data')->name('insert_random_data'); - ################ SETTINGS ################ - $logged_user->get('/profile')->to('login#profile'); + $logged_user->get('/profile')->to('login#profile')->name('show_my_profile'); $admin_user->get('/manage_users')->to('login#manage_users') ->name('manage_users'); - $admin_user->get('/profile/:id')->to('login#foreign_profile') + $admin_user->get('/profile/<:id>')->to('login#foreign_profile') ->name('show_user_profile'); - $admin_user->get('/profile/delete/:id')->to('login#delete_user') + $admin_user->get('/profile/delete/<:id>')->to('login#delete_user') ->name('delete_user'); - $admin_user->get('/profile/make_user/:id')->to('login#make_user') + $admin_user->get('/profile/make_user/<:id>')->to('login#make_user') ->name('make_user'); - $admin_user->get('/profile/make_manager/:id')->to('login#make_manager') + $admin_user->get('/profile/make_manager/<:id>')->to('login#make_manager') ->name('make_manager'); - $admin_user->get('/profile/make_admin/:id')->to('login#make_admin') + $admin_user->get('/profile/make_admin/<:id>')->to('login#make_admin') ->name('make_admin'); $manager_user->get('/log')->to('display#show_log')->name('show_log'); @@ -460,9 +341,9 @@ sub setup_routes { ->name('show_stats'); # websocket for fun - $manager_user->websocket('/log_websocket/:num')->to('display#show_log_ws') + $manager_user->websocket('/log_websocket/<:num>')->to('display#show_log_ws') ->name('show_log_websocket'); - $manager_user->websocket('/statistics/:num') + $manager_user->websocket('/statistics/<:num>') ->to('display#show_stats_websocket')->name('show_stats_websocket'); $admin_user->get('/settings/fix_months')->to('publications#fixMonths') @@ -474,7 +355,7 @@ sub setup_routes { $manager_user->get('/settings/mark_all_to_regenerate') ->to('publications#mark_all_to_regenerate')->name('mark_all_to_regenerate'); - $manager_user->get('/settings/mark_author_to_regenerate/:author_id') + $manager_user->get('/settings/mark_author_to_regenerate/<:author_id>') ->to('publications#mark_author_to_regenerate') ->name('mark_author_to_regenerate'); @@ -482,22 +363,24 @@ sub setup_routes { ->to('publications#regenerate_html_for_all') ->name('regenerate_html_for_all'); - $logged_user->get('/settings/regenerate_html_in_chunk/:chunk_size') + $logged_user->get('/settings/regenerate_html_in_chunk/<:chunk_size>') ->to('publications#regenerate_html_in_chunk') ->name('regenerate_html_in_chunk'); $manager_user->get('/backups')->to('backup#index')->name('backup_index'); + + # Do default backup $manager_user->put('/backups')->to('backup#save')->name('backup_do'); $manager_user->put('/backups/mysql')->to('backup#save_mysql') ->name('backup_do_mysql'); $manager_user->put('/backups/json')->to('backup#save_json') ->name('backup_do_json'); - $manager_user->get('/backups/:id')->to('backup#backup_download') + $manager_user->get('/backups/<:id>')->to('backup#backup_download') ->name('backup_download'); - $admin_user->delete('/backups/:id')->to('backup#delete_backup') + $admin_user->delete('/backups/<:id>')->to('backup#delete_backup') ->name('backup_delete'); - $admin_user->put('/backups/:id')->to('backup#restore_backup') + $admin_user->put('/backups/<:id>')->to('backup#restore_backup') ->name('backup_restore'); $admin_user->delete('/backups')->to('backup#cleanup')->name('backup_cleanup'); @@ -506,19 +389,19 @@ sub setup_routes { $manager_user->get('/types/add')->to('types#add_type')->name('add_type_get'); $manager_user->post('/types/add')->to('types#post_add_type') ->name('add_type_post'); - $manager_user->get('/types/manage/:name')->to('types#manage') + $manager_user->get('/types/manage/<:name>')->to('types#manage') ->name('edit_type'); - $manager_user->get('/types/delete/:name')->to('types#delete_type') + $manager_user->get('/types/delete/<:name>')->to('types#delete_type') ->name('delete_type'); $manager_user->post('/types/store_description') ->to('types#post_store_description')->name('update_type_description'); - $manager_user->get('/types/toggle/:name')->to('types#toggle_landing') + $manager_user->get('/types/toggle/<:name>')->to('types#toggle_landing') ->name('toggle_landing_type'); - $manager_user->get('/types/:our_type/map/:bibtex_type') - ->to('types#map_types'); - $manager_user->get('/types/:our_type/unmap/:bibtex_type') + $manager_user->get('/types/<:our_type>/map/<:bibtex_type>') + ->to('types#map_types')->name('map_bibtex_type'); + $manager_user->get('/types/<:our_type>/unmap/<:bibtex_type>') ->to('types#unmap_types')->name('unmap_bibtex_type'); ################ AUTHORS ################ @@ -529,117 +412,109 @@ sub setup_routes { ->name('add_author'); $manager_user->post('/authors/add/')->to('authors#add_post'); - $logged_user->get('/authors/edit/:id')->to('authors#edit_author') + $logged_user->get('/authors/edit/<:id>')->to('authors#edit_author') ->name('edit_author'); $manager_user->post('/authors/edit/')->to('authors#edit_post') ->name('edit_author_post'); - $manager_user->get('/authors/delete/:id')->to('authors#delete_author') + $manager_user->get('/authors/delete/<:id>')->to('authors#delete_author') ->name('delete_author'); - $admin_user->get('/authors/delete/:id/force') - ->to('authors#delete_author_force'); - - # for dev only!! - $admin_user->get('/authors/decimate')->to('authors#delete_invisible_authors'); + $admin_user->get('/authors/delete/<:id>/force') + ->to('authors#delete_author_force')->name('delete_author_force'); $manager_user->post('/authors/edit_membership_dates') ->to('authors#post_edit_membership_dates') ->name('edit_author_membership_dates'); - $manager_user->get('/authors/:id/add_to_team/:tid') + $manager_user->get('/authors/<:id>/add_to_team/<:tid>') ->to('authors#add_to_team')->name('add_author_to_team'); - $manager_user->get('/authors/:id/remove_from_team/:tid') + $manager_user->get('/authors/<:id>/remove_from_team/<:tid>') ->to('authors#remove_from_team')->name('remove_author_from_team'); - $manager_user->get('/authors/:masterid/remove_uid/:uid') + $manager_user->get('/authors/<:master_id>/remove_uid/<:minor_id>') ->to('authors#remove_uid')->name('remove_author_uid'); $manager_user->post('/authors/merge/')->to('authors#merge_authors') ->name('merge_authors'); - $admin_user->get('/authors/fix_masters')->to('authors#fix_masters') - ->name('fix_masters'); - $manager_user->get('/authors/reassign') ->to('authors#reassign_authors_to_entries'); $admin_user->get('/authors/reassign_and_create') ->to('authors#reassign_authors_to_entries_and_create_authors'); - $manager_user->get('/authors/toggle_visibility/:id') + $manager_user->get('/authors/toggle_visibility/<:id>') ->to('authors#toggle_visibility')->name('toggle_author_visibility'); - # $logged_user->get('/authors/toggle_visibility') - # ->to('authors#toggle_visibility'); - ################ TAG TYPES ################ # $logged_user->get('/tags/')->to('tags#index')->name("tags_index"); $logged_user->get('/tagtypes')->to('tagtypes#index')->name('all_tag_types'); $admin_user->get('/tagtypes/add')->to('tagtypes#add')->name('add_tag_type'); $admin_user->post('/tagtypes/add')->to('tagtypes#add_post') ->name('add_tag_type_post'); - $admin_user->get('/tagtypes/delete/:id')->to('tagtypes#delete') + $admin_user->get('/tagtypes/delete/<:id>')->to('tagtypes#delete') ->name('delete_tag_type'); - $manager_user->any('/tagtypes/edit/:id')->to('tagtypes#edit') + $manager_user->any('/tagtypes/edit/<:id>')->to('tagtypes#edit') ->name('edit_tag_type'); ################ TAGS ################ - $logged_user->get('/tags/:type')->to('tags#index', type => 1) + $logged_user->get('/tags/<:type>')->to('tags#index', type => 1) ->name('all_tags'); - $admin_user->get('/tags/add/:type')->to('tags#add', type => 1) + $admin_user->get('/tags/add/<:type>')->to('tags#add', type => 1) ->name('add_tag_get'); - $admin_user->post('/tags/add/:type')->to('tags#add_post', type => 1) + $admin_user->post('/tags/add/<:type>')->to('tags#add_post', type => 1) ->name('add_tag_post'); - $logged_user->get('/tags/authors/:id/:type') + $logged_user->get('/tags/authors/<:id>/<:type>') ->to('tags#get_authors_for_tag', type => 1)->name('get_authors_for_tag'); - $admin_user->get('/tags/delete/:id')->to('tags#delete')->name('delete_tag'); + $admin_user->get('/tags/delete/<:id>')->to('tags#delete')->name('delete_tag'); ### EDIT TAG FORM GOES WITH GET - WTF!?! # FIXME: FIX THIS - $manager_user->get('/tags/edit/:id')->to('tags#edit')->name('edit_tag'); + $manager_user->get('/tags/edit/<:id>')->to('tags#edit')->name('edit_tag'); - $anyone->get('/read/authors-for-tag/:tag_id/:team_id') + $anyone->get('/read/authors-for-tag/<:tag_id>/<:team_id>') ->to('tags#get_authors_for_tag_and_team') ->name('get_authors_for_tag_and_team'); #ALIAS - $anyone->get('/r/a4t/:tag_id/:team_id') + $anyone->get('/r/a4t/<:tag_id>/<:team_id>') ->to('tags#get_authors_for_tag_and_team') ->name('get_authors_for_tag_and_team'); - $anyone->get('/read/authors-for-tag/:tag_id/:team_id') + $anyone->get('/read/authors-for-tag/<:tag_id>/<:team_id>') ->to('tags#get_authors_for_tag_and_team') ->name('get_authors_for_tag_and_team'); #ALIAS - $anyone->get('/r/a4t/:tag_id/:team_id') + $anyone->get('/r/a4t/<:tag_id>/<:team_id>') ->to('tags#get_authors_for_tag_and_team') ->name('get_authors_for_tag_and_team'); - $anyone->get('/read/tags-for-author/:author_id') + $anyone->get('/read/tags-for-author/<:author_id>') ->to('tags#get_tags_for_author_read')->name('tags_for_author'); #ALIAS - $anyone->get('/r/t4a/:author_id')->to('tags#get_tags_for_author_read'); + $anyone->get('/r/t4a/<:author_id>')->to('tags#get_tags_for_author_read'); - $anyone->get('/read/tags-for-team/:team_id') + $anyone->get('/read/tags-for-team/<:team_id>') ->to('tags#get_tags_for_team_read')->name('tags_for_team'); #ALIAS - $anyone->get('/r/t4t/:team_id')->to('tags#get_tags_for_team_read'); + $anyone->get('/r/t4t/<:team_id>')->to('tags#get_tags_for_team_read'); ################ TEAMS ################ $logged_user->get('/teams')->to('teams#show')->name('all_teams'); - $manager_user->get('/teams/edit/:id')->to('teams#edit')->name('edit_team'); - $manager_user->get('/teams/delete/:id')->to('teams#delete_team') + $manager_user->get('/teams/edit/<:id>')->to('teams#edit')->name('edit_team'); + $manager_user->get('/teams/delete/<:id>')->to('teams#delete_team') ->name('delete_team'); - $manager_user->get('/teams/delete/:id/force')->to('teams#delete_team_force') - ->name('delete_team_force'); - $logged_user->get('/teams/unrealted_papers/:teamid') + $manager_user->get('/teams/delete/<:id>/force') + ->to('teams#delete_team_force')->name('delete_team_force'); + $logged_user->get('/teams/<:teamid>/unrelated_papers') ->to('publications#show_unrelated_to_team') ->name('unrelated_papers_for_team'); $manager_user->get('/teams/add')->to('teams#add_team')->name('add_team_get'); - $manager_user->post('/teams/add/')->to('teams#add_team_post'); + $manager_user->post('/teams/add/')->to('teams#add_team_post') + ->name('add_team_post'); ################ EDITING PUBLICATIONS ################ #<<< no perltidy here @@ -664,11 +539,11 @@ sub setup_routes { # ->to('publications#all_ajax') # ->name('publications_ajax'); - $logged_user->get('/publications/recently_added/:num') + $logged_user->get('/publications/recently_added/<:num>') ->to('publications#all_recently_added') ->name('recently_added'); - $logged_user->get('/publications/recently_modified/:num') + $logged_user->get('/publications/recently_modified/<:num>') ->to('publications#all_recently_modified') ->name('recently_changed'); @@ -679,7 +554,7 @@ sub setup_routes { ->to('publications#delete_orphaned')->name('delete_orphaned'); - $logged_user->get('/publications/untagged/:tagtype') + $logged_user->get('/publications/untagged/<:tagtype>') ->to( 'publications#all_without_tag') ->name('get_untagged_publications'); @@ -690,7 +565,7 @@ sub setup_routes { $manager_user->get('/publications/missing_month') ->to('publications#all_with_missing_month'); - $logged_user->get('/publications/get/:id') + $logged_user->get('/publications/get/<:id>') ->to('publications#single') ->name('get_single_publication'); @@ -702,13 +577,10 @@ sub setup_routes { ->to('publications#download') ->name('download_publication_pdf'); - $anyone->get('/publications/download/:filetype/
" - . $self->app->repo->lr->get_summary_table - . ""; - - $self->flash( - msg_type => 'success', - msg => - "Backup restored successfully. Database recreated, persistence layers in sync. $status" - ); - } - else { - $self->flash( - msg_type => 'danger', - msg => "Cannot restore - backup not healthy!" - ); - } - $self->redirect_to('backup_index'); - return; -} - 1; diff --git a/lib/BibSpace/Controller/Cron.pm b/lib/BibSpace/Controller/Cron.pm index c74d79e..11a8233 100644 --- a/lib/BibSpace/Controller/Cron.pm +++ b/lib/BibSpace/Controller/Cron.pm @@ -123,7 +123,6 @@ sub cron_run { my $text_to_render; - ############ Cron ACTIONS if ($last_call_hours < $call_freq) { $text_to_render = "Cron level $level called too often. Last call $last_call_hours hours ago. Come back in $left hours\n"; @@ -133,7 +132,6 @@ sub cron_run { $text_to_render = "Cron level $level here\n"; } - ############ Cron ACTIONS $self->app->logger->info("Cron level $level started"); if ($level == 0) { @@ -164,32 +162,29 @@ sub cron_run { sub do_cron_day { my $self = shift; - - my $backup1 = do_storable_backup($self->app, "cron"); - + do_json_backup($self->app, "cron"); + return 1; } sub do_cron_night { - my $self = shift; - + my $self = shift; my @entries = $self->app->repo->entries_all; - for my $e (@entries) { $e->regenerate_html(0, $self->app->bst, $self->app->bibtexConverter); } + return 1; } sub do_cron_week { my $self = shift; - - my $backup1 = do_mysql_backup($self->app, "cron"); - my $num_deleted = delete_old_backups($self->app); - + do_mysql_backup($self->app, "cron"); + delete_old_backups($self->app); + return 1; } sub do_cron_month { my $self = shift; - + return 1; } sub log_cron_usage { @@ -233,27 +228,4 @@ sub get_last_cron_run { return $diff; } -# sub get_last_cron_run_in_hours { -# my $self = shift; -# my $level = shift; - -# my $last_call_str = $self->app->preferences->cron_get($level); -# return 0 if !$last_call_str; - -# my $now = DateTime->now->set_time_zone($self->app->preferences->local_time_zone); -# my $last_call; -# try{ -# $last_call = DateTime::Format::HTTP->parse_datetime( $last_call_str ); -# } -# catch{ -# warn; -# $self->app->logger->error("Cannot parse date of last cron usage. Parser got input: '$last_call_str', error: $_ "); -# }; -# return 0 if !$last_call; - -# my $diff = $now->subtract_datetime($last_call); -# my $hours = $diff->hours; -# return $hours; -# } - 1; diff --git a/lib/BibSpace/Controller/Helpers.pm b/lib/BibSpace/Controller/Helpers.pm index e919c76..5359a97 100644 --- a/lib/BibSpace/Controller/Helpers.pm +++ b/lib/BibSpace/Controller/Helpers.pm @@ -26,25 +26,14 @@ sub register { my ($self, $app) = @_; -# this must be a helper, -# because smartIDprovider can be exchanged during system lifetime (e.g. restore backup), -# so the reference must always point to the currently valid id provider -# smartIDProvider must be instantiated INSIDE LayeredRepository - $app->helper( - smartIDProvider => sub { - my $self = shift; - return $self->app->layeredRepository->uidProvider; - } - ); - # this must be a helper, # because entityFactory can be exchanged during system lifetime (e.g. restore backup), # so the reference must always point to the currently valid id provider -# entityFactory must be instantiated INSIDE LayeredRepository +# entityFactory must be instantiated INSIDE flatRepository $app->helper( entityFactory => sub { my $self = shift; - return $self->app->layeredRepository->e_factory; + return $self->app->flatRepository->e_factory; } ); @@ -262,7 +251,7 @@ sub register { my $type = shift // 1; my $paper = $self->app->repo->entries_find(sub { $_->id == $eid }); - my @tags = $paper->get_tags($type); + my @tags = $paper->get_tags_of_type($type); @tags = sort { $a->name cmp $b->name } @tags; return @tags; } @@ -275,7 +264,7 @@ sub register { my $type = shift // 1; my $paper = $self->app->repo->entries_find(sub { $_->id == $eid }); - my %has_tags = map { $_ => 1 } $paper->get_tags($type); + my %has_tags = map { $_ => 1 } $paper->get_tags_of_type($type); my @all_tags = $self->app->repo->tags_filter(sub { $_->type == $type }); my @unassigned = grep { not $has_tags{$_} } @all_tags; @unassigned = sort { $a->name cmp $b->name } @unassigned; @@ -287,9 +276,6 @@ sub register { num_authors => sub { my $self = shift; return $self->app->repo->authors_count; - - # return $self->storage->authors_all; - } ); @@ -328,9 +314,7 @@ sub register { my $author = shift; my $tag = shift; - return - scalar $author->authorships_filter( - sub { defined $_ and defined $_->entry and $_->entry->has_tag($tag) }); + return scalar grep { $_->has_tag($tag) } $author->get_entries; } ); @@ -338,7 +322,7 @@ sub register { num_pubs_for_tag => sub { my $self = shift; my $tag = shift; - return $tag->labelings_count // 0; + return scalar $tag->get_entries // 0; } ); diff --git a/lib/BibSpace/Controller/Login.pm b/lib/BibSpace/Controller/Login.pm index b458376..cdafed0 100644 --- a/lib/BibSpace/Controller/Login.pm +++ b/lib/BibSpace/Controller/Login.pm @@ -200,11 +200,6 @@ sub profile { $self->render(template => 'login/profile'); } -sub index { - my $self = shift; - $self->render(template => 'login/index'); -} - sub forgot { my $self = shift; $self->app->logger->info("Forgot password form opened"); @@ -238,49 +233,46 @@ sub post_gen_forgot_token { msg_type => 'warning', msg => "User '$login' or email '$email' does not exist. Try again." ); - $self->redirect_to('forgot'); + $self->redirect_to($self->url_for('forgot_password')); return; } - else { - # store token in the user object - $user->forgot_token(generate_token); - - my $email_content = $self->render_to_string('email_forgot_password', - token => $user->forgot_token); - try { - my %email_config = ( - mailgun_domain => $self->app->config->{mailgun_domain}, - mailgun_key => $self->app->config->{mailgun_key}, - from => $self->app->config->{mailgun_from}, - to => $user->email, - content => $email_content, - subject => 'BibSpace password reset request' - ); - send_email(\%email_config); - } - catch { - $self->app->logger->warn( - "Could not sent Email with Mailgun. This is okay for test, but not for production. Error: $_ ." - ); - }; - $self->app->logger->info("Forgot-password-token '" - . $user->forgot_token - . "' sent to '" - . $user->email - . "'."); + # store token in the user object + $user->set_forgot_pass_token(generate_token); + $self->app->repo->users_update($user); - $self->flash( - msg_type => 'info', - msg => - "Email with password reset instructions has been sent. Expect an email from " - . $self->app->config->{mailgun_from} + my $email_content = $self->render_to_string('email_forgot_password', + token => $user->get_forgot_pass_token); + try { + my %email_config = ( + mailgun_domain => $self->app->config->{mailgun_domain}, + mailgun_key => $self->app->config->{mailgun_key}, + from => $self->app->config->{mailgun_from}, + to => $user->email, + content => $email_content, + subject => 'BibSpace password reset request' ); - $self->redirect_to('/'); - + send_email(\%email_config); } + catch { + $self->app->logger->warn("Could not sent Email with Mailgun. Error: $_ ."); + }; + + $self->app->logger->info("Forgot-password-token '" + . $user->get_forgot_pass_token + . "' sent to '" + . $user->email + . "'."); + + $self->flash( + msg_type => 'info', + msg => + "Email with password reset instructions has been sent. Expect an email from " + . $self->app->config->{mailgun_from} + ); + $self->redirect_to('start'); + return; - $self->redirect_to('forgot'); } sub token_clicked { @@ -302,7 +294,11 @@ sub store_password { my $user; if ($token) { $user = $self->app->repo->users_find( - sub { defined $_->forgot_token and $_->forgot_token eq $token }); + sub { + defined $_->get_forgot_pass_token + and $_->get_forgot_pass_token eq $token; + } + ); } if (!$user) { @@ -323,7 +319,8 @@ sub store_password { my $password_hash = encrypt_password($pass1, $salt); $user->pass($password_hash); $user->pass2($salt); - $user->forgot_token(""); + $user->reset_forgot_token; + $self->app->repo->users_update($user); $self->flash( msg_type => 'success', msg => @@ -377,7 +374,7 @@ sub login { $user->record_logging_in; $self->app->logger->info("Login as '$input_login' success."); - $self->redirect_to('/'); + $self->redirect_to('start'); return; } else { @@ -460,7 +457,7 @@ sub register { return; } else { - $self->redirect_to('/noregister'); + $self->redirect_to('registration_disabled'); } } @@ -474,7 +471,7 @@ sub post_do_register { my $password2 = $self->param('password2'); if (!$self->can_register) { - $self->redirect_to('/noregister'); + $self->redirect_to('registration_disabled'); return; } @@ -504,7 +501,7 @@ sub post_do_register { msg_type => 'success', msg => "User created successfully! You may now login using login: $login." ); - $self->redirect_to('/'); + $self->redirect_to('start'); } catch { $failure_reason = $_; diff --git a/lib/BibSpace/Controller/Persistence.pm b/lib/BibSpace/Controller/Persistence.pm index 3f116e3..a5d67f0 100644 --- a/lib/BibSpace/Controller/Persistence.pm +++ b/lib/BibSpace/Controller/Persistence.pm @@ -11,25 +11,13 @@ use Try::Tiny; use Data::Dumper; use BibSpace::Functions::MySqlBackupFunctions; +use BibSpace::Functions::BackupFunctions qw/restore_json_backup/; use BibSpace::Functions::Core; use BibSpace::Model::Backup; -use BibSpace::Functions::BackupFunctions qw(restore_storable_backup); use BibSpace::Functions::FDB; use Mojo::Base 'Mojolicious::Controller'; -sub persistence_status { - my $self = shift; - - my $status - = "Status:
" - . $self->app->repo->lr->get_summary_table - . ""; - $self->stash(msg_type => 'success', msg => $status); - $self->flash(msg_type => 'success', msg => $status); - $self->redirect_to($self->get_referrer); -} - sub persistence_status_ajax { my $self = shift; @@ -38,13 +26,13 @@ sub persistence_status_ajax { . $self->app->repo->lr->get_summary_table . ""; $self->render(text => $status); - } sub load_fixture { my $self = shift; - my $fixture_file = $self->app->home->rel_file('fixture/bibspace_fixture.dat'); + my $fixture_file + = $self->app->home->rel_file('fixture/bibspace_fixture.json'); $self->app->logger->info("Loading fixture from: " . $fixture_file->to_string); my $fixture = Backup->new( @@ -52,7 +40,7 @@ sub load_fixture { filename => '' . $fixture_file->basename ); - restore_storable_backup($fixture, $self->app); + restore_json_backup($fixture, $self->app); my $status = "Status:
" @@ -70,20 +58,20 @@ sub save_fixture { $self->app->logger->warn("PERSISTENCE CONTROLLER does: save_fixture"); - my $fixture_file = $self->app->home->rel_file('fixture/bibspace_fixture.dat'); + my $fixture_file + = $self->app->home->rel_file('fixture/bibspace_fixture.json'); - my $backup = Backup->create('dummy', "storable"); + my $backup = Backup->create('dummy', "json"); $backup->dir('' . $fixture_file->dirname); $backup->filename('' . $fixture_file->basename); my $layer = $self->app->repo->lr->get_read_layer; my $path = "" . $backup->get_path; - $Storable::forgive_me = "do store regexp please, we will not use them anyway"; - -# if you see any exceptions being thrown here, this might be due to REGEXP caused by DateTime pattern. -# this should not happen currently however - I think it is fixed now. - Storable::store $layer, $path; + # Doing backup + my $dtoObject = BibSpaceDTO->fromLayeredRepo($self->app->repo); + my $jsonString = $dtoObject->toJSON; + Path::Tiny::path($backup->get_path)->spew($jsonString); my $status = "Status:" @@ -96,141 +84,6 @@ sub save_fixture { $self->redirect_to($self->get_referrer); } -sub copy_mysql_to_smart { - my $self = shift; - - $self->app->logger->warn("PERSISTENCE CONTROLLER does: copy_mysql_to_smart"); - - $self->app->repo->lr->copy_data({from => 'mysql', to => 'smart'}); - $self->app->link_data; - - my $status - = "Status:" - . $self->app->repo->lr->get_summary_table - . ""; - $self->flash(msg_type => 'success', msg => "Copied mysql => smart. $status"); - $self->redirect_to($self->get_referrer); -} - -sub copy_smart_to_mysql { - my $self = shift; - - $self->app->repo->lr->copy_data({from => 'smart', to => 'mysql'}); - - my $status - = "Status:" - . $self->app->repo->lr->get_summary_table - . ""; - $self->flash(msg_type => 'success', msg => "Copied smart => mysql. $status"); - $self->redirect_to($self->get_referrer); -} - -sub insert_random_data { - my $self = shift; - my $num = $self->param('num') // 300; - - my $str_len = 60; - - for (1 .. $num) { - my $obj = $self->app->entityFactory->new_User( - login => random_string($str_len), - email => random_string($str_len) . '@example.com', - real_name => random_string($str_len), - pass => random_string($str_len), - pass2 => random_string($str_len) - - ); - $self->app->repo->users_save($obj); - - $obj - = $self->app->entityFactory->new_Author(uid => random_string($str_len),); - $self->app->repo->authors_save($obj); - - $obj - = $self->app->entityFactory->new_Entry(bib => random_string($str_len),); - $self->app->repo->entries_save($obj); - - $obj - = $self->app->entityFactory->new_TagType(name => random_string($str_len), - ); - $self->app->repo->tagTypes_save($obj); - - my $tt = ($self->app->repo->tagTypes_all)[0]; - - $obj = $self->app->entityFactory->new_Tag( - name => random_string($str_len), - type => $tt->id - ); - $self->app->repo->tags_save($obj); - - $obj - = $self->app->entityFactory->new_Team(name => random_string($str_len),); - $self->app->repo->teams_save($obj); - } - - my $status - = "Status:" - . $self->app->repo->lr->get_summary_table - . ""; - $self->flash(msg_type => 'success', msg => "Copied smart => mysql. $status"); - $self->redirect_to($self->get_referrer); -} - -sub reset_smart { - my $self = shift; - - $self->app->logger->warn("PERSISTENCE CONTROLLER does: reset_smart"); - - my $layer = $self->app->repo->lr->get_layer('smart'); - if ($layer) { - $layer->reset_data; - } - - # no pub_admin user would lock the whole system - # if you insert it here, it may will cause clash of IDs - # $self->app->insert_admin; - # instead, do not insert admin and set system in demo mode - $self->app->preferences->run_in_demo_mode(1); - - say "setting preferences->run_in_demo_mode to: '" - . $self->app->preferences->run_in_demo_mode . "'"; - - my $status - = "Status:" - . $self->app->repo->lr->get_summary_table - . ""; - $self->flash(msg_type => 'success', msg => $status); - $self->redirect_to($self->get_referrer); -} - -sub reset_mysql { - my $self = shift; - - $self->app->logger->warn("PERSISTENCE CONTROLLER does: reset_mysql"); - - my $layer = $self->app->repo->lr->get_layer('mysql'); - if ($layer) { - $layer->reset_data; - my $status - = "Status:" - . $self->app->repo->lr->get_summary_table - . ""; - $self->flash(msg_type => 'success', msg => $status); - } - else { - my $status - = "Status:" - . $self->app->repo->lr->get_summary_table - . ""; - $self->flash( - msg_type => 'danger', - msg => "Reset failed - backend handle undefined. " . $status - ); - } - - $self->redirect_to($self->get_referrer); -} - sub reset_all { my $self = shift; @@ -238,7 +91,6 @@ sub reset_all { my @layers = $self->app->repo->lr->get_all_layers; foreach (@layers) { $_->reset_data } - $self->app->repo->lr->reset_uid_providers; # no pub_admin user would lock the whole system # if you insert it here, it may will cause clash of IDs diff --git a/lib/BibSpace/Controller/Preferences.pm b/lib/BibSpace/Controller/Preferences.pm index b9547d6..5ab925c 100644 --- a/lib/BibSpace/Controller/Preferences.pm +++ b/lib/BibSpace/Controller/Preferences.pm @@ -11,7 +11,6 @@ use Try::Tiny; use Data::Dumper; use Mojo::Base 'Mojolicious::Controller'; -use Storable; use BibSpace::Functions::Core; use BibSpace::Util::Preferences; diff --git a/lib/BibSpace/Controller/Publications.pm b/lib/BibSpace/Controller/Publications.pm index df855f3..4655081 100644 --- a/lib/BibSpace/Controller/Publications.pm +++ b/lib/BibSpace/Controller/Publications.pm @@ -112,7 +112,8 @@ sub all_without_tag { # this will filter entries based on query my @all = Fget_publications_main_hashed_args($self, {year => undef}); - my @untagged_entries = grep { scalar $_->get_tags($tagtype) == 0 } @all; + my @untagged_entries + = grep { scalar $_->get_tags_of_type($tagtype) == 0 } @all; my @filtered = Fget_publications_main_hashed_args($self, {}, \@untagged_entries); @@ -362,11 +363,11 @@ sub delete_orphaned { = $self->app->repo->entries_filter(sub { scalar($_->get_authors) == 0 }); foreach my $entry (@entries) { - my @au = $entry->authorships_all; + my @au = $entry->get_authorships; $self->app->repo->authorships_delete(@au); - my @ex = $entry->exceptions_all; + my @ex = $entry->get_exceptions; $self->app->repo->exceptions_delete(@ex); - my @la = $entry->labelings_all; + my @la = $entry->get_labelings; $self->app->repo->labelings_delete(@la); } @@ -386,7 +387,7 @@ sub fix_file_urls { my @all_entries; - if ($id) { + if ($id and $id > 0) { my $entry = $self->app->repo->entries_find(sub { $_->id == $id }); push @all_entries, $entry if $entry; } @@ -402,17 +403,15 @@ sub fix_file_urls { ++$num_checks; my $str; - $str .= "Entry " . $entry->id . ": "; $entry->discover_attachments($self->app->get_upload_dir); my @discovered_types = $entry->attachments_keys; - $str .= "has types: ("; - foreach (@discovered_types) { - $str .= " $_, "; - } - $str .= "). Fixed: "; + $str .= "Entry " . $entry->id . ": "; + $str + .= "with types: (" + . join(" ", @discovered_types) + . "). Fixed the following: "; - # say $str; my $fixed; my $file = $entry->get_attachment('paper'); my $file_url = $self->url_for( @@ -426,7 +425,7 @@ sub fix_file_urls { $str .= "\n\t"; $entry->add_bibtex_field("pdf", "$file_url"); $fixed = 1; - $str .= "Added Bibtex filed PDF " . $file_url; + $str .= "Added Bibtex field 'pdf = { " . $file_url . "}'"; } $file = $entry->get_attachment('slides'); @@ -441,7 +440,7 @@ sub fix_file_urls { $str .= "\n\t"; $entry->add_bibtex_field("slides", "$file_url"); $fixed = 1; - $str .= "Added Bibtex filed SLIDES " . $file_url; + $str .= "Added Bibtex field 'slides = { " . $file_url . "}'"; } $str .= "\n"; @@ -845,9 +844,9 @@ sub delete_sure { } $entry->delete_all_attachments; - my @entry_authorships = $entry->authorships_all; - my @entry_labelings = $entry->labelings_all; - my @entry_exceptions = $entry->exceptions_all; + my @entry_authorships = $entry->get_authorships; + my @entry_labelings = $entry->get_labelings; + my @entry_exceptions = $entry->get_exceptions; $self->app->repo->authorships_delete(@entry_authorships); $self->app->repo->labelings_delete(@entry_labelings); $self->app->repo->exceptions_delete(@entry_exceptions); @@ -870,7 +869,7 @@ sub show_authors_of_entry { return; } - my @authors = map { $_->author } $entry->authorships_all; + my @authors = $entry->get_authors; my @teams = $entry->get_teams; $self->stash(entry => $entry, authors => \@authors, teams => \@teams); @@ -908,9 +907,7 @@ sub remove_tag { if (defined $entry and defined $tag) { - my $search_label = Labeling->new( - entry => $entry, - tag => $tag, + my $search_label = $self->app->repo->entityFactory->new_Labeling( entry_id => $entry->id, tag_id => $tag->id ); @@ -952,9 +949,7 @@ sub add_tag { my $tag = $self->app->repo->tags_find(sub { $_->id == $tag_id }); if (defined $entry and defined $tag) { - my $label = Labeling->new( - entry => $entry, - tag => $tag, + my $label = $self->app->repo->entityFactory->new_Labeling( entry_id => $entry->id, tag_id => $tag->id ); @@ -986,7 +981,7 @@ sub manage_exceptions { return; } - my @exceptions = $entry->exceptions_all; + my @exceptions = $entry->get_exceptions; my @all_teams = $self->app->repo->teams_all; my @teams = $entry->get_teams; my @authors = $entry->get_authors; @@ -1017,7 +1012,7 @@ sub add_exception { if (defined $entry and defined $team) { - my $exception = Exception->new( + my $exception = $self->app->repo->entityFactory->new_Exception( entry => $entry, team => $team, entry_id => $entry->id, @@ -1060,11 +1055,9 @@ sub remove_exception { if (defined $entry and defined $team) { - my $ex = Exception->new( + my $ex = $self->app->repo->entityFactory->new_Exception( team_id => $team_id, entry_id => $entry_id, - team => $team, - entry => $entry ); my $exception = $self->app->repo->exceptions_find(sub { $_->equals($ex) }); @@ -1228,6 +1221,7 @@ sub publications_add_post { # any action my $existing_entry = $self->app->repo->entries_find( sub { $_->bibtex_key eq $entry->bibtex_key }); + if ($existing_entry) { $status_code_str = 'KEY_TAKEN'; my $msg_type = 'danger'; @@ -1269,7 +1263,7 @@ sub publications_add_post { $added_under_id = $entry->id; ## !!! the entry must be added before executing Freassign_authors_to_entries_given_by_array - ## why? beacuse authorship will be unable to map existing entry to the author + ## why? because authorship will be unable to map existing entry to the author Freassign_authors_to_entries_given_by_array($self->app, 1, [$entry]); my $msg_type = 'success'; diff --git a/lib/BibSpace/Controller/PublicationsExperimental.pm b/lib/BibSpace/Controller/PublicationsExperimental.pm index 02244ef..53cbab9 100644 --- a/lib/BibSpace/Controller/PublicationsExperimental.pm +++ b/lib/BibSpace/Controller/PublicationsExperimental.pm @@ -4,7 +4,6 @@ use Data::Dumper; use utf8; use Text::BibTeX; # parsing bib files use DateTime; -use Path::Tiny; # for creating directories use Try::Tiny; use v5.16; #because of ~~ diff --git a/lib/BibSpace/Controller/Tags.pm b/lib/BibSpace/Controller/Tags.pm index 04cbd4f..1d774da 100644 --- a/lib/BibSpace/Controller/Tags.pm +++ b/lib/BibSpace/Controller/Tags.pm @@ -191,7 +191,7 @@ sub get_tags_for_author_read { my $count = scalar @objs; my $url = $self->url_for('lyp')->query( - author => $author->{master}, + author => $author->master->name, tag => $tag_name, title => '1', navbar => '1' @@ -241,8 +241,10 @@ sub get_tags_for_team_read { foreach my $paper (@team_entries) { # merge two hashes - %team_tags_hash = (%team_tags_hash, - map { "" . $_->name => $_ } $paper->get_tags($tag_type)); + %team_tags_hash = ( + %team_tags_hash, + map { "" . $_->name => $_ } $paper->get_tags_of_type($tag_type) + ); } my @team_tags = values %team_tags_hash; @@ -300,10 +302,10 @@ sub get_authors_for_tag { return; } - my @papers = map { $_->entry } $tag->labelings_all; + my @papers = map { $_->entry } $tag->get_labelings; my @authors; foreach my $paper (@papers) { - my @subset_authors = map { $_->author } $paper->authorships_all; + my @subset_authors = map { $_->author } $paper->get_authorships; push @subset_authors, @authors; } if (!@authors) { @@ -326,20 +328,8 @@ sub delete { if ($tag) { my $name = $tag->name; - ## TODO: refactor these blocks nicely! - ## Deleting labelings - my @labelings = $tag->labelings_all; - - # for each entry, remove labeling in this team - foreach my $labeling (@labelings) { - $labeling->entry->remove_labeling($labeling); - } + my @labelings = $tag->get_labelings; $self->app->repo->labelings_delete(@labelings); - - # remove all labelings for this team - $tag->labelings_clear; - - # finally delete tag $self->app->repo->tags_delete($tag); $self->flash(msg_type => 'success', msg => "Tag $name has been deleted."); diff --git a/lib/BibSpace/Controller/Teams.pm b/lib/BibSpace/Controller/Teams.pm index b1e761d..6ce3ec4 100644 --- a/lib/BibSpace/Controller/Teams.pm +++ b/lib/BibSpace/Controller/Teams.pm @@ -121,7 +121,7 @@ sub do_delete_team { my $team = shift; ## Deleting memberships - my @memberships = $team->memberships_all; + my @memberships = $team->get_memberships; # for each team, remove membership in this team foreach my $membership (@memberships) { diff --git a/lib/BibSpace/Controller/Types.pm b/lib/BibSpace/Controller/Types.pm index 0347f10..446346e 100644 --- a/lib/BibSpace/Controller/Types.pm +++ b/lib/BibSpace/Controller/Types.pm @@ -13,9 +13,6 @@ use Mojo::Base 'Mojolicious::Controller'; use Mojo::Base 'Mojolicious::Plugin::Config'; use Mojo::Log; -# ALTER TABLE OurType_to_Type ADD COLUMN description TEXT DEFAULT NULL; -# ALTER TABLE OurType_to_Type ADD COLUMN landing INTEGER DEFAULT 0; - sub all_our { my $self = shift; @@ -36,8 +33,15 @@ sub post_add_type { my $new_type = $self->param('new_type'); my $type = $self->app->entityFactory->new_Type(our_type => $new_type); - $self->app->repo->types_save($type); + # Databse requires that each type must have at least one bibtex_type + $type->bibtexTypes_add('dummy'); + $self->app->repo->types_save($type); + $self->flash( + msg_type => 'warning', + message => + "Type $new_type has been added and mapped onto dummy bibtex type." + ); $self->redirect_to($self->url_for('all_types')); } @@ -94,7 +98,7 @@ sub post_store_description { $type_obj->description($description); $self->app->repo->types_update($type_obj); } - $self->redirect_to($self->get_referrer); + $self->redirect_to($self->url_for('edit_type', name => $type_name)); } sub delete_type { @@ -118,7 +122,7 @@ sub delete_type { "$type_name cannot be deleted. Possible reasons: mappings exist or it is native bibtex type." ); } - $self->redirect_to($self->get_referrer); + $self->redirect_to($self->url_for('all_types')); } sub map_types { @@ -158,7 +162,7 @@ sub map_types { msg_type => 'danger' ); } - $self->redirect_to($self->get_referrer); + $self->redirect_to($self->url_for('edit_type', name => $o_type)); } sub unmap_types { @@ -197,8 +201,7 @@ sub unmap_types { msg_type => 'danger' ); } - $self->redirect_to($self->get_referrer); - + $self->redirect_to($self->url_for('edit_type', name => $o_type)); } 1; diff --git a/lib/BibSpace/Converter/BibStyleConverter.pm b/lib/BibSpace/Converter/BibStyleConverter.pm index 0353339..fdc9bb8 100644 --- a/lib/BibSpace/Converter/BibStyleConverter.pm +++ b/lib/BibSpace/Converter/BibStyleConverter.pm @@ -403,7 +403,7 @@ sub delatexify { =item string_replace_with_counting uses counting to do strin replace - Example: + Example: single runn of 'string_replace_with_counting' with parameters s = aaa{bbb{cc{dd}}} opening = { @@ -413,11 +413,11 @@ sub delatexify { opening_replace = '' closing replace = '' returns: aaa{bbb{ccdd}} - next run: + next run: returns: aaa{bbbccdd} - next run: + next run: returns: aaabbbccdd -=cut +=cut sub string_replace_with_counting { my ($s, $opening, $closing, $avoid_l, $avoid_r, $opening_replace, diff --git a/lib/BibSpace/DAO/DAOFactory.pm b/lib/BibSpace/DAO/DAOFactory.pm index 99b3271..1f016a9 100644 --- a/lib/BibSpace/DAO/DAOFactory.pm +++ b/lib/BibSpace/DAO/DAOFactory.pm @@ -6,8 +6,6 @@ use namespace::autoclean; use Moose; use BibSpace::Util::ILogger; use BibSpace::DAO::MySQLDAOFactory; -use BibSpace::DAO::RedisDAOFactory; -use BibSpace::DAO::SmartArrayDAOFactory; use BibSpace::Util::EntityFactory; diff --git a/lib/BibSpace/DAO/Interface/IDAO.pm b/lib/BibSpace/DAO/Interface/IDAO.pm index f9160f9..2527f8a 100644 --- a/lib/BibSpace/DAO/Interface/IDAO.pm +++ b/lib/BibSpace/DAO/Interface/IDAO.pm @@ -29,7 +29,6 @@ has 'logger' => (is => 'ro', does => 'ILogger', required => 1); # e.g. database connection handle has 'handle' => (is => 'ro', required => 1, traits => ['DoNotSerialize']); - has 'e_factory' => (is => 'ro', isa => 'EntityFactory', required => 1); 1; diff --git a/lib/BibSpace/DAO/MySQL/AuthorMySQLDAO.pm b/lib/BibSpace/DAO/MySQL/AuthorMySQLDAO.pm index 76d85f2..3817acb 100644 --- a/lib/BibSpace/DAO/MySQL/AuthorMySQLDAO.pm +++ b/lib/BibSpace/DAO/MySQL/AuthorMySQLDAO.pm @@ -22,16 +22,15 @@ use Time::HiRes qw( gettimeofday tv_interval ); =item all Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub all { my ($self) = @_; my $dbh = $self->handle; - my $qry = "SELECT + my $qry = "SELECT id, uid, display, - master, master_id FROM Author"; my @objs; @@ -44,17 +43,9 @@ sub all { id => $row->{id}, uid => $row->{uid}, display => $row->{display}, - master => $row->{master}, master_id => $row->{master_id} ); - # if( $obj->{master_id} != $obj->{id} ){ - # $obj->{masterObj} = MAuthor->static_get($dbh, $obj->{master_id}); - # } - # else{ - # $obj->{masterObj} = $obj; - # } - # FIXME: Temporary fix. This should be fixed with a join! $obj->{masterObj} = undef; $obj->id; # due to lazy filling of this field @@ -69,7 +60,7 @@ after 'all' => sub { shift->logger->exiting(""); }; =item count Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub count { my ($self) = @_; @@ -86,7 +77,7 @@ after 'count' => sub { shift->logger->exiting(""); }; =item empty Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub empty { my ($self) = @_; @@ -94,8 +85,8 @@ sub empty { my $sth = $dbh->prepare("SELECT 1 as num FROM Author LIMIT 1"); $sth->execute(); my $row = $sth->fetchrow_hashref(); - my $num = $row->{num} // 0; - return $num == 0; + return 1 if not defined $row; + return; } before 'empty' => sub { shift->logger->entering(""); }; after 'empty' => sub { shift->logger->exiting(""); }; @@ -103,7 +94,7 @@ after 'empty' => sub { shift->logger->exiting(""); }; =item exists Method documentation placeholder. This method takes single object as argument and returns a scalar. -=cut +=cut sub exists { my ($self, $object) = @_; @@ -111,9 +102,9 @@ sub exists { my $dbh = $self->handle; my $sth = $dbh->prepare( "SELECT EXISTS(SELECT 1 FROM Author WHERE id=? LIMIT 1) as num "); - $sth->execute($object->id); - my $row = $sth->fetchrow_hashref(); - my $num = $row->{num} // 0; + my $result = $sth->execute($object->id); + my $row = $sth->fetchrow_hashref(); + my $num = $row->{num} // 0; return $num > 0; } @@ -123,7 +114,7 @@ after 'exists' => sub { shift->logger->exiting(""); }; =item save Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub save { my ($self, @objects) = @_; @@ -150,7 +141,7 @@ after 'save' => sub { shift->logger->exiting(""); }; =item _insert Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub _insert { my ($self, @objects) = @_; @@ -159,62 +150,71 @@ sub _insert { INSERT INTO Author( id, uid, - master_id, - master, - display - ) - VALUES (?,?,?,?,?);"; + display, + master_id + ) + VALUES (?,?,?,?);"; my $sth = $dbh->prepare($qry); my $added = 0; foreach my $obj (@objects) { + my $id = undef; + my $master_id = undef; + $id = $obj->id if defined $obj->id and $obj->id > 0; + $master_id = $obj->get_master_id + if defined $obj->get_master_id and $obj->get_master_id > 0; try { - my $result - = $sth->execute($obj->id, $obj->uid, $obj->master_id, $obj->master, - $obj->display); - ++$added; + $added += $sth->execute($id, $obj->uid, $obj->display, $master_id); + my $inserted_id = $sth->{mysql_insertid}; + $obj->id($inserted_id); + if (not $master_id) { + + # sets master_id if unset + $obj->get_master_id; + + # This updates master_id to point to i + $obj->repo->authors_update($obj); + } } catch { - $self->logger->error("Insert exception: $_"); + $self->logger->error("Author insert exception: $_"); }; } return $added; - - # $dbh->commit(); } -before '_insert' => sub { shift->logger->entering(""); }; -after '_insert' => sub { shift->logger->exiting(""); }; =item update Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub update { my ($self, @objects) = @_; - my $dbh = $self->handle; + my $dbh = $self->handle; + my $success = 0; foreach my $obj (@objects) { next if !defined $obj->id; - # update field 'modified_time' only if needed my $qry = "UPDATE Author SET uid=?, master_id=?, - master=?, display=?"; $qry .= " WHERE id = ?"; my $sth = $dbh->prepare($qry); + my $result; try { - my $result = $sth->execute( - $obj->{uid}, $obj->{master_id}, $obj->{master}, - $obj->{display}, $obj->{id} - ); + $sth->execute($obj->uid, $obj->get_master_id, $obj->display, $obj->id); + $success = 1; } catch { + $success = 0; $self->logger->error("Update exception: $_"); }; } + + # Return for tests to signal that nothing has been thrown + return $success; } before 'update' => sub { shift->logger->entering(""); }; after 'update' => sub { shift->logger->exiting(""); }; @@ -222,29 +222,32 @@ after 'update' => sub { shift->logger->exiting(""); }; =item delete Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub delete { my ($self, @objects) = @_; - my $dbh = $self->handle; + my $dbh = $self->handle; + my $result = 0; foreach my $obj (@objects) { my $qry = "DELETE FROM Author WHERE id=?;"; my $sth = $dbh->prepare($qry); try { - my $result = $sth->execute($obj->id); + $result = $sth->execute($obj->id); } catch { + $result = 0; $self->logger->error("Delete exception: $_"); }; } - + return 1 if $result > 0; + return; } before 'delete' => sub { shift->logger->entering(""); }; after 'delete' => sub { shift->logger->exiting(""); }; =item filter Method documentation placeholder. -=cut +=cut sub filter { my ($self, $coderef) = @_; @@ -259,7 +262,7 @@ after 'filter' => sub { shift->logger->exiting(""); }; =item find Method documentation placeholder. -=cut +=cut sub find { my ($self, $coderef) = @_; diff --git a/lib/BibSpace/DAO/MySQL/AuthorshipMySQLDAO.pm b/lib/BibSpace/DAO/MySQL/AuthorshipMySQLDAO.pm index 29684f2..6fc3c33 100644 --- a/lib/BibSpace/DAO/MySQL/AuthorshipMySQLDAO.pm +++ b/lib/BibSpace/DAO/MySQL/AuthorshipMySQLDAO.pm @@ -22,7 +22,7 @@ use Time::HiRes qw( gettimeofday tv_interval ); =item all Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub all { my ($self) = @_; @@ -36,7 +36,7 @@ sub all { my @objects; while (my $row = $sth->fetchrow_hashref()) { - my $authorship = Authorship->new( + my $authorship = $self->e_factory->new_Authorship( author_id => $row->{author_id}, entry_id => $row->{entry_id} ); @@ -50,7 +50,7 @@ after 'all' => sub { shift->logger->exiting(""); }; =item count Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub count { my ($self) = @_; @@ -68,7 +68,7 @@ after 'count' => sub { shift->logger->exiting(""); }; =item empty Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub empty { my ($self) = @_; @@ -76,8 +76,8 @@ sub empty { my $sth = $dbh->prepare("SELECT 1 as num FROM Entry_to_Author LIMIT 1"); $sth->execute(); my $row = $sth->fetchrow_hashref(); - my $num = $row->{num} // 0; - return $num == 0; + return 1 if not defined $row; + return; } before 'empty' => sub { shift->logger->entering(""); }; after 'empty' => sub { shift->logger->exiting(""); }; @@ -85,7 +85,7 @@ after 'empty' => sub { shift->logger->exiting(""); }; =item exists Method documentation placeholder. This method takes single object as argument and returns a scalar. -=cut +=cut sub exists { my ($self, $object) = @_; @@ -105,7 +105,7 @@ after 'exists' => sub { shift->logger->exiting(""); }; =item save Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub save { my ($self, @objects) = @_; @@ -132,7 +132,7 @@ after 'save' => sub { shift->logger->exiting(""); }; =item _insert Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub _insert { my ($self, @objects) = @_; @@ -174,7 +174,7 @@ after '_insert' => sub { shift->logger->exiting(""); }; =item update Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub update { my ($self, @objects) = @_; @@ -194,28 +194,32 @@ after 'update' => sub { shift->logger->exiting(""); }; =item delete Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub delete { my ($self, @objects) = @_; - my $dbh = $self->handle; + my $dbh = $self->handle; + my $result = 0; foreach my $obj (@objects) { my $qry = "DELETE FROM Entry_to_Author WHERE entry_id=? AND author_id=?;"; my $sth = $dbh->prepare($qry); try { - my $result = $sth->execute($obj->entry_id, $obj->author_id); + $result = $sth->execute($obj->entry_id, $obj->author_id); } catch { + $result = 0; $self->logger->error("Delete exception: $_"); }; } + return 1 if $result > 0; + return; } before 'delete' => sub { shift->logger->entering(""); }; after 'delete' => sub { shift->logger->exiting(""); }; =item filter Method documentation placeholder. -=cut +=cut sub filter { my ($self, $coderef) = @_; @@ -230,7 +234,7 @@ after 'filter' => sub { shift->logger->exiting(""); }; =item find Method documentation placeholder. -=cut +=cut sub find { my ($self, $coderef) = @_; diff --git a/lib/BibSpace/DAO/MySQL/EntryMySQLDAO.pm b/lib/BibSpace/DAO/MySQL/EntryMySQLDAO.pm index 5676087..a27b661 100644 --- a/lib/BibSpace/DAO/MySQL/EntryMySQLDAO.pm +++ b/lib/BibSpace/DAO/MySQL/EntryMySQLDAO.pm @@ -22,7 +22,7 @@ use Time::HiRes qw( gettimeofday tv_interval ); =item all Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub all { my ($self) = @_; @@ -66,28 +66,16 @@ sub all { my $mt = $mysqlPattern->parse_datetime($row->{modified_time}); # set defaults if there is no data in mysql - $ct ||= DateTime->now() - ; # formatter => $mysqlPattern); # do not store pattern! - it is incompat. with Storable - $mt ||= DateTime->now() - ; # formatter => $mysqlPattern); # do not store pattern! - it is incompat. with Storable + $ct ||= DateTime->now(); + $mt ||= DateTime->now(); # ct and mt are not in DateTime's internal format - -# # set formatter to output date/time in the requested format -# $ct->set_formatter($mysqlPattern); -# $mt->set_formatter($mysqlPattern); -# # finally fount it! -# # this causes to inject regexp in the object and causes problems with Storable! -# # $mysqlPattern seems to be REGEXP - do not store this in the object! -# say "Entry->SQL->all: parsing mod_time: ".$mt; - # add default my $month = $row->{month} // 0; - push @objs, - $self->e_factory->new_Entry( - old_mysql_id => $row->{id}, + my $obj = $self->e_factory->new_Entry( id => $row->{id}, + old_mysql_id => $row->{id}, entry_type => $row->{entry_type}, bibtex_key => $row->{bibtex_key}, _bibtex_type => $row->{bibtex_type}, @@ -102,7 +90,11 @@ sub all { creation_time => $ct, modified_time => $mt, need_html_regen => $row->{need_html_regen}, - ); + ); + + # Factory sets id to undef, so extra rewrite is needed + # $obj->{id} = $row->{id}; + push @objs, $obj; } return @objs; } @@ -112,7 +104,7 @@ after 'all' => sub { shift->logger->exiting(""); }; =item count Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub count { my ($self) = @_; @@ -129,7 +121,7 @@ after 'count' => sub { shift->logger->exiting(""); }; =item empty Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub empty { my ($self) = @_; @@ -137,8 +129,8 @@ sub empty { my $sth = $dbh->prepare("SELECT 1 as num FROM Entry LIMIT 1;"); $sth->execute(); my $row = $sth->fetchrow_hashref(); - my $num = $row->{num} // 0; - return $num == 0; + return 1 if not defined $row; + return; } before 'empty' => sub { shift->logger->entering(""); }; after 'empty' => sub { shift->logger->exiting(""); }; @@ -146,7 +138,7 @@ after 'empty' => sub { shift->logger->exiting(""); }; =item exists Method documentation placeholder. This method takes single object as argument and returns a scalar. -=cut +=cut sub exists { my ($self, $object) = @_; @@ -164,7 +156,7 @@ after 'exists' => sub { shift->logger->exiting(""); }; =item save Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub save { my ($self, @objects) = @_; @@ -188,7 +180,7 @@ after 'save' => sub { shift->logger->exiting(""); }; =item _insert Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub _insert { my ($self, @objects) = @_; @@ -210,19 +202,21 @@ sub _insert { creation_time, modified_time, need_html_regen - ) + ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; my $sth = $dbh->prepare($qry); foreach my $obj (@objects) { - + my $id = undef; + $id = $obj->id if defined $obj->id and $obj->id > 0; try { my $result = $sth->execute( - $obj->id, $obj->entry_type, $obj->bibtex_key, + $id, $obj->entry_type, $obj->bibtex_key, $obj->{_bibtex_type}, $obj->bib, $obj->html, $obj->html_bib, $obj->abstract, $obj->title, $obj->hidden, $obj->year, $obj->month, $obj->creation_time, $obj->modified_time, $obj->need_html_regen, ); + $obj->id($sth->{mysql_insertid}); } catch { $self->logger->error("Insert exception during inserting ID " @@ -232,8 +226,6 @@ sub _insert { . ". Error: $_"); }; } - - # $dbh->commit(); } before '_insert' => sub { shift->logger->entering(""); }; after '_insert' => sub { shift->logger->exiting(""); }; @@ -241,7 +233,7 @@ after '_insert' => sub { shift->logger->exiting(""); }; =item update Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub update { my ($self, @objects) = @_; @@ -290,30 +282,33 @@ after 'update' => sub { shift->logger->exiting(""); }; =item delete Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub delete { my ($self, @objects) = @_; - my $dbh = $self->handle; + my $dbh = $self->handle; + my $result = 0; foreach my $obj (@objects) { my $qry = "DELETE FROM Entry WHERE id=?;"; my $sth = $dbh->prepare($qry); try { - my $result = $sth->execute($obj->id); + $result = $sth->execute($obj->id); } catch { + $result = 0; $self->logger->error("Delete exception: $_", "" . __PACKAGE__ . "->delete"); }; } - + return 1 if $result > 0; + return; } before 'delete' => sub { shift->logger->entering(""); }; after 'delete' => sub { shift->logger->exiting(""); }; =item filter Method documentation placeholder. -=cut +=cut sub filter { my ($self, $coderef) = @_; @@ -328,7 +323,7 @@ after 'filter' => sub { shift->logger->exiting(""); }; =item find Method documentation placeholder. -=cut +=cut sub find { my ($self, $coderef) = @_; diff --git a/lib/BibSpace/DAO/MySQL/ExceptionMySQLDAO.pm b/lib/BibSpace/DAO/MySQL/ExceptionMySQLDAO.pm index c5c5207..9236168 100644 --- a/lib/BibSpace/DAO/MySQL/ExceptionMySQLDAO.pm +++ b/lib/BibSpace/DAO/MySQL/ExceptionMySQLDAO.pm @@ -22,7 +22,7 @@ use Time::HiRes qw( gettimeofday tv_interval ); =item all Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub all { my ($self) = @_; @@ -35,7 +35,10 @@ sub all { while (my $row = $sth->fetchrow_hashref()) { push @objs, - Exception->new(entry_id => $row->{entry_id}, team_id => $row->{team_id}); + $self->e_factory->new_Exception( + entry_id => $row->{entry_id}, + team_id => $row->{team_id} + ); } return @objs; } @@ -45,7 +48,7 @@ after 'all' => sub { shift->logger->exiting(""); }; =item count Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub count { my ($self) = @_; @@ -54,8 +57,7 @@ sub count { "SELECT COUNT(*) as num FROM Exceptions_Entry_to_Team LIMIT 1"); $sth->execute(); my $row = $sth->fetchrow_hashref(); - my $num = $row->{num} // 0; - return $num; + return $row->{num} || 0; } before 'count' => sub { shift->logger->entering(""); }; after 'count' => sub { shift->logger->exiting(""); }; @@ -63,7 +65,7 @@ after 'count' => sub { shift->logger->exiting(""); }; =item empty Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub empty { my ($self) = @_; @@ -72,8 +74,8 @@ sub empty { = $dbh->prepare("SELECT 1 as num FROM Exceptions_Entry_to_Team LIMIT 1"); $sth->execute(); my $row = $sth->fetchrow_hashref(); - my $num = $row->{num} // 0; - return $num == 0; + return 1 if not defined $row; + return; } before 'empty' => sub { shift->logger->entering(""); }; after 'empty' => sub { shift->logger->exiting(""); }; @@ -81,7 +83,7 @@ after 'empty' => sub { shift->logger->exiting(""); }; =item exists Method documentation placeholder. This method takes single object as argument and returns a scalar. -=cut +=cut sub exists { my ($self, $object) = @_; @@ -101,7 +103,7 @@ after 'exists' => sub { shift->logger->exiting(""); }; =item save Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub save { my ($self, @objects) = @_; @@ -114,7 +116,7 @@ after 'save' => sub { shift->logger->exiting(""); }; =item _insert Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub _insert { my ($self, @objects) = @_; @@ -141,7 +143,7 @@ after '_insert' => sub { shift->logger->exiting(""); }; =item update Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub update { my ($self, @objects) = @_; @@ -161,29 +163,33 @@ after 'update' => sub { shift->logger->exiting(""); }; =item delete Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub delete { my ($self, @objects) = @_; - my $dbh = $self->handle; + my $dbh = $self->handle; + my $result = 0; foreach my $obj (@objects) { my $qry = "DELETE FROM Exceptions_Entry_to_Team WHERE entry_id=? AND team_id=?;"; my $sth = $dbh->prepare($qry); try { - my $result = $sth->execute($obj->entry_id, $obj->team_id); + $result = $sth->execute($obj->entry_id, $obj->team_id); } catch { + $result = 0; $self->logger->error("Delete exception: $_"); }; } + return 1 if $result > 0; + return; } before 'delete' => sub { shift->logger->entering(""); }; after 'delete' => sub { shift->logger->exiting(""); }; =item filter Method documentation placeholder. -=cut +=cut sub filter { my ($self, $coderef) = @_; @@ -205,7 +211,7 @@ after 'filter' => sub { shift->logger->exiting(""); }; =item find Method documentation placeholder. -=cut +=cut sub find { my ($self, $coderef) = @_; diff --git a/lib/BibSpace/DAO/MySQL/LabelingMySQLDAO.pm b/lib/BibSpace/DAO/MySQL/LabelingMySQLDAO.pm index cc09660..5695d6d 100644 --- a/lib/BibSpace/DAO/MySQL/LabelingMySQLDAO.pm +++ b/lib/BibSpace/DAO/MySQL/LabelingMySQLDAO.pm @@ -22,7 +22,7 @@ use Time::HiRes qw( gettimeofday tv_interval ); =item all Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub all { my ($self) = @_; @@ -35,7 +35,10 @@ sub all { while (my $row = $sth->fetchrow_hashref()) { push @objs, - Labeling->new(entry_id => $row->{entry_id}, tag_id => $row->{tag_id}); + $self->e_factory->new_Labeling( + entry_id => $row->{entry_id}, + tag_id => $row->{tag_id} + ); } return @objs; } @@ -45,7 +48,7 @@ after 'all' => sub { shift->logger->exiting(""); }; =item count Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub count { my ($self) = @_; @@ -62,7 +65,7 @@ after 'count' => sub { shift->logger->exiting(""); }; =item empty Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub empty { my ($self) = @_; @@ -70,8 +73,8 @@ sub empty { my $sth = $dbh->prepare("SELECT 1 as num FROM Entry_to_Tag LIMIT 1"); $sth->execute(); my $row = $sth->fetchrow_hashref(); - my $num = $row->{num} // 0; - return $num == 0; + return 1 if not defined $row; + return; } before 'empty' => sub { shift->logger->entering(""); }; after 'empty' => sub { shift->logger->exiting(""); }; @@ -79,7 +82,7 @@ after 'empty' => sub { shift->logger->exiting(""); }; =item exists Method documentation placeholder. This method takes single object as argument and returns a scalar. -=cut +=cut sub exists { my ($self, $object) = @_; @@ -99,7 +102,7 @@ after 'exists' => sub { shift->logger->exiting(""); }; =item save Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub save { my ($self, @objects) = @_; @@ -123,7 +126,7 @@ after 'save' => sub { shift->logger->exiting(""); }; =item _insert Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub _insert { my ($self, @objects) = @_; @@ -152,7 +155,7 @@ after '_insert' => sub { shift->logger->exiting(""); }; =item update Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub update { my ($self, @objects) = @_; @@ -172,21 +175,25 @@ after 'update' => sub { shift->logger->exiting(""); }; =item delete Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub delete { my ($self, @objects) = @_; - my $dbh = $self->handle; + my $dbh = $self->handle; + my $result = 0; foreach my $obj (@objects) { my $qry = "DELETE FROM Entry_to_Tag WHERE entry_id=? AND tag_id=?;"; my $sth = $dbh->prepare($qry); try { - my $result = $sth->execute($obj->entry_id, $obj->tag_id); + $result = $sth->execute($obj->entry_id, $obj->tag_id); } catch { + $result = 0; $self->logger->error("Delete exception: $_"); }; } + return 1 if $result > 0; + return; } before 'delete' => sub { shift->logger->entering(""); }; @@ -194,7 +201,7 @@ after 'delete' => sub { shift->logger->exiting(""); }; =item filter Method documentation placeholder. -=cut +=cut sub filter { my ($self, $coderef) = @_; @@ -216,7 +223,7 @@ after 'filter' => sub { shift->logger->exiting(""); }; =item find Method documentation placeholder. -=cut +=cut sub find { my ($self, $coderef) = @_; diff --git a/lib/BibSpace/DAO/MySQL/MembershipMySQLDAO.pm b/lib/BibSpace/DAO/MySQL/MembershipMySQLDAO.pm index 25f69f9..b05dec4 100644 --- a/lib/BibSpace/DAO/MySQL/MembershipMySQLDAO.pm +++ b/lib/BibSpace/DAO/MySQL/MembershipMySQLDAO.pm @@ -25,7 +25,7 @@ use Time::HiRes qw( gettimeofday tv_interval ); =item all Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub all { my ($self) = @_; @@ -38,7 +38,7 @@ sub all { my @memberships; while (my $row = $sth->fetchrow_hashref()) { - my $mem = Membership->new( + my $mem = $self->e_factory->new_Membership( team_id => $row->{team_id}, author_id => $row->{author_id}, start => $row->{start}, @@ -55,7 +55,7 @@ after 'all' => sub { shift->logger->exiting(""); }; =item count Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub count { my ($self) = @_; @@ -72,7 +72,7 @@ after 'count' => sub { shift->logger->exiting(""); }; =item empty Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub empty { my ($self) = @_; @@ -80,8 +80,8 @@ sub empty { my $sth = $dbh->prepare("SELECT 1 as num FROM Author_to_Team LIMIT 1"); $sth->execute(); my $row = $sth->fetchrow_hashref(); - my $num = $row->{num} // 0; - return $num == 0; + return 1 if not defined $row; + return; } before 'empty' => sub { shift->logger->entering(""); }; after 'empty' => sub { shift->logger->exiting(""); }; @@ -89,7 +89,7 @@ after 'empty' => sub { shift->logger->exiting(""); }; =item exists Method documentation placeholder. This method takes single object as argument and returns a scalar. -=cut +=cut sub exists { my ($self, $object) = @_; @@ -109,7 +109,7 @@ after 'exists' => sub { shift->logger->exiting(""); }; =item save Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub save { my ($self, @objects) = @_; @@ -133,7 +133,7 @@ after 'save' => sub { shift->logger->exiting(""); }; =item _insert Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub _insert { my ($self, @objects) = @_; @@ -147,6 +147,7 @@ sub _insert { $obj->stop); } catch { + $self->logger->error("Insert exception: $_"); }; } @@ -159,7 +160,7 @@ after '_insert' => sub { shift->logger->exiting(""); }; =item update Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub update { my ($self, @objects) = @_; @@ -171,7 +172,7 @@ sub update { # update field 'modified_time' only if needed my $qry = "UPDATE Author_to_Team SET start=?, - stop=? + stop=? WHERE author_id = ? AND team_id = ?"; my $sth = $dbh->prepare($qry); @@ -190,35 +191,38 @@ after 'update' => sub { shift->logger->exiting(""); }; =item delete Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub delete { my ($self, @objects) = @_; - my $dbh = $self->handle; - + my $dbh = $self->handle; + my $result = 0; foreach my $obj (@objects) { next if !defined $obj; my $qry = "DELETE FROM Author_to_Team WHERE author_id=? AND team_id=?;"; my $sth = $dbh->prepare($qry); try { if (defined $obj->author and defined $obj->team) { - $sth->execute($obj->author->id, $obj->team->id); + $result = $sth->execute($obj->author->id, $obj->team->id); } else { - $sth->execute($obj->author_id, $obj->team_id); + $result = $sth->execute($obj->author_id, $obj->team_id); } } catch { + $result = 0; $self->logger->error("Delete exception: $_"); }; } + return 1 if $result > 0; + return; } before 'delete' => sub { shift->logger->entering(""); }; after 'delete' => sub { shift->logger->exiting(""); }; =item filter Method documentation placeholder. -=cut +=cut sub filter { my ($self, $coderef) = @_; @@ -233,7 +237,7 @@ after 'filter' => sub { shift->logger->exiting(""); }; =item find Method documentation placeholder. -=cut +=cut sub find { my ($self, $coderef) = @_; diff --git a/lib/BibSpace/DAO/MySQL/TagMySQLDAO.pm b/lib/BibSpace/DAO/MySQL/TagMySQLDAO.pm index 4d386e9..92b2329 100644 --- a/lib/BibSpace/DAO/MySQL/TagMySQLDAO.pm +++ b/lib/BibSpace/DAO/MySQL/TagMySQLDAO.pm @@ -25,7 +25,7 @@ use Time::HiRes qw( gettimeofday tv_interval ); =item all Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub all { my ($self) = @_; @@ -58,7 +58,7 @@ after 'all' => sub { shift->logger->exiting(""); }; =item count Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub count { my ($self) = @_; @@ -75,7 +75,7 @@ after 'count' => sub { shift->logger->exiting(""); }; =item empty Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub empty { my ($self) = @_; @@ -83,8 +83,8 @@ sub empty { my $sth = $dbh->prepare("SELECT 1 as num FROM Tag LIMIT 1"); $sth->execute(); my $row = $sth->fetchrow_hashref(); - my $num = $row->{num} // 0; - return $num == 0; + return 1 if not defined $row; + return; } before 'empty' => sub { shift->logger->entering(""); }; after 'empty' => sub { shift->logger->exiting(""); }; @@ -92,7 +92,7 @@ after 'empty' => sub { shift->logger->exiting(""); }; =item exists Method documentation placeholder. This method takes single object as argument and returns a scalar. -=cut +=cut sub exists { my ($self, $object) = @_; @@ -111,7 +111,7 @@ after 'exists' => sub { shift->logger->exiting(""); }; =item save Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub save { my ($self, @objects) = @_; @@ -135,7 +135,7 @@ after 'save' => sub { shift->logger->exiting(""); }; =item _insert Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub _insert { my ($self, @objects) = @_; @@ -144,9 +144,11 @@ sub _insert { INSERT INTO Tag(id, name, type, permalink) VALUES (?,?,?,?);"; my $sth = $dbh->prepare($qry); foreach my $obj (@objects) { + my $id = undef; + $id = $obj->id if defined $obj->id and $obj->id > 0; try { - my $result - = $sth->execute($obj->id, $obj->name, $obj->type, $obj->permalink); + my $result = $sth->execute($id, $obj->name, $obj->type, $obj->permalink); + $obj->id($sth->{mysql_insertid}); } catch { $self->logger->error("Insert exception: $_"); @@ -161,7 +163,7 @@ after '_insert' => sub { shift->logger->exiting(""); }; =item update Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub update { my ($self, @objects) = @_; @@ -190,28 +192,32 @@ after 'update' => sub { shift->logger->exiting(""); }; =item delete Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub delete { my ($self, @objects) = @_; - my $dbh = $self->handle; + my $dbh = $self->handle; + my $result = 0; foreach my $obj (@objects) { my $qry = "DELETE FROM Tag WHERE id=?;"; my $sth = $dbh->prepare($qry); try { - my $result = $sth->execute($obj->id); + $result = $sth->execute($obj->id); } catch { + $result = 0; $self->logger->error("Delete exception: $_"); }; } + return 1 if $result > 0; + return; } before 'delete' => sub { shift->logger->entering(""); }; after 'delete' => sub { shift->logger->exiting(""); }; =item filter Method documentation placeholder. -=cut +=cut sub filter { my ($self, $coderef) = @_; @@ -226,7 +232,7 @@ after 'filter' => sub { shift->logger->exiting(""); }; =item find Method documentation placeholder. -=cut +=cut sub find { my ($self, $coderef) = @_; diff --git a/lib/BibSpace/DAO/MySQL/TagTypeMySQLDAO.pm b/lib/BibSpace/DAO/MySQL/TagTypeMySQLDAO.pm index fd11cb9..2bba1ed 100644 --- a/lib/BibSpace/DAO/MySQL/TagTypeMySQLDAO.pm +++ b/lib/BibSpace/DAO/MySQL/TagTypeMySQLDAO.pm @@ -25,12 +25,12 @@ use Time::HiRes qw( gettimeofday tv_interval ); =item all Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub all { my ($self) = @_; my $dbh = $self->handle; - my $qry = "SELECT id, name, comment + my $qry = "SELECT id, name, comment FROM TagType;"; my $sth = $dbh->prepare($qry); $sth->execute(); @@ -55,7 +55,7 @@ after 'all' => sub { shift->logger->exiting(""); }; =item count Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub count { my ($self) = @_; @@ -80,11 +80,16 @@ after 'count' => sub { shift->logger->exiting(""); }; =item empty Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub empty { my ($self) = @_; - return $self->count() == 0; + my $dbh = $self->handle; + my $sth = $dbh->prepare("SELECT 1 as num FROM TagType LIMIT 1;"); + $sth->execute(); + my $row = $sth->fetchrow_hashref(); + return 1 if not defined $row; + return; } before 'empty' => sub { shift->logger->entering(""); }; after 'empty' => sub { shift->logger->exiting(""); }; @@ -92,7 +97,7 @@ after 'empty' => sub { shift->logger->exiting(""); }; =item exists Method documentation placeholder. This method takes single object as argument and returns a scalar. -=cut +=cut sub exists { my ($self, $object) = @_; @@ -116,7 +121,7 @@ after 'exists' => sub { shift->logger->exiting(""); }; =item save Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub save { my ($self, @objects) = @_; @@ -140,7 +145,7 @@ after 'save' => sub { shift->logger->exiting(""); }; =item _insert Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub _insert { my ($self, @objects) = @_; @@ -149,8 +154,11 @@ sub _insert { INSERT INTO TagType(id, name, comment) VALUES (?,?,?);"; my $sth = $dbh->prepare($qry); foreach my $obj (@objects) { + my $id = undef; + $id = $obj->id if defined $obj->id and $obj->id > 0; try { - my $result = $sth->execute($obj->id, $obj->name, $obj->comment); + my $result = $sth->execute($id, $obj->name, $obj->comment); + $obj->id($sth->{mysql_insertid}); } catch { $self->logger->error("Insert exception: $_"); @@ -165,7 +173,7 @@ after '_insert' => sub { shift->logger->exiting(""); }; =item update Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub update { my ($self, @objects) = @_; @@ -192,28 +200,32 @@ after 'update' => sub { shift->logger->exiting(""); }; =item delete Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub delete { my ($self, @objects) = @_; - my $dbh = $self->handle; + my $dbh = $self->handle; + my $result = 0; foreach my $obj (@objects) { my $qry = "DELETE FROM TagType WHERE id=?;"; my $sth = $dbh->prepare($qry); try { - my $result = $sth->execute($obj->id); + $result = $sth->execute($obj->id); } catch { + $result = 0; $self->logger->error("Delete exception: $_"); }; } + return 1 if $result > 0; + return; } before 'delete' => sub { shift->logger->entering(""); }; after 'delete' => sub { shift->logger->exiting(""); }; =item filter Method documentation placeholder. -=cut +=cut sub filter { my ($self, $coderef) = @_; @@ -228,7 +240,7 @@ after 'filter' => sub { shift->logger->exiting(""); }; =item find Method documentation placeholder. -=cut +=cut sub find { my ($self, $coderef) = @_; diff --git a/lib/BibSpace/DAO/MySQL/TeamMySQLDAO.pm b/lib/BibSpace/DAO/MySQL/TeamMySQLDAO.pm index 7582d80..d61720d 100644 --- a/lib/BibSpace/DAO/MySQL/TeamMySQLDAO.pm +++ b/lib/BibSpace/DAO/MySQL/TeamMySQLDAO.pm @@ -22,7 +22,7 @@ use Time::HiRes qw( gettimeofday tv_interval ); =item all Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub all { my ($self) = @_; @@ -52,7 +52,7 @@ after 'all' => sub { shift->logger->exiting(""); }; =item count Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub count { my ($self) = @_; @@ -75,22 +75,16 @@ after 'count' => sub { shift->logger->exiting(""); }; =item empty Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub empty { my ($self) = @_; my $dbh = $self->handle; - my $num = 0; - try { - my $sth = $dbh->prepare("SELECT 1 as num FROM Team LIMIT 1"); - $sth->execute(); - my $row = $sth->fetchrow_hashref(); - $num = $row->{num}; - } - catch { - $self->logger->error("Count exception: $_"); - }; - return $num == 0; + my $sth = $dbh->prepare("SELECT 1 as num FROM Team LIMIT 1"); + $sth->execute(); + my $row = $sth->fetchrow_hashref(); + return 1 if not defined $row; + return; } before 'empty' => sub { shift->logger->entering(""); }; after 'empty' => sub { shift->logger->exiting(""); }; @@ -98,7 +92,7 @@ after 'empty' => sub { shift->logger->exiting(""); }; =item exists Method documentation placeholder. This method takes single object as argument and returns a scalar. -=cut +=cut sub exists { my ($self, $object) = @_; @@ -117,7 +111,7 @@ after 'exists' => sub { shift->logger->exiting(""); }; =item save Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub save { my ($self, @objects) = @_; @@ -141,7 +135,7 @@ after 'save' => sub { shift->logger->exiting(""); }; =item _insert Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub _insert { my ($self, @objects) = @_; @@ -150,8 +144,11 @@ sub _insert { INSERT INTO Team (id, name, parent) VALUES (?,?,?);"; my $sth = $dbh->prepare($qry); foreach my $obj (@objects) { + my $id = undef; + $id = $obj->id if defined $obj->id and $obj->id > 0; try { - my $result = $sth->execute($obj->id, $obj->name, $obj->parent); + my $result = $sth->execute($id, $obj->name, $obj->parent); + $obj->id($sth->{mysql_insertid}); } catch { $self->logger->error("Insert exception: $_"); @@ -166,7 +163,7 @@ after '_insert' => sub { shift->logger->exiting(""); }; =item update Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub update { my ($self, @objects) = @_; @@ -195,29 +192,32 @@ after 'update' => sub { shift->logger->exiting(""); }; =item delete Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub delete { my ($self, @objects) = @_; - my $dbh = $self->handle; + my $dbh = $self->handle; + my $result = 0; foreach my $obj (@objects) { my $qry = "DELETE FROM Team WHERE id=?;"; my $sth = $dbh->prepare($qry); try { - my $result = $sth->execute($obj->id); + $result = $sth->execute($obj->id); } catch { + $result = 0; $self->logger->error("Delete exception: $_"); }; } - + return 1 if $result > 0; + return; } before 'delete' => sub { shift->logger->entering(""); }; after 'delete' => sub { shift->logger->exiting(""); }; =item filter Method documentation placeholder. -=cut +=cut sub filter { my ($self, $coderef) = @_; @@ -232,7 +232,7 @@ after 'filter' => sub { shift->logger->exiting(""); }; =item find Method documentation placeholder. -=cut +=cut sub find { my ($self, $coderef) = @_; diff --git a/lib/BibSpace/DAO/MySQL/TypeMySQLDAO.pm b/lib/BibSpace/DAO/MySQL/TypeMySQLDAO.pm index 5f4bc0f..5d6535f 100644 --- a/lib/BibSpace/DAO/MySQL/TypeMySQLDAO.pm +++ b/lib/BibSpace/DAO/MySQL/TypeMySQLDAO.pm @@ -21,7 +21,7 @@ use Time::HiRes qw( gettimeofday tv_interval ); =item all Method documentation placeholder. -=cut +=cut sub all { my ($self) = @_; @@ -74,7 +74,7 @@ after 'all' => sub { shift->logger->exiting(""); }; =item count Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub count { my ($self) = @_; @@ -92,11 +92,16 @@ after 'count' => sub { shift->logger->exiting(""); }; =item empty Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub empty { my ($self) = @_; - return $self->count == 0; + my $dbh = $self->handle; + my $sth = $dbh->prepare("SELECT 1 as num FROM OurType_to_Type LIMIT 1;"); + $sth->execute(); + my $row = $sth->fetchrow_hashref(); + return 1 if not defined $row; + return; } before 'empty' => sub { shift->logger->entering(""); }; @@ -105,7 +110,7 @@ after 'empty' => sub { shift->logger->exiting(""); }; =item exists Method documentation placeholder. This method takes single object as argument and returns a scalar. -=cut +=cut sub exists { my ($self, $object) = @_; @@ -125,7 +130,7 @@ after 'exists' => sub { shift->logger->exiting(""); }; =item _insert Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub _insert { my ($self, @objects) = @_; @@ -154,7 +159,7 @@ after '_insert' => sub { shift->logger->exiting(""); }; =item save Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub save { my ($self, @objects) = @_; @@ -162,13 +167,9 @@ sub save { foreach my $obj (@objects) { if ($self->exists($obj)) { $self->update($obj); - $self->logger->lowdebug( - "Updated " . ref($obj) . " ID " . $obj->id . " in DB."); } else { $self->_insert($obj); - $self->logger->lowdebug( - "Inserted " . ref($obj) . " ID " . $obj->id . " into DB."); } } } @@ -178,7 +179,7 @@ after 'save' => sub { shift->logger->exiting(""); }; =item update Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub update { my ($self, @objects) = @_; @@ -193,31 +194,33 @@ after 'update' => sub { shift->logger->exiting(""); }; =item delete Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub delete { my ($self, @objects) = @_; - my $dbh = $self->handle; - my $qry = " + my $dbh = $self->handle; + my $result = 0; + my $qry = " DELETE FROM OurType_to_Type WHERE our_type=?;"; my $sth = $dbh->prepare($qry); foreach my $obj (@objects) { try { - my $result = $sth->execute($obj->our_type); + $result = $sth->execute($obj->our_type); } catch { + $result = 0; $self->logger->error("Delete exception: $_"); }; } - - # $dbh->commit(); + return 1 if $result > 0; + return; } before 'delete' => sub { shift->logger->entering(""); }; after 'delete' => sub { shift->logger->exiting(""); }; =item filter Method documentation placeholder. -=cut +=cut sub filter { my ($self, $coderef) = @_; @@ -233,7 +236,7 @@ after 'filter' => sub { shift->logger->exiting(""); }; =item find Method documentation placeholder. -=cut +=cut sub find { my ($self, $coderef) = @_; diff --git a/lib/BibSpace/DAO/MySQL/UserMySQLDAO.pm b/lib/BibSpace/DAO/MySQL/UserMySQLDAO.pm index c2b5ea9..a16f166 100644 --- a/lib/BibSpace/DAO/MySQL/UserMySQLDAO.pm +++ b/lib/BibSpace/DAO/MySQL/UserMySQLDAO.pm @@ -22,23 +22,23 @@ use Time::HiRes qw( gettimeofday tv_interval ); =item all Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub all { my ($self) = @_; my $dbh = $self->handle; - my $qry = "SELECT - id, - login, - registration_time, - last_login, - real_name, - email, - pass, - pass2, - pass3, - rank, - master_id, + my $qry = "SELECT + id, + login, + registration_time, + last_login, + real_name, + email, + pass, + pass2, + pass3, + rank, + master_id, tennant_id FROM Login ORDER BY login ASC"; @@ -60,21 +60,19 @@ sub all { while (my $row = $sth->fetchrow_hashref()) { # set formatter to parse date/time in the requested format - my $rt = $mysqlPattern->parse_datetime($row->{registration_time}); - my $ll = $mysqlPattern->parse_datetime($row->{last_login}); + my $regTime = $mysqlPattern->parse_datetime($row->{registration_time}); + my $lastLogin = $mysqlPattern->parse_datetime($row->{last_login}); # set defaults if there is no data in mysql - $rt ||= DateTime->now() - ; # formatter => $mysqlPattern); # do not store pattern! - it is incompat. with Storable - $ll ||= DateTime->now() - ; # formatter => $mysqlPattern); # do not store pattern! - it is incompat. with Storable + $regTime ||= DateTime->now(); + $lastLogin ||= DateTime->now(); my $obj = $self->e_factory->new_User( old_mysql_id => $row->{id}, id => $row->{id}, login => $row->{login}, - registration_time => $rt, - last_login => $ll, + registration_time => $regTime, + last_login => $lastLogin, real_name => $row->{real_name}, email => $row->{email}, pass => $row->{pass}, @@ -92,7 +90,7 @@ sub all { =item count Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub count { my ($self) = @_; @@ -107,7 +105,7 @@ sub count { =item empty Method documentation placeholder. This method takes no arguments and returns array or scalar. -=cut +=cut sub empty { my ($self) = @_; @@ -115,14 +113,14 @@ sub empty { my $sth = $dbh->prepare("SELECT 1 as num FROM Login LIMIT 1"); $sth->execute(); my $row = $sth->fetchrow_hashref(); - my $num = $row->{num} // 0; - return $num == 0; + return 1 if not defined $row; + return; } =item exists Method documentation placeholder. This method takes single object as argument and returns a scalar. -=cut +=cut sub exists { my ($self, $object) = @_; @@ -138,7 +136,7 @@ sub exists { =item save Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub save { my ($self, @objects) = @_; @@ -160,37 +158,39 @@ sub save { =item _insert Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub _insert { my ($self, @objects) = @_; my $dbh = $self->handle; my $qry = " INSERT INTO Login( - id, - login, - registration_time, - last_login, - real_name, - email, - pass, - pass2, - pass3, - rank, - master_id, + id, + login, + registration_time, + last_login, + real_name, + email, + pass, + pass2, + pass3, + rank, + master_id, tennant_id - ) + ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?);"; my $sth = $dbh->prepare($qry); foreach my $obj (@objects) { - + my $id = undef; + $id = $obj->id if defined $obj->id and $obj->id > 0; try { my $result = $sth->execute( - $obj->id, $obj->login, $obj->registration_time, + $id, $obj->login, $obj->registration_time, $obj->last_login, $obj->real_name, $obj->email, $obj->pass, $obj->pass2, $obj->pass3, $obj->rank, $obj->master_id, $obj->tennant_id ); + $obj->id($sth->{mysql_insertid}); } catch { $self->logger->error("Insert exception: $_"); @@ -203,7 +203,7 @@ sub _insert { =item update Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub update { my ($self, @objects) = @_; @@ -213,17 +213,17 @@ sub update { next if !defined $obj->login; # update field 'modified_time' only if needed - my $qry = "UPDATE Login SET + my $qry = "UPDATE Login SET login=?, - registration_time=?, - last_login=?, - real_name=?, - email=?, - pass=?, - pass2=?, - pass3=?, - rank=?, - master_id=?, + registration_time=?, + last_login=?, + real_name=?, + email=?, + pass=?, + pass2=?, + pass3=?, + rank=?, + master_id=?, tennant_id=? WHERE id = ?"; @@ -246,27 +246,30 @@ sub update { =item delete Method documentation placeholder. This method takes single object or array of objects as argument and returns nothing. -=cut +=cut sub delete { my ($self, @objects) = @_; - my $dbh = $self->handle; + my $dbh = $self->handle; + my $result = 0; foreach my $obj (@objects) { my $qry = "DELETE FROM Login WHERE id=?;"; my $sth = $dbh->prepare($qry); try { - my $result = $sth->execute($obj->id); + $result = $sth->execute($obj->id); } catch { + $result = 0; $self->logger->error("Delete exception: $_"); }; } - + return 1 if $result > 0; + return; } =item filter Method documentation placeholder. -=cut +=cut sub filter { my ($self, $coderef) = @_; @@ -280,7 +283,7 @@ sub filter { =item find Method documentation placeholder. -=cut +=cut sub find { my ($self, $coderef) = @_; diff --git a/lib/BibSpace/DAO/MySQLDAOFactory.pm b/lib/BibSpace/DAO/MySQLDAOFactory.pm index 77b3c4e..bb6eb8e 100644 --- a/lib/BibSpace/DAO/MySQLDAOFactory.pm +++ b/lib/BibSpace/DAO/MySQLDAOFactory.pm @@ -31,8 +31,6 @@ sub getMembershipDao { e_factory => $self->e_factory ); } -before 'getMembershipDao' => sub { shift->logger->entering(""); }; -after 'getMembershipDao' => sub { shift->logger->exiting(""); }; sub getTagDao { my $self = shift; @@ -42,8 +40,6 @@ sub getTagDao { e_factory => $self->e_factory ); } -before 'getTagDao' => sub { shift->logger->entering(""); }; -after 'getTagDao' => sub { shift->logger->exiting(""); }; sub getAuthorshipDao { my $self = shift; @@ -53,8 +49,6 @@ sub getAuthorshipDao { e_factory => $self->e_factory ); } -before 'getAuthorshipDao' => sub { shift->logger->entering(""); }; -after 'getAuthorshipDao' => sub { shift->logger->exiting(""); }; sub getEntryDao { my $self = shift; @@ -64,8 +58,6 @@ sub getEntryDao { e_factory => $self->e_factory ); } -before 'getEntryDao' => sub { shift->logger->entering(""); }; -after 'getEntryDao' => sub { shift->logger->exiting(""); }; sub getTeamDao { my $self = shift; @@ -75,8 +67,6 @@ sub getTeamDao { e_factory => $self->e_factory ); } -before 'getTeamDao' => sub { shift->logger->entering(""); }; -after 'getTeamDao' => sub { shift->logger->exiting(""); }; sub getExceptionDao { my $self = shift; @@ -86,8 +76,6 @@ sub getExceptionDao { e_factory => $self->e_factory ); } -before 'getExceptionDao' => sub { shift->logger->entering(""); }; -after 'getExceptionDao' => sub { shift->logger->exiting(""); }; sub getTagTypeDao { my $self = shift; @@ -97,8 +85,6 @@ sub getTagTypeDao { e_factory => $self->e_factory ); } -before 'getTagTypeDao' => sub { shift->logger->entering(""); }; -after 'getTagTypeDao' => sub { shift->logger->exiting(""); }; sub getLabelingDao { my $self = shift; @@ -108,8 +94,6 @@ sub getLabelingDao { e_factory => $self->e_factory ); } -before 'getLabelingDao' => sub { shift->logger->entering(""); }; -after 'getLabelingDao' => sub { shift->logger->exiting(""); }; sub getAuthorDao { my $self = shift; @@ -119,8 +103,6 @@ sub getAuthorDao { e_factory => $self->e_factory ); } -before 'getAuthorDao' => sub { shift->logger->entering(""); }; -after 'getAuthorDao' => sub { shift->logger->exiting(""); }; sub getTypeDao { my $self = shift; @@ -130,8 +112,6 @@ sub getTypeDao { e_factory => $self->e_factory ); } -before 'getTypeDao' => sub { shift->logger->entering(""); }; -after 'getTypeDao' => sub { shift->logger->exiting(""); }; sub getUserDao { my $self = shift; @@ -141,8 +121,6 @@ sub getUserDao { e_factory => $self->e_factory ); } -before 'getUserDao' => sub { shift->logger->entering(""); }; -after 'getUserDao' => sub { shift->logger->exiting(""); }; __PACKAGE__->meta->make_immutable; no Moose; diff --git a/lib/BibSpace/DAO/Redis/AuthorRedisDAO.pm b/lib/BibSpace/DAO/Redis/AuthorRedisDAO.pm deleted file mode 100644 index de06cd1..0000000 --- a/lib/BibSpace/DAO/Redis/AuthorRedisDAO.pm +++ /dev/null @@ -1,185 +0,0 @@ - -package AuthorRedisDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Author; -with 'IDAO'; -use Try::Tiny; - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to update " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to delete " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/Redis/AuthorshipRedisDAO.pm b/lib/BibSpace/DAO/Redis/AuthorshipRedisDAO.pm deleted file mode 100644 index 713532a..0000000 --- a/lib/BibSpace/DAO/Redis/AuthorshipRedisDAO.pm +++ /dev/null @@ -1,185 +0,0 @@ - -package AuthorshipRedisDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Authorship; -with 'IDAO'; -use Try::Tiny; - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to update " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to delete " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/Redis/EntryRedisDAO.pm b/lib/BibSpace/DAO/Redis/EntryRedisDAO.pm deleted file mode 100644 index dc668cb..0000000 --- a/lib/BibSpace/DAO/Redis/EntryRedisDAO.pm +++ /dev/null @@ -1,185 +0,0 @@ - -package EntryRedisDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Entry; -with 'IDAO'; -use Try::Tiny; - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to update " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to delete " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/Redis/ExceptionRedisDAO.pm b/lib/BibSpace/DAO/Redis/ExceptionRedisDAO.pm deleted file mode 100644 index cdf079a..0000000 --- a/lib/BibSpace/DAO/Redis/ExceptionRedisDAO.pm +++ /dev/null @@ -1,185 +0,0 @@ - -package ExceptionRedisDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Exception; -with 'IDAO'; -use Try::Tiny; - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to update " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to delete " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/Redis/LabelingRedisDAO.pm b/lib/BibSpace/DAO/Redis/LabelingRedisDAO.pm deleted file mode 100644 index 9f3cdcf..0000000 --- a/lib/BibSpace/DAO/Redis/LabelingRedisDAO.pm +++ /dev/null @@ -1,185 +0,0 @@ - -package LabelingRedisDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Labeling; -with 'IDAO'; -use Try::Tiny; - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to update " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to delete " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/Redis/MembershipRedisDAO.pm b/lib/BibSpace/DAO/Redis/MembershipRedisDAO.pm deleted file mode 100644 index 5c3f7da..0000000 --- a/lib/BibSpace/DAO/Redis/MembershipRedisDAO.pm +++ /dev/null @@ -1,185 +0,0 @@ - -package MembershipRedisDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Membership; -with 'IDAO'; -use Try::Tiny; - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to update " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to delete " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/Redis/TagRedisDAO.pm b/lib/BibSpace/DAO/Redis/TagRedisDAO.pm deleted file mode 100644 index 476c347..0000000 --- a/lib/BibSpace/DAO/Redis/TagRedisDAO.pm +++ /dev/null @@ -1,185 +0,0 @@ - -package TagRedisDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Tag; -with 'IDAO'; -use Try::Tiny; - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to update " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to delete " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/Redis/TagTypeRedisDAO.pm b/lib/BibSpace/DAO/Redis/TagTypeRedisDAO.pm deleted file mode 100644 index e3bb0f6..0000000 --- a/lib/BibSpace/DAO/Redis/TagTypeRedisDAO.pm +++ /dev/null @@ -1,185 +0,0 @@ - -package TagTypeRedisDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::TagType; -with 'IDAO'; -use Try::Tiny; - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to update " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to delete " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/Redis/TeamRedisDAO.pm b/lib/BibSpace/DAO/Redis/TeamRedisDAO.pm deleted file mode 100644 index 5b0461d..0000000 --- a/lib/BibSpace/DAO/Redis/TeamRedisDAO.pm +++ /dev/null @@ -1,185 +0,0 @@ - -package TeamRedisDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Team; -with 'IDAO'; -use Try::Tiny; - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to update " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to delete " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/Redis/TypeRedisDAO.pm b/lib/BibSpace/DAO/Redis/TypeRedisDAO.pm deleted file mode 100644 index 32b9168..0000000 --- a/lib/BibSpace/DAO/Redis/TypeRedisDAO.pm +++ /dev/null @@ -1,158 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-14T17:02:11 -package BibSpace::DAO::Redis::TypeRedisDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::ITypeDAO; -use BibSpace::Model::Type; -with 'BibSpace::DAO::Interface::ITypeDAO'; - -# Inherited fields from BibSpace::DAO::Interface::ITypeDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'BibSpace::Util::ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. -=cut - -sub all { - my ($self) = @_; - $self->logger->entering(""); - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - $self->logger->exiting(""); -} - -=item save - Method documentation placeholder. -=cut - -sub save { - my ($self, @objects) = @_; - $self->logger->entering(""); - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - $self->logger->exiting(""); -} - -=item update - Method documentation placeholder. -=cut - -sub update { - my ($self, @objects) = @_; - $self->logger->entering(""); - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - $self->logger->exiting(""); -} - -=item delete - Method documentation placeholder. -=cut - -sub delete { - my ($self, @objects) = @_; - $self->logger->entering(""); - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - $self->logger->exiting(""); -} - -=item exists - Method documentation placeholder. -=cut - -sub exists { - my ($self, @objects) = @_; - $self->logger->entering(""); - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - $self->logger->exiting(""); -} - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - $self->logger->entering(""); - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - $self->logger->exiting(""); -} - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - $self->logger->entering(""); - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - $self->logger->exiting(""); -} - -=item count - Method documentation placeholder. -=cut - -sub count { - my ($self, $coderef) = @_; - $self->logger->entering(""); - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - $self->logger->exiting(""); -} - -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/Redis/UserRedisDAO.pm b/lib/BibSpace/DAO/Redis/UserRedisDAO.pm deleted file mode 100644 index 975afed..0000000 --- a/lib/BibSpace/DAO/Redis/UserRedisDAO.pm +++ /dev/null @@ -1,185 +0,0 @@ - -package UserRedisDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::User; -with 'IDAO'; -use Try::Tiny; - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to save " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to update " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - - die "" - . (caller(0))[3] - . " not implemented. Method was instructed to delete " - . scalar(@objects) - . " objects."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - - die "" . (caller(0))[3] . " not implemented."; - - # TODO: auto-generated method stub. Implement me! - -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/RedisDAOFactory.pm b/lib/BibSpace/DAO/RedisDAOFactory.pm deleted file mode 100644 index 0a97bc4..0000000 --- a/lib/BibSpace/DAO/RedisDAOFactory.pm +++ /dev/null @@ -1,148 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T14:47:33 -package RedisDAOFactory; - -use namespace::autoclean; - -use Moose; -use BibSpace::Util::ILogger; -use BibSpace::DAO::Redis::MembershipRedisDAO; -use BibSpace::DAO::Redis::TagRedisDAO; -use BibSpace::DAO::Redis::AuthorshipRedisDAO; -use BibSpace::DAO::Redis::EntryRedisDAO; -use BibSpace::DAO::Redis::TeamRedisDAO; -use BibSpace::DAO::Redis::ExceptionRedisDAO; -use BibSpace::DAO::Redis::TagTypeRedisDAO; -use BibSpace::DAO::Redis::LabelingRedisDAO; -use BibSpace::DAO::Redis::AuthorRedisDAO; -use BibSpace::DAO::Redis::UserRedisDAO; -use BibSpace::DAO::DAOFactory; -extends 'DAOFactory'; - -has 'handle' => (is => 'ro', required => 1); -has 'logger' => (is => 'ro', does => 'ILogger', required => 1); -has 'e_factory' => (is => 'ro', isa => 'EntityFactory', required => 1); - -sub getMembershipDao { - my $self = shift; - return MembershipRedisDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getMembershipDao' => sub { shift->logger->entering(""); }; -after 'getMembershipDao' => sub { shift->logger->exiting(""); }; - -sub getTagDao { - my $self = shift; - return TagRedisDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getTagDao' => sub { shift->logger->entering(""); }; -after 'getTagDao' => sub { shift->logger->exiting(""); }; - -sub getAuthorshipDao { - my $self = shift; - return AuthorshipRedisDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getAuthorshipDao' => sub { shift->logger->entering(""); }; -after 'getAuthorshipDao' => sub { shift->logger->exiting(""); }; - -sub getEntryDao { - my $self = shift; - return EntryRedisDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getEntryDao' => sub { shift->logger->entering(""); }; -after 'getEntryDao' => sub { shift->logger->exiting(""); }; - -sub getTeamDao { - my $self = shift; - return TeamRedisDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getTeamDao' => sub { shift->logger->entering(""); }; -after 'getTeamDao' => sub { shift->logger->exiting(""); }; - -sub getExceptionDao { - my $self = shift; - return ExceptionRedisDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getExceptionDao' => sub { shift->logger->entering(""); }; -after 'getExceptionDao' => sub { shift->logger->exiting(""); }; - -sub getTagTypeDao { - my $self = shift; - return TagTypeRedisDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getTagTypeDao' => sub { shift->logger->entering(""); }; -after 'getTagTypeDao' => sub { shift->logger->exiting(""); }; - -sub getLabelingDao { - my $self = shift; - return LabelingRedisDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getLabelingDao' => sub { shift->logger->entering(""); }; -after 'getLabelingDao' => sub { shift->logger->exiting(""); }; - -sub getAuthorDao { - my $self = shift; - return AuthorRedisDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getAuthorDao' => sub { shift->logger->entering(""); }; -after 'getAuthorDao' => sub { shift->logger->exiting(""); }; - -sub getTypeDao { - my $self = shift; - return TypeRedisDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getTypeDao' => sub { shift->logger->entering(""); }; -after 'getTypeDao' => sub { shift->logger->exiting(""); }; - -sub getUserDao { - my $self = shift; - return UserRedisDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getUserDao' => sub { shift->logger->entering(""); }; -after 'getUserDao' => sub { shift->logger->exiting(""); }; - -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/SmartArray/AuthorSmartArrayDAO.pm b/lib/BibSpace/DAO/SmartArray/AuthorSmartArrayDAO.pm deleted file mode 100644 index 7e2ba08..0000000 --- a/lib/BibSpace/DAO/SmartArray/AuthorSmartArrayDAO.pm +++ /dev/null @@ -1,140 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T16:44:28 -package AuthorSmartArrayDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Author; -with 'IDAO'; -use Try::Tiny; -use List::MoreUtils qw(any uniq); -use List::Util qw(first); - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - return $self->handle->all("Author"); -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - return $self->handle->count("Author"); -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - return $self->handle->empty("Author"); -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - $self->handle->exists($object); -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - $self->handle->save(@objects); -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - # smart array does not require updating! Objects are direct references! -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - $self->handle->delete(@objects); -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->filter("Author", $coderef); -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->find("Author", $coderef); -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/SmartArray/AuthorshipSmartArrayDAO.pm b/lib/BibSpace/DAO/SmartArray/AuthorshipSmartArrayDAO.pm deleted file mode 100644 index 681130a..0000000 --- a/lib/BibSpace/DAO/SmartArray/AuthorshipSmartArrayDAO.pm +++ /dev/null @@ -1,141 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T16:44:28 -package AuthorshipSmartArrayDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Authorship; -with 'IDAO'; -use Try::Tiny; -use List::MoreUtils qw(any uniq); -use List::Util qw(first); - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - return $self->handle->all("Authorship"); - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - return $self->handle->count("Authorship"); -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - return $self->handle->empty("Authorship"); -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - $self->handle->exists($object); -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - $self->handle->save(@objects); -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - # smart array does not require updating! Objects are direct references! -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - $self->handle->delete(@objects); -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->filter("Authorship", $coderef); -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->find("Authorship", $coderef); -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/SmartArray/EntrySmartArrayDAO.pm b/lib/BibSpace/DAO/SmartArray/EntrySmartArrayDAO.pm deleted file mode 100644 index 2d1cca7..0000000 --- a/lib/BibSpace/DAO/SmartArray/EntrySmartArrayDAO.pm +++ /dev/null @@ -1,142 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T16:44:28 -package EntrySmartArrayDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Entry; -with 'IDAO'; -use Try::Tiny; -use List::MoreUtils qw(any uniq); -use List::Util qw(first); - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - return $self->handle->all("Entry"); - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - return $self->handle->count("Entry"); -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - return $self->handle->empty("Entry"); -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - $self->handle->exists($object); -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - $self->handle->save(@objects); -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - # smart array does not require updating! Objects are direct references! -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - $self->handle->delete(@objects); -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->filter("Entry", $coderef); -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->find("Entry", $coderef); -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/SmartArray/ExceptionSmartArrayDAO.pm b/lib/BibSpace/DAO/SmartArray/ExceptionSmartArrayDAO.pm deleted file mode 100644 index a06dee2..0000000 --- a/lib/BibSpace/DAO/SmartArray/ExceptionSmartArrayDAO.pm +++ /dev/null @@ -1,142 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T16:44:28 -package ExceptionSmartArrayDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Exception; -with 'IDAO'; -use Try::Tiny; -use List::MoreUtils qw(any uniq); -use List::Util qw(first); - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - return $self->handle->all("Exception"); - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - return $self->handle->count("Exception"); -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - return $self->handle->empty("Exception"); -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - $self->handle->exists($object); -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - $self->handle->save(@objects); -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - # smart array does not require updating! Objects are direct references! -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - $self->handle->delete(@objects); -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->filter("Exception", $coderef); -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->find("Exception", $coderef); -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/SmartArray/LabelingSmartArrayDAO.pm b/lib/BibSpace/DAO/SmartArray/LabelingSmartArrayDAO.pm deleted file mode 100644 index 441a3c2..0000000 --- a/lib/BibSpace/DAO/SmartArray/LabelingSmartArrayDAO.pm +++ /dev/null @@ -1,146 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T16:44:28 -package LabelingSmartArrayDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Labeling; -with 'IDAO'; -use Try::Tiny; -use List::MoreUtils qw(any uniq); -use List::Util qw(first); -use feature qw( state say ); - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - return $self->handle->all("Labeling"); - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - return $self->handle->count("Labeling"); -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - return $self->handle->empty("Labeling"); -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - $self->handle->exists($object); -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - - my %existing = map { $_->id => 1 } $self->all; - @objects = grep { not $existing{$_->id} } @objects; - $self->handle->save(@objects); -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - # smart array does not require updating! Objects are direct references! -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - $self->handle->delete(@objects); -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->filter("Labeling", $coderef); -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->find("Labeling", $coderef); -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/SmartArray/MembershipSmartArrayDAO.pm b/lib/BibSpace/DAO/SmartArray/MembershipSmartArrayDAO.pm deleted file mode 100644 index 229f372..0000000 --- a/lib/BibSpace/DAO/SmartArray/MembershipSmartArrayDAO.pm +++ /dev/null @@ -1,139 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T16:44:28 -package MembershipSmartArrayDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Membership; -with 'IDAO'; -use Try::Tiny; -use List::Util qw(first); - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - return $self->handle->all("Membership"); -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - return $self->handle->count("Membership"); -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - return $self->handle->empty("Membership"); -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - $self->handle->exists($object); -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - $self->handle->save(@objects); -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - # smart array does not require updating! Objects are direct references! -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - $self->handle->delete(@objects); -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->filter("Membership", $coderef); -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->find("Membership", $coderef); -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/SmartArray/TagSmartArrayDAO.pm b/lib/BibSpace/DAO/SmartArray/TagSmartArrayDAO.pm deleted file mode 100644 index 6d433bf..0000000 --- a/lib/BibSpace/DAO/SmartArray/TagSmartArrayDAO.pm +++ /dev/null @@ -1,141 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T16:44:28 -package TagSmartArrayDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Tag; -with 'IDAO'; -use Try::Tiny; -use List::Util qw(first); - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - return $self->handle->all("Tag"); - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - return $self->handle->count("Tag"); -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - return $self->handle->empty("Tag"); -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - $self->handle->exists($object); -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - $self->handle->save(@objects); -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - # smart array does not require updating! Objects are direct references! -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - $self->handle->delete(@objects); -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->filter("Tag", $coderef); -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->find("Tag", $coderef); -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/SmartArray/TagTypeSmartArrayDAO.pm b/lib/BibSpace/DAO/SmartArray/TagTypeSmartArrayDAO.pm deleted file mode 100644 index fe13d48..0000000 --- a/lib/BibSpace/DAO/SmartArray/TagTypeSmartArrayDAO.pm +++ /dev/null @@ -1,141 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T16:44:28 -package TagTypeSmartArrayDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::TagType; -with 'IDAO'; -use Try::Tiny; -use List::Util qw(first); - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - return $self->handle->all("TagType"); - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - return $self->handle->count("TagType"); -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - return $self->handle->empty("TagType"); -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - $self->handle->exists($object); -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - $self->handle->save(@objects); -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - # smart array does not require updating! Objects are direct references! -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - $self->handle->delete(@objects); -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->filter("TagType", $coderef); -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->find("TagType", $coderef); -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/SmartArray/TeamSmartArrayDAO.pm b/lib/BibSpace/DAO/SmartArray/TeamSmartArrayDAO.pm deleted file mode 100644 index b7c967b..0000000 --- a/lib/BibSpace/DAO/SmartArray/TeamSmartArrayDAO.pm +++ /dev/null @@ -1,139 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T16:44:28 -package TeamSmartArrayDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Team; -with 'IDAO'; -use Try::Tiny; -use List::Util qw(first); - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - return $self->handle->all("Team"); -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - return $self->handle->count("Team"); -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - return $self->handle->empty("Team"); -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - $self->handle->exists($object); -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - $self->handle->save(@objects); -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - # smart array does not require updating! Objects are direct references! -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - $self->handle->delete(@objects); -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->filter("Team", $coderef); -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->find("Team", $coderef); -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/SmartArray/TypeSmartArrayDAO.pm b/lib/BibSpace/DAO/SmartArray/TypeSmartArrayDAO.pm deleted file mode 100644 index 782b4dc..0000000 --- a/lib/BibSpace/DAO/SmartArray/TypeSmartArrayDAO.pm +++ /dev/null @@ -1,139 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T16:44:28 -package TypeSmartArrayDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::Type; -with 'IDAO'; -use Try::Tiny; -use List::Util qw(first); - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - return $self->handle->all("Type"); -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - return $self->handle->count("Type"); -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - return $self->handle->empty("Type"); -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - $self->handle->exists($object); -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - $self->handle->save(@objects); -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - # smart array does not require updating! Objects are direct references! -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - $self->handle->delete(@objects); -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->filter("Type", $coderef); -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->find("Type", $coderef); -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/SmartArray/UserSmartArrayDAO.pm b/lib/BibSpace/DAO/SmartArray/UserSmartArrayDAO.pm deleted file mode 100644 index 3242203..0000000 --- a/lib/BibSpace/DAO/SmartArray/UserSmartArrayDAO.pm +++ /dev/null @@ -1,142 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T16:44:28 -package UserSmartArrayDAO; - -use namespace::autoclean; - -use Moose; -use BibSpace::DAO::Interface::IDAO; -use BibSpace::Model::User; -with 'IDAO'; -use Try::Tiny; -use List::MoreUtils qw(any uniq); -use List::Util qw(first); - -# Inherited fields from BibSpace::DAO::Interface::IDAO Mixin: -# has 'logger' => ( is => 'ro', does => 'ILogger', required => 1); -# has 'handle' => ( is => 'ro', required => 1); - -=item all - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub all { - my ($self) = @_; - - return $self->handle->all("User"); - -} -before 'all' => sub { shift->logger->entering(""); }; -after 'all' => sub { shift->logger->exiting(""); }; - -=item count - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub count { - my ($self) = @_; - return $self->handle->count("User"); -} -before 'count' => sub { shift->logger->entering(""); }; -after 'count' => sub { shift->logger->exiting(""); }; - -=item empty - Method documentation placeholder. - This method takes no arguments and returns array or scalar. -=cut - -sub empty { - my ($self) = @_; - return $self->handle->empty("User"); -} -before 'empty' => sub { shift->logger->entering(""); }; -after 'empty' => sub { shift->logger->exiting(""); }; - -=item exists - Method documentation placeholder. - This method takes single object as argument and returns a scalar. -=cut - -sub exists { - my ($self, $object) = @_; - $self->handle->exists($object); -} -before 'exists' => sub { shift->logger->entering(""); }; -after 'exists' => sub { shift->logger->exiting(""); }; - -=item save - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub save { - my ($self, @objects) = @_; - $self->handle->save(@objects); -} -before 'save' => sub { shift->logger->entering(""); }; -after 'save' => sub { shift->logger->exiting(""); }; - -=item update - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub update { - my ($self, @objects) = @_; - - # smart array does not require updating! Objects are direct references! -} -before 'update' => sub { shift->logger->entering(""); }; -after 'update' => sub { shift->logger->exiting(""); }; - -=item delete - Method documentation placeholder. - This method takes single object or array of objects as argument and returns nothing. -=cut - -sub delete { - my ($self, @objects) = @_; - $self->handle->delete(@objects); -} -before 'delete' => sub { shift->logger->entering(""); }; -after 'delete' => sub { shift->logger->exiting(""); }; - -=item filter - Method documentation placeholder. -=cut - -sub filter { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->filter("User", $coderef); -} -before 'filter' => sub { shift->logger->entering(""); }; -after 'filter' => sub { shift->logger->exiting(""); }; - -=item find - Method documentation placeholder. -=cut - -sub find { - my ($self, $coderef) = @_; - die "" - . (caller(0))[3] - . " incorrect type of argument. Got: '" - . ref($coderef) - . "', expected: " - . (ref sub { }) . "." - unless (ref $coderef eq ref sub { }); - return $self->handle->find("User", $coderef); -} -before 'find' => sub { shift->logger->entering(""); }; -after 'find' => sub { shift->logger->exiting(""); }; -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/DAO/SmartArrayDAOFactory.pm b/lib/BibSpace/DAO/SmartArrayDAOFactory.pm deleted file mode 100644 index 46c4683..0000000 --- a/lib/BibSpace/DAO/SmartArrayDAOFactory.pm +++ /dev/null @@ -1,149 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T16:44:28 -package SmartArrayDAOFactory; - -use namespace::autoclean; - -use Moose; -use BibSpace::Util::ILogger; -use BibSpace::DAO::SmartArray::TagTypeSmartArrayDAO; -use BibSpace::DAO::SmartArray::TeamSmartArrayDAO; -use BibSpace::DAO::SmartArray::AuthorSmartArrayDAO; -use BibSpace::DAO::SmartArray::AuthorshipSmartArrayDAO; -use BibSpace::DAO::SmartArray::MembershipSmartArrayDAO; -use BibSpace::DAO::SmartArray::EntrySmartArrayDAO; -use BibSpace::DAO::SmartArray::LabelingSmartArrayDAO; -use BibSpace::DAO::SmartArray::TagSmartArrayDAO; -use BibSpace::DAO::SmartArray::ExceptionSmartArrayDAO; -use BibSpace::DAO::SmartArray::TypeSmartArrayDAO; -use BibSpace::DAO::SmartArray::UserSmartArrayDAO; -use BibSpace::DAO::DAOFactory; -extends 'DAOFactory'; - -has 'handle' => (is => 'ro', required => 1); -has 'logger' => (is => 'ro', does => 'ILogger', required => 1); -has 'e_factory' => (is => 'ro', isa => 'EntityFactory', required => 1); - -sub getTagTypeDao { - my $self = shift; - return TagTypeSmartArrayDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getTagTypeDao' => sub { shift->logger->entering(""); }; -after 'getTagTypeDao' => sub { shift->logger->exiting(""); }; - -sub getTeamDao { - my $self = shift; - return TeamSmartArrayDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getTeamDao' => sub { shift->logger->entering(""); }; -after 'getTeamDao' => sub { shift->logger->exiting(""); }; - -sub getAuthorDao { - my $self = shift; - return AuthorSmartArrayDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getAuthorDao' => sub { shift->logger->entering(""); }; -after 'getAuthorDao' => sub { shift->logger->exiting(""); }; - -sub getAuthorshipDao { - my $self = shift; - return AuthorshipSmartArrayDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getAuthorshipDao' => sub { shift->logger->entering(""); }; -after 'getAuthorshipDao' => sub { shift->logger->exiting(""); }; - -sub getMembershipDao { - my $self = shift; - return MembershipSmartArrayDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getMembershipDao' => sub { shift->logger->entering(""); }; -after 'getMembershipDao' => sub { shift->logger->exiting(""); }; - -sub getEntryDao { - my $self = shift; - return EntrySmartArrayDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getEntryDao' => sub { shift->logger->entering(""); }; -after 'getEntryDao' => sub { shift->logger->exiting(""); }; - -sub getLabelingDao { - my $self = shift; - return LabelingSmartArrayDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getLabelingDao' => sub { shift->logger->entering(""); }; -after 'getLabelingDao' => sub { shift->logger->exiting(""); }; - -sub getTagDao { - my $self = shift; - return TagSmartArrayDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getTagDao' => sub { shift->logger->entering(""); }; -after 'getTagDao' => sub { shift->logger->exiting(""); }; - -sub getExceptionDao { - my $self = shift; - return ExceptionSmartArrayDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getExceptionDao' => sub { shift->logger->entering(""); }; -after 'getExceptionDao' => sub { shift->logger->exiting(""); }; - -sub getTypeDao { - my $self = shift; - return TypeSmartArrayDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getTypeDao' => sub { shift->logger->entering(""); }; -after 'getTypeDao' => sub { shift->logger->exiting(""); }; - -sub getUserDao { - my $self = shift; - return UserSmartArrayDAO->new( - logger => $self->logger, - handle => $self->handle, - e_factory => $self->e_factory - ); -} -before 'getUserDao' => sub { shift->logger->entering(""); }; -after 'getUserDao' => sub { shift->logger->exiting(""); }; - -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/Functions/BackupFunctions.pm b/lib/BibSpace/Functions/BackupFunctions.pm index 9b118d4..b700a85 100644 --- a/lib/BibSpace/Functions/BackupFunctions.pm +++ b/lib/BibSpace/Functions/BackupFunctions.pm @@ -4,11 +4,9 @@ use BibSpace::Functions::MySqlBackupFunctions; use BibSpace::Model::Backup; use BibSpace::Functions::Core; use BibSpace::Functions::FDB; -use BibSpace::Backend::SmartBackendHelper; use JSON -convert_blessed_universally; use BibSpace::Model::SerializableBase::BibSpaceDTO; -use Storable; use Data::Dumper; use utf8; @@ -30,11 +28,9 @@ our @ISA = qw( Exporter ); our @EXPORT = qw( find_backup read_backups - do_storable_backup do_json_backup do_mysql_backup restore_json_backup - restore_storable_backup delete_old_backups ); ## Trivial DAO FIND @@ -87,25 +83,6 @@ sub do_json_backup { return $backup; } -sub do_storable_backup { - my $app = shift; - my $name = shift // 'normal'; - - my $backup_dir = Path::Tiny->new($app->get_backups_dir)->relative; - $backup_dir =~ s!/*$!/!; # hy do I need to add this??? - - my $backup = Backup->create($name, "storable"); - $backup->dir("" . $backup_dir); - - my $layer = $app->repo->lr->get_read_layer; - my $path = "" . $backup->get_path; - - $Storable::forgive_me = "do store regexp please"; - Storable::store $layer, $path; - - return $backup; -} - sub do_mysql_backup { my $app = shift; my $name = shift // 'normal'; @@ -138,12 +115,8 @@ sub restore_json_backup { my $dto = BibSpaceDTO->new(); my $decodedDTO; try { - $decodedDTO = $dto->toLayeredRepo( - $jsonString, - $app->repo->lr->uidProvider, - $app->repo->lr->preferences - ); - $success = 1; + $decodedDTO = $dto->toLayeredRepo($jsonString, $app->repo); + $success = 1; } catch { $app->logger->error("Exception during JSON restore: $_"); @@ -155,8 +128,6 @@ sub restore_json_backup { my @layers = $app->repo->lr->get_all_layers; foreach (@layers) { $_->reset_data } - # $app->repo->lr->reset_uid_providers; - for my $type (@{$app->repo->entities}, @{$app->repo->relations}) { my $arrayRef = $decodedDTO->data->{$type}; @@ -190,45 +161,10 @@ sub restore_json_backup { }; } } - BibSpace::Backend::SmartBackendHelper::linkData($app); } return $success; } -sub restore_storable_backup { - my $backup = shift; - my $app = shift; - - my $layer = retrieve($backup->get_path); - - say "restore_storable_backup has retrieved:" . $layer->get_summary_table; - - ## this writes to all layers!! - - my @layers = $app->repo->lr->get_all_layers; - foreach (@layers) { $_->reset_data } - $app->repo->lr->reset_uid_providers; - -# say "Smart layer after reset:" . $app->repo->lr->get_layer('smart')->get_summary_table; - - my $layer_to_replace = $app->repo->lr->get_read_layer; - $app->repo->lr->replace_layer($layer_to_replace->name, $layer); - - foreach my $layer (@layers) { - next if $layer->name eq $layer_to_replace->name; - - $app->repo->lr->copy_data( - {from => $layer_to_replace->name, to => $layer->name}); - } - -# say "Smart layer after replace:" . $app->repo->lr->get_layer('smart')->get_summary_table; - - say "restore_storable_backup DONE. Smart layer after copy_data:" - . $app->repo->lr->get_layer('smart')->get_summary_table; - say "restore_storable_backup DONE. All layer after copy_data:" - . $app->repo->lr->get_summary_table; -} - sub delete_old_backups { my $app = shift; my $age_treshold = shift diff --git a/lib/BibSpace/Functions/Core.pm b/lib/BibSpace/Functions/Core.pm index edce8b2..60cf4fc 100644 --- a/lib/BibSpace/Functions/Core.pm +++ b/lib/BibSpace/Functions/Core.pm @@ -119,18 +119,6 @@ sub fix_bibtex_national_characters { # makes sth \ss sth --> sth {\ss} sth $str =~ s/(?install_driver("mysql"); - -# say "!!! DROPPING DATABASE '$db_database'."; -# try { -# my $rc = $drh->func( 'dropdb', $db_database, $db_host, $db_user, $db_pass, 'admin' ); -# } -# catch { -# warn $_; -# }; - -# say "!!! CREATING DATABASE '$db_database'."; -# try { -# my $rc = $drh->func( 'createdb', $db_database, $db_host, $db_user, $db_pass, 'admin' ); -# } -# catch { -# warn $_; -# }; - - # say "Restarting connection to '$db_database'."; - # try { - # $dbh = db_connect( $db_host, $db_user, $db_database, $db_pass ); - # create_main_db($dbh); - - # } - # catch { - # warn $_; - # }; - - return $dbh; -} - sub create_main_db { my $dbh = shift; @@ -262,12 +221,7 @@ sub create_main_db { # prepare_token_table_mysql($dbh); prepare_cron_table($dbh); prepare_user_table_mysql($dbh); - -# this causes desynchronisation between layers!! -# mysql has some initial data, whereas smart doesnt (so id providers are unaware of the data as well) - populate_tables($dbh); - - # $dbh->commit(); + apply_migrations($dbh); } # sub prepare_token_table_mysql { @@ -359,42 +313,17 @@ sub prepare_user_table_mysql { }; } -sub populate_tables { +sub apply_migrations { my $dbh = shift; try { -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('incollection','inproceedings',NULL,1)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('incollection','bibtex-incollection',NULL,0)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('inproceedings','bibtex-inproceedings',NULL,0)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('inbook','book',NULL,0)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('mastersthesis','theses',NULL,1)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('phdthesis','theses',NULL,1)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('phdthesis','volumes',NULL,1)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('proceedings','volumes',NULL,1)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('article','article',NULL,1)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('book','book',NULL,0)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('inbook','inbook',NULL,0)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('incollection','incollection',NULL,0)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('inproceedings','inproceedings',NULL,1)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('manual','manual','Manuals',1)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('mastersthesis','mastersthesis',NULL,0)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('misc','misc',NULL,1)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('phdthesis','phdthesis',NULL,0)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('proceedings','proceedings',NULL,0)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('techreport','techreport',NULL,1)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('unpublished','unpublished',NULL,0)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('book','volumes',NULL,0)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('mastersthesis','supervised_theses','Supervised Theses',0)"); -# $dbh->do("INSERT IGNORE INTO OurType_to_Type VALUES('phdthesis','supervised_theses','Supervised Theses',0)"); - -# $dbh->do("INSERT IGNORE INTO `TagType` VALUES ('Tag','keyword',1)"); -# $dbh->do("INSERT IGNORE INTO `TagType` VALUES ('Category','12 categories defined as in research agenda',2)"); -# $dbh->do("INSERT IGNORE INTO `TagType` VALUES ('Other','Reserved for other groupings of papers',3)"); + say "Attempt to migrate table Author"; + $dbh->do( + "ALTER TABLE `Author` DROP PRIMARY KEY, MODIFY id INTEGER(8) PRIMARY KEY AUTO_INCREMENT" + ); } catch { - say "Data already exist. Doing nothing."; + say "Migration not necessary or failed: $_"; }; - - # $dbh->commit(); } 1; diff --git a/lib/BibSpace/Functions/FPublications.pm b/lib/BibSpace/Functions/FPublications.pm index a5e0dda..c15e9c5 100644 --- a/lib/BibSpace/Functions/FPublications.pm +++ b/lib/BibSpace/Functions/FPublications.pm @@ -53,7 +53,7 @@ sub Freassign_authors_to_entries_given_by_array { } if ($create_new == 1 or defined $author) { - my $authorship = Authorship->new( + my $authorship = $app->entityFactory->new_Authorship( author => $author->get_master, entry => $entry, author_id => $author->get_master->id, @@ -246,20 +246,20 @@ sub Fget_publications_core { my $query_tag = shift; my $query_team = shift; my $query_permalink = shift; - #<<< no perltidy here - my $query_visible = shift // 0; # value can be set only from code (not from browser) - my $query_hidden = shift; # value can be set only from code (not from browser) - my $debug = shift // 0; # value can be set only from code (not from browser) - - # catch bad urls like: ...&entry_type=&tag=&author= - $query_author = undef if defined $query_author and length( "".$query_author ) < 1; - $query_year = undef if defined $query_year and length( "".$query_year ) < 1; - $query_bibtex_type = undef if defined $query_bibtex_type and length( "".$query_bibtex_type ) < 1; - $query_entry_type = undef if defined $query_entry_type and length( "".$query_entry_type ) < 1; - $query_tag = undef if defined $query_tag and length( "".$query_tag ) < 1; - $query_team = undef if defined $query_team and length( "".$query_team ) < 1; - $query_permalink = undef if defined $query_permalink and length( "".$query_permalink ) < 1; - #>>> + #<<< no perltidy here + my $query_visible = shift // 0; # value can be set only from code (not from browser) + my $query_hidden = shift; # value can be set only from code (not from browser) + my $debug = shift // 0; # value can be set only from code (not from browser) + + # catch bad urls like: ...&entry_type=&tag=&author= + $query_author = undef if defined $query_author and length( "".$query_author ) < 1; + $query_year = undef if defined $query_year and length( "".$query_year ) < 1; + $query_bibtex_type = undef if defined $query_bibtex_type and length( "".$query_bibtex_type ) < 1; + $query_entry_type = undef if defined $query_entry_type and length( "".$query_entry_type ) < 1; + $query_tag = undef if defined $query_tag and length( "".$query_tag ) < 1; + $query_team = undef if defined $query_team and length( "".$query_team ) < 1; + $query_permalink = undef if defined $query_permalink and length( "".$query_permalink ) < 1; + #>>> if ($debug == 1) { $self->app->logger->debug(Dumper $self->req->params); @@ -305,14 +305,14 @@ sub Fget_publications_core { if (defined $query_author) { if (Scalar::Util::looks_like_number($query_author)) { $author_obj - = $self->app->repo->authors_find(sub { $_->master_id == $query_author } + = $self->app->repo->authors_find(sub { $_->master->id == $query_author } ); $author_obj ||= $self->app->repo->authors_find(sub { $_->id == $query_author }); } else { - $author_obj - = $self->app->repo->authors_find(sub { $_->master eq $query_author }); + $author_obj = $self->app->repo->authors_find( + sub { $_->master->name eq $query_author }); $author_obj ||= $self->app->repo->authors_find(sub { $_->uid eq $query_author }); } @@ -395,7 +395,7 @@ sub Fget_publications_core { # Entries of visible authors # by default, we return entries of all authors if (defined $query_visible and $query_visible == 1) { - @entries = grep { $_->is_visible } @entries; + @entries = grep { $_->belongs_to_visible_author } @entries; } ######## complex filters diff --git a/lib/BibSpace/Functions/MySqlBackupFunctions.pm b/lib/BibSpace/Functions/MySqlBackupFunctions.pm index bc2c375..32efd1c 100644 --- a/lib/BibSpace/Functions/MySqlBackupFunctions.pm +++ b/lib/BibSpace/Functions/MySqlBackupFunctions.pm @@ -60,67 +60,4 @@ sub dump_mysql_to_file { return $fname; } -# This is the old function (version <0.5) used to restroee backups. -# It does not work with all MySQL server configurations, so we dont use it. -# sub do_restore_backup_from_file { -# my $app = shift; -# my $dbh = shift; -# my $file_path = shift; -# my $config = shift; - -# # I assume that $file_path is the SQL dump that I want to restore - -# my $file_exists = 0; -# if ( -e $file_path ) { -# $file_exists = 1; -# } -# else { -# $app->logger->warn("Cannot restore database from file $file_path. I stop now."); -# return; -# } - -# try{ -# $dbh->{mysql_auto_reconnect} = 0; -# $dbh->disconnect(); -# } -# catch{ -# $app->logger->error("Cannot disconnect: $_"); -# }; - -# my $db_host = $config->{db_host}; -# my $db_user = $config->{db_user}; -# my $db_database = $config->{db_database}; -# my $db_pass = $config->{db_pass}; - -# my $cmd = "mysql -u $db_user -p$db_pass $db_database < $file_path"; -# if ( $db_pass =~ /^\s*$/ ) { # password empty -# $cmd = "mysql -u $db_user $db_database < $file_path"; -# } -# my $command_output = ""; -# try { -# $command_output = `$cmd`; -# } -# catch { -# $app->logger->error("Restoring DB failed from file $file_path. Reason: $_. Status? $?. Command_output: $command_output."); -# db_connect($db_host, $db_user, $db_database, $db_pass); -# $app->db; # this will reconnect -# $app->db->{mysql_auto_reconnect} = 1; -# }; - -# $app->db(); # this will reconnect -# $app->db->{mysql_auto_reconnect} = 1; - -# if ( $? == 0 ) { -# $app->repo->hardReset; -# $app->setup_repositories; - -# $app->logger->info("Restoring backup succeeded from file $file_path"); -# return 1; -# } -# else { -# $app->logger->error("Restoring backup FAILED from file $file_path"); -# return; -# } -# } - 1; diff --git a/lib/BibSpace/Model/Author.pm b/lib/BibSpace/Model/Author.pm index 2a47297..eadbdbb 100644 --- a/lib/BibSpace/Model/Author.pm +++ b/lib/BibSpace/Model/Author.pm @@ -8,6 +8,7 @@ use List::MoreUtils qw(any uniq); use BibSpace::Model::Membership; use Moose; use MooseX::Storage; +use MooseX::Privacy; with Storage; require BibSpace::Model::IEntity; require BibSpace::Model::IAuthored; @@ -16,41 +17,28 @@ with 'IEntity', 'IAuthored', 'IMembered'; use BibSpace::Model::SerializableBase::AuthorSerializableBase; extends 'AuthorSerializableBase'; -# Cast self to SerializableBase and serialize -sub TO_JSON { - my $self = shift; - my $copy = $self->meta->clone_object($self); - return AuthorSerializableBase->meta->rebless_instance_back($copy)->TO_JSON; -} - -has 'master' => ( - is => 'rw', - isa => 'Maybe[Str]', - default => sub { shift->{uid} }, - traits => ['DoNotSerialize'], - documentation => q{Author master name. Redundant field.} -); - +# A placeholder for master object. This will be lazily populated on first read has 'masterObj' => ( is => 'rw', isa => 'Maybe[Author]', default => sub {undef}, - traits => ['DoNotSerialize'], + traits => [qw/DoNotSerialize/, qw/Private/], documentation => q{Author's master author object.} ); # called after the default constructor sub BUILD { my $self = shift; - $self->id; # trigger lazy execution of idProvider - if ((!defined $self->master) or ($self->master eq '')) { - $self->master($self->uid); - } - if ((!defined $self->master_id) and (defined $self->{id})) { - $self->master_id($self->id); - } - if ((defined $self->masterObj) and ($self->masterObj == $self)) { - $self->masterObj(undef); + $self->name($self->uid); +} + +# Entitiy receives ID first on save to DB +# This can be fixed with generating UUID on object creation and referencing master using uuid as FK +sub post_insert_hook { + my $self = shift; + if (defined $self->id and $self->id > 0) { + $self->get_master_id; # sets master_id if unset + $self->repo->authors_update($self); } } @@ -66,37 +54,36 @@ sub equals { return $result; } -sub set_master { - my $self = shift; - my $master_author = shift; - - $self->masterObj($master_author); - - $self->master($master_author->uid); - $self->master_id($master_author->id); +sub master_name { + my $self = shift; + return $self->get_master->uid; } -sub get_master { +sub master { my $self = shift; + return $self if not $self->master_id; + return $self if not $self->masterObj; + return $self->masterObj; +} - return $self if $self->is_master; - return $self->masterObj if $self->masterObj; +sub set_master { + my $self = shift; + my $master = shift; + if (not $master->id) { + warn "Cannot set_master if master has no ID"; + return; + } + $self->masterObj($master); + $self->master_id($master->id); +} - warn "SERIOUS WARNING! Cannot derive master for " - . $self->uid - . ". Author is not master, but masterObj is undef. id '" - . $self->id - . "' master_id '" - . $self->master_id . "'."; - return; +sub get_master { + shift->master; } sub is_master { my $self = shift; - - if ($self->equals($self->masterObj) or $self->master_id == $self->id) { - return 1; - } + return 1 if ($self->id == $self->master_id); return; } @@ -108,34 +95,22 @@ sub is_minion { sub is_minion_of { my $self = shift; my $master = shift; - - if ($self->masterObj and $self->masterObj->equals($master)) { - return 1; - } + return 1 if $self->master_id == $master->id; return; } -sub update_master_name { +sub update_name { my $self = shift; my $new_master = shift; $self->uid($new_master); - - if ($self->is_minion) { - # - } - else { - $self->master($new_master); - } + $self->name($new_master); return 1; } sub remove_master { my $self = shift; - - $self->masterObj(undef); - $self->master($self->uid); - $self->master_id($self->id); + $self->set_master($self); } sub add_minion { @@ -152,6 +127,8 @@ sub can_merge_authors { my $source_author = shift; if ( (defined $source_author) + and (defined $source_author->id) + and (defined $self->id) and ($source_author->id != $self->id) and (!$self->equals($source_author))) { @@ -188,15 +165,49 @@ sub can_be_deleted { return; } +sub has_team { + my $self = shift; + my $team = shift; + return grep { $_->id eq $team->id } $self->get_teams; +} + +sub get_teams { + my $self = shift; + my @team_ids + = map { $_->team_id } + $self->repo->memberships_filter( + sub { $_->author_id == $self->id or $_->author_id == $self->get_master_id } + ); + return $self->repo->teams_filter( + sub { + my $t = $_; + return grep { $_ eq $t->id } @team_ids; + } + ); +} + +sub get_entries { + my $self = shift; + my @entry_ids = map { $_->entry_id } + $self->repo->authorships_filter(sub { $_->author_id == $self->id }); + return $self->repo->entries_filter( + sub { + my $e = $_; + return grep { $_ eq $e->id } @entry_ids; + } + ); +} + sub has_entry { my $self = shift; my $entry = shift; - my $authorship = $self->authorships_find( - sub { - $_->entry->equals($entry) and $_->author->equals($self); - } + my $authorship_to_find = $self->repo->entityFactory->new_Authorship( + author_id => $self->id, + entry_id => $entry->id ); + my $authorship + = $self->repo->authorships_find(sub { $_->equals_id($authorship_to_find) }); return defined $authorship; } @@ -208,13 +219,11 @@ sub joined_team { return -1 if !defined $team; - my $query_mem = Membership->new( - author => $self->get_master, - team => $team, + my $query_mem = $self->repo->entityFactory->new_Membership( + team_id => $team->id, author_id => $self->get_master->id, - team_id => $team->id ); - my $mem = $self->memberships_find(sub { $_->equals($query_mem) }); + my $mem = $self->repo->memberships_find(sub { $_->equals($query_mem) }); return -1 if !defined $mem; return $mem->start; @@ -226,13 +235,11 @@ sub left_team { return -1 if !defined $team; - my $query_mem = Membership->new( - author => $self->get_master, - team => $team, + my $query_mem = $self->repo->entityFactory->new_Membership( author_id => $self->get_master->id, team_id => $team->id ); - my $mem = $self->memberships_find(sub { $_->equals($query_mem) }); + my $mem = $self->repo->memberships_find(sub { $_->equals($query_mem) }); return -1 if !defined $mem; return $mem->stop; @@ -246,24 +253,27 @@ sub update_membership { return if !$team; - my $query_mem_master = Membership->new( - author => $self->get_master, - team => $team, + my $query_mem_master = $self->repo->entityFactory->new_Membership( author_id => $self->get_master->id, team_id => $team->id ); - my $query_mem_minor = Membership->new( - author => $self, - team => $team, + my $query_mem_minor = $self->repo->entityFactory->new_Membership( author_id => $self->id, team_id => $team->id ); my $mem_master - = $self->memberships_find(sub { $_->equals($query_mem_master) }); - my $mem_minor = $self->memberships_find(sub { $_->equals($query_mem_minor) }); + = $self->repo->memberships_find(sub { $_->equals($query_mem_master) }); + my $mem_minor + = $self->repo->memberships_find(sub { $_->equals($query_mem_minor) }); - if ($mem_minor != $mem_master) { - warn "MEMBERSHIP for master differs to membership of minor!"; + if ( defined $mem_minor + and defined $mem_master + and not $mem_minor->equals($mem_master)) + { + warn "MEMBERSHIP for master differs to membership of minor! master has " + . $mem_master->id + . ", minor has " + . $mem_minor->id; } my $mem = $mem_master // $mem_minor; @@ -282,19 +292,25 @@ sub update_membership { $mem->start($start) if defined $start; $mem->stop($stop) if defined $stop; + $self->repo->memberships_update($mem); return 1; } #################################################################################### TAGS -sub get_tags { +sub get_tags_of_type { + my $self = shift; + my $tag_type = shift // 1; + return grep { $_->type == $tag_type } $self->get_tags; +} - my $self = shift; - my $type = shift // 1; +sub get_tags { + my $self = shift; + my $potentialType = shift; + die "use entry->get_tags_of_type instead" if defined $potentialType; my @myTags; - - map { push @myTags, $_->get_tags($type) } $self->get_entries; + map { push @myTags, $_->get_tags } $self->get_entries; @myTags = uniq @myTags; return @myTags; diff --git a/lib/BibSpace/Model/Authorship.pm b/lib/BibSpace/Model/Authorship.pm index d2f2661..c138d0b 100644 --- a/lib/BibSpace/Model/Authorship.pm +++ b/lib/BibSpace/Model/Authorship.pm @@ -1,77 +1,44 @@ package Authorship; -use Data::Dumper; use utf8; use v5.16; use BibSpace::Model::Author; use BibSpace::Model::Entry; use BibSpace::Model::IRelation; use Try::Tiny; +use Data::Dumper; +$Data::Dumper::Maxdepth = 2; use Moose; with 'IRelation'; - use BibSpace::Model::SerializableBase::AuthorshipSerializableBase; extends 'AuthorshipSerializableBase'; -# Cast self to SerializableBase and serialize -sub TO_JSON { +# # the fileds below are used for linking process +# has 'entry_id' => (is => 'ro', isa => 'Int'); +# has 'author_id' => (is => 'ro', isa => 'Int'); + +sub author { my $self = shift; - my $copy = $self->meta->clone_object($self); - return AuthorshipSerializableBase->meta->rebless_instance_back($copy) - ->TO_JSON; + return $self->repo->authors_find(sub { $_->id == $self->author_id }); } -# the fileds below are used for linking process -has 'entry_id' => (is => 'ro', isa => 'Int'); -has 'author_id' => (is => 'ro', isa => 'Int'); -has 'entry' => ( - is => 'rw', - isa => 'Maybe[Entry]', - traits => ['DoNotSerialize'] # due to cycyles -); -has 'author' => ( - is => 'rw', - isa => 'Maybe[Author]', - traits => ['DoNotSerialize'] # due to cycyles -); - -sub id { +sub entry { my $self = shift; - return "(" . $self->entry_id . "-" . $self->author->id . ")" - if defined $self->author; - return "(" . $self->entry_id . "-" . $self->author_id . ")"; + return $self->repo->entries_find(sub { $_->id == $self->entry_id }); } -sub validate { +sub id { my $self = shift; - if (defined $self->author and defined $self->entry) { - if ($self->author->id != $self->author_id) { - die "Label has been built wrongly author->id and author_id differs.\n" - . "label->author->id: " - . $self->author->id - . ", label->author_id: " - . $self->author_id; - } - if ($self->entry->id != $self->entry_id) { - die "Label has been built wrongly entry->id and entry_id differs.\n" - . "label->entry->id: " - . $self->entry->id - . ", label->entry_id: " - . $self->entry_id; - } - } - return 1; + return + "(" + . ($self->author_id || "undef") . "-" + . ($self->entry_id || "undef") . ")"; } sub equals { my $self = shift; my $obj = shift; - die "Comparing apples to peaches! " . ref($self) . " against " . ref($obj) - unless ref($self) eq ref($obj); - if ($self->entry and $self->author and $obj->entry and $obj->author) { - return $self->equals_obj($obj); - } return $self->equals_id($obj); } @@ -84,15 +51,6 @@ sub equals_id { return 1; } -sub equals_obj { - my $self = shift; - my $obj = shift; - die "Comparing apples to peaches!!" unless ref($self) eq ref($obj); - return if !$self->entry->equals($obj->entry); - return if !$self->author->equals($obj->author); - return 1; -} - no Moose; __PACKAGE__->meta->make_immutable; 1; diff --git a/lib/BibSpace/Model/Backup.pm b/lib/BibSpace/Model/Backup.pm index cbbca8b..fe9261e 100644 --- a/lib/BibSpace/Model/Backup.pm +++ b/lib/BibSpace/Model/Backup.pm @@ -20,7 +20,7 @@ class_has 'date_format_pattern' => (is => 'ro', default => '%Y-%m-%d-%H-%M-%S'); has 'uuid' => (is => 'rw', isa => 'Str', default => sub { create_uuid_as_string(UUID_V4) }); has 'name' => (is => 'rw', isa => 'Str', default => 'normal'); -has 'type' => (is => 'rw', isa => 'Str', default => 'storable'); +has 'type' => (is => 'rw', isa => 'Str', default => 'json'); has 'filename' => (is => 'rw', isa => 'Maybe[Str]'); has 'dir' => (is => 'rw', isa => 'Maybe[Str]'); has 'allow_delete' => (is => 'rw', isa => 'Bool', default => 1); @@ -102,11 +102,10 @@ sub get_age { sub create { my $self = shift; my $name = shift; - my $type = shift // 'storable'; + my $type = shift // 'json'; - my $ext = '.dat'; - $ext = '.sql' if $type eq 'mysql'; - $ext = '.json' if $type eq 'json'; + my $ext = '.json'; + $ext = '.sql' if $type eq 'mysql'; my $uuid = create_uuid_as_string(UUID_V4); @@ -142,7 +141,6 @@ sub parse { my $type = shift @tokens; my $date = shift @tokens; - $date =~ s/\.dat//g; $date =~ s/\.sql//g; $date =~ s/\.json//g; diff --git a/lib/BibSpace/Model/Entry.pm b/lib/BibSpace/Model/Entry.pm index 2d64dad..355b5f2 100644 --- a/lib/BibSpace/Model/Entry.pm +++ b/lib/BibSpace/Model/Entry.pm @@ -30,13 +30,6 @@ with 'IEntity', 'ILabeled', 'IAuthored', 'IHavingException'; use BibSpace::Model::SerializableBase::EntrySerializableBase; extends 'EntrySerializableBase'; -# Cast self to SerializableBase and serialize -sub TO_JSON { - my $self = shift; - my $copy = $self->meta->clone_object($self); - return EntrySerializableBase->meta->rebless_instance_back($copy)->TO_JSON; -} - has 'entry_type' => (is => 'rw', isa => 'Str', default => 'paper'); has 'bibtex_key' => (is => 'rw', isa => 'Maybe[Str]'); has '_bibtex_type' => @@ -233,11 +226,11 @@ sub discover_attachments { # $self->add_attachment( 'unknown', $_ ) for @discovery_other; } -=item is_visible +=item belongs_to_visible_author Entry is visible if at least one of its authors is visible =cut -sub is_visible { +sub belongs_to_visible_author { my $self = shift; my $visible_author = any { $_->is_visible } $self->get_authors; @@ -295,14 +288,11 @@ sub is_talk { sub matches_our_type { my $self = shift; my $oType = shift; - my $repo = shift; - - die "This method requires repo, sorry." unless $repo; # example: ourType = inproceedings # mathces bibtex types: inproceedings, incollection - my $mapping = $repo->types_find( + my $mapping = $self->repo->types_find( sub { ($_->our_type cmp $oType) == 0; } @@ -332,27 +322,24 @@ sub populate_from_bib { return if !$self->has_valid_bibtex; - if (defined $self->bib and $self->bib ne '') { - my $bibtex_entry = new Text::BibTeX::Entry(); - my $s = $bibtex_entry->parse_s($self->bib); + my $bibtex_entry = new Text::BibTeX::Entry(); + my $s = $bibtex_entry->parse_s($self->bib); - $self->bibtex_key($bibtex_entry->key); - my $year_str = $bibtex_entry->get('year'); - if (Scalar::Util::looks_like_number($year_str)) { - $self->year($year_str); - } + $self->bibtex_key($bibtex_entry->key); + my $year_str = $bibtex_entry->get('year'); + if (Scalar::Util::looks_like_number($year_str)) { + $self->year($year_str); + } - if ($bibtex_entry->exists('booktitle')) { - $self->title($bibtex_entry->get('booktitle')); - } - if ($bibtex_entry->exists('title')) { - $self->title($bibtex_entry->get('title')); - } - $self->abstract($bibtex_entry->get('abstract') || undef); - $self->_bibtex_type($bibtex_entry->type); - return 1; + if ($bibtex_entry->exists('booktitle')) { + $self->title($bibtex_entry->get('booktitle')); } - return; + if ($bibtex_entry->exists('title')) { + $self->title($bibtex_entry->get('title')); + } + $self->abstract($bibtex_entry->get('abstract') || undef); + $self->_bibtex_type($bibtex_entry->type); + return 1; } sub add_bibtex_field { @@ -497,29 +484,105 @@ sub regenerate_html { return 0; } +sub get_exceptions { + my $self = shift; + return $self->repo->exceptions_filter(sub { $_->entry_id == $self->id }); +} + +sub get_teams { + my $self = shift; + + my @exception_team_id = map { $_->team_id } $self->get_exceptions; + my @exception_teams = $self->repo->teams_filter( + sub { + my $t = $_; + return grep { $_ eq $t->id } @exception_team_id; + } + ); + + ## Important: this means that entry-teams = teams + exceptions! + my %final_teams = map { $_->id => $_ } @exception_teams; + + foreach my $author ($self->get_authors) { + + foreach my $team ($author->get_teams) { + my $joined = $author->joined_team($team); + my $left = $author->left_team($team); + + # entry has no year... strange but possible + if (!$self->year) { + $final_teams{$team->id} = $team; + } + elsif ($joined <= $self->year and ($left > $self->year or $left == 0)) { + $final_teams{$team->id} = $team; + } + } + } + return values %final_teams; +} + +sub get_labelings { + my $self = shift; + return $self->repo->labelings_filter(sub { $_->entry_id == $self->id }); +} + +sub get_tags_of_type { + my $self = shift; + my $tag_type = shift // 1; + return grep { $_->type == $tag_type } $self->get_tags; +} + +sub get_tags { + my $self = shift; + my $potentialType = shift; + die "use entry->get_tags_of_type instead" if defined $potentialType; + + my @tag_ids = map { $_->tag_id } $self->get_labelings; + return $self->repo->tags_filter( + sub { + my $t = $_; + return grep { $_ eq $t->id } @tag_ids; + } + ); +} + +sub has_tag { + my $self = shift; + my $tag = shift; + return + defined $self->repo->labelings_find( + sub { $_->entry_id == $self->id and $_->tag_id == $tag->id }); +} + +sub get_authorships { + my $self = shift; + return $self->repo->authorships_filter(sub { $_->entry_id == $self->id }); +} + +sub get_authors { + my $self = shift; + my @author_ids = map { $_->author_id } $self->get_authorships; + return $self->repo->authors_filter( + sub { + my $a = $_; + return grep { $_ eq $a->id } @author_ids; + } + ); +} + sub has_author { my $self = shift; my $author = shift; - my $authorship_to_find = Authorship->new( - author => $author, - entry => $self, + my $authorship_to_find = $self->repo->entityFactory->new_Authorship( author_id => $author->id, entry_id => $self->id ); - my $authorship - = $self->authorships_find(sub { $_->equals($authorship_to_find) }); + = $self->repo->authorships_find(sub { $_->equals($authorship_to_find) }); return defined $authorship; } -sub has_master_author { - my $self = shift; - my $author = shift; - - return $self->has_author($author->get_master); -} - sub author_names_from_bibtex { my $self = shift; @@ -548,32 +611,6 @@ sub author_names_from_bibtex { return @author_names; } -sub get_teams { - my $self = shift; - - my @exception_teams = map { $_->team } $self->get_exceptions; - - ## Important: this means that entry-teams = teams + exceptions! - my %final_teams = map { $_->id => $_ } @exception_teams; - - foreach my $author ($self->get_authors) { - - foreach my $team ($author->get_teams) { - my $joined = $author->joined_team($team); - my $left = $author->left_team($team); - - # entry has no year... strange but possible - if (!$self->year) { - $final_teams{$team->id} = $team; - } - elsif ($joined <= $self->year and ($left > $self->year or $left == 0)) { - $final_teams{$team->id} = $team; - } - } - } - return values %final_teams; -} - sub has_team { my $self = shift; my $team = shift; diff --git a/lib/BibSpace/Model/Exception.pm b/lib/BibSpace/Model/Exception.pm index a586445..98db269 100644 --- a/lib/BibSpace/Model/Exception.pm +++ b/lib/BibSpace/Model/Exception.pm @@ -12,29 +12,24 @@ with 'IRelation'; use BibSpace::Model::SerializableBase::ExceptionSerializableBase; extends 'ExceptionSerializableBase'; -# Cast self to SerializableBase and serialize -sub TO_JSON { +sub team { my $self = shift; - my $copy = $self->meta->clone_object($self); - return ExceptionSerializableBase->meta->rebless_instance_back($copy)->TO_JSON; + return if not $self->team_id or $self->team_id < 1; + return $self->repo->teams_find(sub { $_->id == $self->team_id }); } -has 'entry' => ( - is => 'rw', - isa => 'Maybe[Entry]', - traits => ['DoNotSerialize'] # due to cycyles -); -has 'team' => ( - is => 'rw', - isa => 'Maybe[Team]', - traits => ['DoNotSerialize'] # due to cycyles -); +sub entry { + my $self = shift; + return if not $self->entry_id or $self->entry_id < 1; + return $self->repo->entries_find(sub { $_->id == $self->entry_id }); +} sub id { my $self = shift; - return "(" . $self->entry_id . "-" . $self->team->name . ")" - if defined $self->team; - return "(" . $self->entry_id . "-" . $self->team_id . ")"; + return + "(" + . ($self->entry_id || "undef") . "-" + . ($self->team_id || "undef") . ")"; } =item equals @@ -44,11 +39,6 @@ sub id { sub equals { my $self = shift; my $obj = shift; - die "Comparing apples to peaches! " . ref($self) . " against " . ref($obj) - unless ref($self) eq ref($obj); - if ($self->entry and $self->team and $obj->entry and $obj->team) { - return $self->equals_obj($obj); - } return $self->equals_id($obj); } @@ -62,16 +52,6 @@ sub equals_id { return 1; } -sub equals_obj { - my $self = shift; - my $obj = shift; - die "Comparing apples to peaches! " . ref($self) . " against " . ref($obj) - unless ref($self) eq ref($obj); - return if !$self->entry->equals($obj->entry); - return if !$self->team->equals($obj->team); - return 1; -} - no Moose; __PACKAGE__->meta->make_immutable; 1; diff --git a/lib/BibSpace/Model/IAuthored.pm b/lib/BibSpace/Model/IAuthored.pm index 6573083..a1f360d 100644 --- a/lib/BibSpace/Model/IAuthored.pm +++ b/lib/BibSpace/Model/IAuthored.pm @@ -4,54 +4,20 @@ use namespace::autoclean; use BibSpace::Functions::Core qw( sort_publications ); use Moose::Role; -has 'authorships' => ( - is => 'rw', - isa => 'ArrayRef[Authorship]', - traits => ['Array', 'DoNotSerialize'], - default => sub { [] }, - handles => { - authorships_all => 'elements', - authorships_add => 'push', - authorships_count => 'count', - authorships_find => 'first', - authorships_find_index => 'first_index', - authorships_filter => 'grep', - authorships_delete => 'delete', - authorships_clear => 'clear', - }, -); - sub has_authorship { my ($self, $authorship) = @_; - my $au = $self->authorships_find(sub { $_->equals($authorship) }); + my $au = $self->repo->authorships_find(sub { $_->equals($authorship) }); return defined $au; } sub add_authorship { my ($self, $authorship) = @_; - if (!$self->has_authorship($authorship)) { - $self->authorships_add($authorship); - } + $self->repo->authorships_save($authorship); } sub remove_authorship { my ($self, $authorship) = @_; - my $index = $self->authorships_find_index(sub { $_->equals($authorship) }); - return if $index == -1; - return 1 if $self->authorships_delete($index); - return; -} - -sub get_authors { - my $self = shift; - return map { $_->author } $self->authorships_all; -} - -sub get_entries { - my $self = shift; - my @entries = map { $_->entry } $self->authorships_all; - @entries = sort_publications(@entries); - return @entries; + return $self->repo->authorships_delete($authorship); } 1; diff --git a/lib/BibSpace/Model/IEntity.pm b/lib/BibSpace/Model/IEntity.pm index 5deb958..1b288bd 100644 --- a/lib/BibSpace/Model/IEntity.pm +++ b/lib/BibSpace/Model/IEntity.pm @@ -1,50 +1,45 @@ package IEntity; use namespace::autoclean; -use BibSpace::Util::IntegerUidProvider; use Moose::Role; use MooseX::StrictConstructor; require BibSpace::Model::SerializableBase::IEntitySerializableBase; with 'IEntitySerializableBase'; -requires 'equals'; -requires 'TO_JSON'; - -sub _generateUIDEntry { - my $self = shift; - - if (defined $self->old_mysql_id and $self->old_mysql_id > 0) { - $self->idProvider->registerUID($self->old_mysql_id); - return $self->old_mysql_id; - } - return $self->idProvider->generateUID(); -} +# Responsibility for ID management is moved to the storage backend has 'preferences' => (is => 'ro', isa => 'Preferences', traits => ['DoNotSerialize']); has 'idProvider' => ( - is => 'ro', - does => 'IUidProvider', - required => 1, - traits => ['DoNotSerialize'], + is => 'rw', + does => 'Maybe[IUidProvider]', + default => undef, + traits => ['DoNotSerialize'], ); has 'old_mysql_id' => (is => 'ro', isa => 'Maybe[Int]', default => undef); +has 'id' => (is => 'rw', isa => 'Maybe[Int]', default => undef); -has 'id' => ( - is => 'ro', - isa => 'Int', - builder => '_generateUIDEntry', - lazy => 1, - init_arg => undef -); +requires 'equals'; + +has 'repo' => (is => 'ro', isa => 'FlatRepositoryFacade', required => 1); + +# Custm cloning method is required because the following construct does not copy fileds values +# my $clone = $self->meta->clone_object($self); +# LabelingSerializableBase->meta->rebless_instance_back($clone); +sub get_base { + my $self = shift; + my $base_class_name = ref($self) . "SerializableBase"; + Class::Load::load_class($base_class_name); + return $base_class_name->new(%$self); +} -# called after the default constructor -sub BUILD { +# Cast self to SerializableBase and serialize +sub TO_JSON { my $self = shift; - $self->id; # trigger lazy execution of idProvider + return $self->get_base->TO_JSON; } 1; diff --git a/lib/BibSpace/Model/IHavingException.pm b/lib/BibSpace/Model/IHavingException.pm index 33bbf51..daa30e7 100644 --- a/lib/BibSpace/Model/IHavingException.pm +++ b/lib/BibSpace/Model/IHavingException.pm @@ -3,48 +3,14 @@ package IHavingException; use namespace::autoclean; use Moose::Role; -has 'exceptions' => ( - is => 'rw', - isa => 'ArrayRef[Exception]', - traits => ['Array'], - default => sub { [] }, - handles => { - exceptions_all => 'elements', - exceptions_add => 'push', - exceptions_count => 'count', - exceptions_find => 'first', - exceptions_find_index => 'first_index', - exceptions_filter => 'grep', - exceptions_delete => 'delete', - exceptions_clear => 'clear', - }, -); - -sub has_exception { - my ($self, $exception) = @_; - my $idx = $self->exceptions_find_index(sub { $_->equals($exception) }); - return $idx >= 0; -} - sub add_exception { my ($self, $exception) = @_; - if (!$self->has_exception($exception)) { - $self->exceptions_add($exception); - } + $self->repo->exceptions_save($exception); } sub remove_exception { my ($self, $exception) = @_; - - my $index = $self->exceptions_find_index(sub { $_->equals($exception) }); - return if $index == -1; - return 1 if $self->exceptions_delete($index); - return; -} - -sub get_exceptions { - my $self = shift; - return $self->exceptions_all; + return $self->repo->exceptions_delete($exception); } 1; diff --git a/lib/BibSpace/Model/ILabeled.pm b/lib/BibSpace/Model/ILabeled.pm index 4f88ee2..8aa3e95 100644 --- a/lib/BibSpace/Model/ILabeled.pm +++ b/lib/BibSpace/Model/ILabeled.pm @@ -3,60 +3,19 @@ package ILabeled; use namespace::autoclean; use Moose::Role; -has 'labelings' => ( - is => 'rw', - isa => 'ArrayRef[Labeling]', - traits => ['Array', 'DoNotSerialize'], - default => sub { [] }, - handles => { - labelings_all => 'elements', - labelings_add => 'push', - labelings_count => 'count', - labelings_find => 'first', - labelings_find_index => 'first_index', - labelings_filter => 'grep', - labelings_delete => 'delete', - labelings_clear => 'clear', - }, -); - -sub has_tag { - my $self = shift; - my $tag = shift; - return defined $self->labelings_find(sub { $_->tag->equals($tag) }); -} - sub has_labeling { my ($self, $labeling) = @_; - my $idx = $self->labelings_find_index(sub { $_->equals($labeling) }); - return $idx >= 0; + return $self->repo->labelings_find(sub { $_->equals($labeling) }); } sub add_labeling { my ($self, $labeling) = @_; - if (!$self->has_labeling($labeling)) { - $self->labelings_add($labeling); - } + $self->repo->labelings_save($labeling); } sub remove_labeling { my ($self, $labeling) = @_; - - my $index = $self->labelings_find_index(sub { $_->equals($labeling) }); - return if $index == -1; - return 1 if $self->labelings_delete($index); - return; -} - -sub get_tags { - my $self = shift; - my $tag_type = shift; - - my @tags = map { $_->tag } $self->labelings_all; - if (defined $tag_type) { - return grep { $_->type == $tag_type } @tags; - } - return @tags; + return $self->repo->labelings_delete($labeling); } 1; diff --git a/lib/BibSpace/Model/IMembered.pm b/lib/BibSpace/Model/IMembered.pm index d68f4da..b2f493e 100644 --- a/lib/BibSpace/Model/IMembered.pm +++ b/lib/BibSpace/Model/IMembered.pm @@ -3,57 +3,19 @@ package IMembered; use namespace::autoclean; use Moose::Role; -has 'memberships' => ( - is => 'rw', - isa => 'ArrayRef[Membership]', - traits => ['Array', 'DoNotSerialize'], - default => sub { [] }, - handles => { - memberships_all => 'elements', - memberships_add => 'push', - memberships_count => 'count', - memberships_find => 'first', - memberships_find_index => 'first_index', - memberships_filter => 'grep', - memberships_delete => 'delete', - memberships_clear => 'clear', - }, -); - -sub get_teams { - my $self = shift; - return map { $_->team } $self->memberships_all; -} - -sub has_team { - my $self = shift; - my $team = shift; - return defined $self->memberships_find(sub { $_->team->equals($team) }); -} - sub has_membership { my ($self, $membership) = @_; - my $idx = $self->memberships_find_index(sub { $_->equals($membership) }); - return $idx >= 0; + return defined $self->repo->memberships_find(sub { $_->equals($membership) }); } sub add_membership { my ($self, $membership) = @_; - - if (!$self->has_membership($membership)) { - $self->memberships_add($membership); - } + $self->repo->memberships_save($membership); } sub remove_membership { my ($self, $membership) = @_; - - # $membership->validate; - - my $index = $self->memberships_find_index(sub { $_->equals($membership) }); - return if $index == -1; - return 1 if $self->memberships_delete($index); - return; + return $self->repo->memberships_delete($membership); } 1; diff --git a/lib/BibSpace/Model/IRelation.pm b/lib/BibSpace/Model/IRelation.pm index 1735e49..14bbf24 100644 --- a/lib/BibSpace/Model/IRelation.pm +++ b/lib/BibSpace/Model/IRelation.pm @@ -4,11 +4,27 @@ use Moose::Role; requires 'id'; requires 'equals'; +has 'repo' => ( + is => 'ro', + isa => 'FlatRepositoryFacade', + required => 1, + traits => ['DoNotSerialize'] +); -# called after the default constructor -sub BUILD { +# Custm cloning method is required because the following construct does not copy fileds values +# my $clone = $self->meta->clone_object($self); +# LabelingSerializableBase->meta->rebless_instance_back($clone); +sub get_base { + my $self = shift; + my $base_class_name = ref($self) . "SerializableBase"; + Class::Load::load_class($base_class_name); + return $base_class_name->new(%$self); +} + +# Cast self to SerializableBase and serialize +sub TO_JSON { my $self = shift; - $self->id; # trigger lazy execution of idProvider + return $self->get_base->TO_JSON; } 1; diff --git a/lib/BibSpace/Model/Labeling.pm b/lib/BibSpace/Model/Labeling.pm index 9d33a56..3cfa73d 100644 --- a/lib/BibSpace/Model/Labeling.pm +++ b/lib/BibSpace/Model/Labeling.pm @@ -6,71 +6,37 @@ use BibSpace::Model::Entry; use BibSpace::Model::Tag; use BibSpace::Model::IRelation; use Try::Tiny; +use Data::Dumper; +$Data::Dumper::Maxdepth = 2; use Moose; with 'IRelation'; use BibSpace::Model::SerializableBase::LabelingSerializableBase; extends 'LabelingSerializableBase'; -# Cast self to SerializableBase and serialize -sub TO_JSON { +sub tag { my $self = shift; - my $copy = $self->meta->clone_object($self); - return LabelingSerializableBase->meta->rebless_instance_back($copy)->TO_JSON; + return if not $self->tag_id or $self->tag_id < 1; + return $self->repo->tags_find(sub { $_->id == $self->tag_id }); } -has 'entry' => ( - is => 'rw', - isa => 'Maybe[Entry]', - traits => ['DoNotSerialize'] # due to cycyles -); -has 'tag' => ( - is => 'rw', - isa => 'Maybe[Tag]', - traits => ['DoNotSerialize'] # due to cycyles -); - -sub id { +sub entry { my $self = shift; - return "(" . $self->entry_id . "-" . $self->tag->name . ")" - if defined $self->tag; - return "(" . $self->entry_id . "-" . $self->tag_id . ")"; + return if not $self->entry_id or $self->entry_id < 1; + return $self->repo->entries_find(sub { $_->id == $self->entry_id }); } -sub validate { +sub id { my $self = shift; - if (defined $self->entry and defined $self->tag) { - if ($self->entry->id != $self->entry_id) { - die "Label has been built wrongly entry->id and entry_id differs.\n" - . "label->entry->id: " - . $self->entry->id - . ", label->entry_id: " - . $self->entry_id; - } - if ($self->tag->id != $self->tag_id) { - die "Label has been built wrongly tag->id and tag_id differs.\n" - . "label->tag->id: " - . $self->tag->id - . ", label->tag_id: " - . $self->tag_id; - } - } - return 1; + return + "(" + . ($self->entry_id || "undef") . "-" + . ($self->tag_id || "undef") . ")"; } sub equals { my $self = shift; my $obj = shift; - - die "Comparing apples to peaches! " - . ref($self) - . " against " - . ref($obj) . "." - unless ref($self) eq ref($obj); - - if ($self->entry and $self->tag and $obj->entry and $obj->tag) { - return $self->equals_obj($obj); - } return $self->equals_id($obj); } @@ -82,14 +48,6 @@ sub equals_id { return 1; } -sub equals_obj { - my $self = shift; - my $obj = shift; - return if !$self->entry->equals($obj->entry); - return if !$self->tag->equals($obj->tag); - return 1; -} - no Moose; __PACKAGE__->meta->make_immutable; 1; diff --git a/lib/BibSpace/Model/Membership.pm b/lib/BibSpace/Model/Membership.pm index 4921789..e6b2b62 100644 --- a/lib/BibSpace/Model/Membership.pm +++ b/lib/BibSpace/Model/Membership.pm @@ -11,56 +11,29 @@ with 'IRelation'; use BibSpace::Model::SerializableBase::MembershipSerializableBase; extends 'MembershipSerializableBase'; -# Cast self to SerializableBase and serialize -sub TO_JSON { +sub author { my $self = shift; - my $copy = $self->meta->clone_object($self); - return MembershipSerializableBase->meta->rebless_instance_back($copy) - ->TO_JSON; + return if not $self->author_id or $self->author_id < 1; + return $self->repo->authors_find(sub { $_->id == $self->author_id }); } -has 'team' => (is => 'rw', isa => 'Maybe[Team]', traits => ['DoNotSerialize']); - -has 'author' => - (is => 'rw', isa => 'Maybe[Author]', traits => ['DoNotSerialize']); - -sub id { +sub team { my $self = shift; - return "(" . $self->team->name . "-" . $self->author->uid . ")" - if defined $self->author and defined $self->team; - return "(" . $self->team_id . "-" . $self->author_id . ")"; + return if not $self->team_id or $self->team_id < 1; + return $self->repo->teams_find(sub { $_->id == $self->team_id }); } -sub validate { +sub id { my $self = shift; - if (defined $self->author and defined $self->team) { - if ($self->author->id != $self->author_id) { - die "Label has been built wrongly author->id and author_id differs.\n" - . "label->author->id: " - . $self->author->id - . ", label->author_id: " - . $self->author_id; - } - if ($self->team->id != $self->team_id) { - die "Label has been built wrongly team->id and team_id differs.\n" - . "label->team->id: " - . $self->team->id - . ", label->team_id: " - . $self->team_id; - } - } - return 1; + return + "(" + . ($self->author_id || "undef") . "-" + . ($self->team_id || "undef") . ")"; } sub equals { my $self = shift; my $obj = shift; - return if !defined $obj; - die "Comparing apples to peaches! " . ref($self) . " against " . ref($obj) - unless ref($self) eq ref($obj); - if ($self->team and $self->author and $obj->team and $obj->author) { - return $self->equals_obj($obj); - } return $self->equals_id($obj); } @@ -68,20 +41,13 @@ sub equals_id { my $self = shift; my $obj = shift; die "Comparing apples to peaches!!" unless ref($self) eq ref($obj); + return if not $self->team_id; + return if not $self->author_id; return if $self->team_id != $obj->team_id; return if $self->author_id != $obj->author_id; return 1; } -sub equals_obj { - my $self = shift; - my $obj = shift; - die "Comparing apples to peaches!!" unless ref($self) eq ref($obj); - return if !$self->team->equals($obj->team); - return if !$self->author->equals($obj->author); - return 1; -} - no Moose; __PACKAGE__->meta->make_immutable; 1; diff --git a/lib/BibSpace/Model/SerializableBase/AuthorSerializableBase.pm b/lib/BibSpace/Model/SerializableBase/AuthorSerializableBase.pm index 5c1b0bb..7d8299f 100644 --- a/lib/BibSpace/Model/SerializableBase/AuthorSerializableBase.pm +++ b/lib/BibSpace/Model/SerializableBase/AuthorSerializableBase.pm @@ -3,10 +3,13 @@ package AuthorSerializableBase; use utf8; use v5.16; use Moose; +use MooseX::Privacy; require BibSpace::Model::SerializableBase::IEntitySerializableBase; with 'IEntitySerializableBase'; -has 'uid' => (is => 'rw', isa => 'Str', documentation => q{Author name}); +has 'uid' => + (is => 'rw', isa => 'Str', documentation => q{Author name (deprecated)}); +has 'name' => (is => 'rw', isa => 'Str', documentation => q{Author name}); has 'display' => ( is => 'rw', @@ -18,9 +21,20 @@ has 'display' => ( has 'master_id' => ( is => 'rw', isa => 'Maybe[Int]', + traits => [qw/Protected/], documentation => q{Id of author's master object} ); +# Read-Only getter for master_id +# It also initializes master_id field for newly inserted elements +sub get_master_id { + my $self = shift; + if (not $self->master_id or $self->master_id < 0) { + $self->master_id($self->id); + } + return $self->master_id; +} + no Moose; __PACKAGE__->meta->make_immutable; 1; diff --git a/lib/BibSpace/Model/SerializableBase/BibSpaceDTO.pm b/lib/BibSpace/Model/SerializableBase/BibSpaceDTO.pm index f6062c6..f591459 100644 --- a/lib/BibSpace/Model/SerializableBase/BibSpaceDTO.pm +++ b/lib/BibSpace/Model/SerializableBase/BibSpaceDTO.pm @@ -6,7 +6,10 @@ package BibSpaceDTO; use utf8; use v5.16; use Moose; +use MooseX::ClassAttribute; use Try::Tiny; +use Data::Dumper; +$Data::Dumper::Maxdepth = 2; # Class attribute is not serialized has 'formatVersion' => (is => 'ro', isa => 'Str', default => '1'); @@ -15,7 +18,14 @@ has 'formatVersion' => (is => 'ro', isa => 'Str', default => '1'); # It is used for deserializing dateTime objects # Always set this parameter to a value that is default for serialization in class 'DateTime' # Currently, it is '%Y-%m-%dT%T' -has 'dateTimeFormat' => (is => 'rw', isa => 'Str', default => '%Y-%m-%dT%T'); +# The parameter is ro, becuse there are no means and need to change it currently + +# Commenting it out due to warning that this is replaced by the class_has version +# has 'dateTimeFormat' => (is => 'ro', isa => 'Str', default => '%Y-%m-%dT%T'); + +# duplicate as class atribute to make some functions purely static +class_has 'dateTimeFormat' => + (is => 'ro', isa => 'Str', default => '%Y-%m-%dT%T'); # The hash has form: 'ClassName' => Array[InstanceofClassName] has 'data' => ( @@ -36,12 +46,13 @@ has 'data' => ( ); # Converts BibSpaceDTO object into JSON string +# THis method changes types of objects from Labeling to LabelingSerializableBase sub toJSON { my $self = shift; use JSON -convert_blessed_universally; - my $json_obj = JSON->new->convert_blessed->utf8->pretty; - return $json_obj->encode($self); + return JSON->new->convert_blessed->utf8->pretty->encode($self) + ; # this method chnages self!! } # Static constructor method that creates BibSpaceDTO from LayeredRepo @@ -62,35 +73,27 @@ sub fromLayeredRepo { # Resulting DTO will hold rich objects (not SerializableBase) and thus # requires additionall data from the repository sub toLayeredRepo { - my $self = shift; - my $jsonString = shift; - my $repoUidProvider = shift - // die "Need to provide UID provider of destination repository"; - my $repoPreferences = shift - // die "Need to provide Preferences of destination repository"; + my $self = shift; + my $jsonString = shift; + my $repoFacade = shift + // die "Need to provide repoFacade of destination repository"; + my $repoPreferences = $repoFacade->lr->preferences; # This parses a shallow BibSpaceDTO my $parsedDTO = bless(JSON->new->decode($jsonString), 'BibSpaceDTO'); # Each array (type => array) holds hashes - # Hases need to be blessed to become objects + # Hashes need to be blessed to become objects # Json givesSerializableBase # Here, we bless into # This will hold rich objects constructed from data from shallow object my $dto = BibSpaceDTO->new('FormatVersion' => 1); - # print "###############\n"; - # use Data::Dumper; - # $Data::Dumper::Maxdepth = 2; - # Init containers for objects for my $className ($parsedDTO->keys) { $dto->set($className, []); } - # Reset ID providers for all classes - only once! - $repoUidProvider->reset; - # Fill containers with objects for my $className ($parsedDTO->keys) { my $arrayRef = $parsedDTO->data->{$className}; @@ -100,14 +103,10 @@ sub toLayeredRepo { # Load className and call constructor Class::Load::load_class($className); - # Rich objects require several additional objects in their constructor - # See IEntity.pm for details - my $idProvider = $repoUidProvider->get_provider($className); - # BlessedObj has only SerializableBase # Call normal constructor to create rich object - my $mooseObj = $self->_hashToMooseObject($className, $objHash, - {idProvider => $idProvider, preferences => $repoPreferences}); + my $mooseObj = BibSpaceDTO->_hashToMooseObject($className, $objHash, + {preferences => $repoPreferences, repo => $repoFacade}); push @{$dto->get($className)}, $mooseObj; } } @@ -125,7 +124,8 @@ sub _hashToMooseObject { my $mooseObj; try { # Try calling constructor that creates DateTime rich fields from string - $mooseObj = $className->new__DateTime_from_string($self->dateTimeFormat, + $mooseObj + = $className->new__DateTime_from_string(BibSpaceDTO->dateTimeFormat, (%hashObj, %hashArgs)); } catch { diff --git a/lib/BibSpace/Model/SerializableBase/UserSerializableBase.pm b/lib/BibSpace/Model/SerializableBase/UserSerializableBase.pm index 90b1875..0baad84 100644 --- a/lib/BibSpace/Model/SerializableBase/UserSerializableBase.pm +++ b/lib/BibSpace/Model/SerializableBase/UserSerializableBase.pm @@ -15,11 +15,14 @@ class_has 'user_rank' => (is => 'ro', default => 0); has 'login' => (is => 'rw', isa => 'Str', required => 1); has 'real_name' => (is => 'rw', isa => 'Str', default => "unnamed"); has 'email' => (is => 'rw', isa => 'Str', required => 1); -has 'rank' => (is => 'rw'); -has 'pass' => (is => 'rw', isa => 'Str'); -has 'pass2' => (is => 'rw', isa => 'Str', documentation => q{Salt}); -has 'pass3' => - (is => 'rw', isa => 'Maybe[Str]', documentation => q{Currently unused}); +has 'rank' => (is => 'rw', default => UserSerializableBase->user_rank); +has 'pass' => (is => 'rw', isa => 'Str'); +has 'pass2' => (is => 'rw', isa => 'Str', documentation => q{Salt}); +has 'pass3' => ( + is => 'rw', + isa => 'Maybe[Str]', + documentation => q{Last password forgot token} +); has 'master_id' => (is => 'rw', default => 0); has 'tennant_id' => (is => 'rw', default => 0); diff --git a/lib/BibSpace/Model/Tag.pm b/lib/BibSpace/Model/Tag.pm index 8075209..fb1efc4 100644 --- a/lib/BibSpace/Model/Tag.pm +++ b/lib/BibSpace/Model/Tag.pm @@ -14,13 +14,6 @@ with 'IEntity', 'ILabeled'; use BibSpace::Model::SerializableBase::TagSerializableBase; extends 'TagSerializableBase'; -# Cast self to SerializableBase and serialize -sub TO_JSON { - my $self = shift; - my $copy = $self->meta->clone_object($self); - return TagSerializableBase->meta->rebless_instance_back($copy)->TO_JSON; -} - has 'tagtype' => (is => 'rw', isa => 'Maybe[TagType]', traits => ['DoNotSerialize'],); @@ -40,9 +33,21 @@ sub get_authors { return uniq @authors; } -sub get_entries { +sub get_labelings { my $self = shift; - return map { $_->entry } $self->labelings_all; + return $self->repo->labelings_filter(sub { $_->tag_id == $self->id }); +} + +sub get_entries { + my $self = shift; + my @entry_ids = map { $_->entry_id } $self->get_labelings; + + return $self->repo->entries_filter( + sub { + my $e = $_; + return grep { $_ eq $e->id } @entry_ids; + } + ); } no Moose; diff --git a/lib/BibSpace/Model/TagType.pm b/lib/BibSpace/Model/TagType.pm index 8546928..ff81473 100644 --- a/lib/BibSpace/Model/TagType.pm +++ b/lib/BibSpace/Model/TagType.pm @@ -10,16 +10,6 @@ with 'IEntity'; use BibSpace::Model::SerializableBase::TagTypeSerializableBase; extends 'TagTypeSerializableBase'; -# Cast self to SerializableBase and serialize -sub TO_JSON { - my $self = shift; - my $copy = $self->meta->clone_object($self); - return TagTypeSerializableBase->meta->rebless_instance_back($copy)->TO_JSON; -} - -has 'name' => (is => 'rw', isa => 'Str'); -has 'comment' => (is => 'rw', isa => 'Maybe[Str]'); - sub equals { my $self = shift; my $obj = shift; diff --git a/lib/BibSpace/Model/Team.pm b/lib/BibSpace/Model/Team.pm index 573de0c..abecba7 100644 --- a/lib/BibSpace/Model/Team.pm +++ b/lib/BibSpace/Model/Team.pm @@ -15,16 +15,6 @@ with 'IEntity', 'IMembered', 'IHavingException'; use BibSpace::Model::SerializableBase::TeamSerializableBase; extends 'TeamSerializableBase'; -# Cast self to SerializableBase and serialize -sub TO_JSON { - my $self = shift; - my $copy = $self->meta->clone_object($self); - return TeamSerializableBase->meta->rebless_instance_back($copy)->TO_JSON; -} - -has 'name' => (is => 'rw', isa => 'Str'); -has 'parent' => (is => 'rw'); - sub equals { my $self = shift; my $obj = shift; @@ -36,13 +26,28 @@ sub equals { sub can_be_deleted { my $self = shift; - return if $self->memberships_count > 0; + return if scalar $self->get_authors > 0; return 1; } -sub get_members { +sub get_memberships { my $self = shift; - return map { $_->author } $self->memberships_all; + return $self->repo->memberships_filter(sub { $_->team_id == $self->id }); +} + +sub get_authors { + my $self = shift; + my @author_ids = map { $_->author_id } $self->get_memberships; + return $self->repo->authors_filter( + sub { + my $a = $_; + return grep { $_ eq $a->id } @author_ids; + } + ); +} + +sub get_members { + return shift->get_authors; } sub get_membership_beginning { @@ -63,11 +68,6 @@ sub get_membership_end { return $author->left_team($self); } -sub get_authors { - my $self = shift; - return map { $_->author } $self->memberships_all; -} - sub tags { my $self = shift; my $type = shift // 1; @@ -75,18 +75,23 @@ sub tags { my @myTags; my @members = $self->get_authors; foreach my $author (@members) { - push @myTags, $author->get_tags($type); + push @myTags, $author->get_tags_of_type($type); } @myTags = uniq @myTags; return @myTags; } +sub get_exceptions { + my $self = shift; + return $self->repo->exceptions_filter(sub { $_->team_id == $self->id }); +} + sub get_entries { my $self = shift; - my @myEntries; - my @members = $self->get_authors; + my @myEntries = (); + my @members = $self->get_authors; foreach my $author (@members) { push @myEntries, $author->get_entries; } diff --git a/lib/BibSpace/Model/Type.pm b/lib/BibSpace/Model/Type.pm index 9451ee5..fee7139 100644 --- a/lib/BibSpace/Model/Type.pm +++ b/lib/BibSpace/Model/Type.pm @@ -11,25 +11,30 @@ use BibSpace::Model::SerializableBase::TypeSerializableBase; extends 'TypeSerializableBase'; # Cast self to SerializableBase and serialize -sub TO_JSON { - my $self = shift; - my $copy = $self->meta->clone_object($self); - -# The bibtexTypes array is not cloned by default, so this needs to be added as fix - $copy->bibtexTypes($self->bibtexTypes); - - # Why this is not copied automatically? - $copy->onLanding($self->onLanding); +# sub TO_JSON { +# my $self = shift; +# my $copy = $self->meta->clone_object($self); +# +# # The bibtexTypes array is not cloned by default, so this needs to be added as fix +# $copy->bibtexTypes($self->bibtexTypes); +# +# # Why this is not copied automatically? +# $copy->onLanding($self->onLanding); +# +# # Suprisingly, some types may miss the obligatory field, so we provide a default vaule +# if ($self->our_type) { +# $copy->our_type($self->our_type); +# } +# else { +# $copy->our_type('Unnamed'); +# } +# my $tsb_debug = TypeSerializableBase->meta->rebless_instance_back($copy); +# return $tsb_debug->TO_JSON; +# } -# Suprisingly, some types may miss the obligatory field, so we provide a default vaule - if ($self->our_type) { - $copy->our_type($self->our_type); - } - else { - $copy->our_type('Unnamed'); - } - my $tsb_debug = TypeSerializableBase->meta->rebless_instance_back($copy); - return $tsb_debug->TO_JSON; +sub id { + my $self = shift; + return "(" . $self->our_type . "-" . join($self->bibtexTypes_all, ',') . ")"; } sub equals { diff --git a/lib/BibSpace/Model/User.pm b/lib/BibSpace/Model/User.pm index 0c82831..9b5a26b 100644 --- a/lib/BibSpace/Model/User.pm +++ b/lib/BibSpace/Model/User.pm @@ -12,39 +12,22 @@ use MooseX::ClassAttribute; with 'IEntity'; use BibSpace::Model::SerializableBase::UserSerializableBase; extends 'UserSerializableBase'; - -# Cast self to SerializableBase and serialize -sub TO_JSON { - my $self = shift; - my $copy = $self->meta->clone_object($self); - return UserSerializableBase->meta->rebless_instance_back($copy)->TO_JSON; -} - use DateTime::Format::Strptime; use DateTime; my $dtPattern = DateTime::Format::Strptime->new(pattern => '%Y-%m-%d %H:%M:%S'); -class_has 'admin_rank' => (is => 'ro', default => 2); -class_has 'manager_rank' => (is => 'ro', default => 1); -class_has 'user_rank' => (is => 'ro', default => 0); - -has 'login' => (is => 'rw', isa => 'Str', required => 1); -has 'real_name' => (is => 'rw', isa => 'Str', default => "unnamed"); -has 'email' => (is => 'rw', isa => 'Str', required => 1); -has 'rank' => (is => 'rw', default => User->user_rank); - -# pass = user password -has 'pass' => (is => 'rw', isa => 'Str'); - -# pass2 = salt -has 'pass2' => (is => 'rw', isa => 'Str'); -has 'pass3' => (is => 'rw', isa => 'Maybe[Str]'); +sub get_forgot_pass_token { + shift->pass3; +} -# TODO: forgot_token is not a DB field! -has 'forgot_token' => (is => 'rw', isa => 'Maybe[Str]'); -has 'master_id' => (is => 'rw', default => 0); -has 'tennant_id' => (is => 'rw', default => 0); +sub set_forgot_pass_token { + shift->pass3(shift); +} +sub reset_forgot_token { + my ($self) = @_; + $self->pass3(undef); +} has 'last_login' => ( is => 'rw', isa => 'DateTime', @@ -132,8 +115,8 @@ sub record_logging_in { my $self = shift; $self->last_login( DateTime->now->set_time_zone($self->preferences->local_time_zone)); - } + no Moose; __PACKAGE__->meta->make_immutable; 1; diff --git a/lib/BibSpace/Repository/FlatRepository.pm b/lib/BibSpace/Repository/FlatRepository.pm new file mode 100644 index 0000000..078f1b9 --- /dev/null +++ b/lib/BibSpace/Repository/FlatRepository.pm @@ -0,0 +1,156 @@ +# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T15:07:35 +package FlatRepository; +use namespace::autoclean; +use Moose; +use MooseX::ClassAttribute; +use feature qw( state say ); +use MooseX::StrictConstructor; +use Try::Tiny; +use List::Util qw(first); +use Scalar::Util qw( refaddr ); + +use BibSpace::Util::IUidProvider; +use BibSpace::Repository::RepositoryLayer; +use BibSpace::Util::EntityFactory; + +has 'logger' => (is => 'ro', does => 'ILogger', required => 1); +has 'preferences' => (is => 'ro', isa => 'Preferences', required => 1); +has 'facade' => + (is => 'rw', isa => 'Maybe[FlatRepositoryFacade]', default => undef); + +sub BUILD { + my $self = shift; + my $e_factory = EntityFactory->new( + logger => $self->logger, + preferences => $self->preferences + ); + $self->e_factory($e_factory); + $self->layer->e_factory($e_factory); +} + +sub set_facade { + my $self = shift; + my $facade = shift; + $self->facade($facade); + $self->e_factory->facade($facade); + $self->layer->e_factory->facade($facade); +} + +# will be set in the post-construction routine BUILD +has 'e_factory' => (is => 'rw', isa => 'EntityFactory'); + +# layer_name => RepositoryLayer +has 'layer' => ( + is => 'ro', + isa => 'RepositoryLayer', + traits => ['DoNotSerialize'], + default => sub { {} } +); + +# static methods +class_has 'entities' => ( + is => 'ro', + isa => 'ArrayRef[Str]', + default => sub { + + # ORDER IS IMPORTANT!!! TAG MUST BE AFTER TAGTYPE - it references it N:1! + ['Author', 'Entry', 'TagType', 'Tag', 'Team', 'Type', 'User']; + }, + traits => ['Array'], + handles => {get_entities => 'elements',}, +); +class_has 'relations' => ( + is => 'ro', + isa => 'ArrayRef[Str]', + default => sub { + ['Authorship', 'Exception', 'Labeling', 'Membership']; + }, + traits => ['Array'], + handles => {get_relations => 'elements',}, +); + +class_has 'models' => ( + is => 'ro', + isa => 'ArrayRef[Str]', + default => sub { + return [FlatRepository->get_entities, FlatRepository->get_relations]; + }, + traits => ['Array'], + handles => {get_models => 'elements',}, +); + +=item get_layer + Returns the only layer +=cut + +sub get_layer { + my $self = shift; + return $self->layer; +} + +# For compatibility with LayeredRespository interface +sub get_all_layers { + my $self = shift; + return ($self->get_layer); +} + +# For compatibility with LayeredRespository interface +sub get_read_layer { + my $self = shift; + return ($self->get_layer); +} + +sub get_summary_table { + my $self = shift; + return $self->get_layer->get_summary_table; +} + +sub all { + my $self = shift; + my $type = shift; + return $self->get_layer->all($type); +} + +sub count { + my ($self, $type) = @_; + return $self->get_layer->count($type); +} + +sub empty { + my ($self, $type) = @_; + return $self->get_layer->empty($type); +} + +sub exists { + my ($self, $type, $obj) = @_; + return $self->get_layer->exists($type, $obj); +} + +sub save { + my ($self, $type, @objects) = @_; + return $self->get_layer->save($type, @objects); +} + +sub update { + my ($self, $type, @objects) = @_; + return $self->get_layer->update($type, @objects); +} + +sub delete { + my ($self, $type, @objects) = @_; + return $self->get_layer->delete($type, @objects); +} + +sub filter { + my ($self, $type, $coderef) = @_; + return $self->get_layer->filter($type, $coderef); +} + +sub find { + my ($self, $type, $coderef) = @_; + return $self->get_layer->find($type, $coderef); +} + +__PACKAGE__->meta->make_immutable; +no Moose; +1; diff --git a/lib/BibSpace/Repository/RepositoryFacade.pm b/lib/BibSpace/Repository/FlatRepositoryFacade.pm similarity index 87% rename from lib/BibSpace/Repository/RepositoryFacade.pm rename to lib/BibSpace/Repository/FlatRepositoryFacade.pm index 973e2bb..03db87c 100644 --- a/lib/BibSpace/Repository/RepositoryFacade.pm +++ b/lib/BibSpace/Repository/FlatRepositoryFacade.pm @@ -1,11 +1,26 @@ -package RepositoryFacade; +package FlatRepositoryFacade; use namespace::autoclean; use Moose; use MooseX::ClassAttribute; use Try::Tiny; -has 'lr' => (is => 'ro', isa => 'LayeredRepository', required => 1); +has 'lr' => (is => 'ro', isa => 'FlatRepository', required => 1); + +# Repeat functions from lower layers +sub entityFactory { + shift->lr->e_factory; +} + +sub e_factory { + shift->lr->e_factory; +} + +# Inject facade into layer +sub BUILD { + my $self = shift; + $self->lr->set_facade($self); +} # static methods class_has 'entities' => ( @@ -34,64 +49,50 @@ class_has 'models' => ( is => 'ro', isa => 'ArrayRef[Str]', default => sub { - return [RepositoryFacade->get_entities, RepositoryFacade->get_relations]; + return [FlatRepositoryFacade->get_entities, + FlatRepositoryFacade->get_relations]; }, traits => ['Array'], handles => {get_models => 'elements',}, ); -sub hardReset { - my $self = shift; - return $self->lr->hardReset; -} - -sub _getIdProvider { - my $self = shift; - my $type = shift; - return $self->lr->uidProvider->get_provider($type); -} - #<<< no perltidy here sub authors_all { my ($self, @params) = @_; return $self->lr->all('Author', @params); } sub authors_count { my ($self, @params) = @_; return $self->lr->count('Author', @params); } sub authors_empty { my ($self, @params) = @_; return $self->lr->empty('Author', @params); } -sub authors_exists { my ($self, @params) = @_; return $self->lr->exists('Author', @params); } sub authors_save { my ($self, @params) = @_; return $self->lr->save('Author', @params); } sub authors_update { my ($self, @params) = @_; return $self->lr->update('Author', @params); } sub authors_delete { my ($self, @params) = @_; return $self->lr->delete('Author', @params); } sub authors_filter { my ($self, @params) = @_; return $self->lr->filter('Author', @params); } sub authors_find { my ($self, @params) = @_; return $self->lr->find('Author', @params); } -#>>> +#>>> #<<< no perltidy here sub authorships_all { my ($self, @params) = @_; return $self->lr->all('Authorship', @params); } sub authorships_count { my ($self, @params) = @_; return $self->lr->count('Authorship', @params); } sub authorships_empty { my ($self, @params) = @_; return $self->lr->empty('Authorship', @params); } -sub authorships_exists { my ($self, @params) = @_; return $self->lr->exists('Authorship', @params); } sub authorships_save { my ($self, @params) = @_; return $self->lr->save('Authorship', @params); } sub authorships_update { my ($self, @params) = @_; return $self->lr->update('Authorship', @params); } sub authorships_delete { my ($self, @params) = @_; return $self->lr->delete('Authorship', @params); } sub authorships_filter { my ($self, @params) = @_; return $self->lr->filter('Authorship', @params); } sub authorships_find { my ($self, @params) = @_; return $self->lr->find('Authorship', @params); } -#>>> +#>>> #<<< no perltidy here sub entries_all { my ($self, @params) = @_; return $self->lr->all('Entry', @params); } sub entries_count { my ($self, @params) = @_; return $self->lr->count('Entry', @params); } sub entries_empty { my ($self, @params) = @_; return $self->lr->empty('Entry', @params); } -sub entries_exists { my ($self, @params) = @_; return $self->lr->exists('Entry', @params); } sub entries_save { my ($self, @params) = @_; return $self->lr->save('Entry', @params); } sub entries_update { my ($self, @params) = @_; return $self->lr->update('Entry', @params); } sub entries_delete { my ($self, @params) = @_; return $self->lr->delete('Entry', @params); } sub entries_filter { my ($self, @params) = @_; return $self->lr->filter('Entry', @params); } sub entries_find { my ($self, @params) = @_; return $self->lr->find('Entry', @params); } -#>>> +#>>> #<<< no perltidy here sub exceptions_all { my ($self, @params) = @_; return $self->lr->all('Exception', @params); } sub exceptions_count { my ($self, @params) = @_; return $self->lr->count('Exception', @params); } sub exceptions_empty { my ($self, @params) = @_; return $self->lr->empty('Exception', @params); } -sub exceptions_exists { my ($self, @params) = @_; return $self->lr->exists('Exception', @params); } sub exceptions_save { my ($self, @params) = @_; return $self->lr->save('Exception', @params); } sub exceptions_update { my ($self, @params) = @_; return $self->lr->update('Exception', @params); } sub exceptions_delete { my ($self, @params) = @_; return $self->lr->delete('Exception', @params); } @@ -103,7 +104,6 @@ sub exceptions_find { my ($self, @params) = @_; return $self->lr->find('Except sub labelings_all { my ($self, @params) = @_; return $self->lr->all('Labeling', @params); } sub labelings_count { my ($self, @params) = @_; return $self->lr->count('Labeling', @params); } sub labelings_empty { my ($self, @params) = @_; return $self->lr->empty('Labeling', @params); } -sub labelings_exists { my ($self, @params) = @_; return $self->lr->exists('Labeling', @params); } sub labelings_save { my ($self, @params) = @_; return $self->lr->save('Labeling', @params); } sub labelings_update { my ($self, @params) = @_; return $self->lr->update('Labeling', @params); } sub labelings_delete { my ($self, @params) = @_; return $self->lr->delete('Labeling', @params); } @@ -115,7 +115,6 @@ sub labelings_find { my ($self, @params) = @_; return $self->lr->find('Labelin sub memberships_all { my ($self, @params) = @_; return $self->lr->all('Membership', @params); } sub memberships_count { my ($self, @params) = @_; return $self->lr->count('Membership', @params); } sub memberships_empty { my ($self, @params) = @_; return $self->lr->empty('Membership', @params); } -sub memberships_exists { my ($self, @params) = @_; return $self->lr->exists('Membership', @params); } sub memberships_save { my ($self, @params) = @_; return $self->lr->save('Membership', @params); } sub memberships_update { my ($self, @params) = @_; return $self->lr->update('Membership', @params); } sub memberships_delete { my ($self, @params) = @_; return $self->lr->delete('Membership', @params); } @@ -127,7 +126,6 @@ sub memberships_find { my ($self, @params) = @_; return $self->lr->find('Membe sub tags_all { my ($self, @params) = @_; return $self->lr->all('Tag', @params); } sub tags_count { my ($self, @params) = @_; return $self->lr->count('Tag', @params); } sub tags_empty { my ($self, @params) = @_; return $self->lr->empty('Tag', @params); } -sub tags_exists { my ($self, @params) = @_; return $self->lr->exists('Tag', @params); } sub tags_save { my ($self, @params) = @_; return $self->lr->save('Tag', @params); } sub tags_update { my ($self, @params) = @_; return $self->lr->update('Tag', @params); } sub tags_delete { my ($self, @params) = @_; return $self->lr->delete('Tag', @params); } @@ -139,7 +137,6 @@ sub tags_find { my ($self, @params) = @_; return $self->lr->find('Tag', @param sub tagTypes_all { my ($self, @params) = @_; return $self->lr->all('TagType', @params); } sub tagTypes_count { my ($self, @params) = @_; return $self->lr->count('TagType', @params); } sub tagTypes_empty { my ($self, @params) = @_; return $self->lr->empty('TagType', @params); } -sub tagTypes_exists { my ($self, @params) = @_; return $self->lr->exists('TagType', @params); } sub tagTypes_save { my ($self, @params) = @_; return $self->lr->save('TagType', @params); } sub tagTypes_update { my ($self, @params) = @_; return $self->lr->update('TagType', @params); } sub tagTypes_delete { my ($self, @params) = @_; return $self->lr->delete('TagType', @params); } @@ -151,7 +148,6 @@ sub tagTypes_find { my ($self, @params) = @_; return $self->lr->find('TagType' sub teams_all { my ($self, @params) = @_; return $self->lr->all('Team', @params); } sub teams_count { my ($self, @params) = @_; return $self->lr->count('Team', @params); } sub teams_empty { my ($self, @params) = @_; return $self->lr->empty('Team', @params); } -sub teams_exists { my ($self, @params) = @_; return $self->lr->exists('Team', @params); } sub teams_save { my ($self, @params) = @_; return $self->lr->save('Team', @params); } sub teams_update { my ($self, @params) = @_; return $self->lr->update('Team', @params); } sub teams_delete { my ($self, @params) = @_; return $self->lr->delete('Team', @params); } @@ -163,7 +159,6 @@ sub teams_find { my ($self, @params) = @_; return $self->lr->find('Team', @par sub types_all { my ($self, @params) = @_; return $self->lr->all('Type', @params); } sub types_count { my ($self, @params) = @_; return $self->lr->count('Type', @params); } sub types_empty { my ($self, @params) = @_; return $self->lr->empty('Type', @params); } -sub types_exists { my ($self, @params) = @_; return $self->lr->exists('Type', @params); } sub types_save { my ($self, @params) = @_; return $self->lr->save('Type', @params); } sub types_update { my ($self, @params) = @_; return $self->lr->update('Type', @params); } sub types_delete { my ($self, @params) = @_; return $self->lr->delete('Type', @params); } @@ -175,7 +170,6 @@ sub types_find { my ($self, @params) = @_; return $self->lr->find('Type', @par sub users_all { my ($self, @params) = @_; return $self->lr->all('User', @params); } sub users_count { my ($self, @params) = @_; return $self->lr->count('User', @params); } sub users_empty { my ($self, @params) = @_; return $self->lr->empty('User', @params); } -sub users_exists { my ($self, @params) = @_; return $self->lr->exists('User', @params); } sub users_save { my ($self, @params) = @_; return $self->lr->save('User', @params); } sub users_update { my ($self, @params) = @_; return $self->lr->update('User', @params); } sub users_delete { my ($self, @params) = @_; return $self->lr->delete('User', @params); } diff --git a/lib/BibSpace/Repository/LayeredRepository.pm b/lib/BibSpace/Repository/LayeredRepository.pm deleted file mode 100644 index b0f77ed..0000000 --- a/lib/BibSpace/Repository/LayeredRepository.pm +++ /dev/null @@ -1,429 +0,0 @@ -# This code was auto-generated using ArchitectureGenerator.pl on 2017-01-15T15:07:35 -package LayeredRepository; -use namespace::autoclean; -use Moose; -use MooseX::ClassAttribute; -use feature qw( state say ); -use MooseX::StrictConstructor; -use Try::Tiny; -use List::Util qw(first); -use Scalar::Util qw( refaddr ); - -use BibSpace::Util::IUidProvider; -use BibSpace::Util::SmartUidProvider; -use BibSpace::Repository::RepositoryLayer; -use BibSpace::Util::EntityFactory; - -# logic of the layered repository = read from one layer, write to all layers - -has 'logger' => (is => 'ro', does => 'ILogger', required => 1); -has 'preferences' => (is => 'ro', isa => 'Preferences', required => 1); -has 'id_provider_class' => (is => 'ro', isa => 'Str', required => 1); - -sub BUILD { - my $self = shift; - - my $uidP = SmartUidProvider->new( - logger => $self->logger, - idProviderClassName => $self->id_provider_class - ); - $self->uidProvider($uidP); - - my $e_factory = EntityFactory->new( - logger => $self->logger, - id_provider => $self->uidProvider, - preferences => $self->preferences - ); - $self->e_factory($e_factory); -} - -# will be set in the post-construction routine BUILD -has 'uidProvider' => (is => 'rw', isa => 'SmartUidProvider'); - -# will be set in the post-construction routine BUILD -has 'e_factory' => (is => 'rw', isa => 'EntityFactory'); - -# layer_name => RepositoryLayer -has 'layers' => ( - is => 'ro', - isa => 'HashRef[RepositoryLayer]', - traits => ['DoNotSerialize'], - default => sub { {} } -); - -# static methods -class_has 'entities' => ( - is => 'ro', - isa => 'ArrayRef[Str]', - default => sub { - - # ORDER IS IMPORTANT!!! TAG MUST BE AFTER TAGTYPE - it references it N:1! - ['Author', 'Entry', 'TagType', 'Tag', 'Team', 'Type', 'User']; - }, - traits => ['Array'], - handles => {get_entities => 'elements',}, -); -class_has 'relations' => ( - is => 'ro', - isa => 'ArrayRef[Str]', - default => sub { - ['Authorship', 'Exception', 'Labeling', 'Membership']; - }, - traits => ['Array'], - handles => {get_relations => 'elements',}, -); - -class_has 'models' => ( - is => 'ro', - isa => 'ArrayRef[Str]', - default => sub { - return [LayeredRepository->get_entities, LayeredRepository->get_relations]; - }, - traits => ['Array'], - handles => {get_models => 'elements',}, -); - -=item get_read_layer - Returns layer designated for reading. Throws exception if no read layer found -=cut - -sub get_read_layer { - my $self = shift; - my $readLayer = first { $_->is_read } $self->get_all_layers; - return $readLayer; -} - -=item get_all_layers - Returns all layers -=cut - -sub get_all_layers { - my $self = shift; - my @sorted_layers - = sort { $a->priority <=> $b->priority } values %{$self->layers}; - return @sorted_layers; -} - -=item get_layer - Searches for layer named $name in the repo and returs it. -=cut - -sub get_layer { - my $self = shift; - my $name = shift; - if (exists $self->layers->{$name}) { - return $self->layers->{$name}; - } - return; -} - -=item replace_layer - Replaces layer named $name in the repo with an input_layer object (e.g., from backup). - Sets id providers (no copy, replace!) in all layers to the id provider of the input layer. -=cut - -sub replace_layer { - my $self = shift; - my $name = shift; - my $input_layer = shift; - - my $destLayer = $self->get_layer($name); - if (ref($destLayer) ne ref($input_layer)) { - $self->logger->error( - "Replacing layers with of different type, this will lead to a failure!"); - die "Replacing layers with of different type, this will lead to a failure!"; - } - if ($destLayer and $input_layer->is_read != $destLayer->is_read) { - $self->logger->error( - "Replacing layers with different is_read value! This is experimental!"); - } - delete $self->layers->{$name}; - $self->layers->{$name} = $input_layer; - - ## START TRANSACTION - you really need to do all of this together - # $self->logger->debug("Replacing ID PROVIDER for all layers!"); - $self->replace_uid_provider($input_layer->uidProvider); - - # $self->logger->debug("Replacing E_FACTORY for all layers!"); - # e_factory has also id_providers, so it must be replaced - $self->replace_e_factory($input_layer->e_factory); - $self->e_factory->id_provider($input_layer->uidProvider); - ## COMMIT TRANSACTION -} - -=item replace_uid_provider - Replaces main id provider (loacted in $self->uidProvider) state. - This id provider is referenced by all layers! -=cut - -sub replace_uid_provider { - my $self = shift; - my $input_id_provider = shift; - $self->uidProvider($input_id_provider); - foreach my $layer ($self->get_all_layers) { - $layer->uidProvider($input_id_provider); - } -} - -=item replace_uid_provider - Replaces main id provider (loacted in $self->uidProvider) state. - This id provider is referenced by all layers! -=cut - -sub replace_e_factory { - my $self = shift; - my $input_e_factory = shift; - $self->e_factory($input_e_factory); - foreach my $layer ($self->get_all_layers) { - $layer->e_factory($input_e_factory); - } -} - -=item add_layer - Adds new layer to the layered repository. - Sets id provider (no copy, replace!) to this layer -=cut - -sub add_layer { - my $self = shift; - my $layer = shift; - - if (exists $self->layers->{$layer->name}) { - die "Layer with such name already exist."; - } - if ($layer->is_read and $self->get_read_layer) { - die "There can be only one read layer."; - } - $layer->e_factory($self->e_factory); - $layer->uidProvider($self->uidProvider); - $self->layers->{$layer->name} = $layer; -} - -=item reset_uid_providers - Resets main id provider (loacted in $self->uidProvider) state. - This id provider is referenced by all layers! - You reset here, and all id_provider references in the layers will be reset as well. -=cut - -sub reset_uid_providers { - my $self = shift; - - # $self->uidProvider is a container that is referenced directly by all layers! - $self->uidProvider->reset; -} - -sub get_summary_table { - my $self = shift; - my $str = "\n"; - - # get_id_provider_summary_hash - - my %count_hash; #layer_name => summary_hash - my @prefixes = qw(CNT_ ID_); - my @column_name = map { $_ . "OK" } @prefixes; - foreach my $layer ($self->get_all_layers) { - push @column_name, "CNT_" . $layer->name; - push @column_name, "ID_" . $layer->name; - $count_hash{"CNT_" . $layer->name} = $layer->get_summary_hash; - $count_hash{"ID_" . $layer->name} = $layer->get_id_provider_summary_hash; - } - - my $tab_width = 91; - - # calc CHECK status - foreach my $entity (LayeredRepository->get_models) { - foreach my $prefix (@prefixes) { - $count_hash{$prefix . 'OK'}->{$entity} = 'y'; - my $val; - foreach my $ln (reverse sort map { $_->name } $self->get_all_layers) { - if (!defined $val) { - $val = "" . $count_hash{$prefix . $ln}->{$entity}; - } - if ($count_hash{$prefix . $ln}->{$entity} ne $val) { - $count_hash{$prefix . 'OK'}->{$entity} = 'NO'; - } - } - } - } - - # print column names - for (1 .. $tab_width) { $str .= "-"; } - $str .= "\n"; - $str .= sprintf "| %-15s |", 'entity'; - foreach my $ln (reverse sort @column_name) { - $str .= sprintf " %-9s |", $ln; - } - $str .= "\n"; - for (1 .. $tab_width) { $str .= "-"; } - $str .= "\n"; - - # print data - foreach my $entity (LayeredRepository->get_entities) { - $str .= sprintf "| %-15s |", $entity; - foreach my $ln (reverse sort @column_name) { - $str .= sprintf " %9s |", $count_hash{$ln}->{$entity}; - } - $str .= "\n"; - } - for (1 .. $tab_width) { $str .= "-"; } - $str .= "\n"; - foreach my $entity (LayeredRepository->get_relations) { - $str .= sprintf "| %-15s |", $entity; - foreach my $ln (reverse sort @column_name) { - $str .= sprintf " %9s |", $count_hash{$ln}->{$entity}; - } - $str .= "\n"; - } - for (1 .. $tab_width) { $str .= "-"; } - $str .= "\n"; - $str - .= "IF YOU SEE ANY 'NO' IN ANY '_OK' COLUMN THEN MANIPULATING DATA IN THE SYSTEM MAY LEAD TO DATA LOSS OR EXCEPTIONS!"; - return $str; -} - -=item copy_data - Copies data between layers of repositories. - Does not change the uid_providers (there is one global) - Remember: If you move data FROM layer, which creates_on_read==true, - then you need to reset id_providers. -=cut - -# refactor this nicely into a single function - load dump fixture or so... -# IMPORTANT FIXME: this should be always called when entire dataset in smart array is replaced!! -# $self->app->repo->lr->get_read_layer->reset_data; -# $self->app->repo->lr->reset_uid_providers; -# $self->repo->lr->copy_data( { from => 'mysql', to => 'smart' } ); - -sub copy_data { - my $self = shift; - my $config = shift; - - my $backendFrom = $config->{from}; - my $backendTo = $config->{to}; - - my $srcLayer = $self->get_layer($backendFrom); - my $destLayer = $self->get_layer($backendTo); - - if ($srcLayer eq $destLayer) { - $self->logger->error( - "Source and destination layers are the same, cannot copy."); - return; - } - - if ((!$srcLayer) or (!$destLayer)) { - $self->logger->error( - "Cannot copy data from layer '$backendFrom' to layer '$backendTo' - one or more layers do not exist." - ); - return; - } - -# $self->logger->debug("State before reset_uid_providers: ".$self->get_summary_table); - - if ($srcLayer->creates_on_read) { - $self->logger->warn( - "Resetting all uid providers during copy from layer '$backendFrom' to layer '$backendTo'." - ); - $self->reset_uid_providers; - } - - # # Copy uid_provider from srcLayer to all layers - # # A) smart -> mysql - # # B) mysql -> smart - # $self->replace_uid_provider($srcLayer->uidProvider); - - # $self->logger->debug("State before reset data:".$self->get_summary_table); - ## avoid data duplication in the destination layer!! - $destLayer->reset_data - ; # this has unfortunately no meaning for mysql :( need to implement this - - # ALWAYS: first copy entities, then relations - - $self->logger->debug( - "Copying data from layer '$backendFrom' to layer '$backendTo'."); - - foreach my $type (LayeredRepository->get_entities) { - my @resultRead = $srcLayer->all($type); - my $resultSave = $destLayer->save($type, @resultRead); - - $self->logger->debug("'$backendFrom'-read " - . scalar(@resultRead) - . " objects '" - . $type - . "' ==> '$backendTo'-write $resultSave objects."); - - } - foreach my $type (LayeredRepository->get_relations) { - - my @resultRead = $srcLayer->all($type); - my $resultSave = $destLayer->save($type, @resultRead); - - $self->logger->debug("'$backendFrom'-read " - . scalar(@resultRead) - . " objects '" - . $type - . "' ==> '$backendTo'-write $resultSave objects."); - - } -} - -sub all { - my $self = shift; - my $type = shift; - return $self->get_read_layer->all($type); -} - -sub count { - my ($self, $type) = @_; - return $self->get_read_layer->count($type); -} - -sub empty { - my ($self, $type) = @_; - return $self->get_read_layer->empty($type); -} - -sub exists { - my ($self, $type, $obj) = @_; - return $self->get_read_layer->exists($type, $obj); -} - -sub save { - my ($self, $type, @objects) = @_; - my @return; - foreach my $layer ($self->get_all_layers) { - push @return, $layer->save($type, @objects); - } - return @return; -} - -sub update { - my ($self, $type, @objects) = @_; - my @return; - foreach my $layer ($self->get_all_layers) { - push @return, $layer->update($type, @objects); - } - return @return; -} - -sub delete { - my ($self, $type, @objects) = @_; - my @return; - foreach my $layer ($self->get_all_layers) { - push @return, $layer->delete($type, @objects); - } - return @return; -} - -sub filter { - my ($self, $type, $coderef) = @_; - return $self->get_read_layer->filter($type, $coderef); -} - -sub find { - my ($self, $type, $coderef) = @_; - return $self->get_read_layer->find($type, $coderef); -} - -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/Repository/RepositoryLayer.pm b/lib/BibSpace/Repository/RepositoryLayer.pm index 250be39..4b29b7c 100644 --- a/lib/BibSpace/Repository/RepositoryLayer.pm +++ b/lib/BibSpace/Repository/RepositoryLayer.pm @@ -8,22 +8,15 @@ use MooseX::StrictConstructor; use Try::Tiny; use BibSpace::Util::IUidProvider; -use BibSpace::DAO::SmartArrayDAOFactory; use BibSpace::DAO::MySQLDAOFactory; -use BibSpace::DAO::RedisDAOFactory; -use BibSpace::Util::SmartUidProvider; use BibSpace::Util::EntityFactory; # this is rewritten during backup-restore, thus rw has 'e_factory' => (is => 'rw', isa => 'Maybe[EntityFactory]'); -# this is rewritten during backup-restore, thus rw -has 'uidProvider' => - (is => 'rw', isa => 'Maybe[SmartUidProvider]', default => undef); - =item backendFactoryName Stores the name of the DAO Factory for this layer. E.g. SmartArrayDaoFactory -=cut +=cut has 'backendFactoryName' => (is => 'ro', isa => 'Str', required => 1); has 'name' => (is => 'ro', isa => 'Str', required => 1); @@ -67,17 +60,17 @@ has 'creates_on_read' => ( required => 1, documentation => q{Does this layer creates new objects (BibSpaceEntity) on reading them from backend? - If yes, then moving data from this layer requires to reset all uid_providers. - Example 1: + If yes, then moving data from this layer requires to reset all uid_providers. + Example 1: 0) MySQL do creates objects on read, 1) Imagine moving data: MySQL -> overwrites -> SmartArray, 2) We reset data (only data) in SmartArray - it will be anyway overwritten, 3) MySQL created objects on read and registers new IDs in the id_provider, 4) There is one instance of id_provider (for each type) per all layers, - 5) The id_provider MUST BE RESET, because the objects already residing in the SmartArray + 5) The id_provider MUST BE RESET, because the objects already residing in the SmartArray would be duplicated with new IDs generated by the id_provider. Example 2: - 0) SmartArray does not create objects on read - it stores references and does not offer persistence. + 0) SmartArray does not create objects on read - it stores references and does not offer persistence. 1) Imagine moving data: SmartArray -> overwrites -> MySQL, 2) We reset data (only data) in MySQL - it will be anyway overwritten, 3) Nothing bad happens in MySQL, MySQL does not persist (directly) state of id_providers, @@ -89,7 +82,7 @@ has 'creates_on_read' => ( ); =item reset_data - Hard reset removes all instances of repositories and resets all id providers. + Hard reset removes all instances of repositories and resets all id providers. Use only for overwriting whole data set, e.g., during backup restore. =cut @@ -115,18 +108,7 @@ sub reset_data { } else { - try { - $self->handle->reset_data; - } - catch { - # Only SmartArray supports direct reset - if ( ref($self->handle) eq 'SmartArray' - or ref($self->handle) eq 'SmartHash') - { - $self->logger->error( - "Reset of " . ref($self->handle) . " failed. Error $_"); - } - }; + $self->handle->reset_data; } } @@ -136,44 +118,37 @@ sub daoDispatcher { my $entity_type = shift; if ($entity_type eq 'TagType') { - return $factory->getTagTypeDao( - $self->uidProvider->get_provider($entity_type)); + return $factory->getTagTypeDao(); } if ($entity_type eq 'Team') { - return $factory->getTeamDao($self->uidProvider->get_provider($entity_type)); + return $factory->getTeamDao(); } if ($entity_type eq 'Author') { - return $factory->getAuthorDao( - $self->uidProvider->get_provider($entity_type)); + return $factory->getAuthorDao(); } if ($entity_type eq 'Authorship') { - return $factory->getAuthorshipDao( - $self->uidProvider->get_provider($entity_type)); + return $factory->getAuthorshipDao(); } if ($entity_type eq 'Membership') { - return $factory->getMembershipDao( - $self->uidProvider->get_provider($entity_type)); + return $factory->getMembershipDao(); } if ($entity_type eq 'Entry') { - return $factory->getEntryDao( - $self->uidProvider->get_provider($entity_type)); + return $factory->getEntryDao(); } if ($entity_type eq 'Labeling') { - return $factory->getLabelingDao( - $self->uidProvider->get_provider($entity_type)); + return $factory->getLabelingDao(); } if ($entity_type eq 'Tag') { - return $factory->getTagDao($self->uidProvider->get_provider($entity_type)); + return $factory->getTagDao(); } if ($entity_type eq 'Exception') { - return $factory->getExceptionDao( - $self->uidProvider->get_provider($entity_type)); + return $factory->getExceptionDao(); } if ($entity_type eq 'Type') { - return $factory->getTypeDao($self->uidProvider->get_provider($entity_type)); + return $factory->getTypeDao(); } if ($entity_type eq 'User') { - return $factory->getUserDao($self->uidProvider->get_provider($entity_type)); + return $factory->getUserDao(); } $self->logger->error("Requested unknown entity_type: '$entity_type'"); die "Requested unknown entity_type: '$entity_type'"; @@ -200,45 +175,29 @@ sub getDao { sub get_summary_hash { my $self = shift; - my %hash = map { $_ => $self->count($_) } LayeredRepository->get_models; - return \%hash; -} - -=item get_id_provider_summary_hash - Provides a summary of a layer in form of a hash. - Has is build like this: entity_name => last_id of idProvider -=cut - -sub get_id_provider_summary_hash { - my $self = shift; - my %entities_hash - = map { $_ => $self->uidProvider->get_provider($_)->last_id } - LayeredRepository->get_entities; - my %relations_hash = map { $_ => '---' } LayeredRepository->get_relations; - my %hash = (%entities_hash, %relations_hash); + my %hash = map { $_ => $self->count($_) } FlatRepository->get_models; return \%hash; } =item get_summary_table - Prints nice summary table for all layers. + Prints nice summary table for all layers. Example: - ID_X = last id of the id_provider in layer X CNT_X = number of entities in layer X - ------------------------------------------- - | entity | ID_smart | CNT_mysql | - ------------------------------------------- - | Author | 1296 | 74 | - | Authorship | --- | 696 | - | Entry | 1117 | 379 | - | Exception | --- | 2 | - | Labeling | --- | 6 | - | Membership | --- | 27 | - | Tag | 231 | 50 | - | TagType | 4 | 4 | - | Team | 6 | 4 | - | Type | 17 | 24 | - | User | 1 | 1 | - ------------------------------------------- + ------------------------------- + | entity | CNT_mysql | + ------------------------------- + | Author | 74 | + | Authorship | 696 | + | Entry | 379 | + | Exception | 2 | + | Labeling | 6 | + | Membership | 27 | + | Tag | 50 | + | TagType | 4 | + | Team | 4 | + | Type | 24 | + | User | 1 | + ------------------------------- =cut sub get_summary_table { @@ -248,11 +207,9 @@ sub get_summary_table { my %count_hash; #layer_name => summary_hash my @layer_names; push @layer_names, "CNT_" . $self->name; - push @layer_names, "ID_" . $self->name; $count_hash{"CNT_" . $self->name} = $self->get_summary_hash; - $count_hash{"ID_" . $self->name} = $self->get_id_provider_summary_hash; - my $tab_width = 67; + my $tab_width = 31; for (1 .. $tab_width) { $str .= "_"; } $str .= "\n"; @@ -263,7 +220,7 @@ sub get_summary_table { $str .= "\n"; for (1 .. $tab_width) { $str .= "-"; } $str .= "\n"; - foreach my $entity (LayeredRepository->get_entities) { + foreach my $entity (FlatRepository->get_entities) { $str .= sprintf "| %-15s |", $entity; foreach my $ln (reverse sort @layer_names) { $str .= sprintf " %9s |", $count_hash{$ln}->{$entity}; @@ -272,7 +229,7 @@ sub get_summary_table { } for (1 .. $tab_width) { $str .= "-"; } $str .= "\n"; - foreach my $entity (sort LayeredRepository->get_relations) { + foreach my $entity (sort FlatRepository->get_relations) { $str .= sprintf "| %-15s |", $entity; foreach my $ln (reverse sort @layer_names) { $str .= sprintf " %9s |", $count_hash{$ln}->{$entity}; diff --git a/lib/BibSpace/TestManager.pm b/lib/BibSpace/TestManager.pm index f457f6e..364c284 100644 --- a/lib/BibSpace/TestManager.pm +++ b/lib/BibSpace/TestManager.pm @@ -4,7 +4,7 @@ use Try::Tiny; use BibSpace; use BibSpace::Model::Backup; -use BibSpace::Functions::BackupFunctions qw(restore_storable_backup); +use BibSpace::Functions::BackupFunctions qw(restore_json_backup); use BibSpace::Functions::FDB; # TODO: purge DB etc. use Moose; @@ -13,11 +13,11 @@ sub apply_fixture { my $self = shift; my $app = shift; ## THIS SHOULD BE REPEATED FOR EACH TEST! - my $fixture_file = $app->home->rel_file('fixture/bibspace_fixture.dat'); + my $fixture_file = $app->home->rel_file('fixture/bibspace_fixture.json'); my $fixture_name = '' . $fixture_file->basename; my $fixture_dir = '' . $fixture_file->dirname; my $fixture = Backup->new(dir => $fixture_dir, filename => $fixture_name); - restore_storable_backup($fixture, $app); + restore_json_backup($fixture, $app); } no Moose; diff --git a/lib/BibSpace/Util/DummyUidProvider.pm b/lib/BibSpace/Util/DummyUidProvider.pm deleted file mode 100644 index 064d984..0000000 --- a/lib/BibSpace/Util/DummyUidProvider.pm +++ /dev/null @@ -1,17 +0,0 @@ -package DummyUidProvider; -use Moose; -use BibSpace::Util::IUidProvider; -with 'IUidProvider'; -use List::Util qw(max); -use Scalar::Util qw( refaddr ); -use List::MoreUtils qw(any uniq); - -use feature qw(say); - -sub reset { 1; } -sub registerUID { 1; } -sub last_id { 1; } -sub generateUID { 1; } - -no Moose; -1; diff --git a/lib/BibSpace/Util/EntityFactory.pm b/lib/BibSpace/Util/EntityFactory.pm index 363f890..128746c 100644 --- a/lib/BibSpace/Util/EntityFactory.pm +++ b/lib/BibSpace/Util/EntityFactory.pm @@ -15,72 +15,77 @@ use BibSpace::Model::Entry; has 'logger' => (is => 'ro', does => 'ILogger', required => 1); # this may be rewritten during backup restore = must be rw (or writable in another way) -has 'id_provider' => (is => 'rw', isa => 'SmartUidProvider', required => 1); -has 'preferences' => (is => 'ro', isa => 'Preferences', required => 1); +has 'preferences' => (is => 'ro', isa => 'Preferences', required => 1); +has 'facade' => + (is => 'rw', isa => 'Maybe[FlatRepositoryFacade]', default => undef); sub new_Entry { my ($self, %args) = @_; - return Entry->new( - idProvider => $self->id_provider->get_provider('Entry'), - preferences => $self->preferences, - %args - ); + return Entry->new(preferences => $self->preferences, repo => $self->facade, + %args); } sub new_TagType { my ($self, %args) = @_; return TagType->new( - idProvider => $self->id_provider->get_provider('TagType'), preferences => $self->preferences, + repo => $self->facade, %args ); } sub new_Team { my ($self, %args) = @_; - return Team->new( - idProvider => $self->id_provider->get_provider('Team'), - preferences => $self->preferences, - %args - ); + return Team->new(preferences => $self->preferences, repo => $self->facade, + %args); } sub new_Author { my ($self, %args) = @_; return Author->new( - idProvider => $self->id_provider->get_provider('Author'), preferences => $self->preferences, + repo => $self->facade, %args ); } sub new_Tag { my ($self, %args) = @_; - return Tag->new( - idProvider => $self->id_provider->get_provider('Tag'), - preferences => $self->preferences, - %args - ); + return Tag->new(preferences => $self->preferences, repo => $self->facade, + %args); } sub new_Type { my ($self, %args) = @_; - return Type->new( - idProvider => $self->id_provider->get_provider('Type'), - preferences => $self->preferences, - %args - ); + return Type->new(preferences => $self->preferences, repo => $self->facade, + %args); } sub new_User { my ($self, %args) = @_; - return User->new( - idProvider => $self->id_provider->get_provider('User'), - preferences => $self->preferences, - %args - ); + return User->new(preferences => $self->preferences, repo => $self->facade, + %args); } +sub new_Authorship { + my ($self, %args) = @_; + return Authorship->new(repo => $self->facade, %args); +} + +sub new_Membership { + my ($self, %args) = @_; + return Membership->new(repo => $self->facade, %args); +} + +sub new_Labeling { + my ($self, %args) = @_; + return Labeling->new(repo => $self->facade, %args); +} + +sub new_Exception { + my ($self, %args) = @_; + return Exception->new(repo => $self->facade, %args); +} __PACKAGE__->meta->make_immutable; no Moose; 1; diff --git a/lib/BibSpace/Util/IntegerUidProvider.pm b/lib/BibSpace/Util/IntegerUidProvider.pm deleted file mode 100644 index 5d006e1..0000000 --- a/lib/BibSpace/Util/IntegerUidProvider.pm +++ /dev/null @@ -1,83 +0,0 @@ -package IntegerUidProvider; -use Moose; -use BibSpace::Util::IUidProvider; -with 'IUidProvider'; -use List::Util qw(max); -use Scalar::Util qw( refaddr ); -use List::MoreUtils qw(any uniq); -use feature qw(say); - -use BibSpace::Util::SimpleLogger; - -# -use MooseX::ClassAttribute; - -has 'data' => ( - traits => ['Hash'], - is => 'ro', - isa => 'HashRef[Int]', - default => sub { {} }, - handles => { - uid_set => 'set', - uid_get => 'get', - uid_has => 'exists', - uid_defined => 'defined', - uid_num => 'count', - uid_keys => 'keys', - uid_pairs => 'kv', - clear => 'clear', - }, -); - -sub reset { - my ($self) = @_; - $self->logger->warn( - "Resetting UID record for type '" . $self->for_type . "' !"); - $self->clear; -} - -sub registerUID { - my ($self, $uid) = @_; - - if (!$self->uid_defined($uid)) { - $self->uid_set($uid => 1); - $self->logger->lowdebug( - "Registered uid '$uid' for type '" . $self->for_type . "'."); - } - else { - my $msg - = "Cannot registerUID for type '" - . $self->for_type - . "'. It exists already! Wanted to reg: $uid."; - $self->logger->error($msg); - ### TODO: THIS SHOULD BE DIE!! - # warn is only for debugging - # die $msg; - } -} - -sub last_id { - my ($self) = @_; - my $curr_max = 0; # starting default id - my $curr_max_candidate = max $self->uid_keys; - if (defined $curr_max_candidate and $curr_max_candidate > 0) { - $curr_max = $curr_max_candidate; - } - return $curr_max; -} - -sub generateUID { - my ($self) = @_; - - my $curr_max = $self->last_id; - my $new_uid = $curr_max + 1; - $self->uid_set($new_uid => 1); - -# this debug msg can break a lot - generated uids are delayed and some older copies are returned... strange -# $self->logger->debug(" (".refaddr($self).") has generated uid '$new_uid' for type '".$self->for_type."'"); -# say " (".refaddr($self).") has generated uid '$new_uid' for type '".$self->for_type."'"; - return $new_uid; -} - -no Moose; -1; diff --git a/lib/BibSpace/Util/SmartUidProvider.pm b/lib/BibSpace/Util/SmartUidProvider.pm deleted file mode 100644 index 73487b2..0000000 --- a/lib/BibSpace/Util/SmartUidProvider.pm +++ /dev/null @@ -1,131 +0,0 @@ -package SmartUidProvider; - -use v5.16; -use Try::Tiny; -use Data::Dumper; -use namespace::autoclean; - -use List::Util qw(max); -use Scalar::Util qw( refaddr ); -use List::MoreUtils qw(any uniq); -use feature qw(say); - -use Moose; - -use Moose::Util::TypeConstraints; -use List::Util qw(first); -use List::MoreUtils qw(first_index); - -use MooseX::Storage; -with Storage(format => 'JSON', 'io' => 'File'); - -=item - This is a in-memory data structure (hash) to hold all objects of BibSpace. - It is build like this: - String "TypeName" => Array of Objects with type TypeName. - It could be improved for performance like this: - String "TypeName" => { Integer UID => Object with type TypeName}. -=cut - -has 'logger' => - (is => 'ro', does => 'ILogger', required => 1, traits => ['DoNotSerialize']); -has 'idProviderClassName' => (is => 'ro', isa => 'Str', required => 1); - -has 'data' => ( - traits => ['Hash'], - is => 'ro', - isa => 'HashRef[IUidProvider]', - default => sub { {} }, - handles => { - _set => 'set', - _get => 'get', - _has => 'exists', - _defined => 'defined', - _keys => 'keys', - _values => 'values', - _num => 'count', - _pairs => 'kv', - }, -); - -sub get_provider { - my ($self, $type) = @_; - $self->_init($type); - my $provider = $self->_get($type); - return $provider; -} - -sub _init { - my ($self, $type) = @_; - - if (!$type) { - $self->logger->error("_init requires a type!"); - die "_init requires a type!"; - } - if (!$self->_defined($type)) { - try { - my $className = $self->idProviderClassName; - Class::Load::load_class($className); - my $providerInstance - = $className->new(logger => $self->logger, for_type => $type); - $self->_set($type, $providerInstance); - } - catch { - my $msg - = "Requested unknown type of IUidProvider : '" - . $self->idProviderClassName - . "'. Error: $_"; - $self->logger->error($msg); - die $msg; - }; - } -} - -sub reset { - my $self = shift; - $self->logger->warn("Resetting all UID Providers"); - foreach my $type ($self->_keys) { - $self->_get($type)->clear; - } - -} - -sub registerUID { - my ($self, $type, $uid) = @_; - - if (!$self->_get($type)->uid_defined($uid)) { - $self->_get($type)->uid_set($uid => 1); - } - else { - my $msg - = "Cannot registerUID. It exists already! Wanted to reg: $uid. Existing: " - . join(' ', sort $self->_keys); - $self->logger->error($msg); - die $msg; - } -} - -sub last_id { - my ($self, $type) = @_; - my $curr_max = 1; # starting default id - my $curr_max_candidate = max $self->_get($type)->uid_keys; - if (defined $curr_max_candidate and $curr_max_candidate > 0) { - $curr_max = $curr_max_candidate; - } - return $curr_max; -} - -# I think this is never used... -sub generateUID { - my ($self, $type) = @_; - - my $curr_max = $self->last_id($type); - my $new_uid = $curr_max + 1; - $self->_get($type)->uid_set($new_uid => 1); - $self->logger->debug("Generated uid '$new_uid' for object type '$type'."); - return $new_uid; -} - -__PACKAGE__->meta->make_immutable; -no Moose; -1; diff --git a/lib/BibSpace/files/config/default.conf b/lib/BibSpace/files/config/default.conf index da1a8b9..b4dedbd 100644 --- a/lib/BibSpace/files/config/default.conf +++ b/lib/BibSpace/files/config/default.conf @@ -1,5 +1,5 @@ { - config_valid_with => 'v0.5.0', + config_valid_with => 'v0.6.0', backups_dir => app->home->rel_file('backups'), upload_dir => app->home->rel_file('public/uploads'), log_dir => app->home->rel_file('log'), @@ -15,10 +15,10 @@ db_pass => "passw00rd", cron_day_freq_lock => 0, - cron_night_freq_lock => 0, - cron_week_freq_lock => 0, + cron_night_freq_lock => 0, + cron_week_freq_lock => 0, cron_month_freq_lock => 0, - + demo_mode => 0, demo_msg => '', diff --git a/lib/BibSpace/files/templates/authors/authors.html.ep b/lib/BibSpace/files/templates/authors/authors.html.ep index 779d041..28f027f 100644 --- a/lib/BibSpace/files/templates/authors/authors.html.ep +++ b/lib/BibSpace/files/templates/authors/authors.html.ep @@ -11,7 +11,7 @@ % } - + All authors @@ -22,7 +22,7 @@% } - + Show visible @@ -33,7 +33,7 @@% } - + Show invisible @@ -47,7 +47,7 @@ % else{% } - All + All % foreach my $let (@{$letters}){ % if( $selected_letter and $let eq $selected_letter ){ @@ -56,7 +56,9 @@ % else{% } - <%= $let %> + + <%= $let %> + %} @@ -70,32 +72,51 @@% foreach my $author (@{$authors}){ - +
- + + + - -- % $i++; % $j--; diff --git a/lib/BibSpace/files/templates/authors/edit_author.html.ep b/lib/BibSpace/files/templates/authors/edit_author.html.ep index 6300c65..ae717c8 100644 --- a/lib/BibSpace/files/templates/authors/edit_author.html.ep +++ b/lib/BibSpace/files/templates/authors/edit_author.html.ep @@ -10,7 +10,7 @@+ [<%= $j %>]
+ <%= $j %>
+% if ($author->is_visible){ - + + + %} %else{ - - + + + + %} % if ( $author->can_be_deleted){ - + + + %} %else{ %} - Edit + + Edit + -- <%= $author->id %>
- <%= $author->master %>
Show papers -Landing page -Landing page years ++ + ++ + +Show papers +Landing page +Landing page years Author:
-@@ -20,23 +20,23 @@<%= $author->uid %>
+<%= $author->uid %>
- - Show entries + + Show entries <%= num_pubs( undef, undef, [$author->get_entries] ) %> - - Show papers + + Show papers <%= num_pubs( 'paper', undef, [$author->get_entries] ) %> - - Show talks + + Show talks <%= num_pubs( 'talk', undef, [$author->get_entries] ) %> - Show tag-cloud + Show tag-cloud@@ -47,44 +47,44 @@- +- +- + @@ -131,11 +131,11 @@Edit author
@@ -120,7 +120,7 @@@@ -151,29 +151,29 @@% my $i = 0; - % + %% for my $minor_author (@$minor_authors){
- - - + + + %} - - <%= $minor_author->uid %> + + <%= $minor_author->name %> %if( $minor_author->id != $author->id){ -
%}@@ -183,7 +183,7 @@
@@ -317,7 +323,7 @@- <%= $team->{name} %> + <%= $team->{name} %> | @@ -325,7 +331,7 @@ % $jj++; % }- +
@@ -339,9 +345,9 @@ %foreach my $tag (@$tags){- <%= $tag->{name} %> + <%= $tag->{name} %> - + <%= num_pubs_for_author_and_tag( $author, $tag )%> @@ -349,7 +355,7 @@ % $k++; %}- +
@@ -358,9 +364,9 @@@@ -369,20 +375,20 @@- + Admin area - +- +- + Merge authorsMerge authors (experimental feature)
-The author, whose ID is given in the form below, will be merged into this one (<%= $author->{master} %>). Feature is experimental.
+The author, whose ID is given in the form below, will be merged into this one (<%= $author->master->name %>). Feature is experimental.
Merging affects only entries.
The result is immediate. Make backup if in doubt. Some things can be reverted (but no teams!)
Warning! The source author will abandon all teams.
@@ -426,7 +432,7 @@+ diff --git a/lib/BibSpace/files/templates/backup/backup.html.ep b/lib/BibSpace/files/templates/backup/backup.html.ep index b12cdbb..c9829ba 100644 --- a/lib/BibSpace/files/templates/backup/backup.html.ep +++ b/lib/BibSpace/files/templates/backup/backup.html.ep @@ -8,11 +8,6 @@Are you sure you want to delete this author from the system? His/her papers remain untouched.
- + - +Back - %= form_for backup_do => (class=>'display-inline') => begin - - % end %= form_for backup_do_mysql => (class=>'display-inline') => begin % end % } - -@@ -87,10 +77,7 @@- % if( $backup->is_healthy and $backup->type eq 'storable' ){ - Restore... - %} - % elsif( $backup->is_healthy and $backup->type eq 'json' ){ + % if( $backup->is_healthy and $backup->type eq 'json' ){ Restore... %} % else{ @@ -147,43 +134,7 @@ - - -- - - +-- -- + %} diff --git a/lib/BibSpace/files/templates/display/danger_zone.html.ep b/lib/BibSpace/files/templates/display/danger_zone.html.ep index 5cb4e04..460d423 100644 --- a/lib/BibSpace/files/templates/display/danger_zone.html.ep +++ b/lib/BibSpace/files/templates/display/danger_zone.html.ep @@ -18,35 +18,13 @@-- -Move data between layers+Reset system state-- - -Reset layers- --- - - \ No newline at end of file + diff --git a/lib/BibSpace/files/templates/login/noregister.html.ep b/lib/BibSpace/files/templates/login/noregister.html.ep index 2a95c8e..fcbdc78 100644 --- a/lib/BibSpace/files/templates/login/noregister.html.ep +++ b/lib/BibSpace/files/templates/login/noregister.html.ep @@ -7,16 +7,15 @@Generate random data- -- Registration is disabled -If you require an account, contact the system administrator.
+Registration is disabled. If you require an account, contact the system administrator.
- - + + diff --git a/lib/BibSpace/files/templates/navi.html.ep b/lib/BibSpace/files/templates/navi.html.ep index 717b7d2..fc39c82 100644 --- a/lib/BibSpace/files/templates/navi.html.ep +++ b/lib/BibSpace/files/templates/navi.html.ep @@ -54,14 +54,14 @@- + Show papers <%= num_pubs('paper')%> - + Show talks <%= num_pubs('talk')%> @@ -84,7 +84,7 @@ Show papers without month field - + % my @ttobjs = get_important_tag_types($self); % foreach my $ttobj (@ttobjs){ @@ -106,14 +106,14 @@Add - + Show all <%= num_authors()%> - + Show visible <%= num_visible_authors()%> @@ -123,14 +123,14 @@ Visible authors - % my @authors = sort {$a->master cmp $b->master} get_visible_authors(); + % my @authors = sort {$a->uid cmp $b->uid} get_visible_authors(); % foreach my $author (@authors){- - <%= $author->{master} %> + + <%= $author->{uid} %> <%= num_pubs( undef, undef, [$author->get_entries] ) %> - + @@ -156,19 +156,19 @@ % foreach my $team ( @all_teams ){- <%= $team->name %> + <%= $team->name %> <%= scalar $team->get_members %> - + %} - + @@ -181,14 +181,14 @@ - + @@ -68,7 +68,7 @@- + <%= $exception->team->name %> @@ -81,7 +81,7 @@ Detected teams will be ignored after adding any exception (at least should be...). But temporarily they are not. Teams = teams + exceptions. -+ % } diff --git a/lib/BibSpace/files/templates/publications/manage_tags.html.ep b/lib/BibSpace/files/templates/publications/manage_tags.html.ep index 85cce5a..080e79c 100644 --- a/lib/BibSpace/files/templates/publications/manage_tags.html.ep +++ b/lib/BibSpace/files/templates/publications/manage_tags.html.ep @@ -9,7 +9,7 @@ @@ -17,27 +17,27 @@
- %= include 'preview_row', preview => $entry->{html}, btype=> $entry->{bibtex_type}, bkey => $entry->bibtex_key; + %= include 'preview_row', preview => $entry->html, btype=> $entry->bibtex_type, bkey => $entry->bibtex_key; % foreach my $ttobj ( @$tag_types ){- % foreach my $tobj (get_tags_of_type_for_paper($entry->{id}, $ttobj->{id})){ + % foreach my $tobj (get_tags_of_type_for_paper($entry->id, $ttobj->id)){ @@ -71,9 +71,3 @@- - - - - - diff --git a/lib/BibSpace/files/templates/publications/show_authors.html.ep b/lib/BibSpace/files/templates/publications/show_authors.html.ep index 8a38c35..a7e9061 100644 --- a/lib/BibSpace/files/templates/publications/show_authors.html.ep +++ b/lib/BibSpace/files/templates/publications/show_authors.html.ep @@ -30,9 +30,9 @@ % my $i = 0; % foreach my $author (@$authors){ - - <%= $author->{master} %> - + + <%= $author->master->name %> + % $i++; % } @@ -52,15 +52,15 @@ % foreach my $team (@$teams){ - <%= $team->{name} %> - + <%= $team->{name} %> + - % } + % }
- + diff --git a/lib/BibSpace/files/templates/tags/authors_having_tag.html.ep b/lib/BibSpace/files/templates/tags/authors_having_tag.html.ep index 1106bff..2e3d8be 100644 --- a/lib/BibSpace/files/templates/tags/authors_having_tag.html.ep +++ b/lib/BibSpace/files/templates/tags/authors_having_tag.html.ep @@ -26,15 +26,15 @@ %foreach my $author (@$authors){- <%= $author->{master} %> + <%= $author->master->name %> - + <%=num_pubs_for_author_and_tag($author, $tag)%>%} - + diff --git a/lib/BibSpace/files/templates/tags/authors_having_tag_read.html.ep b/lib/BibSpace/files/templates/tags/authors_having_tag_read.html.ep index 82164e1..19a790b 100644 --- a/lib/BibSpace/files/templates/tags/authors_having_tag_read.html.ep +++ b/lib/BibSpace/files/templates/tags/authors_having_tag_read.html.ep @@ -1,8 +1,8 @@ % layout 'default';-<%= $tag->{name} %>: +<%= $tag->{name} %>: %foreach my $author (@$authors){ - <%= $author->{master} %> (<%=num_pubs_for_author_and_tag($author, $tag)%>), + <%= $author->master->name %> (<%=num_pubs_for_author_and_tag($author, $tag)%>), %}diff --git a/lib/BibSpace/files/templates/tagtypes/edit.html.ep b/lib/BibSpace/files/templates/tagtypes/edit.html.ep index 659aff3..7338d47 100644 --- a/lib/BibSpace/files/templates/tagtypes/edit.html.ep +++ b/lib/BibSpace/files/templates/tagtypes/edit.html.ep @@ -17,12 +17,12 @@ - +
- +@@ -31,7 +31,7 @@--
+
@@ -28,7 +28,7 @@ @@ -54,7 +54,7 @@Are you sure you want to delete tag type: <%= $tt->{name} %>?
- +- <%=$tt->{id}%> + + + <%= $tt->id %> + - <%= $tt->{name} %>
+ + + % my $tt_name = $tt->name; + % $tt_name =~ s/\s/_/g; + <%= $tt->name %> +<%= $tt->{comment} %>
diff --git a/lib/BibSpace/files/templates/teams/add_team.html.ep b/lib/BibSpace/files/templates/teams/add_team.html.ep index 963d01c..f69f1de 100644 --- a/lib/BibSpace/files/templates/teams/add_team.html.ep +++ b/lib/BibSpace/files/templates/teams/add_team.html.ep @@ -35,7 +35,7 @@ Team name-diff --git a/lib/BibSpace/files/templates/teams/teams.html.ep b/lib/BibSpace/files/templates/teams/teams.html.ep index 9de8044..d04b7e4 100644 --- a/lib/BibSpace/files/templates/teams/teams.html.ep +++ b/lib/BibSpace/files/templates/teams/teams.html.ep @@ -22,12 +22,19 @@ % foreach my $team (@{$teams}){- <%= $team->{id} %> ++ + <%= $team->{id} %> + + Show papers @@ -41,4 +48,4 @@ - \ No newline at end of file + diff --git a/lib/BibSpace/files/templates/types/add.html.ep b/lib/BibSpace/files/templates/types/add.html.ep index 0ac0205..5382cd6 100644 --- a/lib/BibSpace/files/templates/types/add.html.ep +++ b/lib/BibSpace/files/templates/types/add.html.ep @@ -5,7 +5,7 @@
diff --git a/lib/BibSpace/files/templates/types/manage_types.html.ep b/lib/BibSpace/files/templates/types/manage_types.html.ep index b507bc3..39b1420 100644 --- a/lib/BibSpace/files/templates/types/manage_types.html.ep +++ b/lib/BibSpace/files/templates/types/manage_types.html.ep @@ -19,21 +19,22 @@ -
+
<%= $type->our_type %> = % foreach my $a_type_str (@assigned_btypes){- - <%= $a_type_str %> + + + <%= $a_type_str %> @@ -50,13 +51,13 @@- % + % % foreach my $b_type (@$unassigned_btypes){- +@@ -78,7 +79,7 @@