| @@ 1050-1086 (lines=37) @@ | ||
| 1047 | * @param dec |
|
| 1048 | * @return |
|
| 1049 | */ |
|
| 1050 | public synchronized Set<Relation> getToActivateRelations(Decision dec) |
|
| 1051 | { |
|
| 1052 | // check decision component |
|
| 1053 | if (!dec.getComponent().equals(this)) { |
|
| 1054 | throw new RuntimeException("Unknown decision to component:\n- component: " + this.name + "\n- decision: " + dec + "\n"); |
|
| 1055 | } |
|
| 1056 | ||
| 1057 | // list of relations |
|
| 1058 | Set<Relation> set = new HashSet<>(); |
|
| 1059 | // check pending local relations |
|
| 1060 | for (Relation rel : this.localRelations) { |
|
| 1061 | // check decisions and relation status |
|
| 1062 | if ((rel.getReference().equals(dec) || |
|
| 1063 | rel.getTarget().equals(dec)) && |
|
| 1064 | rel.canBeActivated()) |
|
| 1065 | { |
|
| 1066 | // add pending local relation |
|
| 1067 | set.add(rel); |
|
| 1068 | } |
|
| 1069 | } |
|
| 1070 | ||
| 1071 | // check pending global relations |
|
| 1072 | synchronized (globalRelations) { |
|
| 1073 | for (Relation rel : globalRelations) { |
|
| 1074 | // check reference and target decisions |
|
| 1075 | if ((rel.getReference().equals(dec) || |
|
| 1076 | rel.getTarget().equals(dec)) && |
|
| 1077 | rel.canBeActivated()) |
|
| 1078 | { |
|
| 1079 | // add pending global relation |
|
| 1080 | set.add(rel); |
|
| 1081 | } |
|
| 1082 | } |
|
| 1083 | } |
|
| 1084 | ||
| 1085 | // get list |
|
| 1086 | return set; |
|
| 1087 | } |
|
| 1088 | ||
| 1089 | /** |
|
| @@ 896-932 (lines=37) @@ | ||
| 893 | * @param dec |
|
| 894 | * @return |
|
| 895 | */ |
|
| 896 | public synchronized Set<Relation> getActiveRelations(Decision dec) |
|
| 897 | { |
|
| 898 | // check if local relation |
|
| 899 | if (!dec.getComponent().equals(this)) { |
|
| 900 | throw new RuntimeException("Unknown decision to component:- component: " + this.name + "\n- decision: " + dec + "\n"); |
|
| 901 | } |
|
| 902 | ||
| 903 | // list of active relations |
|
| 904 | Set<Relation> set = new HashSet<>(); |
|
| 905 | // check local relations |
|
| 906 | for (Relation rel : this.localRelations) { |
|
| 907 | // check related decisions and relation status |
|
| 908 | if ((rel.getReference().equals(dec) || |
|
| 909 | rel.getTarget().equals(dec)) |
|
| 910 | && rel.isActive()) |
|
| 911 | { |
|
| 912 | // add relation |
|
| 913 | set.add(rel); |
|
| 914 | } |
|
| 915 | } |
|
| 916 | ||
| 917 | // check global relations |
|
| 918 | synchronized (globalRelations) { |
|
| 919 | for (Relation rel : globalRelations) { |
|
| 920 | // check related decision and relation status |
|
| 921 | if ((rel.getReference().equals(dec) || |
|
| 922 | rel.getTarget().equals(dec)) && |
|
| 923 | rel.isActive()) |
|
| 924 | { |
|
| 925 | // add relation |
|
| 926 | set.add(rel); |
|
| 927 | } |
|
| 928 | } |
|
| 929 | } |
|
| 930 | ||
| 931 | // get the list |
|
| 932 | return set; |
|
| 933 | } |
|
| 934 | ||
| 935 | /** |
|
| @@ 1094-1127 (lines=34) @@ | ||
| 1091 | * @param dec |
|
| 1092 | * @return |
|
| 1093 | */ |
|
| 1094 | public synchronized Set<Relation> getPendingRelations(Decision dec) |
|
| 1095 | { |
|
| 1096 | // check if local decision |
|
| 1097 | if (!dec.getComponent().equals(this)) { |
|
| 1098 | throw new RuntimeException("Unknown decision to component:- component: " + this.name + "\n- decision: " + dec + "\n"); |
|
| 1099 | } |
|
| 1100 | ||
| 1101 | // list of relations |
|
| 1102 | Set<Relation> set = new HashSet<>(); |
|
| 1103 | // check local relations |
|
| 1104 | for (Relation rel : this.localRelations) |
|
| 1105 | { |
|
| 1106 | // check decisions and relation status |
|
| 1107 | if ((rel.getReference().equals(dec) || |
|
| 1108 | rel.getTarget().equals(dec)) && |
|
| 1109 | rel.isPending()) { |
|
| 1110 | // add pending relation |
|
| 1111 | set.add(rel); |
|
| 1112 | } |
|
| 1113 | } |
|
| 1114 | ||
| 1115 | // check global relations |
|
| 1116 | synchronized (globalRelations) { |
|
| 1117 | for (Relation rel : globalRelations) { |
|
| 1118 | // check decisions and relation status |
|
| 1119 | if ((rel.getReference().equals(dec) || rel.getTarget().equals(dec)) && rel.isPending()) { |
|
| 1120 | // add pending relation |
|
| 1121 | set.add(rel); |
|
| 1122 | } |
|
| 1123 | } |
|
| 1124 | } |
|
| 1125 | ||
| 1126 | // get list |
|
| 1127 | return set; |
|
| 1128 | } |
|
| 1129 | ||
| 1130 | /** |
|
| @@ 1136-1167 (lines=32) @@ | ||
| 1133 | * @param dec |
|
| 1134 | * @return |
|
| 1135 | */ |
|
| 1136 | public synchronized Set<Relation> getRelations(Decision dec) |
|
| 1137 | { |
|
| 1138 | // check if local decision |
|
| 1139 | if (!dec.getComponent().equals(this)) { |
|
| 1140 | throw new RuntimeException("Unknown decision to component:- component: " + this.name + "\n- decision: " + dec + "\n"); |
|
| 1141 | } |
|
| 1142 | ||
| 1143 | // list local of relations |
|
| 1144 | Set<Relation> set = new HashSet<>(); |
|
| 1145 | for (Relation rel : this.localRelations) { |
|
| 1146 | // check decisions and relation status |
|
| 1147 | if (dec.equals(rel.getReference()) || |
|
| 1148 | dec.equals(rel.getTarget())) { |
|
| 1149 | // add relation |
|
| 1150 | set.add(rel); |
|
| 1151 | } |
|
| 1152 | } |
|
| 1153 | ||
| 1154 | // check global relations |
|
| 1155 | synchronized (globalRelations) { |
|
| 1156 | // get also global relation |
|
| 1157 | for (Relation rel : globalRelations) { |
|
| 1158 | if (dec.equals(rel.getReference()) || |
|
| 1159 | dec.equals(rel.getTarget())) { |
|
| 1160 | // add relation |
|
| 1161 | set.add(rel); |
|
| 1162 | } |
|
| 1163 | } |
|
| 1164 | } |
|
| 1165 | ||
| 1166 | // get list |
|
| 1167 | return set; |
|
| 1168 | } |
|
| 1169 | ||
| 1170 | /** |
|