SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
1
The Road to Damascas –
A Conversion Experience:
LS and @Formula to SSJS
2014/03/17– Matthew Fyleman
2
 Matthew Fyleman
 21 YearsasaNotes/Domino Developer
 MostlyWorking on:
 Xpagesconversions
 Product development
Who AmI?
3
 Based on MyExperiences
 Converting LotusScript and @Formula to
SSJS
 Toolsthat can help – particularly regular
expressions
What isthisTalk About?
4
 When should you convert existing
code?
 Conversion Options
 NotesAgent.run() with parameter doc
 Search and Replace
 Dedicated Tools
 Search and Replace
 Preparation
 Introduction to Regular Expressions
 Examplesand Demonstration
 Tipsand Traps
 Dedicated Tools
 Questions
What amI talking about?
5
Never!
When should you convert existing code?
6
What isthe problem?
 It isalwaysgoing to beslow
 GIGO
 You will introducenew bugs
 Re-developing will bequicker, cheaper and
you will end up with abetter result
 But if you really must ...
When should you convert existing code?
7
What are your options?
 NotesAgent.run()
 Quick and Dirty
 Agent must run independently
 Only usewhen agentsareavailableand timeiscritical
 Search and Replace
 LotusScript -> JavaScript (and Java)
 Lessuseful for @Formula
 Dedicated Tools
 @Formula
Conversion Options
8
 Search and Replaceismost useful for LSconversion
 Syntacticallysimilar
 Easiest if you do alittlerefactoring first
 Option Declare
 doc.field(0) -> doc.getItemValue(“ Field“ )(0)
 Camel CaseNotesObjects
 MakeSureMethod callsareconsistentlynamed
 Best to Avoid All-In-One-Go
 Function or Sub at aTime
 Variablewith onepurposein onelocation mayhaveadifferent useelsewhere
Converting LotusScript to SSJS- Preparation
9
 Regular Expressionsareyour new BFF
 Sophisticated Pattern Matching
 Elementsfromsearch can becarried through to
replace
 TheSearch and Replacebuilt in to DDEcan use
Regular Expressions
 Useful outsideLSconversion (e.g. Validation)
 SeePlanet Lotus- http://planetlotus.org/profiles/ross-swick_97733
Regular Expressions
10
 Tidyup first – Option Declare, removeclustering e.g.:
Dimx asInteger,y asInteger,zasInteger
 Wewant to match any variablenamein thepattern:
Dim<var name> As<Anyvalid type>
 Fairly simple:
Dim[ ]+[A-Za-z0-9_]+[ ]+As[ ]+(Integer|String|Boolean|Double|Variant)
 But how do wereplace?
 Modifythesearch:
Dim[ ]+([w]*)[ ]+As[ ]+String
 Usethisfor replace
var 1 = “ ” ;
Starting Simple– DimStatements
11
 For NotesObjects, Thingsaresimpler
Dim<var name> AsNotes<rest of object name>
- Ignore... AsNew NotesSession for now
 Also, initialising in SSJS, = null isok:
var <var name>:Notes<rest of object name> = null;
 So our termsare:
 Search:
Dim[ ]+([w]*)[ ]+As[ ]+(Notes[w]*)
 Replace:
var 1:2 = null;
Starting Simple– DimStatements(2)
12
 For themost part, simpleS& R(but order isimportant):
