AttachmentMapperImpl.java
package com.wilzwert.myjobs.infrastructure.persistence.mongo.mapper;
import com.wilzwert.myjobs.core.domain.model.activity.ActivityId;
import com.wilzwert.myjobs.core.domain.model.activity.ActivityType;
import com.wilzwert.myjobs.core.domain.model.activity.command.UpdateActivityCommand;
import com.wilzwert.myjobs.core.domain.model.attachment.Attachment;
import com.wilzwert.myjobs.core.domain.model.attachment.command.CreateAttachmentCommand;
import com.wilzwert.myjobs.core.domain.model.job.JobId;
import com.wilzwert.myjobs.core.domain.model.user.UserId;
import com.wilzwert.myjobs.infrastructure.api.rest.dto.AttachmentResponse;
import com.wilzwert.myjobs.infrastructure.api.rest.dto.CreateAttachmentRequest;
import com.wilzwert.myjobs.infrastructure.api.rest.dto.UpdateActivityRequest;
import com.wilzwert.myjobs.infrastructure.persistence.mongo.entity.MongoAttachment;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.processing.Generated;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2025-06-18T09:42:43+0000",
comments = "version: 1.6.2, compiler: javac, environment: Java 21.0.7 (Eclipse Adoptium)"
)
@Component
public class AttachmentMapperImpl implements AttachmentMapper {
@Autowired
private IdMapper idMapper;
@Override
public MongoAttachment toEntity(Attachment domain) {
if ( domain == null ) {
return null;
}
MongoAttachment mongoAttachment = new MongoAttachment();
mongoAttachment.setId( idMapper.toEntity( domain.getId() ) );
mongoAttachment.setName( domain.getName() );
mongoAttachment.setFileId( domain.getFileId() );
mongoAttachment.setFilename( domain.getFilename() );
mongoAttachment.setContentType( domain.getContentType() );
mongoAttachment.setCreatedAt( domain.getCreatedAt() );
mongoAttachment.setUpdatedAt( domain.getUpdatedAt() );
return mongoAttachment;
}
@Override
public List<MongoAttachment> toEntity(List<Attachment> domains) {
if ( domains == null ) {
return null;
}
List<MongoAttachment> list = new ArrayList<MongoAttachment>( domains.size() );
for ( Attachment attachment : domains ) {
list.add( toEntity( attachment ) );
}
return list;
}
@Override
public Attachment toDomain(MongoAttachment entity) {
if ( entity == null ) {
return null;
}
Attachment.Builder attachment = Attachment.builder();
attachment.id( idMapper.mapAttachmentId( entity.getId() ) );
attachment.name( entity.getName() );
attachment.fileId( entity.getFileId() );
attachment.filename( entity.getFilename() );
attachment.contentType( entity.getContentType() );
attachment.createdAt( entity.getCreatedAt() );
attachment.updatedAt( entity.getUpdatedAt() );
return attachment.build();
}
@Override
public List<Attachment> toDomain(List<MongoAttachment> entities) {
if ( entities == null ) {
return null;
}
List<Attachment> list = new ArrayList<Attachment>( entities.size() );
for ( MongoAttachment mongoAttachment : entities ) {
list.add( toDomain( mongoAttachment ) );
}
return list;
}
@Override
public AttachmentResponse toResponse(Attachment domain) {
if ( domain == null ) {
return null;
}
AttachmentResponse attachmentResponse = new AttachmentResponse();
attachmentResponse.setId( idMapper.toEntity( domain.getId() ) );
attachmentResponse.setName( domain.getName() );
attachmentResponse.setFilename( domain.getFilename() );
attachmentResponse.setContentType( domain.getContentType() );
attachmentResponse.setCreatedAt( domain.getCreatedAt() );
return attachmentResponse;
}
@Override
public List<AttachmentResponse> toResponse(List<Attachment> domains) {
if ( domains == null ) {
return null;
}
List<AttachmentResponse> list = new ArrayList<AttachmentResponse>( domains.size() );
for ( Attachment attachment : domains ) {
list.add( toResponse( attachment ) );
}
return list;
}
@Override
public CreateAttachmentCommand toCommand(CreateAttachmentRequest request) {
if ( request == null ) {
return null;
}
String name = null;
String filename = null;
name = request.getName();
filename = request.getFilename();
File file = null;
UserId userId = null;
JobId jobId = null;
CreateAttachmentCommand createAttachmentCommand = new CreateAttachmentCommand( name, file, filename, userId, jobId );
return createAttachmentCommand;
}
@Override
public UpdateActivityCommand toUpdateCommand(UpdateActivityRequest request) {
if ( request == null ) {
return null;
}
String comment = null;
comment = request.getComment();
ActivityId activityId = null;
ActivityType activityType = null;
UserId userId = null;
JobId jobId = null;
UpdateActivityCommand updateActivityCommand = new UpdateActivityCommand( activityId, activityType, comment, userId, jobId );
return updateActivityCommand;
}
@Override
public CreateAttachmentCommand toCommand(CreateAttachmentRequest createAttachmentRequest, UserId userId, JobId jobId, File file) {
if ( createAttachmentRequest == null && userId == null && jobId == null && file == null ) {
return null;
}
String name = null;
String filename = null;
if ( createAttachmentRequest != null ) {
name = createAttachmentRequest.getName();
filename = createAttachmentRequest.getFilename();
}
UserId userId1 = null;
userId1 = userId;
JobId jobId1 = null;
jobId1 = jobId;
File file1 = null;
file1 = file;
CreateAttachmentCommand createAttachmentCommand = new CreateAttachmentCommand( name, file1, filename, userId1, jobId1 );
return createAttachmentCommand;
}
}