JobMapperImpl.java
package com.wilzwert.myjobs.infrastructure.persistence.mongo.mapper;
import com.wilzwert.myjobs.core.domain.model.attachment.Attachment;
import com.wilzwert.myjobs.core.domain.model.job.Job;
import com.wilzwert.myjobs.core.domain.model.job.JobId;
import com.wilzwert.myjobs.core.domain.model.job.JobRating;
import com.wilzwert.myjobs.core.domain.model.job.JobStatus;
import com.wilzwert.myjobs.core.domain.model.job.command.CreateJobCommand;
import com.wilzwert.myjobs.core.domain.model.job.command.UpdateJobFullCommand;
import com.wilzwert.myjobs.core.domain.model.job.command.UpdateJobRatingCommand;
import com.wilzwert.myjobs.core.domain.model.job.command.UpdateJobStatusCommand;
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.job.CreateJobRequest;
import com.wilzwert.myjobs.infrastructure.api.rest.dto.job.JobResponse;
import com.wilzwert.myjobs.infrastructure.api.rest.dto.job.UpdateJobRatingRequest;
import com.wilzwert.myjobs.infrastructure.api.rest.dto.job.UpdateJobRequest;
import com.wilzwert.myjobs.infrastructure.api.rest.dto.job.UpdateJobStatusRequest;
import com.wilzwert.myjobs.infrastructure.persistence.mongo.entity.MongoAttachment;
import com.wilzwert.myjobs.infrastructure.persistence.mongo.entity.MongoJob;
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 JobMapperImpl implements JobMapper {
@Autowired
private IdMapper idMapper;
@Autowired
private ActivityMapper activityMapper;
@Autowired
private JobRatingMapper jobRatingMapper;
@Override
public MongoJob toEntity(Job domain) {
if ( domain == null ) {
return null;
}
MongoJob mongoJob = new MongoJob();
mongoJob.setId( idMapper.toEntity( domain.getId() ) );
mongoJob.setUrl( domain.getUrl() );
mongoJob.setStatus( domain.getStatus() );
mongoJob.setTitle( domain.getTitle() );
mongoJob.setCompany( domain.getCompany() );
mongoJob.setDescription( domain.getDescription() );
mongoJob.setProfile( domain.getProfile() );
mongoJob.setComment( domain.getComment() );
mongoJob.setSalary( domain.getSalary() );
mongoJob.setRating( domain.getRating() );
mongoJob.setCreatedAt( domain.getCreatedAt() );
mongoJob.setUpdatedAt( domain.getUpdatedAt() );
mongoJob.setStatusUpdatedAt( domain.getStatusUpdatedAt() );
mongoJob.setFollowUpReminderSentAt( domain.getFollowUpReminderSentAt() );
mongoJob.setUserId( idMapper.toEntity( domain.getUserId() ) );
mongoJob.setActivities( activityMapper.toEntity( domain.getActivities() ) );
mongoJob.setAttachments( attachmentListToMongoAttachmentList( domain.getAttachments() ) );
return mongoJob;
}
@Override
public List<MongoJob> toEntity(List<Job> domains) {
if ( domains == null ) {
return null;
}
List<MongoJob> list = new ArrayList<MongoJob>( domains.size() );
for ( Job job : domains ) {
list.add( toEntity( job ) );
}
return list;
}
@Override
public Job toDomain(MongoJob entity) {
if ( entity == null ) {
return null;
}
Job.Builder job = Job.builder();
job.id( idMapper.mapJobId( entity.getId() ) );
job.url( entity.getUrl() );
job.status( entity.getStatus() );
job.title( entity.getTitle() );
job.company( entity.getCompany() );
job.description( entity.getDescription() );
job.profile( entity.getProfile() );
job.comment( entity.getComment() );
job.salary( entity.getSalary() );
job.rating( entity.getRating() );
job.createdAt( entity.getCreatedAt() );
job.updatedAt( entity.getUpdatedAt() );
job.statusUpdatedAt( entity.getStatusUpdatedAt() );
job.followUpReminderSentAt( entity.getFollowUpReminderSentAt() );
job.userId( idMapper.mapUserId( entity.getUserId() ) );
job.activities( activityMapper.toDomain( entity.getActivities() ) );
job.attachments( mongoAttachmentListToAttachmentList( entity.getAttachments() ) );
return job.build();
}
@Override
public List<Job> toDomain(List<MongoJob> entities) {
if ( entities == null ) {
return null;
}
List<Job> list = new ArrayList<Job>( entities.size() );
for ( MongoJob mongoJob : entities ) {
list.add( toDomain( mongoJob ) );
}
return list;
}
@Override
public JobResponse toResponse(Job domain) {
if ( domain == null ) {
return null;
}
JobResponse jobResponse = new JobResponse();
jobResponse.setId( idMapper.toEntity( domain.getId() ) );
jobResponse.setTitle( domain.getTitle() );
jobResponse.setCompany( domain.getCompany() );
jobResponse.setUrl( domain.getUrl() );
jobResponse.setDescription( domain.getDescription() );
jobResponse.setProfile( domain.getProfile() );
jobResponse.setComment( domain.getComment() );
jobResponse.setSalary( domain.getSalary() );
jobResponse.setStatus( domain.getStatus() );
jobResponse.setRating( jobRatingMapper.toResponse( domain.getRating() ) );
jobResponse.setCreatedAt( domain.getCreatedAt() );
jobResponse.setUpdatedAt( domain.getUpdatedAt() );
jobResponse.setStatusUpdatedAt( domain.getStatusUpdatedAt() );
jobResponse.setActivities( activityMapper.toResponse( domain.getActivities() ) );
jobResponse.setAttachments( attachmentListToAttachmentResponseList( domain.getAttachments() ) );
return jobResponse;
}
@Override
public List<JobResponse> toResponse(List<Job> domains) {
if ( domains == null ) {
return null;
}
List<JobResponse> list = new ArrayList<JobResponse>( domains.size() );
for ( Job job : domains ) {
list.add( toResponse( job ) );
}
return list;
}
@Override
public CreateJobCommand toCommand(CreateJobRequest request) {
if ( request == null ) {
return null;
}
String title = null;
String company = null;
String url = null;
String description = null;
String profile = null;
String comment = null;
String salary = null;
title = request.getTitle();
company = request.getCompany();
url = request.getUrl();
description = request.getDescription();
profile = request.getProfile();
comment = request.getComment();
salary = request.getSalary();
UserId userId = null;
CreateJobCommand createJobCommand = new CreateJobCommand( title, company, url, description, profile, comment, salary, userId );
return createJobCommand;
}
@Override
public UpdateJobFullCommand toUpdateCommand(UpdateJobRequest request) {
if ( request == null ) {
return null;
}
String title = null;
String company = null;
String url = null;
String description = null;
String profile = null;
String comment = null;
String salary = null;
title = request.getTitle();
company = request.getCompany();
url = request.getUrl();
description = request.getDescription();
profile = request.getProfile();
comment = request.getComment();
salary = request.getSalary();
JobId jobId = null;
UserId userId = null;
UpdateJobFullCommand updateJobFullCommand = new UpdateJobFullCommand( jobId, userId, title, company, url, description, profile, comment, salary );
return updateJobFullCommand;
}
@Override
public CreateJobCommand toCommand(CreateJobRequest createJobRequest, UserId userId) {
if ( createJobRequest == null && userId == null ) {
return null;
}
String title = null;
String company = null;
String url = null;
String description = null;
String profile = null;
String comment = null;
String salary = null;
if ( createJobRequest != null ) {
title = createJobRequest.getTitle();
company = createJobRequest.getCompany();
url = createJobRequest.getUrl();
description = createJobRequest.getDescription();
profile = createJobRequest.getProfile();
comment = createJobRequest.getComment();
salary = createJobRequest.getSalary();
}
UserId userId1 = null;
userId1 = userId;
CreateJobCommand createJobCommand = new CreateJobCommand( title, company, url, description, profile, comment, salary, userId1 );
return createJobCommand;
}
@Override
public UpdateJobFullCommand toCommand(UpdateJobRequest updateJobRequest, UserId userId, JobId jobId) {
if ( updateJobRequest == null && userId == null && jobId == null ) {
return null;
}
String title = null;
String company = null;
String url = null;
String description = null;
String profile = null;
String comment = null;
String salary = null;
if ( updateJobRequest != null ) {
title = updateJobRequest.getTitle();
company = updateJobRequest.getCompany();
url = updateJobRequest.getUrl();
description = updateJobRequest.getDescription();
profile = updateJobRequest.getProfile();
comment = updateJobRequest.getComment();
salary = updateJobRequest.getSalary();
}
UserId userId1 = null;
userId1 = userId;
JobId jobId1 = null;
jobId1 = jobId;
UpdateJobFullCommand updateJobFullCommand = new UpdateJobFullCommand( jobId1, userId1, title, company, url, description, profile, comment, salary );
return updateJobFullCommand;
}
@Override
public UpdateJobStatusCommand toCommand(UpdateJobStatusRequest updateJobStatusRequest, UserId userId, JobId jobId) {
if ( updateJobStatusRequest == null && userId == null && jobId == null ) {
return null;
}
JobStatus status = null;
if ( updateJobStatusRequest != null ) {
status = updateJobStatusRequest.getStatus();
}
UserId userId1 = null;
userId1 = userId;
JobId jobId1 = null;
jobId1 = jobId;
UpdateJobStatusCommand updateJobStatusCommand = new UpdateJobStatusCommand( jobId1, userId1, status );
return updateJobStatusCommand;
}
@Override
public UpdateJobRatingCommand toCommand(UpdateJobRatingRequest updateJobStatusRequest, UserId userId, JobId jobId) {
if ( updateJobStatusRequest == null && userId == null && jobId == null ) {
return null;
}
JobRating rating = null;
if ( updateJobStatusRequest != null ) {
rating = updateJobStatusRequest.getRating();
}
UserId userId1 = null;
userId1 = userId;
JobId jobId1 = null;
jobId1 = jobId;
UpdateJobRatingCommand updateJobRatingCommand = new UpdateJobRatingCommand( jobId1, userId1, rating );
return updateJobRatingCommand;
}
protected MongoAttachment attachmentToMongoAttachment(Attachment attachment) {
if ( attachment == null ) {
return null;
}
MongoAttachment mongoAttachment = new MongoAttachment();
mongoAttachment.setId( idMapper.toEntity( attachment.getId() ) );
mongoAttachment.setName( attachment.getName() );
mongoAttachment.setFileId( attachment.getFileId() );
mongoAttachment.setFilename( attachment.getFilename() );
mongoAttachment.setContentType( attachment.getContentType() );
mongoAttachment.setCreatedAt( attachment.getCreatedAt() );
mongoAttachment.setUpdatedAt( attachment.getUpdatedAt() );
return mongoAttachment;
}
protected List<MongoAttachment> attachmentListToMongoAttachmentList(List<Attachment> list) {
if ( list == null ) {
return null;
}
List<MongoAttachment> list1 = new ArrayList<MongoAttachment>( list.size() );
for ( Attachment attachment : list ) {
list1.add( attachmentToMongoAttachment( attachment ) );
}
return list1;
}
protected Attachment mongoAttachmentToAttachment(MongoAttachment mongoAttachment) {
if ( mongoAttachment == null ) {
return null;
}
Attachment.Builder attachment = Attachment.builder();
attachment.id( idMapper.mapAttachmentId( mongoAttachment.getId() ) );
attachment.name( mongoAttachment.getName() );
attachment.fileId( mongoAttachment.getFileId() );
attachment.filename( mongoAttachment.getFilename() );
attachment.contentType( mongoAttachment.getContentType() );
attachment.createdAt( mongoAttachment.getCreatedAt() );
attachment.updatedAt( mongoAttachment.getUpdatedAt() );
return attachment.build();
}
protected List<Attachment> mongoAttachmentListToAttachmentList(List<MongoAttachment> list) {
if ( list == null ) {
return null;
}
List<Attachment> list1 = new ArrayList<Attachment>( list.size() );
for ( MongoAttachment mongoAttachment : list ) {
list1.add( mongoAttachmentToAttachment( mongoAttachment ) );
}
return list1;
}
protected AttachmentResponse attachmentToAttachmentResponse(Attachment attachment) {
if ( attachment == null ) {
return null;
}
AttachmentResponse attachmentResponse = new AttachmentResponse();
attachmentResponse.setId( idMapper.toEntity( attachment.getId() ) );
attachmentResponse.setName( attachment.getName() );
attachmentResponse.setFilename( attachment.getFilename() );
attachmentResponse.setContentType( attachment.getContentType() );
attachmentResponse.setCreatedAt( attachment.getCreatedAt() );
return attachmentResponse;
}
protected List<AttachmentResponse> attachmentListToAttachmentResponseList(List<Attachment> list) {
if ( list == null ) {
return null;
}
List<AttachmentResponse> list1 = new ArrayList<AttachmentResponse>( list.size() );
for ( Attachment attachment : list ) {
list1.add( attachmentToAttachmentResponse( attachment ) );
}
return list1;
}
}