How to use process method in Gherkin-python

Best Python code snippet using gherkin-python

Run Gherkin-python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

run_only_CTPPS_cfg_DIG_.py

Source: run_only_CTPPS_cfg_DIG_.py Github

copy
1import FWCore.ParameterSet.Config as cms
2
3from Configuration.StandardSequences.Eras import eras
4process = cms.Process('CTPPS2',eras.Run2_25ns)
5
6# import of standard configurations
7process.load('Configuration.StandardSequences.Services_cff')
8process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
9process.load('FWCore.MessageService.MessageLogger_cfi')
10process.load('Configuration.EventContent.EventContent_cff')
11process.load('SimGeneral.MixingModule.mixNoPU_cfi')
12process.load('Configuration.StandardSequences.MagneticField_38T_cff')
13process.load('Configuration.StandardSequences.Generator_cff')
14process.load('IOMC.EventVertexGenerators.VtxSmearedRealistic50ns13TeVCollision_cfi')
15process.load('GeneratorInterface.Core.genFilterSummary_cff')
16process.load('Configuration.StandardSequences.SimIdeal_cff')
17process.load('Configuration.StandardSequences.EndOfProcess_cff')
18process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
19############### using only CTPPS geometry 
20from Configuration.Geometry.geometry_CTPPS_cfi import XMLIdealGeometryESSource_CTPPS
21process.XMLIdealGeometryESSource = XMLIdealGeometryESSource_CTPPS.clone()
22
23##########SimTransport###########
24process.load('SimTransport.HectorProducer.HectorTransportCTPPS_cfi')
25
26process.load("SimG4Core.Application.g4SimHits_cfi")
27process.g4SimHits.Generator.ApplyPCuts          = False
28process.g4SimHits.Generator.ApplyPhiCuts        = False
29process.g4SimHits.Generator.ApplyEtaCuts        = False
30process.g4SimHits.Generator.HepMCProductLabel   = 'LHCTransport'
31process.g4SimHits.Generator.MinEtaCut        = -13.0
32process.g4SimHits.Generator.MaxEtaCut        = 13.0
33process.g4SimHits.Generator.Verbosity        = 0
34
35process.g4SimHits.G4TrackingManagerVerbosity = cms.untracked.int32(3)
36process.g4SimHits.SteppingAction.MaxTrackTime = cms.double(2000.0)
37process.g4SimHits.StackingAction.MaxTrackTime = cms.double(2000.0)
38
39process.load("IOMC.RandomEngine.IOMC_cff")
40process.RandomNumberGeneratorService.generator.initialSeed = 456789
41process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876
42process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789
43process.RandomNumberGeneratorService.RPixDetDigitizer = cms.PSet(initialSeed =cms.untracked.uint32(137137))
44
45process.maxEvents = cms.untracked.PSet(
46        input = cms.untracked.int32(1000)
47        )
48
49from Configuration.AlCa.GlobalTag import GlobalTag
50process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_hlt_relval', '')
51process.load('PhysicsTools.HepMCCandAlgos.genParticles_cfi')
52
53import math
54phi_min = -math.pi
55phi_max = math.pi
56t_min   = 0.
57t_max   = 2.
58xi_min  = 0.01
59xi_max  = 0.3
60ecms = 13000.
61
62process.generator = cms.EDProducer("RandomtXiGunProducer",
63        PGunParameters = cms.PSet(
64            PartID = cms.vint32(2212),
65            MinPhi = cms.double(phi_min),
66            MaxPhi = cms.double(phi_max),
67            ECMS   = cms.double(ecms),
68            Mint   = cms.double(t_min),
69            Maxt   = cms.double(t_max),
70            MinXi  = cms.double(xi_min),
71            MaxXi  = cms.double(xi_max)
72            ),
73        Verbosity = cms.untracked.int32(0),
74        psethack = cms.string('single protons'),
75        FireBackward = cms.bool(True),
76        FireForward  = cms.bool(True),
77        firstRun = cms.untracked.uint32(1),
78        )
79
80process.source = cms.Source("EmptySource",
81        firstRun = cms.untracked.uint32(294700),
82        numberEventsInRun = cms.untracked.uint32(100),
83)
84
85process.ProductionFilterSequence = cms.Sequence(process.generator)
86
87############
88process.o1 = cms.OutputModule("PoolOutputModule",
89        outputCommands = cms.untracked.vstring('keep *'),
90        fileName = cms.untracked.string('simevent_CTPPS_DIG.root')
91        )
92
93process.common_maximum_timex = cms.PSet( # need to be localy redefined
94        MaxTrackTime  = cms.double(2000.0),  # need to be localy redefined
95        MaxTimeNames  = cms.vstring('ZDCRegion'), # need to be localy redefined
96        MaxTrackTimes = cms.vdouble(10000.0),  # need to be localy redefined
97        DeadRegions = cms.vstring()
98        )
99process.generation_step = cms.Path(process.pgen)
100process.simulation_step = cms.Path(process.psim)
101process.g4Simhits_step = cms.Path(process.g4SimHits)
102
103# Transport
104process.transport_step = cms.Path(process.LHCTransport)
105process.genfiltersummary_step = cms.EndPath(process.genFilterSummary)
106
107process.outpath = cms.EndPath(process.o1)
108
109process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.transport_step,process.g4Simhits_step,process.outpath)
110
111# filter all path with the production filter sequence
112for path in process.paths:
113    getattr(process,path)._seq = process.ProductionFilterSequence * getattr(process,path)._seq
114
115
116
Full Screen

Diamond_test.py

Source: Diamond_test.py Github

copy
1# Auto generated configuration file
2# using: 
3# Revision: 1.19 
4# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v 
5# with command line options: GluGluTo2Jets_M_100_7TeV_exhume_cff.py --mc --eventcontent FEVTDEBUG --datatier GEN-SIM --conditions 80X_mcRun2_asymptotic_2016_v2 --step GEN,SIM --era Run2_25ns --geometry Extended2017dev --processName=CTPPS --no_exec
6import FWCore.ParameterSet.Config as cms
7
8from Configuration.StandardSequences.Eras import eras
9
10process = cms.Process('CTPPS',eras.Run2_2017)
11
12# import of standard configurations
13process.load('Configuration.StandardSequences.Services_cff')
14process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
15process.load('FWCore.MessageService.MessageLogger_cfi')
16process.load('Configuration.EventContent.EventContent_cff')
17process.load('SimGeneral.MixingModule.mixNoPU_cfi')
18process.load('Configuration.StandardSequences.GeometryRecoDB_cff')
19process.load('Configuration.Geometry.GeometryExtended2017dev_cff')
20process.load('Configuration.StandardSequences.MagneticField_cff')
21process.load('Configuration.StandardSequences.Generator_cff')
22process.load('IOMC.EventVertexGenerators.VtxSmearedRealistic50ns13TeVCollision_cfi')
23process.load('GeneratorInterface.Core.genFilterSummary_cff')
24process.load('Configuration.StandardSequences.SimIdeal_cff')
25process.load('Configuration.StandardSequences.EndOfProcess_cff')
26process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
27###########SimTransport###########
28process.load('SimTransport.HectorProducer.HectorTransportCTPPS_cfi')
29
30process.load('SimG4Core.Application.g4SimHits_cfi')
31process.g4SimHits.Physics.DefaultCutValue = 100.
32process.g4SimHits.UseMagneticField              = False
33process.g4SimHits.Generator.ApplyPCuts          = False
34process.g4SimHits.Generator.ApplyPhiCuts        = False
35process.g4SimHits.Generator.ApplyEtaCuts        = False
36process.g4SimHits.Generator.HepMCProductLabel   = 'LHCTransport'
37process.g4SimHits.Generator.MinEtaCut        = -13.0
38process.g4SimHits.Generator.MaxEtaCut        = 13.0
39process.g4SimHits.Generator.Verbosity        = 0
40process.g4SimHits.Generator.EtaCutForHector  = 7.0
41
42process.g4SimHits.G4TrackingManagerVerbosity = cms.untracked.int32(3)
43process.g4SimHits.SteppingAction.MaxTrackTime = cms.double(2000.0)
44process.g4SimHits.StackingAction.MaxTrackTime = cms.double(2000.0)
45
46process.common_maximum_timex = cms.PSet( # need to be localy redefined
47   MaxTrackTime  = cms.double(2000.0),  # need to be localy redefined
48   MaxTimeNames  = cms.vstring('ZDCRegion'), # need to be localy redefined
49   MaxTrackTimes = cms.vdouble(10000.0),  # need to be localy redefined
50   DeadRegions = cms.vstring()
51)
52
53process.maxEvents = cms.untracked.PSet(
54    input = cms.untracked.int32(10)
55)
56
57# Input source
58process.source = cms.Source("EmptySource")
59
60process.options = cms.untracked.PSet(
61)
62
63# Production Info
64process.configurationMetadata = cms.untracked.PSet(
65    annotation = cms.untracked.string('GluGluTo2Jets_M_100_7TeV_exhume_cff.py nevts:1'),
66    name = cms.untracked.string('Applications'),
67    version = cms.untracked.string('$Revision: 1.19 $')
68)
69
70# Output definition
71
72process.FEVTDEBUGoutput = cms.OutputModule("PoolOutputModule",
73    SelectEvents = cms.untracked.PSet(
74        SelectEvents = cms.vstring('generation_step')
75    ),
76    dataset = cms.untracked.PSet(
77        dataTier = cms.untracked.string('GEN-SIM'),
78        filterName = cms.untracked.string('')
79    ),
80    eventAutoFlushCompressedSize = cms.untracked.int32(5242880),
81    fileName = cms.untracked.string('GluGluTo2Jets_M_300_2000_13TeV_exhume_cff_py_GEN_SIM_HECTOR_CTPPS.root'),
82    outputCommands = process.FEVTDEBUGEventContent.outputCommands,
83    splitLevel = cms.untracked.int32(0)
84)
85
86# Additional output definition
87
88# Other statements
89process.genstepfilter.triggerConditions=cms.vstring("generation_step")
90from Configuration.AlCa.GlobalTag import GlobalTag
91process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2017_realistic', '')
92process.load('PhysicsTools.HepMCCandAlgos.genParticles_cfi')
93
94process.generator = cms.EDFilter("ExhumeGeneratorFilter",
95    ExhumeParameters = cms.PSet(
96        AlphaEw = cms.double(0.0072974),
97        B = cms.double(4.0),
98        BottomMass = cms.double(4.6),
99        CharmMass = cms.double(1.42),
100        HiggsMass = cms.double(120.0),
101        HiggsVev = cms.double(246.0),
102        LambdaQCD = cms.double(80.0),
103        MinQt2 = cms.double(0.64),
104        MuonMass = cms.double(0.1057),
105        PDF = cms.double(11000),
106        Rg = cms.double(1.2),
107        StrangeMass = cms.double(0.19),
108        Survive = cms.double(0.03),
109        TauMass = cms.double(1.77),
110        TopMass = cms.double(175.0),
111        WMass = cms.double(80.33),
112        ZMass = cms.double(91.187)
113    ),
114    ExhumeProcess = cms.PSet(
115        MassRangeHigh = cms.double(2000.0),
116        MassRangeLow = cms.double(300.0),
117        ProcessType = cms.string('GG'),
118        ThetaMin = cms.double(0.3)
119    ),
120    PythiaParameters = cms.PSet(
121        parameterSets = cms.vstring()
122    ),
123    comEnergy = cms.double(13000.0),
124    maxEventsToPrint = cms.untracked.int32(2),
125    pythiaHepMCVerbosity = cms.untracked.bool(False),
126    pythiaPylistVerbosity = cms.untracked.int32(1)
127)
128
129process.ProductionFilterSequence = cms.Sequence(process.generator)
130#process.load("SimCTPPS.CTPPSPixelDigiProducer.RPixDetConf_cfi")
131#process.load("Configuration.Geometry.geometry_CTPPS_cfi")
132process.load("Configuration.Geometry.cmsExtendedGeometry2017dev_veryforward_RP_CTPPS_XML_cfi")
133# Path and EndPath definitions
134process.generation_step = cms.Path(process.pgen)
135process.simulation_step = cms.Path(process.psim)
136
137# Transport
138process.transport_step = cms.Path(process.LHCTransport)
139process.genfiltersummary_step = cms.EndPath(process.genFilterSummary)
140process.endjob_step = cms.EndPath(process.endOfProcess)
141process.FEVTDEBUGoutput_step = cms.EndPath(process.FEVTDEBUGoutput)
142
143
144process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.transport_step,process.simulation_step,process.endjob_step,process.FEVTDEBUGoutput_step)
145
146# filter all path with the production filter sequence
147for path in process.paths:
148	getattr(process,path)._seq = process.ProductionFilterSequence * getattr(process,path)._seq 
149
150
151
Full Screen

