private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final String distributionSetTypekey) { return distributionSetTypeManagement.getByKey(distributionSetTypekey) .orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypekey)); }
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final String distributionSetTypekey) { return distributionSetTypeManagement.getByKey(distributionSetTypekey) .orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypekey)); }
@Override protected Optional<DistributionSetType> findEntityByKey() { return distributionSetTypeManagement.getByKey(getTypeKey().getValue()); }
@Override protected Optional<DistributionSetType> findEntityByKey() { return distributionSetTypeManagement.getByKey(getTypeKey().getValue()); }
/** * Finds {@link DistributionSetType} in repository with given * {@link DistributionSetType#getKey()} or creates if it does not exist yet. * * @param dsTypeKey * {@link DistributionSetType#getKey()} * @param dsTypeName * {@link DistributionSetType#getName()} * @param mandatory * {@link DistributionSetType#getMandatoryModuleTypes()} * @param optional * {@link DistributionSetType#getOptionalModuleTypes()} * * @return persisted {@link DistributionSetType} */ public DistributionSetType findOrCreateDistributionSetType(final String dsTypeKey, final String dsTypeName, final Collection<SoftwareModuleType> mandatory, final Collection<SoftwareModuleType> optional) { return distributionSetTypeManagement.getByKey(dsTypeKey) .orElseGet(() -> distributionSetTypeManagement.create(entityFactory.distributionSetType().create() .key(dsTypeKey).name(dsTypeName).description(LOREM.words(10)).colour("black") .optional(optional.stream().map(SoftwareModuleType::getId).collect(Collectors.toList())) .mandatory(mandatory.stream().map(SoftwareModuleType::getId).collect(Collectors.toList())))); }
/** * Finds {@link DistributionSetType} in repository with given * {@link DistributionSetType#getKey()} or creates if it does not exist yet. * * @param dsTypeKey * {@link DistributionSetType#getKey()} * @param dsTypeName * {@link DistributionSetType#getName()} * @param mandatory * {@link DistributionSetType#getMandatoryModuleTypes()} * @param optional * {@link DistributionSetType#getOptionalModuleTypes()} * * @return persisted {@link DistributionSetType} */ public DistributionSetType findOrCreateDistributionSetType(final String dsTypeKey, final String dsTypeName, final Collection<SoftwareModuleType> mandatory, final Collection<SoftwareModuleType> optional) { return distributionSetTypeManagement.getByKey(dsTypeKey) .orElseGet(() -> distributionSetTypeManagement.create(entityFactory.distributionSetType().create() .key(dsTypeKey).name(dsTypeName).description(LOREM.words(10)).colour("black") .optional(optional.stream().map(SoftwareModuleType::getId).collect(Collectors.toList())) .mandatory(mandatory.stream().map(SoftwareModuleType::getId).collect(Collectors.toList())))); }
/** * Creates {@link DistributionSetType} in repository. * * @param dsTypeKey * {@link DistributionSetType#getKey()} * @param dsTypeName * {@link DistributionSetType#getName()} * * @return persisted {@link DistributionSetType} */ public DistributionSetType findOrCreateDistributionSetType(final String dsTypeKey, final String dsTypeName) { return distributionSetTypeManagement.getByKey(dsTypeKey) .orElseGet(() -> distributionSetTypeManagement.create(entityFactory.distributionSetType().create() .key(dsTypeKey).name(dsTypeName).description(LOREM.words(10)).colour("black"))); }
/** * Creates {@link DistributionSetType} in repository. * * @param dsTypeKey * {@link DistributionSetType#getKey()} * @param dsTypeName * {@link DistributionSetType#getName()} * * @return persisted {@link DistributionSetType} */ public DistributionSetType findOrCreateDistributionSetType(final String dsTypeKey, final String dsTypeName) { return distributionSetTypeManagement.getByKey(dsTypeKey) .orElseGet(() -> distributionSetTypeManagement.create(entityFactory.distributionSetType().create() .key(dsTypeKey).name(dsTypeName).description(LOREM.words(10)).colour("black"))); }