use of org.apache.syncope.core.persistence.api.entity.AnyType 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.core.persistence.api.entity.AnyType in project syncope by apache.
the class AnyTypeLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPE_DELETE + "')")
public AnyTypeTO delete(final String key) {
AnyType anyType = anyTypeDAO.find(key);
if (anyType == null) {
LOG.error("Could not find anyType '" + key + "'");
throw new NotFoundException(key);
}
Integer anyObjects = anyObjectDAO.countByType().get(anyType);
if (anyObjects != null && anyObjects > 0) {
LOG.error("{} AnyObject instances found for {}, aborting", anyObjects, anyType);
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidAnyType);
sce.getElements().add("AnyObject instances found for " + key);
throw sce;
}
try {
return binder.delete(anyType);
} catch (IllegalArgumentException e) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
sce.getElements().add(e.getMessage());
throw sce;
}
}
use of org.apache.syncope.core.persistence.api.entity.AnyType in project syncope by apache.
the class AnyTypeLogic method update.
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPE_UPDATE + "')")
public AnyTypeTO update(final AnyTypeTO anyTypeTO) {
AnyType anyType = anyTypeDAO.find(anyTypeTO.getKey());
if (anyType == null) {
LOG.error("Could not find anyType '" + anyTypeTO.getKey() + "'");
throw new NotFoundException(anyTypeTO.getKey());
}
binder.update(anyType, anyTypeTO);
anyType = anyTypeDAO.save(anyType);
return binder.getAnyTypeTO(anyTypeDAO.save(anyType));
}
use of org.apache.syncope.core.persistence.api.entity.AnyType in project syncope by apache.
the class JPAAnyTypeClassDAO method delete.
@Override
public void delete(final String key) {
AnyTypeClass anyTypeClass = find(key);
if (anyTypeClass == null) {
return;
}
for (PlainSchema schema : plainSchemaDAO.findByAnyTypeClasses(Collections.singletonList(anyTypeClass))) {
schema.setAnyTypeClass(null);
}
for (DerSchema schema : derSchemaDAO.findByAnyTypeClasses(Collections.singletonList(anyTypeClass))) {
schema.setAnyTypeClass(null);
}
for (VirSchema schema : virSchemaDAO.findByAnyTypeClasses(Collections.singletonList(anyTypeClass))) {
schema.setAnyTypeClass(null);
}
for (AnyType type : anyTypeDAO.findByTypeClass(anyTypeClass)) {
type.getClasses().remove(anyTypeClass);
}
for (TypeExtension typeExt : groupDAO.findTypeExtensions(anyTypeClass)) {
typeExt.getAuxClasses().remove(anyTypeClass);
if (typeExt.getAuxClasses().isEmpty()) {
typeExt.getGroup().getTypeExtensions().remove(typeExt);
typeExt.setGroup(null);
}
}
for (Provision provision : resourceDAO.findProvisionsByAuxClass(anyTypeClass)) {
provision.getAuxClasses().remove(anyTypeClass);
}
entityManager().remove(anyTypeClass);
}
use of org.apache.syncope.core.persistence.api.entity.AnyType in project syncope by apache.
the class AnyTypeTest method find.
@Test
public void find() {
AnyType userType = anyTypeDAO.findUser();
assertNotNull(userType);
assertEquals(AnyTypeKind.USER, userType.getKind());
assertEquals(AnyTypeKind.USER.name(), userType.getKey());
assertFalse(userType.getClasses().isEmpty());
AnyType groupType = anyTypeDAO.findGroup();
assertNotNull(groupType);
assertEquals(AnyTypeKind.GROUP, groupType.getKind());
assertEquals(AnyTypeKind.GROUP.name(), groupType.getKey());
assertFalse(groupType.getClasses().isEmpty());
AnyType otherType = anyTypeDAO.find("PRINTER");
assertNotNull(otherType);
assertEquals(AnyTypeKind.ANY_OBJECT, otherType.getKind());
assertEquals("PRINTER", otherType.getKey());
}
Aggregations