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