Mar 22, 2015

MBE, Mongo Back End.


First MBE version out





MBE is a backend written in Python 3 that provides database access, authentication, access control and other features on top of the MongoDB document database.

It is basically a blatant attempt of having the cake and eating it, to explore the possibilities given when combining the absolute freedom of a document database with the fine-grained control of a JSON Schema.

It doesn't hurt, of course that the same JSON-schema can be used to validate data directly in the web client interface, for example using angular-schema-form.

Conceptual documentation can be found at http://www.optimalbpm.se/wiki/index.php/MBE .


API documentation can be found at http://www.optimalbpm.se/api/mbe/index.html .

The source as well as a very simple example is found at https://github.com/OptimalBPM/mbe .



Good times!

Nov 19, 2014

More WiX articles on Python problems and blogging location


First:

I felt it was time to clear up some more of the WiX-situation with regards to pip on windows.
As, for example, both pyodbc and lxml simply won't install without vcvarsall.bat, several packages aren't installable via pip on Windows.

The most elegant solution to this is not installing Visual Studio on all machines you want to run your application, but to build .msi-installers that are easily included in your installation.

So don't wait, but go and see the article on the Optimal BPM wiki: How to make .msi packages from Pythonlib .exe-files.

I can answer some questions in the comments here if needed.


Second:

This blog will move to optimalbpm.se soon.

Bye!

Nov 5, 2014

MongoDB,BPM, QAL 0.4.0, Optimal Sync 0.9.0 and improved WiX article

Releases

Recently, QAL and Optimal Sync(Optimal BPM Tools) was released in new versions(QAL, Optimal Sync). Many a new features are included and especially Optimal Sync is shaping up to become a pretty useful tool. Especially, the Windows installation of Optimal BPM Tools(Optimal Sync) is much improved.

MongoDB

I am currently investigating using MongoDB as a database backend for the system. There is currently a backend written that uses a EAV structure that works in all backends(DB2, Oracle, Postgres, MySQL, SQL server).

However, since Optimal BPM is geared towards simplicity, it is pointless to make the users learn installing and maintaining a complex relational database backend, when possibly, there are better options.

The document-oriented approach of MongoDB seems, at least so far, be a perfect fit for a BPM system. All possible possible issues, like data integrity, schema upgrade issues and similar concerns, are under investigation and hopefully resolved this week.

This means a couple of things for Optimal BPM:
  1. It will be even easier to install.
  2. It can have a far simpler data layer.
  3. The system only needs to support one database backend for installations.
  4. QAL doesn't need to support more DDL functionality, and can evolve further into the data mining and transformation direction in a more clean manner.
  5. The UBE project, and its upgrader functionality, can be discontinued.


A surprising way of using Optimal Sync, if I choose to develop that functionality, is to make it able to transform from an old MongoDB logical schema to a new, using a old JSON-schema and a new JSON-schema and map the differences. This way one can handle database structure upgrades without having to write scary upgrade scripts.


WiX

The bane of many a developer, WiX, has now been honored by an improved write-up at the wiki. The script/custom action section has been moved to its own article:  http://www.optimalbpm.se/wiki/index.php/Wix_and_scripting_languages .
The old article is now more as it is supposed to be, a pre-tutorial introduction.

May 31, 2014

QAL API documentation


The QAL API documentation is now online for your browsing pleasure!

Python3-Sphinx was used, a small article on that subject may develop over time as well.


Cheers!



May 29, 2014

Windows installer done at last!


Phew. That was actually pretty hard. The WiX and MSI documentation is both lacking and confusing.

Anyway, the installer is now available for download at the files section at source forge.

It is burn-based, and downloads dependency packages and installs them.

As I mentioned before, I made a WiX primer, I have now updated that with some information on how to install pip packages:
http://www.optimalbpm.se/wiki/index.php/WiX.


Cheers!

May 23, 2014

WiX, .msi and a setuptools(easy install) and pip bundle

Hi,

I am forging ahead with the making of the .msi-files for the windows installation of Optimal BPM tools (or rather Optimal Sync, to be fair).

