public Set<String> getMissingProcesses(Archive archive) { Set<String> starters = findBWProcessStarters(archive); return configs. entrySet().stream().filter(v -> v.getKey().getB().equals(archive)). map(v -> v.getValue()). map(n -> n.search(true, "bwprocess").map(nn -> nn.getAttribute("name"))). // search all name elements from NVPairs flatMap(n -> n). filter(s -> !starters.contains(s)). collect(Collectors.toSet()); } private Map<Archive, Set<String>> startersCache = new HashMap<>();
private Set<ReferenceInfo> getAttributes( Map<String, Map<String, String>> prefixedAttributes) { return prefixedAttributes.keySet().stream(). map(prefix -> prefixedAttributes.get(prefix).entrySet().stream().map(v -> T.V(prefix, v))). flatMap(m -> m). map(m -> new ReferenceInfoImpl(getNamespace(m.getA()), m.getB().getKey() + ( m.getB().getValue() != null ? "=" + m.getB().getValue() : ""))). //map(i -> i.createQualifiedName(this)). collect(Collectors.toSet()); } @Override
public void removeMissingProcesses(Archive archive) { Set<String> missing = getMissingProcesses(archive); configs. entrySet().stream().filter(v -> v.getKey().getB().equals(archive)). map(v -> v.getValue()). map(n -> n.search(true, "bwprocess").filter(nn -> missing.contains(nn.getAttribute("name")))). flatMap(n -> n). collect(Collectors.toList()). forEach(n -> n.getParent().removeChild(n)); // search all name elements from NVPairs }
public Set<String> getDuplicateVariables() { Map<V3<String, String, String>, List<V2<V2<Environment, Archive>, String>>> collect = configs. entrySet().stream(). map(v -> v.getValue().searchFirstByName("NVPairs").search(true, "name").map(nn -> T.V(v.getKey(), nn.getTextContent()))). // search all name elements from NVPairs flatMap(n -> n). collect(Collectors.groupingBy(s -> (V3<String, String, String>)T.V(s.getA().getA().getValue(), s.getA().getB().getValue(), s.getB()))); return collect. entrySet(). stream(). filter(v -> v.getValue().size() > 1). map(v -> v.getKey().getC()). collect(Collectors.toSet()); } public Set<String> getDuplicateServiceVariables() {
private static void checkMaxJob(Repository r, String archiveName, NodeBuilder env, V2<String, Optional<NodeBuilder>> p, String property, List<String> messages) { NodeBuilder maxJob = p.getB().get().searchFirstByName(property); if (maxJob == null || maxJob.getTextContent() == null) { messages.add(r.getDeployment().getName() + "\t" + archiveName + "\t" + env.getAttribute("domain") + "\t"+ "missing or missing value of "+property+" in bwprocess config in fullconfig" + "\t" + p.getA()); } else { Optional<Integer> tryParse = tryParse(maxJob.getTextContent()); if (!tryParse.isPresent()) { messages.add(r.getDeployment().getName() + "\t" + archiveName + "\t" + env.getAttribute("domain") + "\t"+ property + " in bwprocess config in fullconfig is not a number (" + maxJob.getTextContent() + ")" + "\t" + p.getA()); } else if (tryParse.get() < 0) { messages.add(r.getDeployment().getName() + "\t" + archiveName + "\t" + env.getAttribute("domain") + "\t"+ property + " in bwprocess config in fullconfig is not a non-negative number (" + maxJob.getTextContent() + ")" + "\t" + p.getA()); } } }
public void removeDuplicateVariables() { Set<String> duplicated = getDuplicateVariables(); Map<V3<String, String, String>, List<V3<V2<Environment, Archive>, String, NodeBuilder>>> toRemove = configs. entrySet().stream(). map(v -> v.getValue().searchFirstByName("NVPairs").search(true, "name").map(nn -> T.V(v.getKey(), nn.getTextContent(), nn.getParent()))). // search all name elements from NVPairs //map(v -> v.getValue().search(true, "bwprocess").map(nn -> T.V(v.getKey(), nn.getAttribute("name"), nn))). flatMap(n -> n). filter(v -> duplicated.contains(v.getB())). collect(Collectors.groupingBy(t -> (V3<String, String, String>)T.V(t.getA().getA().getValue(), t.getA().getB().getValue(), t.getB()))); toRemove. entrySet().stream(). forEach(v -> { v.getValue().stream().skip(1).forEach(n -> n.getC().getParent().removeChild(n.getC())); }); }
public Set<String> getDuplicateProcesses(Archive archive) { Map<V2<String, String>, List<V2<V2<Environment, Archive>, String>>> collect = configs. entrySet().stream().filter(v -> v.getKey().getB().equals(archive)). map(v -> v.getValue().search(true, "bwprocess").map(nn -> T.V(v.getKey(), nn.getAttribute("name")))). // search all name elements from NVPairs flatMap(n -> n). collect(Collectors.groupingBy(s -> (V2<String, String>)T.V(s.getA().getA().getValue(), s.getB()))); return collect. entrySet(). stream(). filter(v -> v.getValue().size() > 1). map(v -> v.getKey().getB()). collect(Collectors.toSet()); } public Set<String> getDuplicateVariables() {
public void removeDuplicateProcesses(Archive archive) { Set<String> duplicated = getDuplicateProcesses(archive); Map<V2<String, String>, List<V3<V2<Environment, Archive>, String, NodeBuilder>>> toRemove = configs. entrySet().stream().filter(v -> v.getKey().getB().equals(archive)). map(v -> v.getValue().search(true, "bwprocess").map(nn -> T.V(v.getKey(), nn.getAttribute("name"), nn))). flatMap(n -> n). filter(v -> duplicated.contains(v.getB())). collect(Collectors.groupingBy(t -> (V2<String, String>)T.V(t.getA().getA().getValue(), t.getB()))); toRemove. entrySet().stream(). forEach(v -> { v.getValue().stream().skip(1).forEach(n -> n.getC().getParent().removeChild(n.getC())); }); }
private static Optional<T.V3<String, byte[], ZipEntry>> getVersion(V2<Path, List<V3<String, byte[], ZipEntry>>> v) { return v.getB().stream().filter(vv -> "!/TIBCO.xml".equals(vv.getA())).findFirst(); }
@Override public List<GlobalVariables> getChildVariables() { if (childVariables == null) { childVariables = parentItem. getChildren(). stream(). filter(i -> ItemType.Folder == i.getItemType()). map(parent -> T.V(parent, parent.getChildren().stream().filter(c -> ItemType.GlobalVariable == c.getItemType()).findAny().orElse(null))). //filter(i -> i != null). map(tupple -> new GlobalVariablesImpl(this, tupple.getB(), tupple.getA(), repository)). collect(Collectors.toList()); } return childVariables; }
private static Optional<T.V3<String, byte[], ZipEntry>> getVersion(V2<Path, List<V3<String, byte[], ZipEntry>>> v) { return v.getB().stream().filter(vv -> "!/TIBCO.xml".equals(vv.getA())).findFirst(); }
private Map<String, Set<V2<String, String>>> getPropertiesNamesAndValues( Map<String, NodeBuilder> adapterProperties) { return adapterProperties.entrySet().stream().map(p -> T.V(p.getKey(), p.getValue().search(true, "option").map(n -> T.V(n.getTextContent(), n.getParent().searchFirstByName("default").getTextContent())).collect(Collectors.toSet()))).collect(Collectors.toMap(v -> v.getA(), v -> v.getB())); }
public void removeServiceVariablesFromConfig(Set<String> variables) { configs.keySet().forEach(v -> variables.forEach(path -> removeServiceVariableFromConfig(v.getA(), v.getB(), path))); } public NodeBuilder createGlobalVariableElement(Environment env, Archive archive, GlobalVariable value) {
public void removeVariablesFromConfig(Set<String> variables) { configs.keySet().forEach(v -> variables.forEach(path -> removeVariableFromConfig(v.getA(), v.getB(), path))); } public void removeServiceVariablesFromConfig(Set<String> variables) {
public boolean isServiceInstanceVariableDefinedInAllConfigs(GlobalVariable variable) { return configs.entrySet().stream(). map(v -> getServices(v.getKey().getA(), v.getKey().getB()). stream().map(s -> T.V(v.getKey().getA(),v.getKey().getB(),s)) ). flatMap(v -> v). map(v -> getInstances(v.getA(), v.getB(), v.getC()). stream().map(instance -> getInstanceConfig(v.getA(), v.getB(), v.getC(), instance).get())). flatMap(n -> n). filter(checkServiceInstanceVariableInConfig(variable)). count() == 0; }
public void normalizeBWSDKVariables(NodeBuilder bw, String version) { Set<V2<String, String>> availableSDKVariables = loader.getBwPropertiesNames().get(version); if (availableSDKVariables == null) { throw new IllegalArgumentException("Cannot find BW SDK Properties for version " + version + " at " + loader.getTibcoBWPath()); } List<NodeBuilder> variableWithDefaultValue = bw.search(true, "name"). map(n -> T.V(n, availableSDKVariables.stream().filter(v -> v.getA().equals(n.getTextContent())).findFirst())). filter(v -> v.getB().isPresent()). filter(v -> sdkVariableHasSameValue(v)). map(v -> v.getA().getParent()). collect(Collectors.toList()); variableWithDefaultValue.forEach(v -> v.getParent().removeChild(v)); }
public void save() { for (T.V2<Environment, Archive> key : configs.keySet()) { NodeBuilder orig = origConfigs.get(key); NodeBuilder newConfig = configs.get(key); if (!orig.equalsTo(newConfig)) { new XmlBuilderFactory().renderNode(newConfig, getConfigPath(key.getB(), key.getA())); } } }
public static <A, B, C> V3<A, B, C> copyAndAdd(V2<A, B> v, C c) { return new V3<A, B, C>(v.getA(), v.getB(), c); } public static <A, B, C, D> V4<A, B, C, D> copyAndAdd(V3<A, B, C> v, D d) {
private boolean sdkVariableHasSameValue(V2<NodeBuilder, Optional<V2<String, String>>> v) { String defaultValue = v.getB().get().getB(); NodeBuilder valueElement = v.getA().getParent().searchFirstByName("value"); return defaultValue == valueElement.getTextContent() || defaultValue.equals(valueElement.getTextContent()); }