End If to }
[ ]*Then to ) {
Else[ ]+If[ ]* to } elseif (
If[ ]* to if (
 But what about:
If (x = 10) Then
 UseSearch: If[ ]+([w()[].<>" ]*)=([w()[].<> "]*)[ ]+Then
 UseReplace: if (1==2) {
 NB: Worksbut not optimal!
 Other comparison operatorsnot aproblem
A bit morecomplex – If Statements
13
 Theproblem:
 Session object isglobal in ssjs: ‘session’
 In LSit iscreated:
DimsessAsNew NotesSession
 Need to find all LSsession objects, and replacewith session
 How do you get alist of session object names?
! – session objects
You need a coffee!
14
 JavaString Object hasregex search and replace
String source = “Dim x As String”;
String result = source.replaceAll(“Dim[ ]+([w]*)[ ]+As[ ]+String”, “var $1 = “”;”);
 Pattern and Matcher objectsmakethiseven morepowerful
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(this.source);
int startPos = 0;
while (m.find(startPos)) {
if (!itemList.contains(m.group(1))) {
itemList.add(m.group(1));
}
startPos = m.end() + 1;
}
Adding Java
15
 Similar Issueto Session
 Need to find all document object names, and replacefield handling
methods
 Will probablyneed to handledot notation
 Arrgghh!
 How do you search for dot notation?
<doc name>.([^GetItemValue])([0-9]+)
 Still hard work!
Field Handling
16
 Thereareother typesthan string!
 Alwaysreview and test converted codethoroughly
 Datehandling isapain
 Script librariescan help here– Java?
 Watch out for User interaction and particularly dialogues
Work out your strategiesin advance!
Search and Replace– Tipsand Traps
17
 In somerespects@Formula -> SSJSiseasier than LS-> SSJS
 @Formula JavaScript Wrappershelp alot
 Mostly just ‘;’ to ‘,’, and converting liststo arrays
 Someconstructionsareobvious:
@SetField(“ Field” , Value);
 Goesto:
doc.replaceItemValue(“ Field” , Value);
 Or
S: @SetField([ ]*([w” ]*)[ ]*,[ ]*([w” ]*)[ ]*);
R: doc.replaceItemValue(1, 2);
 But therearesomeissues...
Converting Formula
@
18
 No direct equivalent in SSJSfor *+, *= *>= etc.
when applied to Lists
 Need to plan for this
 JavaClass/Library to providedirect substitute
 Unfortunately, Javadoesnot permit operator
overloading, so hasto beaset of methods
Converting Formula – List Processing
@!
19
@If(@Contains(_WFData_neu;_Key);"";
@Do(
@Set("_Sachgebiet_Zuordnung";@DbLookup("NOTES":"NOCACHE";"":_ADM$StructureDB;"Workflows";"WFArbeitsanweisung";"Sachgebietzuordn
ung"));
@If(_Sachgebiet_Zuordnung= "" | !@Contains(_Sachgebiet_Zuordnung;_Key2);@Do(
@Prompt([Ok];"Hinweis";"Inder SystemStruktur VBM wurdefür dasaktuelleSachgebiet kein Workflow definiert. DasDokument wird zumehemaligen
Kompetenzträger zurückgegeben, damit dieser ein neuesSachgebiet auswählenkann.");
@Set("_Kompetenzträger";Bearbeiter1);
@Set("_tmpintern";5)
);
@Do(
@Prompt([Ok];"Hinweis";"Inder SystemStruktur VBM wurdefür dasaktuelleSachgebiet ein neuesSachgebiet konfiguriert. DasDokument wird zum
Kompetenzträger zurückgegeben, damit dieser dasneueSachgebiet auswählenkann.");
@Set("_neues_Sachgebiet";@Left(@Right(_Sachgebiet_Zuordnung;_key2);"||"));
@Set("_Elements";@Elements(@Explode(@Left(@Left(@Right(_WFData_neu;"||Sachgebiet#");"||"); _neues_Sachgebiet)+ _neues_Sachgebiet; "$"
)));
@Set("_KompetenzträgerData";@Explode(@Left(@Right(_WFData_neu;"||Kompetenzträger#");"||"); "$"));
@Set("_Kompetenzträger";@Subset(@Subset(_KompetenzträgerData;_Elements);-1));
@Set("_tmpintern";6)
)
)
)
);
Converting Formula - @If, @Do and @While
@!!!
20
 Search and Replacecan beused for @Formula ->
SSJS...
 ... but it can only takeyou so far
 Adedicated parser can go further
 Onlyreal alternativeto manual translation for complex
statements
 Timeconsuming to create
 Still not asilver bullet
Parsers
21
 Espresso - http://www.ultrapico.com/Expresso.htm
 Good for learning regex, and seriousregex dev
 Free!
 PowerGREP
 Sophisticated regex filesearch
 Whereregex started (UNIXgrep)!
 Expensive
Dedicated Tools
22
 We4IT– www.we4it.com
 OpenNTF– www.openntf.org
 Regex Quick Reference
http://www.night-ray.com/regex.pdf
 Loadsof websitesfor all aspectsof regex development
 Mastering Regular Expressions– JeffreyE.F. Friedl –
O’ReillyPublishing
Resourcesand Information
23
Questions?
24
matthew.fyleman@we4it.com

Mais conteúdo relacionado

Destaque

bccon-2014 key01 ibm_collaboration_solutions_connect_2014
bccon-2014 key01 ibm_collaboration_solutions_connect_2014bccon-2014 key01 ibm_collaboration_solutions_connect_2014
bccon-2014 key01 ibm_collaboration_solutions_connect_2014ICS User Group
 
bccon-2014 dev04 domino_apps_reaching_up&out
bccon-2014 dev04 domino_apps_reaching_up&outbccon-2014 dev04 domino_apps_reaching_up&out
bccon-2014 dev04 domino_apps_reaching_up&outICS User Group
 
bccon-2014 adm04 ibm-domino-64bit-all-you-need-to-know
bccon-2014 adm04 ibm-domino-64bit-all-you-need-to-knowbccon-2014 adm04 ibm-domino-64bit-all-you-need-to-know
bccon-2014 adm04 ibm-domino-64bit-all-you-need-to-knowICS User Group
 
bccon-2014 adm05 ibm traveler-2013-and-beyond
bccon-2014 adm05 ibm traveler-2013-and-beyondbccon-2014 adm05 ibm traveler-2013-and-beyond
bccon-2014 adm05 ibm traveler-2013-and-beyondICS User Group
 
bccon-2014 dev02 xpages-coffe-from-a-friend-using-third-party-java-libraries
bccon-2014 dev02 xpages-coffe-from-a-friend-using-third-party-java-librariesbccon-2014 dev02 xpages-coffe-from-a-friend-using-third-party-java-libraries
bccon-2014 dev02 xpages-coffe-from-a-friend-using-third-party-java-librariesICS User Group
 
bccon-2014 com02 level-up_building_next_generation_business_applications
bccon-2014 com02 level-up_building_next_generation_business_applicationsbccon-2014 com02 level-up_building_next_generation_business_applications
bccon-2014 com02 level-up_building_next_generation_business_applicationsICS User Group
 
bccon-2014 adm06 hony,_i_shrunk_the_data
bccon-2014 adm06 hony,_i_shrunk_the_databccon-2014 adm06 hony,_i_shrunk_the_data
bccon-2014 adm06 hony,_i_shrunk_the_dataICS User Group
 
Lotus iNotes をカスタマイズしてみよう
Lotus iNotes をカスタマイズしてみようLotus iNotes をカスタマイズしてみよう
Lotus iNotes をカスタマイズしてみようMasashi Miyazaki
 
bccon-2014 str06 ibm-notes-browser-plug-in_9.0.1
bccon-2014 str06 ibm-notes-browser-plug-in_9.0.1bccon-2014 str06 ibm-notes-browser-plug-in_9.0.1
bccon-2014 str06 ibm-notes-browser-plug-in_9.0.1ICS User Group
 
bccon-2014 str05 ibm-smart_cloud-for-social-business
bccon-2014 str05 ibm-smart_cloud-for-social-businessbccon-2014 str05 ibm-smart_cloud-for-social-business
bccon-2014 str05 ibm-smart_cloud-for-social-businessICS User Group
 
IBM iNotes 9.0 Social Edition のご紹介
IBM iNotes 9.0 Social Edition のご紹介IBM iNotes 9.0 Social Edition のご紹介
IBM iNotes 9.0 Social Edition のご紹介Masashi Miyazaki
 

Destaque (14)

bccon-2014 key01 ibm_collaboration_solutions_connect_2014
bccon-2014 key01 ibm_collaboration_solutions_connect_2014bccon-2014 key01 ibm_collaboration_solutions_connect_2014
bccon-2014 key01 ibm_collaboration_solutions_connect_2014
 
bccon-2014 dev04 domino_apps_reaching_up&out
bccon-2014 dev04 domino_apps_reaching_up&outbccon-2014 dev04 domino_apps_reaching_up&out
bccon-2014 dev04 domino_apps_reaching_up&out
 
bccon-2014 adm04 ibm-domino-64bit-all-you-need-to-know
bccon-2014 adm04 ibm-domino-64bit-all-you-need-to-knowbccon-2014 adm04 ibm-domino-64bit-all-you-need-to-know
bccon-2014 adm04 ibm-domino-64bit-all-you-need-to-know
 
bccon-2014-welcome
bccon-2014-welcomebccon-2014-welcome
bccon-2014-welcome
 
Slide Show
Slide ShowSlide Show
Slide Show
 
bccon-2014 adm05 ibm traveler-2013-and-beyond
bccon-2014 adm05 ibm traveler-2013-and-beyondbccon-2014 adm05 ibm traveler-2013-and-beyond
bccon-2014 adm05 ibm traveler-2013-and-beyond
 
bccon-2014 dev02 xpages-coffe-from-a-friend-using-third-party-java-libraries
bccon-2014 dev02 xpages-coffe-from-a-friend-using-third-party-java-librariesbccon-2014 dev02 xpages-coffe-from-a-friend-using-third-party-java-libraries
bccon-2014 dev02 xpages-coffe-from-a-friend-using-third-party-java-libraries
 
bccon-2014 com02 level-up_building_next_generation_business_applications
bccon-2014 com02 level-up_building_next_generation_business_applicationsbccon-2014 com02 level-up_building_next_generation_business_applications
bccon-2014 com02 level-up_building_next_generation_business_applications
 
bccon-2014 adm06 hony,_i_shrunk_the_data
bccon-2014 adm06 hony,_i_shrunk_the_databccon-2014 adm06 hony,_i_shrunk_the_data
bccon-2014 adm06 hony,_i_shrunk_the_data
 
Lotus iNotes をカスタマイズしてみよう
Lotus iNotes をカスタマイズしてみようLotus iNotes をカスタマイズしてみよう
Lotus iNotes をカスタマイズしてみよう
 
презентация Dancers 2.0
презентация Dancers 2.0презентация Dancers 2.0
презентация Dancers 2.0
 
bccon-2014 str06 ibm-notes-browser-plug-in_9.0.1
bccon-2014 str06 ibm-notes-browser-plug-in_9.0.1bccon-2014 str06 ibm-notes-browser-plug-in_9.0.1
bccon-2014 str06 ibm-notes-browser-plug-in_9.0.1
 
bccon-2014 str05 ibm-smart_cloud-for-social-business
bccon-2014 str05 ibm-smart_cloud-for-social-businessbccon-2014 str05 ibm-smart_cloud-for-social-business
bccon-2014 str05 ibm-smart_cloud-for-social-business
 
IBM iNotes 9.0 Social Edition のご紹介
IBM iNotes 9.0 Social Edition のご紹介IBM iNotes 9.0 Social Edition のご紹介
IBM iNotes 9.0 Social Edition のご紹介
 

Semelhante a bccon-2014 dev03 xpages-road_to_damascas-lotus-script-and-@formula-to-ssjs

Icsug conf 14_dev03_xpages-roadtodamascas-lotus-script-and-formula-to-ssjs
Icsug conf 14_dev03_xpages-roadtodamascas-lotus-script-and-formula-to-ssjsIcsug conf 14_dev03_xpages-roadtodamascas-lotus-script-and-formula-to-ssjs
Icsug conf 14_dev03_xpages-roadtodamascas-lotus-script-and-formula-to-ssjsICS User Group
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescriptDavid Furber
 
SOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSergey Karpushin
 
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)ruthmcdavitt
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl TechniquesDave Cross
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9sagaroceanic11
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9sagaroceanic11
 
Scala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameScala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameAntony Stubbs
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Jonathan Felch
 
The Great Scala Makeover
The Great Scala MakeoverThe Great Scala Makeover
The Great Scala MakeoverGarth Gilmour
 
Unit 3-Javascript.pptx
Unit 3-Javascript.pptxUnit 3-Javascript.pptx
Unit 3-Javascript.pptxAmanJha533833
 
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014hwilming
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteDr Nic Williams
 

Semelhante a bccon-2014 dev03 xpages-road_to_damascas-lotus-script-and-@formula-to-ssjs (20)

Icsug conf 14_dev03_xpages-roadtodamascas-lotus-script-and-formula-to-ssjs
Icsug conf 14_dev03_xpages-roadtodamascas-lotus-script-and-formula-to-ssjsIcsug conf 14_dev03_xpages-roadtodamascas-lotus-script-and-formula-to-ssjs
Icsug conf 14_dev03_xpages-roadtodamascas-lotus-script-and-formula-to-ssjs
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescript
 
SOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principles
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl Techniques
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9
 
What`s New in Java 8
What`s New in Java 8What`s New in Java 8
What`s New in Java 8
 
Scala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameScala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love Game
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
 
mod_rewrite
mod_rewritemod_rewrite
mod_rewrite
 
The Great Scala Makeover
The Great Scala MakeoverThe Great Scala Makeover
The Great Scala Makeover
 
Ruby
RubyRuby
Ruby
 
Unit 3-Javascript.pptx
Unit 3-Javascript.pptxUnit 3-Javascript.pptx
Unit 3-Javascript.pptx
 
mod_rewrite
mod_rewritemod_rewrite
mod_rewrite
 
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
 
Fancy talk
Fancy talkFancy talk
Fancy talk
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
 

Último

Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FIDO Alliance
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jNeo4j
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Hiroshi SHIBATA
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsLeah Henrickson
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIES VE
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?Mark Billinghurst
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsStefano
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastUXDXConf
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 

Último (20)

Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4j
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 

bccon-2014 dev03 xpages-road_to_damascas-lotus-script-and-@formula-to-ssjs

  • 1. 1 The Road to Damascas – A Conversion Experience: LS and @Formula to SSJS 2014/03/17– Matthew Fyleman
  • 2. 2  Matthew Fyleman  21 YearsasaNotes/Domino Developer  MostlyWorking on:  Xpagesconversions  Product development Who AmI?
  • 3. 3  Based on MyExperiences  Converting LotusScript and @Formula to SSJS  Toolsthat can help – particularly regular expressions What isthisTalk About?
  • 4. 4  When should you convert existing code?  Conversion Options  NotesAgent.run() with parameter doc  Search and Replace  Dedicated Tools  Search and Replace  Preparation  Introduction to Regular Expressions  Examplesand Demonstration  Tipsand Traps  Dedicated Tools  Questions What amI talking about?
  • 5. 5 Never! When should you convert existing code?
  • 6. 6 What isthe problem?  It isalwaysgoing to beslow  GIGO  You will introducenew bugs  Re-developing will bequicker, cheaper and you will end up with abetter result  But if you really must ... When should you convert existing code?
  • 7. 7 What are your options?  NotesAgent.run()  Quick and Dirty  Agent must run independently  Only usewhen agentsareavailableand timeiscritical  Search and Replace  LotusScript -> JavaScript (and Java)  Lessuseful for @Formula  Dedicated Tools  @Formula Conversion Options
  • 8. 8  Search and Replaceismost useful for LSconversion  Syntacticallysimilar  Easiest if you do alittlerefactoring first  Option Declare  doc.field(0) -> doc.getItemValue(“ Field“ )(0)  Camel CaseNotesObjects  MakeSureMethod callsareconsistentlynamed  Best to Avoid All-In-One-Go  Function or Sub at aTime  Variablewith onepurposein onelocation mayhaveadifferent useelsewhere Converting LotusScript to SSJS- Preparation
  • 9. 9  Regular Expressionsareyour new BFF  Sophisticated Pattern Matching  Elementsfromsearch can becarried through to replace  TheSearch and Replacebuilt in to DDEcan use Regular Expressions  Useful outsideLSconversion (e.g. Validation)  SeePlanet Lotus- http://planetlotus.org/profiles/ross-swick_97733 Regular Expressions
  • 10. 10  Tidyup first – Option Declare, removeclustering e.g.: Dimx asInteger,y asInteger,zasInteger  Wewant to match any variablenamein thepattern: Dim<var name> As<Anyvalid type>  Fairly simple: Dim[ ]+[A-Za-z0-9_]+[ ]+As[ ]+(Integer|String|Boolean|Double|Variant)  But how do wereplace?  Modifythesearch: Dim[ ]+([w]*)[ ]+As[ ]+String  Usethisfor replace var 1 = “ ” ; Starting Simple– DimStatements
  • 11. 11  For NotesObjects, Thingsaresimpler Dim<var name> AsNotes<rest of object name> - Ignore... AsNew NotesSession for now  Also, initialising in SSJS, = null isok: var <var name>:Notes<rest of object name> = null;  So our termsare:  Search: Dim[ ]+([w]*)[ ]+As[ ]+(Notes[w]*)  Replace: var 1:2 = null; Starting Simple– DimStatements(2)
  • 12. 12  For themost part, simpleS& R(but order isimportant): End If to } [ ]*Then to ) { Else[ ]+If[ ]* to } elseif ( If[ ]* to if (  But what about: If (x = 10) Then  UseSearch: If[ ]+([w()[].<>" ]*)=([w()[].<> "]*)[ ]+Then  UseReplace: if (1==2) {  NB: Worksbut not optimal!  Other comparison operatorsnot aproblem A bit morecomplex – If Statements
  • 13. 13  Theproblem:  Session object isglobal in ssjs: ‘session’  In LSit iscreated: DimsessAsNew NotesSession  Need to find all LSsession objects, and replacewith session  How do you get alist of session object names? ! – session objects You need a coffee!
  • 14. 14  JavaString Object hasregex search and replace String source = “Dim x As String”; String result = source.replaceAll(“Dim[ ]+([w]*)[ ]+As[ ]+String”, “var $1 = “”;”);  Pattern and Matcher objectsmakethiseven morepowerful Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(this.source); int startPos = 0; while (m.find(startPos)) { if (!itemList.contains(m.group(1))) { itemList.add(m.group(1)); } startPos = m.end() + 1; } Adding Java
  • 15. 15  Similar Issueto Session  Need to find all document object names, and replacefield handling methods  Will probablyneed to handledot notation  Arrgghh!  How do you search for dot notation? <doc name>.([^GetItemValue])([0-9]+)  Still hard work! Field Handling
  • 16. 16  Thereareother typesthan string!  Alwaysreview and test converted codethoroughly  Datehandling isapain  Script librariescan help here– Java?  Watch out for User interaction and particularly dialogues Work out your strategiesin advance! Search and Replace– Tipsand Traps
  • 17. 17  In somerespects@Formula -> SSJSiseasier than LS-> SSJS  @Formula JavaScript Wrappershelp alot  Mostly just ‘;’ to ‘,’, and converting liststo arrays  Someconstructionsareobvious: @SetField(“ Field” , Value);  Goesto: doc.replaceItemValue(“ Field” , Value);  Or S: @SetField([ ]*([w” ]*)[ ]*,[ ]*([w” ]*)[ ]*); R: doc.replaceItemValue(1, 2);  But therearesomeissues... Converting Formula @
  • 18. 18  No direct equivalent in SSJSfor *+, *= *>= etc. when applied to Lists  Need to plan for this  JavaClass/Library to providedirect substitute  Unfortunately, Javadoesnot permit operator overloading, so hasto beaset of methods Converting Formula – List Processing @!
  • 19. 19 @If(@Contains(_WFData_neu;_Key);""; @Do( @Set("_Sachgebiet_Zuordnung";@DbLookup("NOTES":"NOCACHE";"":_ADM$StructureDB;"Workflows";"WFArbeitsanweisung";"Sachgebietzuordn ung")); @If(_Sachgebiet_Zuordnung= "" | !@Contains(_Sachgebiet_Zuordnung;_Key2);@Do( @Prompt([Ok];"Hinweis";"Inder SystemStruktur VBM wurdefür dasaktuelleSachgebiet kein Workflow definiert. DasDokument wird zumehemaligen Kompetenzträger zurückgegeben, damit dieser ein neuesSachgebiet auswählenkann."); @Set("_Kompetenzträger";Bearbeiter1); @Set("_tmpintern";5) ); @Do( @Prompt([Ok];"Hinweis";"Inder SystemStruktur VBM wurdefür dasaktuelleSachgebiet ein neuesSachgebiet konfiguriert. DasDokument wird zum Kompetenzträger zurückgegeben, damit dieser dasneueSachgebiet auswählenkann."); @Set("_neues_Sachgebiet";@Left(@Right(_Sachgebiet_Zuordnung;_key2);"||")); @Set("_Elements";@Elements(@Explode(@Left(@Left(@Right(_WFData_neu;"||Sachgebiet#");"||"); _neues_Sachgebiet)+ _neues_Sachgebiet; "$" ))); @Set("_KompetenzträgerData";@Explode(@Left(@Right(_WFData_neu;"||Kompetenzträger#");"||"); "$")); @Set("_Kompetenzträger";@Subset(@Subset(_KompetenzträgerData;_Elements);-1)); @Set("_tmpintern";6) ) ) ) ); Converting Formula - @If, @Do and @While @!!!
  • 20. 20  Search and Replacecan beused for @Formula -> SSJS...  ... but it can only takeyou so far  Adedicated parser can go further  Onlyreal alternativeto manual translation for complex statements  Timeconsuming to create  Still not asilver bullet Parsers
  • 21. 21  Espresso - http://www.ultrapico.com/Expresso.htm  Good for learning regex, and seriousregex dev  Free!  PowerGREP  Sophisticated regex filesearch  Whereregex started (UNIXgrep)!  Expensive Dedicated Tools
  • 22. 22  We4IT– www.we4it.com  OpenNTF– www.openntf.org  Regex Quick Reference http://www.night-ray.com/regex.pdf  Loadsof websitesfor all aspectsof regex development  Mastering Regular Expressions– JeffreyE.F. Friedl – O’ReillyPublishing Resourcesand Information