use of org.apache.syncope.common.lib.info.NumbersInfo in project syncope by apache.
the class SyncopeLogic method numbers.
@PreAuthorize("isAuthenticated()")
public NumbersInfo numbers() {
NumbersInfo numbersInfo = new NumbersInfo();
numbersInfo.setTotalUsers(userDAO.count());
numbersInfo.getUsersByRealm().putAll(userDAO.countByRealm());
numbersInfo.getUsersByStatus().putAll(userDAO.countByStatus());
numbersInfo.setTotalGroups(groupDAO.count());
numbersInfo.getGroupsByRealm().putAll(groupDAO.countByRealm());
Map<AnyType, Integer> anyObjectNumbers = anyObjectDAO.countByType();
int i = 0;
for (Iterator<Map.Entry<AnyType, Integer>> itor = anyObjectNumbers.entrySet().iterator(); i < 2 && itor.hasNext(); i++) {
Map.Entry<AnyType, Integer> entry = itor.next();
if (i == 0) {
numbersInfo.setAnyType1(entry.getKey().getKey());
numbersInfo.setTotalAny1(entry.getValue());
numbersInfo.getAny1ByRealm().putAll(anyObjectDAO.countByRealm(entry.getKey()));
} else if (i == 1) {
numbersInfo.setAnyType2(entry.getKey().getKey());
numbersInfo.setTotalAny2(entry.getValue());
numbersInfo.getAny2ByRealm().putAll(anyObjectDAO.countByRealm(entry.getKey()));
}
}
numbersInfo.setTotalResources(resourceDAO.count());
numbersInfo.setTotalRoles(roleDAO.count());
numbersInfo.getConfCompleteness().put(NumbersInfo.ConfItem.RESOURCE.name(), numbersInfo.getTotalResources() > 0);
numbersInfo.getConfCompleteness().put(NumbersInfo.ConfItem.ACCOUNT_POLICY.name(), !policyDAO.find(AccountPolicy.class).isEmpty());
numbersInfo.getConfCompleteness().put(NumbersInfo.ConfItem.PASSWORD_POLICY.name(), !policyDAO.find(PasswordPolicy.class).isEmpty());
numbersInfo.getConfCompleteness().put(NumbersInfo.ConfItem.NOTIFICATION.name(), !notificationDAO.findAll().isEmpty());
numbersInfo.getConfCompleteness().put(NumbersInfo.ConfItem.PULL_TASK.name(), !taskDAO.findAll(TaskType.PULL).isEmpty());
numbersInfo.getConfCompleteness().put(NumbersInfo.ConfItem.VIR_SCHEMA.name(), !virSchemaDAO.findAll().isEmpty());
numbersInfo.getConfCompleteness().put(NumbersInfo.ConfItem.ANY_TYPE.name(), !anyObjectNumbers.isEmpty());
numbersInfo.getConfCompleteness().put(NumbersInfo.ConfItem.SECURITY_QUESTION.name(), !securityQuestionDAO.findAll().isEmpty());
numbersInfo.getConfCompleteness().put(NumbersInfo.ConfItem.ROLE.name(), numbersInfo.getTotalRoles() > 0);
return numbersInfo;
}
use of org.apache.syncope.common.lib.info.NumbersInfo in project syncope by apache.
the class JAXBTest method numbersInfo.
@Test
public void numbersInfo() throws JAXBException {
JAXBContext context = JAXBContext.newInstance(NumbersInfo.class);
Marshaller marshaller = context.createMarshaller();
Unmarshaller unmarshaller = context.createUnmarshaller();
NumbersInfo original = new NumbersInfo();
original.setTotalUsers(5);
original.getUsersByRealm().put("/", 4);
original.getUsersByRealm().put("/even", 1);
original.getUsersByStatus().put("active", 5);
original.setTotalGroups(16);
original.getGroupsByRealm().put("/", 14);
original.getGroupsByRealm().put("/even", 1);
original.getGroupsByRealm().put("/odd", 1);
original.setAnyType1("PRINTER");
original.setTotalAny1(3);
original.getAny1ByRealm().put("/", 2);
original.getAny1ByRealm().put("/even/two", 1);
original.setTotalResources(21);
original.setTotalRoles(4);
original.getConfCompleteness().put(NumbersInfo.ConfItem.ANY_TYPE.name(), Boolean.TRUE);
original.getConfCompleteness().put(NumbersInfo.ConfItem.PULL_TASK.name(), Boolean.TRUE);
original.getConfCompleteness().put(NumbersInfo.ConfItem.ROLE.name(), Boolean.TRUE);
original.getConfCompleteness().put(NumbersInfo.ConfItem.NOTIFICATION.name(), Boolean.TRUE);
original.getConfCompleteness().put(NumbersInfo.ConfItem.PASSWORD_POLICY.name(), Boolean.TRUE);
original.getConfCompleteness().put(NumbersInfo.ConfItem.ACCOUNT_POLICY.name(), Boolean.TRUE);
original.getConfCompleteness().put(NumbersInfo.ConfItem.RESOURCE.name(), Boolean.TRUE);
original.getConfCompleteness().put(NumbersInfo.ConfItem.VIR_SCHEMA.name(), Boolean.TRUE);
original.getConfCompleteness().put(NumbersInfo.ConfItem.SECURITY_QUESTION.name(), Boolean.TRUE);
StringWriter writer = new StringWriter();
marshaller.marshal(original, writer);
Object actual = unmarshaller.unmarshal(new StringReader(writer.toString()));
assertEquals(original, actual);
}
Aggregations