Reputation: 1
I want to migrate Lotus Notes database to salesforce. using domingo I am able to retrieve the forms , form fields ,documents and etc. As soon as I get the form with its fields & their datatypes, I want to create a class for this form. Like this I want to create a class for each form. Each document can then be made as an instance to this class. I am looping the database to get forms and then looping forms to get their fields(using for loops), now is there a way to create a class for this form right in this for loop dynamically so that each form can be exposed as a class. Please kindly help
Upvotes: 0
Views: 833
Reputation: 4785
Code java skeleton classes creation what you are doing is correct. Below is my quick and untested version:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim views As Variant
Dim notesToJavaFieldMap List As String
Dim doc As NotesDocument
Dim count As Integer
count = 0
Dim formsAlreadyProcessed(count) As String
Set db = session.CurrentDatabase
views = db.Views
Forall v In views
If v.IsDefaultView Then
Set view = v
Exit Forall
End If
End Forall
'Declare a complete on to one mapping here for all Notes item types to Java datatypes
notesToJavaFieldMap(" RichText") = "String"
notesToJavaFieldMap("Text") = "String"
notesToJavaFieldMap("Time/Date") = "Date"
Dim authorItem As NotesItem
Dim itemType As String
Dim itemName As String
Dim formName As String
Dim fileNum As Integer
Dim fileName As String
Set doc = view.GetFirstDocument
While Not(doc Is Nothing)
fileNum% = Freefile()
If Arraygetindex(formsAlreadyProcessed,doc.form(0)) Is Not Null Then
formsAlreadyProcessed(Ubound(formsAlreadyProcessed)) = doc.form(0)
Redim Preserve formsAlreadyProcessed(Ubound(formsAlreadyProcessed) + 1)
fileName$ = doc.form(0) +".java"
Open fileName$ For Output As fileNum%
Write #fileNum%, "package com.mypackage;"
Write #fileNum%, "\n \r"
Write #fileNum%, " public class " + fileName
Write #fileNum%, "\n \r"
Forall item In doc.Items
itemType = item.type
itemName = item.name
Write #fileNum%, "private " +notesToJavaFieldMap(itemType) + " " +itemName
Write #fileNum%, "\n \r"
End Forall
Close fileNum%
End If
Wend
End Sub
You can them open these class java files with an IDE like eclipse and import missing imports by going Ctrl+ O
and generate get and sets as well.
For the data itself dump it out as cvs and export it in.
I did not have lotus notes designer with me so this code is not tested .
Upvotes: 0
Reputation: 414
I believe that it might be possible to do this via the Salesforce metadata API, but I haven't personally used that API yet. I've had people recommend it to me as a means for handling similar tasks.
I'd question the benefits of doing a migration so generically. Unless you have so many objects and fields to create that the simple task of object and field creation will take significant time, what's the advantage? Remember, you can get and set fields on Salesforce standard and custom objects without writing code to go with those objects (at least you can in Apex). Likewise, each object automatically gets a standard controller to handle display and standard operations.
You should ask yourself if your data and data model are clean enough to generate code from. Are you sure? Really really sure? What about that widget count field that got added to the shipment object back in 2005 to solve a reporting issue? Nobody uses it anymore. Still want it in your new db?
Both times I've migrated Notes databases to Salesforce, I've exported to CSV and someone else has loaded the data. The first export was just a simple export of contacts and accounts. The second time I wrote my own Lotusscript exporter since I needed to fix certain data problems before doing the Salesforce import. The second time the load was done with the data loader. If I was loading the data myself, I'd use Demand Tools. It's much more industrial-strength tool. The de-duplication features alone can save you writing a lot of custom code.
Upvotes: 1
Reputation: 9551
You will need to code this yourself by exporting Lotus Notes domino form elements as DXL and then translate that into you're own custom form objects for use with SalesForce.
Upvotes: 0
Reputation: 1415
I believe the word 'dynamically' is misleading in this case. Perhaps I am reading the question wrong, but it seems that the forms in question are of fixed format and the word 'dynamically' is used in place of the ability to instantiate an object of a given class (aka how Java and many other languages work).
That being said, I would agree with michael667 in that this is certainly possible. Converting Form data (View) to an in memory Object (Model) via code logic (Controller) is what I (and many MANY others) do as a day job. Keep MVC in mind while developing and you should be just fine.
Upvotes: 0
Reputation: 3260
This certainly is possible, but wouldn't it be better to use a data structure like nested maps/lists in this case? When you dynamically create classes, you also have to dynamically create the code that works with these classes, otherwise you do not gain anything over a generic data structure.
Upvotes: 1