Skip to content

Commit

Permalink
Merge 61b8784 into a766ad1
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Wiedemann authored Sep 29, 2022
2 parents a766ad1 + 61b8784 commit 274e058
Show file tree
Hide file tree
Showing 27 changed files with 1,699 additions and 1,400 deletions.
207 changes: 70 additions & 137 deletions api/broker-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1070,45 +1070,35 @@ components:
type: object
properties:
type:
type: string
enum:
- Point
$ref: '#/components/schemas/GeometryType'
coordinates:
$ref: '#/components/schemas/positionDefinition'
MultiPoint:
type: object
properties:
type:
type: string
enum:
- MultiPoint
$ref: '#/components/schemas/GeometryType'
coordinates:
$ref: '#/components/schemas/positionArrayDefinition'
Polygon:
type: object
properties:
type:
type: string
enum:
- Polygon
$ref: '#/components/schemas/GeometryType'
coordinates:
$ref: '#/components/schemas/polygonDefinition'
LineString:
type: object
properties:
type:
type: string
enum:
- LineString
$ref: '#/components/schemas/GeometryType'
coordinates:
$ref: '#/components/schemas/lineStringDefinition'
MultiLineString:
type: object
properties:
type:
type: string
enum:
- MultiLineString
$ref: '#/components/schemas/GeometryType'
coordinates:
type: array
items:
Expand All @@ -1117,22 +1107,38 @@ components:
type: object
properties:
type:
type: string
enum:
- MultiPolygon
$ref: '#/components/schemas/GeometryType'
coordinates:
type: array
items:
$ref: '#/components/schemas/polygonDefinition'
Geometry:
description: ' Avalid GeoJSON geometry object'
discriminator:
propertyName: type
mapping:
Point: '#/components/schemas/Point'
MultiPoint: '#/components/schemas/MultiPoint'
Polygon: '#/components/schemas/Polygon'
LineString: '#/components/schemas/LineString'
MultiLineString: '#/components/schemas/MultiLineString'
MultiPolygon: '#/components/schemas/MultiPolygon'
oneOf:
- $ref: '#/components/schemas/Point'
- $ref: '#/components/schemas/MultiPoint'
- $ref: '#/components/schemas/Polygon'
- $ref: '#/components/schemas/LineString'
- $ref: '#/components/schemas/MultiLineString'
- $ref: '#/components/schemas/MultiPolygon'
GeometryType:
type: string
enum:
- Point
- MultiPoint
- Polygon
- LineString
- MultiLineString
- MultiPolygon
observedAt:
type: string
format: date-time
Expand All @@ -1148,13 +1154,38 @@ components:
instanceId:
type: string
format: uri
AdditionalProperty:
oneOf:
- $ref: '#/components/schemas/AdditionalPropertyList'
- $ref: '#/components/schemas/AdditionalPropertyObject'
AdditionalPropertyList:
oneOf:
- $ref: '#/components/schemas/PropertyList'
- $ref: '#/components/schemas/GeoPropertyList'
- $ref: '#/components/schemas/RelationshipList'
AdditionalPropertyObject:
discriminator:
propertyName: type
mapping:
Property: '#/components/schemas/Property'
GeoProperty: '#/components/schemas/GeoProperty'
Relationship: '#/components/schemas/Relationship'
properties:
type:
$ref: '#/components/schemas/PropertyType'
oneOf:
- $ref: '#/components/schemas/Property'
- $ref: '#/components/schemas/GeoProperty'
- $ref: '#/components/schemas/Relationship'
PropertyType:
type: string
enum:
- Property
- GeoProperty
- Relationship
Property:
type: object
properties:
type:
type: string
enum:
- Property
value:
oneOf:
- type: string
Expand Down Expand Up @@ -1184,16 +1215,10 @@ components:
- type
- value
additionalProperties:
oneOf:
- $ref: '#/components/schemas/Property'
- $ref: '#/components/schemas/Relationship'
$ref: '#/components/schemas/AdditionalProperty'
Relationship:
type: object
properties:
type:
type: string
enum:
- Relationship
object:
type: string
format: uri
Expand All @@ -1211,16 +1236,10 @@ components:
- type
- object
additionalProperties:
oneOf:
- $ref: '#/components/schemas/Property'
- $ref: '#/components/schemas/Relationship'
$ref: '#/components/schemas/AdditionalProperty'
GeoProperty:
type: object
properties:
type:
type: string
enum:
- GeoProperty
value:
type: object
observedAt:
Expand All @@ -1239,10 +1258,7 @@ components:
- type
- value
additionalProperties:
oneOf:
- $ref: '#/components/schemas/Geometry'
- $ref: '#/components/schemas/Property'
- $ref: '#/components/schemas/Relationship'
$ref: '#/components/schemas/AdditionalProperty'
Name:
type: string
pattern: '^((\d|[a-zA-Z]|_)+(:(\d|[a-zA-Z]|_)+)?(#\d+)?)$'
Expand All @@ -1269,10 +1285,19 @@ components:
modifiedAt:
$ref: '#/components/schemas/modifiedAt'
additionalProperties:
oneOf:
- $ref: '#/components/schemas/Property'
- $ref: '#/components/schemas/Relationship'
- $ref: '#/components/schemas/GeoProperty'
$ref: '#/components/schemas/AdditionalProperty'
PropertyList:
type: array
items:
$ref: '#/components/schemas/Property'
GeoPropertyList:
type: array
items:
$ref: '#/components/schemas/GeoProperty'
RelationshipList:
type: array
items:
$ref: '#/components/schemas/Relationship'
Entity:
type: object
properties:
Expand All @@ -1294,10 +1319,7 @@ components:
modifiedAt:
$ref: '#/components/schemas/modifiedAt'
additionalProperties:
oneOf:
- $ref: '#/components/schemas/Property'
- $ref: '#/components/schemas/Relationship'
- $ref: '#/components/schemas/GeoProperty'
$ref: '#/components/schemas/AdditionalProperty'
EntityList:
type: array
items:
Expand Down Expand Up @@ -1603,95 +1625,6 @@ components:
- before
- after
- between
EntityTemporalFragment:
type: object
properties:
'@context':
$ref: '#/components/schemas/LdContext'
location:
type: array
items:
$ref: '#/components/schemas/GeoProperty'
minItems: 1
observationSpace:
type: array
items:
$ref: '#/components/schemas/GeoProperty'
minItems: 1
operationSpace:
type: array
items:
$ref: '#/components/schemas/GeoProperty'
minItems: 1
id:
type: string
format: uri
type:
$ref: '#/components/schemas/Name'
additionalProperties:
oneOf:
- type: array
items:
$ref: '#/components/schemas/Property'
minItems: 1
- type: array
items:
$ref: '#/components/schemas/Relationship'
minItems: 1
- type: array
items:
$ref: '#/components/schemas/GeoProperty'
minItems: 1
EntityTemporal:
type: object
properties:
'@context':
$ref: '#/components/schemas/LdContext'
location:
type: array
items:
$ref: '#/components/schemas/GeoProperty'
minItems: 1
observationSpace:
type: array
items:
$ref: '#/components/schemas/GeoProperty'
minItems: 1
operationSpace:
type: array
items:
$ref: '#/components/schemas/GeoProperty'
minItems: 1
id:
type: string
format: uri
type:
$ref: '#/components/schemas/Name'
createdAt:
$ref: '#/components/schemas/createdAt'
modifiedAt:
$ref: '#/components/schemas/modifiedAt'
additionalProperties:
oneOf:
- type: array
items:
$ref: '#/components/schemas/Property'
minItems: 1
- type: array
items:
$ref: '#/components/schemas/Relationship'
minItems: 1
- type: array
items:
$ref: '#/components/schemas/GeoProperty'
minItems: 1
required:
- type
- id
EntityTemporalList:
type: array
items:
$ref: '#/components/schemas/EntityTemporal'
TemporalQuery:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,32 @@
import org.fiware.ngsi.model.EntityFragmentVO;
import org.fiware.ngsi.model.EntityVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(componentModel = "jsr330")
public interface NGSIMapper {

@Mapping(target = "id", expression = "java(null)")
EntityFragmentVO map(EntityVO entityVO);
default EntityFragmentVO map(EntityVO entityVO) {
if (entityVO == null) {
return null;
}

EntityFragmentVO entityFragmentVO = new EntityFragmentVO();
if (entityFragmentVO.getAdditionalProperties() != null) {
entityVO.getAdditionalProperties().clear();
}
entityVO.getAdditionalProperties().entrySet().forEach(entry -> entityFragmentVO.setAdditionalProperties(entry.getKey(), entry.getValue()));

entityFragmentVO.setAtContext(entityVO.getAtContext());
entityFragmentVO.setLocation(entityVO.getLocation());
entityFragmentVO.setObservationSpace(entityVO.getObservationSpace());
entityFragmentVO.setOperationSpace(entityVO.getOperationSpace());
entityFragmentVO.setType(entityVO.getType());
entityFragmentVO.setCreatedAt(entityVO.getCreatedAt());
entityFragmentVO.setModifiedAt(entityVO.getModifiedAt());

entityFragmentVO.setId(null);

return entityFragmentVO;
}

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package org.fiware.tmforum.common.repository;

import io.reactivex.Maybe;
import io.reactivex.Single;
import lombok.extern.slf4j.Slf4j;
import org.fiware.ngsi.api.EntitiesApi;
import org.fiware.ngsi.api.EntitiesApiClient;
import org.fiware.ngsi.model.EntityVO;
import org.fiware.tmforum.common.configuration.GeneralProperties;
import org.fiware.tmforum.mapping.EntitiesRepository;
import reactor.core.publisher.Mono;

import javax.inject.Singleton;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Expand All @@ -21,20 +19,20 @@
@Singleton
public class BrokerBackedEntitiesRepository extends NgsiLdBaseRepository implements EntitiesRepository {

public BrokerBackedEntitiesRepository(GeneralProperties generalProperties, EntitiesApi entitiesApi) {
public BrokerBackedEntitiesRepository(GeneralProperties generalProperties, EntitiesApiClient entitiesApi) {
super(generalProperties, entitiesApi);
}

@Override
public Single<List<EntityVO>> getEntities(List<URI> entityIds) {
public Mono<List<EntityVO>> getEntities(List<URI> entityIds) {

// this can be replaced in the futures, when the brokers properly implement the retrieval of entities with multiple sub-properties, with an idPattern query
// Currently:
// * orion-ld: does not properly handle datasetIDs, thus omits such properties and relationships on retrieval
// * scoprio: declares query parameters as mandatory, that are optional in the spec
// * stellio: not tested yet
return Maybe.zip(
return Mono.zip(
entityIds.stream().map(this::retrieveEntityById).toList(),
eVOs -> Arrays.stream(eVOs).map(EntityVO.class::cast).toList()).toSingle(new ArrayList<>());
eVOs -> Arrays.stream(eVOs).map(EntityVO.class::cast).toList());
}
}
Loading

0 comments on commit 274e058

Please sign in to comment.