During the process of making the installation bundle(I want to include everything) i have been forced to create som  .msi:s that I would think could be pretty useful outside this project, namely a setuptools and pip windows installation bundle. Please download and if you encounter any problem, just create a ticket at the Sourceforge project page.

If course, for a Python application, these programs are very important. So now there is a way to easily include easy install and pip in an Python 3.3 windows deployment for those who want that. The installation checks for a Python 3.3 installation and installs the files in its /Scripts-folder.

By the way, WiX is one of the least well documented tools i have ever encountered. At the same time it is pretty complicated. And strange. So it hasn't been easy. Far from it.

However, in the end, I have managed to create a pretty flexible setup using WiX preprocessor variables. Which actually works in a predictable manner as opposed to WiX Properties and normal WiXVariable constructs which might or might not be available at "bind" time.

My current recommendation is to use preprocessor variables instead of the other stuff as they don't resolve in an equally predictable manner.
I will elaborate on that further on my writeup later on.



Until then, have a nice time.


May 7, 2014

Windows, MSI and fixes

Hi everybody,


The seriously bug fixed Optimal Sync(as of now at 0.8.3)  is about to be installable on Windows as well soon. I have started building an .msi-package, which turned out to be a bit more problematic than expected. However, I think I have overcome most of the problems.

So much, actually, that I have felt compelled to poste a guide on how WiX works and its caveats. The guide is thought of as a primer before you get into the official tutorial, which is a bit wordy and difficult to get.

I consider the problems I encountered quite typical of what most that develop an .msi-package encounters and that my example file is more useful. Especially, I use the paraffin.exe-utility instead of the quite insufficient heat.exe . I would imagine that most does, maybe the article can save them some time.

Anyway, the guide is at the wiki, here, and I hope it will help you understand WiX and its somewhat maddening quirks a bit better.

Cheers!


Apr 17, 2014

First release of the Optimal Sync application/script - 0.8!

 

Tagline(s):

What? Sales department saving their contacts in an excel sheet? You want their edits maintained in the CRM database? Do you regularly want to download a data set from a table in a web page? And transform the data a little before you insert it?

It's out!

Optimal Sync is a small and simple multi-platform(well soon) BPM utility that is able to move and affect data between different many sources and destinations.
As it is dependent on Python 3.3 and just recently released open source software packages, it requires at least Debian "Jessie" or Ubuntu 13.04. It will however stay with stable releases after its initial release. 0.9 will mean a tested Windows version and 1.0 OS X.
That needs to be restated, this is a first release, so there are some quirks. However the ambitions are high and there is an aggressive release schedule ahead.
Please try it out and don't hesitate to report any issues as tickets here at the project page and you'll get a response.
(The GUI is "ugly"? Well, please share how to make it prettier!)
Download packages at Sourceforge:
https://sourceforge.net/projects/optimalbpm/files/Optimal%20BPM%20tools/
Install QAL before Optimal Sync:
http://www.optimalbpm.se/wiki/index.php/Optimal_Sync#From%20packages
More documentation at:
http://www.optimalbpm.se/wiki/index.php/Optimal_Sync

And phew.

The above is obviously a quote from the Sourceforge blog post.
So finally something actually installable and runnable has emerged from all this experimenting and fiddling around. Saying it is a cool application is perhaps not the right word, the GUI is very much leaning towards "functional" and leaning away from "aesthetic".

BUT, it is all open source, and it uses the latest libraries available. In fact, so new are they, that this could not have been released a month ago. There will now be a consolidation phase where only the application and QAL will evolve as the underlying libraries goes into stabler repositories. Cool stuff will be added indeed, when all the technical hurdles has been cleared.

Anyway, happiness abound!

Happy Easter!

Apr 9, 2014

Simple replicator


The first thing coming out of the Optimal BPM project will be the 0.8 version of a tool called Simple Replicator. The Business Process Management angle is that transfer and transformation of data is a fundamental part of BPM. Also, the simple replicator is just that, simple. It just scratches the surface of what is possible to do with QAL.

I'll begin with Debian, then Windows and Redhat(v 0.9), Mac OS X (1.0) packages, But if you just can't wait for .deb packages, you can try out the source already, it will not change much until release:
git clone git://git.code.sf.net/p/optimalbpm/code optimalbpm-code



