example.asset/src/example/asset/lexicon/ExampleRelatedObsAsset.java
private Observation createARelatedObservation(String sensorId, ObservationSubTypeEnum observationType,
            Observation linkToObs, RelationshipTypeEnum linkToObsRelationship) throws ValidationFailedException
    {
        final Observation observation = new Observation();
        observation.withSensorId(sensorId);
        
        ObservationRef relatedObsRef = new ObservationRef();
        relatedObsRef.setUuid(linkToObs.getUuid());
        relatedObsRef.setRelationship(new Relationship().withRelationshipType(linkToObsRelationship));
        observation.withRelatedObservations(relatedObsRef);
        
        if (observationType == null)
        {
            Coordinates assetLoc = new Coordinates()
                .withLatitude(new LatitudeWgsDegrees().withValue(50.0))
                .withLongitude(new LongitudeWgsDegrees().withValue(70.0));
            Coordinates pointLoc = new Coordinates().withLatitude(new LatitudeWgsDegrees().withValue(88.0))
                    .withLongitude(new LongitudeWgsDegrees().withValue(10.0));
            
            Orientation assetOrient = new Orientation().withHeading(
                    new HeadingDegrees().withPrecision(10.0).withStdev(1.0));
            Orientation pltOrient = new Orientation().withHeading(new HeadingDegrees()
                .withPrecision(2.0).withStdev(15.0));
            
            observation.withAssetLocation(assetLoc);
            observation.withAssetOrientation(assetOrient);
            
            observation.withPointingLocation(pointLoc);
            observation.withPlatformOrientation(pltOrient);
        }
        else
        {
            switch (observationType)
            {
                case DETECTION:
                    LatitudeWgsDegrees lat = new LatitudeWgsDegrees().withValue(50.0);
                    LongitudeWgsDegrees lng = new LongitudeWgsDegrees().withValue(70.0);
                    Coordinates coords = new Coordinates().withLatitude(lat).withLongitude(lng);
                    Detection detection = new Detection();
                    detection.setType(DetectionTypeEnum.TAMPER);
                    final HeadingDegrees heading = new HeadingDegrees().withValue(50);
                    final ElevationDegrees elevation = new ElevationDegrees().withValue(90);
                    detection.withTargetLocation(coords);
                    detection.withTargetOrientation(new Orientation(heading, elevation, null));
                    detection.withTrackHistories(new TrackElement(coords, new SpeedMetersPerSecond(205.5, null, null, 
                            null, null), new Orientation(heading, elevation, null), null, 2003L));
                    detection.setTargetFrequency(new FrequencyKhz().withValue(30));
                    detection.setTargetId("example-target-id");
                    
                    observation.withDetection(detection);
                    observation.withModalities(new SensingModality().withValue(SensingModalityEnum.ACOUSTIC));
                    break;
                case STATUS:
                    Status status = new Status().withBatteryVoltage(new VoltageVolts().withValue(3.4f))
                        .withSummaryStatus(new OperatingStatus().withSummary(SummaryStatusEnum.GOOD));
                    observation.setStatus(status);
                    break;
                case WEATHER:
                    Weather weather = new Weather().withRoadCondition(new RoadCondition()                    
                        .withType(new RoadConditionType(RoadConditionTypeEnum.BLACK_ICE, "Black Ice")))
                        .withTemperature(new TemperatureCelsius().withValue(19.0));
                    observation.setWeather(weather);
                    break;
                case AUDIO_METADATA:
                    DigitalMedia digitalAudio = new DigitalMedia().withEncoding("audio/mp3").withValue(new byte[100]);
                    AudioMetadata audio = new AudioMetadata().withStartTime(System.currentTimeMillis())
                        .withEndTime(System.currentTimeMillis() + 3000).withSampleRateKHz(52)
                        .withSampleOfInterest(new AudioSampleOfInterest()
                            .withStartTime(1L).withEndTime(2L))
                        .withRecorderType(new AudioRecorder().withValue(AudioRecorderEnum.MICROPHONE));
                    observation.withDigitalMedia(digitalAudio).withAudioMetadata(audio);
                    break;
                case IMAGE_METADATA:
                    DigitalMedia digitalImage = new DigitalMedia().withEncoding("image/jpeg").withValue(new byte[100]);
                    ImageMetadata image = new ImageMetadata().withImager(new Camera()
                        .withType(CameraTypeEnum.OTHER))
                            .withImageCaptureReason(new ImageCaptureReason().withValue(ImageCaptureReasonEnum.OTHER));
                    observation.withDigitalMedia(digitalImage).withImageMetadata(image);
                    break;
                case VIDEO_METADATA:
                    DigitalMedia digitalVideo = new DigitalMedia().withEncoding("video/wav").withValue(new byte[100]);
                    VideoMetadata videoData = new VideoMetadata().withRecorder(new Camera()
                        .withType(CameraTypeEnum.OTHER));
                    observation.withDigitalMedia(digitalVideo).withVideoMetadata(videoData);
                    break;
                default:
                    throw new IllegalArgumentException(String.format("No case exists for %s!"
                            + " Cannot create related observation.", observationType));
            }
        }
        
        m_Context.persistObservation(observation);
        
        return observation;
    }
