@Override public Map<String, ILifecycleComponent> getLifecycleComponents() { return delegate.getLifecycleComponents(); }
@Override public Map<UUID, ILifecycleComponent> getLifecycleComponents() { return getDelegate().getLifecycleComponents(); }
/** * Recursive matching of nested components to find those of the given type. * * @param current * @param matches * @param type * @throws SiteWhereException */ public void findComponentsOfType(ILifecycleComponent current, List<ILifecycleComponent> matches, LifecycleComponentType type) throws SiteWhereException { if (current.getComponentType() == type) { matches.add(current); } for (ILifecycleComponent child : current.getLifecycleComponents().values()) { findComponentsOfType(child, matches, type); } }
/** * Recursively navigates component structure and creates a map of components * by id. * * @param current * @param map */ protected static void buildComponentMap(ILifecycleComponent current, Map<String, ILifecycleComponent> map) { map.put(current.getComponentId(), current); for (ILifecycleComponent sub : current.getLifecycleComponents().values()) { // Root components have a separate hierarchy. if (!(sub instanceof ILifecycleHierarchyRoot)) { buildComponentMap(sub, map); } } }
/** * Recursively navigates component structure and creates a map of components by * id. * * @param current * @param map */ protected static void buildComponentMap(ILifecycleComponent current, Map<UUID, ILifecycleComponent> map) { map.put(current.getComponentId(), current); for (ILifecycleComponent sub : current.getLifecycleComponents().values()) { // Root components have a separate hierarchy. if (!(sub instanceof ILifecycleHierarchyRoot)) { buildComponentMap(sub, map); } } }
/** * Recursive matching of nested components to find those of the given type. * * @param current * @param matches * @param type * @throws SiteWhereException */ public void findComponentsOfType(ILifecycleComponent current, List<ILifecycleComponent> matches, LifecycleComponentType type) throws SiteWhereException { if (current.getComponentType() == type) { matches.add(current); } for (ILifecycleComponent child : current.getLifecycleComponents().values()) { findComponentsOfType(child, matches, type); } }
/** * Recursively log state for a component. * * @param pad * @param component */ protected String logState(String pad, ILifecycleComponent component) { String entry = "\n" + pad + "+ " + component.getComponentName() + " " + component.getLifecycleStatus(); List<ILifecycleComponent> subcomponents = new ArrayList<ILifecycleComponent>( component.getLifecycleComponents().values()); // Sort components by created date. Collections.sort(subcomponents, new Comparator<ILifecycleComponent>() { @Override public int compare(ILifecycleComponent o1, ILifecycleComponent o2) { return o1.getCreatedDate().compareTo(o2.getCreatedDate()); } }); for (ILifecycleComponent subcomponent : subcomponents) { entry = entry + logState(" " + pad, subcomponent); } return entry; }
/** * Recursively log state for a component. * * @param pad * @param component */ protected String logState(String pad, ILifecycleComponent component) { String entry = "\n" + pad + "+ " + component.getComponentName() + " " + component.getLifecycleStatus(); List<ILifecycleComponent> subcomponents = new ArrayList<ILifecycleComponent>( component.getLifecycleComponents().values()); // Sort components by created date. Collections.sort(subcomponents, new Comparator<ILifecycleComponent>() { @Override public int compare(ILifecycleComponent o1, ILifecycleComponent o2) { return o1.getCreatedDate().compareTo(o2.getCreatedDate()); } }); for (ILifecycleComponent subcomponent : subcomponents) { entry = entry + logState(" " + pad, subcomponent); } return entry; }
/** * Recursive call to capture hierarchy of components. * * @param parent * @param results */ protected void getComponentHierarchyState(ILifecycleComponent parent, List<ITenantEngineComponent> results) { Map<String, ILifecycleComponent> children = parent.getLifecycleComponents(); for (ILifecycleComponent child : children.values()) { TenantEngineComponent component = new TenantEngineComponent(); component.setId(child.getComponentId()); component.setName(child.getComponentName()); component.setStatus(child.getLifecycleStatus()); component.setType(child.getComponentType()); component.setParentId(parent.getComponentId()); results.add(component); getComponentHierarchyState(child, results); } }