private void addPropertyJoinTables(XProperty property, PropertyAuditingData propertyData) {
   // first set the join table based on the AuditJoinTable annotation
   final AuditJoinTable joinTable = property.getAnnotation(AuditJoinTable.class);
   if (joinTable != null) {
     propertyData.setJoinTable(joinTable);
   } else {
     propertyData.setJoinTable(DEFAULT_AUDIT_JOIN_TABLE);
   }
 }
 private void setPropertyAuditMappedBy(XProperty property, PropertyAuditingData propertyData) {
   final AuditMappedBy auditMappedBy = property.getAnnotation(AuditMappedBy.class);
   if (auditMappedBy != null) {
     propertyData.setAuditMappedBy(auditMappedBy.mappedBy());
     if (!"".equals(auditMappedBy.positionMappedBy())) {
       propertyData.setPositionMappedBy(auditMappedBy.positionMappedBy());
     }
   }
 }
 /**
  * Add the {@link AuditOverride} annotations.
  *
  * @param property the property being processed
  * @param propertyData the Envers auditing data for this property
  */
 private void addPropertyAuditingOverrides(XProperty property, PropertyAuditingData propertyData) {
   final AuditOverride annotationOverride = property.getAnnotation(AuditOverride.class);
   if (annotationOverride != null) {
     propertyData.addAuditingOverride(annotationOverride);
   }
   final AuditOverrides annotationOverrides = property.getAnnotation(AuditOverrides.class);
   if (annotationOverrides != null) {
     propertyData.addAuditingOverrides(annotationOverrides);
   }
 }
  /**
   * Checks if a property is audited and if yes, fills all of its data.
   *
   * @param property Property to check.
   * @param propertyData Property data, on which to set this property's modification store.
   * @param accessType Access type for the property.
   * @return False if this property is not audited.
   */
  private boolean fillPropertyData(
      XProperty property,
      PropertyAuditingData propertyData,
      String accessType,
      Audited allClassAudited) {

    // check if a property is declared as not audited to exclude it
    // useful if a class is audited but some properties should be excluded
    final NotAudited unVer = property.getAnnotation(NotAudited.class);
    if ((unVer != null && !overriddenAuditedProperties.contains(property))
        || overriddenNotAuditedProperties.contains(property)) {
      return false;
    } else {
      // if the optimistic locking field has to be unversioned and the current property
      // is the optimistic locking field, don't audit it
      if (globalCfg.isDoNotAuditOptimisticLockingField()) {
        final Version jpaVer = property.getAnnotation(Version.class);
        if (jpaVer != null) {
          return false;
        }
      }
    }

    if (!this.checkAudited(property, propertyData, allClassAudited)) {
      return false;
    }

    final String propertyName = propertyNamePrefix + property.getName();
    propertyData.setName(propertyName);
    propertyData.setModifiedFlagName(
        MetadataTools.getModifiedFlagPropertyName(propertyName, globalCfg.getModifiedFlagSuffix()));
    propertyData.setBeanName(property.getName());
    propertyData.setAccessType(accessType);

    addPropertyJoinTables(property, propertyData);
    addPropertyAuditingOverrides(property, propertyData);
    if (!processPropertyAuditingOverrides(property, propertyData)) {
      // not audited due to AuditOverride annotation
      return false;
    }
    addPropertyMapKey(property, propertyData);
    setPropertyAuditMappedBy(property, propertyData);
    setPropertyRelationMappedBy(property, propertyData);

    return true;
  }
 protected boolean checkAudited(
     XProperty property, PropertyAuditingData propertyData, Audited allClassAudited) {
   // Checking if this property is explicitly audited or if all properties are.
   Audited aud =
       (property.isAnnotationPresent(Audited.class))
           ? property.getAnnotation(Audited.class)
           : allClassAudited;
   if (aud == null
       && overriddenAuditedProperties.contains(property)
       && !overriddenNotAuditedProperties.contains(property)) {
     // Assigning @Audited defaults. If anyone needs to customize those values in the future,
     // appropriate fields shall be added to @AuditOverride annotation.
     aud = DEFAULT_AUDITED;
   }
   if (aud != null) {
     propertyData.setStore(aud.modStore());
     propertyData.setRelationTargetAuditMode(aud.targetAuditMode());
     propertyData.setUsingModifiedFlag(checkUsingModifiedFlag(aud));
     return true;
   } else {
     return false;
   }
 }
 /**
  * Process the {@link AuditOverride} annotations for this property.
  *
  * @param property the property for which the {@link AuditOverride} annotations are being
  *     processed
  * @param propertyData the Envers auditing data for this property
  * @return {@code false} if isAudited() of the override annotation was set to
  */
 private boolean processPropertyAuditingOverrides(
     XProperty property, PropertyAuditingData propertyData) {
   // if this property is part of a component, process all override annotations
   if (this.auditedPropertiesHolder instanceof ComponentAuditingData) {
     final List<AuditOverride> overrides =
         ((ComponentAuditingData) this.auditedPropertiesHolder).getAuditingOverrides();
     for (AuditOverride override : overrides) {
       if (property.getName().equals(override.name())) {
         // the override applies to this property
         if (!override.isAudited()) {
           return false;
         } else {
           if (override.auditJoinTable() != null) {
             propertyData.setJoinTable(override.auditJoinTable());
           }
         }
       }
     }
   }
   return true;
 }
 private void addPropertyMapKey(XProperty property, PropertyAuditingData propertyData) {
   final MapKey mapKey = property.getAnnotation(MapKey.class);
   if (mapKey != null) {
     propertyData.setMapKey(mapKey.name());
   }
 }
 private void setPropertyRelationMappedBy(XProperty property, PropertyAuditingData propertyData) {
   final OneToMany oneToMany = property.getAnnotation(OneToMany.class);
   if (oneToMany != null && !"".equals(oneToMany.mappedBy())) {
     propertyData.setRelationMappedBy(oneToMany.mappedBy());
   }
 }