/**
     * Randomly generates an observation that is to be used as a related observation. Also, creates links 
     * back to the given observation.
     * 
     * @param sensorId
     *  the sensor id of the created observation
     * @param linkToObs
     *  the observation that the related observation is to be created for
     * @param linkToObsRelationship
     *  the observations relationship to the created related observation
     * @return
     *  the related observation for the given linkToObs 
     */
Randomly generates an observation that is to be used as a related observation. Also, creates links
back to the given observation.

@param sensorId
the sensor id of the created observation
@param linkToObs
the observation that the related observation is to be created for
@param linkToObsRelationship
the observations relationship to the created related observation
@return
the related observation for the given linkToObs
Randomly generates an observation that is to be used as a related observation . Also creates links back to the given observation . @param sensorId the sensor id of the created observation @param linkToObs the observation that the related observation is to be created for @param linkToObsRelationship the observations relationship to the created related observation @return the related observation for the given linkToObs
private Observation createARelatedObservation(String sensorId, ObservationSubTypeEnum observationType,
            Observation linkToObs, RelationshipTypeEnum linkToObsRelationship) throws ValidationFailedException
    {
        final Observation observation = new Observation();
        observation.withSensorId(sensorId);
        ObservationRef relatedObsRef = new ObservationRef();
        relatedObsRef.setUuid(linkToObs.getUuid());
        relatedObsRef.setRelationship(new Relationship().withRelationshipType(linkToObsRelationship));
        observation.withRelatedObservations(relatedObsRef);
        if (observationType == null)
        {
            Coordinates assetLoc = new Coordinates()
                .withLatitude(new LatitudeWgsDegrees().withValue(50.0))
                .withLongitude(new LongitudeWgsDegrees().withValue(70.0));
            Coordinates pointLoc = new Coordinates().withLatitude(new LatitudeWgsDegrees().withValue(88.0))
                    .withLongitude(new LongitudeWgsDegrees().withValue(10.0));
            Orientation assetOrient = new Orientation().withHeading(
                    new HeadingDegrees().withPrecision(10.0).withStdev(1.0));
            Orientation pltOrient = new Orientation().withHeading(new HeadingDegrees()
                .withPrecision(2.0).withStdev(15.0));
            observation.withAssetLocation(assetLoc);
            observation.withAssetOrientation(assetOrient);
            observation.withPointingLocation(pointLoc);
            observation.withPlatformOrientation(pltOrient);
        }
        else
        {
            switch (observationType)
            {
                case DETECTION:
                    LatitudeWgsDegrees lat = new LatitudeWgsDegrees().withValue(50.0);
                    LongitudeWgsDegrees lng = new LongitudeWgsDegrees().withValue(70.0);
                    Coordinates coords = new Coordinates().withLatitude(lat).withLongitude(lng);
                    Detection detection = new Detection();
                    detection.setType(DetectionTypeEnum.TAMPER);
                    final HeadingDegrees heading = new HeadingDegrees().withValue(50);
                    final ElevationDegrees elevation = new ElevationDegrees().withValue(90);
                    detection.withTargetLocation(coords);
                    detection.withTargetOrientation(new Orientation(heading, elevation, null));
                    detection.withTrackHistories(new TrackElement(coords, new SpeedMetersPerSecond(205.5, null, null, 
                            null, null), new Orientation(heading, elevation, null), null, 2003L));
                    detection.setTargetFrequency(new FrequencyKhz().withValue(30));
                    detection.setTargetId("example-target-id");
                    observation.withDetection(detection);
                    observation.withModalities(new SensingModality().withValue(SensingModalityEnum.ACOUSTIC));
                    break;
                case STATUS:
                    Status status = new Status().withBatteryVoltage(new VoltageVolts().withValue(3.4f))
                        .withSummaryStatus(new OperatingStatus().withSummary(SummaryStatusEnum.GOOD));
                    observation.setStatus(status);
                    break;
                case WEATHER:
                    Weather weather = new Weather().withRoadCondition(new RoadCondition()                    
                        .withType(new RoadConditionType(RoadConditionTypeEnum.BLACK_ICE, "Black Ice")))
                        .withTemperature(new TemperatureCelsius().withValue(19.0));
                    observation.setWeather(weather);
                    break;
                case AUDIO_METADATA:
                    DigitalMedia digitalAudio = new DigitalMedia().withEncoding("audio/mp3").withValue(new byte[100]);
                    AudioMetadata audio = new AudioMetadata().withStartTime(System.currentTimeMillis())
                        .withEndTime(System.currentTimeMillis() + 3000).withSampleRateKHz(52)
                        .withSampleOfInterest(new AudioSampleOfInterest()
                            .withStartTime(1L).withEndTime(2L))
                        .withRecorderType(new AudioRecorder().withValue(AudioRecorderEnum.MICROPHONE));
                    observation.withDigitalMedia(digitalAudio).withAudioMetadata(audio);
                    break;
                case IMAGE_METADATA:
                    DigitalMedia digitalImage = new DigitalMedia().withEncoding("image/jpeg").withValue(new byte[100]);
                    ImageMetadata image = new ImageMetadata().withImager(new Camera()
                        .withType(CameraTypeEnum.OTHER))
                            .withImageCaptureReason(new ImageCaptureReason().withValue(ImageCaptureReasonEnum.OTHER));
                    observation.withDigitalMedia(digitalImage).withImageMetadata(image);
                    break;
                case VIDEO_METADATA:
                    DigitalMedia digitalVideo = new DigitalMedia().withEncoding("video/wav").withValue(new byte[100]);
                    VideoMetadata videoData = new VideoMetadata().withRecorder(new Camera()
                        .withType(CameraTypeEnum.OTHER));
                    observation.withDigitalMedia(digitalVideo).withVideoMetadata(videoData);
                    break;
                default:
                    throw new IllegalArgumentException(String.format("No case exists for %s!"
                            + " Cannot create related observation.", observationType));
            }
        }
        m_Context.persistObservation(observation);
        return observation;
    }
