use of ma.glasnost.orika.metadata.TypeBuilder in project java-example by saxingz.
the class VideoController method listVideos.
/**
* 查看原始视频
*/
@ApiOperation("查看原始视频")
@ApiImplicitParams({ @ApiImplicitParam(name = "page", value = "页码", defaultValue = "1"), @ApiImplicitParam(name = "pageNum", value = "每页条数", defaultValue = "1") })
@PostMapping("/list")
public Page<VideoVO> listVideos(@RequestBody VideoDO video, @RequestParam @Min(value = 1, message = "页码不得少于1") Integer page, @RequestParam @Min(value = 1, message = "每页条数不得少于1") @Max(value = 100, message = "每页条数不大于100") Integer pageNum) {
LambdaQueryWrapper<VideoDO> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.setEntity(video);
queryWrapper.like(StringUtils.isNotBlank(video.getChannelId()), VideoDO::getChannelId, video.getChannelId());
queryWrapper.like(StringUtils.isNotBlank(video.getChannelTitle()), VideoDO::getChannelTitle, video.getChannelTitle());
queryWrapper.like(StringUtils.isNotBlank(video.getVideoId()), VideoDO::getVideoId, video.getVideoId());
queryWrapper.like(StringUtils.isNotBlank(video.getVideoTitle()), VideoDO::getVideoTitle, video.getVideoTitle());
queryWrapper.like(StringUtils.isNotBlank(video.getDescription()), VideoDO::getDescription, video.getDescription());
queryWrapper.like(StringUtils.isNotBlank(video.getDownloadedUrl()), VideoDO::getDownloadedUrl, video.getDownloadedUrl());
video.setChannelId(null).setChannelTitle(null).setVideoId(null).setVideoTitle(null).setDescription(null).setDownloadedUrl(null);
Page<VideoDO> videoDOPage = videoLogic.page(new Page<>(page, pageNum), queryWrapper).addOrder(OrderItem.desc(TableInfoHelper.getTableInfo(VideoDO.class).getKeyProperty()));
Page<VideoVO> result = beanMapper.map(videoDOPage, new TypeBuilder<Page<VideoDO>>() {
}.build(), new TypeBuilder<Page<VideoVO>>() {
}.build());
if (result.getSize() > 0) {
result.getRecords().forEach(r -> r.setTransferList(transferLogic.list(new QueryWrapper<>(new TransferDO().setVideoId(r.getId())))));
}
return result;
}
use of ma.glasnost.orika.metadata.TypeBuilder in project tiamat by entur.
the class LineStringConverterTest method convertToLineString.
@Test
public void convertToLineString() throws Exception {
LineStringType lineStringType = new LineStringType().withId("LineString").withPosList(new DirectPositionListType().withSrsDimension(BigInteger.valueOf(2L)).withValue(71.1, 9.1, 4.1, 9.5));
LineString lineString = lineStringConverter.convertTo(lineStringType, new TypeBuilder<LineString>() {
}.build(), mappingContext);
assertThat(lineString).isNotNull();
assertThat(lineString.getCoordinates()).hasSize(2);
assertThat(lineString.getCoordinates()[0].x).isEqualTo(lineStringType.getPosList().getValue().get(1));
assertThat(lineString.getCoordinates()[0].y).isEqualTo(lineStringType.getPosList().getValue().get(0));
assertThat(lineString.getCoordinates()[1].x).isEqualTo(lineStringType.getPosList().getValue().get(3));
assertThat(lineString.getCoordinates()[1].y).isEqualTo(lineStringType.getPosList().getValue().get(2));
}
use of ma.glasnost.orika.metadata.TypeBuilder in project tiamat by entur.
the class PolygonConverterTest method convertFromWithHoles.
@Test
public void convertFromWithHoles() throws Exception {
List<Double> values = new ArrayList<>();
values.add(9.8468);
values.add(59.2649);
values.add(9.8456);
values.add(59.2654);
values.add(9.8457);
values.add(59.2655);
values.add(values.get(0));
values.add(values.get(1));
DirectPositionListType positionList = new DirectPositionListType().withValue(values);
LinearRingType linearRing = new LinearRingType().withPosList(positionList);
PolygonType polygonType = new PolygonType().withId("KVE-07").withExterior(new AbstractRingPropertyType().withAbstractRing(openGisObjectFactory.createLinearRing(linearRing))).withInterior(new AbstractRingPropertyType().withAbstractRing(openGisObjectFactory.createLinearRing(linearRing)));
Polygon polygon = polygonConverter.convertFrom(polygonType, new TypeBuilder<Polygon>() {
}.build(), new MappingContext(new HashMap<>()));
assertThat(polygon).isNotNull();
assertThat(polygon.getExteriorRing().getCoordinates()).hasSize(values.size() / 2);
assertThat(polygon.getNumInteriorRing()).isEqualTo(1);
assertCoordinatesMatch(polygon.getExteriorRing(), values, "Exterior ring");
assertInteriorRingsMatch(polygon, Arrays.asList(values));
}
use of ma.glasnost.orika.metadata.TypeBuilder in project tiamat by entur.
the class LineStringConverterTest method convertFromLineStringToNetexGmlLineStringType.
@Test
public void convertFromLineStringToNetexGmlLineStringType() throws Exception {
Coordinate[] coordinates = new Coordinate[2];
coordinates[0] = new Coordinate(11, 60);
coordinates[1] = new Coordinate(11.1, 60.1);
CoordinateSequence points = new CoordinateArraySequence(coordinates);
LineString lineString = new LineString(points, geometryFactory);
LineStringType gisLineString = lineStringConverter.convertFrom(lineString, new TypeBuilder<LineStringType>() {
}.build(), mappingContext);
assertThat(gisLineString).isNotNull();
assertThat(gisLineString.getPosList().getCount().intValue()).isEqualTo(4);
assertThat(gisLineString.getId()).isNotEmpty();
// Check that the format is Y,X
assertThat(gisLineString.getPosList().getValue().get(0)).isEqualTo(coordinates[0].y);
assertThat(gisLineString.getPosList().getValue().get(1)).isEqualTo(coordinates[0].x);
assertThat(gisLineString.getPosList().getValue().get(2)).isEqualTo(coordinates[1].y);
assertThat(gisLineString.getPosList().getValue().get(3)).isEqualTo(coordinates[1].x);
assertThat(gisLineString.getSrsDimension().intValue()).isEqualTo(2);
}
use of ma.glasnost.orika.metadata.TypeBuilder in project tiamat by entur.
the class PolygonConverterTest method convertFrom.
@Test
public void convertFrom() throws Exception {
List<Double> values = new ArrayList<>();
values.add(9.8468);
values.add(59.2649);
values.add(9.8456);
values.add(59.2654);
values.add(9.8457);
values.add(59.2655);
values.add(values.get(0));
values.add(values.get(1));
DirectPositionListType positionList = new DirectPositionListType().withValue(values);
LinearRingType linearRing = new LinearRingType().withPosList(positionList);
PolygonType polygonType = new PolygonType().withId("KVE-07").withExterior(new AbstractRingPropertyType().withAbstractRing(openGisObjectFactory.createLinearRing(linearRing)));
Polygon polygon = polygonConverter.convertFrom(polygonType, new TypeBuilder<Polygon>() {
}.build(), new MappingContext(new HashMap<>()));
assertThat(polygon).isExactlyInstanceOf(Polygon.class).isNotNull();
assertThat(polygon.getExteriorRing().getCoordinates()).hasSize(values.size() / 2);
assertCoordinatesMatch(polygon.getExteriorRing(), values, "Exterior ring");
}
Aggregations