private BuildRecord . Builder initBuildRecordBuilder ( BuildTask buildTask ) { BuildOptions buildOptions = buildTask . getBuildOptions ( ) ; BuildRecord . Builder builder = BuildRecord . Builder . newBuilder ( ) . id ( buildTask . getId ( ) ) . buildConfigurationAudited ( buildTask . getBuildConfigurationAudited ( ) ) . user ( buildTask . getUser ( ) ) . submitTime ( buildTask . getSubmitTime ( ) ) . startTime ( buildTask . getStartTime ( ) ) . productMilestone ( buildTask . getProductMilestone ( ) ) . temporaryBuild ( buildOptions . isTemporaryBuild ( ) ) ; if ( buildTask . getEndTime ( ) == null ) { buildTask . setEndTime ( Date . from ( Instant . now ( ) ) ) ; } builder . endTime ( buildTask . getEndTime ( ) ) ; if ( buildTask . getBuildConfigSetRecordId ( ) != null ) { BuildConfigSetRecord buildConfigSetRecord = datastore . getBuildConfigSetRecordById ( buildTask . getBuildConfigSetRecordId ( ) ) ; builder . buildConfigSetRecord ( buildConfigSetRecord ) ; } List < Integer > dependencies = buildTask . getDependencies ( ) . stream ( ) . map ( t -> t . getId ( ) ) . collect ( Collectors . toList ( ) ) ; builder . dependencyBuildRecordIds ( dependencies . toArray ( new Integer [ dependencies . size ( ) ] ) ) ; List < Integer > dependants = buildTask . getDependants ( ) . stream ( ) . map ( t -> t . getId ( ) ) . collect ( Collectors . toList ( ) ) ; builder . dependentBuildRecordIds ( dependants . toArray ( new Integer [ dependants . size ( ) ] ) ) ; return builder ; }
Initialize a new BuildRecord . Builder based on the data contained in the BuildTask . Note this must be done inside a transaction because it fetches the BuildRecordSet entities from the database .