use of ddf.catalog.data.MetacardType in project ddf by codice.
the class TestGenericXmlLib method testNoFactoriesTransform.
@Test
public void testNoFactoriesTransform() {
XmlInputTransformer xmlInputTransformer = new XmlInputTransformer();
xmlInputTransformer.setSaxEventHandlerConfiguration(Collections.singletonList("test"));
xmlInputTransformer.setSaxEventHandlerFactories(Collections.emptyList());
SaxEventHandlerDelegate delegate = xmlInputTransformer.create();
MetacardType metacardType = delegate.getMetacardType(xmlInputTransformer.getId());
assertThat(metacardType.getAttributeDescriptors(), is(BasicTypes.BASIC_METACARD.getAttributeDescriptors()));
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class ConfluenceSourceTest method setup.
@Before
public void setup() {
MetacardType type = new MetacardTypeImpl("confluence", (List) null);
transformer = new ConfluenceInputTransformer(type);
encryptionService = mock(EncryptionService.class);
reader = mock(ResourceReader.class);
factory = mock(SecureCxfClientFactory.class);
client = mock(SearchResource.class);
clientResponse = mock(Response.class);
when(factory.getClient()).thenReturn(client);
doReturn(clientResponse).when(client).search(anyString(), anyString(), anyString(), anyString(), anyInt(), anyInt(), anyBoolean());
when(encryptionService.decryptValue(anyString())).thenReturn("decryptedPass");
confluence = new TestConfluenceSource(adapter, encryptionService, transformer, reader, factory);
confluence.setAvailabilityPollInterval(1);
confluence.setConfigurationPid("configPid");
confluence.setEndpointUrl("https://confluence/rest/api/content");
confluence.setExpandedSections(Collections.singletonList("expandedField"));
confluence.setUsername("username");
confluence.setPassword("password");
confluence.setIncludeArchivedSpaces(false);
List<String> additionalAttributes = new ArrayList<>();
additionalAttributes.add("attrib1=val1");
additionalAttributes.add("attrib2=val1,val2,val3");
confluence.setAdditionalAttributes(additionalAttributes);
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class InspectCommand method executeWithSubject.
@Override
protected Object executeWithSubject() throws Exception {
if (id == null) {
return null;
}
Filter filter = filterBuilder.attribute(Metacard.ID).is().equalTo().text(id);
QueryImpl query = new QueryImpl(filter);
SourceResponse response = getCatalog().query(new QueryRequestImpl(query));
String formatString = "%1$s%2$-30s%3$s: %4$-25s %n";
String newLineFormatString = "%1$s%2$-30s%3$s %4$-25s %n";
if (response.getResults() != null && response.getResults().size() > 0) {
Metacard card = response.getResults().get(0).getMetacard();
MetacardType mType = card.getMetacardType();
String rClass = card.getClass().getName();
String siteShortName = card.getSourceId();
console.println("------------------------------");
console.printf(formatString, color(rClass), "Class", color(rClass), rClass);
console.printf(formatString, color(siteShortName), "Sitename", color(siteShortName), siteShortName);
for (AttributeDescriptor ad : mType.getAttributeDescriptors()) {
Attribute attribute = card.getAttribute(ad.getName());
Serializable value = null;
if (attribute != null) {
value = attribute.getValue();
}
// indent items with new lines in the value
if (value != null && (value.toString().contains("\r\n") || value.toString().contains("\n"))) {
String valueString = value.toString();
String[] values = valueString.split("\r\n");
if (values.length < 2) {
values = valueString.split("\n");
}
console.printf(formatString, color(attribute), ad.getName(), color(attribute), values[0]);
for (int i = 1; i < values.length; i++) {
console.printf(newLineFormatString, color(""), "", color(""), values[i]);
}
} else {
console.printf(formatString, color(attribute), ad.getName(), color(attribute), value);
}
}
// make sure we put the console default color back.
console.print(defaultColor());
console.println("------------------------------");
}
return null;
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class OperationsMetacardSupport method setDefaultValues.
/**
* Updates any empty metacard attributes with those defined in the
* {@link DefaultAttributeValueRegistry}.
*
* @param metacard the metacard to update with default attribute values
*/
void setDefaultValues(Metacard metacard) {
MetacardType metacardType = metacard.getMetacardType();
DefaultAttributeValueRegistry registry = frameworkProperties.getDefaultAttributeValueRegistry();
metacardType.getAttributeDescriptors().stream().map(AttributeDescriptor::getName).filter(attributeName -> hasNoValue(metacard.getAttribute(attributeName))).forEach(attributeName -> {
registry.getDefaultValue(metacardType.getName(), attributeName).ifPresent(defaultValue -> metacard.setAttribute(new AttributeImpl(attributeName, defaultValue)));
});
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class OverrideAttributesSupport method overrideMetacard.
public static Metacard overrideMetacard(Metacard currentMetacard, Metacard overrideMetacard, boolean ignoreType, boolean onlyFillNull) {
MetacardType updatedMetacardType = currentMetacard.getMetacardType();
if (!ignoreType && !BasicTypes.BASIC_METACARD.equals(overrideMetacard.getMetacardType())) {
updatedMetacardType = overrideMetacard.getMetacardType();
}
Metacard updatedMetacard = new MetacardImpl(currentMetacard, updatedMetacardType);
addAttributes(updatedMetacard, overrideMetacard, onlyFillNull);
return updatedMetacard;
}
Aggregations