/** * Copy information from SPI into Mongo {@link Document}. * * @param source * @param target */ public static void toDocument(IArea source, Document target) { target.append(PROP_AREA_TYPE_ID, source.getAreaTypeId()); target.append(PROP_PARENT_AREA_ID, source.getParentAreaId()); target.append(PROP_NAME, source.getName()); target.append(PROP_DESCRIPTION, source.getDescription()); MongoBoundedEntity.saveBounds(source, target); MongoBrandedEntity.toDocument(source, target); }
/** * Convert area from API to GRPC. * * @param api * @return * @throws SiteWhereException */ public static GArea asGrpcArea(IArea api) throws SiteWhereException { GArea.Builder grpc = GArea.newBuilder(); grpc.setAreaTypeId(CommonModelConverter.asGrpcUuid(api.getAreaTypeId())); if (api.getParentAreaId() != null) { grpc.setParentAreaId(CommonModelConverter.asGrpcUuid(api.getParentAreaId())); } grpc.setName(api.getName()); grpc.setDescription(api.getDescription()); grpc.addAllBounds(CommonModelConverter.asGrpcLocations(api.getBounds())); grpc.setEntityInformation(CommonModelConverter.asGrpcEntityInformation(api)); grpc.setBranding(CommonModelConverter.asGrpcBrandingInformation(api)); return grpc.build(); }
area.setParentAreaId(source.getParentAreaId()); area.setName(source.getName()); area.setDescription(source.getDescription()); if (source.getParentAreaId() != null) { IArea parent = getDeviceManagement().getArea(source.getParentAreaId()); area.setParentArea(parent);