public static Set createAttributeUpdateMetadataEntity()

in core/src/main/java/org/apache/custos/core/mapper/tenant/AttributeUpdateMetadataMapper.java [43:150]


    public static Set<TenantAttributeUpdateMetadata> createAttributeUpdateMetadataEntity(Tenant oldTenant, Tenant newTenant, String updatedBy) {

        Set<TenantAttributeUpdateMetadata> metadataSet = new HashSet<>();
        if (!oldTenant.getName().equals(newTenant.getName())) {
            TenantAttributeUpdateMetadata attributeUpdateMetadata = new TenantAttributeUpdateMetadata();
            attributeUpdateMetadata.setTenant(newTenant);
            attributeUpdateMetadata.setUpdatedFieldKey("name");
            attributeUpdateMetadata.setUpdatedFieldValue(newTenant.getName());
            attributeUpdateMetadata.setUpdatedBy(updatedBy);
            attributeUpdateMetadata.setTenant(newTenant);
            metadataSet.add(attributeUpdateMetadata);
        }

        if (!oldTenant.getAdminEmail().equals(newTenant.getAdminEmail())) {
            TenantAttributeUpdateMetadata attributeUpdateMetadata = new TenantAttributeUpdateMetadata();
            attributeUpdateMetadata.setTenant(newTenant);
            attributeUpdateMetadata.setUpdatedFieldKey("adminEmail");
            attributeUpdateMetadata.setUpdatedFieldValue(newTenant.getAdminEmail());
            attributeUpdateMetadata.setUpdatedBy(updatedBy);
            attributeUpdateMetadata.setTenant(newTenant);
            metadataSet.add(attributeUpdateMetadata);
        }

        if (!oldTenant.getAdminFirstName().equals(newTenant.getAdminFirstName())) {
            TenantAttributeUpdateMetadata attributeUpdateMetadata = new TenantAttributeUpdateMetadata();
            attributeUpdateMetadata.setTenant(newTenant);
            attributeUpdateMetadata.setUpdatedFieldKey("adminFirstName");
            attributeUpdateMetadata.setUpdatedFieldValue(newTenant.getAdminFirstName());
            attributeUpdateMetadata.setUpdatedBy(updatedBy);
            attributeUpdateMetadata.setTenant(newTenant);
            metadataSet.add(attributeUpdateMetadata);
        }

        if (!oldTenant.getAdminLastName().equals(newTenant.getAdminLastName())) {
            TenantAttributeUpdateMetadata attributeUpdateMetadata = new TenantAttributeUpdateMetadata();
            attributeUpdateMetadata.setTenant(newTenant);
            attributeUpdateMetadata.setUpdatedFieldKey("adminLastName");
            attributeUpdateMetadata.setUpdatedFieldValue(newTenant.getAdminLastName());
            attributeUpdateMetadata.setUpdatedBy(updatedBy);
            attributeUpdateMetadata.setTenant(newTenant);
            metadataSet.add(attributeUpdateMetadata);
        }

        if (!oldTenant.getDomain().equals(newTenant.getDomain())) {
            TenantAttributeUpdateMetadata attributeUpdateMetadata = new TenantAttributeUpdateMetadata();
            attributeUpdateMetadata.setTenant(newTenant);
            attributeUpdateMetadata.setUpdatedFieldKey("domain");
            attributeUpdateMetadata.setUpdatedFieldValue(newTenant.getDomain());
            attributeUpdateMetadata.setUpdatedBy(updatedBy);
            attributeUpdateMetadata.setTenant(newTenant);
            metadataSet.add(attributeUpdateMetadata);
        }

        if (!oldTenant.getLogoURI().equals(newTenant.getLogoURI())) {
            TenantAttributeUpdateMetadata attributeUpdateMetadata = new TenantAttributeUpdateMetadata();
            attributeUpdateMetadata.setTenant(newTenant);
            attributeUpdateMetadata.setUpdatedFieldKey("logoURI");
            attributeUpdateMetadata.setUpdatedFieldValue(newTenant.getLogoURI());
            attributeUpdateMetadata.setUpdatedBy(updatedBy);
            attributeUpdateMetadata.setTenant(newTenant);
            metadataSet.add(attributeUpdateMetadata);
        }

        if (!oldTenant.getRequesterEmail().equals(newTenant.getRequesterEmail())) {
            TenantAttributeUpdateMetadata attributeUpdateMetadata = new TenantAttributeUpdateMetadata();
            attributeUpdateMetadata.setTenant(newTenant);
            attributeUpdateMetadata.setUpdatedFieldKey("requesterEmail");
            attributeUpdateMetadata.setUpdatedFieldValue(newTenant.getRequesterEmail());
            attributeUpdateMetadata.setUpdatedBy(updatedBy);
            attributeUpdateMetadata.setTenant(newTenant);
            metadataSet.add(attributeUpdateMetadata);
        }


        if (!oldTenant.getScope().equals(newTenant.getScope())) {
            TenantAttributeUpdateMetadata attributeUpdateMetadata = new TenantAttributeUpdateMetadata();
            attributeUpdateMetadata.setTenant(newTenant);
            attributeUpdateMetadata.setUpdatedFieldKey("scope");
            attributeUpdateMetadata.setUpdatedFieldValue(newTenant.getScope());
            attributeUpdateMetadata.setUpdatedBy(updatedBy);
            attributeUpdateMetadata.setTenant(newTenant);
            metadataSet.add(attributeUpdateMetadata);
        }

        Set diff = difference(oldTenant.getRedirectURIS(), newTenant.getRedirectURIS());

        if (!diff.isEmpty()) {
            TenantAttributeUpdateMetadata attributeUpdateMetadata = new TenantAttributeUpdateMetadata();
            attributeUpdateMetadata.setTenant(newTenant);
            attributeUpdateMetadata.setUpdatedFieldKey("redirectURIS");
            attributeUpdateMetadata.setUpdatedFieldValue(setToString(diff));
            attributeUpdateMetadata.setUpdatedBy(updatedBy);
            attributeUpdateMetadata.setTenant(newTenant);
            metadataSet.add(attributeUpdateMetadata);
        }

        Set conDiff = difference(oldTenant.getContacts(), newTenant.getContacts());
        if (!conDiff.isEmpty()) {
            TenantAttributeUpdateMetadata attributeUpdateMetadata = new TenantAttributeUpdateMetadata();
            attributeUpdateMetadata.setTenant(newTenant);
            attributeUpdateMetadata.setUpdatedFieldKey("contacts");
            attributeUpdateMetadata.setUpdatedFieldValue(setToString(conDiff));
            attributeUpdateMetadata.setUpdatedBy(updatedBy);
            attributeUpdateMetadata.setTenant(newTenant);
            metadataSet.add(attributeUpdateMetadata);
        }
        return metadataSet;
    }