Closed ZouhairBear closed 4 years ago
[x] ExportApp will contain
ExportApp
@TypeChecked class ExportApp implements IExists { AppDTO appDTO = new AppDTO() AppVersionDTO AppVersionDTO = new AppVersionDTO() ArrayList<AppVersionDTO> versions = new ArrayList<AppVersionDTO>() @Override boolean exists() { return appDTO.exists() && AppVersionDTO.exists() } void setAppFromApiResult(appDetailResult) { AppDTO.setAppFromApiResult(appDetailResult) } void setAppVersionFromApiResult(version) { appVersionDTO.setAppVersionFromApiResult(version) } } void addAppVersionFromV2ApiResult(version) { AppVersionDTO appVersionDTOElement = new AppVersionDTO() appVersionDTOElement.setAppVersionFromApiResult(version) versions.add(appVersionDTOElement) }
AppDTO
class AppDTO extends JobDTO { int storageSizeInMB; void setAppFromApiResult(appDetailResult) { this.storageSizeInMB = appDetailResult.storageSizeInMB; this.setJobFromApiResult(appDetailResult); } }
[x] AppVersionDTO will contain
AppVersionDTO
class AppVersionDTO implements IExists { List<String> storagePaths = [] // String releaseNote // int number // List<ExposedPort> exposedPorts = [] // DockerInfos dockerInfo = new DockerInfos() // Resources resources = new Resources() // @Override boolean exists() { return dockerInfo || releaseNote || resources } void setAppVersionFromApiResult(version) { if (version.dockerInfo && version.dockerInfo.dockerCredentialsId) { dockerInfo.dockerCredentialsId = version.dockerInfo.dockerCredentialsId } if (version.dockerInfo && version.dockerInfo.image) { dockerInfo.image = version.dockerInfo.image } releaseNote = version.releaseNote storagePaths = version.storagePaths if (version.number) { number = version.number } if (version.exposedPorts) { exposedPorts = version.exposedPorts } if (version.resources) { resources = version.resources } } }
- [ ] `AppMapper` will contain
package io.saagie.plugin.dataops.models
class AppMapper { App job = new App() AppVersion jobVersion = new AppVersion()
public AppMapper() { this.AppVersion.resources { disk = 512 memory = 512 cpu = 0.3 } } Object app(Closure closure) { app.with(closure) } Object appVersion(Closure closure) { appVersion.with(closure) } def static Map mapAppAndAppVersionWithoutMail(App app, AppVersion appVersion, String projectId) { if (!app) { return null } def newAppConfig = mapAppWithoutMail(app, projectId) def mappedAppVersion = appVersion.toMap() if (appVersion) { newAppConfig.put('jobVersion', [ releaseNote : mappedAppVersion.releaseNote ]) if (mappedAppVersion.dockerInfo?.image) { newAppConfig.jobVersion.put('dockerInfo', [ image : mappedAppVersion.dockerInfo?.image, dockerCredentialsId: mappedAppVersion.dockerInfo?.dockerCredentialsId ]) } if (mappedAppVersion.resources?.cpu || mappedAppVersion.resources?.disk || mappedAppVersion.resources?.memory) { newAppConfig.jobVersion.put('resources', mappedAppVersion.resources) } if (mappedAppVersion.exposedPorts) { newAppConfig.jobVersion.put('exposedPorts', mappedAppVersion.exposedPorts) } } return newAppConfig } def static mapAppWithoutMail(App app, String projectId) { def mappedApp = app.toMap() def newAppConfig = [:] def technology = app.technology newAppConfig.put('job', [ name : mappedApp?.name, isScheduled : mappedApp?.isScheduled, category : mappedApp?.category, isStreaming : mappedApp?.isStreaming, description : mappedApp?.description, technology : [id: technology], storageSizeInMB: mappedApp?.storageSizeInMB ]) if (projectId) { newAppConfig.job.put("projectId", projectId) } if (mappedApp.id) { newAppConfig.job.put('id', mappedApp.id) } if (mappedApp.alerting?.emails) { newAppConfig.app.put('alerting', [ emails : mappedApp.alerting?.emails, statusList: mappedApp.alerting?.statusList, logins : mappedApp.alerting?.logins ]) } return newAppConfig }
}
Entites:
[x]
ExportApp
will containAppDTO
will contain[x]
AppVersionDTO
will containpackage io.saagie.plugin.dataops.models
class AppMapper { App job = new App() AppVersion jobVersion = new AppVersion()
}