private static String getPrefix(String flowId, ExecutionPhase phase, String nodeId) { assert flowId != null; assert phase != null; assert nodeId != null; return getPrefix(flowId, phase) + nodeId + '.'; }
private static String getPrefix(String flowId, ExecutionPhase phase) { assert flowId != null; assert phase != null; return getPrefix(flowId) + phase.getSymbol() + '.'; }
private static Set<String> consumeBlockerIds(NavigableMap<String, String> flowMap, String flowId) { String blockersString = extract(flowMap, getPrefix(flowId), KEY_BLOCKERS); Set<String> blockerIds = parseTokens(blockersString); return blockerIds; }
private static EnumMap<ExecutionPhase, List<ExecutionScript>> consumeScripts( NavigableMap<String, String> flowMap, String flowId) { EnumMap<ExecutionPhase, List<ExecutionScript>> results = new EnumMap<>(ExecutionPhase.class); for (ExecutionPhase phase : ExecutionPhase.values()) { results.put(phase, Collections.emptyList()); } int count = 0; Map<String, NavigableMap<String, String>> phaseMap = partitioning(flowMap); for (Map.Entry<String, NavigableMap<String, String>> entry : phaseMap.entrySet()) { String phaseSymbol = entry.getKey(); NavigableMap<String, String> phaseContents = entry.getValue(); ExecutionPhase phase = ExecutionPhase.findFromSymbol(phaseSymbol); if (phase == null) { throw new IllegalArgumentException(MessageFormat.format( "Unknown phase in \"{0}\": {1}", flowId, phaseSymbol)); } List<ExecutionScript> scriptsInPhase = loadScripts(flowId, phase, phaseContents); results.put(phase, scriptsInPhase); count += scriptsInPhase.size(); } LOG.debug("Loaded {} execution scripts: {}*", count, getPrefix(flowId)); return results; }
throw new IllegalArgumentException("phase must not be null"); //$NON-NLS-1$ String prefix = getPrefix(flowId, phase); LOG.debug("Loading execution scripts: {}*", prefix); Set<String> availableFlowIds = extractFlowIds(properties);
/** * Loads a {@link FlowScript} with the specified ID. * @param properties source properties * @param flowId the target flow ID * @return the loaded script * @throws IllegalArgumentException if script is invalid, or some parameters were {@code null} * @see #extractFlowIds(Properties) */ public static FlowScript load(Properties properties, String flowId) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); //$NON-NLS-1$ } if (flowId == null) { throw new IllegalArgumentException("flowId must not be null"); //$NON-NLS-1$ } String prefix = getPrefix(flowId); LOG.debug("Loading execution scripts: {}*", prefix); NavigableMap<String, String> flowMap = PropertiesUtil.createPrefixMap(properties, prefix); Set<String> blockerIds = consumeBlockerIds(flowMap, flowId); Set<ExecutionScript.Kind> enables = consumeEnables(flowMap, flowId); Map<ExecutionPhase, List<ExecutionScript>> scripts = consumeScripts(flowMap, flowId); FlowScript script = new FlowScript(flowId, blockerIds, scripts, enables); LOG.trace("Loaded {}*: {}", prefix, script); return script; }
throw new IllegalArgumentException("properties must not be null"); //$NON-NLS-1$ String flowPrefix = getPrefix(getId()); properties.setProperty(flowPrefix + KEY_BLOCKERS, join(getBlockerIds())); properties.setProperty(flowPrefix + KEY_ENABLED_SCRIPT_KINDS, join(toSymbols(getEnabledScriptKinds()))); int index = 0; for (ExecutionScript script : phase.getValue()) { String scriptPrefix = getPrefix(getId(), phase.getKey(), String.format("%04d", index++)); properties.setProperty(scriptPrefix + KEY_ID, script.getId()); properties.setProperty(scriptPrefix + KEY_KIND, script.getKind().getSymbol());
assert nodeId != null; assert contents != null; String prefix = getPrefix(flowId, phase, nodeId); String scriptId = extract(contents, prefix, KEY_ID); String kindSymbol = extract(contents, prefix, KEY_KIND);