public static JsonLDEventMessage from ( final FedoraEvent evt ) { final String baseUrl = evt . getInfo ( ) . get ( BASE_URL ) ; // build objectId final String objectId = convertToExternalPath ( baseUrl + evt . getPath ( ) ) ; // build event types list final List < String > types = evt . getTypes ( ) . stream ( ) . map ( rdfType -> rdfType . getTypeAbbreviated ( ) ) . collect ( toList ( ) ) ; // comma-separated list for names of events (since name requires string rather than array) final String name = String . join ( ", " , evt . getTypes ( ) . stream ( ) . map ( rdfType -> rdfType . getName ( ) ) . collect ( toList ( ) ) ) ; // build resource types list final List < String > resourceTypes = new ArrayList <> ( evt . getResourceTypes ( ) ) ; if ( ! resourceTypes . contains ( PROV_NAMESPACE + "Entity" ) ) { resourceTypes . add ( PROV_NAMESPACE + "Entity" ) ; } // build actors list final List < Actor > actor = new ArrayList <> ( ) ; actor . add ( new Person ( evt . getUserURI ( ) . toString ( ) , singletonList ( "Person" ) ) ) ; final String softwareAgent = evt . getInfo ( ) . get ( USER_AGENT ) ; if ( softwareAgent != null ) { actor . add ( new Application ( softwareAgent , singletonList ( "Application" ) ) ) ; } final JsonLDEventMessage msg = new JsonLDEventMessage ( ) ; msg . id = evt . getEventID ( ) ; msg . context = Arrays . asList ( ACTIVITYSTREAMS_NS , new Context ( ) ) ; msg . actor = actor ; msg . published = evt . getDate ( ) ; msg . type = types ; msg . name = name ; msg . object = new Object ( objectId , resourceTypes , baseUrl ) ; return msg ; }
Populate a JsonLDEventMessage from a FedoraEvent