Search in sources :

Example 6 with SlotType1

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1 in project ddf by codice.

the class SlotTypeHelper method getNameSlotMapDuplicateSlotNamesAllowed.

/**
     * This is a convenience method that will iterate through the List of SlotType1 provided and return a mapping of SlotType1 name to a List of SlotType1s
     * * If multiple slots share the same name they will be added to the list
     *
     * @param slots the list of SlotType1s to be mapped, null returns empty map
     * @return a mapping of SlotType1 name to List of SlotType1
     */
public Map<String, List<SlotType1>> getNameSlotMapDuplicateSlotNamesAllowed(List<SlotType1> slots) {
    Map<String, List<SlotType1>> slotMap = new HashMap<>();
    if (CollectionUtils.isNotEmpty(slots)) {
        for (SlotType1 slot : slots) {
            slotMap.putIfAbsent(slot.getName(), new ArrayList<>());
            slotMap.get(slot.getName()).add(slot);
        }
    }
    return slotMap;
}
Also used : SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with SlotType1

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1 in project ddf by codice.

the class SourceConfigurationHandler method getServiceBindingProperties.

/**
     * Returns the service binding slots as a map of string properties with the slot name as the key
     *
     * @param binding ServiceBindingType to generate the map from
     * @return A map of service binding slots
     */
private Map<String, Object> getServiceBindingProperties(ServiceBindingType binding) {
    Map<String, Object> properties = new HashMap<>();
    for (SlotType1 slot : binding.getSlot()) {
        List<String> slotValues = slotHelper.getStringValues(slot);
        if (CollectionUtils.isEmpty(slotValues)) {
            continue;
        }
        properties.put(slot.getName(), slotValues.size() == 1 ? slotValues.get(0) : slotValues);
    }
    if (binding.isSetAccessURI() && properties.get(urlBindingName) != null) {
        properties.put(properties.get(urlBindingName).toString(), binding.getAccessURI());
    }
    return properties;
}
Also used : SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 8 with SlotType1

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1 in project ddf by codice.

the class SlotTypeHelperTest method testGetSlotByName.

@Test
public void testGetSlotByName() throws Exception {
    List<SlotType1> slots = registryObject.getSlot();
    Map<String, SlotType1> slotMap = stHelper.getNameSlotMap(slots);
    for (String slotName : slotMap.keySet()) {
        SlotType1 slot = slotMap.get(slotName);
        assertThat(slot, is(equalTo(stHelper.getSlotByName(slotName, slots))));
    }
}
Also used : SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) Test(org.junit.Test)

Example 9 with SlotType1

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1 in project ddf by codice.

the class SlotTypeHelperTest method getDateValues.

@Test
public void getDateValues() throws Exception {
    List<SlotType1> slots = registryObject.getSlot();
    int expectedSize = 1;
    for (SlotType1 slot : slots) {
        String slotTypeUC = slot.getSlotType().toUpperCase();
        if (slotTypeUC.contains("DATE")) {
            List<Date> dates = stHelper.getDateValues(slot);
            assertThat(dates, hasSize(expectedSize));
        }
    }
}
Also used : SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) Date(java.util.Date) Test(org.junit.Test)

Example 10 with SlotType1

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1 in project ddf by codice.

the class SlotTypeHelperTest method getNameSlotMapDuplicateSlotNamesAllowed.

@Test
public void getNameSlotMapDuplicateSlotNamesAllowed() throws Exception {
    RegistryObjectType rot = getRegistryObjectFromResource("/registry-package-slots-only-with-dup.xml");
    List<SlotType1> slots = rot.getSlot();
    String duplicateSlotCase = "serviceType";
    int expectedSize = 1;
    int expectedServiceTypeSize = 2;
    Map<String, List<SlotType1>> slotMap = stHelper.getNameSlotMapDuplicateSlotNamesAllowed(slots);
    for (SlotType1 slot : slots) {
        String slotName = slot.getName();
        // duplicate slotCase
        if (duplicateSlotCase.equals(slotName)) {
            continue;
        }
        assertThat(slotMap, hasKey(slotName));
        assertThat(slotMap.get(slotName), hasSize(expectedSize));
        SlotType1 mappedSlot = slotMap.get(slotName).get(0);
        assertThat(mappedSlot, is(equalTo(slot)));
    }
    // ServiceType slot is repeated in the test xml
    // Testing that both slots(SOAP & REST) are stored
    List<SlotType1> serviceTypes = slotMap.get(duplicateSlotCase);
    assertThat(serviceTypes, notNullValue());
    assertThat(serviceTypes, hasSize(expectedServiceTypeSize));
    for (SlotType1 serviceTypeSlot : serviceTypes) {
        String value = stHelper.getStringValues(serviceTypeSlot).get(0);
        assertThat(value, anyOf(equalTo("SOAP"), equalTo("REST")));
    }
}
Also used : SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) ArrayList(java.util.ArrayList) List(java.util.List) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType) Test(org.junit.Test)

Aggregations

SlotType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1)23 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)7 List (java.util.List)6 HashMap (java.util.HashMap)5 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)5 ValueListType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ValueListType)5 JAXBElement (javax.xml.bind.JAXBElement)4 Map (java.util.Map)3 AnyValueType (net.opengis.cat.wrs.v_1_0_2.AnyValueType)3 ValueListType (net.opengis.cat.wrs.v_1_0_2.ValueListType)3 DirectPositionType (net.opengis.gml.v_3_1_1.DirectPositionType)3 EnvelopeType (net.opengis.gml.v_3_1_1.EnvelopeType)3 PointType (net.opengis.gml.v_3_1_1.PointType)3 ClassificationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType)3 RegistryObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)3 OffsetDateTime (java.time.OffsetDateTime)2 Collectors (java.util.stream.Collectors)2 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)2 ServiceBindingType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceBindingType)2