Code Duplication    Length = 52-52 lines in 2 locations

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

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