use of io.hops.hopsworks.persistence.entity.jobs.configuration.DefaultJobConfigurationPK in project hopsworks by logicalclocks.
the class DefaultJobConfigurationFacade method createOrUpdate.
public DefaultJobConfiguration createOrUpdate(Project project, JobConfiguration jobConfiguration, JobType jobType, DefaultJobConfiguration currentConfig) throws ProjectException {
if (jobConfiguration instanceof SparkJobConfiguration) {
((SparkJobConfiguration) jobConfiguration).setMainClass(Settings.SPARK_PY_MAINCLASS);
jobType = JobType.PYSPARK;
}
// create
if (currentConfig == null) {
currentConfig = new DefaultJobConfiguration();
DefaultJobConfigurationPK pk = new DefaultJobConfigurationPK();
pk.setProjectId(project.getId());
pk.setType(jobType);
currentConfig.setDefaultJobConfigurationPK(pk);
currentConfig.setJobConfig(jobConfiguration);
project.getDefaultJobConfigurationCollection().add(currentConfig);
em.merge(project);
return currentConfig;
// update
} else {
for (DefaultJobConfiguration dc : project.getDefaultJobConfigurationCollection()) {
if (dc.getDefaultJobConfigurationPK().getType().equals(jobType)) {
dc.setJobConfig(jobConfiguration);
em.merge(project);
return dc;
}
}
throw new ProjectException(RESTCodes.ProjectErrorCode.PROJECT_DEFAULT_JOB_CONFIG_NOT_FOUND, Level.FINEST);
}
}
Aggregations