use of models.datatable.ComputeVirtualPoolElementDataTable.ComputeVirtualElementInfo in project coprhd-controller by CoprHD.
the class ComputeVirtualPools method listComputeElementsJson.
public static void listComputeElementsJson(String cvpid, ComputeVirtualPoolsForm computeVirtualPool) {
List<ComputeVirtualElementInfo> results = Lists.newArrayList();
computeVirtualPool.validateQualifiers("computeVirtualPool");
if (Validation.hasErrors()) {
// cannot call the errorhandler from inside the json call
Logger.info("has errors error: %s", Validation.errors().toString());
} else {
List<ComputeSystemRestRep> allComputes = ComputeSystemUtils.getComputeSystems();
List<ComputeElementRestRep> allComputeElements = (List<ComputeElementRestRep>) ComputeSystemUtils.getAllComputeElements();
if (NullColumnValueGetter.isNotNullValue(cvpid)) {
computeVirtualPool.id = NullColumnValueGetter.getStringValue(cvpid);
// We always show the full list of matching elements - in case of manual - selected ones will be checked
List<ComputeElementRestRep> matchedElements = ComputeVirtualPoolUtils.listMatchingComputeElements(computeVirtualPool.createMatch());
for (ComputeElementRestRep element : allComputeElements) {
String computeSystemName = ": " + element.getName();
for (ComputeSystemRestRep compSys : allComputes) {
if (compSys.getId().equals(element.getComputeSystem().getId())) {
computeSystemName = compSys.getName() + computeSystemName;
break;
}
}
for (ComputeElementRestRep filteredElement : matchedElements) {
if (filteredElement.getId().equals(element.getId())) {
results.add(new ComputeVirtualElementInfo(element, element.getName(), computeSystemName));
break;
}
}
}
} else {
List<ComputeElementRestRep> matchedElements = ComputeVirtualPoolUtils.listMatchingComputeElements(computeVirtualPool.createMatch());
for (ComputeElementRestRep elementA : allComputeElements) {
String computeSystemName = ": " + elementA.getName();
for (ComputeSystemRestRep compSys : allComputes) {
if (compSys.getId().equals(elementA.getComputeSystem().getId())) {
computeSystemName = compSys.getName() + computeSystemName;
break;
}
}
for (ComputeElementRestRep elementM : matchedElements) {
if (elementM.getId().toString().equals(elementA.getId().toString())) {
results.add(new ComputeVirtualElementInfo(elementA, elementA.getName(), computeSystemName));
}
}
}
}
}
renderJSON(DataTablesSupport.createJSON(results, params));
}
use of models.datatable.ComputeVirtualPoolElementDataTable.ComputeVirtualElementInfo in project coprhd-controller by CoprHD.
the class ComputeVirtualPools method listComputePoolElements.
public static void listComputePoolElements(String id) {
List<ComputeVirtualElementInfo> results = Lists.newArrayList();
List<ComputeElementRestRep> allComputeElements = (List<ComputeElementRestRep>) ComputeSystemUtils.getAllComputeElements();
ComputeVirtualPoolRestRep computePool = ComputeVirtualPoolUtils.getComputeVirtualPool(id);
List<RelatedResourceRep> matchedElements = computePool.getMatchedComputeElements();
for (RelatedResourceRep poolElement : matchedElements) {
for (ComputeElementRestRep element : allComputeElements) {
if (element.getId().equals(poolElement.getId())) {
results.add(new ComputeVirtualElementInfo(element, computePool.getName(), (String) "No Name yet"));
break;
}
}
}
renderJSON(DataTablesSupport.createJSON(results, params));
}
Aggregations