-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ctor-polaris/src/main/java/com/netflix/metacat/connector/polaris/mappers/AuditMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.netflix.metacat.connector.polaris.mappers; | ||
|
||
import com.netflix.metacat.common.server.connectors.model.AuditInfo; | ||
import com.netflix.metacat.connector.polaris.store.entities.AuditEntity; | ||
import org.apache.commons.lang3.ObjectUtils; | ||
|
||
import java.util.Date; | ||
|
||
|
||
/** | ||
* Database object mapper implementations. | ||
*/ | ||
public class AuditMapper implements | ||
EntityToInfoMapper<AuditEntity, AuditInfo>, | ||
InfoToEntityMapper<AuditInfo, AuditEntity> { | ||
|
||
/** | ||
* {@inheritDoc}. | ||
*/ | ||
@Override | ||
public AuditInfo toInfo(final AuditEntity entity) { | ||
AuditInfo auditInfo = AuditInfo.builder() | ||
.createdBy(entity.getCreatedBy()) | ||
.createdDate(Date.from(entity.getCreatedDate())) | ||
.lastModifiedBy(entity.getLastModifiedBy()) | ||
.lastModifiedDate(Date.from(entity.getLastModifiedDate())) | ||
.build(); | ||
return auditInfo; | ||
} | ||
|
||
/** | ||
* {@inheritDoc}. | ||
*/ | ||
@Override | ||
public AuditEntity toEntity(final AuditInfo info) { | ||
final AuditEntity entity = AuditEntity.builder() | ||
.createdBy(info.getCreatedBy()) | ||
.createdDate(ObjectUtils.defaultIfNull(info.getCreatedDate(), new Date()).toInstant()) | ||
.lastModifiedBy(info.getLastModifiedBy()) | ||
.lastModifiedDate(ObjectUtils.defaultIfNull(info.getLastModifiedDate(), new Date()).toInstant()) | ||
.build(); | ||
return entity; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters