Code Duplication    Length = 50-52 lines in 2 locations

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

@@ 655-706 (lines=52) @@
652
			// get task description
653
			AgentTaskDescription task = goal.getTaskDescription();
654
			// set known information concerning components
655
			for (TokenDescription f : task.getFacts()) 
656
			{
657
				// get domain component
658
				DomainComponent component = this.pdb.getComponentByName(f.getComponent());
659
				// get goal referred value
660
				ComponentValue value = component.getValueByName(f.getValue());
661
				// check start time bound
662
				long[] start = f.getStart();
663
				if (start == null) {
664
					start = new long[] {
665
						this.pdb.getOrigin(),
666
						this.pdb.getHorizon()
667
					};
668
				}
669
				
670
				// check end time bound
671
				long[] end = f.getEnd();
672
				if (end == null) {
673
					end = new long[] {
674
						this.pdb.getOrigin(),
675
						this.pdb.getHorizon()
676
					};
677
				}
678
				
679
				// check duration bound
680
				long[] duration = f.getDuration();
681
				if (duration == null) {
682
					duration = new long[] {
683
						value.getDurationLowerBound(),
684
						value.getDurationUpperBound()
685
					};
686
				}
687
				
688
				// check labels
689
				String[] labels = f.getLabels();
690
				if (labels == null) {
691
					labels = new String[] {};
692
				}
693
				
694
				// create fact decision
695
				Decision decision = component.create(
696
						value, 
697
						labels,
698
						start,
699
						end,
700
						duration
701
						);
702
				
703
				// also activate fact decision
704
				component.activate(decision);
705
				// add decision to fact list
706
				facts.add(decision);
707
			}
708
			
709
			// set planning goals 
@@ 710-759 (lines=50) @@
707
			}
708
			
709
			// set planning goals 
710
			for (TokenDescription g : task.getGoals()) 
711
			{
712
				// get domain component
713
				DomainComponent component = this.pdb.getComponentByName(g.getComponent());
714
				// get goal referred value
715
				ComponentValue value = component.getValueByName(g.getValue());
716
				// check start time bound
717
				long[] start = g.getStart();
718
				if (start == null) {
719
					start = new long[] {
720
						this.pdb.getOrigin(),
721
						this.pdb.getHorizon()
722
					};
723
				}
724
				
725
				// check end time bound
726
				long[] end = g.getEnd();
727
				if (end == null) {
728
					end = new long[] {
729
						this.pdb.getOrigin(),
730
						this.pdb.getHorizon()
731
					};
732
				}
733
				
734
				// check duration bound
735
				long[] duration = g.getDuration();
736
				if (duration == null) {
737
					duration = new long[] {
738
						value.getDurationLowerBound(),
739
						value.getDurationUpperBound()
740
					};
741
				}
742
				
743
				// check labels
744
				String[] labels = g.getLabels();
745
				if (labels == null) {
746
					labels = new String[] {};
747
				}
748
				
749
				// create goal decision
750
				Decision decision = component.create(
751
						value, 
752
						labels,
753
						start,
754
						end,
755
						duration
756
						);
757
				
758
				// add decision to goal list
759
				goals.add(decision);
760
			}
761
			
762