org.springframework.data.annotation.CreatedDate Java Examples

The following examples show how to use org.springframework.data.annotation.CreatedDate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MappingAuditableBeanWrapperFactory.java    From spring-data-mybatis with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link MappingAuditingMetadata} instance from the given
 * {@link PersistentEntity}.
 */
public <P> MappingAuditingMetadata(
		MappingContext<?, ? extends PersistentProperty<?>> context,
		Class<?> type) {

	Assert.notNull(type, "Type must not be null!");

	this.createdByPaths = context.findPersistentPropertyPaths(type,
			withAnnotation(CreatedBy.class,
					org.springframework.data.mybatis.annotation.CreatedBy.class));
	this.createdDatePaths = context.findPersistentPropertyPaths(type,
			withAnnotation(CreatedDate.class,
					org.springframework.data.mybatis.annotation.CreatedDate.class));
	this.lastModifiedByPaths = context.findPersistentPropertyPaths(type,
			withAnnotation(LastModifiedBy.class,
					org.springframework.data.mybatis.annotation.LastModifiedBy.class));
	this.lastModifiedDatePaths = context.findPersistentPropertyPaths(type,
			withAnnotation(LastModifiedDate.class,
					org.springframework.data.mybatis.annotation.LastModifiedDate.class));

	this.isAuditable = Lazy.of( //
			() -> Arrays
					.asList(createdByPaths, createdDatePaths, lastModifiedByPaths,
							lastModifiedDatePaths) //
					.stream() //
					.anyMatch(it -> !it.isEmpty())//
	);
}
 
Example #2
Source File: AbstractJpaBaseEntity.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@CreatedDate
public void setCreatedAt(final long createdAt) {
    this.createdAt = createdAt;

    // In general modification audit entry is not changed by the controller.
    // However, we want to stay consistent with
    // EnableJpaAuditing#modifyOnCreate=true.
    if (isController()) {
        this.lastModifiedAt = createdAt;
    }
}
 
Example #3
Source File: CmisTypeDefinitionFactoryBean.java    From spring-content with Apache License 2.0 4 votes vote down vote up
protected void addBasePropertyDefinitions(MutableTypeDefinition type, Class<?> entityClazz, CmisVersion cmisVersion, boolean inherited) {
	Field cmisNameField = BeanUtils.findFieldWithAnnotation(entityClazz, CmisName.class);
	if (cmisNameField != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:name", "Name", "Name", propertyType(cmisNameField), cardinality(cmisNameField), updatability(entityClazz, cmisNameField), inherited, true, false, false));
	}
	if (cmisVersion != CmisVersion.CMIS_1_0) {
		Field cmisDescField = BeanUtils.findFieldWithAnnotation(entityClazz, CmisDescription.class);
		if (cmisDescField != null) {
			type.addPropertyDefinition(this.createPropertyDefinition("cmis:description", "Description", "Description", propertyType(cmisDescField), cardinality(cmisDescField), updatability(entityClazz, cmisDescField), inherited, false, false, false));
		}
	}

	Field idField = BeanUtils.findFieldWithAnnotation(entityClazz, Id.class);
	if (idField == null) {
		idField = BeanUtils.findFieldWithAnnotation(entityClazz, org.springframework.data.annotation.Id.class);
	}
	if (idField != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:objectId", "Object Id", "Object Id", PropertyType.ID, cardinality(idField), Updatability.READONLY, inherited, false, false, false));
	}

	type.addPropertyDefinition(this.createPropertyDefinition("cmis:baseTypeId", "Base Type Id", "Base Type Id", PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
	type.addPropertyDefinition(this.createPropertyDefinition("cmis:objectTypeId", "Object Type Id", "Object Type Id", PropertyType.ID, Cardinality.SINGLE, Updatability.ONCREATE, inherited, true, false, false));
	if (cmisVersion != CmisVersion.CMIS_1_0) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:secondaryObjectTypeIds", "Secondary Type Ids", "Secondary Type Ids", PropertyType.ID, Cardinality.MULTI, Updatability.READONLY, inherited, false, false, false));
	}

	Field field = BeanUtils.findFieldWithAnnotation(entityClazz, CreatedBy.class);
	if (field != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:createdBy", "Created By", "Created By", propertyType(field), cardinality(field), Updatability.READONLY, inherited, false, false, false));
	}
	field = BeanUtils.findFieldWithAnnotation(entityClazz, CreatedDate.class);
	if (field != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:creationDate", "Creation Date", "Creation Date", propertyType(field), cardinality(field), Updatability.READONLY, inherited, false, false, false));
	}
	field = BeanUtils.findFieldWithAnnotation(entityClazz, LastModifiedBy.class);
	if (field != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:lastModifiedBy", "Last Modified By", "Last Modified By", propertyType(field), cardinality(field), Updatability.READONLY, inherited, false, false, false));
	}
	field = BeanUtils.findFieldWithAnnotation(entityClazz, LastModifiedDate.class);
	if (field != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:lastModificationDate", "Last Modification Date", "Last Modification Date", propertyType(field), cardinality(field), Updatability.READONLY, inherited, false, false, false));
	}
	field = BeanUtils.findFieldWithAnnotation(entityClazz, Version.class);
	if (field != null) {
		type.addPropertyDefinition(this.createPropertyDefinition("cmis:changeToken", "Change Token", "Change Token", PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, inherited, false, false, false));
	}
}