use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class MetacardApplication method patchMetacards.
protected UpdateResponse patchMetacards(List<MetacardChanges> metacardChanges) throws SourceUnavailableException, IngestException, FederationException, UnsupportedQueryException {
Set<String> changedIds = metacardChanges.stream().flatMap(mc -> mc.getIds().stream()).collect(Collectors.toSet());
Map<String, Result> results = util.getMetacards(changedIds, "*");
for (MetacardChanges changeset : metacardChanges) {
for (AttributeChange attributeChange : changeset.getAttributes()) {
for (String id : changeset.getIds()) {
List<String> values = attributeChange.getValues();
Metacard result = results.get(id).getMetacard();
Function<Serializable, Serializable> mapFunc = Function.identity();
if (isChangeTypeDate(attributeChange, result)) {
mapFunc = mapFunc.andThen(util::parseDate);
}
result.setAttribute(new AttributeImpl(attributeChange.getAttribute(), values.stream().filter(Objects::nonNull).map(mapFunc).collect(Collectors.toList())));
}
}
}
List<Metacard> changedMetacards = results.values().stream().map(Result::getMetacard).collect(Collectors.toList());
return catalogFramework.update(new UpdateRequestImpl(changedMetacards.stream().map(Metacard::getId).collect(Collectors.toList()).toArray(new String[0]), changedMetacards));
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class RequiredAttributesMetacardValidatorTest method testInvalidMetacard.
@Test
public void testInvalidMetacard() {
final Metacard metacard = new MetacardImpl();
metacard.setAttribute(new AttributeImpl("title", "test"));
metacard.setAttribute(new AttributeImpl("created", new Date()));
metacard.setAttribute(new AttributeImpl("thumbnail", new byte[] { 1, 2, 3, 4 }));
validateWithErrors(metacard, Sets.newHashSet("title", "created", "thumbnail", "effective", "metadata"), 2);
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class SizeValidatorTest method testValidMapValue.
@Test
public void testValidMapValue() {
final HashMap<Integer, Integer> map = new HashMap<>();
map.put(1, 2);
validateNoErrors(new AttributeImpl("test", map), 0, 5);
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class PastDateValidatorTest method validateNoErrors.
private void validateNoErrors(final Instant instant) {
final Optional<AttributeValidationReport> reportOptional = VALIDATOR.validate(new AttributeImpl("test", Date.from(instant)));
assertThat(reportOptional.isPresent(), is(false));
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class PatternValidatorTest method validateNoErrors.
private void validateNoErrors(final String value) {
final Optional<AttributeValidationReport> reportOptional = VALIDATOR.validate(new AttributeImpl("test", value));
assertThat(reportOptional.isPresent(), is(false));
}
Aggregations