geometryTestRun_cfg.py

Source: geometryTestRun_cfg.py Github

copy
1import FWCore.ParameterSet.Config as cms
2
3process = cms.Process("GeometryTest")
4process.load("Geometry.CMSCommonData.cmsIdealGeometryXML_cff")
5
6process.load("Geometry.RPCGeometry.rpcGeometry_cfi")
7
8process.load("Geometry.DTGeometry.dtGeometry_cfi")
9
10#startCSC
11process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi")
12#process.load("Geometry.MuonCommonData.muonEndcapIdealGeometryXML_cfi")
13# flags for modelling of CSC layer & strip geometry
14process.load("Geometry.CSCGeometry.cscGeometry_cfi")
15#process.load("Geometry.CSCGeometryBuilder.idealForDigiCscGeometry_cff")
16process.load("Alignment.CommonAlignmentProducer.FakeAlignmentSource_cfi")
17#process.preferFakeAlign = cms.ESPrefer("FakeAlignmentSource", "FakeAlignmentSource")
18process.fake2 = process.FakeAlignmentSource
19del process.FakeAlignmentSource
20process.preferFakeAlign = cms.ESPrefer("FakeAlignmentSource", "fake2")
21process.load("Geometry.CSCGeometry.cscGeometry_cfi")
22#end CSC
23
24process.load("Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi")
25
26process.load("Geometry.TrackerGeometryBuilder.trackerGeometry_cfi")
27
28#process.load("MagneticField.Engine.volumeBasedMagneticField_cfi")
29process.load("Configuration.StandardSequences.MagneticField_38T_cff")
30
31process.load("Geometry.CaloEventSetup.CaloGeometry_cff")
32
33process.maxEvents = cms.untracked.PSet(
34        input = cms.untracked.int32(1)
35        )
36process.source = cms.Source("EmptySource")
37
38process.prpc = cms.EDAnalyzer("RPCGeometryAnalyzer")
39
40process.pdt = cms.EDAnalyzer("DTGeometryAnalyzer")
41
42process.pcsc = cms.EDAnalyzer("CSCGeometryAnalyzer")
43
44process.ptrak = cms.EDAnalyzer("TrackerDigiGeometryAnalyzer")
45
46#process.pcalo = cms.EDAnalyzer("CaloGeometryAnalyzer")
47process.load("Geometry.CaloEventSetup.CaloGeometry_cff")
48process.load("Geometry.CaloEventSetup.CaloTopology_cfi")
49process.etta = cms.EDAnalyzer("dumpEcalTrigTowerMapping")
50
51process.ctgw = cms.EDAnalyzer("testEcalGetWindow")
52
53process.cga = cms.EDAnalyzer("CaloGeometryAnalyzer",
54                                 fullEcalDump = cms.untracked.bool(True)
55                             )
56process.load("Geometry.CaloEventSetup.EcalTrigTowerConstituents_cfi")
57
58
59process.ctgw = cms.EDAnalyzer("testEcalGetWindow")
60process.mfa = cms.EDAnalyzer("testMagneticField")
61
62process.TFileService = cms.Service("TFileService", fileName = cms.string('calogeom.root') )
63
64process.cga = cms.EDAnalyzer("CaloGeometryAnalyzer",
65                                 fullEcalDump = cms.untracked.bool(True)
66                             )
67
68process.myprint = cms.OutputModule("AsciiOutputModule")
69
70process.MessageLogger = cms.Service("MessageLogger",
71                                        detailedInfo = cms.untracked.PSet(
72            threshold = cms.untracked.string('DEBUG')
73                ),
74                                        warning = cms.untracked.PSet(
75            threshold = cms.untracked.string('WARNING')
76                ),
77                                        debugModules = cms.untracked.vstring('*'),
78                                        critical = cms.untracked.PSet(
79            threshold = cms.untracked.string('ERROR')
80                ),
81                                        destinations = cms.untracked.vstring('detailedInfo',
82                                                                                     'critical',
83                                                                                     'info',
84                                                                                     'warning')
85                                    )
86
87process.p1 = cms.Path(process.pcsc*process.prpc*process.pdt*process.ptrak*process.etta*process.ctgw*process.cga*process.mfa) #*process.pcalo)
88process.ep = cms.EndPath(process.myprint)
89
Full Screen

ProcessDiagramGenerator.js

Source: ProcessDiagramGenerator.js Github

