Search in sources :

Example 1 with VirSchemaDAO

use of org.apache.syncope.core.persistence.api.dao.VirSchemaDAO in project syncope by apache.

the class JPAExternalResourceDAO method delete.

@Override
public void delete(final String name) {
    ExternalResource resource = find(name);
    if (resource == null) {
        return;
    }
    taskDAO().deleteAll(resource, TaskType.PROPAGATION);
    taskDAO().deleteAll(resource, TaskType.PULL);
    taskDAO().deleteAll(resource, TaskType.PUSH);
    realmDAO().findByResource(resource).forEach(realm -> realm.getResources().remove(resource));
    anyObjectDAO().findByResource(resource).forEach(anyObject -> anyObject.getResources().remove(resource));
    userDAO().findByResource(resource).forEach(user -> user.getResources().remove(resource));
    groupDAO().findByResource(resource).forEach(group -> group.getResources().remove(resource));
    policyDAO().findByResource(resource).forEach(policy -> policy.getResources().remove(resource));
    resource.getProvisions().stream().filter(provision -> provision.getMapping() != null).peek(provision -> provision.getMapping().getItems().forEach(item -> item.setMapping(null))).peek(provision -> {
        provision.getMapping().getItems().clear();
        provision.setMapping(null);
        provision.setResource(null);
    }).forEachOrdered(provision -> virSchemaDAO().findByProvision(provision).forEach(schema -> virSchemaDAO().delete(schema.getKey())));
    externalResourceHistoryConfDAO().deleteByEntity(resource);
    if (resource.getConnector() != null && resource.getConnector().getResources() != null && !resource.getConnector().getResources().isEmpty()) {
        resource.getConnector().getResources().remove(resource);
    }
    resource.setConnector(null);
    entityManager().remove(resource);
}
Also used : JPAMappingItem(org.apache.syncope.core.persistence.jpa.entity.resource.JPAMappingItem) JPAExternalResource(org.apache.syncope.core.persistence.jpa.entity.resource.JPAExternalResource) StandardEntitlement(org.apache.syncope.common.lib.types.StandardEntitlement) PullPolicy(org.apache.syncope.core.persistence.api.entity.policy.PullPolicy) ConnectorRegistry(org.apache.syncope.core.provisioning.api.ConnectorRegistry) Autowired(org.springframework.beans.factory.annotation.Autowired) TypedQuery(javax.persistence.TypedQuery) TaskDAO(org.apache.syncope.core.persistence.api.dao.TaskDAO) JPAProvision(org.apache.syncope.core.persistence.jpa.entity.resource.JPAProvision) HashSet(java.util.HashSet) PasswordPolicy(org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy) GroupDAO(org.apache.syncope.core.persistence.api.dao.GroupDAO) DelegatedAdministrationException(org.apache.syncope.core.spring.security.DelegatedAdministrationException) AnyObjectDAO(org.apache.syncope.core.persistence.api.dao.AnyObjectDAO) RealmDAO(org.apache.syncope.core.persistence.api.dao.RealmDAO) AuthContextUtils(org.apache.syncope.core.spring.security.AuthContextUtils) Repository(org.springframework.stereotype.Repository) AnyTypeClass(org.apache.syncope.core.persistence.api.entity.AnyTypeClass) JPAMapping(org.apache.syncope.core.persistence.jpa.entity.resource.JPAMapping) UserDAO(org.apache.syncope.core.persistence.api.dao.UserDAO) Policy(org.apache.syncope.core.persistence.api.entity.policy.Policy) Set(java.util.Set) Implementation(org.apache.syncope.core.persistence.api.entity.Implementation) Collectors(java.util.stream.Collectors) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) MappingItem(org.apache.syncope.core.persistence.api.entity.resource.MappingItem) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) List(java.util.List) Query(javax.persistence.Query) AccountPolicy(org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy) Provision(org.apache.syncope.core.persistence.api.entity.resource.Provision) PolicyDAO(org.apache.syncope.core.persistence.api.dao.PolicyDAO) VirSchemaDAO(org.apache.syncope.core.persistence.api.dao.VirSchemaDAO) ApplicationContextProvider(org.apache.syncope.core.spring.ApplicationContextProvider) Collections(java.util.Collections) ExternalResourceDAO(org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO) ExternalResourceHistoryConfDAO(org.apache.syncope.core.persistence.api.dao.ExternalResourceHistoryConfDAO) TaskType(org.apache.syncope.common.lib.types.TaskType) Transactional(org.springframework.transaction.annotation.Transactional) JPAExternalResource(org.apache.syncope.core.persistence.jpa.entity.resource.JPAExternalResource) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)

Aggregations

Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Query (javax.persistence.Query)1 TypedQuery (javax.persistence.TypedQuery)1 StandardEntitlement (org.apache.syncope.common.lib.types.StandardEntitlement)1 TaskType (org.apache.syncope.common.lib.types.TaskType)1 AnyObjectDAO (org.apache.syncope.core.persistence.api.dao.AnyObjectDAO)1 ExternalResourceDAO (org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO)1 ExternalResourceHistoryConfDAO (org.apache.syncope.core.persistence.api.dao.ExternalResourceHistoryConfDAO)1 GroupDAO (org.apache.syncope.core.persistence.api.dao.GroupDAO)1 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)1 PolicyDAO (org.apache.syncope.core.persistence.api.dao.PolicyDAO)1 RealmDAO (org.apache.syncope.core.persistence.api.dao.RealmDAO)1 TaskDAO (org.apache.syncope.core.persistence.api.dao.TaskDAO)1 UserDAO (org.apache.syncope.core.persistence.api.dao.UserDAO)1 VirSchemaDAO (org.apache.syncope.core.persistence.api.dao.VirSchemaDAO)1 AnyTypeClass (org.apache.syncope.core.persistence.api.entity.AnyTypeClass)1