However, in most situations you don't have to join rows from a webpage HTML tag tree with rows from a RDBMS with those of a .csv file. So that is what "simple" means.
The full potential of QAL and Optimal BPM will instead be managed in a web-based interface. If you want to se examples of what QAL can do, look at the the unit tests. Information about  manual installation is on the wiki, see below.

I have already started using the ticket system at Sourceforge to track some of the development, it works ok for that purpose, however, and of course, it is not near what bugzilla and other bugtrackers can provide, but will suffice for now. You can view and add tickets here. All questions are welcome.

There is also the beginning of a wiki brewing. So far there is only an article about QAL's database abstraction layer and the Optimal BPM tool Simple Replicator

Cheers!


Dec 25, 2013

New name, Optimal BPM.


Name change and GoDaddy anger       



Unified BPM has changed its name to Optimal BPM. 

Why? Because it is free, plenty better and more catchy: Optimal BPM - The beat of your business". :-) 

Also I got a not very good feeling concerning the future of Unified BPM, name-conflict-wise. However, QAL is still QAL and Unified Back End is still Unified Back End. (Because I still like that name and OBE was something else).

The Sourceforge project will change its unix name shortly.

A web site and wiki will surface instead of the placeholder at optimalbpm.org* soon.

GoDaddy is strange and does business like no other.

I tried to get the unifiedbpm.com and .org address and turned to the GoDaddy buy services. For $69 bucks they'll contact the owner for you and does your bidding. 

However, even though the seller was claimed to be interested in selling, the seller never got back after I made my first bid. Of course, they've could of considered it too low or something, but they didn't get back with a counter offer.
Not even saying that is way too low. And now stuff starts to get weird.

I asked to get copies of what they had sent to the potential seller, I didn't need to know who it was, just what had been said.
Then they told me that they to give out "internal correspondence" unless they get a subpoena, which he recommended me to get! Holy bejesus, a subpoena?

The craziest about the entire thing is that:

1. There is no proof *whatsoever*, they haven't even bothered to fake some, that says they have even done *anything*.
2. The owner of the domain according to whois, is GoDaddy themselves. This means that there could very well be no counterparty at all. GoDaddy might actually bid with themselves! Like stock brokers used to clear in-house but still charge fees. But almost worse!

It is quite extraordinary that *anyone* would use such a service. Had I known, I would never considered it.



* Yes, I nicked the .com and .se as well.
  .SE? Please, I am a swede after all...

Aug 15, 2013

Back on track/Lots of changes

I have decided to split the project into three different projects.

From the bottom up, it will look like this:

1. QAL wants to try its own wings and have moved out, to https://sourceforge.net/projects/qal/ .

The query abstraction layer is now a separate software package and I have made it available throug PyPI. At least python 3 is needed, install using
sudo pip-3.X install qal


2. Unified Back End, UBE, at https://sourceforge.net/projects/ube/ , has been created. This is simply a matter of the Unified BPM node tree and EAV-model moving out. This because it's access layers and its database are a very generic designs that could be used in many software projects. It is how I, after 15 years of business database and software design want to persist my data. QAL is a dependency. As with QAL, it will soon be available through PyPI. As with QAL, at least python 3 is needed, install using
sudo pip-3.X install unified_back_end


3. Unified BPM. What is left is the system itself, which currently isn't all that much as most of its functionality is in the back end layers and prototype code.

3.1 Unified BPM Tools is not a part of the Unified BPM system, but part of the project. Soon, a scriptable data moving utility will turn up there.



Nov 5, 2012

AOP, yeah you know me. And some postgresql/windows context issues.

AOP

Unified BPM vill make heavy use of Aspect Oriented Programming.
Why? Because if there ever was a system that would benefit from centralizing cross-cutting concerns, it is this one.
There is basically none of the typical uses for AOP that aren't present everywhere in Unified BPM: Security, Logging, Caching(memoization), Syncronization, Connection management, Proxification, Run-time debugging, tracing, statistics and basically whatever you could think of, they are all present here.

Also, the support for it in Python is positively excellent and simple to use. Especially using the "decorator" module.


Postgresql-client vs. Windows USERNAME

