@@ -6,12 +6,13 @@ import {
66 DataType ,
77 DataVariable ,
88 I18nString ,
9+ ImportUtils ,
910 NodeElement ,
1011 PetriNet ,
1112 Place ,
1213 Role ,
1314 Transition ,
14- XmlArcType
15+ XmlArcType ,
1516} from '@netgrif/petriflow' ;
1617import { ModelConfig } from './model-config' ;
1718import { CanvasConfiguration } from '@netgrif/petri.svg' ;
@@ -29,7 +30,7 @@ import {ChangedRole} from '../../role-mode/role-detail/changed-role';
2930import { ModelerUtils } from '../../modeler-utils' ;
3031
3132@Injectable ( {
32- providedIn : 'root'
33+ providedIn : 'root' ,
3334} )
3435export class ModelService {
3536 private readonly _model : BehaviorSubject < PetriNet > ;
@@ -59,7 +60,7 @@ export class ModelService {
5960 ] ) ;
6061
6162 constructor (
62- private arcFactory : ArcFactory
63+ private arcFactory : ArcFactory ,
6364 ) {
6465 this . _model = new BehaviorSubject < PetriNet > ( undefined ) ;
6566 this . _placeChange = new Subject < PlaceChange > ( ) ;
@@ -113,7 +114,7 @@ export class ModelService {
113114 this . alignPositionCoordinate ( x , CanvasConfiguration . WIDTH ) ,
114115 this . alignPositionCoordinate ( y , CanvasConfiguration . HEIGHT ) ,
115116 false ,
116- this . nextPlaceId ( )
117+ this . nextPlaceId ( ) ,
117118 ) ;
118119 if ( this . model . getPlaces ( ) . length === 0 ) {
119120 place . marking = 1 ;
@@ -177,7 +178,7 @@ export class ModelService {
177178 const transition = new Transition (
178179 this . alignPositionCoordinate ( x , CanvasConfiguration . WIDTH ) ,
179180 this . alignPositionCoordinate ( y , CanvasConfiguration . HEIGHT ) ,
180- this . nextTransitionId ( )
181+ this . nextTransitionId ( ) ,
181182 ) ;
182183 this . addTransition ( transition ) ;
183184 return transition ;
@@ -272,10 +273,10 @@ export class ModelService {
272273 return arc ;
273274 }
274275
275- public newArcBreakpoint ( arc : Arc < NodeElement , NodeElement > , position : DOMPoint , index : number , ) : void {
276+ public newArcBreakpoint ( arc : Arc < NodeElement , NodeElement > , position : DOMPoint , index : number ) : void {
276277 const breakPoint = new Breakpoint (
277278 this . alignPositionX ( position . x ) ,
278- this . alignPositionY ( position . y )
279+ this . alignPositionY ( position . y ) ,
279280 ) ;
280281 arc . breakpoints . splice ( index , 0 , breakPoint ) ;
281282 this . model . lastChanged = Date . now ( ) ;
@@ -455,7 +456,7 @@ export class ModelService {
455456 public alignPosition ( position : DOMPoint ) : DOMPoint {
456457 return new DOMPoint (
457458 this . alignPositionX ( position . x ) ,
458- this . alignPositionY ( position . y )
459+ this . alignPositionY ( position . y ) ,
459460 ) ;
460461 }
461462
@@ -483,8 +484,10 @@ export class ModelService {
483484 const referencedData = model . getData ( id ) ;
484485 if ( referencedData ) {
485486 if ( referencedData . init . value ) {
486- return Number ( referencedData . init . value ) ;
487- // TODO: NAB-326 check if isFinite and >= 0
487+ if ( ImportUtils . isInitValueNumber ( referencedData . init ) ) {
488+ return Number ( referencedData . init . value ) ;
489+ }
490+ return 0 ;
488491 }
489492 return 0 ;
490493 }
@@ -531,8 +534,8 @@ export class ModelService {
531534 . map ( dg =>
532535 dg . getDataRefs ( )
533536 . map ( ref =>
534- ModelerUtils . numberOfEventActions ( ref . getEvents ( ) )
535- ) . reduce ( ( sum , current ) => sum + current , 0 )
537+ ModelerUtils . numberOfEventActions ( ref . getEvents ( ) ) ,
538+ ) . reduce ( ( sum , current ) => sum + current , 0 ) ,
536539 ) . reduce ( ( sum , current ) => sum + current , 0 ) ;
537540 return eventActions + dataRefActions ;
538541 }
0 commit comments