use of com.synopsys.integration.alert.common.rest.model.FieldModel in project hub-alert by blackducksoftware.
the class FieldModelProcessor method createCustomMessageFieldModel.
public FieldModel createCustomMessageFieldModel(FieldModel fieldModel) throws AlertException {
String id = fieldModel.getId();
FieldModel upToDateFieldModel = fieldModel;
if (StringUtils.isNotBlank(id)) {
Long convertedId = Long.parseLong(id);
upToDateFieldModel = populateTestFieldModel(convertedId, fieldModel);
}
return upToDateFieldModel;
}
use of com.synopsys.integration.alert.common.rest.model.FieldModel in project hub-alert by blackducksoftware.
the class FieldModelProcessor method populateTestFieldModel.
private FieldModel populateTestFieldModel(Long id, FieldModel fieldModel) throws AlertException {
Collection<ConfigurationFieldModel> configurationFieldModels = fillFieldModelWithExistingData(id, fieldModel);
Map<String, FieldValueModel> fields = new HashMap<>();
for (ConfigurationFieldModel configurationFieldModel : configurationFieldModels) {
FieldValueModel fieldValueModel = new FieldValueModel(configurationFieldModel.getFieldValues(), configurationFieldModel.isSet());
fields.put(configurationFieldModel.getFieldKey(), fieldValueModel);
}
FieldModel newFieldModel = new FieldModel("", "", fieldModel.getCreatedAt(), fieldModel.getLastUpdated(), fields);
return fieldModel.fill(newFieldModel);
}
use of com.synopsys.integration.alert.common.rest.model.FieldModel in project hub-alert by blackducksoftware.
the class DefaultDescriptorGlobalConfigUtility method getFieldModel.
public Optional<FieldModel> getFieldModel() throws AlertException {
Optional<ConfigurationModel> configurationModelOptional = getConfiguration();
if (configurationModelOptional.isPresent()) {
ConfigurationModel configurationModel = configurationModelOptional.get();
FieldModel fieldModel = configurationFieldModelConverter.convertToFieldModel(configurationModel);
return Optional.ofNullable(apiAction.afterGetAction(fieldModel));
}
return Optional.empty();
}
use of com.synopsys.integration.alert.common.rest.model.FieldModel in project hub-alert by blackducksoftware.
the class AbstractJobResourceActions method correctProjectsField.
// FIXME More tech debt until we fix the Jobs API
private void correctProjectsField(JobFieldModel jobFieldModel) {
List<JobProviderProjectFieldModel> projects = jobFieldModel.getConfiguredProviderProjects();
if (null == projects) {
projects = List.of();
}
String projectFieldKey = "channel.common.configured.project";
for (FieldModel fieldModel : jobFieldModel.getFieldModels()) {
Map<String, FieldValueModel> keyToValues = fieldModel.getKeyToValues();
if (keyToValues.containsKey(projectFieldKey)) {
FieldValueModel projectFieldValues = createProjectFieldValues(projects);
keyToValues.put(projectFieldKey, projectFieldValues);
return;
}
}
}
use of com.synopsys.integration.alert.common.rest.model.FieldModel in project hub-alert by blackducksoftware.
the class AlertStartupInitializer method createFieldModelsFromDefinedFields.
private Set<ConfigurationFieldModel> createFieldModelsFromDefinedFields(DescriptorKey descriptorKey, List<DefinedFieldModel> fieldsForDescriptor, Map<String, ConfigurationFieldModel> existingConfiguredFields) {
Set<ConfigurationFieldModel> configurationModels = new HashSet<>();
logger.info(" ### Environment Variables ### ");
for (DefinedFieldModel fieldModel : fieldsForDescriptor) {
String key = fieldModel.getKey();
String convertedKey = environmentUtility.convertKeyToProperty(descriptorKey, key);
boolean hasEnvironmentValue = environmentUtility.hasEnvironmentValue(convertedKey);
logger.info(" {}", convertedKey);
logger.debug(" Environment Variable Found - {}", hasEnvironmentValue);
String defaultValue = null;
if (existingConfiguredFields.containsKey(key)) {
Optional<String> fieldValue = existingConfiguredFields.get(key).getFieldValue();
if (fieldValue.isPresent()) {
defaultValue = fieldValue.get();
}
}
environmentUtility.getEnvironmentValue(convertedKey, defaultValue).flatMap(value -> modelConverter.convertFromDefinedFieldModel(fieldModel, value, StringUtils.isNotBlank(value))).ifPresent(configurationModels::add);
}
return configurationModels;
}
Aggregations