So, suddenly Hudson started reporting that the Win XP-postgresql tests failed.
I also realized that they only failed while being remotely run by the Hudson test runner.
I just could not get my head around it, after a while I managed to find out it was getpass that tried to load the pwd-module. Which of course doesn't exist in the Windows environment.
I had no idea why, though. It really had no use for that data. The only reason was that it used it to populate some defaults when it couldn't find the USERNAME environmental variable.
The thing was, that that variable was available when I ran it as the same user from a logged in shell. But it seemed it wasn't when being run by Hudson.

It took me a while to come to the conclusion that my only option was to manually set the USERNAME variable as a parameter in Hudson. I did, and it worked.

It seems that the USERNAME environment variable isn't set by Windows, but by the process creator. Or something to that effect.


Sep 2, 2012

Database editor and structure

Hi,

Some new stuff, have not had much time the last year. Most importantly though, the genesis of the UBPM database structure builds on all platforms(postgres, mySQL, SQL server, DB2 and Oracle).

Editor for XML SQL structures:

So first, I have created a web based editor for the XML SQL structures. Behold.


It resides in the Q_N_D-folder, which means that it is quick and dirty, something built to be able to move forward. However, it had to have some..

Features:
  • Ability to store(and load) the resulting data files centrally(preferrably within the source tree).
  • Functionality to build upgrade files for the upgrades.
  • It had to be easy to also make stand-alone statements.
Just run controller.py and open up http://127.0.0.1:8080 to watch it in action.
It uses cherryPy for the backend and Genshi for templating, a really nice and lightweight framework indeed.


The database


Using that, I have finally stumbled into what for me is far more familiar ground, database design.
I have created an upgrade script that creates the first parts of the Unified BPM database structure(stuff like a tree, rights, users, languages).


The database will store the persistent structural data in a central tree.
Its meta data will be stored in one of three different ways, depending on what suits the specific entity considering simplicity, flexibility and performance.

The data models:


  • Relational:
    This is the usual way people store data, with sub tables detailing the nodes in the tree.
  • EAV(Entity-Attribute-Value):
    Instead of having many subtables, everything is stored in one table. If one doesn't want to use variants, one uses one table per data type. In reality, however, that doesn't matter as much, as database engines nowadays store data in a far more intelligent manner, so it could actually be SLOWER to NOT use variants. How about that, strongly typing advocates?
  • XML:
    Actually similar to to EAV in many modern database implementations, where XML is its own data type which can be queried just like a table structure. However, UBPM will not use any these implementations however cool they are. UBPM will only store the XML as strings.
    The reason is that 1) all those implementations are proprietary and would be hell to generalize and 2) that it is not the point. XML data will be used to allow for freely structured storage...that is somewhat structured. If you know what I mean. An example would be a 3rd party kind of data. 

In conclusion


It now seems that most of the surprisingly large technical hurdles in dealing with multiple database platforms has been negotiated. Now it is just a matter of expanding the support for more of the SQL standard. But the next in line, like ALTER TABLE and UPDATE are quite easy and contains the same elements as the already implemented.
Also, my self-educational goals up till now has been met as well, I have learned quite a lot.
From here on, if feels like it should be a far more straight forward matter of comparatively simply building the system. I suspect the multi-platform deployment will create problems, however I will simply not try to generalize between windows and linux installations. It will basically be completely different solutions.

Nov 23, 2011

Success!

Hi everybody!