copy
1 /**
2 * Class to generate an image based the diagram interchange information in a
3 * BPMN 2.0 process.
4 *
5 * @author (Javascript) Dmitry Farafonov
6 */
7 
8var ProcessDiagramGenerator = {	
9	options: {},
10	
11	processDiagramCanvas: [],
12	
13	activityDrawInstructions:{},
14	
15	processDiagrams: {},
16	
17	diagramBreadCrumbs: null,
18	
19	init: function(){
20		// start event
21		this.activityDrawInstructions["startEvent"] = function(){
22			var activityImpl = this.activity;
23			var processDiagramCanvas = this.processDiagramCanvas;
24			processDiagramCanvas.setConextObject(activityImpl);
25			
26			processDiagramCanvas.drawNoneStartEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
27		};
28		
29		// start timer event
30		this.activityDrawInstructions["startTimerEvent"] = function(){
31			var activityImpl = this.activity;
32			var processDiagramCanvas = this.processDiagramCanvas;
33			processDiagramCanvas.setConextObject(activityImpl);
34			
35			var isInterrupting = activityImpl.getProperty("isInterrupting");
36			processDiagramCanvas.drawTimerStartEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), isInterrupting, activityImpl.getProperty("name"));
37		};
38		
39		// start event
40		this.activityDrawInstructions["messageStartEvent"] = function(){
41			var activityImpl = this.activity;
42			var processDiagramCanvas = this.processDiagramCanvas;
43			processDiagramCanvas.setConextObject(activityImpl);
44			
45			var isInterrupting = activityImpl.getProperty("isInterrupting");
46			processDiagramCanvas.drawMessageStartEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), isInterrupting, activityImpl.getProperty("name"));
47		};
48		
49		// start signal event
50		this.activityDrawInstructions["startSignalEvent"] = function(){
51			var activityImpl = this.activity;
52			var processDiagramCanvas = this.processDiagramCanvas;
53			processDiagramCanvas.setConextObject(activityImpl);
54			
55			var isInterrupting = activityImpl.getProperty("isInterrupting");
56			processDiagramCanvas.drawSignalStartEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), isInterrupting, activityImpl.getProperty("name"));
57		};
58		
59		// start multiple event
60		this.activityDrawInstructions["startMultipleEvent"] = function(){
61			var activityImpl = this.activity;
62			var processDiagramCanvas = this.processDiagramCanvas;
63			processDiagramCanvas.setConextObject(activityImpl);
64			
65			var isInterrupting = activityImpl.getProperty("isInterrupting");
66			processDiagramCanvas.drawMultipleStartEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), isInterrupting, activityImpl.getProperty("name"));
67		};
68		
69		// signal catch
70		this.activityDrawInstructions["intermediateSignalCatch"] = function(){
71			var activityImpl = this.activity;
72			var processDiagramCanvas = this.processDiagramCanvas;
73			processDiagramCanvas.setConextObject(activityImpl);
74			
75			var isInterrupting = activityImpl.getProperty("isInterrupting");
76			processDiagramCanvas.drawCatchingSignalEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), isInterrupting, null);
77			
78			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
79			if (label)
80			  processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
81		};
82		
83		// message catch
84		this.activityDrawInstructions["intermediateMessageCatch"] = function(){
85			var activityImpl = this.activity;
86			var processDiagramCanvas = this.processDiagramCanvas;
87			processDiagramCanvas.setConextObject(activityImpl);
88			
89			var isInterrupting = activityImpl.getProperty("isInterrupting");
90			processDiagramCanvas.drawCatchingMessageEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), isInterrupting, null);
91			
92			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
93      if (label)
94        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
95		};
96		
97		// multiple catch
98		this.activityDrawInstructions["intermediateMultipleCatch"] = function(){
99			var activityImpl = this.activity;
100			var processDiagramCanvas = this.processDiagramCanvas;
101			processDiagramCanvas.setConextObject(activityImpl);
102			
103			var isInterrupting = activityImpl.getProperty("isInterrupting");
104			processDiagramCanvas.drawCatchingMultipleEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), isInterrupting, null);
105			
106			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
107      if (label)
108        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
109		};
110		
111		
112		
113		// signal throw
114		this.activityDrawInstructions["intermediateSignalThrow"] = function(){
115			var activityImpl = this.activity;
116			var processDiagramCanvas = this.processDiagramCanvas;
117			processDiagramCanvas.setConextObject(activityImpl);
118			
119			processDiagramCanvas.drawThrowingSignalEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), activityImpl.getProperty("name"));
120			
121			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
122      if (label)
123        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
124		};
125		
126		// message throw
127		this.activityDrawInstructions["intermediateMessageThrow"] = function(){
128			var activityImpl = this.activity;
129			var processDiagramCanvas = this.processDiagramCanvas;
130			processDiagramCanvas.setConextObject(activityImpl);
131			
132			processDiagramCanvas.drawThrowingMessageEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), activityImpl.getProperty("name"));
133			
134			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
135      if (label)
136        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
137		};
138		
139		// multiple throw
140		this.activityDrawInstructions["intermediateMultipleThrow"] = function(){
141			var activityImpl = this.activity;
142			var processDiagramCanvas = this.processDiagramCanvas;
143			processDiagramCanvas.setConextObject(activityImpl);
144			
145			processDiagramCanvas.drawThrowingMultipleEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), activityImpl.getProperty("name"));
146			
147			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
148      if (label)
149        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
150		};
151		
152		// none throw
153		this.activityDrawInstructions["intermediateThrowEvent"] = function() {
154			var activityImpl = this.activity;
155			var processDiagramCanvas = this.processDiagramCanvas;
156			processDiagramCanvas.setConextObject(activityImpl);
157			
158			processDiagramCanvas.drawThrowingNoneEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), activityImpl.getProperty("name"));
159			
160			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
161      if (label)
162        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
163		};
164		
165		// end event
166		this.activityDrawInstructions["endEvent"] = function(){
167			var activityImpl = this.activity;
168			var processDiagramCanvas = this.processDiagramCanvas;
169			processDiagramCanvas.setConextObject(activityImpl);
170			
171			processDiagramCanvas.drawNoneEndEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
172		};
173		
174		// error end event
175		this.activityDrawInstructions["errorEndEvent"] = function(){
176			var activityImpl = this.activity;
177			var processDiagramCanvas = this.processDiagramCanvas;
178			processDiagramCanvas.setConextObject(activityImpl);
179			
180			processDiagramCanvas.drawErrorEndEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), null);
181			
182			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
183      if (label)
184        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
185		};
186		
187		// message end event
188		this.activityDrawInstructions["messageEndEvent"] = function(){
189			var activityImpl = this.activity;
190			var processDiagramCanvas = this.processDiagramCanvas;
191			processDiagramCanvas.setConextObject(activityImpl);
192			
193			processDiagramCanvas.drawMessageEndEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), null);
194			
195			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
196      if (label)
197        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
198		};
199		
200		// signal end event
201		this.activityDrawInstructions["signalEndEvent"] = function(){
202			var activityImpl = this.activity;
203			var processDiagramCanvas = this.processDiagramCanvas;
204			processDiagramCanvas.setConextObject(activityImpl);
205			
206			processDiagramCanvas.drawSignalEndEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), null);
207			
208			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
209      if (label)
210        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
211		};
212		
213		// multiple end event
214		this.activityDrawInstructions["multipleEndEvent"] = function(){
215			var activityImpl = this.activity;
216			var processDiagramCanvas = this.processDiagramCanvas;
217			processDiagramCanvas.setConextObject(activityImpl);
218			
219			processDiagramCanvas.drawMultipleEndEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), null);
220			
221			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
222      if (label)
223        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
224		};
225		
226		// terminate end event
227		this.activityDrawInstructions["terminateEndEvent"] = function(){
228			var activityImpl = this.activity;
229			var processDiagramCanvas = this.processDiagramCanvas;
230			processDiagramCanvas.setConextObject(activityImpl);
231			
232			processDiagramCanvas.drawTerminateEndEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
233			
234			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
235      if (label)
236        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
237		};
238		
239		// error start event
240		this.activityDrawInstructions["errorStartEvent"] = function(){
241			var activityImpl = this.activity;
242			var processDiagramCanvas = this.processDiagramCanvas;
243			processDiagramCanvas.setConextObject(activityImpl);
244			
245			processDiagramCanvas.drawErrorStartEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), activityImpl.getProperty("name"));
246			
247			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
248      if (label)
249        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
250		};
251		
252		// task
253		this.activityDrawInstructions["task"] = function(){
254			var activityImpl = this.activity;
255			var processDiagramCanvas = this.processDiagramCanvas;
256			processDiagramCanvas.setConextObject(activityImpl);
257			
258			// TODO: 
259			//console.error("task is not implemented yet");
260			/*
261			var activityImpl = this;
262			processDiagramCanvas.drawTask(activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), thickBorder);
263			*/
264		};
265		
266		
267		// user task
268		this.activityDrawInstructions["userTask"] = function(){
269			var activityImpl = this.activity;
270			var processDiagramCanvas = this.processDiagramCanvas;
271			processDiagramCanvas.setConextObject(activityImpl);
272			
273			processDiagramCanvas.drawUserTask(activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
274		};
275		
276		// script task
277		this.activityDrawInstructions["scriptTask"] = function(){
278			var activityImpl = this.activity;
279			var processDiagramCanvas = this.processDiagramCanvas;
280			processDiagramCanvas.setConextObject(activityImpl);
281			
282			processDiagramCanvas.drawScriptTask(activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
283		};
284		
285		// service task
286		this.activityDrawInstructions["serviceTask"] = function(){
287			var activityImpl = this.activity;
288			var processDiagramCanvas = this.processDiagramCanvas;
289			processDiagramCanvas.setConextObject(activityImpl);
290			
291			processDiagramCanvas.drawServiceTask(activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
292		};
293
294		// receive task
295		this.activityDrawInstructions["receiveTask"] = function(){
296			var activityImpl = this.activity;
297			var processDiagramCanvas = this.processDiagramCanvas;
298			processDiagramCanvas.setConextObject(activityImpl);
299			
300			processDiagramCanvas.drawReceiveTask(activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
301		};
302		
303		// send task
304		this.activityDrawInstructions["sendTask"] = function(){
305			var activityImpl = this.activity;
306			var processDiagramCanvas = this.processDiagramCanvas;
307			processDiagramCanvas.setConextObject(activityImpl);
308			
309			processDiagramCanvas.drawSendTask(activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
310		};
311
312		// manual task
313		this.activityDrawInstructions["manualTask"] = function(){
314			var activityImpl = this.activity;
315			var processDiagramCanvas = this.processDiagramCanvas;
316			processDiagramCanvas.setConextObject(activityImpl);
317		
318			processDiagramCanvas.drawManualTask(activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
319		};
320
321		// businessRuleTask task
322		this.activityDrawInstructions["businessRuleTask"] = function(){
323			var activityImpl = this.activity;
324			var processDiagramCanvas = this.processDiagramCanvas;
325			processDiagramCanvas.setConextObject(activityImpl);
326			
327			processDiagramCanvas.drawBusinessRuleTask(activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
328		};
329
330		// exclusive gateway
331		this.activityDrawInstructions["exclusiveGateway"] = function(){
332			var activityImpl = this.activity;
333			var processDiagramCanvas = this.processDiagramCanvas;
334			processDiagramCanvas.setConextObject(activityImpl);
335			
336			processDiagramCanvas.drawExclusiveGateway(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
337		};
338		
339		// inclusive gateway
340		this.activityDrawInstructions["inclusiveGateway"] = function(){
341			var activityImpl = this.activity;
342			var processDiagramCanvas = this.processDiagramCanvas;
343			processDiagramCanvas.setConextObject(activityImpl);
344			
345			processDiagramCanvas.drawInclusiveGateway(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
346		};
347		
348		// parallel gateway
349		this.activityDrawInstructions["parallelGateway"] = function(){
350			var activityImpl = this.activity;
351			var processDiagramCanvas = this.processDiagramCanvas;
352			processDiagramCanvas.setConextObject(activityImpl);
353			
354			processDiagramCanvas.drawParallelGateway(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
355		};
356		
357		// eventBasedGateway
358		this.activityDrawInstructions["eventBasedGateway"] = function(){
359			var activityImpl = this.activity;
360			var processDiagramCanvas = this.processDiagramCanvas;
361			processDiagramCanvas.setConextObject(activityImpl);
362			
363			processDiagramCanvas.drawEventBasedGateway(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
364		};
365		
366		// Boundary timer
367		this.activityDrawInstructions["boundaryTimer"] = function(){
368			var activityImpl = this.activity;
369			var processDiagramCanvas = this.processDiagramCanvas;
370			processDiagramCanvas.setConextObject(activityImpl);
371			
372			var isInterrupting = activityImpl.getProperty("isInterrupting");
373			processDiagramCanvas.drawCatchingTimerEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), isInterrupting, null);
374			
375			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
376      if (label)
377        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
378		};
379		
380		// Boundary catch error
381		this.activityDrawInstructions["boundaryError"] = function(){
382			var activityImpl = this.activity;
383			var processDiagramCanvas = this.processDiagramCanvas;
384			processDiagramCanvas.setConextObject(activityImpl);
385			
386			var isInterrupting = activityImpl.getProperty("isInterrupting");
387			processDiagramCanvas.drawCatchingErrorEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), isInterrupting, null);
388			
389			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
390      if (label)
391        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
392		};
393		
394		// Boundary signal event
395		this.activityDrawInstructions["boundarySignal"] = function(){
396			var activityImpl = this.activity;
397			var processDiagramCanvas = this.processDiagramCanvas;
398			processDiagramCanvas.setConextObject(activityImpl);
399			
400			var isInterrupting = activityImpl.getProperty("isInterrupting");
401			processDiagramCanvas.drawCatchingSignalEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), isInterrupting, null);
402			
403			var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
404      if (label)
405        processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
406		};
407
408    // Boundary message event
409    this.activityDrawInstructions["boundaryMessage"] = function(){
410        var activityImpl = this.activity;
411        var processDiagramCanvas = this.processDiagramCanvas;
412        processDiagramCanvas.setConextObject(activityImpl);
413
414        var isInterrupting = activityImpl.getProperty("isInterrupting");
415        processDiagramCanvas.drawCatchingMessageEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), isInterrupting, null);
416
417        var label = ProcessDiagramGenerator.getActivitiLabel(activityImpl);
418        if (label)
419            processDiagramCanvas.drawLabel(label.text, label.x, label.y, label.width, label.height);
420    };
421		
422		// timer catch event
423		this.activityDrawInstructions["intermediateTimer"] = function(){
424			var activityImpl = this.activity;
425			var processDiagramCanvas = this.processDiagramCanvas;
426			processDiagramCanvas.setConextObject(activityImpl);
427			
428			var isInterrupting = null;
429			processDiagramCanvas.drawCatchingTimerEvent(activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight(), isInterrupting, activityImpl.getProperty("name"));
430		};
431		
432		// subprocess
433		this.activityDrawInstructions["subProcess"] = function(){
434			var activityImpl = this.activity;
435			var processDiagramCanvas = this.processDiagramCanvas;
436			// TODO: 
437			
438			processDiagramCanvas.setConextObject(activityImpl);
439			
440			var isExpanded = activityImpl.getProperty("isExpanded");
441			var isTriggeredByEvent = activityImpl.getProperty("triggeredByEvent");
442			if(isTriggeredByEvent == undefined) {
443			  isTriggeredByEvent = true;
444			}
445			// TODO: check why isTriggeredByEvent = true when undefined
446			isTriggeredByEvent = false;
447			
448			if (isExpanded != undefined && isExpanded == false) {
449			  processDiagramCanvas.drawCollapsedSubProcess(activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(),
450					  activityImpl.getWidth(), activityImpl.getHeight(), isTriggeredByEvent);
451			} else {
452			  processDiagramCanvas.drawExpandedSubProcess(activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(),
453					  activityImpl.getWidth(), activityImpl.getHeight(), isTriggeredByEvent);
454			}
455			
456			//console.error("subProcess is not implemented yet");
457		};
458		
459		// call activity
460		this.activityDrawInstructions["callActivity"] = function(){
461			var activityImpl = this.activity;
462			var processDiagramCanvas = this.processDiagramCanvas;
463			processDiagramCanvas.setConextObject(activityImpl);
464			processDiagramCanvas.drawCollapsedCallActivity(activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight());
465		};
466		
467		$(document).ready(function(){
468		  // Protect right click on SVG elements (and on canvas too)
469		  document.body.oncontextmenu = function(event) {
470		    if (window.event.srcElement.tagName == "shape" || window.event.srcElement.tagName == "DIV" && window.event.srcElement.parentElement.className == "diagram") {
471
472		      // IE DIAGRAM CANVAS OR SHAPE DETECTED!
473		      return false;
474		    }
475		    return (!Object.isSVGElement(window.event.srcElement));
476		  };
477		});
478	},
479	
480	 getActivitiLabel:function(activityImpl){
481	   /*
482	     TODO: Label object should be in activityImpl and looks like:
483	     {
484	       x: 250,
485	       y: 250,
486	       width: 80,
487	       height: 30
488	     }
489	     And then:
490	     if (!activityImpl.label)
491	       return null;
492	     var label = activityImpl.label;
493	     label.text = activityImpl.name;
494	     return label;
495	   */
496
497	   // But now default label for all events is:
498	   return {
499	     text: activityImpl.getProperty("name"),
500	     x: activityImpl.getX() + .5 + activityImpl.getWidth()/2,
501	     y: activityImpl.getY() + .5 + activityImpl.getHeight() + ICON_PADDING,
502	     width: 100,
503	     height: 0
504	   };
505	},
506		
507	generateDiagram: function(processDefinitionDiagramLayout){
508		// Init canvas
509		var processDefinitionId = processDefinitionDiagramLayout.processDefinition.id;
510		//console.log("Init canvas ", processDefinitionId);
511		
512		if (this.getProcessDiagram(processDefinitionId) != undefined) {
513			// TODO: may be reset canvas if exists.. Or just show
514			//console.log("ProcessDiagram '" + processDefinitionId + "' is already generated. Just show it.");
515			return;
516		}
517		var processDiagram = this.initProcessDiagramCanvas(processDefinitionDiagramLayout);
518		var processDiagramCanvas = processDiagram.diagramCanvas;
519		
520		// Draw pool shape, if process is participant in collaboration
521		
522		if(processDefinitionDiagramLayout.participantProcess != undefined) {
523		  //console.log("Draw pool shape");
524		  var pProc = processDefinitionDiagramLayout.participantProcess;
525		  processDiagramCanvas.drawPoolOrLane(pProc.x, pProc.y, pProc.width, pProc.height, pProc.name);
526		}
527		
528		var laneSets = processDefinitionDiagramLayout.laneSets;
529		var activities = processDefinitionDiagramLayout.activities;
530		var sequenceFlows = processDefinitionDiagramLayout.sequenceFlows;
531		
532		
533		pb1.set('value', 0);
534		var cnt = 0;
535		if (laneSets) 
536			for(var i in laneSets) {
537				cnt += laneSets[i].lanes.length;
538			}
539		if (activities) 
540			cnt += activities.length;
541		if (sequenceFlows) 
542			cnt += sequenceFlows.length;
543		var step = (cnt>0)? 100/cnt : 0;
544		var progress = 0;
545		//console.log("progress bar step: ", step);
546		
547		var task1 = new $.AsyncQueue();
548		
549			// Draw lanes
550			
551			task1.add(function (task1) {
552				if (!laneSets) laneSets = [];
553				//console.log("> draw lane sets, count:", laneSets.length)
554			});
555			
556			for(var i in laneSets) {
557				var laneSet = laneSets[i];
558				//laneSet.id, laneSet.name
559				
560				task1.add(laneSet.lanes,function (task1, lane) {
561					progress += step;
562					pb1.set('value', parseInt(progress));
563					
564					//console.log("--> laneId: " + lane.name + ", name: " + lane.name);
565					
566					processDiagramCanvas.drawPoolOrLane(lane.x, lane.y, lane.width, lane.height, lane.name);
567				});
568			}
569			
570			// Draw activities
571			
572			task1.add(function (task1) {
573				if (!activities) activities = [];
574				//console.log("> draw activities, count:", activities.length)
575			});
576			
577			var activitiesLength = activities.length;
578			task1.add(activities,function (task1, activityJson) {
579				var activity = new ActivityImpl(activityJson);
580				activitiesLength --;
581				progress += step;
582				pb1.set('value', parseInt(progress));
583				//console.log(activitiesLength, "--> activityId: " + activity.getId() + ", name: " + activity.getProperty("name"));
584				ProcessDiagramGenerator.drawActivity(processDiagramCanvas, activity);
585			});
586			
587			// Draw sequence-flows
588			
589			task1.add(function (task1) {
590				if (!sequenceFlows) sequenceFlows = [];
591				//console.log("> draw sequence flows, count:", sequenceFlows.length)
592			});
593			
594			var flowsLength = sequenceFlows.length;
595			task1.add(sequenceFlows,function (task1, flow) {
596				var waypoints = [];
597				for(var j in flow.xPointArray) {
598					waypoints[j] = {x: flow.xPointArray[j], y: flow.yPointArray[j]};
599				}
600				var isDefault = flow.isDefault;
601				var isConditional = flow.isConditional;
602				var isHighLighted = flow.isHighLighted;
603				
604				// TODO: add source and destination for sequence flows in REST
605				// parse for test
606					var f = flow.flow;
607					var matches = f.match(/\((.*)\)--.*-->\((.*)\)/);
608					var sourceActivityId, destinationActivityId;
609					if (matches != null) {
610						sourceActivityId = matches[1];
611						destinationActivityId = matches[2];
612					}
613					flow.sourceActivityId = sourceActivityId;
614					flow.destinationActivityId = destinationActivityId;
615				//
616				flowsLength--;
617				progress += step;
618				pb1.set('value', parseInt(progress));
619				
620				//console.log(flowsLength, "--> flow: " + flow.flow);
621				
622				processDiagramCanvas.setConextObject(flow);
623				processDiagramCanvas.drawSequenceflow(waypoints, isConditional, isDefault, isHighLighted);
624			});
625			
626			task1.onComplete(function(){
627				if (progress<100)
628					pb1.set('value', 100);
629				//console.log("COMPLETE!!!");
630					
631				//console.timeEnd('generateDiagram');
632			});
633			
634			task1.run();
635	},
636	
637	getProcessDiagram: function (processDefinitionId) {
638		return this.processDiagrams[processDefinitionId];
639	},
640	
641	initProcessDiagramCanvas: function (processDefinitionDiagramLayout) {
642		var minX = 0;
643		var maxX = 0;
644		var minY = 0;
645		var maxY = 0;
646		
647		if(processDefinitionDiagramLayout.participantProcess != undefined) {
648		  var pProc = processDefinitionDiagramLayout.participantProcess;
649		  
650		  minX = pProc.x;
651		  maxX = pProc.x + pProc.width;
652		  minY = pProc.y;
653		  maxY = pProc.y + pProc.height;
654		}
655
656		var activities = processDefinitionDiagramLayout.activities;
657		for(var i in activities) {
658			var activityJson = activities[i];
659			var activity = new ActivityImpl(activityJson);
660			
661			// width
662			if (activity.getX() + activity.getWidth() > maxX) {
663				maxX = activity.getX() + activity.getWidth();
664			}
665			if (activity.getX() < minX) {
666				minX = activity.getX();
667			}
668			// height
669			if (activity.getY() + activity.getHeight() > maxY) {
670				maxY = activity.getY() + activity.getHeight();
671			}
672			if (activity.getY() < minY) {
673				minY = activity.getY();
674			}
675		}
676		
677		var sequenceFlows = processDefinitionDiagramLayout.sequenceFlows;
678		for(var i in sequenceFlows) {
679			var flow = sequenceFlows[i];
680			var waypoints = [];
681			for(var j in flow.xPointArray) {
682				waypoints[j] = {x: flow.xPointArray[j], y: flow.yPointArray[j]};
683				
684				// width
685				if (waypoints[j].x > maxX) {
686					maxX = waypoints[j].x;
687				}
688				if (waypoints[j].x < minX) {
689					minX = waypoints[j].x;
690				}
691				// height
692				if (waypoints[j].y > maxY) {
693					maxY = waypoints[j].y;
694				}
695				if (waypoints[j].y < minY) {
696					minY = waypoints[j].y;
697				}
698			}
699		}
700		
701		var laneSets = processDefinitionDiagramLayout.laneSets;
702		for(var i in laneSets) {
703			var laneSet = laneSets[i];
704			//laneSet.id, laneSet.name
705			
706			for(var j in laneSet.lanes) {
707				var lane = laneSet.lanes[j];
708				// width
709				if (lane.x + lane.width > maxX) {
710				  maxX = lane.x + lane.width;
711				}
712				if (lane.x < minX) {
713				  minX = lane.x;
714				}
715				// height
716				if (lane.y + lane.height > maxY) {
717				  maxY = lane.y + lane.height;
718				}
719				if (lane.y < minY) {
720				  minY = lane.y;
721				}
722			}
723		}
724	
725		var diagramCanvas = new ProcessDiagramCanvas();
726		if (diagramCanvas) {
727			
728			// create div in diagramHolder
729			var diagramHolder = document.getElementById(this.options.diagramHolderId);
730			if (!diagramHolder)
731				throw {msg: "Diagram holder not found", error: "diagramHolderNotFound"};
732			var div = document.createElement("DIV");
733			div.id = processDefinitionDiagramLayout.processDefinition.id;
734			div.className = "diagram";
735			diagramHolder.appendChild(div);
736			
737			diagramCanvas.init(maxX + 20, maxY + 20, processDefinitionDiagramLayout.processDefinition.id);
738			this.processDiagrams[processDefinitionDiagramLayout.processDefinition.id] = {
739				processDefinitionDiagramLayout: processDefinitionDiagramLayout,
740				diagramCanvas: diagramCanvas
741			};
742		}
743		return this.getProcessDiagram(processDefinitionDiagramLayout.processDefinition.id);
744		//return new DefaultProcessDiagramCanvas(maxX + 10, maxY + 10, minX, minY);
745	},
746	
747	drawActivity: function(processDiagramCanvas, activity, highLightedActivities) {
748		var type = activity.getProperty("type");
749		var drawInstruction = this.activityDrawInstructions[type];
750		if (drawInstruction != null) {	
751			drawInstruction.apply({processDiagramCanvas:processDiagramCanvas, activity:activity});
752		} else {
753			//console.error("no drawInstruction for " + type + ": ", activity);
754		}
755		
756		// Actually draw the markers
757		if (activity.getProperty("multiInstance") != undefined || activity.getProperty("collapsed") != undefined) {
758			//console.log(activity.getProperty("name"), activity.properties);
759			var multiInstanceSequential = (activity.getProperty("multiInstance") == "sequential");
760			var multiInstanceParallel = (activity.getProperty("multiInstance") == "parrallel");
761			var collapsed = activity.getProperty("collapsed");
762				processDiagramCanvas.drawActivityMarkers(activity.getX(), activity.getY(), activity.getWidth(), activity.getHeight(), 
763					multiInstanceSequential, multiInstanceParallel, collapsed);
764		}
765		/*
766		processDiagramCanvas.drawActivityMarkers(activity.getX(), activity.getY(), activity.getWidth(), activity.getHeight(), multiInstanceSequential,
767              multiInstanceParallel, collapsed);
768		*/
769
770		// TODO: Draw highlighted activities if they are present
771		
772	},
773	
774	setHighLights: function(highLights){
775		if (highLights.processDefinitionId == undefined) {
776			//console.error("Process instance " + highLights.processInstanceId + " doesn't exist");
777			return;
778		}
779		
780		var processDiagram = this.getProcessDiagram(highLights.processDefinitionId);
781		if (processDiagram == undefined) {
782			//console.error("Process diagram " + highLights.processDefinitionId + " not found");
783			return;
784		}
785		
786		var processDiagramCanvas = processDiagram.diagramCanvas;
787		
788		// TODO: remove highLightes from all activities before set new highLight
789		for (var i in highLights.activities) {
790			var activityId = highLights.activities[i];
791			processDiagramCanvas.highLightActivity(activityId);
792		}
793		
794		// TODO: remove highLightes from all flows before set new highLight
795		for (var i in highLights.flows) {
796			var flowId = highLights.flows[i];
797			var object = processDiagramCanvas.g.getById(flowId);
798			var flow = object.data("contextObject");
799			flow.isHighLighted = true;
800			processDiagramCanvas.highLightFlow(flowId);
801		}
802	},
803	
804	drawHighLights: function(processInstanceId) {
805		// Load highLights for the processInstanceId
806		/*
807		var url = Lang.sub(this.options.processInstanceHighLightsUrl, {processInstanceId: processInstanceId});
808		$.ajax({
809			url: url,
810			type: 'GET',
811			dataType: 'json',
812			cache: false,
813			async: true,
814		}).done(function(data) {
815			var highLights = data;
816			if (!highLights) {
817				console.log("highLights not found");
818				return;
819			}
820			
821			console.log("highLights[" + highLights.processDefinitionId + "][" + processInstanceId + "]: ", highLights);
822			
823			ProcessDiagramGenerator.setHighLights(highLights);
824		}).fail(function(jqXHR, textStatus){
825			console.log('Get HighLights['+processDefinitionId+'] failure: ', textStatus, jqXHR);
826		});
827		*/
828		ActivitiRest.getHighLights(processInstanceId, this._drawHighLights);
829	},
830	_drawHighLights: function() {
831		var highLights = this.highLights;
832		ProcessDiagramGenerator.setHighLights(highLights);
833	},
834	
835	// Load processDefinition
836	
837	drawDiagram: function(processDefinitionId) {
838		// Hide all diagrams
839		var diagrams = $("#" + this.options.diagramHolderId + " div.diagram");
840		diagrams.addClass("hidden");
841	
842	
843		// If processDefinitionId doesn't contain ":" then it's a "processDefinitionKey", not an id.
844		// Get process definition by key
845		if (processDefinitionId.indexOf(":") < 0) {
846			ActivitiRest.getProcessDefinitionByKey(processDefinitionId, this._drawDiagram);
847		} else {
848			this._drawDiagram.apply({processDefinitionId: processDefinitionId});
849		}
850	},
851	_drawDiagram: function() {
852		var processDefinitionId = this.processDefinitionId;
853		
854		ProcessDiagramGenerator.addBreadCrumbsItem(processDefinitionId);
855		
856		
857		// Check if processDefinition is already loaded and rendered
858		
859		
860		var processDiagram = ProcessDiagramGenerator.getProcessDiagram(processDefinitionId);
861
862		if (processDiagram != undefined && processDiagram != null) {
863			//console.log("Process diagram " + processDefinitionId + " is already loaded");
864			//return;
865			
866			var diagram = document.getElementById(processDefinitionId);
867			$(diagram).removeClass("hidden");
868			
869			// Regenerate image
870			var processDefinitionDiagramLayout = processDiagram.processDefinitionDiagramLayout;
871			ProcessDiagramGenerator.generateDiagram(processDefinitionDiagramLayout);
872			
873			return;
874		}
875
876		//console.time('loadDiagram');
877		
878		// Load processDefinition
879		
880		ActivitiRest.getProcessDefinition(processDefinitionId, ProcessDiagramGenerator._generateDiagram);
881	},
882	_generateDiagram: function() {
883		var processDefinitionDiagramLayout = this.processDefinitionDiagramLayout;
884		
885		//console.log("process-definition-diagram-layout["+processDefinitionDiagramLayout.processDefinition.id+"]: ", processDefinitionDiagramLayout);
886		
887		//console.timeEnd('loadDiagram');
888		//console.time('generateDiagram');
889		
890		pb1.set('value', 0);
891		ProcessDiagramGenerator.generateDiagram(processDefinitionDiagramLayout);
892	},
893	
894	getProcessDefinitionByKey: function(processDefinitionKey) {
895		var url = Lang.sub(this.options.processDefinitionByKeyUrl, {processDefinitionKey: processDefinitionKey});
896		
897		var processDefinition;
898		$.ajax({
899			url: url,
900			type: 'POST',
901			dataType: 'json',
902			cache: false,
903			async: false
904		}).done(function(data) { 
905			//console.log("ajax returned data");
906			//console.log("ajax returned data:", data);
907			processDefinition = data;
908			if (!processDefinition) {
909				//console.error("Process definition '" + processDefinitionKey + "' not found");
910			}
911		}).fail(function(jqXHR, textStatus){
912			//console.error('Get diagram layout['+processDefinitionKey+'] failure: ', textStatus, jqXHR);
913		});
914		
915		if (processDefinition) {
916			//console.log("Get process definition by key '" + processDefinitionKey + "': ", processDefinition.id);
917			return processDefinition;
918		} else {
919			return null;
920		}
921	},
922	
923	addBreadCrumbsItem: function(processDefinitionId){
924		var TPL_UL_CONTAINER = '<ul></ul>',
925			TPL_LI_CONTAINER = '<li id="{id}", processDefinitionId="{processDefinitionId}"><span>{name}</span></li>';
926		
927		if (!this.diagramBreadCrumbs)
928			this.diagramBreadCrumbs = $("#" + this.options.diagramBreadCrumbsId);
929		if (!this.diagramBreadCrumbs) return;
930		
931		
932		var ul = this.diagramBreadCrumbs.find("ul");
933		//console.log("ul: ", ul);
934		if (ul.size() == 0) {
935			ul = $(TPL_UL_CONTAINER);
936			this.diagramBreadCrumbs.append(ul);
937			
938		}
939		var liListOld = ul.find("li");
940		//console.warn("liListOld", liListOld);
941		
942		// TODO: if there is any items after current then remove that before adding new item (m.b. it is a duplicate)
943		var currentBreadCrumbsItemId = this.currentBreadCrumbsItemId;
944			found = false;
945		liListOld.each(
946			function(index, item) {
947				//console.warn("item:", $(this));
948				if (!found && currentBreadCrumbsItemId == $(this).attr("id")) {
949					found = true;
950					return;
951				}
952				if (found) {
953					//console.warn("remove ", $(this).attr("id"));
954					$(this).remove();
955				}
956			}
957		);
958		
959		var liListNew = ul.find("li");
960		
961		//console.log("liListNew size: ", liListNew.size());
962		var values = {
963			id: 'breadCrumbsItem_' + liListNew.size(),
964			processDefinitionId: processDefinitionId,
965			name: processDefinitionId
966		};
967		
968		
969		var tpl = Lang.sub(TPL_LI_CONTAINER, values);
970		//console.log("tpl: ", tpl);
971		ul.append(tpl);
972		
973		var li = ul.find("#" + values.id);
974		//console.warn("li:", li);
975		$('#' + values.id).on('click', this._breadCrumbsItemClick);
976		
977		ul.find("li").removeClass("selected");
978		li.attr("num", liListNew.size());
979		li.addClass("selected");
980		this.currentBreadCrumbsItemId = li.attr("id");
981	},
982	_breadCrumbsItemClick: function(){
983		var li = $(this),
984			id = li.attr("id"),
985			processDefinitionId = li.attr("processDefinitionId");
986		//console.warn("_breadCrumbsItemClick: ", id, ", processDefinitionId: ", processDefinitionId);
987		
988		var ul = ProcessDiagramGenerator.diagramBreadCrumbs.one("ul");
989		ul.find("li").removeClass("selected");
990		li.addClass("selected");
991		ProcessDiagramGenerator.currentBreadCrumbsItemId = li.attr("id");
992		
993		// Hide all diagrams
994		var diagrams = $("#"+ProcessDiagramGenerator.options.diagramHolderId+" div.diagram");
995		diagrams.addClass("hidden");
996		
997		var processDiagram = ProcessDiagramGenerator.getProcessDiagram(processDefinitionId);
998		
999		var diagram = document.getElementById(processDefinitionId);
1000		if (!diagram) return;
1001		$(diagram).removeClass("hidden");
1002		
1003		// Regenerate image
1004		var processDefinitionDiagramLayout = processDiagram.processDefinitionDiagramLayout;
1005		ProcessDiagramGenerator.generateDiagram(processDefinitionDiagramLayout);
1006	},
1007	
1008	showFlowInfo: function(flow){
1009		var diagramInfo = $("#" + this.options.diagramInfoId);
1010		if (!diagramInfo) return;
1011		
1012		var values = {
1013			flow: flow.flow,
1014			isDefault: (flow.isDefault)? "true":"",
1015			isConditional: (flow.isConditional)? "true":"",
1016			isHighLighted: (flow.isHighLighted)? "true":"",
1017			sourceActivityId: flow.sourceActivityId,
1018			destinationActivityId: flow.destinationActivityId
1019		};
1020		var TPL_FLOW_INFO = '<div>{flow}</div>' 
1021				+ '<div><b>sourceActivityId</b>: {sourceActivityId}</div>'
1022				+ '<div><b>destinationActivityId</b>: {destinationActivityId}</div>'
1023				+ '<div><b>isDefault</b>: {isDefault}</div>'
1024				+ '<div><b>isConditional</b>: {isConditional}</div>'
1025				+ '<div><b>isHighLighted</b>: {isHighLighted}</div>';
1026		var tpl = Lang.sub(TPL_FLOW_INFO, values);
1027		//console.log("info: ", tpl);
1028		diagramInfo.html(tpl);
1029	},
1030	
1031	showActivityInfo: function(activity){
1032		var diagramInfo = $("#" + this.options.diagramInfoId);
1033		if (!diagramInfo) return;
1034		
1035		var values = {
1036			activityId: activity.getId(),
1037			name: activity.getProperty("name"),
1038			type: activity.getProperty("type")
1039		};
1040		var TPL_ACTIVITY_INFO = '' 
1041				+ '<div><b>activityId</b>: {activityId}</div>'
1042				+ '<div><b>name</b>: {name}</div>'
1043				+ '<div><b>type</b>: {type}</div>';
1044		var TPL_CALLACTIVITY_INFO = ''
1045				+ '<div><b>collapsed</b>: {collapsed}</div>'
1046				+ '<div><b>processDefinitonKey</b>: {processDefinitonKey}</div>';
1047		
1048		var template = TPL_ACTIVITY_INFO;
1049		if (activity.getProperty("type") == "callActivity") {
1050			values.collapsed = activity.getProperty("collapsed");
1051			values.processDefinitonKey = activity.getProperty("processDefinitonKey");
1052			template += TPL_CALLACTIVITY_INFO;
1053		} else if (activity.getProperty("type") == "callActivity") {
1054		
1055		}
1056				
1057		var tpl = Lang.sub(template, values);
1058		//console.log("info: ", tpl);
1059		diagramInfo.html(tpl);
1060	},
1061	
1062	hideInfo: function(){
1063	  var diagramInfo = $("#" + this.options.diagramInfoId);
1064	  if (!diagramInfo) return;
1065	  diagramInfo.html("");
1066	},
1067	
1068	vvoid: function(){}
1069};
1070
1071var Lang = {
1072	SUBREGEX: /\{\s*([^\|\}]+?)\s*(?:\|([^\}]*))?\s*\}/g,
1073	UNDEFINED: 'undefined',
1074	isUndefined: function(o) {
1075		return typeof o === Lang.UNDEFINED;
1076	},
1077	sub: function(s, o) {
1078		return ((s.replace) ? s.replace(Lang.SUBREGEX, function(match, key) {
1079			return (!Lang.isUndefined(o[key])) ? o[key] : match;
1080		}) : s);
1081	}
1082};
1083
1084if (Lang.isUndefined(console)) {
1085    console = { log: function() {}, warn: function() {}, error: function() {}};
1086}
1087ProcessDiagramGenerator.init();
Full Screen

