|
@@ 549-663 (lines=115) @@
|
| 546 |
|
// get all (pending) relation concerning the goal decision |
| 547 |
|
Set<Relation> pending = goalComp.getRelations(goal); |
| 548 |
|
// check relations |
| 549 |
|
for (Relation rel : pending) |
| 550 |
|
{ |
| 551 |
|
// check parameter constraint type |
| 552 |
|
if (rel.getCategory().equals(ConstraintCategory.PARAMETER_CONSTRAINT)) |
| 553 |
|
{ |
| 554 |
|
// check relation type |
| 555 |
|
switch (rel.getType()) |
| 556 |
|
{ |
| 557 |
|
// bind parameter |
| 558 |
|
case BIND_PARAMETER: |
| 559 |
|
{ |
| 560 |
|
// the goal can be only the reference of the relation |
| 561 |
|
ParameterRelation pRel = (ParameterRelation) rel; |
| 562 |
|
|
| 563 |
|
// get relation reference parameter label |
| 564 |
|
String refParamLabel = pRel.getReferenceParameterLabel(); |
| 565 |
|
// get label index |
| 566 |
|
int refParameterIndex = pRel.getReference().getParameterIndexByLabel(refParamLabel); |
| 567 |
|
// get unification decision parameter label |
| 568 |
|
String label = decision.getParameterLabelByIndex(refParameterIndex); |
| 569 |
|
|
| 570 |
|
// update reference decision |
| 571 |
|
pRel.setReference(decision); |
| 572 |
|
|
| 573 |
|
// update reference label of the relation |
| 574 |
|
pRel.setReferenceParameterLabel(label); |
| 575 |
|
// add relation to the list of translated ones |
| 576 |
|
translatedReferenceGoalRelations.add(pRel); |
| 577 |
|
} |
| 578 |
|
break; |
| 579 |
|
|
| 580 |
|
case EQUAL_PARAMETER : |
| 581 |
|
{ |
| 582 |
|
// get parameter relation |
| 583 |
|
EqualParameterRelation eqRel = (EqualParameterRelation) rel; |
| 584 |
|
// check if the goal is the reference or the parameter constraint |
| 585 |
|
if (eqRel.getReference().equals(goal)) |
| 586 |
|
{ |
| 587 |
|
// get relation reference parameter label |
| 588 |
|
String refParamLabel = eqRel.getReferenceParameterLabel(); |
| 589 |
|
// get label index |
| 590 |
|
int refParameterIndex = eqRel.getReference().getParameterIndexByLabel(refParamLabel); |
| 591 |
|
// get unification decision parameter label |
| 592 |
|
String label = decision.getParameterLabelByIndex(refParameterIndex); |
| 593 |
|
|
| 594 |
|
// update reference decision |
| 595 |
|
eqRel.setReference(decision); |
| 596 |
|
// update reference label of the relation |
| 597 |
|
eqRel.setReferenceParameterLabel(label); |
| 598 |
|
// add relation to the list of translated ones |
| 599 |
|
translatedReferenceGoalRelations.add(eqRel); |
| 600 |
|
} |
| 601 |
|
else // the goal is the target of the relation |
| 602 |
|
{ |
| 603 |
|
// get relation reference parameter label |
| 604 |
|
String refParamLabel = eqRel.getTargetParameterLabel(); |
| 605 |
|
// get label index |
| 606 |
|
int refParameterIndex = eqRel.getTarget().getParameterIndexByLabel(refParamLabel); |
| 607 |
|
// get unification decision parameter label |
| 608 |
|
String label = decision.getParameterLabelByIndex(refParameterIndex); |
| 609 |
|
|
| 610 |
|
// update reference decision |
| 611 |
|
eqRel.setTarget(decision); |
| 612 |
|
// update reference label of the relation |
| 613 |
|
eqRel.setTargetParameterLabel(label); |
| 614 |
|
// add relation to the list of translated ones |
| 615 |
|
translatedTargetGoalRelations.add(eqRel); |
| 616 |
|
} |
| 617 |
|
} |
| 618 |
|
break; |
| 619 |
|
|
| 620 |
|
case NOT_EQUAL_PARAMETER : |
| 621 |
|
{ |
| 622 |
|
// get parameter relation |
| 623 |
|
NotEqualParameterRelation neqRel = (NotEqualParameterRelation) rel; |
| 624 |
|
// check if the goal is the reference or the parameter constraint |
| 625 |
|
if (neqRel.getReference().equals(goal)) |
| 626 |
|
{ |
| 627 |
|
// get relation reference parameter label |
| 628 |
|
String refParamLabel = neqRel.getReferenceParameterLabel(); |
| 629 |
|
// get label index |
| 630 |
|
int refParameterIndex = neqRel.getReference().getParameterIndexByLabel(refParamLabel); |
| 631 |
|
// get unification decision parameter label |
| 632 |
|
String label = decision.getParameterLabelByIndex(refParameterIndex); |
| 633 |
|
|
| 634 |
|
// update reference decision |
| 635 |
|
neqRel.setReference(decision); |
| 636 |
|
// update reference label of the relation |
| 637 |
|
neqRel.setReferenceParameterLabel(label); |
| 638 |
|
// add relation to the list of translated ones |
| 639 |
|
translatedReferenceGoalRelations.add(neqRel); |
| 640 |
|
} |
| 641 |
|
else // the goal is the target of the relation |
| 642 |
|
{ |
| 643 |
|
// get relation reference parameter label |
| 644 |
|
String refParamLabel = neqRel.getTargetParameterLabel(); |
| 645 |
|
// get label index |
| 646 |
|
int refParameterIndex = neqRel.getTarget().getParameterIndexByLabel(refParamLabel); |
| 647 |
|
// get unification decision parameter label |
| 648 |
|
String label = decision.getParameterLabelByIndex(refParameterIndex); |
| 649 |
|
|
| 650 |
|
// update reference decision |
| 651 |
|
neqRel.setTarget(decision); |
| 652 |
|
// update reference label of the relation |
| 653 |
|
neqRel.setTargetParameterLabel(label); |
| 654 |
|
// add relation to the list of translated ones |
| 655 |
|
translatedTargetGoalRelations.add(neqRel); |
| 656 |
|
} |
| 657 |
|
} |
| 658 |
|
break; |
| 659 |
|
|
| 660 |
|
|
| 661 |
|
default: |
| 662 |
|
// unknown parameter relation |
| 663 |
|
throw new RuntimeException("Unknown Parameter relation type : " + rel.getType() + "\n"); |
| 664 |
|
} |
| 665 |
|
} |
| 666 |
|
} |
|
@@ 955-1088 (lines=134) @@
|
| 952 |
|
// get pending relations associated to the goal |
| 953 |
|
Set<Relation> gRels = goalComp.getRelations(goal); |
| 954 |
|
// translate pending relations by replacing goal's information with unification decision's information |
| 955 |
|
for (Relation rel : gRels) |
| 956 |
|
{ |
| 957 |
|
// check relation category |
| 958 |
|
if (rel.getCategory().equals(ConstraintCategory.TEMPORAL_CONSTRAINT)) |
| 959 |
|
{ |
| 960 |
|
// check relation reference |
| 961 |
|
if (rel.getReference().equals(goal)) { |
| 962 |
|
// replace reference |
| 963 |
|
rel.setReference(unification.getUnificationDecision()); |
| 964 |
|
// add relation to the list |
| 965 |
|
translatedReferenceGoalRelations.add(rel); |
| 966 |
|
} |
| 967 |
|
|
| 968 |
|
// check relation target |
| 969 |
|
if (rel.getTarget().equals(goal)) { |
| 970 |
|
// replace target |
| 971 |
|
rel.setTarget(unification.getUnificationDecision()); |
| 972 |
|
// add relation to the list |
| 973 |
|
translatedTargetGoalRelations.add(rel); |
| 974 |
|
} |
| 975 |
|
|
| 976 |
|
} |
| 977 |
|
|
| 978 |
|
if (rel.getCategory().equals(ConstraintCategory.PARAMETER_CONSTRAINT)) |
| 979 |
|
{ |
| 980 |
|
// check relation type |
| 981 |
|
switch (rel.getType()) |
| 982 |
|
{ |
| 983 |
|
// bind parameter |
| 984 |
|
case BIND_PARAMETER: |
| 985 |
|
{ |
| 986 |
|
// the goal can be only the reference of the relation |
| 987 |
|
ParameterRelation pRel = (ParameterRelation) rel; |
| 988 |
|
|
| 989 |
|
// get relation reference parameter label |
| 990 |
|
String refParamLabel = pRel.getReferenceParameterLabel(); |
| 991 |
|
// get label index |
| 992 |
|
int refParameterIndex = pRel.getReference().getParameterIndexByLabel(refParamLabel); |
| 993 |
|
// get unification decision parameter label |
| 994 |
|
String label = unification.getUnificationDecision().getParameterLabelByIndex(refParameterIndex); |
| 995 |
|
|
| 996 |
|
// update reference decision |
| 997 |
|
pRel.setReference(unification.getUnificationDecision()); |
| 998 |
|
// update reference label of the relation |
| 999 |
|
pRel.setReferenceParameterLabel(label); |
| 1000 |
|
// add relation to the list of translated ones |
| 1001 |
|
translatedReferenceGoalRelations.add(pRel); |
| 1002 |
|
} |
| 1003 |
|
break; |
| 1004 |
|
|
| 1005 |
|
case EQUAL_PARAMETER : |
| 1006 |
|
{ |
| 1007 |
|
// get parameter relation |
| 1008 |
|
EqualParameterRelation eqRel = (EqualParameterRelation) rel; |
| 1009 |
|
// check if the goal is the reference or the parameter constraint |
| 1010 |
|
if (eqRel.getReference().equals(goal)) |
| 1011 |
|
{ |
| 1012 |
|
// get relation reference parameter label |
| 1013 |
|
String refParamLabel = eqRel.getReferenceParameterLabel(); |
| 1014 |
|
// get label index |
| 1015 |
|
int refParameterIndex = eqRel.getReference().getParameterIndexByLabel(refParamLabel); |
| 1016 |
|
// get unification decision parameter label |
| 1017 |
|
String label = unification.getUnificationDecision().getParameterLabelByIndex(refParameterIndex); |
| 1018 |
|
|
| 1019 |
|
// update reference decision |
| 1020 |
|
eqRel.setReference(unification.getUnificationDecision()); |
| 1021 |
|
// update reference label of the relation |
| 1022 |
|
eqRel.setReferenceParameterLabel(label); |
| 1023 |
|
// add relation to the list of translated ones |
| 1024 |
|
translatedReferenceGoalRelations.add(eqRel); |
| 1025 |
|
} |
| 1026 |
|
else // the goal is the target of the relation |
| 1027 |
|
{ |
| 1028 |
|
// get relation reference parameter label |
| 1029 |
|
String refParamLabel = eqRel.getTargetParameterLabel(); |
| 1030 |
|
// get label index |
| 1031 |
|
int refParameterIndex = eqRel.getTarget().getParameterIndexByLabel(refParamLabel); |
| 1032 |
|
// get unification decision parameter label |
| 1033 |
|
String label = unification.getUnificationDecision().getParameterLabelByIndex(refParameterIndex); |
| 1034 |
|
|
| 1035 |
|
// update reference decision |
| 1036 |
|
eqRel.setTarget(unification.getUnificationDecision()); |
| 1037 |
|
// update reference label of the relation |
| 1038 |
|
eqRel.setTargetParameterLabel(label); |
| 1039 |
|
// add relation to the list of translated ones |
| 1040 |
|
translatedTargetGoalRelations.add(eqRel); |
| 1041 |
|
} |
| 1042 |
|
} |
| 1043 |
|
break; |
| 1044 |
|
|
| 1045 |
|
case NOT_EQUAL_PARAMETER : |
| 1046 |
|
{ |
| 1047 |
|
// get parameter relation |
| 1048 |
|
NotEqualParameterRelation neqRel = (NotEqualParameterRelation) rel; |
| 1049 |
|
// check if the goal is the reference or the parameter constraint |
| 1050 |
|
if (neqRel.getReference().equals(goal)) |
| 1051 |
|
{ |
| 1052 |
|
// get relation reference parameter label |
| 1053 |
|
String refParamLabel = neqRel.getReferenceParameterLabel(); |
| 1054 |
|
// get label index |
| 1055 |
|
int refParameterIndex = neqRel.getReference().getParameterIndexByLabel(refParamLabel); |
| 1056 |
|
// get unification decision parameter label |
| 1057 |
|
String label = unification.getUnificationDecision().getParameterLabelByIndex(refParameterIndex); |
| 1058 |
|
|
| 1059 |
|
// update reference decision |
| 1060 |
|
neqRel.setReference(unification.getUnificationDecision()); |
| 1061 |
|
// update reference label of the relation |
| 1062 |
|
neqRel.setReferenceParameterLabel(label); |
| 1063 |
|
// add relation to the list of translated ones |
| 1064 |
|
translatedReferenceGoalRelations.add(neqRel); |
| 1065 |
|
} |
| 1066 |
|
else // the goal is the target of the relation |
| 1067 |
|
{ |
| 1068 |
|
// get relation reference parameter label |
| 1069 |
|
String refParamLabel = neqRel.getTargetParameterLabel(); |
| 1070 |
|
// get label index |
| 1071 |
|
int refParameterIndex = neqRel.getTarget().getParameterIndexByLabel(refParamLabel); |
| 1072 |
|
// get unification decision parameter label |
| 1073 |
|
String label = unification.getUnificationDecision().getParameterLabelByIndex(refParameterIndex); |
| 1074 |
|
|
| 1075 |
|
// update reference decision |
| 1076 |
|
neqRel.setTarget(unification.getUnificationDecision()); |
| 1077 |
|
// update reference label of the relation |
| 1078 |
|
neqRel.setTargetParameterLabel(label); |
| 1079 |
|
// add relation to the list of translated ones |
| 1080 |
|
translatedTargetGoalRelations.add(neqRel); |
| 1081 |
|
} |
| 1082 |
|
} |
| 1083 |
|
break; |
| 1084 |
|
|
| 1085 |
|
|
| 1086 |
|
default: |
| 1087 |
|
// unknown parameter relation |
| 1088 |
|
throw new RuntimeException("Unknown Parameter relation type : " + rel.getType() + "\n"); |
| 1089 |
|
} |
| 1090 |
|
} |
| 1091 |
|
} |