SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Andere mochten auch

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
 

Andere mochten auch (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 のご紹介
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingSelcen Ozturkcan
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Kürzlich hochgeladen (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

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