use of ma.glasnost.orika.CustomMapper in project ORCID-Source by ORCID.
the class MapperFacadeFactory method mapFuzzyDateToStartDateEntityAndEndDateEntity.
private void mapFuzzyDateToStartDateEntityAndEndDateEntity(MapperFactory mapperFactory) {
mapperFactory.classMap(FuzzyDate.class, StartDateEntity.class).customize(new CustomMapper<FuzzyDate, StartDateEntity>() {
@Override
public void mapAtoB(FuzzyDate fuzzyDate, StartDateEntity entity, MappingContext context) {
if (fuzzyDate.getYear() != null) {
entity.setYear(Integer.valueOf(fuzzyDate.getYear().getValue()));
} else {
entity.setYear(null);
}
if (fuzzyDate.getMonth() != null) {
entity.setMonth(Integer.valueOf(fuzzyDate.getMonth().getValue()));
} else {
entity.setMonth(null);
}
if (fuzzyDate.getDay() != null) {
entity.setDay(Integer.valueOf(fuzzyDate.getDay().getValue()));
} else {
entity.setDay(null);
}
}
@Override
public void mapBtoA(StartDateEntity entity, FuzzyDate fuzzyDate, MappingContext context) {
if (entity.getYear() != null) {
fuzzyDate.setYear(new Year(entity.getYear()));
} else {
fuzzyDate.setYear(null);
}
if (entity.getMonth() != null) {
fuzzyDate.setMonth(new Month(entity.getMonth()));
} else {
fuzzyDate.setMonth(null);
}
if (entity.getDay() != null) {
fuzzyDate.setDay(new Day(entity.getDay()));
} else {
fuzzyDate.setDay(null);
}
}
}).register();
mapperFactory.classMap(FuzzyDate.class, EndDateEntity.class).customize(new CustomMapper<FuzzyDate, EndDateEntity>() {
@Override
public void mapAtoB(FuzzyDate fuzzyDate, EndDateEntity entity, MappingContext context) {
if (fuzzyDate.getYear() != null) {
entity.setYear(Integer.valueOf(fuzzyDate.getYear().getValue()));
} else {
entity.setYear(null);
}
if (fuzzyDate.getMonth() != null) {
entity.setMonth(Integer.valueOf(fuzzyDate.getMonth().getValue()));
} else {
entity.setMonth(null);
}
if (fuzzyDate.getDay() != null) {
entity.setDay(Integer.valueOf(fuzzyDate.getDay().getValue()));
} else {
entity.setDay(null);
}
}
@Override
public void mapBtoA(EndDateEntity entity, FuzzyDate fuzzyDate, MappingContext context) {
if (entity.getYear() != null) {
fuzzyDate.setYear(new Year(entity.getYear()));
} else {
fuzzyDate.setYear(null);
}
if (entity.getMonth() != null) {
fuzzyDate.setMonth(new Month(entity.getMonth()));
} else {
fuzzyDate.setMonth(null);
}
if (entity.getDay() != null) {
fuzzyDate.setDay(new Day(entity.getDay()));
} else {
fuzzyDate.setDay(null);
}
}
}).register();
}
use of ma.glasnost.orika.CustomMapper in project ORCID-Source by ORCID.
the class MapperFacadeFactory method mapFuzzyDateToStartDateEntityAndEndDateEntity.
private void mapFuzzyDateToStartDateEntityAndEndDateEntity(MapperFactory mapperFactory) {
mapperFactory.classMap(FuzzyDate.class, StartDateEntity.class).customize(new CustomMapper<FuzzyDate, StartDateEntity>() {
@Override
public void mapAtoB(FuzzyDate fuzzyDate, StartDateEntity entity, MappingContext context) {
if (fuzzyDate.getYear() != null) {
entity.setYear(Integer.valueOf(fuzzyDate.getYear().getValue()));
} else {
entity.setYear(null);
}
if (fuzzyDate.getMonth() != null) {
entity.setMonth(Integer.valueOf(fuzzyDate.getMonth().getValue()));
} else {
entity.setMonth(null);
}
if (fuzzyDate.getDay() != null) {
entity.setDay(Integer.valueOf(fuzzyDate.getDay().getValue()));
} else {
entity.setDay(null);
}
}
@Override
public void mapBtoA(StartDateEntity entity, FuzzyDate fuzzyDate, MappingContext context) {
if (entity.getYear() != null) {
fuzzyDate.setYear(new Year(entity.getYear()));
} else {
fuzzyDate.setYear(null);
}
if (entity.getMonth() != null) {
fuzzyDate.setMonth(new Month(entity.getMonth()));
} else {
fuzzyDate.setMonth(null);
}
if (entity.getDay() != null) {
fuzzyDate.setDay(new Day(entity.getDay()));
} else {
fuzzyDate.setDay(null);
}
}
}).register();
mapperFactory.classMap(FuzzyDate.class, EndDateEntity.class).customize(new CustomMapper<FuzzyDate, EndDateEntity>() {
@Override
public void mapAtoB(FuzzyDate fuzzyDate, EndDateEntity entity, MappingContext context) {
if (fuzzyDate.getYear() != null) {
entity.setYear(Integer.valueOf(fuzzyDate.getYear().getValue()));
} else {
entity.setYear(null);
}
if (fuzzyDate.getMonth() != null) {
entity.setMonth(Integer.valueOf(fuzzyDate.getMonth().getValue()));
} else {
entity.setMonth(null);
}
if (fuzzyDate.getDay() != null) {
entity.setDay(Integer.valueOf(fuzzyDate.getDay().getValue()));
} else {
entity.setDay(null);
}
}
@Override
public void mapBtoA(EndDateEntity entity, FuzzyDate fuzzyDate, MappingContext context) {
if (entity.getYear() != null) {
fuzzyDate.setYear(new Year(entity.getYear()));
} else {
fuzzyDate.setYear(null);
}
if (entity.getMonth() != null) {
fuzzyDate.setMonth(new Month(entity.getMonth()));
} else {
fuzzyDate.setMonth(null);
}
if (entity.getDay() != null) {
fuzzyDate.setDay(new Day(entity.getDay()));
} else {
fuzzyDate.setDay(null);
}
}
}).register();
}
Aggregations