private Observation createARelatedObservation ( String sensorId , ObservationSubTypeEnum observationType , Observation linkToObs , RelationshipTypeEnum linkToObsRelationship ) throws ValidationFailedException { final Observation observation = new Observation ( ) ; observation . withSensorId ( sensorId ) ; ObservationRef relatedObsRef = new ObservationRef ( ) ; relatedObsRef . setUuid ( linkToObs . getUuid ( ) ) ; relatedObsRef . setRelationship ( new Relationship ( ) . withRelationshipType ( linkToObsRelationship ) ) ; observation . withRelatedObservations ( relatedObsRef ) ; if ( observationType == null ) { Coordinates assetLoc = new Coordinates ( ) . withLatitude ( new LatitudeWgsDegrees ( ) . withValue ( 50.0 ) ) . withLongitude ( new LongitudeWgsDegrees ( ) . withValue ( 70.0 ) ) ; Coordinates pointLoc = new Coordinates ( ) . withLatitude ( new LatitudeWgsDegrees ( ) . withValue ( 88.0 ) ) . withLongitude ( new LongitudeWgsDegrees ( ) . withValue ( 10.0 ) ) ; Orientation assetOrient = new Orientation ( ) . withHeading ( new HeadingDegrees ( ) . withPrecision ( 10.0 ) . withStdev ( 1.0 ) ) ; Orientation pltOrient = new Orientation ( ) . withHeading ( new HeadingDegrees ( ) . withPrecision ( 2.0 ) . withStdev ( 15.0 ) ) ; observation . withAssetLocation ( assetLoc ) ; observation . withAssetOrientation ( assetOrient ) ; observation . withPointingLocation ( pointLoc ) ; observation . withPlatformOrientation ( pltOrient ) ; } else { switch ( observationType ) { case DETECTION : LatitudeWgsDegrees lat = new LatitudeWgsDegrees ( ) . withValue ( 50.0 ) ; LongitudeWgsDegrees lng = new LongitudeWgsDegrees ( ) . withValue ( 70.0 ) ; Coordinates coords = new Coordinates ( ) . withLatitude ( lat ) . withLongitude ( lng ) ; Detection detection = new Detection ( ) ; detection . setType ( DetectionTypeEnum . TAMPER ) ; final HeadingDegrees heading = new HeadingDegrees ( ) . withValue ( 50 ) ; final ElevationDegrees elevation = new ElevationDegrees ( ) . withValue ( 90 ) ; detection . withTargetLocation ( coords ) ; detection . withTargetOrientation ( new Orientation ( heading , elevation , null ) ) ; detection . withTrackHistories ( new TrackElement ( coords , new SpeedMetersPerSecond ( 205.5 , null , null , null , null ) , new Orientation ( heading , elevation , null ) , null , 2003L ) ) ; detection . setTargetFrequency ( new FrequencyKhz ( ) . withValue ( 30 ) ) ; detection . setTargetId ( "example-target-id" ) ; observation . withDetection ( detection ) ; observation . withModalities ( new SensingModality ( ) . withValue ( SensingModalityEnum . ACOUSTIC ) ) ; break ; case STATUS : Status status = new Status ( ) . withBatteryVoltage ( new VoltageVolts ( ) . withValue ( 3.4f ) ) . withSummaryStatus ( new OperatingStatus ( ) . withSummary ( SummaryStatusEnum . GOOD ) ) ; observation . setStatus ( status ) ; break ; case WEATHER : Weather weather = new Weather ( ) . withRoadCondition ( new RoadCondition ( ) . withType ( new RoadConditionType ( RoadConditionTypeEnum . BLACK_ICE , "Black Ice" ) ) ) . withTemperature ( new TemperatureCelsius ( ) . withValue ( 19.0 ) ) ; observation . setWeather ( weather ) ; break ; case AUDIO_METADATA : DigitalMedia digitalAudio = new DigitalMedia ( ) . withEncoding ( "audio/mp3" ) . withValue ( new byte [ 100 ] ) ; AudioMetadata audio = new AudioMetadata ( ) . withStartTime ( System . currentTimeMillis ( ) ) . withEndTime ( System . currentTimeMillis ( ) + 3000 ) . withSampleRateKHz ( 52 ) . withSampleOfInterest ( new AudioSampleOfInterest ( ) . withStartTime ( 1L ) . withEndTime ( 2L ) ) . withRecorderType ( new AudioRecorder ( ) . withValue ( AudioRecorderEnum . MICROPHONE ) ) ; observation . withDigitalMedia ( digitalAudio ) . withAudioMetadata ( audio ) ; break ; case IMAGE_METADATA : DigitalMedia digitalImage = new DigitalMedia ( ) . withEncoding ( "image/jpeg" ) . withValue ( new byte [ 100 ] ) ; ImageMetadata image = new ImageMetadata ( ) . withImager ( new Camera ( ) . withType ( CameraTypeEnum . OTHER ) ) . withImageCaptureReason ( new ImageCaptureReason ( ) . withValue ( ImageCaptureReasonEnum . OTHER ) ) ; observation . withDigitalMedia ( digitalImage ) . withImageMetadata ( image ) ; break ; case VIDEO_METADATA : DigitalMedia digitalVideo = new DigitalMedia ( ) . withEncoding ( "video/wav" ) . withValue ( new byte [ 100 ] ) ; VideoMetadata videoData = new VideoMetadata ( ) . withRecorder ( new Camera ( ) . withType ( CameraTypeEnum . OTHER ) ) ; observation . withDigitalMedia ( digitalVideo ) . withVideoMetadata ( videoData ) ; break ; default : throw new IllegalArgumentException ( String . format ( "No case exists for %s!" + " Cannot create related observation." , observationType ) ) ; } } m_Context . persistObservation ( observation ) ; return observation ; }
Randomly generates an observation that is to be used as a related observation.
Randomly generates an observation that is to be used as a related observation .