Source:
<code>public long save(Experiment experiment) throws IOException { try { authorizationManager.throwIfNotWritable(experiment); if (experiment.getId() == ExperimentImpl.UNSAVED_ID) { <START> experimentStore.save(experiment); <END> String name = namingScheme.generateNameFor(experiment); experiment.setName(name); ValidationResult nameValidation = namingScheme.validateName(experiment.getName()); if (!nameValidation.isValid()) { throw new IOException("Cannot save Experiment - invalid name:" + nameValidation.getMessage()); } return experimentStore.save(experiment); } ValidationResult nameValidation = namingScheme.validateName(experiment.getName()); if (!nameValidation.isValid()) { throw new IOException("Cannot save Experiment - invalid name:" + nameValidation.getMessage()); } Experiment original = experimentStore.get(experiment.getId()); authorizationManager.throwIfNotWritable(original); original.setAccession(experiment.getAccession()); original.setAlias(experiment.getAlias()); original.setDescription(experiment.getDescription()); original.setName(experiment.getName()); original.setPlatform(platformStore.get(experiment.getPlatform().getId())); original.setPool(poolStore.get(experiment.getPool().getId())); original.setStudy(studyStore.get(experiment.getStudy().getId())); original.setSecurityProfile(securityStore.getSecurityProfileById(experiment.getSecurityProfile().getProfileId())); original.setTitle(experiment.getTitle()); Set<Kit> kits = new HashSet<>(); for (Kit k : experiment.getKits()) { kits.add(kitStore.get(k.getId())); } original.setKits(kits); return experimentStore.save(original); } catch (MisoNamingException e) { throw new IOException("Cannot save Experiment - issue with naming scheme", e); } }</code><technical_language>fail due null name. generate a temporary name first, is done Samples</technical_language>

Target:
public long save(Experiment experiment) throws IOException { try { authorizationManager.throwIfNotWritable(experiment); if (experiment.getId() == ExperimentImpl.UNSAVED_ID) { experiment.setName(DbUtils.generateTemporaryName()); experimentStore.save(experiment); String name = namingScheme.generateNameFor(experiment); experiment.setName(name); ValidationResult nameValidation = namingScheme.validateName(experiment.getName()); if (!nameValidation.isValid()) { throw new IOException("Cannot save Experiment - invalid name:" + nameValidation.getMessage()); } return experimentStore.save(experiment); } ValidationResult nameValidation = namingScheme.validateName(experiment.getName()); if (!nameValidation.isValid()) { throw new IOException("Cannot save Experiment - invalid name:" + nameValidation.getMessage()); } Experiment original = experimentStore.get(experiment.getId()); authorizationManager.throwIfNotWritable(original); original.setAccession(experiment.getAccession()); original.setAlias(experiment.getAlias()); original.setDescription(experiment.getDescription()); original.setName(experiment.getName()); original.setPlatform(platformStore.get(experiment.getPlatform().getId())); original.setPool(poolStore.get(experiment.getPool().getId())); original.setStudy(studyStore.get(experiment.getStudy().getId())); original.setSecurityProfile(securityStore.getSecurityProfileById(experiment.getSecurityProfile().getProfileId())); original.setTitle(experiment.getTitle()); Set<Kit> kits = new HashSet<>(); for (Kit k : experiment.getKits()) { kits.add(kitStore.get(k.getId())); } original.setKits(kits); return experimentStore.save(original); } catch (MisoNamingException e) { throw new IOException("Cannot save Experiment - issue with naming scheme", e); } }