use of datawave.data.type.StringType in project datawave by NationalSecurityAgency.
the class FacetedTransformer method buildFacets.
/**
* Accepts an attribute. The document data will be placed into the value of the Field.
*
* @param documentKey
* @param fieldName
* @param attr
* @param topLevelColumnVisibility
* @param markingFunctions
* @return
*/
protected Collection<FieldCardinalityBase> buildFacets(Key documentKey, String fieldName, Attribute<?> attr, ColumnVisibility topLevelColumnVisibility, MarkingFunctions markingFunctions) {
Set<FieldCardinalityBase> myFields = new HashSet<>();
if (attr instanceof Attributes) {
Attributes attributeList = Attributes.class.cast(attr);
for (Attribute<?> embeddedAttr : attributeList.getAttributes()) myFields.addAll(buildFacets(documentKey, fieldName, embeddedAttr, topLevelColumnVisibility, markingFunctions));
} else {
// Use the markings on the Field if we're returning the markings to the client
if (attr instanceof Cardinality) {
try {
Cardinality card = (Cardinality) attr;
FieldValueCardinality v = card.getContent();
StringType value = new StringType();
value.setDelegate(v.toString());
value.setNormalizedValue(v.toString());
FieldCardinalityBase fc = this.responseObjectFactory.getFieldCardinality();
fc.setField(v.getFieldName());
// reduces colvis based on
fc.setMarkings(markingFunctions.translateFromColumnVisibilityForAuths(attr.getColumnVisibility(), auths));
// visibility
fc.setColumnVisibility(new String(markingFunctions.translateToColumnVisibility(fc.getMarkings()).flatten()));
fc.setLower(v.getFloorValue());
fc.setUpper(v.getCeilingValue());
fc.setCardinality(v.getEstimate().cardinality());
myFields.add(fc);
} catch (Exception e) {
log.error("unable to process markings:" + e);
}
}
}
return myFields;
}
use of datawave.data.type.StringType in project datawave by NationalSecurityAgency.
the class ShardQueryConfigurationTest method testGetSetIndexedFieldDataTypes.
@Test
public void testGetSetIndexedFieldDataTypes() {
Assert.assertEquals("", config.getIndexedFieldDataTypesAsString());
Set<String> indexedFields = Sets.newHashSet("fieldA", "fieldB");
Multimap<String, Type<?>> queryFieldsDatatypes = ArrayListMultimap.create();
queryFieldsDatatypes.put("fieldA", new DateType());
queryFieldsDatatypes.put("fieldB", new StringType());
config.setIndexedFields(indexedFields);
config.setQueryFieldsDatatypes(queryFieldsDatatypes);
String expected = "fieldA:datawave.data.type.DateType;fieldB:datawave.data.type.StringType;";
Assert.assertEquals(expected, config.getIndexedFieldDataTypesAsString());
}
use of datawave.data.type.StringType in project datawave by NationalSecurityAgency.
the class ShardQueryConfigurationTest method testGetSetNormalizedFieldNormalizers.
@Test
public void testGetSetNormalizedFieldNormalizers() {
Assert.assertEquals("", config.getNormalizedFieldNormalizersAsString());
Set<String> normalizedFields = Sets.newHashSet("fieldA", "fieldB");
Multimap<String, Type<?>> normalizedFieldsDatatypes = ArrayListMultimap.create();
normalizedFieldsDatatypes.put("fieldA", new DateType());
normalizedFieldsDatatypes.put("fieldB", new StringType());
config.setIndexedFields(normalizedFields);
config.setNormalizedFieldsDatatypes(normalizedFieldsDatatypes);
String expected = "fieldA:datawave.data.type.DateType;fieldB:datawave.data.type.StringType;";
Assert.assertEquals(expected, config.getNormalizedFieldNormalizersAsString());
}
Aggregations