Code Duplication    Length = 52-52 lines in 2 locations

src/main/java/it/cnr/istc/pst/platinum/control/acting/GoalOrientedActingAgent.java 2 locations

@@ 643-694 (lines=52) @@
640
			}
641
			
642
			// set planning goals 
643
			for (TokenDescription g : task.getGoals()) {
644
				
645
				// get domain component
646
				DomainComponent component = this.pdb.getComponentByName(g.getComponent());
647
				// get goal referred value
648
				ComponentValue value = component.getValueByName(g.getValue());
649
				// check start time bound
650
				long[] start = g.getStart();
651
				if (start == null) {
652
					start = new long[] {
653
						this.pdb.getOrigin(),
654
						this.pdb.getHorizon()
655
					};
656
				}
657
				
658
				// check end time bound
659
				long[] end = g.getEnd();
660
				if (end == null) {
661
					end = new long[] {
662
						this.pdb.getOrigin(),
663
						this.pdb.getHorizon()
664
					};
665
				}
666
				
667
				// check duration bound
668
				long[] duration = g.getDuration();
669
				if (duration == null) {
670
					duration = new long[] {
671
						value.getDurationLowerBound(),
672
						value.getDurationUpperBound()
673
					};
674
				}
675
				
676
				// check labels
677
				String[] labels = g.getLabels();
678
				if (labels == null) {
679
					labels = new String[] {};
680
				}
681
				
682
				// create goal decision
683
				Decision decision = component.create(
684
						value, 
685
						labels,
686
						start,
687
						end,
688
						duration
689
						);
690
				
691
				// set as mandatory expansion decision
692
				decision.setMandatoryExpansion();
693
				// add decision to goal list
694
				goals.add(decision);
695
			}
696
			
697
			
@@ 588-639 (lines=52) @@
585
			// get task description
586
			AgentTaskDescription task = goal.getTaskDescription();
587
			// set known information concerning components
588
			for (TokenDescription f : task.getFacts()) {
589
				
590
				// get domain component
591
				DomainComponent component = this.pdb.getComponentByName(f.getComponent());
592
				// get goal referred value
593
				ComponentValue value = component.getValueByName(f.getValue());
594
				// check start time bound
595
				long[] start = f.getStart();
596
				if (start == null) {
597
					start = new long[] {
598
						this.pdb.getOrigin(),
599
						this.pdb.getHorizon()
600
					};
601
				}
602
				
603
				// check end time bound
604
				long[] end = f.getEnd();
605
				if (end == null) {
606
					end = new long[] {
607
						this.pdb.getOrigin(),
608
						this.pdb.getHorizon()
609
					};
610
				}
611
				
612
				// check duration bound
613
				long[] duration = f.getDuration();
614
				if (duration == null) {
615
					duration = new long[] {
616
						value.getDurationLowerBound(),
617
						value.getDurationUpperBound()
618
					};
619
				}
620
				
621
				// check labels
622
				String[] labels = f.getLabels();
623
				if (labels == null) {
624
					labels = new String[] {};
625
				}
626
				
627
				// create fact decision
628
				Decision decision = component.create(
629
						value, 
630
						labels,
631
						start,
632
						end,
633
						duration
634
						);
635
				
636
				// also activate fact decision
637
				component.activate(decision);
638
				// add decision to fact list
639
				facts.add(decision);
640
			}
641
			
642
			// set planning goals