Now I have finally succeeded in making the following work:

  • XML to object structure

  • Object structure to XML (the tests goes both ways)


  • The following structures are currently supported:

    • SELECT

      • Operators/Identifiers/Aliases
      • Function calls
      • TOP/LIMIT
      • CASE..WHEN
      • JOIN
      • WHERE
      • ORDER BY



    • INSERT INTO (from SELECT)

    • CREATE TABLE

      • Constraints(PK/FK)
      • Indexes
      • Default values
      • Auto increment. On Oracle using triggers, thanks for that pointless inconvenience, Oracle :-(



    • Custom

      • The "custom" structure simply take an SQL statement for each backend.

        It is intended for those cases when very database-specific features are needed.


  • The db_upgrader library, that uses the DAL to upgrade databases, outside of performing the upgrades from an XML-definition, now tracks applications and versions. Cewl stuff.


Basically, those three statements are enough to build most things.
There is usually no long-term gain into making a database much more complex than so.
I'd say you solve 95 % of your database creation needs with that, and what it does not solve..well perhaps it should not be in the database layer.



These structures are all tested as integration tests that are run on both Windows XP and Debian(unstable) that, using the db_upgrader library creates an example database on the following platforms:

  • Postgresql(on Debian stable)

  • MySQL(on Debian stable)

  • MSSQL server Express(on Windows XP)

  • IBM DB2 Express-C (on Debian stable)

  • Oracle 11g XE (on Fedora 16)




I can say one thing, it sure wasn't easy.

I basically had these requirements:
  1. The Database Abstraction Layer(DAL) should be able to run on both Windows and Linux and seamlessly be able to do the same thing on PostgreSQL, MySQL, MSSQL, DB2 and Oracle.
  2. The installation of the clients must be simple(server:port, database, user, password) , and therefore any installation procedures need to be scriptable. A user should not need to edit a million config files, set environment variables or download lots of files to make it work.
  3. The connection to the database backends should not need lots of tweaking, it should "just work". I did not mind if some performance had to be sacrificed. According to my experience after 10 years of database development, it is usually not the driver that is the show stopping performance bottleneck, but indexing, lack of proper database engine internals and, of course bad database design.
I almost met all of them. The only one were I didn't make it all the way was point 2.
And actually, I think I can semi-automate or at least wildly simplify those processes if the worst client-side hassle offenders, IBM DB2 and Oracle 11g, is OK with it.

Configuring the back end servers was a real pain though, especially Oracle 11g.
Don't try install that on Debian/Ubuntu, folks. Go with Fedora for Oracle 11g and you'll live longer.
Luckily, I am done with that now. :-)

On to moving the whole thing stuff into public display on the Sourceforge GIT. Or perhaps somewhere else, Google code? Ideas?

Anyway, I will now set up some CI-testing solution around my servers and clients. That'd be great.

And then it is on to some more installation(.deb/.msi files) stuff and then the fun part. Adding features.

Sep 18, 2011

XML to structure and back again.

Hi again.

After a year long pause, I have started with this again.
And so I now have my first test of the XML-to-SQL objects-to-XML.
And it works to both parse and generate it back from the object structure and getting a file identical to the first.

The XML looks like this:

<?xml version="1.0" ?>
<sql:Statement xmlns:sql="http://www.unifiedbpm.se/XMLschema/DAL/SQL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://www.unifiedbpm.se/XMLschema/DAL/SQL ../SQL.xsd">
<sql:Verb_CREATE_TABLE>
<sql:Name>Table1</sql:Name>
<sql:Constraints>
<sql:Parameter_Constraint>
<sql:CheckConditions />
<sql:Constraint_Type>PRIMARY KEY</sql:Constraint_Type>
<sql:References>
<sql:str>Table1ID</sql:str>
</sql:References>
<sql:Name>PK_Table1_Table1ID</sql:Name>
</sql:Parameter_Constraint>
<sql:Parameter_Constraint>
<sql:CheckConditions />
<sql:Constraint_Type>FOREIGN KEY</sql:Constraint_Type>
<sql:References>
<sql:str>Table1ID</sql:str>
<sql:str>Table2</sql:str>
<sql:str>Table2ID</sql:str>
</sql:References>
<sql:Name>FK_Table1_Table1ID_Table2_Table2ID</sql:Name>
</sql:Parameter_Constraint>
<sql:Parameter_Constraint>
<sql:CheckConditions>
<sql:Parameter_Conditions>
<sql:Conditions>
<sql:Parameter_Condition>
<sql:Operator>></sql:Operator>
<sql:ANDOR>AND</sql:ANDOR>
<sql:Right>
<sql:Parameter_Numeric>
<sql:Numeric_Value>2.4</sql:Numeric_Value>
</sql:Parameter_Numeric>
</sql:Right>
<sql:Left>
<sql:Parameter_Numeric>
<sql:Numeric_Value>1.3</sql:Numeric_Value>
</sql:Parameter_Numeric>
</sql:Left>
</sql:Parameter_Condition>
<sql:Parameter_Condition>
<sql:Operator>LIKE</sql:Operator>
<sql:ANDOR>AND</sql:ANDOR>
<sql:Right>
<sql:Parameter_String>
<sql:String_Value>%</sql:String_Value>
</sql:Parameter_String>
</sql:Right>
<sql:Left>
<sql:Parameter_Identifier>
<sql:Identifier>T1.firstname</sql:Identifier>
</sql:Parameter_Identifier>
</sql:Left>
</sql:Parameter_Condition>
</sql:Conditions>
</sql:Parameter_Conditions>
</sql:CheckConditions>
<sql:Constraint_Type>CHECK</sql:Constraint_Type>
<sql:References>
<sql:str>Table1ID</sql:str>
</sql:References>
<sql:Name>CK_Table1_Name</sql:Name>
</sql:Parameter_Constraint>
<sql:Parameter_Constraint>
<sql:CheckConditions />
<sql:Constraint_Type>UNIQUE</sql:Constraint_Type>
<sql:References>
<sql:str>Table1ID</sql:str>
</sql:References>
<sql:Name>UQ_Table1_Name</sql:Name>
</sql:Parameter_Constraint>
</sql:Constraints>
<sql:Columns>
<sql:Parameter_ColumnDefinition>
<sql:Datatype>serial</sql:Datatype>
<sql:Default />
<sql:NOTNULL>True</sql:NOTNULL>
<sql:Name>Table1ID</sql:Name>
</sql:Parameter_ColumnDefinition>
<sql:Parameter_ColumnDefinition>
<sql:Datatype>string(400)</sql:Datatype>
<sql:Default />
<sql:NOTNULL>False</sql:NOTNULL>
<sql:Name>Table1Name</sql:Name>
</sql:Parameter_ColumnDefinition>
<sql:Parameter_ColumnDefinition>
<sql:Datatype>timestamp</sql:Datatype>
<sql:Default />
<sql:NOTNULL>False</sql:NOTNULL>
<sql:Name>Table1Changed</sql:Name>
</sql:Parameter_ColumnDefinition>
</sql:Columns>
<sql:postSQL />
</sql:Verb_CREATE_TABLE>
</sql:Statement>



As you see, it is basically an abstraction of the SQL language.
It should be pretty easy to write a GUI for generating the XML that would be similar to actually writing SQL.
With that as input, the following SQLs are generated when calling any of the SQL objects' AsSQL-method(note the oracle syntax):


SQL for the MySQL database:

CREATE TABLE Table1 (
`Table1ID` INTEGER AUTO_INCREMENT NOT NULL,
`Table1Name` VARCHAR(400),
`Table1Changed` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT `PK_Table1_Table1ID` PRIMARY KEY (Table1ID),
CONSTRAINT `FK_Table1_Table1ID_Table2_Table2ID` FOREIGN KEY (Table1ID) REFERENCES Table2(Table2ID),
CONSTRAINT `CK_Table1_Name` CHECK ((1.3 > 2.4) AND (T1.firstname LIKE '%ercedes')),
CONSTRAINT `UQ_Table1_Name` UNIQUE (Table1ID)
)


SQL for the PostgreSQL database:



