Version 2

    One often requested idea is to have the content of rules/artifacts stored in some external system (external to Guvnors JCR store).

     

    The most common would be: RDBMS, followed by a SCM (such as subversion).

     

    This could be achieved by pumping up the pluggable "content handlers" a bit, so that when an artifact is loaded/stored, it would give a chance to be stored in some normalise RDBMS etc... (so in a sense - JCR is a metadata, version and index storage engine).

     

    For example, a mocked up SQL schema could be something like:

     

    CREATE TABLE "dbo"."Categories" ( 
         "Id"                 int IDENTITY(1,1) NOT NULL,
         "Name"               varchar(100) NOT NULL,
         "CreateDate"         datetime NULL,
         CONSTRAINT "PK_Categories" PRIMARY KEY("Id")
         WITH FILLFACTOR = 90
         )
    GO
    
    CREATE TABLE CREATE TABLE "dbo"."RuleCategories" ... you get the idea
    
    
    CREATE TABLE "dbo"."Conditions" ( 
         "Id"                 int IDENTITY(1,1) NOT NULL,
         "Name"               varchar(50) NULL,
         "Text"               varchar(500) NOT NULL,
         CONSTRAINT "PK_Conditions" PRIMARY KEY("Id")
         WITH FILLFACTOR = 90
         )
    GO
    
    
    CREATE TABLE "dbo"."Consequences" ( 
         "Id"                 int IDENTITY(1,1) NOT NULL,
         "Name"               varchar(50) NULL,
         "Text"               varchar(500) NOT NULL,
         CONSTRAINT "PK_Consequences" PRIMARY KEY("Id")
         )
    GO
    CREATE TABLE "dbo"."RuleConditions" ( 
         "RuleId"           int NOT NULL,
         "ConditionId"      int NOT NULL,
         "DisplayOrder"     int NULL 
         )
    GO
    CREATE TABLE "dbo"."RuleConsequences" ( 
         "RuleId"            int NOT NULL,
         "ConsequenceId"     int NOT NULL 
         )
    GO
    
    CREATE TABLE "dbo"."RuleParams" ( 
         "RuleId"      int NOT NULL,
         "ParamId"     int NOT NULL 
         )
    GO
    
    CREATE TABLE "dbo"."Params" ... you get the idea 
    
    
    CREATE TABLE "dbo"."Rules" ( 
         "Id"                     int IDENTITY(1,1) NOT NULL,
         "Name"                   varchar(100) NOT NULL,
         "Description"            varchar(500) NULL,
         "Status"                 int NULL,
         "Version"                int NULL,
         "Notes"                  varchar(500) NULL,
         "Requestor"              varchar(50) NULL,
         "CreateDate"             datetime NULL,
         "CreatedBy"              varchar(50) NULL,
         "LastModified"           datetime NULL,
         "LastModifiedBy"         varchar(50) NULL,
         CONSTRAINT "PK_Rules" PRIMARY KEY("Id")
         WITH FILLFACTOR = 90
         )
    GO
    
    CREATE TABLE "dbo"."Status" ( 
         "Id"                 int IDENTITY(1,1) NOT NULL,
         "Name"               varchar(15) NOT NULL,
         CONSTRAINT "PK_Status" PRIMARY KEY("Id")
         WITH FILLFACTOR = 90
         )
    GO
    
    
    

     

    Note that this would need to map out the rule content as much as possible, and the categories, status and a few other bits of meta data. The rule content could be edited in this database, and then the next time it is loaded it will get it from the database (so its not a one way thing) - this would only extent (normally) to content - other attributes may be able to be edited but will not necessarily show up in the GUI immediately.

     

    Draft API:

     

    interface RuleStorage {
    
        void onCreate(RuleModel m, AssetItem metaData);
        void onUpdate(RuleModel m AssetItem metaData);
        RuleAsset onRetrieve(AssetItem metaData);
        void onDelete(RuleAsset asset, AssetItem metaData);
    
    }
    
    interface PackageStorage {
    
        void onCreate(String packageName);
        void onDelete(String packageName);
    
    }
    
    
    

     

     

    So you can get the rule data in a few ways - one is just as a stream - good for odds and ends that you want to store just as a blob (if you care) - but when its the guided editor, you will get a richer model you can store normalised as needed. Most likely it will be the asset.getFormat() value that switches in different logic on how you want to store it.