Page 1 of 2

Aladdin Magic Plugin

PostPosted: Sat Feb 20, 2016 8:25 am
by red1
After some years doing the same things over and over for each new plugin in iDempiere (which is already amazing) but the refactoring spirit can be used to shorten the whole process even more amazingly. Introducing a Module Creator that is a sample plugin with stubs and a new menu and window template ready for reuse. But that is not all. It has fantastic goodies inside.

PluginModuleTemplate.png (37.33 KiB) Viewed 36490 times
This is a ready to use template. The menu can be renamed to intended menu. But here is where the manual drudgery ends.

WindowStub.png (65.22 KiB) Viewed 36490 times
All the developer needs to do is key in a new name and a Callout does the rest. A new copy of the window will be created under the new name! The template window remains as it is and is not accessible on Client side. The created window is not accessible on System side. The compulsory 7 Columns and Elements are created and synched with the Database!

All the developer or user need to do is to continue adding columns and fields, and then synch to database. Help guidelines are also given in the Comments tips.

ModelGenerator.png (83.3 KiB) Viewed 36465 times
The greatest magic will happen here. The developer can generate the X and I classes model without lifting another window. Just check the options including Model Factory to be placed in the new plugin in the source. (Thus this plugin is preferably run from source IDE for continous working.) And imagine you can then pack out the whole new menu without lifting another mouse and the resultant 2Pack will be nicely placed in the plugin's META-INF!

All the developer has to do in the end is just click on Save and the event validator goes to work.

A new process stub can also be defined here and the plugin.xml and new java implementing SvrProcess will be created! The same goes for creating a sub-table!

This concept took one whole day since yesterday here in chilling North Vietnam with Hiep LQ brainstorming how to make the best ERP in the world also the fastest to code in. I couldn't put the thought down after making some sketches in the app last night, i continued up in bed since 3am and its now 7am when i finally completed the concept design and ready to code them in the following rest of the month here before returning to Malaysia with my son.

Re: Aladdin Magic Plugin

PostPosted: Sat Feb 20, 2016 9:48 am
by red1
The concept model above is all packed out in a 2Pack and uploaded here ... uleCreator. Like to add that this idea is not new. I have always suspected that Jorg Janke, the original creator of Compiere did not grasp the power of his own creation. It is not an ERP per se but a powerful app creator as i wrote many years ago
It is also something which others particularly Nicolas Micoud has put forth an effort on

Re: Aladdin Magic Plugin

PostPosted: Sat Feb 20, 2016 3:25 pm
by nmicoud
Nice feature, congrats red1, hiep and naseem !

BTW, my name Micoud (with a 'i' between M and c) ;)



Re: Module Creator!

