use of org.opennms.newts.api.Resource in project opennms by OpenNMS.
the class NewtsResourceStorageDao method setStringAttribute.
@Override
public void setStringAttribute(ResourcePath path, String key, String value) {
// Create a mock sample referencing the resource
Map<String, String> attributes = new ImmutableMap.Builder<String, String>().put(key, value).build();
Resource resource = new Resource(toResourceId(path), Optional.of(attributes));
Sample sample = NewtsUtils.createSampleForIndexingStrings(m_context, resource);
// Index, but do not insert the sample(s)
// The key/value pair specified in the attributes map will be merged with the others.
m_newtsWriter.index(Lists.newArrayList(sample));
}
use of org.opennms.newts.api.Resource in project opennms by OpenNMS.
the class NewtsPersistOperationBuilder method getSamplesToIndex.
public List<Sample> getSamplesToIndex() {
final List<Sample> samples = Lists.newLinkedList();
// Convert string attributes to samples
for (Entry<ResourcePath, Map<String, String>> entry : m_stringAttributesByPath.entrySet()) {
Resource resource = new Resource(toResourceId(entry.getKey()), Optional.of(entry.getValue()));
samples.add(NewtsUtils.createSampleForIndexingStrings(m_context, resource));
}
return samples;
}
Aggregations