Search in sources :

Example 1 with TypeBuilder

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;
}
Also used : VideoVO(org.saxing.a0041_wemedia.domain.vo.VideoVO) VideoDO(org.saxing.a0041_wemedia.domain.entity.VideoDO) TypeBuilder(ma.glasnost.orika.metadata.TypeBuilder) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) TransferDO(org.saxing.a0041_wemedia.domain.entity.TransferDO) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with TypeBuilder

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));
}
Also used : LineString(org.locationtech.jts.geom.LineString) TypeBuilder(ma.glasnost.orika.metadata.TypeBuilder) DirectPositionListType(net.opengis.gml._3.DirectPositionListType) LineStringType(net.opengis.gml._3.LineStringType) Test(org.junit.Test)

Example 3 with TypeBuilder

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));
}
Also used : MappingContext(ma.glasnost.orika.MappingContext) TypeBuilder(ma.glasnost.orika.metadata.TypeBuilder) HashMap(java.util.HashMap) LinearRingType(net.opengis.gml._3.LinearRingType) AbstractRingPropertyType(net.opengis.gml._3.AbstractRingPropertyType) ArrayList(java.util.ArrayList) DirectPositionListType(net.opengis.gml._3.DirectPositionListType) PolygonType(net.opengis.gml._3.PolygonType) Polygon(org.locationtech.jts.geom.Polygon) Test(org.junit.Test)

Example 4 with TypeBuilder

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);
}
Also used : CoordinateSequence(org.locationtech.jts.geom.CoordinateSequence) DoubleValuesToCoordinateSequence(org.rutebanken.tiamat.geo.DoubleValuesToCoordinateSequence) Coordinate(org.locationtech.jts.geom.Coordinate) LineString(org.locationtech.jts.geom.LineString) TypeBuilder(ma.glasnost.orika.metadata.TypeBuilder) LineStringType(net.opengis.gml._3.LineStringType) CoordinateArraySequence(org.locationtech.jts.geom.impl.CoordinateArraySequence) Test(org.junit.Test)

Example 5 with TypeBuilder

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");
}
Also used : MappingContext(ma.glasnost.orika.MappingContext) TypeBuilder(ma.glasnost.orika.metadata.TypeBuilder) HashMap(java.util.HashMap) LinearRingType(net.opengis.gml._3.LinearRingType) AbstractRingPropertyType(net.opengis.gml._3.AbstractRingPropertyType) ArrayList(java.util.ArrayList) DirectPositionListType(net.opengis.gml._3.DirectPositionListType) PolygonType(net.opengis.gml._3.PolygonType) Polygon(org.locationtech.jts.geom.Polygon) Test(org.junit.Test)

Aggregations

TypeBuilder (ma.glasnost.orika.metadata.TypeBuilder)7 Test (org.junit.Test)6 HashMap (java.util.HashMap)4 MappingContext (ma.glasnost.orika.MappingContext)4 PolygonType (net.opengis.gml._3.PolygonType)4 Polygon (org.locationtech.jts.geom.Polygon)4 DirectPositionListType (net.opengis.gml._3.DirectPositionListType)3 Coordinate (org.locationtech.jts.geom.Coordinate)3 CoordinateArraySequence (org.locationtech.jts.geom.impl.CoordinateArraySequence)3 ArrayList (java.util.ArrayList)2 AbstractRingPropertyType (net.opengis.gml._3.AbstractRingPropertyType)2 LineStringType (net.opengis.gml._3.LineStringType)2 LinearRingType (net.opengis.gml._3.LinearRingType)2 LineString (org.locationtech.jts.geom.LineString)2 LinearRing (org.locationtech.jts.geom.LinearRing)2 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1 ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)1 ApiOperation (io.swagger.annotations.ApiOperation)1 CoordinateSequence (org.locationtech.jts.geom.CoordinateSequence)1 DoubleValuesToCoordinateSequence (org.rutebanken.tiamat.geo.DoubleValuesToCoordinateSequence)1