PostPosted: Sat Feb 20, 2016 3:45 pm
by red1
Bonjour Nicolas,
Merci et pardon et oui, I have corrected the name. And i just incorporated a large portion of my method calls from your AddTable during my events and resting a while before pushing the button. Hope it does not explode :D
(I learned alot from your code and would have taken a lot of time if I haven't been told by Hiep here to look at it)

Re: Module Creator!

PostPosted: Sat Feb 20, 2016 11:48 pm
by red1
Submitted version 0.1. Credits and thanks also to Nicolas Micoud's contribution. Only New Window is functioning. Change its name to your new table name, save it, and it will automatically create a menu with window with tab of that name and all its compulsory fields and columns and elements created. Also synchronized with database.
Official TableName will be hardset to 'MY_<tablename>'.
You can then proceed to add columns and synch right away, use the Tab Editor to layout nicely and drag the new item into the New Menu. Then login as Client and input data into your new window and of course you can print out on the fly too. Source is at Binary with 2Pack included at ... leCreator/<timestamp>.jar

Future version will make creating new columns also painless (no need to create corresponding elements). And yes, I will work at the Model Designer soon.

Re: Aladdin Magic Plugin

PostPosted: Sun Feb 21, 2016 7:31 am
by red1
Now i have made any new Column creation a smoother ride down to minimal 2 steps. The element field is automatically created! The datatype Reference is defaulted to String with FieldLength of 22! You can change to another and then SynchroniseColumn to Database. Not only that. If you are creating a column that has an existing Element such as PriceList, it will automatically pull the Element ID and set it! (That also obtain its datatype Reference and FieldLength as a previous feature.) If FieldLength is ever zero it will just default it to 22 to avoid saving error.

What is more fantastic is that now after saving your new column, you can go to the Window, Tab > Tab Editor and see your new field inserted there!

(However the other details in the Element are not set for Centralised Maintenance magic. I will solve later by pushing back the first-time creation from the Column side!)

Try the plugin from the sourceforge link or the source from bitbucket link.

I made a movie here:

Re: Aladdin Magic Plugin

PostPosted: Mon Feb 22, 2016 4:00 pm
by red1
Now starting a new model is even more automated! With a new ColumnSet field, you can enter new String type columns without going to the Table and Column window to do that. A sample is prepared for you to just add in one more column name and press Save. Note the Comment/Help and HowTo tips.

ColumnSet.png (108.77 KiB) Viewed 36359 times
Then go to the GardenWorld client and start entering data and print preview it! So this is a fantastic and amazing kick start in building any model into the ERP. From there you can then put in more fields particularly those that are non-string type. You can also leave the ColumnSet blank and build each column as shown in previous movie. I updated a new movie for this here:

Re: Aladdin Magic Plugin

PostPosted: Tue Feb 23, 2016 7:39 am
by red1
Now the X and I model interface is automatically generated. Easier than I thought. Thanks to good source code from others for me to reuse. Note that this can be done from a binary instance and need not be in Eclipse.

GenerateModel.png (246.09 KiB) Viewed 36342 times
To make this happen, go to the Model Design window (under SystemAdmin) and pull down your newly created Table from the list (only U/serDefined tables will be listed) and check the HasChanged box. Then press Save. Define your plugin source location. The generated code will be placed there. If it is not correct the system will prompt you while saving. If saved without error, go to your source location and the classes will be there.

TableModelGenerateSet.png (45.48 KiB) Viewed 36342 times

I just uploaded the new binary plugin with the data changes in embedded 2Pack and also to bitbucket the source. I am breaking off for travel to Hanoi by rail and meetup with a fan there for a tour. So if there is any issue/error I appreciate you send me an email or post here or in googlegroup thread where i announced this.

Tomorrow early morning I be flying back to Malaysia. From there, after some rest, I will continue (or maybe i scratch the itch on board the flight) to finish off auto generating of ModelFactory.. and then an auto window-sub-tab-table creation (definitely when i touched down).

Re: Aladdin Magic Plugin

PostPosted: Fri Feb 26, 2016 2:21 pm
by red1
After 2 days of coding, finally made a total production of plugin artifacts (select the boxes for GenerateModel and GenerateModelFactory in the Model Design window and press Save):

GeneratedFiles.png (90.03 KiB) Viewed 36188 times
Only the last bit of updating the MANIFEST.MF has to be manually done by pasting advice from MANIFEST.txt (append to the existing Service-Component:)

GeneratedSource.png (58.47 KiB) Viewed 36130 times
I tried doing two models, and they worked, their generated code jive well. As I enter data, their PO modelfactory is stated:

ModelsWorking.png (22.07 KiB) Viewed 36185 times
Further adding of columns will also now be possible by saving again new columns (of same table). So is the use of pre existing element such as PriceList, tried below and it is accepted.

ExistingElementPriceList.png (34.1 KiB) Viewed 36186 times
I am freezing at this juncture on datatype setting (though the stubs are created in code) is not really that important since one can reuse so many pre-existing elements such as Description, Help, Qty, Date. Later i will look at the making of sub tab table creation.

Re: Aladdin Magic Plugin

PostPosted: Sat Feb 27, 2016 7:21 pm
by red1
Now, a Master-Detail can be generated with a sub-tab! And it can be recalled back at the New Window enter the same table name, and specify in the columnlist whatever columns you want to add to it. I created the following Master-Detail window in just 1 minute!

MasterDetail.png (94.53 KiB) Viewed 36112 times
From there you can build any myriad just by specifying in Model Designer the main TableName and the Master-Detail (sub-table) name. It will be generated with the parent FK and tab level one level below it, with the parent link made so that it manages all children data nicely.

DesignPage.png (101.66 KiB) Viewed 36112 times
From here, i will revisit the DataType parsing described earlier. For now, users can collect both source and SF binary to test. Note in the above screen that we can now use lookup IDs such as C_BPartner_ID, C_Location_ID and M_Product_ID and it will be a search or TableDirect access lookup. Be very exact when spelling them in the ColumnSet of NewWindow. Also do not use the same names without IDs such as C_Location will cause a clash. Note also the use of 'Value' as column name will map to the commonly known Search Key field.

Re: Aladdin Magic Plugin

PostPosted: Sun Feb 28, 2016 4:48 am
by red1
Now you can set different datatypes on the fly! It still works as String if you leave it as it is. The types to use are the single letter code before the hash # and it has default length setting hard-coded.
Code: Select all
* Q# = Qty - 11
* Y# = Yes/No - 1
* A# = Amount - 11
* D# = DateTime - 11
* T# = Text - 2000

I set them to test in the same Statistics model. (Note that adding more columns work well as long as you make sure you spell your model table name exactly.)

DataTypeSetting.png (14.96 KiB) Viewed 36065 times
Then after some dragging around in the Tab Editor, I relogin into the GardenWorld to call up the Statistics window again and it can be used exactly as defined.

DataTypeResult.png (41.95 KiB) Viewed 36065 times

Re: Module Creator!

PostPosted: Mon Feb 29, 2016 12:48 am
by red1
Now you can enter column that reference List on the fly! Using the L#Week etc you get the Weekdays list. You can then go to Window,Tab&Field to change the displayed label if you want. The L# is parsed in a Like 'columnname%' script so you need not spell the whole length of the Reference Value. Remember this is for List validation only at the moment. Below is the setting and after that is the result.

NewWindowWeekdays.png (37.26 KiB) Viewed 36027 times
Note that you can use direct ID lookup, normal unhashed String type and the other types.

DataEntryWeekdays.png (25.65 KiB) Viewed 36027 times
Works like a charm! Everything committed and uploaded for you to try it out now!
(Note: Logs showed some DB synch errors. The Text Description is not added to Window,Tab which has to be manually done. This means there is a conflict of reference as Description is a pre-existing element. So advice will be to avoid same elements or just use it as pre-defined without the T#. Also the code for some reason not able to synch D#End. Using D#Ending seems OK.
To correct mistakes - removing the D#End:
1. Go to Window,Tab&Field, delete the field
2. Go to Table and Column, delete the column
3. Do Cache Reset at the ClientAdmin.
Then return to the NewWindow and at the same table, columnset only D#Ending and save.)

Made a movie to wrap this edition since the last movie -

Re: Aladdin Magic Plugin

PostPosted: Tue Mar 01, 2016 8:31 am
by red1
Now I am going to show you how to do something really cool as in real life as in making an Accessories tab to the present Sales Order on the fly. You get to peek more under the powerful AD engine at the same time. First we go to the Validation Rule window and change in the ValidationCode space, the 'U' to 'D'.

ValidationRule.png (52.28 KiB) Viewed 35413 times
Then go straight to the ModelCreator window as the C_Order (Table for the Sales Order Window) can now be accessed.

C_OrderSubTabCreation.png (98.99 KiB) Viewed 35946 times
Then just uncheck the other script creation and just have MasterDetail value = 'Accessories'. After save, go to the NewWindow and give your Accessories some columns:

AccessoriesColumnsCreation.png (72.58 KiB) Viewed 35946 times
After save, you are all done! Just change role to your client Sales Order and see the magic!

AccessoriesTab.png (76.16 KiB) Viewed 35946 times
Another additional feature I made along the way is that now, you can also join any previously created table to any table in Master-Detail relationship!

Re: Aladdin Magic Plugin

PostPosted: Thu Mar 03, 2016 12:11 am
by red1
Now we have auto-translator done online via Yandex API. Login in your locale language, go to the Model Designer, set the PackOut as checked and then press Save. (PackOut is used as a temporary proof of concept here). Then the API will go to work, fetching and updating each name in the _Trl tables to the version you set up for. Not only this, your base language can be non-English! It can be French and then you setup a Spanish locale, as Yandex will detect the base to be French and find the Spanish version of it. Of course this is off the shelf literal translator, but at least you can now impress your audience within seconds rather than days during a demo. Use it and tell me how more to make it better and a killer. Enjoy!

Translated.png (42.58 KiB) Viewed 35859 times
You can try out this free online service at Languages covered are:

Code: Select all
When used together with the Sales Order window, creating a new sub-tab Accessories, i made it to not overwrite previously translated names. I made it smart by comparing origin and target TRL values. If they are the same, then it knows it has not been translated and proceeded to translate them. So this is amazing - quick and smart.

TranslateOnlyNewTab.png (87.26 KiB) Viewed 35823 times
Here is a movie showing how it works within a few clicks.

Re: Aladdin Magic Plugin

PostPosted: Fri Mar 04, 2016 4:00 pm
by red1
Now i made it able to translate without need of the usual language pack import. This is particularly useful for those who wants to save the hassle of looking for the language pack or is using the Aladdin Magic ERP plugin for new windows on the fly. Just go to your Language window, choose desired language, and check two boxes: Login Locale and System Language:

LanguageMaintenance.png (38.15 KiB) Viewed 35757 times
Then press the Language Maintenance button so that it creates all the Trl_ records. Then login with the example of Thai as Language:

ThaiLogin.png (25.91 KiB) Viewed 35757 times
Then go to the Model Designer with the checked PackOut and save it. The window fields are now translated.

TranslatedThai.png (29.89 KiB) Viewed 35757 times

Re: Module Creator!

PostPosted: Sun Mar 06, 2016 3:42 am
by johnbendi
When does the process with the Module Creator kick off? After the database table must have been created?

And also why is the table prefix a constant MY? Can it not be made configurable?

Sorry! A lot of questions I know. Pardon me.

Re: Aladdin Magic Plugin

PostPosted: Mon Mar 07, 2016 8:22 am
by red1
Hi JohnBendi, No problem, questions is what makes the forums go round. I answered in the GoogleGroup forum some of the answers but i will answer again for the benefit of readers here:
1. I am looking at other priorities besides the Process which is more developer oriented rather than newbie oriented. My primary objective when designing this 'Aladdin Plugin' is to address absolute simpleton ERP first timers who just want to see some fast stuff - a window, translation, applying to their business. That is why I am currently now these few days looking closely as some business rules apps such as OpenL Tablets. I also need to form a strategic picture of the idea, similar to how i did it for the rest. So you can help by adding your imagination to it. How would you really want the Process generation to accomplish? We can certainly discuss and when it hits my itch, it be out sooner than you think! :)

2. The MY_ prefix is to really avoid messing up as i said when used by first timer newbies. After a person is an expert s/he can easily work with the code and modify them. My main concern is to start of very clean, lean and mean but ending up heavy and complicated which is breaking the principle of been user friendly. But again, later, when i have made the other priority of business rules (the OpenL is a killer been excel based appeals to a real big crowd of accountants and SMEs out there) i can then look at wrapping into a nice toolset. Again i need imaginary feedback from users as most of my killer work is a result from others discussing about issues and clumsiness when using complex app as in ERP.

Meanwhile thank you so much for your good questions.

Re: Aladdin Magic Plugin

PostPosted: Mon Mar 07, 2016 6:08 pm
by red1
I put in some tough code (took some hours to get it tested coming out right) and now you can use your own prefix as shown in the main and sub tab setting below. The resulting effect will be used only in AD_Table setting for TableName but the other values will be smartly parsed - prefix removed and leading caps spaced out for Window and TabName. You can also leave out any prefix and the code won't use any. I.e. WonderfulStatistics alone will be set as TableName.

PrefixControl.png (29.33 KiB) Viewed 35651 times
Just use leading caps without spaces and name setting will be automatically spaced, i.e. BigStore will become Big Store.

PrefixResults.png (58.3 KiB) Viewed 35651 times
I put in a Spanish test to make sure that GenerateTranslation is not broken. I replaced that to the earlier PackOut stub.

SpanishTranslation.png (38.91 KiB) Viewed 35651 times
Another tip is that PackOutFormat is automatically prepared in Pack Out window. Just go there and it is set to pack out NewMenu again. You can first drag your created windows into the New Menu

Re: Aladdin Magic Plugin

PostPosted: Wed Mar 16, 2016 5:22 pm
by red1
I have made the Sub Tab able to choose its own preferred ParentLink Column. It is specified by the columnname after the split character '>'

ParentLinkColumn.png (21.34 KiB) Viewed 35458 times
The result shows the new column linked to the parent's corresponding column. In this case it is not a new column but a core model R_Request.C_BPartner_ID linked to a new parent, 'SL_SalesLeadManagement. So this shows how perfect the code handle such real life cases.

TabChosenLink.png (47.29 KiB) Viewed 35458 times
I did that so that the Sales Lead Management main tab that has a C_BPartner_ID will have its sub-tab be only those Requests that are of the same Business Partner as more requests may be made by that same BPartner. Later we can have a further sub-tab below the Requests such as its RequestHistory.

Re: Aladdin Magic Plugin

PostPosted: Thu Mar 24, 2016 12:50 am
by red1
Now you can create an InfoWindow (stub) with a single line! Enter as below in the NewWindow:

InfoWindowCreation.png (27.27 KiB) Viewed 35338 times
Press save and its done! The SQL construct formulated into a new InfoWindow:

Code: Select all
C_OrderLine a
INNER JOIN C_Order b ON (b.C_Order_ID=a.C_Order_ID)
INNER JOIN C_BPartner c ON (c.C_BPartner_ID=a.C_BPartner_ID)
INNER JOIN M_Product d ON (d.M_Product_ID=a.M_Product_ID)

Its key columns also created. Later i will code the ColumnSet to allow more InfoColumns created abstractly and specific table linked.

GeneratedInfoItem.png (28.65 KiB) Viewed 35338 times
It appears on the Dashboard. And usable right away or modify further.

InfoWindow.png (131.32 KiB) Viewed 35276 times
Thanks to Hiep's debugging and advice, made some small touches to come out like that.

Re: Aladdin Magic Plugin

PostPosted: Thu Mar 24, 2016 10:42 am
by red1
Now we can have Reference List creation on the fly! Just use for example L#House=Double/Flat/Single/Studio where L# says this is a list, and House is the ListName, and if exist, it will add on. If not, will be created. The = values separated by / will be inserted into the Ref-List only those not existing before. If you hit unique constraint error, you can break down your column and list values into batches. i.e. L#House=Double/Flat. After save: L#House=Studio.

ReferenceListCreation.png (23.53 KiB) Viewed 35291 times
This is an example, after save you can see the reference created:

ReferenceListCreated.png (53.39 KiB) Viewed 35291 times
It will take the first two characters as key values, so you cannot have two similar key values. If your value length is 1 it will just take 1 as key value.

Login into GardenAdmin client will show it working beautifully.

ListWorking.png (55.11 KiB) Viewed 35291 times
It can also work for pure single digit numbers. Using L#Counter=1/2/3/4/5

NumberListing.png (73.43 KiB) Viewed 35291 times
But there is some reference mixup thinking that this is a number. So just go into your column and change reference from Integer back to Listing and call that counter list.

Re: Aladdin Magic Plugin

PostPosted: Fri Mar 25, 2016 4:04 pm
by red1
You can use the ColumnSet in the multi-tables definition for InfoWindow on the fly. Ensure the columns are existing ones by checking in the Element window.

InfoColumnSet.png (42.6 KiB) Viewed 35190 times
It is done in a flash.

FullInfo.png (54.53 KiB) Viewed 35190 times

Re: Aladdin Magic Plugin

PostPosted: Tue Apr 19, 2016 8:54 pm
by red1
A recent change breaks the 2Pack during Pack In. This seemed to be caused by new models such as AD_New and AD_ModelDesign not been committed before it is loaded for SQL insert (no POInfo error). To solve this, you have to set in the System Config window, at the 2PackCommitDDL to Y. Then you can install the plugin.

2PackCommitDDL.png (50.88 KiB) Viewed 34761 times

Re: Aladdin Magic Plugin

PostPosted: Tue Apr 26, 2016 9:19 pm
by red1
Generate Process can now be done on the fly! Not only that, you can add in the Parameters together and not only that, you can attach the Process to the Toolbar at the same time!

First call up the Model Design window.

GenerateProcess.png (43.52 KiB) Viewed 34652 times
Note that if you do not want to use it, replace ** at the beginning of the GenerateProcess field or leave it entirely blank. Then fill in any parameters you want in the Comment/Help box. Note that it should be existing elements. If your parameters are incorrect, it will just throw an error and you can edit it until it is correct. Error will not result in any process generated.

GeneratedFiles.png (23.06 KiB) Viewed 34652 times
You will see in your sourcecode, 2 files generated and written there. The itself and a plugin.txt advice. Take the xml snip inside and append to the plugin.xml.

ExtensionPluginXML.png (54.22 KiB) Viewed 34652 times
Check from the Extensions tab that the process definition works when you click on the class to check that the code is OK and without error. You can then add in your logic straight away to test it.

ADProcess.png (61.15 KiB) Viewed 34652 times
Inside your SystemAdmin, in the Report and Process window you will see your new Process defined into the database. Logout and login back as ClientAdmin. You will see in the Menu tree your new Process.

NewProcessInMenu.png (23.07 KiB) Viewed 34652 times
Click on it and it comes out well.

ProcessFromMenu.png (35.6 KiB) Viewed 34652 times
Now we try something amazing. Go back to the SystemAdmin and call up the Model Designer again. Leave the GenerateProcess alone as Aladdin will detect the process already exist and not create it again. But select a table and Aladdin will append that process to its Toolbar! (You can do this together on the first try.)

ProcessWithTable.png (51.92 KiB) Viewed 34652 times
Relogin into your Client and see the magic.

AttachedToolBar.png (51.01 KiB) Viewed 34652 times
Click on the gear icon and you will see your process attached there. You can click on it, and enter the parameters to see its working.

ProcessFromToolBar.png (78.54 KiB) Viewed 34652 times
When you click OK, your generated code will work if you put a break in your debug mode as shown.

ProcessJava.png (68.18 KiB) Viewed 34652 times
Mouse over the parameters and they do fetch the values from your selection. Aladdin Magic Plugin now removes yet more grunt work from another important developer task.

Re: Aladdin Magic Plugin

PostPosted: Wed Apr 27, 2016 4:58 pm
by red1
Made movie to show how the fantastic the Process generation works: