SlideShare una empresa de Scribd logo
1 de 24
Descargar para leer sin conexión
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

Más contenido relacionado

Destacado

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
 

Destacado (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 のご紹介
 

Similar 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
 

Similar 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

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Último (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

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