docker.js

Source: docker.js Github

copy
1/**
2 * Docker environment settings
3 */
4
5module.exports = {
6
7  models: {
8    connection: 'postgresql',
9    migrate: 'alter'
10  },
11
12  port: 80,
13
14  log: {
15    level: process.env['LOG_LEVEL']
16  },
17
18  auth: {
19    static: {
20      username: process.env['APP_USERNAME'],
21      password: process.env['APP_PASSWORD']
22    }
23  },
24  appUrl: process.env['APP_URL'],
25  connections: {
26    postgresql: {
27      adapter: 'sails-postgresql',
28      host: process.env['DB_HOST'] || process.env['DATABASE_URL'] && process.env['DATABASE_URL'].split('@')[1].split(':')[0],
29      port: process.env['DB_PORT'] || process.env['DATABASE_URL'] && process.env['DATABASE_URL'].split('@')[1].split(':')[1].split('/')[0],
30      user: process.env['DB_USERNAME'] || process.env['DATABASE_URL'] && process.env['DATABASE_URL'].split('@')[0].split(':')[1].split('/')[2],
31      password: process.env['DB_PASSWORD'] || process.env['DATABASE_URL'] && process.env['DATABASE_URL'].split('@')[0].split(':')[2],
32      database: process.env['DB_NAME'] || process.env['DATABASE_URL'] && process.env['DATABASE_URL'].split('/')[3]
33    }
34  },
35  jwt: {
36    // Recommended: 63 random alpha-numeric characters
37    // Generate using: https://www.grc.com/passwords.htm
38    token_secret: process.env['TOKEN_SECRET'],
39  },
40  files: {
41    dirname: process.env['ASSETS_PATH'] || '/tmp/',
42  },
43  session: {
44    // Recommended: 63 random alpha-numeric characters
45    // Generate using: https://www.grc.com/passwords.htm
46    token_secret: process.env['TOKEN_SECRET'],
47    database: process.env['DB_NAME'] || process.env['DATABASE_URL'] && process.env['DATABASE_URL'].split('/')[3],
48    host: process.env['DB_HOST'] || process.env['DATABASE_URL'] && process.env['DATABASE_URL'].split('@')[1].split(':')[0],
49    user: process.env['DB_USERNAME'] || process.env['DATABASE_URL'] && process.env['DATABASE_URL'].split('@')[0].split(':')[1].split('/')[2],
50    password: process.env['DB_PASSWORD'] || process.env['DATABASE_URL'] && process.env['DATABASE_URL'].split('@')[0].split(':')[2],
51    port: process.env['DB_PORT'] || process.env['DATABASE_URL'] && process.env['DATABASE_URL'].split('@')[1].split(':')[1].split('/')[0]
52  }
53
54};
55
Full Screen

