<commit_before>== Liferay & ActiveRecord

This is a collection of Liferay v5 models for ActiveRecord.

Current stable version only supports PostgreSQL, due to differences in the Liferay schema between databases. The development version in master contains partial MySQL solution, with model alterations that have broken PostgreSQL as well, so the absolute HEAD is not ready. __Use the branch 1.0 (still hosted on Rubyforge git) until author imports the branch to Github.__


== Follow these steps

1. Configure ActiveRecord as usual. See example configurations[http://github.com/lamikae/lportal/tree/master/config/].
2. <tt>require 'lportal'</tt>
3. You're good to go.

This gem quite effectively pollutes your namespace, and that is intentional. If you are working in the context of the portal, having your users modeled by User is more convenient rather than having to reference them as "Lportal::Users".


== General notions and examples
=== Caterpillar
To create new instances you need Caterpillar. Liferay's ORM, Hibernate, does not seem to use database sequences, but ActiveRecord assumes they exist. Caterpillar's purpose is to lower the barriers to deploy Rails portlets and it contains various tasks that do not belong to this library. See the Caterpillar docs on installation; this document assumes your environment is set up. Do not forget to run the migrations!


=== Layouts
Each Group can have public and private pages. In both cases, there has to first exist a Web::LayoutSet, which is automatically created for a new Group. The individual pages (class Web::Layout) belong to this set, but they are not directly linked (in 5.1.1 at least). Instead, they belong to the Group and are either public or private. The models have methods to query the relations.

Say you create a new Group "group".

  company = Company.first
  group = Group.create(
    :company => company,
    :creatoruserid => company.administrators.first.id,
    :name => 'Example'
  )

  => #<Group groupid: 8400004, companyid: 10109, creatoruserid: 10129, classnameid: 0, classpk: 0, parentgroupid: 0, livegroupid: 0, name: "Example", description: "", type_: 1, typesettings: "", friendlyurl: "/example", active_: true>

The LayoutSets can then be queried:

  group.public_layoutset

  => #<Web::LayoutSet layoutsetid: 8400011, groupid: 8400004, companyid: 10109, privatelayout: false, logo: false, logoid: 0, themeid: "", colorschemeid: "01", wapthemeid: "mobile", wapcolorschemeid: "01", css: "", pagecount: 0, virtualhost: "">

  group.private_layoutset

  => #<Web::LayoutSet layoutsetid: 8400010, groupid: 8400004, companyid: 10109, privatelayout: true, logo: false, logoid: 0, themeid: "", colorschemeid: "01", wapthemeid: "mobile", wapcolorschemeid: "01", css: "", pagecount: 0, virtualhost: ""><commit_msg>separate instructions for PostgreSQL / other dbs<commit_after>== Liferay & ActiveRecord
This is a collection of Liferay v5 models for ActiveRecord.

Current stable version only supports PostgreSQL, due to differences in the Liferay schema between databases. The development version in master contains partial MySQL solution, with model alterations that have broken PostgreSQL as well, so the absolute HEAD is not ready. __Use the branch 1.0 (still hosted on Rubyforge git) until author imports the branch to Github.__


== Follow these steps for PostgreSQL

# Setup Liferay database.
# <tt>gem install lportal</tt> # version 1.0.18
# Configure ActiveRecord to use the Liferay database. See example configurations[http://github.com/lamikae/lportal/tree/master/config/].
# <tt>require 'lportal'</tt>
# You're good to go.

This gem quite effectively pollutes your namespace, which is intentional. If you are working in the context of the portal, having your users modeled by User is more convenient rather than having to reference them as "Lportal::Users".

== Other databases
Github contains impartial import, which does not include branches that are stored at Rubyforge.

  git clone git://rubyforge.org/lportal.git

  $ cd lportal
  $ git branch -a

You need some knowledge of Ruby and databases in general for making it work. You may also contact the author.


== General notions and examples
=== Caterpillar
To create new instances you need Caterpillar. Liferay's ORM, Hibernate, does not seem to use database sequences, but ActiveRecord assumes they exist. Caterpillar's purpose is to lower the barriers to deploy Rails portlets and it contains various tasks that do not belong to this library. See the Caterpillar docs on installation; this document assumes your environment is set up. Do not forget to run the migrations!


=== Layouts
Each Group can have public and private pages. In both cases, there has to first exist a Web::LayoutSet, which is automatically created for a new Group. The individual pages (class Web::Layout) belong to this set, but they are not directly linked (in 5.1.1 at least). Instead, they belong to the Group and are either public or private. The models have methods to query the relations.

Say you create a new Group "group".

  company = Company.first
  group = Group.create(
    :company => company,
    :creatoruserid => company.administrators.first.id,
    :name => 'Example'
  )

  => #<Group groupid: 8400004, companyid: 10109, creatoruserid: 10129, classnameid: 0, classpk: 0, parentgroupid: 0, livegroupid: 0, name: "Example", description: "", type_: 1, typesettings: "", friendlyurl: "/example", active_: true>

The LayoutSets can then be queried:

  group.public_layoutset

  => #<Web::LayoutSet layoutsetid: 8400011, groupid: 8400004, companyid: 10109, privatelayout: false, logo: false, logoid: 0, themeid: "", colorschemeid: "01", wapthemeid: "mobile", wapcolorschemeid: "01", css: "", pagecount: 0, virtualhost: "">

  group.private_layoutset

  => #<Web::LayoutSet layoutsetid: 8400010, groupid: 8400004, companyid: 10109, privatelayout: true, logo: false, logoid: 0, themeid: "", colorschemeid: "01", wapthemeid: "mobile", wapcolorschemeid: "01", css: "", pagecount: 0, virtualhost: "">
{'fraction_non_alphanumeric': 0.08570954907161804, 'fraction_numerical': 0.027022546419098143, 'mean_word_length': 4.851600387972842, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1485146', 'n_tokens_mistral': 1821, 'n_tokens_neox': 1649, 'n_words': 780}