Search in sources :

Example 76 with AttributeImpl

use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.

the class FederationAdminServiceImplTest method getPopulatedRemoteTestRegistryMetacard.

private Metacard getPopulatedRemoteTestRegistryMetacard() {
    Metacard mcard = getPopulatedTestRegistryMetacard();
    mcard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REMOTE_REGISTRY_ID, "RemoteRegId"));
    return mcard;
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl)

Example 77 with AttributeImpl

use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.

the class FederationAdminServiceImplTest method testAddRegistryEntryWithInvalidMetacardNoRegistryTag.

@Test(expected = FederationAdminException.class)
public void testAddRegistryEntryWithInvalidMetacardNoRegistryTag() throws Exception {
    String destination = TEST_DESTINATION;
    Metacard metacard = getTestMetacard();
    metacard.setAttribute(new AttributeImpl(Metacard.TAGS, Collections.singletonList(null)));
    Set<String> destinations = new HashSet<>();
    destinations.add(destination);
    federationAdminServiceImpl.addRegistryEntry(metacard, destinations);
    verify(catalogFramework, never()).create(any(CreateRequest.class));
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateRequest(ddf.catalog.operation.CreateRequest) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 78 with AttributeImpl

use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.

the class FederationAdminServiceImplTest method testGetLocalRegistryObjectsWithEmptyMetadata.

@Test(expected = FederationAdminException.class)
public void testGetLocalRegistryObjectsWithEmptyMetadata() throws Exception {
    Metacard localMetacard = getTestMetacard();
    localMetacard.setAttribute(new AttributeImpl(Metacard.METADATA, ""));
    List<Metacard> localMetacards = new ArrayList<>();
    localMetacards.add(localMetacard);
    doReturn(localMetacards).when(federationAdminServiceImpl).getLocalRegistryMetacards();
    federationAdminServiceImpl.getLocalRegistryObjects();
    verify(parser, never()).unmarshal(any(ParserConfigurator.class), eq(JAXBElement.class), any(InputStream.class));
}
Also used : ParserConfigurator(org.codice.ddf.parser.ParserConfigurator) Metacard(ddf.catalog.data.Metacard) InputStream(java.io.InputStream) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

Example 79 with AttributeImpl

use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.

the class GenericFeatureConverter method unmarshal.

/**
     * This method will unmarshal an XML instance of a "gml:featureMember" to a {@link Metacard}.
     *
     * @param hreader the stream reader responsible for reading this xml doc
     * @param context a reference back to the Xstream unmarshalling context. Allows you to call
     *                "convertAnother" which will lookup other registered converters.
     */
@Override
public Object unmarshal(HierarchicalStreamReader hreader, UnmarshallingContext context) {
    LOGGER.debug("Entering: {} : unmarshal", this.getClass().getName());
    String fid = hreader.getAttribute(FID);
    MetacardImpl mc;
    if (metacardType != null) {
        mc = (MetacardImpl) createMetacardFromFeature(hreader, metacardType);
    } else {
        throw new IllegalArgumentException("No MetacardType registered on the FeatureConverter.  Unable to to convert features to metacards.");
    }
    mc.setId(fid);
    mc.setSourceId(sourceId);
    // set some default values that we can't get from a generic
    // featureCollection if they are not already set
    Date genericDate = new Date();
    if (mc.getEffectiveDate() == null) {
        mc.setEffectiveDate(genericDate);
    }
    ifAttributeSet(mc.getAttribute(Core.CREATED), attribute -> mc.setAttribute(new AttributeImpl(Core.CREATED, genericDate)));
    ifAttributeSet(mc.getAttribute(Core.MODIFIED), attribute -> mc.setAttribute(new AttributeImpl(Core.MODIFIED, genericDate)));
    ifAttributeSet(mc.getAttribute(Core.TITLE), attribute -> mc.setAttribute(new AttributeImpl(Core.MODIFIED, genericDate)));
    mc.setContentTypeName(metacardType.getName());
    try {
        mc.setTargetNamespace(new URI(WfsConstants.NAMESPACE_URN_ROOT + metacardType.getName()));
    } catch (URISyntaxException e) {
        LOGGER.debug("Unable to set Target Namespace on metacard: {}, Exception {}", WfsConstants.NAMESPACE_URN_ROOT + metacardType.getName(), e);
    }
    return mc;
}
Also used : AttributeImpl(ddf.catalog.data.impl.AttributeImpl) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Date(java.util.Date)

Example 80 with AttributeImpl

use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.

the class TestAttributeMetacardTransformer method testNotAString.

/**
     * Tests exception thrown for {@code null} string
     *
     * @throws CatalogTransformerException
     * @throws IOException
     */
@Test(expected = CatalogTransformerException.class)
public void testNotAString() throws CatalogTransformerException, IOException {
    Metacard mockMetacard = mock(Metacard.class);
    when(mockMetacard.getAttribute(isA(String.class))).thenReturn(new AttributeImpl(Metacard.METADATA, new Date()));
    METADATA_TRANSFORMER.transform(mockMetacard, null);
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) Date(java.util.Date) Test(org.junit.Test)

Aggregations

AttributeImpl (ddf.catalog.data.impl.AttributeImpl)181 Metacard (ddf.catalog.data.Metacard)109 Test (org.junit.Test)75 ArrayList (java.util.ArrayList)56 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)49 Serializable (java.io.Serializable)30 Date (java.util.Date)30 Attribute (ddf.catalog.data.Attribute)29 List (java.util.List)23 HashMap (java.util.HashMap)20 IOException (java.io.IOException)18 InputStream (java.io.InputStream)17 Result (ddf.catalog.data.Result)15 HashSet (java.util.HashSet)15 PolicyResponse (ddf.catalog.plugin.PolicyResponse)14 ResultImpl (ddf.catalog.data.impl.ResultImpl)11 UpdateRequestImpl (ddf.catalog.operation.impl.UpdateRequestImpl)11 Set (java.util.Set)11 ContentItem (ddf.catalog.content.data.ContentItem)10 QueryResponse (ddf.catalog.operation.QueryResponse)10