@Override public VariableDescriptor getVariableKey(final String name) { if (name == null) { return null; } final VariableDescriptor spec = new VariableDescriptor(name); for (final Map.Entry<VariableDescriptor, String> entry : getVariableMap().entrySet()) { if (entry.getKey().equals(spec)) { return entry.getKey(); } } return null; }
/** * @return a VariableDescriptor as configured * */ public VariableDescriptor build() { return new VariableDescriptor(this); } }
/** * Gets the variable value * * @param name the string name of the VariableDescriptor that is the key of * the value to lookup. * @return the value associated with the given variable name if found; null * otherwise */ default String getVariableValue(final String name) { if (name == null) { return null; } return getVariableMap().get(new VariableDescriptor(name)); }
@Override public Set<Entry<String, String>> entrySet() { final Map<String, String> newMap = new HashMap<>(); //put variable registry entries first for (final Map.Entry<VariableDescriptor, String> entry : registry.getVariableMap().entrySet()) { newMap.put(entry.getKey().getName(), entry.getValue()); } //put attribute maps in reverse order final List<Map<String,String>> listOfMaps = new ArrayList<>(maps); Collections.reverse(listOfMaps); for(final Map<String,String> map : listOfMaps){ for(final Map.Entry<String, String> entry : map.entrySet()){ newMap.put(entry.getKey(), entry.getValue()); } } return newMap.entrySet(); }
/** * Returns the VariableDescriptor for the given key name if it exists. * * @param name the string name of the VariableDescriptor to lookup. * @return the variable descriptor registered for this name if it exists; * null otherwise */ default VariableDescriptor getVariableKey(final String name) { if (name == null) { return null; } final VariableDescriptor spec = new VariableDescriptor(name); for (final Map.Entry<VariableDescriptor, String> entry : getVariableMap().entrySet()) { if (entry.getKey().equals(spec)) { return entry.getKey(); } } return null; }
@Override public void setVariables(final Map<String, String> variables) { writeLock.lock(); try { verifyCanUpdateVariables(variables); if (variables == null) { return; } final Map<VariableDescriptor, String> variableMap = new HashMap<>(); variables.entrySet() // cannot use Collectors.toMap because value may be null .forEach(entry -> variableMap.put(new VariableDescriptor(entry.getKey()), entry.getValue())); variableRegistry.setVariables(variableMap); } finally { writeLock.unlock(); } }
.collect(Collectors.toMap(entry -> entry.getKey().getName(), Map.Entry::getValue)));
@Override public String getVariableValue(final String name) { if (name == null) { return null; } final VariableDescriptor descriptor = new VariableDescriptor(name); final String value = getVariableMap().get(descriptor); if (value != null) { return value; } return parent.getVariableValue(descriptor); }
private ComponentSearchResultDTO search(final String searchStr, final ProcessGroup group) { final List<String> matches = new ArrayList<>(); final ProcessGroup parent = group.getParent(); if (parent == null) { return null; } addIfAppropriate(searchStr, group.getIdentifier(), "Id", matches); addIfAppropriate(searchStr, group.getVersionedComponentId().orElse(null), "Version Control ID", matches); addIfAppropriate(searchStr, group.getName(), "Name", matches); addIfAppropriate(searchStr, group.getComments(), "Comments", matches); final ComponentVariableRegistry varRegistry = group.getVariableRegistry(); if (varRegistry != null) { final Map<VariableDescriptor, String> variableMap = varRegistry.getVariableMap(); for (final Map.Entry<VariableDescriptor, String> entry : variableMap.entrySet()) { addIfAppropriate(searchStr, entry.getKey().getName(), "Variable Name", matches); addIfAppropriate(searchStr, entry.getValue(), "Variable Value", matches); } } if (matches.isEmpty()) { return null; } final ComponentSearchResultDTO result = new ComponentSearchResultDTO(); result.setId(group.getIdentifier()); result.setName(group.getName()); result.setGroupId(parent.getIdentifier()); result.setMatches(matches); return result; }
.map(descriptor -> descriptor.getName()) .collect(Collectors.toList());
.collect(Collectors.toMap(entry -> entry.getKey().getName(), entry -> entry.getValue())); dto.setVariables(variables);
addVariable(element, entry.getKey().getName(), entry.getValue());