desktop.widgets.admin.adhoc.processes.js

Source: desktop.widgets.admin.adhoc.processes.js Github

copy
1/**
2 * Admin module to manage adhoc processes
3 *
4 * @author Jose Aranzazu
5 */
6adhoc.processes.admin.authorization.extend("bizagi.workportal.widgets.admin.adhoc.processes", {}, {
7    /*
8	 *   Returns the widget name
9	 */
10    getWidgetName: function () {
11        return bizagi.workportal.widgets.widget.BIZAGI_WORKPORTAL_WIDGET_ADMIN_ADHOC_PROCESSES;
12    },
13
14    init: function (workportalFacade, dataService, params) {
15
16        var self = this;
17
18        // Call base
19        self._super(workportalFacade, dataService, params);
20
21        //Pagination data
22        self.filterData = {};
23        self.maxRows = 8;
24        self.maxPages = 10;
25        self.$canvas = params.canvas;
26        self.users = [];
27        self.totalPages = 0;
28        self.currentPage = 1;
29        self.orderType = "ASC";
30        self.orderField = "";
31        self.tableHeaders = [
32            { "displayName": self.getResource("workportal-widget-adhoc-process-table-name"), "fieldValue": "displayName" },
33            { "displayName": self.getResource("workportal-widget-adhoc-process-table-creation-date"), "fieldValue": "displayCreationDate" },
34            { "displayName": self.getResource("workportal-widget-adhoc-process-table-state"), "fieldValue": "state" }
35        ];
36
37        self.adhocProcessLinks = [
38            {
39                name: "edition",
40                label: bizagi.localization.getResource("bz-rp-components-dimension-edit"),
41                icon: "bz-icon-cog-outline",
42                alwaysShow: true
43            },
44            {
45                name: "workflow",
46                label: bizagi.localization.getResource("workportal-widget-admin-alarms-task-table-title-workflow"),
47                icon: "bz-icon-diagram-outline",
48                alwaysShow: true
49            },
50            {
51                name: "clone",
52                label: bizagi.localization.getResource("workportal-adhoc-process-clone-button"),                
53                icon: "bz-icon-window-create-outline",
54                alwaysShow: false
55            },
56            {
57                name: "delete",
58                label: bizagi.localization.getResource("bz-rp-components-dimension-delete"),
59                icon: "bz-icon-trash",
60                alwaysShow: false
61            },
62            {
63                name: "auth",
64                label: bizagi.localization.getResource("workportal-adhoc-process-authorization-button"),
65                icon: "bz-icon-authentication-outline",
66                alwaysShow: false
67            }
68        ];    
69
70        self.stateList = [
71            { id: "", displayName: "----------------" },
72            { id: "Draft", displayName: "Draft" },
73            { id: "Pilot", displayName: "Pilot" },
74            { id: "Published", displayName: "Published" }
75        ];
76
77        self.allowCreation = true;        
78
79        self.adhocProcesses = [];              
80
81        //Load templates
82        self.loadTemplates({
83            "admin.adhoc.processes": bizagi.getTemplate("bizagi.workportal.desktop.widgets.admin.adhoc.processes").concat("#ui-bizagi-workportal-widget-admin-adhoc-processes"),
84            "admin.adhoc.processes.formbuttons": bizagi.getTemplate("bizagi.workportal.desktop.widgets.admin.adhoc.processes").concat("#ui-bizagi-workportal-widget-admin-adhoc-processes-formbuttons"),
85            "admin.adhoc.processes.wrapper": bizagi.getTemplate("bizagi.workportal.desktop.widgets.admin.adhoc.processes").concat("#ui-bizagi-workportal-widget-admin-adhoc-processes-wrapper"),
86            "admin.adhoc.processes.query.form": bizagi.getTemplate("bizagi.workportal.desktop.widgets.admin.adhoc.processes").concat("#ui-bizagi-workportal-widget-admin-adhoc-processes-query-form"),            
87            "admin.adhoc.processes.table": bizagi.getTemplate("bizagi.workportal.desktop.widgets.admin.adhoc.processes").concat("#ui-bizagi-workportal-widget-admin-adhoc-processes-table"),
88            "admin.adhoc.processes.message": bizagi.getTemplate("bizagi.workportal.desktop.widgets.admin.adhoc.processes").concat("#ui-bizagi-workportal-widget-admin-adhoc-processes-message"),
89            "admin.adhoc.processes.create.popup": bizagi.getTemplate("bizagi.workportal.desktop.widgets.admin.adhoc.processes").concat("#adhoc-process-popup-template"),
90            "admin.adhoc.processes.edit.popup": bizagi.getTemplate("bizagi.workportal.desktop.widgets.admin.adhoc.processes").concat("#ui-bizagi-workportal-widget-admin-adhoc-processes-edit-form"),
91            useNewEngine: false
92        });
93    },    
94
95    /*
96	 *   Renders the content for the current controller
97	 */
98    renderContent: function () {
99        var self = this;
100        var tmpl = self.getTemplate("admin.adhoc.processes");
101        self.content = $.tmpl(tmpl);
102        return self.content;
103    },
104
105    postRender: function () {
106        var self = this;
107
108        self.dateFormat = self.getResource("dateFormat") + " " + self.getResource("timeFormat");
109        self.$adhocProcessTable = $("#bz-wp-widget-admin-adhoc-process-table", self.content);
110        self.$processModelerCanvas = $("#bz-wp-widget-admin-adhoc-process-renderform", self.content);
111        self.$formModelerCanvas = $("#bz-wp-widget-admin-adhoc-process-form-modeler", self.content);
112        self.$buttonsContainer = $("#bz-wp-widget-admin-adhoc-process-buttonset", self.content);        
113
114        $.when(self.dataService.getAllCategories()).done(function (rps) {
115            self.catList = $.parseJSON(rps);
116            self.catList.unshift({ categoryName: "----------------", guidCategory: "" });
117            self.renderQueryForm();
118        }).fail(function (error) {
119            bizagi.log(error);
120        });        
121
122        //add event handlers
123        self.addEventsHandler();
124    },
125
126    /**
127     * Render user table
128     */
129    renderQueryForm: function () {
130        var self = this;
131        var queryFormTemplate = $.tmpl(self.getTemplate("admin.adhoc.processes.query.form"), { catList: self.catList.length });
132        var wrapperFormFormTemplate = $.tmpl(self.getTemplate("admin.adhoc.processes.wrapper"), {});
133        $("#biz-wp-admin-adhoc-processes-wrapperform", wrapperFormFormTemplate).html(queryFormTemplate);
134        $("#bz-wp-widget-admin-adhoc-process-table", self.content).html(wrapperFormFormTemplate);            
135        self.setupPredefinedCombo(queryFormTemplate.find("#biz-wp-admin-adhoc-processes-state"), self.stateList, self.stateList[0]);
136        self.setupCatCombo(queryFormTemplate.find("#biz-wp-admin-adhoc-processes-cat"), self.catList, self.catList[0]);   
137        self.setupFormEventsHandler();
138        self.renderButtons("query");      
139    },
140
141    /**
142     * Events Handlers
143     */
144    addEventsHandler: function () {
145        var self = this;
146
147        self.$adhocProcessTable.on("click", "#bz-wp-widget-admin-adhocprocess-createbutton-wrapper", function () {
148            self.adhocProcessData = {};            
149            self.showPopupCreateProcess();
150        });
151
152        var $btnBack = $("#bz-wp-widget-admin-adhoc-process-buttonset", self.content);
153        $btnBack.on("click", "button", function () {
154            if(self.workflowView.formModeler && self.workflowView.formModeler.editor && self.workflowView.formModeler.editor.controller.thereAreChangesInForm()){
155                $.when(bizagi.showConfirmationBox(bizagi.localization.getResource("confirmation-savebox-message2"), "", "info")).done(function () {
156                    self.returnToContainer($("button", $btnBack).data("backto"));
157                });
158            }
159            else{
160                self.returnToContainer($(this).data("backto"));
161            }
162        });       
163
164    },
165
166    setupFormEventsHandler: function () {
167        var self = this;            
168        var $adhocProcessForm = $("#biz-wp-admin-adhoc-processes-wrapperform form", self.content);
169
170        $adhocProcessForm.on("submit", function (e) {
171
172            e.preventDefault();
173
174            self.currentPage = 1;
175            self.orderType = "DES";
176            self.orderField = "displayCreationDate";
177
178            self.filterData = {
179                filter: {},
180                pag: self.currentPage,
181                pagSize: self.maxRows,
182                orderField: self.orderField,
183                orderType: self.orderType
184            };
185
186            if (this.elements[0].value.length > 0) self.filterData.filter.displayName = this.elements[0].value;
187            if ($(this.elements[1]).data('value') != "") self.filterData.filter.state = $(this.elements[1]).data('value');
188            if ($(this.elements[2]).data('value') != "") self.filterData.filter.category = $(this.elements[2]).data('value');
189
190            self.getAdhocProcessTableData();
191
192        });
193
194        $adhocProcessForm.on("reset", function (event) {
195            event.preventDefault();
196            this.elements[0].value = "";
197            $(this.elements[1]).data("value", "").val("----------------");
198            $(this.elements[2]).data("value", "").val("----------------");
199            $("#biz-wp-admin-adhoc-processes-wrapperlist", self.content).empty();
200        });
201
202    },
203
204    /*
205    * Get adhoc processes table data
206    */
207    getAdhocProcessTableData: function (args) {
208        var self = this;
209
210        var params = args || {};
211        self.orderType = params.orderType || self.orderType;
212        self.orderField = params.orderField || self.orderField;
213
214        $.when(self.dataService.getAdhocProcessesList($.extend(self.filterData, params))).done(function (data) {
215
216            self.adhocProcesses = data.adhocProcesses;
217            self.totalPages = data.total;
218
219            self.showAdhocProcessesTable();
220            self.setAdhocProcessActions();
221
222        }).fail(function (error) {
223            bizagi.log(error);
224        });
225    },
226
227    showAdhocProcessesTable: function () {
228
229        var self = this;
230        var $wrapperList = $("#biz-wp-admin-adhoc-processes-wrapperlist", self.content);
231
232        $wrapperList.empty();
233
234        if (self.adhocProcesses.length > 0) {
235
236            var pagination = (self.totalPages > 1);
237            var pagesArray = self.getPagesArray();
238
239            var links = self.adhocProcessLinks && Object.prototype.toString.apply(self.adhocProcessLinks) === "[object Array]" ? self.adhocProcessLinks : [self.adhocProcessLinks];
240
241            var adhocProcessTableTmpl = $.tmpl(self.getTemplate("admin.adhoc.processes.table"), { adhocProcesses: self.adhocProcesses, headers: self.tableHeaders, links: links, page: self.currentPage, pagination: pagination, pagesArray: pagesArray, orderField: self.orderField, orderType: self.orderType });
242            $wrapperList.html(adhocProcessTableTmpl);
243
244            self.setUpPagination();
245            self.setUpSortColumnLinks();
246        } else {
247            var msg = bizagi.localization.getResource("workportal-widget-usertable-empty");
248            $wrapperList.html($.tmpl(self.usersTableMessage, { message: msg }));
249        }
250    },
251
252    /*
253    * Get Pages
254    */
255    getPagesArray: function () {
256
257        var self = this;
258        var pagesToShow = (self.maxPages > self.totalPages) ? self.totalPages : self.maxPages;
259        var aux = [];
260
261        for (var a = 0; a < pagesToShow; a++) {
262            aux.push(a + 1);
263        }
264
265        return aux;
266    },
267
268    /*
269    * Set pagination
270    */
271    setUpPagination: function () {
272        var self = this;
273        var $pager = $("#biz-wp-admin-adhoc-processes-pager ul", self.content);
274
275        $pager.bizagiPagination({
276            maxElemShow: self.maxRows,
277            totalPages: self.totalPages,
278            actualPage: self.currentPage,
279            listElement: $pager,
280            clickCallBack: function (options) {
281                self.filterData.pag = self.currentPage = parseInt(options.page);
282                self.getAdhocProcessTableData();
283            }
284        });
285
286    },
287
288    /*
289    * assign click event to each column to order
290    */
291    setUpSortColumnLinks: function () {
292        var self = this;
293
294        $(".biz-wp-table-head th", self.content).click(function () {
295
296            var orderField = $(this).data("orderfield");
297            var orderType = $(this).data("ordertype");
298
299            self.getAdhocProcessTableData({ "orderType": orderType, "orderField": orderField });
300            self.setAdhocProcessActions();
301        });
302
303    },
304
305    setAdhocProcessActions: function () {
306        var self = this;
307
308        $(".bizagi-wp-admin-adhoc-processes-link", self.content).click(function (e) {            
309            var idSelectedProcess = this.id;
310
311            if (!self.currentProcess || self.currentProcess.id != idSelectedProcess) {
312                self.currentProcess = self.adhocProcesses.filter(function (process) {
313                    return process.id === idSelectedProcess;
314                })[0];
315            }
316
317            switch ($(this).data("linkname")) {
318                case "edition": self.showPopupEditAdhocProcess();
319                    break;
320                case "delete": self.deleteAdhocProcess();
321                    break;
322                case "workflow": self.renderAdhocProcessEditor();
323                    break;
324                case "clone": self.cloneAdhocProcess();
325                    break;
326                case "auth": self.showPopupAuthAdhocProcess();                    
327                    break;
328            }
329        });
330    },
331
332    /**
333     * Return to adhoc process table to query processes
334     */
335    returnToContainer: function (container) {
336        var self = this;
337        self.toggleForm(container);                
338    },
339
340    /**
341     * Remove Buttons
342     */
343    removeButtons: function () {
344        var self = this;
345        self.$buttonsContainer.empty();
346    },
347
348    /**
349     * Render form button
350     */
351    renderButtons: function (type, backTo) {
352        var self = this;
353        var tmpl = self.getTemplate("admin.adhoc.processes.formbuttons");
354        var $button = $.tmpl(tmpl, { type: type, allowCreation: self.allowCreation, backTo: backTo });
355
356        if (type === "query") {
357            $("#bz-wp-widget-admin-adhoc-process-table #admin-adhoc-processes-table-buttonset", self.content).append($button);
358        }
359        else {
360            self.$buttonsContainer.html($button);
361        }
362    },
363
364    /**
365     * Change form display
366     */
367    toggleForm: function (display) {
368        var self = this;
369        self.removeButtons();
370        switch (display) {
371            case "table":
372                self.getAdhocProcessTableData();
373                self.$adhocProcessTable.show();
374                self.$processModelerCanvas.hide();
375                self.$processModelerCanvas.empty();
376                self.$formModelerCanvas.hide();                
377                self.currentProcess = null;
378                break;
379            case "form":
380                self.$adhocProcessTable.hide();                
381                self.$formModelerCanvas.hide();                
382                self.$processModelerCanvas.show();
383                self.renderButtons("back", "table");
384                break;
385            case "modeler":
386                self.$adhocProcessTable.hide();
387                self.$processModelerCanvas.hide();
388                self.$formModelerCanvas.show();
389                self.renderButtons("back", "form");
390                break;
391        }
392    },
393
394    /**
395     * Render Adhoc Process form
396     */
397    renderAdhocProcessEditor: function () {
398        var self = this;
399        self.$processModelerCanvas.empty();
400
401        self.workflowView = new adhoc.processes.workflow(self.workportalFacade, self.dataService, { adhocProcessInfo: self.currentProcess, formModelerCanvas: self.$formModelerCanvas });
402        self.workflowView.render(self.$processModelerCanvas);
403
404        self.subscribe("refreshAdhocProcessesCanvas", function (e, params) {
405            self.toggleForm(params.canvasName);
406        });
407
408        self.toggleForm("form");        
409    },
410
411    deleteAdhocProcess: function () {
412        var self = this;        
413        $.when(bizagi.showConfirmationBox(bizagi.localization.getResource("workportal-adhoc-process-delete-confirmation"), "", "info")).done(function () {
414            $.when(self.dataService.deleteAdhocProcess(self.currentProcess.id)).done(function () {
415                self.currentProcess = null;
416                self.getAdhocProcessTableData();
417            });
418        });
419    },
420
421    cloneAdhocProcess: function () {
422        var self = this;
423
424        $.when(bizagi.showConfirmationBox(bizagi.localization.getResource("workportal-adhoc-process-clone-confirmation"), "", "info")).done(function () {        
425            $.when(self.dataService.cloneAdhocProcess(self.currentProcess)).done(function () {                
426                self.getAdhocProcessTableData();
427            });
428        });      
429    },
430
431    setupPredefinedCombo: function (element, data, initValue) {
432        element.uicombo({
433            data: { combo: data },
434            initValue: initValue,
435            itemValue: function (item) {
436                return item.id;
437            },
438            itemText: function (item) {
439                return item.displayName;
440            },
441            onChange: function (obj) {
442                var value = obj.ui.data('value');
443                element.val(value);
444            }
445        });
446    },
447
448    setupCatCombo: function (element, data, initValue) {                
449        element.uicombo({
450            data: { combo: data },
451            initValue: initValue,
452            itemValue: function (item) {
453                return item.guidCategory;                
454            },
455            itemText: function (item) {
456                return item.categoryName;                
457            },
458            onChange: function (obj) {
459                var value = obj.ui.data('value');
460                element.val(value);
461            }
462        });        
463    },
464
465    showPopupCreateProcess: function () {
466        var self = this, template = self.getTemplate("admin.adhoc.processes.create.popup");
467        var createProcessPopup = {};
468        createProcessPopup.formContent = $.tmpl(template);
469        createProcessPopup.elements = {
470            inputName: $("#input-name-adhoc-process", createProcessPopup.formContent),
471            buttonSave: $("#button-accept-create-adhoc-process", createProcessPopup.formContent),
472            buttonCancel: $("#button-cancel-create-adhoc-process", createProcessPopup.formContent)
473        };
474        createProcessPopup.elements.buttonSave.on("click", $.proxy(self.onCreateProcess, self, createProcessPopup));
475        createProcessPopup.elements.buttonCancel.on("click", $.proxy(self.closeDialogBox, self, createProcessPopup.formContent));
476               
477        createProcessPopup.formContent.dialog({
478            resizable: false,
479            draggable: false,
480            height: "auto",
481            width: "600px",
482            modal: true,
483            title: bizagi.localization.getResource("workportal-adhoc-process-create-popup-title"),
484            maximize: false,
485            close: function () {
486                createProcessPopup.formContent.dialog("destroy");
487                createProcessPopup.formContent.detach();
488            }
489        });
490    },
491
492    showPopupEditAdhocProcess: function () {
493        var self = this, template = self.getTemplate("admin.adhoc.processes.edit.popup");
494        var editProcessPopup = {};
495        editProcessPopup.formContent = $.tmpl(template);
496        editProcessPopup.elements = {
497            inputName: $("#input-name-adhoc-process", editProcessPopup.formContent),
498            inputDesc: $("#input-desc-adhoc-process", editProcessPopup.formContent),
499            inputCat: $("#input-cat-adhoc-process", editProcessPopup.formContent),
500            inputState: $("#input-state-adhoc-process", editProcessPopup.formContent),
501            inputAlarms: $("#input-alarms-adhoc-process", editProcessPopup.formContent),
502            inputCaseNumber: $("#input-case-number-adhoc-process", editProcessPopup.formContent),
503            inputCaseNumberPreffix: $("#input-case-number-preffix", editProcessPopup.formContent),
504            inputCaseNumberSuffix: $("#input-case-number-suffix", editProcessPopup.formContent),
505            validator: $("#input-case-number-validator", editProcessPopup.formContent),
506            buttonSave: $("#button-accept-edit-adhoc-process", editProcessPopup.formContent),
507            buttonCancel: $("#button-cancel-edit-adhoc-process", editProcessPopup.formContent)
508        };
509        editProcessPopup.elements.buttonSave.on("click", $.proxy(self.onEditAdhocProcess, self, editProcessPopup));
510        editProcessPopup.elements.buttonCancel.on("click", $.proxy(self.closeDialogBox, self, editProcessPopup.formContent));
511
512        editProcessPopup.elements.inputCaseNumber.change(function () {
513            $('.case-number-container', editProcessPopup.formContent).toggle(this.checked);
514        }).change();
515
516        editProcessPopup.elements.inputCat.html('');
517
518        var initValue = self.catList[0];
519        if (self.currentProcess.category && self.currentProcess.category != null) {
520            initValue = self.catList.filter(function (cat) {
521                return cat.guidCategory === self.currentProcess.category;
522            })[0];
523        }
524        
525        self.setupCatCombo(editProcessPopup.elements.inputCat, self.catList, initValue);
526
527        editProcessPopup.elements.inputName.val(self.currentProcess.displayName);
528        editProcessPopup.elements.inputDesc.val(self.currentProcess.description);
529        editProcessPopup.elements.inputCat.val(self.currentProcess.category);
530        editProcessPopup.elements.inputState.html(self.currentProcess.state);
531        if (self.currentProcess.enableAlarms) editProcessPopup.elements.inputAlarms.attr('checked', true);
532        if (self.currentProcess.enableCustomizedCaseNumber) {
533            editProcessPopup.elements.inputCaseNumber.attr('checked', true);
534            editProcessPopup.elements.inputCaseNumberPreffix.val(self.currentProcess.caseNumberSequence.prefix);
535            editProcessPopup.elements.inputCaseNumberSuffix.val(self.currentProcess.caseNumberSequence.suffix);
536            $('.case-number-container', editProcessPopup.formContent).show();
537        } else {
538            $('.case-number-container', editProcessPopup.formContent).hide();
539        }
540
541        editProcessPopup.formContent.dialog({
542            resizable: false,
543            draggable: false,
544            height: "auto",
545            width: "600px",
546            modal: true,
547            title: bizagi.localization.getResource("workportal-adhoc-process-popup-title"),
548            maximize: false,
549            close: function () {
550                editProcessPopup.formContent.dialog("destroy");
551                editProcessPopup.formContent.detach();
552            }
553        });
554    },
555
556    showPopupAuthAdhocProcess: function () {
557        var self = this, template = self.getTemplate("adhoc.processes.authorization.editor.popup");
558
559        var formContent = $.tmpl(template, {});
560
561        if (self.currentProcess.authorization == null || !self.currentProcess.authorization[0].allowTo) {
562            self.currentProcess.authorization = [{ id: Math.guid(), allowTo: [] }];
563        }
564
565        self.renderAuthorizationItems($("#authorizationItems", formContent), self.currentProcess.id, self.currentProcess.authorization[0], false);
566
567        this.unsubscribe("refreshAuthItems");
568        this.subscribe("refreshAuthItems", function (e, params) {
569            $("#authorizationItems", formContent).empty();
570            self.currentProcess.authorization[0] = params.auth;
571            self.renderAuthorizationItems($("#authorizationItems", formContent), self.currentProcess.id, params.auth, false);
572        });
573
574        formContent.dialog({
575            resizable: false,
576            draggable: false,
577            height: "auto",
578            width: "615px",
579            modal: true,
580            title: bizagi.localization.getResource("workportal-adhoc-process-auth-popup-title"),
581            maximize: false,
582            close: $.proxy(self.closeDialogBox, self, formContent)
583        });
584    },
585
586    onCreateProcess: function (dialogBox, event) {
587        event.preventDefault();
588        var self = this;
589        if (self.validateParams(dialogBox)) {
590            var paramsNewProcess = {                
591                id: Math.guid(),
592                displayName: dialogBox.elements.inputName.val(),
593                state: "Draft",                                
594                activities: []
595            };
596            $.when(self.dataService.createAdhocProcess(paramsNewProcess)).done(function (data) {
597                self.currentProcess = data;
598                self.adhocProcesses.push(data);
599                self.closeDialogBox(dialogBox.formContent);
600                self.notifier.showSucessMessage(printf(bizagi.localization.getResource("workportal-adhoc-process-created"), ""));
601                self.renderAdhocProcessEditor(paramsNewProcess.id);
602            }).fail(function (error) {
603                bizagi.log(error);
604            });           
605        }
606    },
607
608    onEditAdhocProcess: function (dialogBox, event) {
609        event.preventDefault();
610        var self = this;
611        if (self.validateParams(dialogBox)) {
612            self.currentProcess.displayName = dialogBox.elements.inputName.val();
613            self.currentProcess.description = dialogBox.elements.inputDesc.val();
614            self.currentProcess.category = dialogBox.elements.inputCat.val();
615            self.currentProcess.enableAlarms = dialogBox.elements.inputAlarms.is(":checked");
616            if (dialogBox.elements.inputCaseNumber.is(":checked")) {
617                self.currentProcess.enableCustomizedCaseNumber = true;
618                if (self.currentProcess.caseNumberSequence != null) {
619                    self.currentProcess.caseNumberSequence.prefix = dialogBox.elements.inputCaseNumberPreffix.val();
620                    self.currentProcess.caseNumberSequence.suffix = dialogBox.elements.inputCaseNumberSuffix.val();
621                } else {
622                    self.currentProcess.caseNumberId = Math.guid();
623                    self.currentProcess.caseNumberSequence = {
624                        id: self.currentProcess.caseNumberId,
625                        prefix: dialogBox.elements.inputCaseNumberPreffix.val(),
626                        suffix: dialogBox.elements.inputCaseNumberSuffix.val()
627                    };
628                }
629            } else {
630                self.currentProcess.enableCustomizedCaseNumber = false;
631            }
632            $.when(self.dataService.updateAdhocProcess(self.currentProcess)).done(function () {
633                self.closeDialogBox(dialogBox.formContent);
634                self.notifier.showSucessMessage(printf(bizagi.localization.getResource("workportal-adhoc-process-saved"), ""));
635                self.getAdhocProcessTableData();                
636            }).fail(function (error) {
637                bizagi.log(error);
638            });
639        }
640    },
641
642    validateParams: function (dialogBox) {
643        var self = this;
644        var isValidForm = true;
645        var name = dialogBox.elements.inputName;
646        if (name.val() && name.val() !== "") {
647            isValidForm = true;
648        } else {
649            var nameValidation = bizagi.localization.getResource("workportal-general-error-field-required");
650            nameValidation = nameValidation.replace("{0}", "Name");
651            name.next().find("span").html(nameValidation);
652            isValidForm = false;
653        }
654        if (dialogBox.elements.inputCaseNumber && dialogBox.elements.inputCaseNumber.is(":checked")) {
655            if (dialogBox.elements.inputCaseNumberPreffix.val() !== "" || dialogBox.elements.inputCaseNumberSuffix.val() !== "") {
656                isValidForm = true;
657            } else {
658                var caseNumberValidation = bizagi.localization.getResource("workportal-general-error-field-required");
659                caseNumberValidation = nameValidation.replace("{0}", "Preffix/Suffix");                
660                dialogBox.elements.validator.find("span").html(caseNumberValidation);
661                isValidForm = false;
662            }
663        }
664        return isValidForm;
665    },
666
667    dispose: function () {
668        var self = this;
669        if (bizagi.rendering) {
670            // Unbind resize handlers
671            $(window).unbind("resize.windowPanel");
672            $(window).unbind("resize.rendering");
673
674            self.restoreMethod('container', 'postRenderContainer');
675            self.restoreMethod('group', 'postRenderContainer');
676            self.restoreMethod('contentPanel', 'postRenderContainer');
677            self.restoreMethod('tab', 'postRenderContainer');
678            self.restoreMethod('form', 'postRenderContainer');
679
680            self.restoreMethod('render', 'postRenderElement');
681            self.restoreMethod('search', 'postRender');
682            self.restoreMethod('imageNoFlash', 'postRender');
683            self.restoreMethod('collectionnavigator', 'postRender');
684        }
685        if (self.workflowView) self.workflowView.dispose();
686        self._super();
687    },
688
689    restoreMethod: function (clazz, method, useBackup) {
690        var self = this;
691        if (bizagi.rendering.form.editorInstance) {
692            bizagi.rendering[clazz].prototype[method] = function () {
693                if (useBackup) {
694                    return bizagi.rendering[clazz].editorInstance[method].apply(this, arguments);
695                } else {
696                    return bizagi.rendering[clazz].original[method].apply(this, arguments);
697                }
698            };
699        }
700    }        
701
702});
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run Python Tests on LambdaTest Cloud Grid

Execute automation tests with Gherkin-python on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)