comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 965:79251b1d47da

Modified the CollectionMonitor to recommend artifacts for the current state's outputs only. flys-artifacts/trunk@2385 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 21 Jul 2011 14:00:09 +0000
parents 92027887775a
children 799c7108ea6d
comparison
equal deleted inserted replaced
964:ff6ce301c472 965:79251b1d47da
1120 return getCurrentStateId() + hash; 1120 return getCurrentStateId() + hash;
1121 } 1121 }
1122 1122
1123 1123
1124 public List<Output> getOutputs(CallContext context) { 1124 public List<Output> getOutputs(CallContext context) {
1125 List<String> stateIds = getPreviousStateIds(); 1125 List<String> stateIds = getPreviousStateIds();
1126
1127 DefaultState cur = (DefaultState) getCurrentState(context);
1128 try {
1129 if (cur.validate(this, context)) {
1130 stateIds.add(cur.getID());
1131 }
1132 }
1133 catch (IllegalArgumentException iae) { }
1134
1135 List<Output> generated = new ArrayList<Output>(); 1126 List<Output> generated = new ArrayList<Output>();
1136 1127
1137 FLYSContext flysContext = getFlysContext(context); 1128 FLYSContext flysContext = getFlysContext(context);
1138 StateEngine engine = (StateEngine) flysContext.get( 1129 StateEngine engine = (StateEngine) flysContext.get(
1139 FLYSContext.STATE_ENGINE_KEY); 1130 FLYSContext.STATE_ENGINE_KEY);
1140 1131
1141 for (String stateId: stateIds) { 1132 for (String stateId: stateIds) {
1142 DefaultState state = (DefaultState) engine.getState(stateId); 1133 DefaultState state = (DefaultState) engine.getState(stateId);
1143 1134 generated.addAll(getOutputForState(context, state));
1144 List<Output> list = state.getOutputs(); 1135 }
1145 if (list == null || list.size() == 0) { 1136
1146 logger.debug("-> No output modes for this state."); 1137 generated.addAll(getCurrentOutputs(context));
1147 continue;
1148 }
1149
1150 List<Facet> fs = facets.get(stateId);
1151 if (fs == null || fs.size() == 0) {
1152 logger.debug("No facets found.");
1153 continue;
1154 }
1155
1156 List<Output> o = generateOutputs(list, fs);
1157
1158 generated.addAll(o);
1159 }
1160
1161 1138
1162 return generated; 1139 return generated;
1140 }
1141
1142
1143 public List<Output> getCurrentOutputs(CallContext context) {
1144 DefaultState cur = (DefaultState) getCurrentState(context);
1145
1146 try {
1147 if (cur.validate(this, context)) {
1148 return getOutputForState(context, cur);
1149 }
1150 }
1151 catch (IllegalArgumentException iae) { }
1152
1153 return new ArrayList<Output>();
1154 }
1155
1156
1157 protected List<Output> getOutputForState(
1158 CallContext context,
1159 DefaultState state)
1160 {
1161 List<Output> list = state.getOutputs();
1162 if (list == null || list.size() == 0) {
1163 logger.debug("-> No output modes for this state.");
1164 return new ArrayList<Output>();
1165 }
1166
1167 List<Facet> fs = facets.get(state.getID());
1168 if (fs == null || fs.size() == 0) {
1169 logger.debug("No facets found.");
1170 return new ArrayList<Output>();
1171 }
1172
1173 return generateOutputs(list, fs);
1163 } 1174 }
1164 1175
1165 1176
1166 protected List<Output> generateOutputs(List<Output> list, List<Facet> fs) { 1177 protected List<Output> generateOutputs(List<Output> list, List<Facet> fs) {
1167 List<Output> generated = new ArrayList<Output>(); 1178 List<Output> generated = new ArrayList<Output>();

http://dive4elements.wald.intevation.org