CREATE TABLE Table1 (
"Table1ID" serial NOT NULL,
"Table1Name" VARCHAR(400),
"Table1Changed" DATETIME DEFAULT(NOW()),
CONSTRAINT "PK_Table1_Table1ID" PRIMARY KEY (Table1ID),
CONSTRAINT "FK_Table1_Table1ID_Table2_Table2ID" FOREIGN KEY (Table1ID) REFERENCES Table2(Table2ID),
CONSTRAINT "CK_Table1_Name" CHECK ((1.3 > 2.4) AND (T1.firstname ILIKE '%
ercedes')),
CONSTRAINT "UQ_Table1_Name" UNIQUE (Table1ID)
)


SQL for the Oracle database:



CREATE TABLE Table1 (
"Table1ID" integer NOT NULL,
"Table1Name" VARCHAR2(400),
"Table1Changed" DATETIME DEFAULT(NOW()),
CONSTRAINT "PK_Table1_Table1ID" PRIMARY KEY (Table1ID),
CONSTRAINT "FK_Table1_Table1ID_Table2_Table2ID" FOREIGN KEY (Table1ID) REFERENCES Table2(Table2ID),
CONSTRAINT "CK_Table1_Name" CHECK ((1.3 > 2.4) AND (T1.firstname LIKE '%
ercedes' escape 'C')),
CONSTRAINT "UQ_Table1_Name" UNIQUE (Table1ID)
)
CREATE SEQUENCE seq_Table1_Table1ID_DAL_auto_increment
start with 1
increment by 1
nomaxvalue;
CREATE TRIGGER tr_Table1_Table1ID_DAL_auto_increment
BEFORE INSERT ON Table1 FOR EACH ROW BEGIN
SELECT seq_Table1_Table1ID_DAL_auto_increment.nextval INTO :new.id FROM dual;
end;


SQL for the DB2 database:



CREATE TABLE Table1 (
"Table1ID" INT GENERATED ALWAYS AS IDENTITY NOT NULL,
"Table1Name" VARCHAR(400),
"Table1Changed" TIMESTAMP,
CONSTRAINT "PK_Table1_Table1ID" PRIMARY KEY (Table1ID),
CONSTRAINT "FK_Table1_Table1ID_Table2_Table2ID" FOREIGN KEY (Table1ID) REFERENCES Table2(Table2ID),
CONSTRAINT "CK_Table1_Name" CHECK ((1.3 > 2.4) AND (T1.firstname LIKE '%
ercedes')),
CONSTRAINT "UQ_Table1_Name" UNIQUE (Table1ID)
)


SQL for the SQLserver database:



CREATE TABLE Table1 (
[Table1ID] int IDENTITY(1,1) NOT NULL,
[Table1Name] varchar(400),
[Table1Changed] DATETIME DEFAULT(NOW()),
CONSTRAINT [PK_Table1_Table1ID] PRIMARY KEY (Table1ID),
CONSTRAINT [FK_Table1_Table1ID_Table2_Table2ID] FOREIGN KEY (Table1ID) REFERENCES Table2(Table2ID),
CONSTRAINT [CK_Table1_Name] CHECK ((1.3 > 2.4) AND (T1.firstname LIKE '%
ercedes')),
CONSTRAINT [UQ_Table1_Name] UNIQUE (Table1ID)
)


Small disclaimer: I haven't run these scripts on all database architectures, am currently rebuilding the testing environment.

Oct 26, 2010

XML, back and forth and here again.

Hi,
Lately i've busy creating, validating and parsing XML.

There are now two schemas used when defining upgrade files:
http://www.unifiedbpm.se/XMLschema/DAL/SQL.xsd
http://www.unifiedbpm.se/XMLschema/DBUpgrader/DBUpgrader.xsd

The first defines the, so far supported, SQL, and the second defines the DBUpgraders upgrade file.

As always, I had less time and it took more effort than I thought, but now I am closing in on having a working upgrader.

It is pretty cool to watch integration tests run that creates the same structure on five different database platforms, inserts data and selects back and actually works.
A bit left to do, but after that, this might actually be a useful functionality.

That's all folks, bye!

Sep 29, 2010

Road map.

Hi,

SO FAR

I've gotten to a point where I have proven and implemented the two most important technical concepts needed for the development of Unified BPM :
1. Database abstraction layer
2. Database upgrade management including an (almost finished) XML schema for upgrade files. The XML schema is to allow for easy upgrade client development, one should not have to dabble with XML file editing. Interesting point is that the code generates the schema mostly by itself, based on its functionality, allowing for simpler maintenance.

This functionality extends to the MySQL, PostgreSQL, DB2, Oracle and SQL server platforms, except for upgrade management, where Oracle is partially unsupported due to its aforementioned lack of auto increment shortcuts. Maybe someone knows a way around that problem?

ROAD MAP


At this stage, then, I am in the really exciting position of being able to present a short road map. It is a seriously pragmatic one, one that is geared at getting something basic working as soon as possible:

1. Basic database abstraction/upgrade management. Creating tables, selecting and inserting data. I won't do anything more advanced with this unless other parts of UBPM needs more functionality. In my experience and according to my expectation, needing advanced SQL statements in the beginning of a project is mostly due to poor database design. Also, I am consciously keeping the database as simple as possible at this stage. I am nearly done with this stage. I have some structural stuff left on the database upgrader, but then I will move on.

2. The next step will be the messaging system of UBPM. I will begin with deciding the basic structure of communication within UBPM. I have already figured most of it out, but now I need to scale that down to its bare necessities in order to start somewhere.
Note that no logging of communications will be implemented in this stage.
The test for this will be to send a file from a listener on one host to another. One listener will run on a Linux host, and the other on a Windows host.

3. Not only files are to be sent, so next up will be to SELECT a dataset on one database server of one type, and INSERT the same data on an other of a different type and compare. This will put the DAL through its paces and probably expose any problems there.

4. By now, the DAL has probably been tested enough to enable me to start working on the Unified BPM database structure. Its primary purpose will be to log whatever happens on the system and that will be what I'll be implementing first. I will test this, and the database upgrade process by installing and upgrading the database and running the tests of points 2 and 3.
At this stage, I will be very happy, since I would now know that all the important concepts of UBPM works. As I see it, the largest technical hurdles are now negotiated and I will have a working integration test environment.


5. GUI. I start to develop a simple web based GUI that enables the generation of the XML database upgrade files. Because, from now on, there will be significantly more database development.
In general, it will be more straightforward development, and perhaps the perfect moment to invite others to join the project. It will certainly still be small enough to be easily influenced by new ideas and feedback.

Sep 14, 2010

Connection(s) established. Initiating execution.

Hi y'all.

So now the next phase is finished.
I now implemented and tested connections to all supported database platforms.
I only used multi-platform python-components.
These are:
  • PostgreSQL(psycopg2, native)
  • MySQL(MySQLdb, native)
  • SQL Server(pyodbc using FreeTDS)
  • DB2(pyodbc, needs libdb2.so)
  • Oracle(cx_Oracle, native, needs oracle instant client)
Getting all the databases running on my network was a real chore, to be honest.
Especially DB2 and Oracle were quite cumbersome to connect to, and needed lots of proprietary stuff installed on the client. Also, they don't really support debian/ubuntu.
However, now that I know how everything works I will try to automate client installations, or at least document them well, so Unified BPM users won't have to go through all the hassle I had to.

Anyway, next now is to define a small XML schema for generalizing of database upgrade management.
My thought is that the same XML should be able to manage database upgrades for multiple platforms, through the functionality of the database abstraction layer.
I don't want some Unified BPM components to end up having half-a$$ed support for specific databases, like it is for the Drupal project, for example.
Also, this makes it possible to make really kewl database tests.

Aug 17, 2010

Done with first phase of SQL generation

So there.

Now I have, in python, created a class which does only the things I need to at begin with the first database part of Unified BPM, creating and querying simple database structures.
The class can currently create these kinds of SQL statements(and then some):
  • SELECT - with where, expressions, conditions, CASE, function calls, joins, subselects.
  • CREATE TABLE - with defaults, primary keys, foreign keys and autoincrement
  • CREATE INDEX - Unique, Clustered, Non-Clustered
Supported databases for this functionality is:
  • Full
    • MySQL
    • PostgreSQL
    • DB2
    • SQL Server
  • Partial DDL
    • Oracle(due to identifier limitations and auto-increment hassle)
Now I will use this generator to make test for the DAL:s connection handling.
I now have working installations of all five databaseservers and will use them to set up integration tests for all flavours.

In practice, Partial DDL means that Unified BPM won't run on that platform but will be able to communicate with it. I simply won't commit to restricting myself to 30 bytes long identifiers. Somebody please think of the FK-names!

Aug 15, 2010

Adding DB2 support

Well, I though that while I'm at it, I might as well add DB2 support as well.
So now I will, it seems to have a pretty much straightforward SQL implementation.

By the way, It is kind of interesting to see what free(as in beer) offerings the different database vendors have, it is a bit revealing with regards to their attitude towards developers.