use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class Checksum method addChecksumAttributes.
private void addChecksumAttributes(Metacard metacard, final String checksumAlgorithm, final String checksumValue) {
metacard.setAttribute(new AttributeImpl(Metacard.CHECKSUM_ALGORITHM, checksumAlgorithm));
metacard.setAttribute(new AttributeImpl(Metacard.CHECKSUM, checksumValue));
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class Historian method setResourceUriForContent.
private void setResourceUriForContent(/*mutable*/
Map<String, Metacard> versionMetacards, CreateStorageResponse createStorageResponse) {
for (ContentItem contentItem : createStorageResponse.getCreatedContentItems()) {
Metacard metacard = versionMetacards.values().stream().filter(m -> contentItem.getId().equals(m.getId())).findFirst().orElse(null);
if (metacard == null) {
LOGGER.info("Could not find version metacard to set resource URI for (contentItem id: {})", contentItem.getId());
continue;
}
metacard.setAttribute(new AttributeImpl(Metacard.RESOURCE_URI, contentItem.getUri()));
}
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class MetacardVersionImpl method sanitizeVersionAttributes.
private static void sanitizeVersionAttributes(/*Mutable*/
Metacard source) {
Consumer<String> nullifySourceAttribute = (s) -> source.setAttribute(new AttributeImpl(s, (Serializable) null));
Sets.difference(VERSION_DESCRIPTORS, BasicTypes.BASIC_METACARD.getAttributeDescriptors()).stream().map(AttributeDescriptor::getName).forEach(nullifySourceAttribute);
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class CswEndpoint method updateRecords.
private int updateRecords(UpdateAction updateAction) throws CswException, FederationException, IngestException, SourceUnavailableException, UnsupportedQueryException {
if (updateAction.getMetacard() != null) {
Metacard newRecord = updateAction.getMetacard();
if (newRecord.getId() != null) {
UpdateRequest updateRequest = new UpdateRequestImpl(newRecord.getId(), newRecord);
LOGGER.debug("Attempting to update {} ", newRecord.getId());
UpdateResponse updateResponse = framework.update(updateRequest);
return updateResponse.getUpdatedMetacards().size();
} else {
throw new CswException("Unable to update record. No ID was specified in the request.", CswConstants.MISSING_PARAMETER_VALUE, updateAction.getHandle());
}
} else if (updateAction.getConstraint() != null) {
QueryConstraintType constraint = updateAction.getConstraint();
QueryRequest queryRequest = queryFactory.getQuery(constraint);
queryRequest = queryFactory.updateQueryRequestTags(queryRequest, schemaTransformerManager.getTransformerSchemaForId(updateAction.getTypeName()));
QueryResponse response = framework.query(queryRequest);
if (response.getHits() > 0) {
Map<String, Serializable> recordProperties = updateAction.getRecordProperties();
List<String> updatedMetacardIdsList = new ArrayList<>();
List<Metacard> updatedMetacards = new ArrayList<>();
for (Result result : response.getResults()) {
Metacard metacard = result.getMetacard();
if (metacard != null) {
for (Entry<String, Serializable> recordProperty : recordProperties.entrySet()) {
Attribute attribute = new AttributeImpl(recordProperty.getKey(), recordProperty.getValue());
metacard.setAttribute(attribute);
}
updatedMetacardIdsList.add(metacard.getId());
updatedMetacards.add(metacard);
}
}
if (updatedMetacardIdsList.size() > 0) {
String[] updatedMetacardIds = updatedMetacardIdsList.toArray(new String[updatedMetacardIdsList.size()]);
UpdateRequest updateRequest = new UpdateRequestImpl(updatedMetacardIds, updatedMetacards);
LOGGER.debug("Attempting to update {} metacards.", updatedMetacardIdsList.size());
UpdateResponse updateResponse = framework.update(updateRequest);
return updateResponse.getUpdatedMetacards().size();
}
}
}
return 0;
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class TestRegistryUtility method testInternalMetacardHasEmptyRegistryId.
@Test
public void testInternalMetacardHasEmptyRegistryId() {
metacard.setAttribute(blankRegistryIdAttribute);
tags.clear();
tags.add(RegistryConstants.REGISTRY_TAG_INTERNAL);
metacard.setAttribute(new AttributeImpl(Metacard.TAGS, tags));
assertThat(RegistryUtility.isInternalRegistryMetacard(metacard), is(false));
}
Aggregations